Signed-off-by: Richard Henderson <[email protected]>
---
include/tcg/tcg-op-common.h | 2 --
tcg/tcg-internal.h | 8 +++++++
include/tcg/tcg-op-def.h.inc | 1 +
tcg/tcg-op.c | 43 +++++++++++++-----------------------
4 files changed, 24 insertions(+), 30 deletions(-)
diff --git a/include/tcg/tcg-op-common.h b/include/tcg/tcg-op-common.h
index aa4fe339d8e..bfda3c1f444 100644
--- a/include/tcg/tcg-op-common.h
+++ b/include/tcg/tcg-op-common.h
@@ -123,7 +123,6 @@ void tcg_gen_plugin_mem_cb(TCGv_i64 addr, unsigned meminfo);
/* 32 bit ops */
-void tcg_gen_div_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2);
void tcg_gen_rem_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2);
void tcg_gen_divu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2);
void tcg_gen_remu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2);
@@ -205,7 +204,6 @@ void tcg_gen_st_i32(TCGv_i32 arg1, TCGv_ptr arg2,
tcg_target_long offset);
/* 64 bit ops */
-void tcg_gen_div_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2);
void tcg_gen_rem_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2);
void tcg_gen_divu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2);
void tcg_gen_remu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2);
diff --git a/tcg/tcg-internal.h b/tcg/tcg-internal.h
index 76c8f026a64..6b65228241e 100644
--- a/tcg/tcg-internal.h
+++ b/tcg/tcg-internal.h
@@ -120,6 +120,14 @@ static inline TCGOp *tcg_gen_op_ttii(TCGOpcode opc,
TCGType type, TCGTemp *t0,
return tcg_gen_op4(opc, type, temp_arg(t0), temp_arg(t1), a2, a3);
}
+static inline void tcg_gen_op_ttttt(TCGOpcode opc, TCGType type,
+ TCGTemp *t0, TCGTemp *t1, TCGTemp *t2,
+ TCGTemp *t3, TCGTemp *t4)
+{
+ tcg_gen_op5(opc, type, temp_arg(t0), temp_arg(t1), temp_arg(t2),
+ temp_arg(t3), temp_arg(t4));
+}
+
QEMU_RET_ARG_NONNULL
TCGOp *tcg_op_insert_before(TCGContext *s, TCGOp *op,
TCGOpcode, TCGType, unsigned nargs);
diff --git a/include/tcg/tcg-op-def.h.inc b/include/tcg/tcg-op-def.h.inc
index 8c9d3d99c48..778854286cc 100644
--- a/include/tcg/tcg-op-def.h.inc
+++ b/include/tcg/tcg-op-def.h.inc
@@ -6,6 +6,7 @@ DEF3(addi, TCGV, TCGV, TINT)
DEF3(and, TCGV, TCGV, TCGV)
DEF3(andi, TCGV, TCGV, TINT)
DEF1(discard, TCGV)
+DEF3(div, TCGV, TCGV, TCGV)
DEF2(mov, TCGV, TCGV)
DEF2(movi, TCGV, TINT)
DEF3(mul, TCGV, TCGV, TCGV)
diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c
index 67ba4a0307a..203de8909fa 100644
--- a/tcg/tcg-op.c
+++ b/tcg/tcg-op.c
@@ -411,6 +411,21 @@ void tcg_gen_discard(TCGType type, TCGTemp *src)
tcg_gen_op1(INDEX_op_discard, type, temp_arg(src));
}
+void tcg_gen_div(TCGType type, TCGTemp *dst, TCGTemp *src1, TCGTemp *src2)
+{
+ if (tcg_op_supported(INDEX_op_divs, type, 0)) {
+ tcg_gen_op_ttt(INDEX_op_divs, type, dst, src1, src2);
+ } else if (tcg_op_supported(INDEX_op_divs2, type, 0)) {
+ g_autoptr(TCGTemp) tmp = tcg_temp_new_ebb(type);
+ int width = tcg_type_size(type) * 8;
+
+ tcg_gen_sari(type, tmp, src1, width - 1);
+ tcg_gen_op_ttttt(INDEX_op_divs2, type, dst, tmp, src1, tmp, src2);
+ } else {
+ g_assert_not_reached();
+ }
+}
+
void tcg_gen_mov(TCGType type, TCGTemp *dst, TCGTemp *src)
{
if (src != dst) {
@@ -609,20 +624,6 @@ void tcg_gen_negsetcondi_i32(TCGCond cond, TCGv_i32 ret,
tcg_gen_negsetcond_i32(cond, ret, arg1, tcg_constant_i32(arg2));
}
-void tcg_gen_div_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
-{
- if (tcg_op_supported(INDEX_op_divs, TCG_TYPE_I32, 0)) {
- tcg_gen_op3_i32(INDEX_op_divs, ret, arg1, arg2);
- } else if (tcg_op_supported(INDEX_op_divs2, TCG_TYPE_I32, 0)) {
- TCGv_i32 t0 = tcg_temp_ebb_new_i32();
- tcg_gen_sari_i32(t0, arg1, 31);
- tcg_gen_op5_i32(INDEX_op_divs2, ret, t0, arg1, t0, arg2);
- tcg_temp_free_i32(t0);
- } else {
- g_assert_not_reached();
- }
-}
-
void tcg_gen_rem_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
{
if (tcg_op_supported(INDEX_op_rems, TCG_TYPE_I32, 0)) {
@@ -1537,20 +1538,6 @@ void tcg_gen_negsetcond_i64(TCGCond cond, TCGv_i64 ret,
}
}
-void tcg_gen_div_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
-{
- if (tcg_op_supported(INDEX_op_divs, TCG_TYPE_I64, 0)) {
- tcg_gen_op3_i64(INDEX_op_divs, ret, arg1, arg2);
- } else if (tcg_op_supported(INDEX_op_divs2, TCG_TYPE_I64, 0)) {
- TCGv_i64 t0 = tcg_temp_ebb_new_i64();
- tcg_gen_sari_i64(t0, arg1, 63);
- tcg_gen_op5_i64(INDEX_op_divs2, ret, t0, arg1, t0, arg2);
- tcg_temp_free_i64(t0);
- } else {
- g_assert_not_reached();
- }
-}
-
void tcg_gen_rem_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
{
if (tcg_op_supported(INDEX_op_rems, TCG_TYPE_I64, 0)) {
--
2.53.0