From e2b71c848f2e12c27bb2ac304d5e22d4929d3b0c Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Thu, 25 Oct 2018 08:30:41 +0100 Subject: [PATCH] overload READ_REG --- riscv/insn_template_sv.cc | 12 ++++++------ riscv/sv.cc | 25 +++++++++++++++---------- riscv/sv_insn_redirect.cc | 20 +++++++++++++------- riscv/sv_insn_redirect.h | 3 ++- 4 files changed, 36 insertions(+), 24 deletions(-) diff --git a/riscv/insn_template_sv.cc b/riscv/insn_template_sv.cc index 5de338f..03ac631 100644 --- a/riscv/insn_template_sv.cc +++ b/riscv/insn_template_sv.cc @@ -186,23 +186,23 @@ reg_t sv_proc_t::FN(processor_t* p, insn_t s_insn, reg_t pc) "vlen %d stop %d pred %lx rdv %lx v %ld rvc2 %ld sp %lx\n", xstr(INSN), INSNCODE, voffs, *src_offs, *dest_offs, vlen, insn.stop_vloop(), - dest_pred & (1<zero; reg = r->regidx; - reg_t predicate = READ_REG(reg); // macros go through processor_t state + reg_spec_t rs = {reg, NULL}; + reg_t predicate = p->s.READ_REG(rs); // macros go through processor_t state if (r->inv) { return ~predicate; @@ -220,6 +218,10 @@ reg_t sv_insn_t::predicate(uint64_t reg, bool intreg, bool &zeroing) reg_spec_t sv_insn_t::predicated(reg_spec_t const& spec, uint64_t pred) { reg_spec_t res = spec; + //if (spec.offset == NULL) + //{ + // return res; + //} if (pred & (1<<(*spec.offset))) { return res; @@ -261,7 +263,9 @@ 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 val = READ_REG(reg); + //reg_spec_t rs = {reg, NULL}; + //uint64_t val = p->s.READ_REG(rs); + uint64_t val = STATE.XPR[reg]; if (set) { val |= (1<s.READ_REG(rs), prs1); } if ((1<s.READ_REG(rs1()), p->s.READ_REG(rs2())); } uint8_t sv_insn_t::reg_elwidth(reg_t reg, bool intreg) diff --git a/riscv/sv_insn_redirect.cc b/riscv/sv_insn_redirect.cc index da1732b..3ad3505 100644 --- a/riscv/sv_insn_redirect.cc +++ b/riscv/sv_insn_redirect.cc @@ -82,7 +82,11 @@ void (sv_proc_t::WRITE_RD)(sv_reg_t const& value) void (sv_proc_t::WRITE_REG)(reg_spec_t const& spec, sv_reg_t const& value) { //WRITE_REG( reg, value ); // XXX TODO: replace properly - STATE.XPR.write(spec.reg, value); + reg_t reg = spec.reg; + //if (spec.offset) { + // reg += *spec.offset; + //} + STATE.XPR.write(reg, value); } //void (sv_proc_t::WRITE_REG)(reg_t reg, uint64_t value) @@ -103,17 +107,19 @@ void (sv_proc_t::WRITE_RD)(uint_fast64_t value) } */ -/* -sv_reg_t (sv_proc_t::READ_REG)(uint64_t i) +reg_t (sv_proc_t::READ_REG)(reg_spec_t const& spec) { - return READ_REG ( i ); + reg_t reg = spec.reg; + uint8_t elwidth = _insn->reg_elwidth(reg, true); + //if (spec.offset) { + // reg += *spec.offset; + //} + return _insn->p->get_state()->XPR[reg]; // XXX TODO: offset } -*/ sv_reg_t sv_proc_t::get_intreg(reg_spec_t const&spec) { - uint8_t elwidth = _insn->reg_elwidth(spec.reg, true); - uint64_t data = _insn->p->get_state()->XPR[spec.reg]; // XXX TODO: offset + uint64_t data = READ_REG(spec); uint8_t bitwidth = _insn->src_bitwidth; return sv_reg_t(data, xlen, bitwidth); } diff --git a/riscv/sv_insn_redirect.h b/riscv/sv_insn_redirect.h index af2b67f..39dc5e1 100644 --- a/riscv/sv_insn_redirect.h +++ b/riscv/sv_insn_redirect.h @@ -24,6 +24,7 @@ #undef WRITE_RVC_RS2S #undef WRITE_RVC_FRS2S #undef WRITE_RD +#undef READ_REG #undef RVC_SP #undef SHAMT #undef sext_xlen @@ -76,7 +77,7 @@ public: void (WRITE_FRD)(freg_t value); void (WRITE_FRD)(float64_t value); void (WRITE_FRD)(float32_t value); - //reg_t (READ_REG)(uint64_t i); + reg_t (READ_REG)(reg_spec_t const& i); processor_t *p; sv_insn_t *_insn; -- 2.30.2