@samitouri / QOSamiQemu / commits / 0eaa17b313

tcg: Introduce tcg_zero_i128()

Extract tcg_zero_i128() helper for re-use. Inspired-by: James Hilliard <james.hilliard1@gmail.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-ID: <20260520121644.10835-1-philmd@linaro.org> [rth: Move the function to tcg-op.c] Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Philippe Mathieu-Daudé committed May 19, 2026 at 20:39 UTC 0eaa17b3138cfea4de5b3cc429ecd0b28e0b4a6f
3 files changed +13 -4
include/tcg/tcg-op-common.h
+2
@@ -18,6 +18,8 @@ TCGv_vaddr tcg_constant_vaddr(uintptr_t val);
18 TCGv_vec tcg_constant_vec(TCGType type, unsigned vece, int64_t val);
19 TCGv_vec tcg_constant_vec_matching(TCGv_vec match, unsigned vece, int64_t val);
20
21 +TCGv_i128 tcg_zero_i128(void);
22 +
23 TCGv_i32 tcg_temp_new_i32(void);
24 TCGv_i64 tcg_temp_new_i64(void);
25 TCGv_ptr tcg_temp_new_ptr(void);
target/arm/tcg/translate-a64.c
+1 -4
@@ -4804,13 +4804,10 @@ static bool do_STG(DisasContext *s, arg_ldst_tag *a, bool is_zero, bool is_pair)
4804
4805 if (is_zero) {
4806 TCGv_i64 clean_addr = clean_data_tbi(s, addr);
4807 - TCGv_i64 zero64 = tcg_constant_i64(0);
4808 - TCGv_i128 zero128 = tcg_temp_new_i128();
4807 + TCGv_i128 zero128 = tcg_zero_i128();
4808 int mem_index = get_mem_index(s);
4809 MemOp mop = finalize_memop(s, MO_128 | MO_ALIGN);
4810
4812 - tcg_gen_concat_i64_i128(zero128, zero64, zero64);
4813 -
4811 /* This is 1 or 2 atomic 16-byte operations. */
4812 tcg_gen_qemu_st_i128(zero128, clean_addr, mem_index, mop);
4813 if (is_pair) {
tcg/tcg-op.c
+10
@@ -2475,6 +2475,16 @@ void tcg_gen_concat_i64_i128(TCGv_i128 ret, TCGv_i64 lo, TCGv_i64 hi)
2475 tcg_gen_mov_i64(TCGV128_HIGH(ret), hi);
2476 }
2477
2478 +TCGv_i128 tcg_zero_i128(void)
2479 +{
2480 + TCGv_i64 zero64 = tcg_constant_i64(0);
2481 + TCGv_i128 zero128 = tcg_temp_new_i128();
2482 +
2483 + tcg_gen_concat_i64_i128(zero128, zero64, zero64);
2484 +
2485 + return zero128;
2486 +}
2487 +
2488 void tcg_gen_mov_i128(TCGv_i128 dst, TCGv_i128 src)
2489 {
2490 if (dst != src) {