Signed-off-by: Richard Henderson <[email protected]>
---
include/tcg/tcg-op-common.h | 2 -
include/tcg/tcg-op-def.h.inc | 1 +
tcg/tcg-op.c | 79 +++++++++++++++++-------------------
3 files changed, 39 insertions(+), 43 deletions(-)
diff --git a/include/tcg/tcg-op-common.h b/include/tcg/tcg-op-common.h
index 1e5282af98d..3ad966b72c1 100644
--- a/include/tcg/tcg-op-common.h
+++ b/include/tcg/tcg-op-common.h
@@ -132,7 +132,6 @@ void tcg_gen_plugin_mem_cb(TCGv_i64 addr, unsigned meminfo);
/* 32 bit ops */
-void tcg_gen_mulu2_i32(TCGv_i32 rl, TCGv_i32 rh, TCGv_i32 arg1, TCGv_i32 arg2);
void tcg_gen_muls2_i32(TCGv_i32 rl, TCGv_i32 rh, TCGv_i32 arg1, TCGv_i32 arg2);
void tcg_gen_mulsu2_i32(TCGv_i32 rl, TCGv_i32 rh, TCGv_i32 arg1, TCGv_i32
arg2);
void tcg_gen_bswap16_i32(TCGv_i32 ret, TCGv_i32 arg, int flags);
@@ -157,7 +156,6 @@ void tcg_gen_st_i32(TCGv_i32 arg1, TCGv_ptr arg2,
tcg_target_long offset);
/* 64 bit ops */
void tcg_gen_addN_i64(int n, TCGv_i64 *r, TCGv_i64 *a, TCGv_i64 *b);
-void tcg_gen_mulu2_i64(TCGv_i64 rl, TCGv_i64 rh, TCGv_i64 arg1, TCGv_i64 arg2);
void tcg_gen_muls2_i64(TCGv_i64 rl, TCGv_i64 rh, TCGv_i64 arg1, TCGv_i64 arg2);
void tcg_gen_mulsu2_i64(TCGv_i64 rl, TCGv_i64 rh, TCGv_i64 arg1, TCGv_i64
arg2);
void tcg_gen_ext32s_i64(TCGv_i64 ret, TCGv_i64 arg);
diff --git a/include/tcg/tcg-op-def.h.inc b/include/tcg/tcg-op-def.h.inc
index 5a472a910c6..75ada0d0473 100644
--- a/include/tcg/tcg-op-def.h.inc
+++ b/include/tcg/tcg-op-def.h.inc
@@ -34,6 +34,7 @@ DEF2(movi, TCGV, TINT)
DEF6(movcond, TCGCond, TCGV, TCGV, TCGV, TCGV, TCGV)
DEF3(mul, TCGV, TCGV, TCGV)
DEF3(muli, TCGV, TCGV, TINT)
+DEF4(mulu2, TCGV, TCGV, TCGV, TCGV)
DEF3(nand, TCGV, TCGV, TCGV)
DEF2(neg, TCGV, TCGV)
DEF4(negsetcond, TCGCond, TCGV, TCGV, TCGV)
diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c
index 4559af91358..5219140f5fb 100644
--- a/tcg/tcg-op.c
+++ b/tcg/tcg-op.c
@@ -135,6 +135,13 @@ static TCGOp *gen_op_tttii(TCGOpcode opc, TCGType type,
temp_arg(t2), a3, a4);
}
+static TCGOp *gen_op_tttt(TCGOpcode opc, TCGType type, TCGTemp *t0,
+ TCGTemp *t1, TCGTemp *t2, TCGTemp *t3)
+{
+ return tcg_gen_op4(opc, type, temp_arg(t0), temp_arg(t1),
+ temp_arg(t2), temp_arg(t3));
+}
+
static TCGOp *gen_op_ttttt(TCGOpcode opc, TCGType type,
TCGTemp *t0, TCGTemp *t1, TCGTemp *t2,
TCGTemp *t3, TCGTemp *t4)
@@ -882,6 +889,37 @@ static void gen_muli(TCGType type, TCGTemp *dst, TCGTemp
*src1, int64_t src2)
}
}
+static void gen_mulu2(TCGType type, TCGTemp *rl, TCGTemp *rh,
+ TCGTemp *src1, TCGTemp *src2)
+{
+ if (tcg_op_supported(INDEX_op_mulu2, type, 0)) {
+ gen_op_tttt(INDEX_op_mulu2, type, rl, rh, src1, src2);
+ } else if (tcg_op_supported(INDEX_op_muluh, type, 0)) {
+ g_autoptr(TCGTemp) t = tcg_temp_new_ebb(type);
+
+ gen_mul(type, t, src1, src2);
+ gen_op_ttt(INDEX_op_muluh, type, rh, src1, src2);
+ gen_mov(type, rl, t);
+ } else if (type == TCG_TYPE_I32) {
+ g_autoptr(TCGTemp) t0 = tcg_temp_new_ebb(TCG_TYPE_I64);
+ g_autoptr(TCGTemp) t1 = tcg_temp_new_ebb(TCG_TYPE_I64);
+
+ /* Simply extend and use host 64-bit multiply. */
+ gen_extu_i32_i64(t0, src1);
+ gen_extu_i32_i64(t1, src2);
+ gen_mul(TCG_TYPE_I64, t0, t0, t1);
+ gen_extrl_i64_i32(rl, t0);
+ gen_extrh_i64_i32(rh, t0);
+ } else {
+ g_autoptr(TCGTemp) t = tcg_temp_new_ebb(type);
+
+ gen_mul(TCG_TYPE_I64, t, src1, src2);
+ gen_helper_muluh_i64(temp_tcgv_i64(rh), temp_tcgv_i64(src1),
+ temp_tcgv_i64(src2));
+ gen_mov(TCG_TYPE_I64, rl, t);
+ }
+}
+
static void gen_nand(TCGType type, TCGTemp *dst, TCGTemp *src1, TCGTemp *src2)
{
if (tcg_op_supported(INDEX_op_nand, type, 0)) {
@@ -1289,28 +1327,6 @@ static void gen_xori(TCGType type, TCGTemp *dst, TCGTemp
*src1, int64_t src2)
/* 32 bit ops */
-void tcg_gen_mulu2_i32(TCGv_i32 rl, TCGv_i32 rh, TCGv_i32 arg1, TCGv_i32 arg2)
-{
- if (tcg_op_supported(INDEX_op_mulu2, TCG_TYPE_I32, 0)) {
- tcg_gen_op4_i32(INDEX_op_mulu2, rl, rh, arg1, arg2);
- } else if (tcg_op_supported(INDEX_op_muluh, TCG_TYPE_I32, 0)) {
- TCGv_i32 t = tcg_temp_ebb_new_i32();
- tcg_gen_op3_i32(INDEX_op_mul, t, arg1, arg2);
- tcg_gen_op3_i32(INDEX_op_muluh, rh, arg1, arg2);
- tcg_gen_mov_i32(rl, t);
- tcg_temp_free_i32(t);
- } else {
- TCGv_i64 t0 = tcg_temp_ebb_new_i64();
- TCGv_i64 t1 = tcg_temp_ebb_new_i64();
- tcg_gen_extu_i32_i64(t0, arg1);
- tcg_gen_extu_i32_i64(t1, arg2);
- tcg_gen_mul_i64(t0, t0, t1);
- tcg_gen_extr_i64_i32(rl, rh, t0);
- tcg_temp_free_i64(t0);
- tcg_temp_free_i64(t1);
- }
-}
-
void tcg_gen_muls2_i32(TCGv_i32 rl, TCGv_i32 rh, TCGv_i32 arg1, TCGv_i32 arg2)
{
if (tcg_op_supported(INDEX_op_muls2, TCG_TYPE_I32, 0)) {
@@ -1796,25 +1812,6 @@ void tcg_gen_addN_i64(int n, TCGv_i64 *r, TCGv_i64 *a,
TCGv_i64 *b)
}
}
-void tcg_gen_mulu2_i64(TCGv_i64 rl, TCGv_i64 rh, TCGv_i64 arg1, TCGv_i64 arg2)
-{
- if (tcg_op_supported(INDEX_op_mulu2, TCG_TYPE_I64, 0)) {
- tcg_gen_op4_i64(INDEX_op_mulu2, rl, rh, arg1, arg2);
- } else if (tcg_op_supported(INDEX_op_muluh, TCG_TYPE_I64, 0)) {
- TCGv_i64 t = tcg_temp_ebb_new_i64();
- tcg_gen_op3_i64(INDEX_op_mul, t, arg1, arg2);
- tcg_gen_op3_i64(INDEX_op_muluh, rh, arg1, arg2);
- tcg_gen_mov_i64(rl, t);
- tcg_temp_free_i64(t);
- } else {
- TCGv_i64 t0 = tcg_temp_ebb_new_i64();
- tcg_gen_mul_i64(t0, arg1, arg2);
- gen_helper_muluh_i64(rh, arg1, arg2);
- tcg_gen_mov_i64(rl, t0);
- tcg_temp_free_i64(t0);
- }
-}
-
void tcg_gen_muls2_i64(TCGv_i64 rl, TCGv_i64 rh, TCGv_i64 arg1, TCGv_i64 arg2)
{
if (tcg_op_supported(INDEX_op_muls2, TCG_TYPE_I64, 0)) {
--
2.53.0