qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/2] tcg: add dup_const_tl wrapper


From: Richard Henderson
Subject: Re: [PATCH 1/2] tcg: add dup_const_tl wrapper
Date: Sun, 3 Oct 2021 13:30:19 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0

On 9/28/21 4:54 PM, Philipp Tomsich wrote:
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 wraps dup_const and legalises the
truncation to target_long by casting it to target_long.

Signed-off-by: Philipp Tomsich <philipp.tomsich@vrull.eu>

---

  include/tcg/tcg.h | 5 +++++
  1 file changed, 5 insertions(+)

diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h
index 44ccd86f3e..8f8a209600 100644
--- a/include/tcg/tcg.h
+++ b/include/tcg/tcg.h
@@ -1272,6 +1272,11 @@ uint64_t dup_const(unsigned vece, uint64_t c);
          : (qemu_build_not_reached_always(), 0))                    \
       : dup_const(VECE, C))
+static inline target_long dup_const_tl(unsigned vece, uint64_t c)
+{
+    return (target_long)dup_const(vece, c);
+}

While this works, it avoids the qemu_build_not_reached() sanity check within dup_const. I think perhaps this should be like

#if TARGET_LONG_BITS == 64
# define dup_const_tl  dup_const
#else
# define dup_const_tl(VECE, C) \
   ... stuff, excluding the MO_64 case
   ... using 32-bit multiplier constants
   ... using (uint32_t)(dup_const)(VECE, C) at the end
#endif


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]