riscv: Add helper to make NaN-boxing for FP register
PATCH v2 1/1 riscv: Add helper to make NaN-boxing for FP register
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.
--- target/riscv/insn_trans/trans_rvf.inc.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
target/riscv/insn_trans/trans_rvf.inc.c +15 -2
@@ -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);
Signature · 1 line
2.17.1
Quoted 6 lines · Ian Jiang
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 <[email protected]>
Alistair
Quoted 43 lines
--- target/riscv/insn_trans/trans_rvf.inc.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)target/riscv/insn_trans/trans_rvf.inc.c +15
-3@@ -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
Quoted 8 lines · Ian Jiang
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 <[email protected]>--- target/riscv/insn_trans/trans_rvf.inc.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
r~
ping ? Could this be merged ?
Chih-Min Chao
Quoted 16 lines · Richard Henderson
Quoted 8 lines · Ian Jiang
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 <[email protected]>--- target/riscv/insn_trans/trans_rvf.inc.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)Reviewed-by Richard Henderson <[email protected]>r~
Alistair Francis
AppliedQuoted 2 lines · Chih-Min Chao
ping ? Could this be merged ?
Applied to the RISC-V tree.
Alistair
Quoted 23 lines
Chih-Min Chao
Quoted 16 lines · Richard Henderson
Quoted 8 lines · Ian Jiang
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 <[email protected]>--- target/riscv/insn_trans/trans_rvf.inc.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)Reviewed-by Richard Henderson <[email protected]>r~