From: Luke Kenneth Casson Leighton Date: Fri, 9 Nov 2018 10:25:27 +0000 (+0000) Subject: macroify rv_and, rv_or, rv_xor X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=061475856b1edf670d2eab5b332501bbe532f467;p=riscv-isa-sim.git macroify rv_and, rv_or, rv_xor --- diff --git a/riscv/sv_insn_redirect.cc b/riscv/sv_insn_redirect.cc index 5703251..c1f2f7b 100644 --- a/riscv/sv_insn_redirect.cc +++ b/riscv/sv_insn_redirect.cc @@ -484,7 +484,7 @@ OP_PREP_FINISH(sv_sreg_t, sv_sreg_t, sv_sreg_t, int64_t, int64_t, int64_t) #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; \ @@ -496,26 +496,32 @@ SRESTYPE sv_proc_t::rv_##fname (SLHSTYPE const & lhs, SRHSTYPE const & rhs) \ 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) @@ -582,21 +588,6 @@ sv_reg_t (sv_proc_t::mulhu)(sv_reg_t const& a, sv_reg_t const& b) 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);