Skip to content

Commit

Permalink
i#3544 RV64: Preserve vtype and vl vector registers
Browse files Browse the repository at this point in the history
Applied the feedbacke recieved by reviwers

Issue: #3544
  • Loading branch information
mariospaok4 committed Dec 17, 2024
1 parent efb52d0 commit a8227b9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 34 deletions.
18 changes: 2 additions & 16 deletions core/arch/riscv64/emit_utils.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* **********************************************************
* Copyright (c) 2022 Rivos, Inc. All rights reserved.
* Copyright (c) 2024 Foundation of Research and Technology, Hellas.
* **********************************************************/

/*
Expand Down Expand Up @@ -664,19 +665,12 @@ append_restore_xflags(dcontext_t *dcontext, instrlist_t *ilist, bool absolute)
opnd_create_reg(DR_REG_A0),
opnd_create_immed_int(VCSR, OPSZ_12b)));

/*
* The code below is contributed and copyrighted by FORTH
* Copyright (c) 2024 Foundation of Research and Technology, Hellas.
* All other rights reserved.
*/
APP(ilist, RESTORE_FROM_DC(dcontext, DR_REG_A0, VL_OFFSET));
APP(ilist, RESTORE_FROM_DC(dcontext, DR_REG_A1, VTYPE_OFFSET));
APP(ilist,
INSTR_CREATE_vsetvl(dcontext, opnd_create_reg(DR_REG_A0),
opnd_create_reg(DR_REG_A0), opnd_create_reg(DR_REG_A1)));
/*
* End of FORTH copyrighted section
*/

}
}

Expand Down Expand Up @@ -894,11 +888,6 @@ append_save_clear_xflags(dcontext_t *dcontext, instrlist_t *ilist, bool absolute
opnd_create_immed_int(VCSR, OPSZ_12b)));
APP(ilist, SAVE_TO_DC(dcontext, DR_REG_A1, VCSR_OFFSET));

/*
* The code below is contributed and copyrighted by FORTH
* Copyright (c) 2024 Foundation of Research and Technology, Hellas.
* All other rights reserved.
*/
APP(ilist,
INSTR_CREATE_csrrs(dcontext, opnd_create_reg(DR_REG_A1),
opnd_create_reg(DR_REG_ZERO),
Expand All @@ -909,9 +898,6 @@ append_save_clear_xflags(dcontext_t *dcontext, instrlist_t *ilist, bool absolute
opnd_create_reg(DR_REG_ZERO),
opnd_create_immed_int(VTYPE, OPSZ_12b)));
APP(ilist, SAVE_TO_DC(dcontext, DR_REG_A1, VTYPE_OFFSET));
/*
* End of FORTH copyrighted section
*/
}
}

Expand Down
18 changes: 2 additions & 16 deletions core/arch/riscv64/mangle.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* **********************************************************
* Copyright (c) 2022 Rivos, Inc. All rights reserved.
* Copyright (c) 2024 Foundation of Research and Technology, Hellas.
* **********************************************************/

/*
Expand Down Expand Up @@ -193,14 +194,8 @@ insert_push_all_registers(dcontext_t *dcontext, clean_call_info_t *cci,
}

dstack_offs += XSP_SZ;

/*
* The code below is contributed and copyrighted by FORTH
* Copyright (c) 2024 Foundation of Research and Technology, Hellas.
* All other rights reserved.
*/

if (proc_has_feature(FEATURE_VECTOR)) {
/* csrr a0, vl */
PRE(ilist, instr,
INSTR_CREATE_csrrs(dcontext, opnd_create_reg(DR_REG_A0),
opnd_create_reg(DR_REG_ZERO),
Expand All @@ -213,13 +208,7 @@ insert_push_all_registers(dcontext_t *dcontext, clean_call_info_t *cci,

dstack_offs += XSP_SZ;

/*
* The code below is contributed and copyrighted by FORTH
* Copyright (c) 2024 Foundation of Research and Technology, Hellas.
* All other rights reserved.
*/
if (proc_has_feature(FEATURE_VECTOR)) {
/* csrr a0, vtype */
PRE(ilist, instr,
INSTR_CREATE_csrrs(dcontext, opnd_create_reg(DR_REG_A0),
opnd_create_reg(DR_REG_ZERO),
Expand All @@ -231,9 +220,6 @@ insert_push_all_registers(dcontext_t *dcontext, clean_call_info_t *cci,
}

dstack_offs += 2 * XSP_SZ;
/*
* End of FORTH copyrighted section
*/

/* Push vector registers. */
if (proc_has_feature(FEATURE_VECTOR)) {
Expand Down
4 changes: 2 additions & 2 deletions core/lib/mcxtx_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,8 @@
reg_t fcsr; /**< Floating-Point Control Register. */
reg_t vstart; /**< Vector Start Index CSR. */
reg_t vcsr; /**< Vector Control and Status Register. */
reg_t vl;
reg_t vtype;
reg_t vl; /**< Vector Length Register. */
reg_t vtype; /**< Vector Type Register. */
/** The Vector registers. */
dr_simd_t simd[MCXT_NUM_SIMD_SLOTS];
#else /* RISCV64 */
Expand Down

0 comments on commit a8227b9

Please sign in to comment.