}
}
-/*
-int to_elwidth(uint8_t bitwidth, int xlen)
+uint8_t maxelwidth(uint8_t wid1, uint8_t wid2)
{
- switch (bitwidth) {
- case xlen: return 0;
- case 8: return 1;
- case 16: return 2;
- default: return 3;
- }
+ if (wid1 == 0 || wid2 == 0) {
+ return 0;
+ }
+ return std::max(wid1, wid2);
}
-*/
sv_insn_t::sv_insn_t(processor_t *pr, bool _sv_enabled,
insn_bits_t bits, unsigned int f, int _xlen,
} else { // nope: zero-extend.
result = zext_bwid(result, bitwidth);
}
- return sv_reg_t(result, xlen); // XXX TODO: bitwidth
+ uint8_t reswidth = maxelwidth(lhs.get_elwidth(), rhs.get_elwidth());
+ return sv_reg_t(result, xlen, reswidth); // XXX TODO: bitwidth
}
sv_reg_t sv_proc_t::rv_sub(sv_reg_t const & lhs, sv_reg_t const & rhs)
#define zext_bwid(x,wid) (((reg_t)(x) << (64-wid)) >> (64-wid))
extern int get_bitwidth(uint8_t elwidth, int xlen);
-//extern int to_elwidth(uint8_t bitwidth, int xlen);
+extern uint8_t maxelwidth(uint8_t bwid1, uint8_t bwid2);
class sv_sreg_t;