require_extension('C');
require(insn.insn_t::rvc_rd() != 0);
-WRITE_RD(MMU.load_int32(rv_add(RVC_SP, insn.rvc_lwsp_imm())));
+WRITE_RD(MMU.load_int32(insn.rvc_sp(false), insn.rvc_lwsp_imm()));
reg_spec_t rvc_rs1s() { return predicated(_rvc_rs1s(), prs1); }
reg_spec_t rvc_rs2 () { return predicated(_rvc_rs2 (), prs2); }
reg_spec_t rvc_rs2s() { return predicated(_rvc_rs2s(), prs2); }
- reg_spec_t rvc_sp () { return predicated(_rvc_sp (), psp ); }
+ reg_spec_t rvc_sp (bool use_offs=true)
+ { return predicated(_rvc_sp (use_offs), psp ); }
reg_spec_t _rd () { return _remap(insn_t::rd (), fimap & REG_RD , offs_rd); }
reg_spec_t _rs1() { return _remap(insn_t::rs1(), fimap & REG_RS1, offs_rs1); }
offs_rs2); }
reg_spec_t _rvc_rs2s() { return _remap(insn_t::rvc_rs2s(), fimap & REG_RVC_RS2S,
offs_rs2); }
- reg_spec_t _rvc_sp () { return _remap(2, true, // sp always 2, always int
- offs_sp); }
+ reg_spec_t _rvc_sp (bool use_offs=true)
+ { return _remap(2, true, // sp always 2, always int
+ use_offs ? offs_sp : NULL); }
void setpc(int xlen, int vlen, reg_t &npc, reg_t addr, uint64_t offs,
reg_t *target_reg);
int bitwidth = get_bitwidth(_insn->reg_elwidth(reg, true), xlen);
int shift = 0;
int offs = 0;
- if (spec.offset != NULL && spec.reg != 2) { // XXX HACK on spec.reg != 2
+ if (spec.offset != NULL) {
int nbytes = width / bitwidth;
if (nbytes == 0) {
nbytes = 1;
// gets element within the reg-block
ndata = data >> (shift*bitwidth);
ndata &= ((1UL<<bitwidth)-1UL); // masks off the right bits
- fprintf(stderr, "readreg %ld bitwidth %d offs %d " \
- "shift %d %lx->%lx\n",
- spec.reg, bitwidth, offs, shift, data, ndata);
}
+ fprintf(stderr, "readreg %ld bitwidth %d offs %d " \
+ "shift %d %lx->%lx\n",
+ spec.reg, bitwidth, offs, shift, data, ndata);
}
return ndata;
}