Signed-off-by: Richard Henderson <[email protected]>
---
 include/tcg/tcg-op-common.h   |  6 ++++--
 include/tcg/tcg-op-def2.h.inc |  1 +
 tcg/tcg-op.c                  | 36 +++++++++++++++++------------------
 3 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/include/tcg/tcg-op-common.h b/include/tcg/tcg-op-common.h
index e6607f48592..35288a19a79 100644
--- a/include/tcg/tcg-op-common.h
+++ b/include/tcg/tcg-op-common.h
@@ -107,6 +107,9 @@ void tcg_gen_plugin_mem_cb(TCGv_i64 addr, unsigned meminfo);
 #define DEF_RRI(NAME) \
     void glue(glue(tcg_gen_,NAME),TEXT)(TCGV a, TCGV b, TINT c);
 
+#define DEF_RIR(NAME) \
+    void glue(glue(tcg_gen_,NAME),TEXT)(TCGV a, TINT b, TCGV c);
+
 #include "tcg-op-def.h.inc"
 
 #undef DEF_R
@@ -114,10 +117,10 @@ void tcg_gen_plugin_mem_cb(TCGv_i64 addr, unsigned 
meminfo);
 #undef DEF_RRR
 #undef DEF_RI
 #undef DEF_RRI
+#undef DEF_RIR
 
 /* 32 bit ops */
 
-void tcg_gen_subfi_i32(TCGv_i32 ret, int32_t arg1, TCGv_i32 arg2);
 void tcg_gen_andi_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2);
 void tcg_gen_ori_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2);
 void tcg_gen_xori_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2);
@@ -216,7 +219,6 @@ void tcg_gen_not_i32(TCGv_i32 ret, TCGv_i32 arg);
 
 /* 64 bit ops */
 
-void tcg_gen_subfi_i64(TCGv_i64 ret, int64_t arg1, TCGv_i64 arg2);
 void tcg_gen_andi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2);
 void tcg_gen_ori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2);
 void tcg_gen_xori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2);
diff --git a/include/tcg/tcg-op-def2.h.inc b/include/tcg/tcg-op-def2.h.inc
index 52b0ebd7ecd..a739c198a56 100644
--- a/include/tcg/tcg-op-def2.h.inc
+++ b/include/tcg/tcg-op-def2.h.inc
@@ -2,6 +2,7 @@
 
 DEF_R(discard)
 DEF_RI(movi)
+DEF_RIR(subfi)
 DEF_RR(mov)
 DEF_RR(neg)
 DEF_RRI(addi)
diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c
index 354fbe07fa7..5e971d8bf54 100644
--- a/tcg/tcg-op.c
+++ b/tcg/tcg-op.c
@@ -335,6 +335,9 @@ void tcg_gen_plugin_mem_cb(TCGv_i64 addr, unsigned meminfo)
 #define DEF_RRI(NAME) \
     static void glue(gen_,NAME)(TCGType, TCGTemp *, TCGTemp *, int64_t);
 
+#define DEF_RIR(NAME) \
+    static void glue(gen_,NAME)(TCGType, TCGTemp *, int64_t, TCGTemp *);
+
 #include "tcg/tcg-op-def2.h.inc"
 
 #undef DEF_R
@@ -342,6 +345,7 @@ void tcg_gen_plugin_mem_cb(TCGv_i64 addr, unsigned meminfo)
 #undef DEF_RRR
 #undef DEF_RI
 #undef DEF_RRI
+#undef DEF_RIR
 
 /*
  * Generic expansions for templated operations.
@@ -395,6 +399,15 @@ static void gen_subi(TCGType type, TCGTemp *dst, TCGTemp 
*src1, int64_t src2)
     gen_addi(type, dst, src1, -src2);
 }
 
+static void gen_subfi(TCGType type, TCGTemp *dst, int64_t src1, TCGTemp *src2)
+{
+    if (src1 == 0) {
+        gen_neg(type, dst, src2);
+    } else {
+        gen_sub(type, dst, tcg_constant_internal(type, src1), src2);
+    }
+}
+
 /*
  * Templated operations.
  */
@@ -419,6 +432,10 @@ static void gen_subi(TCGType type, TCGTemp *dst, TCGTemp 
*src1, int64_t src2)
     void glue(glue(tcg_gen_,NAME),TEXT)(TCGV a, TCGV b, TINT c)         \
     { gen_##NAME(TYPE, TTMP(a), TTMP(b), c); }
 
+#define DEF_RIR(NAME)                                                   \
+    void glue(glue(tcg_gen_,NAME),TEXT)(TCGV a, TINT b, TCGV c)         \
+    { gen_##NAME(TYPE, TTMP(a), b, TTMP(c)); }
+
 #include "tcg/tcg-op-def.h.inc"
 
 #undef DEF_R
@@ -426,18 +443,10 @@ static void gen_subi(TCGType type, TCGTemp *dst, TCGTemp 
*src1, int64_t src2)
 #undef DEF_RRR
 #undef DEF_RI
 #undef DEF_RRI
+#undef DEF_RIR
 
 /* 32 bit ops */
 
-void tcg_gen_subfi_i32(TCGv_i32 ret, int32_t arg1, TCGv_i32 arg2)
-{
-    if (arg1 == 0) {
-        tcg_gen_neg_i32(ret, arg2);
-    } else {
-        tcg_gen_sub_i32(ret, tcg_constant_i32(arg1), arg2);
-    }
-}
-
 void tcg_gen_and_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
 {
     tcg_gen_op3_i32(INDEX_op_and, ret, arg1, arg2);
@@ -1546,15 +1555,6 @@ void tcg_gen_mul_i64(TCGv_i64 ret, TCGv_i64 arg1, 
TCGv_i64 arg2)
     tcg_gen_op3_i64(INDEX_op_mul, ret, arg1, arg2);
 }
 
-void tcg_gen_subfi_i64(TCGv_i64 ret, int64_t arg1, TCGv_i64 arg2)
-{
-    if (arg1 == 0) {
-        tcg_gen_neg_i64(ret, arg2);
-    } else {
-        tcg_gen_sub_i64(ret, tcg_constant_i64(arg1), arg2);
-    }
-}
-
 void tcg_gen_andi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
 {
     /* Some cases can be optimized here.  */
-- 
2.53.0


Reply via email to