@@ -46,7 +46,7 @@ DEF(mb, 0, 0, 1, 0)
DEF(mov_i32, 1, 1, 0, TCG_OPF_NOT_PRESENT)
DEF(setcond_i32, 1, 2, 1, 0)
-DEF(negsetcond_i32, 1, 2, 1, IMPL(TCG_TARGET_HAS_negsetcond_i32))
+DEF(negsetcond_i32, 1, 2, 1, IMPL(TCG_TARGET_HAS_negsetcond(TCG_TYPE_I32)))
DEF(movcond_i32, 1, 4, 1, 0)
/* load/store */
DEF(ld8u_i32, 1, 1, 1, 0)
@@ -112,7 +112,7 @@ DEF(ctpop_i32, 1, 1, 0, IMPL(TCG_TARGET_HAS_ctpop(TCG_TYPE_I32)))
DEF(mov_i64, 1, 1, 0, TCG_OPF_64BIT | TCG_OPF_NOT_PRESENT)
DEF(setcond_i64, 1, 2, 1, IMPL64)
-DEF(negsetcond_i64, 1, 2, 1, IMPL64 | IMPL(TCG_TARGET_HAS_negsetcond_i64))
+DEF(negsetcond_i64, 1, 2, 1, IMPL64 | IMPL(TCG_TARGET_HAS_negsetcond(TCG_TYPE_I64)))
DEF(movcond_i64, 1, 4, 1, IMPL64)
/* load/store */
DEF(ld8u_i64, 1, 1, 1, IMPL64)
@@ -23,6 +23,7 @@
#define TCG_TARGET_HAS_mulu2(T) 0
#define TCG_TARGET_HAS_mulsh(T) (T == TCG_TYPE_I64)
#define TCG_TARGET_HAS_muluh(T) (T == TCG_TYPE_I64)
+#define TCG_TARGET_HAS_negsetcond(T) 1
#define TCG_TARGET_HAS_rem(T) 1
#define TCG_TARGET_HAS_rot(T) 1
#define TCG_TARGET_HAS_sub2(T) 1
@@ -43,7 +44,6 @@
#define TCG_TARGET_HAS_extract_i32 1
#define TCG_TARGET_HAS_sextract_i32 1
#define TCG_TARGET_HAS_extract2_i32 1
-#define TCG_TARGET_HAS_negsetcond_i32 1
#define TCG_TARGET_HAS_extr_i64_i32 0
#define TCG_TARGET_HAS_qemu_st8_i32 0
@@ -57,7 +57,6 @@
#define TCG_TARGET_HAS_extract_i64 1
#define TCG_TARGET_HAS_sextract_i64 1
#define TCG_TARGET_HAS_extract2_i64 1
-#define TCG_TARGET_HAS_negsetcond_i64 1
/*
* Without FEAT_LSE2, we must use LDXP+STXP to implement atomic 128-bit load,
@@ -34,6 +34,7 @@ extern bool use_neon_instructions;
#define TCG_TARGET_HAS_mulu2(T) 1
#define TCG_TARGET_HAS_mulsh(T) 0
#define TCG_TARGET_HAS_muluh(T) 0
+#define TCG_TARGET_HAS_negsetcond(T) 1
#define TCG_TARGET_HAS_rem(T) 0
#define TCG_TARGET_HAS_rot(T) 1
#define TCG_TARGET_HAS_sub2(T) 1
@@ -54,7 +55,6 @@ extern bool use_neon_instructions;
#define TCG_TARGET_HAS_extract_i32 use_armv7_instructions
#define TCG_TARGET_HAS_sextract_i32 use_armv7_instructions
#define TCG_TARGET_HAS_extract2_i32 1
-#define TCG_TARGET_HAS_negsetcond_i32 1
#define TCG_TARGET_HAS_qemu_st8_i32 0
#define TCG_TARGET_HAS_qemu_ldst_i128 0
@@ -36,6 +36,7 @@
#define TCG_TARGET_HAS_mulu2(T) 1
#define TCG_TARGET_HAS_mulsh(T) 0
#define TCG_TARGET_HAS_muluh(T) 0
+#define TCG_TARGET_HAS_negsetcond(T) 1
#define TCG_TARGET_HAS_rot(T) 1
#define TCG_TARGET_HAS_sub2(T) 1
@@ -55,7 +56,6 @@
#define TCG_TARGET_HAS_extract_i32 1
#define TCG_TARGET_HAS_sextract_i32 1
#define TCG_TARGET_HAS_extract2_i32 1
-#define TCG_TARGET_HAS_negsetcond_i32 1
#if TCG_TARGET_REG_BITS == 64
/* Keep 32-bit values zero-extended in a register. */
@@ -70,7 +70,6 @@
#define TCG_TARGET_HAS_extract_i64 1
#define TCG_TARGET_HAS_sextract_i64 0
#define TCG_TARGET_HAS_extract2_i64 1
-#define TCG_TARGET_HAS_negsetcond_i64 1
#define TCG_TARGET_HAS_qemu_st8_i32 0
#else
#define TCG_TARGET_HAS_qemu_st8_i32 1
@@ -20,6 +20,7 @@
#define TCG_TARGET_HAS_mulu2(T) 0
#define TCG_TARGET_HAS_mulsh(T) 1
#define TCG_TARGET_HAS_muluh(T) 1
+#define TCG_TARGET_HAS_negsetcond(T) 0
#define TCG_TARGET_HAS_rem(T) 1
#define TCG_TARGET_HAS_rot(T) 1
#define TCG_TARGET_HAS_sub2(T) 0
@@ -32,7 +33,6 @@
#define TCG_TARGET_HAS_not(T) 1
#define TCG_TARGET_HAS_orc(T) 1
-#define TCG_TARGET_HAS_negsetcond_i32 0
#define TCG_TARGET_HAS_deposit_i32 1
#define TCG_TARGET_HAS_extract_i32 1
#define TCG_TARGET_HAS_sextract_i32 0
@@ -46,7 +46,6 @@
#define TCG_TARGET_HAS_qemu_st8_i32 0
/* 64-bit operations */
-#define TCG_TARGET_HAS_negsetcond_i64 0
#define TCG_TARGET_HAS_deposit_i64 1
#define TCG_TARGET_HAS_extract_i64 1
#define TCG_TARGET_HAS_sextract_i64 0
@@ -49,6 +49,7 @@ extern bool use_mips32r2_instructions;
#define TCG_TARGET_HAS_mulu2(T) (!use_mips32r6_instructions)
#define TCG_TARGET_HAS_mulsh(T) 1
#define TCG_TARGET_HAS_muluh(T) 1
+#define TCG_TARGET_HAS_negsetcond(T) 0
#define TCG_TARGET_HAS_rem(T) 1
#define TCG_TARGET_HAS_rot(T) use_mips32r2_instructions
#define TCG_TARGET_HAS_sub2(T) (TCG_TARGET_REG_BITS == 32)
@@ -62,13 +63,10 @@ extern bool use_mips32r2_instructions;
#define TCG_TARGET_HAS_not(T) 1
#define TCG_TARGET_HAS_orc(T) 0
-#define TCG_TARGET_HAS_negsetcond_i32 0
-
#if TCG_TARGET_REG_BITS == 64
#define TCG_TARGET_HAS_extr_i64_i32 1
#define TCG_TARGET_HAS_ext32s_i64 1
#define TCG_TARGET_HAS_ext32u_i64 1
-#define TCG_TARGET_HAS_negsetcond_i64 0
#endif
/* optional instructions detected at runtime */
@@ -27,6 +27,7 @@
#define TCG_TARGET_HAS_mulu2(T) 0
#define TCG_TARGET_HAS_mulsh(T) 1
#define TCG_TARGET_HAS_muluh(T) 1
+#define TCG_TARGET_HAS_negsetcond(T) 1
#define TCG_TARGET_HAS_rem(T) 1
#define TCG_TARGET_HAS_rot(T) 1
#define TCG_TARGET_HAS_sub2(T) (T == TCG_TYPE_REG)
@@ -49,7 +50,6 @@
#define TCG_TARGET_HAS_extract_i32 1
#define TCG_TARGET_HAS_sextract_i32 0
#define TCG_TARGET_HAS_extract2_i32 0
-#define TCG_TARGET_HAS_negsetcond_i32 1
#define TCG_TARGET_HAS_qemu_st8_i32 0
#if TCG_TARGET_REG_BITS == 64
@@ -64,7 +64,6 @@
#define TCG_TARGET_HAS_extract_i64 1
#define TCG_TARGET_HAS_sextract_i64 0
#define TCG_TARGET_HAS_extract2_i64 0
-#define TCG_TARGET_HAS_negsetcond_i64 1
#endif
#define TCG_TARGET_HAS_qemu_ldst_i128 \
@@ -20,6 +20,7 @@
#define TCG_TARGET_HAS_mulu2(T) 0
#define TCG_TARGET_HAS_mulsh(T) (T == TCG_TYPE_I64)
#define TCG_TARGET_HAS_muluh(T) (T == TCG_TYPE_I64)
+#define TCG_TARGET_HAS_negsetcond(T) 1
#define TCG_TARGET_HAS_rem(T) 1
#define TCG_TARGET_HAS_rot(T) (cpuinfo & CPUINFO_ZBB)
#define TCG_TARGET_HAS_sub2(T) 1
@@ -32,7 +33,6 @@
#define TCG_TARGET_HAS_not(T) 1
#define TCG_TARGET_HAS_orc(T) (T <= TCG_TYPE_REG && (cpuinfo & CPUINFO_ZBB))
-#define TCG_TARGET_HAS_negsetcond_i32 1
#define TCG_TARGET_HAS_deposit_i32 0
#define TCG_TARGET_HAS_extract_i32 0
#define TCG_TARGET_HAS_sextract_i32 0
@@ -45,7 +45,6 @@
#define TCG_TARGET_HAS_setcond2 1
#define TCG_TARGET_HAS_qemu_st8_i32 0
-#define TCG_TARGET_HAS_negsetcond_i64 1
#define TCG_TARGET_HAS_deposit_i64 0
#define TCG_TARGET_HAS_extract_i64 0
#define TCG_TARGET_HAS_sextract_i64 0
@@ -39,6 +39,7 @@ extern uint64_t s390_facilities[3];
#define TCG_TARGET_HAS_mulu2(T) (T == TCG_TYPE_I64)
#define TCG_TARGET_HAS_mulsh(T) 0
#define TCG_TARGET_HAS_muluh(T) 0
+#define TCG_TARGET_HAS_negsetcond(T) 1
#define TCG_TARGET_HAS_rot(T) 1
#define TCG_TARGET_HAS_sub2(T) 1
@@ -58,7 +59,6 @@ extern uint64_t s390_facilities[3];
#define TCG_TARGET_HAS_extract_i32 1
#define TCG_TARGET_HAS_sextract_i32 0
#define TCG_TARGET_HAS_extract2_i32 0
-#define TCG_TARGET_HAS_negsetcond_i32 1
#define TCG_TARGET_HAS_extr_i64_i32 0
#define TCG_TARGET_HAS_qemu_st8_i32 0
@@ -72,7 +72,6 @@ extern uint64_t s390_facilities[3];
#define TCG_TARGET_HAS_extract_i64 1
#define TCG_TARGET_HAS_sextract_i64 0
#define TCG_TARGET_HAS_extract2_i64 0
-#define TCG_TARGET_HAS_negsetcond_i64 1
#define TCG_TARGET_HAS_qemu_ldst_i128 1
@@ -24,6 +24,7 @@ extern bool use_vis3_instructions;
#define TCG_TARGET_HAS_mulu2(T) (T == TCG_TYPE_I32)
#define TCG_TARGET_HAS_mulsh(T) 0
#define TCG_TARGET_HAS_muluh(T) (T == TCG_TYPE_I64 && use_vis3_instructions)
+#define TCG_TARGET_HAS_negsetcond(T) 1
#define TCG_TARGET_HAS_rem(T) 0
#define TCG_TARGET_HAS_rot(T) 0
#define TCG_TARGET_HAS_sub2(T) 1
@@ -44,7 +45,6 @@ extern bool use_vis3_instructions;
#define TCG_TARGET_HAS_extract_i32 0
#define TCG_TARGET_HAS_sextract_i32 0
#define TCG_TARGET_HAS_extract2_i32 0
-#define TCG_TARGET_HAS_negsetcond_i32 1
#define TCG_TARGET_HAS_qemu_st8_i32 0
#define TCG_TARGET_HAS_extr_i64_i32 0
@@ -58,7 +58,6 @@ extern bool use_vis3_instructions;
#define TCG_TARGET_HAS_extract_i64 0
#define TCG_TARGET_HAS_sextract_i64 0
#define TCG_TARGET_HAS_extract2_i64 0
-#define TCG_TARGET_HAS_negsetcond_i64 1
#define TCG_TARGET_HAS_qemu_ldst_i128 0
@@ -22,7 +22,6 @@
#define TCG_TARGET_HAS_extract_i64 0
#define TCG_TARGET_HAS_sextract_i64 0
#define TCG_TARGET_HAS_extract2_i64 0
-#define TCG_TARGET_HAS_negsetcond_i64 0
#endif
#ifndef TCG_TARGET_deposit_i32_valid
@@ -18,6 +18,7 @@
#define TCG_TARGET_HAS_mulu2(T) 1
#define TCG_TARGET_HAS_mulsh(T) 0
#define TCG_TARGET_HAS_muluh(T) 0
+#define TCG_TARGET_HAS_negsetcond(T) 0
#define TCG_TARGET_HAS_rem(T) 1
#define TCG_TARGET_HAS_rot(T) 1
#define TCG_TARGET_HAS_sub2(T) 1
@@ -38,7 +39,6 @@
#define TCG_TARGET_HAS_extract_i32 1
#define TCG_TARGET_HAS_sextract_i32 1
#define TCG_TARGET_HAS_extract2_i32 0
-#define TCG_TARGET_HAS_negsetcond_i32 0
#define TCG_TARGET_HAS_qemu_st8_i32 0
#if TCG_TARGET_REG_BITS == 64
@@ -53,7 +53,6 @@
#define TCG_TARGET_HAS_ext8u_i64 1
#define TCG_TARGET_HAS_ext16u_i64 1
#define TCG_TARGET_HAS_ext32u_i64 1
-#define TCG_TARGET_HAS_negsetcond_i64 0
#endif /* TCG_TARGET_REG_BITS == 64 */
#define TCG_TARGET_HAS_qemu_ldst_i128 0
@@ -2004,7 +2004,7 @@ static bool fold_movcond(OptContext *ctx, TCGOp *op)
switch (ctx->type) {
case TCG_TYPE_I32:
opc = INDEX_op_setcond_i32;
- if (TCG_TARGET_HAS_negsetcond_i32) {
+ if (TCG_TARGET_HAS_negsetcond(TCG_TYPE_I32)) {
negopc = INDEX_op_negsetcond_i32;
}
tv = (int32_t)tv;
@@ -2012,7 +2012,7 @@ static bool fold_movcond(OptContext *ctx, TCGOp *op)
break;
case TCG_TYPE_I64:
opc = INDEX_op_setcond_i64;
- if (TCG_TARGET_HAS_negsetcond_i64) {
+ if (TCG_TARGET_HAS_negsetcond(TCG_TYPE_I64)) {
negopc = INDEX_op_negsetcond_i64;
}
break;
@@ -560,7 +560,7 @@ void tcg_gen_negsetcond_i32(TCGCond cond, TCGv_i32 ret,
tcg_gen_movi_i32(ret, -1);
} else if (cond == TCG_COND_NEVER) {
tcg_gen_movi_i32(ret, 0);
- } else if (TCG_TARGET_HAS_negsetcond_i32) {
+ } else if (TCG_TARGET_HAS_negsetcond(TCG_TYPE_I32)) {
tcg_gen_op4i_i32(INDEX_op_negsetcond_i32, ret, arg1, arg2, cond);
} else {
tcg_gen_setcond_i32(cond, ret, arg1, arg2);
@@ -2024,14 +2024,14 @@ void tcg_gen_negsetcond_i64(TCGCond cond, TCGv_i64 ret,
tcg_gen_movi_i64(ret, -1);
} else if (cond == TCG_COND_NEVER) {
tcg_gen_movi_i64(ret, 0);
- } else if (TCG_TARGET_HAS_negsetcond_i64) {
- tcg_gen_op4i_i64(INDEX_op_negsetcond_i64, ret, arg1, arg2, cond);
} else if (TCG_TARGET_REG_BITS == 32) {
tcg_gen_op6i_i32(INDEX_op_setcond2_i32, TCGV_LOW(ret),
TCGV_LOW(arg1), TCGV_HIGH(arg1),
TCGV_LOW(arg2), TCGV_HIGH(arg2), cond);
tcg_gen_neg_i32(TCGV_LOW(ret), TCGV_LOW(ret));
tcg_gen_mov_i32(TCGV_HIGH(ret), TCGV_LOW(ret));
+ } else if (TCG_TARGET_HAS_negsetcond(TCG_TYPE_I64)) {
+ tcg_gen_op4i_i64(INDEX_op_negsetcond_i64, ret, arg1, arg2, cond);
} else {
tcg_gen_setcond_i64(cond, ret, arg1, arg2);
tcg_gen_neg_i64(ret, ret);
@@ -2209,7 +2209,7 @@ bool tcg_op_supported(TCGOpcode op, TCGType type)
return true;
case INDEX_op_negsetcond_i32:
- return TCG_TARGET_HAS_negsetcond_i32;
+ return TCG_TARGET_HAS_negsetcond(TCG_TYPE_I32);
case INDEX_op_div_i32:
case INDEX_op_divu_i32:
return TCG_TARGET_HAS_div(TCG_TYPE_I32);
@@ -2306,7 +2306,7 @@ bool tcg_op_supported(TCGOpcode op, TCGType type)
return TCG_TARGET_REG_BITS == 64;
case INDEX_op_negsetcond_i64:
- return TCG_TARGET_HAS_negsetcond_i64;
+ return TCG_TARGET_REG_BITS == 64 && TCG_TARGET_HAS_negsetcond(TCG_TYPE_I64);
case INDEX_op_div_i64:
case INDEX_op_divu_i64:
return TCG_TARGET_REG_BITS == 64 && TCG_TARGET_HAS_div(TCG_TYPE_I64);
Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- include/tcg/tcg-opc.h | 4 ++-- tcg/aarch64/tcg-target-has.h | 3 +-- tcg/arm/tcg-target-has.h | 2 +- tcg/i386/tcg-target-has.h | 3 +-- tcg/loongarch64/tcg-target-has.h | 3 +-- tcg/mips/tcg-target-has.h | 4 +--- tcg/ppc/tcg-target-has.h | 3 +-- tcg/riscv/tcg-target-has.h | 3 +-- tcg/s390x/tcg-target-has.h | 3 +-- tcg/sparc64/tcg-target-has.h | 3 +-- tcg/tcg-has.h | 1 - tcg/tci/tcg-target-has.h | 3 +-- tcg/optimize.c | 4 ++-- tcg/tcg-op.c | 6 +++--- tcg/tcg.c | 4 ++-- 15 files changed, 19 insertions(+), 30 deletions(-)