[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 03/28] tcg: add dup_const_tl wrapper
From: |
Richard Henderson |
Subject: |
[PULL 03/28] tcg: add dup_const_tl wrapper |
Date: |
Wed, 6 Oct 2021 08:19:49 -0700 |
From: Philipp Tomsich <philipp.tomsich@vrull.eu>
dup_const always generates a uint64_t, which may exceed the size of a
target_long (generating warnings with recent-enough compilers).
To ensure that we can use dup_const both for 64bit and 32bit targets,
this adds dup_const_tl, which either maps back to dup_const (for 64bit
targets) or provides a similar implementation using 32bit constants.
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Philipp Tomsich <philipp.tomsich@vrull.eu>
Message-Id: <20211003214243.3813425-1-philipp.tomsich@vrull.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/tcg/tcg.h | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h
index 44ccd86f3e..1bb6c0ce3e 100644
--- a/include/tcg/tcg.h
+++ b/include/tcg/tcg.h
@@ -1272,6 +1272,18 @@ uint64_t dup_const(unsigned vece, uint64_t c);
: (qemu_build_not_reached_always(), 0)) \
: dup_const(VECE, C))
+#if TARGET_LONG_BITS == 64
+# define dup_const_tl dup_const
+#else
+# define dup_const_tl(VECE, C) \
+ (__builtin_constant_p(VECE) \
+ ? ( (VECE) == MO_8 ? 0x01010101ul * (uint8_t)(C) \
+ : (VECE) == MO_16 ? 0x00010001ul * (uint16_t)(C) \
+ : (VECE) == MO_32 ? 0x00000001ul * (uint32_t)(C) \
+ : (qemu_build_not_reached_always(), 0)) \
+ : (target_long)dup_const(VECE, C))
+#endif
+
/*
* Memory helpers that will be used by TCG generated code.
*/
--
2.25.1
- [PULL 00/28] tcg patch queue, Richard Henderson, 2021/10/06
- [PULL 02/28] tests/docker: Fix fedora-i386-cross cross-compilation, Richard Henderson, 2021/10/06
- [PULL 03/28] tcg: add dup_const_tl wrapper,
Richard Henderson <=
- [PULL 08/28] trace/mem: Pass MemOpIdx to trace_mem_get_info, Richard Henderson, 2021/10/06
- [PULL 06/28] tcg: Rename TCGMemOpIdx to MemOpIdx, Richard Henderson, 2021/10/06
- [PULL 05/28] tcg: Expand MO_SIZE to 3 bits, Richard Henderson, 2021/10/06
- [PULL 07/28] tcg: Split out MemOpIdx to exec/memopidx.h, Richard Henderson, 2021/10/06
- [PULL 14/28] tcg/s390x: Rename from tcg/s390, Richard Henderson, 2021/10/06
- [PULL 04/28] accel/tcg: Drop signness in tracing in cputlb.c, Richard Henderson, 2021/10/06
- [PULL 13/28] tcg: Expand usadd/ussub with umin/umax, Richard Henderson, 2021/10/06
- [PULL 10/28] plugins: Reorg arguments to qemu_plugin_vcpu_mem_cb, Richard Henderson, 2021/10/06
- [PULL 16/28] tcg/s390x: Merge TCG_AREG0 and TCG_REG_CALL_STACK into TCGReg, Richard Henderson, 2021/10/06
- [PULL 24/28] tcg/s390x: Implement vector shift operations, Richard Henderson, 2021/10/06