OP_M64_FN( mulhsu, sv_sreg_t, sv_reg_t, sv_sreg_t, int64_t, uint64_t, int64_t )
OP_M64_FN( mulh , sv_sreg_t, sv_sreg_t, sv_sreg_t, int64_t, int64_t, int64_t )
-sv_reg_t sv_proc_t::rv_sl(sv_reg_t const & lhs, sv_reg_t const & rhs,
- unsigned int dflt_bitwidth)
-{
- uint8_t bitwidth = _insn->src_bitwidth;
- uint64_t vlhs = 0;
- uint64_t vrhs = 0;
- if (rv_int_op_prepare(lhs, rhs, vlhs, vrhs, bitwidth)) {
- sv_reg_t result = lhs << rv_and(rhs, sv_reg_t(dflt_bitwidth-1U));
- fprintf(stderr, "sl result %lx %lx %lx\n",
- (uint64_t)lhs, (uint64_t)rhs, (uint64_t)(result));
- return result;
- }
- uint64_t result = vlhs << (vrhs & (bitwidth-1));
- return rv_int_op_finish(lhs, rhs, result, bitwidth);
+#define OP_SHF_FN( fname, SLHSTYPE, SRHSTYPE, SRESTYPE, \
+ LHSTYPE, RHSTYPE, RESTYPE ) \
+SRESTYPE sv_proc_t::rv##fname (SLHSTYPE const & lhs, SRHSTYPE const & rhs, \
+ unsigned int dflt_bitwidth) \
+{ \
+ uint8_t bitwidth = _insn->src_bitwidth; \
+ LHSTYPE vlhs = 0; \
+ RHSTYPE vrhs = 0; \
+ if (rv_int_op_prepare(lhs, rhs, vlhs, vrhs, bitwidth)) { \
+ RESTYPE result = lhs fname rv_and(rhs, sv_reg_t(dflt_bitwidth-1U)); \
+ fprintf(stderr, "%s result %lx %lx %lx\n", \
+ xstr(fname), (LHSTYPE)lhs, (RHSTYPE)rhs, (RESTYPE)result); \
+ return SRESTYPE(result); \
+ } \
+ RESTYPE result = vlhs fname (vrhs & (bitwidth-1)); \
+ fprintf(stderr, "%s result %lx %lx %lx bw %d\n", \
+ xstr(fname), (LHSTYPE)lhs, (RHSTYPE)rhs, (RESTYPE)result, bitwidth); \
+ return rv_int_op_finish(lhs, rhs, result, bitwidth); \
}
-sv_reg_t sv_proc_t::rv_sr(sv_reg_t const & lhs, sv_reg_t const & rhs,
- unsigned int dflt_bitwidth)
-{
- uint8_t bitwidth = _insn->src_bitwidth;
- uint64_t vlhs = 0;
- uint64_t vrhs = 0;
- if (rv_int_op_prepare(lhs, rhs, vlhs, vrhs, bitwidth)) {
- sv_reg_t result = lhs >> rv_and(rhs, sv_reg_t(dflt_bitwidth-1U));
- fprintf(stderr, "sr result %lx %lx %lx\n",
- (uint64_t)lhs, (uint64_t)rhs, (uint64_t)(result));
- return result;
- }
- uint64_t result = vlhs >> (vrhs & (bitwidth-1));
- sv_reg_t sresult = rv_int_op_finish(lhs, rhs, result, bitwidth);
- fprintf(stderr, "sr result %lx %lx %lx bw %d\n",
- (uint64_t)lhs, (uint64_t)rhs, (uint64_t)(sresult), bitwidth);
- return sresult;
-}
+#define _sl <<
+#define _sr >>
+
+OP_SHF_FN ( _sl, sv_reg_t, sv_reg_t, sv_reg_t, uint64_t, uint64_t, uint64_t )
+OP_SHF_FN ( _sr, sv_reg_t, sv_reg_t, sv_reg_t, uint64_t, uint64_t, uint64_t )
#define lt <
#define gt >