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 | 38 +++++++++++++++++------------------
3 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/include/tcg/tcg-op-common.h b/include/tcg/tcg-op-common.h
index ab0c3f9554c..96d8ed8990a 100644
--- a/include/tcg/tcg-op-common.h
+++ b/include/tcg/tcg-op-common.h
@@ -104,16 +104,19 @@ void tcg_gen_plugin_mem_cb(TCGv_i64 addr, unsigned
meminfo);
#define DEF_RI(NAME) \
void glue(glue(tcg_gen_,NAME),TEXT)(TCGV a, TINT b);
+#define DEF_RRI(NAME) \
+ void glue(glue(tcg_gen_,NAME),TEXT)(TCGV a, TCGV b, TINT c);
+
#include "tcg-op-def.h.inc"
#undef DEF_R
#undef DEF_RR
#undef DEF_RRR
#undef DEF_RI
+#undef DEF_RRI
/* 32 bit ops */
-void tcg_gen_addi_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2);
void tcg_gen_subfi_i32(TCGv_i32 ret, int32_t arg1, TCGv_i32 arg2);
void tcg_gen_subi_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2);
void tcg_gen_andi_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_addi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2);
void tcg_gen_subfi_i64(TCGv_i64 ret, int64_t arg1, TCGv_i64 arg2);
void tcg_gen_subi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2);
void tcg_gen_andi_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 e36fd296a30..642cc7cfa48 100644
--- a/include/tcg/tcg-op-def2.h.inc
+++ b/include/tcg/tcg-op-def2.h.inc
@@ -3,4 +3,5 @@
DEF_R(discard)
DEF_RI(movi)
DEF_RR(mov)
+DEF_RRI(addi)
DEF_RRR(add)
diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c
index 30c84d348c9..b48dc62bdfc 100644
--- a/tcg/tcg-op.c
+++ b/tcg/tcg-op.c
@@ -332,12 +332,16 @@ void tcg_gen_plugin_mem_cb(TCGv_i64 addr, unsigned
meminfo)
#define DEF_RI(NAME) \
static void glue(gen_,NAME)(TCGType, TCGTemp *, int64_t);
+#define DEF_RRI(NAME) \
+ static void glue(gen_,NAME)(TCGType, TCGTemp *, TCGTemp *, int64_t);
+
#include "tcg/tcg-op-def2.h.inc"
#undef DEF_R
#undef DEF_RR
#undef DEF_RRR
#undef DEF_RI
+#undef DEF_RRI
/*
* Generic expansions for templated operations.
@@ -350,6 +354,15 @@ static void gen_add(TCGType type, TCGTemp *dst, TCGTemp
*src1, TCGTemp *src2)
gen_op_ttt(INDEX_op_add, type, dst, src1, src2);
}
+static void gen_addi(TCGType type, TCGTemp *dst, TCGTemp *src1, int64_t src2)
+{
+ if (unlikely(src2 == 0)) {
+ gen_mov(type, dst, src1);
+ } else {
+ gen_add(type, dst, src1, tcg_constant_internal(type, src2));
+ }
+}
+
static void gen_discard(TCGType type, TCGTemp *src)
{
tcg_gen_op1(INDEX_op_discard, type, temp_arg(src));
@@ -387,25 +400,20 @@ static void gen_movi(TCGType type, TCGTemp *dst, int64_t
src)
DNI void glue(glue(tcg_gen_,NAME),TEXT)(TCGV a, TINT b) \
{ gen_##NAME(TYPE, TTMP(a), b); }
+#define DEF_RRI(NAME) \
+ void glue(glue(tcg_gen_,NAME),TEXT)(TCGV a, TCGV b, TINT c) \
+ { gen_##NAME(TYPE, TTMP(a), TTMP(b), c); }
+
#include "tcg/tcg-op-def.h.inc"
#undef DEF_R
#undef DEF_RR
#undef DEF_RRR
#undef DEF_RI
+#undef DEF_RRI
/* 32 bit ops */
-void tcg_gen_addi_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
-{
- /* some cases can be optimized here */
- if (arg2 == 0) {
- tcg_gen_mov_i32(ret, arg1);
- } else {
- tcg_gen_add_i32(ret, arg1, tcg_constant_i32(arg2));
- }
-}
-
void tcg_gen_sub_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
{
tcg_gen_op3_i32(INDEX_op_sub, ret, arg1, arg2);
@@ -1543,16 +1551,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_addi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
-{
- /* some cases can be optimized here */
- if (arg2 == 0) {
- tcg_gen_mov_i64(ret, arg1);
- } else {
- tcg_gen_add_i64(ret, arg1, tcg_constant_i64(arg2));
- }
-}
-
void tcg_gen_subfi_i64(TCGv_i64 ret, int64_t arg1, TCGv_i64 arg2)
{
if (arg1 == 0) {
--
2.53.0