qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] riscv: Add helper to make NaN-boxing for FP register
@ 2020-01-28  0:37 Ian Jiang
  2020-01-28  0:41 ` Alistair Francis
  2020-01-28 18:32 ` Richard Henderson
  0 siblings, 2 replies; 5+ messages in thread
From: Ian Jiang @ 2020-01-28  0:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alistair.Francis, palmer, Ian Jiang, sagark, kbastian

The function that makes NaN-boxing when a 32-bit value is assigned
to a 64-bit FP register is split out to a helper gen_nanbox_fpr().
Then it is applied in translating of the FLW instruction.

Signed-off-by: Ian Jiang <ianjiang.ict@gmail.com>
---
 target/riscv/insn_trans/trans_rvf.inc.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/target/riscv/insn_trans/trans_rvf.inc.c b/target/riscv/insn_trans/trans_rvf.inc.c
index e23cd639a6..3bfd8881e7 100644
--- a/target/riscv/insn_trans/trans_rvf.inc.c
+++ b/target/riscv/insn_trans/trans_rvf.inc.c
@@ -23,6 +23,20 @@
         return false;                       \
 } while (0)
 
+/*
+ * RISC-V requires NaN-boxing of narrower width floating
+ * point values.  This applies when a 32-bit value is
+ * assigned to a 64-bit FP register.  Thus this does not
+ * apply when the RVD extension is not present.
+ */
+static void gen_nanbox_fpr(DisasContext *ctx, int regno)
+{
+    if (has_ext(ctx, RVD)) {
+        tcg_gen_ori_i64(cpu_fpr[regno], cpu_fpr[regno],
+                        MAKE_64BIT_MASK(32, 32));
+    }
+}
+
 static bool trans_flw(DisasContext *ctx, arg_flw *a)
 {
     TCGv t0 = tcg_temp_new();
@@ -32,8 +46,7 @@ static bool trans_flw(DisasContext *ctx, arg_flw *a)
     tcg_gen_addi_tl(t0, t0, a->imm);
 
     tcg_gen_qemu_ld_i64(cpu_fpr[a->rd], t0, ctx->mem_idx, MO_TEUL);
-    /* RISC-V requires NaN-boxing of narrower width floating point values */
-    tcg_gen_ori_i64(cpu_fpr[a->rd], cpu_fpr[a->rd], 0xffffffff00000000ULL);
+    gen_nanbox_fpr(ctx, a->rd);
 
     tcg_temp_free(t0);
     mark_fs_dirty(ctx);
-- 
2.17.1



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

* Re: [PATCH v2] riscv: Add helper to make NaN-boxing for FP register
  2020-01-28  0:37 [PATCH v2] riscv: Add helper to make NaN-boxing for FP register Ian Jiang
@ 2020-01-28  0:41 ` Alistair Francis
  2020-01-28 18:32 ` Richard Henderson
  1 sibling, 0 replies; 5+ messages in thread
From: Alistair Francis @ 2020-01-28  0:41 UTC (permalink / raw)
  To: Ian Jiang
  Cc: Palmer Dabbelt, Alistair Francis,
	qemu-devel@nongnu.org Developers, Sagar Karandikar,
	Bastian Koppelmann

On Mon, Jan 27, 2020 at 4:37 PM Ian Jiang <ianjiang.ict@gmail.com> wrote:
>
> The function that makes NaN-boxing when a 32-bit value is assigned
> to a 64-bit FP register is split out to a helper gen_nanbox_fpr().
> Then it is applied in translating of the FLW instruction.
>
> Signed-off-by: Ian Jiang <ianjiang.ict@gmail.com>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  target/riscv/insn_trans/trans_rvf.inc.c | 17 +++++++++++++++--
>  1 file changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/target/riscv/insn_trans/trans_rvf.inc.c b/target/riscv/insn_trans/trans_rvf.inc.c
> index e23cd639a6..3bfd8881e7 100644
> --- a/target/riscv/insn_trans/trans_rvf.inc.c
> +++ b/target/riscv/insn_trans/trans_rvf.inc.c
> @@ -23,6 +23,20 @@
>          return false;                       \
>  } while (0)
>
> +/*
> + * RISC-V requires NaN-boxing of narrower width floating
> + * point values.  This applies when a 32-bit value is
> + * assigned to a 64-bit FP register.  Thus this does not
> + * apply when the RVD extension is not present.
> + */
> +static void gen_nanbox_fpr(DisasContext *ctx, int regno)
> +{
> +    if (has_ext(ctx, RVD)) {
> +        tcg_gen_ori_i64(cpu_fpr[regno], cpu_fpr[regno],
> +                        MAKE_64BIT_MASK(32, 32));
> +    }
> +}
> +
>  static bool trans_flw(DisasContext *ctx, arg_flw *a)
>  {
>      TCGv t0 = tcg_temp_new();
> @@ -32,8 +46,7 @@ static bool trans_flw(DisasContext *ctx, arg_flw *a)
>      tcg_gen_addi_tl(t0, t0, a->imm);
>
>      tcg_gen_qemu_ld_i64(cpu_fpr[a->rd], t0, ctx->mem_idx, MO_TEUL);
> -    /* RISC-V requires NaN-boxing of narrower width floating point values */
> -    tcg_gen_ori_i64(cpu_fpr[a->rd], cpu_fpr[a->rd], 0xffffffff00000000ULL);
> +    gen_nanbox_fpr(ctx, a->rd);
>
>      tcg_temp_free(t0);
>      mark_fs_dirty(ctx);
> --
> 2.17.1
>
>


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

* Re: [PATCH v2] riscv: Add helper to make NaN-boxing for FP register
  2020-01-28  0:37 [PATCH v2] riscv: Add helper to make NaN-boxing for FP register Ian Jiang
  2020-01-28  0:41 ` Alistair Francis
@ 2020-01-28 18:32 ` Richard Henderson
  2020-06-09 10:07   ` Chih-Min Chao
  1 sibling, 1 reply; 5+ messages in thread
From: Richard Henderson @ 2020-01-28 18:32 UTC (permalink / raw)
  To: Ian Jiang, qemu-devel; +Cc: palmer, Alistair.Francis, sagark, kbastian

On 1/27/20 4:37 PM, Ian Jiang wrote:
> The function that makes NaN-boxing when a 32-bit value is assigned
> to a 64-bit FP register is split out to a helper gen_nanbox_fpr().
> Then it is applied in translating of the FLW instruction.
> 
> Signed-off-by: Ian Jiang <ianjiang.ict@gmail.com>
> ---
>  target/riscv/insn_trans/trans_rvf.inc.c | 17 +++++++++++++++--
>  1 file changed, 15 insertions(+), 2 deletions(-)

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


r~


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

* Re: [PATCH v2] riscv: Add helper to make NaN-boxing for FP register
  2020-01-28 18:32 ` Richard Henderson
@ 2020-06-09 10:07   ` Chih-Min Chao
  2020-06-09 23:16     ` Alistair Francis
  0 siblings, 1 reply; 5+ messages in thread
From: Chih-Min Chao @ 2020-06-09 10:07 UTC (permalink / raw)
  To: Richard Henderson
  Cc: open list:RISC-V, Sagar Karandikar, Bastian Koppelmann,
	qemu-devel@nongnu.org Developers, Alistair Francis, palmer,
	Ian Jiang

[-- Attachment #1: Type: text/plain, Size: 650 bytes --]

ping ?  Could this be merged ?


Chih-Min Chao



On Wed, Jan 29, 2020 at 3:43 AM Richard Henderson <
richard.henderson@linaro.org> wrote:

> On 1/27/20 4:37 PM, Ian Jiang wrote:
> > The function that makes NaN-boxing when a 32-bit value is assigned
> > to a 64-bit FP register is split out to a helper gen_nanbox_fpr().
> > Then it is applied in translating of the FLW instruction.
> >
> > Signed-off-by: Ian Jiang <ianjiang.ict@gmail.com>
> > ---
> >  target/riscv/insn_trans/trans_rvf.inc.c | 17 +++++++++++++++--
> >  1 file changed, 15 insertions(+), 2 deletions(-)
>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>
>
> r~
>
>

[-- Attachment #2: Type: text/html, Size: 1391 bytes --]

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

* Re: [PATCH v2] riscv: Add helper to make NaN-boxing for FP register
  2020-06-09 10:07   ` Chih-Min Chao
@ 2020-06-09 23:16     ` Alistair Francis
  0 siblings, 0 replies; 5+ messages in thread
From: Alistair Francis @ 2020-06-09 23:16 UTC (permalink / raw)
  To: Chih-Min Chao
  Cc: open list:RISC-V, Sagar Karandikar, Bastian Koppelmann,
	Richard Henderson, qemu-devel@nongnu.org Developers,
	Alistair Francis, Palmer Dabbelt, Ian Jiang

On Tue, Jun 9, 2020 at 3:08 AM Chih-Min Chao <chihmin.chao@sifive.com> wrote:
>
> ping ?  Could this be merged ?

Applied to the RISC-V tree.

Alistair

>
>
> Chih-Min Chao
>
>
>
> On Wed, Jan 29, 2020 at 3:43 AM Richard Henderson <richard.henderson@linaro.org> wrote:
>>
>> On 1/27/20 4:37 PM, Ian Jiang wrote:
>> > The function that makes NaN-boxing when a 32-bit value is assigned
>> > to a 64-bit FP register is split out to a helper gen_nanbox_fpr().
>> > Then it is applied in translating of the FLW instruction.
>> >
>> > Signed-off-by: Ian Jiang <ianjiang.ict@gmail.com>
>> > ---
>> >  target/riscv/insn_trans/trans_rvf.inc.c | 17 +++++++++++++++--
>> >  1 file changed, 15 insertions(+), 2 deletions(-)
>>
>> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>>
>>
>> r~
>>


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

end of thread, other threads:[~2020-06-09 23:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-28  0:37 [PATCH v2] riscv: Add helper to make NaN-boxing for FP register Ian Jiang
2020-01-28  0:41 ` Alistair Francis
2020-01-28 18:32 ` Richard Henderson
2020-06-09 10:07   ` Chih-Min Chao
2020-06-09 23:16     ` Alistair Francis

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).