1 // See LICENSE for license details.
3 #ifndef _RISCV_SV_DECODE_H
4 #define _RISCV_SV_DECODE_H
14 #define REG_RVC_RS1 0x10
15 #define REG_RVC_RS2 0x20
16 #define REG_RVC_RS1S 0x40
17 #define REG_RVC_RS2S 0x80
20 class sv_insn_t
: public insn_t
23 sv_insn_t(processor_t
*pr
, insn_bits_t bits
, unsigned int f
) :
24 insn_t(bits
), p(pr
), vloop_continue(true), fimap(f
),
25 cached_rd(0xff), cached_rs1(0xff),
26 cached_rs2(0xff), cached_rs3(0xff),
27 offs_rd(0), offs_rs1(0),
28 offs_rs2(0), offs_rs3(0) {}
30 { return _remap(insn_t::rd (), fimap
& REG_RD
, offs_rd
, cached_rd
); }
32 { return _remap(insn_t::rs1(), fimap
& REG_RS1
, offs_rs1
, cached_rs1
); }
34 { return _remap(insn_t::rs2(), fimap
& REG_RS2
, offs_rs2
, cached_rs2
); }
36 { return _remap(insn_t::rs3(), fimap
& REG_RS3
, offs_rs3
, cached_rs3
); }
38 { return _remap(insn_t::rvc_rs1(), fimap
& REG_RVC_RS1
,
39 offs_rs1
, cached_rs1
); }
41 { return _remap(insn_t::rvc_rs1s(), fimap
& REG_RVC_RS1S
,
42 offs_rs1
, cached_rs1
); }
44 { return _remap(insn_t::rvc_rs2(), fimap
& REG_RVC_RS2
,
45 offs_rs2
, cached_rs2
); }
47 { return _remap(insn_t::rvc_rs2s(), fimap
& REG_RVC_RS2S
,
48 offs_rs2
, cached_rs2
); }
50 void reset_caches(void)
58 bool sv_check_reg(bool intreg
, uint64_t reg
);
59 sv_reg_entry
* get_regentry(uint64_t reg
, bool isint
);
60 sv_pred_entry
* get_predentry(uint64_t reg
, bool isint
);
61 reg_t
predicate(uint64_t reg
, bool isint
, bool &zeroing
);
63 void reset_vloop_check(void) { vloop_continue
= true; }
64 bool stop_vloop(void) { return !vloop_continue
; }
78 // remaps the register through the lookup table.
79 // will need to take the current loop index/offset somehow
80 uint64_t remap(uint64_t reg
, bool isint
, int &offs
);
82 // cached version of remap: if remap is called multiple times
83 // by an emulated instruction it would increment the loop offset
84 // before it's supposed to.
85 uint64_t _remap(uint64_t reg
, bool isint
, int &offs
, uint64_t &cached
)
89 cached
= remap(reg
, isint
, offs
);
91 else if (!sv_check_reg(isint
, reg
))
93 vloop_continue
= false;