Message ID | 20210928205450.4121269-1-philipp.tomsich@vrull.eu (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/2] tcg: add dup_const_tl wrapper | expand |
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~
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); +} + /* * Memory helpers that will be used by TCG generated code. */
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(+)