diff --git a/include/tcg/tcg-op-common.h b/include/tcg/tcg-op-common.h index 9dc05cc7b7..6168af878a 100644 --- a/include/tcg/tcg-op-common.h +++ b/include/tcg/tcg-op-common.h @@ -92,6 +92,8 @@ void tcg_gen_plugin_mem_cb(TCGv_i64 addr, unsigned meminfo); * Construct operations from templates. */ +#define DEF1(NAME, T1) \ + QEMU_ARG_NONNULL void glue(glue(tcg_gen_,NAME),TExt)(T1); #define DEF2(NAME, T1, T2) \ QEMU_ARG_NONNULL void glue(glue(tcg_gen_,NAME),TExt)(T1, T2); @@ -113,6 +115,7 @@ void tcg_gen_plugin_mem_cb(TCGv_i64 addr, unsigned meminfo); #undef TINT #undef TCGV +#undef DEF1 #undef DEF2 /* 32 bit ops */ @@ -197,8 +200,6 @@ void tcg_gen_revbit32_i32(TCGv_i32 ret, TCGv_i32 arg); /* Replicate a value of size @vece from @in to all the lanes in @out */ void tcg_gen_dup_i32(unsigned vece, TCGv_i32 out, TCGv_i32 in); -void tcg_gen_discard_i32(TCGv_i32 arg); - void tcg_gen_ld8u_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset); void tcg_gen_ld8s_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset); void tcg_gen_ld16u_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset); @@ -317,7 +318,6 @@ void tcg_gen_st32_i64(TCGv_i64 arg1, TCGv_ptr arg2, tcg_target_long offset); void tcg_gen_add_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2); void tcg_gen_sub_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2); -void tcg_gen_discard_i64(TCGv_i64 arg); void tcg_gen_ld8u_i64(TCGv_i64 ret, TCGv_ptr arg2, tcg_target_long offset); void tcg_gen_ld8s_i64(TCGv_i64 ret, TCGv_ptr arg2, tcg_target_long offset); void tcg_gen_ld16u_i64(TCGv_i64 ret, TCGv_ptr arg2, tcg_target_long offset); @@ -541,10 +541,7 @@ static inline void tcg_gen_st_ptr(TCGv_ptr r, TCGv_ptr a, intptr_t o) glue(tcg_gen_st_, PTR)((NAT)r, a, o); } -static inline void tcg_gen_discard_ptr(TCGv_ptr a) -{ - glue(tcg_gen_discard_,PTR)((NAT)a); -} +QEMU_ARG_NONNULL void tcg_gen_discard_ptr(TCGv_ptr a); static inline void tcg_gen_add_ptr(TCGv_ptr r, TCGv_ptr a, TCGv_ptr b) { diff --git a/include/tcg/tcg-op-def.h.inc b/include/tcg/tcg-op-def.h.inc index e55a9f9993..8c61a75cd0 100644 --- a/include/tcg/tcg-op-def.h.inc +++ b/include/tcg/tcg-op-def.h.inc @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: MIT */ /* Templated TCGv_i32 and TCGv_i64 operations */ +DEF1(discard, TCGV) DEF2(mov, TCGV, TCGV) DEF2(movi, TCGV, TINT) diff --git a/tcg/tcg-internal.h b/tcg/tcg-internal.h index 3568157ebb..ed1f5f20f8 100644 --- a/tcg/tcg-internal.h +++ b/tcg/tcg-internal.h @@ -124,6 +124,8 @@ bool tcg_op_imm_match(TCGOpcode op, TCGType type, tcg_target_ulong imm); * Declarations of templated TCGv_i32 and TCGv_i64 operations. */ +#define DEF1(NAME, T1) \ + QEMU_ARG_NONNULL void glue(tcg_gen_,NAME)(TCGType, T1); #define DEF2(NAME, T1, T2) \ QEMU_ARG_NONNULL void glue(tcg_gen_,NAME)(TCGType, T1, T2); @@ -135,6 +137,7 @@ bool tcg_op_imm_match(TCGOpcode op, TCGType type, tcg_target_ulong imm); #undef TINT #undef TCGV +#undef DEF1 #undef DEF2 #endif /* TCG_INTERNAL_H */ diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index d7272b08cd..ffddb3c19d 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -114,16 +114,6 @@ TCGOp * NI tcg_gen_op6(TCGOpcode opc, TCGType type, TCGArg a1, TCGArg a2, # define DNI #endif -static void DNI tcg_gen_op1_i32(TCGOpcode opc, TCGType type, TCGv_i32 a1) -{ - tcg_gen_op1(opc, type, tcgv_i32_arg(a1)); -} - -static void DNI tcg_gen_op1_i64(TCGOpcode opc, TCGType type, TCGv_i64 a1) -{ - tcg_gen_op1(opc, type, tcgv_i64_arg(a1)); -} - static TCGOp * DNI tcg_gen_op1i(TCGOpcode opc, TCGType type, TCGArg a1) { return tcg_gen_op1(opc, type, a1); @@ -319,6 +309,10 @@ void tcg_gen_plugin_mem_cb(TCGv_i64 addr, unsigned meminfo) * Templated TCGv_i32 and TCGv_i64 operations. */ +#define DEF1(NAME, T1) \ + void glue(glue(tcg_gen_,NAME),TExt)(T1 a) \ + { tcg_gen_##NAME(TYPE, glue(C_,T1)(a)); } + #define DEF2(NAME, T1, T2) \ void glue(glue(tcg_gen_,NAME),TExt)(T1 a, T2 b) \ { tcg_gen_##NAME(TYPE, glue(C_,T1)(a), glue(C_,T2)(b)); } @@ -355,6 +349,7 @@ void tcg_gen_plugin_mem_cb(TCGv_i64 addr, unsigned meminfo) #undef C_int32_t #undef C_int64_t +#undef DEF1 #undef DEF2 /* @@ -363,6 +358,11 @@ void tcg_gen_plugin_mem_cb(TCGv_i64 addr, unsigned meminfo) * are of the proper type. */ +void tcg_gen_discard(TCGType type, TCGTemp *src) +{ + tcg_gen_op1(INDEX_op_discard, type, temp_arg(src)); +} + void tcg_gen_mov(TCGType type, TCGTemp *dst, TCGTemp *src) { if (src != dst) { @@ -377,11 +377,6 @@ void tcg_gen_movi(TCGType type, TCGTemp *dst, int64_t src) /* 32 bit ops */ -void tcg_gen_discard_i32(TCGv_i32 arg) -{ - tcg_gen_op1_i32(INDEX_op_discard, TCG_TYPE_I32, arg); -} - void tcg_gen_add_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) { tcg_gen_op3_i32(INDEX_op_add, ret, arg1, arg2); @@ -1439,11 +1434,6 @@ void tcg_gen_st_i32(TCGv_i32 arg1, TCGv_ptr arg2, tcg_target_long offset) /* 64-bit ops */ -void tcg_gen_discard_i64(TCGv_i64 arg) -{ - tcg_gen_op1_i64(INDEX_op_discard, TCG_TYPE_I64, arg); -} - void tcg_gen_ld8u_i64(TCGv_i64 ret, TCGv_ptr arg2, tcg_target_long offset) { tcg_gen_ldst_op_i64(INDEX_op_ld8u, ret, arg2, offset); @@ -2769,6 +2759,11 @@ void tcg_gen_lookup_and_goto_ptr(void) /* Host pointer operations */ +void tcg_gen_discard_ptr(TCGv_ptr s) +{ + tcg_gen_discard(TCG_TYPE_PTR, tcgv_ptr_temp(s)); +} + void tcg_gen_mov_ptr(TCGv_ptr d, TCGv_ptr s) { tcg_gen_mov(TCG_TYPE_PTR, tcgv_ptr_temp(d), tcgv_ptr_temp(s));