#define OP_RES_FN( fname, SLHSTYPE, SRHSTYPE, SRESTYPE, \
LHSTYPE, RHSTYPE, RESTYPE ) \
-SRESTYPE sv_proc_t::rv_##fname (SLHSTYPE const & lhs, SRHSTYPE const & rhs) \
+SRESTYPE sv_proc_t::rv##fname (SLHSTYPE const & lhs, SRHSTYPE const & rhs) \
{ \
uint8_t bitwidth = _insn->src_bitwidth; \
LHSTYPE vlhs = 0; \
return SRESTYPE(result); \
} \
RESTYPE result = vlhs fname vrhs; \
- fprintf(stderr, "%s result %lx %lx %d bw %d\n", \
+ 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); \
}
-#define add +
-#define sub -
-#define div /
-#define rem %
-#define mul *
-
-OP_RES_FN ( add, sv_reg_t, sv_reg_t, sv_reg_t, uint64_t, uint64_t, uint64_t )
-OP_RES_FN ( sub, sv_reg_t, sv_reg_t, sv_reg_t, uint64_t, uint64_t, uint64_t )
-OP_RES_FN ( div, sv_reg_t, sv_reg_t, sv_reg_t, uint64_t, uint64_t, uint64_t )
-OP_RES_FN ( div, sv_sreg_t, sv_sreg_t, sv_sreg_t, int64_t, int64_t, int64_t )
-OP_RES_FN ( rem, sv_reg_t, sv_reg_t, sv_reg_t, uint64_t, uint64_t, uint64_t )
-OP_RES_FN ( rem, sv_sreg_t, sv_sreg_t, sv_sreg_t, int64_t, int64_t, int64_t )
-OP_RES_FN ( mul, sv_reg_t, sv_reg_t, sv_reg_t, uint64_t, uint64_t, uint64_t )
-OP_RES_FN ( mul, sv_sreg_t, sv_reg_t, sv_sreg_t, int64_t, uint64_t, int64_t )
-OP_RES_FN ( mul, sv_sreg_t, sv_sreg_t, sv_sreg_t, int64_t, int64_t, int64_t )
+#define _add +
+#define _sub -
+#define _and &
+#define _or |
+#define _xor ^
+#define _div /
+#define _rem %
+#define _mul *
+
+OP_RES_FN ( _add, sv_reg_t, sv_reg_t, sv_reg_t, uint64_t, uint64_t, uint64_t )
+OP_RES_FN ( _sub, sv_reg_t, sv_reg_t, sv_reg_t, uint64_t, uint64_t, uint64_t )
+OP_RES_FN ( _and, sv_reg_t, sv_reg_t, sv_reg_t, uint64_t, uint64_t, uint64_t )
+OP_RES_FN ( _or , sv_reg_t, sv_reg_t, sv_reg_t, uint64_t, uint64_t, uint64_t )
+OP_RES_FN ( _xor, sv_reg_t, sv_reg_t, sv_reg_t, uint64_t, uint64_t, uint64_t )
+OP_RES_FN ( _div, sv_reg_t, sv_reg_t, sv_reg_t, uint64_t, uint64_t, uint64_t )
+OP_RES_FN ( _div, sv_sreg_t, sv_sreg_t, sv_sreg_t, int64_t, int64_t, int64_t )
+OP_RES_FN ( _rem, sv_reg_t, sv_reg_t, sv_reg_t, uint64_t, uint64_t, uint64_t )
+OP_RES_FN ( _rem, sv_sreg_t, sv_sreg_t, sv_sreg_t, int64_t, int64_t, int64_t )
+OP_RES_FN ( _mul, sv_reg_t, sv_reg_t, sv_reg_t, uint64_t, uint64_t, uint64_t )
+OP_RES_FN ( _mul, sv_sreg_t, sv_reg_t, sv_sreg_t, int64_t, uint64_t, int64_t )
+OP_RES_FN ( _mul, sv_sreg_t, sv_sreg_t, sv_sreg_t, int64_t, int64_t, int64_t )
/* 32-bit mulh/mulhu/mulhsu */
sv_reg_t sv_proc_t::rv_mulhu(sv_reg_t const & lhs, sv_reg_t const & rhs)
return sv_reg_t(::mulhu(a, b));
}
-sv_reg_t sv_proc_t::rv_and(sv_reg_t const & lhs, sv_reg_t const & rhs)
-{
- return lhs & rhs;
-}
-
-sv_reg_t sv_proc_t::rv_or(sv_reg_t const & lhs, sv_reg_t const & rhs)
-{
- return lhs | rhs;
-}
-
-sv_reg_t sv_proc_t::rv_xor(sv_reg_t const & lhs, sv_reg_t const & rhs)
-{
- return lhs ^ rhs;
-}
-
sv_reg_t sv_proc_t::rv_sl(sv_reg_t const & lhs, sv_reg_t const & rhs)
{
return rv_sl(lhs, rhs, xlen);