From 5fd7f0ef97e364f6ab7111c31b3d895d0c339495 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Thu, 15 Nov 2018 23:23:13 +0000 Subject: [PATCH] add predication remap option --- riscv/processor.cc | 7 +++++-- riscv/processor.h | 2 +- riscv/sv.cc | 13 ++++++------- riscv/sv.h | 4 ++++ riscv/sv_decode.h | 2 +- riscv/sv_insn_redirect.cc | 4 ++-- riscv/sv_insn_redirect.h | 2 +- 7 files changed, 20 insertions(+), 14 deletions(-) diff --git a/riscv/processor.cc b/riscv/processor.cc index 773fab8..f84aa8f 100644 --- a/riscv/processor.cc +++ b/riscv/processor.cc @@ -193,13 +193,13 @@ sv_csr_t &state_t::sv() return get_usv(); } -sv_shape_t* state_t::get_shape(reg_t reg) +sv_shape_t* state_t::get_shape(reg_t reg, bool pred) { if (prv == PRV_M || prv == PRV_S || reg == 0) { return NULL; } for (int i = 0; i < 3; i++) { - if (remap[i].regidx == reg) { + if (remap[i].regidx == reg && remap[i].pred == pred) { return &shape[i]; } } @@ -614,6 +614,9 @@ reg_t processor_t::set_csr(int which, reg_t val, bool imm_mode) state.remap[0].regidx = get_field(val, SV_REMAP_REGIDX0); state.remap[1].regidx = get_field(val, SV_REMAP_REGIDX1); state.remap[2].regidx = get_field(val, SV_REMAP_REGIDX2); + state.remap[0].pred = get_field(val, SV_REMAP_PRED0); + state.remap[1].pred = get_field(val, SV_REMAP_PRED1); + state.remap[2].pred = get_field(val, SV_REMAP_PRED2); state.remap[0].shape = get_field(val, SV_REMAP_SHAPE0); state.remap[1].shape = get_field(val, SV_REMAP_SHAPE1); state.remap[2].shape = get_field(val, SV_REMAP_SHAPE2); diff --git a/riscv/processor.h b/riscv/processor.h index 4a7fee8..efd8945 100644 --- a/riscv/processor.h +++ b/riscv/processor.h @@ -168,7 +168,7 @@ struct state_t sv_remap_t remap[3]; sv_shape_t shape[3]; - sv_shape_t *get_shape(reg_t reg); + sv_shape_t *get_shape(reg_t reg, bool pred=false); void sv_csr_reg_unpack(); void sv_csr_pred_unpack(); void get_csr_start_end(int &start, int &end); diff --git a/riscv/sv.cc b/riscv/sv.cc index 2096351..8f24631 100644 --- a/riscv/sv.cc +++ b/riscv/sv.cc @@ -277,15 +277,14 @@ uint64_t sv_insn_t::_rvc_spoffs_imm(uint64_t elwidth, uint64_t offs) } // for use in predicated branches. sets bit N if val=true; clears bit N if false -uint64_t sv_insn_t::rd_bitset(reg_t reg, uint64_t bit, bool set) +uint64_t sv_insn_t::rd_bitset(reg_t reg, int bit, bool set) { - //reg_spec_t rs = {reg, NULL}; - //uint64_t val = p->s.READ_REG(rs); + reg_spec_t rs = {reg, &bit}; uint64_t val = STATE.XPR[reg]; if (set) { - val |= (1<get_state()->get_shape(spec.reg); + sv_shape_t *shape = p->get_state()->get_shape(spec.reg, pred); if (shape == NULL) { return offs; } diff --git a/riscv/sv_insn_redirect.h b/riscv/sv_insn_redirect.h index c90eb67..e510b4e 100644 --- a/riscv/sv_insn_redirect.h +++ b/riscv/sv_insn_redirect.h @@ -265,7 +265,7 @@ public: sv_reg_t to_uint32(sv_freg_t const& reg); sv_reg_t to_uint32(sv_float32_t const& reg); - unsigned int remap(reg_spec_t const& regspec); + unsigned int remap(reg_spec_t const& regspec, bool pred=false); bool rv_int_op_prepare(sv_reg_t const & lhs, sv_reg_t const & rhs, uint64_t &vlhs, uint64_t &vrhs, -- 2.30.2