OP_PREP_FINISH(sv_reg_t, sv_reg_t, sv_reg_t, uint64_t, uint64_t, uint64_t)
+OP_PREP_FINISH(sv_sreg_t, sv_reg_t, sv_sreg_t, int64_t, uint64_t, int64_t)
OP_PREP_FINISH(sv_sreg_t, sv_sreg_t, sv_sreg_t, int64_t, int64_t, int64_t)
sv_reg_t sv_proc_t::rv_add(sv_reg_t const & lhs, sv_reg_t const & rhs)
sv_reg_t sv_proc_t::rv_mul(sv_reg_t const & lhs, sv_reg_t const & rhs)
{
- return lhs * rhs;
+ 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 * rhs;
+ fprintf(stderr, "mul result %lx %lx %lx\n",
+ (uint64_t)lhs, (uint64_t)rhs, (uint64_t)result);
+ return result;
+ }
+ uint64_t result = vlhs * vrhs;
+ return rv_int_op_finish(lhs, rhs, result, bitwidth);
}
sv_sreg_t sv_proc_t::rv_mul(sv_sreg_t const & lhs, sv_reg_t const & rhs)
{
- return lhs * rhs;
+ uint8_t bitwidth = _insn->src_bitwidth;
+ int64_t vlhs = 0;
+ uint64_t vrhs = 0;
+ if (rv_int_op_prepare(lhs, rhs, vlhs, vrhs, bitwidth)) {
+ sv_sreg_t result = lhs * rhs;
+ fprintf(stderr, "mul result %lx %lx %lx\n",
+ (int64_t)lhs, (uint64_t)rhs, (uint64_t)result);
+ return result;
+ }
+ int64_t result = vlhs * vrhs;
+ return rv_int_op_finish(lhs, rhs, result, bitwidth);
}
sv_sreg_t sv_proc_t::rv_mul(sv_sreg_t const & lhs, sv_sreg_t const & rhs)
return lhs * rhs;
}
+/* 32-bit mulh/mulhu/mulhsu */
sv_reg_t sv_proc_t::rv_mulhu(sv_reg_t const & lhs, sv_reg_t const & rhs)
{
return (lhs * rhs) >> 32;
return (lhs * rhs) >> 32;
}
+/* 64-bit mulh/mulhu/mulhsu */
+sv_sreg_t (sv_proc_t::mulhsu)(sv_sreg_t const& a, sv_reg_t const& b)
+{
+ return sv_sreg_t(::mulhsu(a, b));
+}
+
+sv_sreg_t (sv_proc_t::mulh)(sv_sreg_t const& a, sv_sreg_t const& b)
+{
+ return sv_sreg_t(::mulh(a, b));
+}
+
+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;
return sv_reg_t(::f128_to_i64(a, roundingMode, exact));
}
-sv_sreg_t (sv_proc_t::mulhsu)(sv_sreg_t const& a, sv_reg_t const& b)
-{
- return sv_sreg_t(::mulhsu(a, b));
-}
-
-sv_sreg_t (sv_proc_t::mulh)(sv_sreg_t const& a, sv_sreg_t const& b)
-{
- return sv_sreg_t(::mulh(a, b));
-}
-
-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_float64_t (sv_proc_t::f64_add)( sv_float64_t a, sv_float64_t b )
bool rv_int_op_prepare(sv_reg_t const & lhs, sv_reg_t const & rhs,
uint64_t &vlhs, uint64_t &vrhs,
uint8_t &bitwidth);
+ bool rv_int_op_prepare(sv_sreg_t const & lhs, sv_reg_t const & rhs,
+ int64_t &vlhs, uint64_t &vrhs,
+ uint8_t &bitwidth);
bool rv_int_op_prepare(sv_sreg_t const & lhs, sv_sreg_t const & rhs,
int64_t &vlhs, int64_t &vrhs,
uint8_t &bitwidth);
sv_reg_t rv_int_op_finish(sv_reg_t const & lhs, sv_reg_t const & rhs,
uint64_t &result, uint8_t &bitwidth);
+ sv_sreg_t rv_int_op_finish(sv_sreg_t const & lhs, sv_reg_t const & rhs,
+ int64_t &result, uint8_t &bitwidth);
sv_sreg_t rv_int_op_finish(sv_sreg_t const & lhs, sv_sreg_t const & rhs,
int64_t &result, uint8_t &bitwidth);