aboutsummaryrefslogtreecommitdiff
path: root/include/tcg
diff options
context:
space:
mode:
authorPhilipp Tomsich <philipp.tomsich@vrull.eu>2021-10-03 23:42:42 +0200
committerRichard Henderson <richard.henderson@linaro.org>2021-10-05 16:53:17 -0700
commitdb637f270b52f8c2a1c55e7e707532532295715c (patch)
treebb77bbef6263bd475245faae8a4e02152fff7cc4 /include/tcg
parent08a13c4b247338329951238a6c47b94f70c387d2 (diff)
tcg: add dup_const_tl wrapper
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>
Diffstat (limited to 'include/tcg')
-rw-r--r--include/tcg/tcg.h12
1 files changed, 12 insertions, 0 deletions
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.
*/