qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] tcg: add dup_const_tl wrapper
@ 2021-09-28 20:54 Philipp Tomsich
  2021-09-28 20:54 ` [PATCH 2/2] target/riscv: Use dup_const_tl in orc.b to legalise truncation of constant Philipp Tomsich
  2021-10-03 17:30 ` [PATCH 1/2] tcg: add dup_const_tl wrapper Richard Henderson
  0 siblings, 2 replies; 4+ messages in thread
From: Philipp Tomsich @ 2021-09-28 20:54 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alistair Francis, Richard Henderson, Philipp Tomsich

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);
+}
+
 /*
  * Memory helpers that will be used by TCG generated code.
  */
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] target/riscv: Use dup_const_tl in orc.b to legalise truncation of constant
  2021-09-28 20:54 [PATCH 1/2] tcg: add dup_const_tl wrapper Philipp Tomsich
@ 2021-09-28 20:54 ` Philipp Tomsich
  2021-10-03 17:30   ` Richard Henderson
  2021-10-03 17:30 ` [PATCH 1/2] tcg: add dup_const_tl wrapper Richard Henderson
  1 sibling, 1 reply; 4+ messages in thread
From: Philipp Tomsich @ 2021-09-28 20:54 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alistair Francis, Richard Henderson, Philipp Tomsich

We need to use the newly introduced dup_const_tl in orc.b to legalise
the truncation (to target_long) of the constant generated with dup_const.

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

 target/riscv/insn_trans/trans_rvb.c.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_trans/trans_rvb.c.inc
index 2927353d9b..185c3e9a60 100644
--- a/target/riscv/insn_trans/trans_rvb.c.inc
+++ b/target/riscv/insn_trans/trans_rvb.c.inc
@@ -249,7 +249,7 @@ static bool trans_rev8_64(DisasContext *ctx, arg_rev8_64 *a)
 static void gen_orc_b(TCGv ret, TCGv source1)
 {
     TCGv  tmp = tcg_temp_new();
-    TCGv  ones = tcg_constant_tl(dup_const(MO_8, 0x01));
+    TCGv  ones = tcg_constant_tl(dup_const_tl(MO_8, 0x01));
 
     /* Set lsb in each byte if the byte was zero. */
     tcg_gen_sub_tl(tmp, source1, ones);
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] tcg: add dup_const_tl wrapper
  2021-09-28 20:54 [PATCH 1/2] tcg: add dup_const_tl wrapper Philipp Tomsich
  2021-09-28 20:54 ` [PATCH 2/2] target/riscv: Use dup_const_tl in orc.b to legalise truncation of constant Philipp Tomsich
@ 2021-10-03 17:30 ` Richard Henderson
  1 sibling, 0 replies; 4+ messages in thread
From: Richard Henderson @ 2021-10-03 17:30 UTC (permalink / raw)
  To: Philipp Tomsich, qemu-devel; +Cc: Alistair Francis

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~


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] target/riscv: Use dup_const_tl in orc.b to legalise truncation of constant
  2021-09-28 20:54 ` [PATCH 2/2] target/riscv: Use dup_const_tl in orc.b to legalise truncation of constant Philipp Tomsich
@ 2021-10-03 17:30   ` Richard Henderson
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Henderson @ 2021-10-03 17:30 UTC (permalink / raw)
  To: Philipp Tomsich, qemu-devel; +Cc: Alistair Francis

On 9/28/21 4:54 PM, Philipp Tomsich wrote:
> We need to use the newly introduced dup_const_tl in orc.b to legalise
> the truncation (to target_long) of the constant generated with dup_const.
> 
> Signed-off-by: Philipp Tomsich<philipp.tomsich@vrull.eu>
> ---
> 
>   target/riscv/insn_trans/trans_rvb.c.inc | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-10-03 17:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-28 20:54 [PATCH 1/2] tcg: add dup_const_tl wrapper Philipp Tomsich
2021-09-28 20:54 ` [PATCH 2/2] target/riscv: Use dup_const_tl in orc.b to legalise truncation of constant Philipp Tomsich
2021-10-03 17:30   ` Richard Henderson
2021-10-03 17:30 ` [PATCH 1/2] tcg: add dup_const_tl wrapper Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).