target/mips: Translate MSA vector load/store opcodes
v4 cover target/mips: Translate MSA vector load/store opcodes
Hi Richard,
I tried to implement your suggestion from v3 [*]. Unfortunately the box where I had the MSA test suite got erased, so it will take me some time to restore the setup. I was surprised these patches pass our CI tests so I added a pair of abort() which didn't fire, so this code path isn't tested at all there. Anyhow, do you mind having a quick look to see this is going in the right direction?
Thanks!
Phil.
[*] https://lore.kernel.org/qemu-devel/[email protected]/
Philippe Mathieu-Daudé (2):
target/mips: Translate MSA vector load opcode (LD.df) target/mips: Translate MSA vector store opcode (ST.df)
target/mips/tcg/msa_helper.h.inc | 9 -- target/mips/tcg/msa_helper.c | 173 ------------------------------- target/mips/tcg/msa_translate.c | 96 ++++++++++++++--- 3 files changed, 84 insertions(+), 194 deletions(-)
Signature · 1 line
2.53.0
RFC PATCH v4 1/2 target/mips: Translate MSA vector load opcode (LD.df)
Replace helpers by translation.
Remove legacy cpu_ld*_data_ra() calls, replacing by tcg_gen_qemu_ld() which allow to respect atomicity.
--- target/mips/tcg/msa_helper.h.inc | 1 - target/mips/tcg/msa_helper.c | 69 -------------------------------- target/mips/tcg/msa_translate.c | 44 +++++++++++++++++++- 3 files changed, 43 insertions(+), 71 deletions(-)
target/mips/tcg/msa_helper.h.inc +0 -1
@@ -434,7 +434,6 @@ DEF_HELPER_4(msa_ffint_s_df, void, env, i32, i32, i32) DEF_HELPER_4(msa_ffint_u_df, void, env, i32, i32, i32) #define MSALDST_PROTO(type) \ -DEF_HELPER_3(msa_ld_ ## type, void, env, i32, tl) \ DEF_HELPER_3(msa_st_ ## type, void, env, i32, tl) MSALDST_PROTO(b) MSALDST_PROTO(h)
target/mips/tcg/msa_helper.c +0 -69
75 lines not on this page · raw message
target/mips/tcg/msa_translate.c +43 -1
56 lines not on this page · raw message
Signature · 1 line
2.53.0
Re: [RFC PATCH v4 1/2] target/mips: Translate MSA vector load opcode (LD.df)
Quoted 19 lines · Philippe Mathieu-Daudé
target/mips/tcg/msa_translate.c +19
-0+static bool trans_LD (DisasContext *ctx,arg_msa_i *a) +{ +TCGv_va addr; +TCGv_i128 d16; +MemOp mop; +int d0 = a->wd <<1 ; +int d1 = d0 +1 ; + +if (!check_msa_enabled (ctx)) { +return true; + } + + addr =tcgv_va_temp_new (); +gen_base_offset_addr (ctx, addr, a->ws, a->sa << a->df); + + mop =MO_128 |MO_LE ; +if (a->df ==0 ) { + mop |=MO_ATOM_NONE ; + }else if (a->df ==3 ) {
target/mips/tcg/msa_translate.c TRANS(FTINT_U, trans_msa_2rf, gen_helper_msa_ftint_u_df); · line 789
Quoted 10 lines
target/mips/tcg/msa_translate.c +10
-0+ mop |=MO_ATOM_IFALIGN_PAIR ; + }else { + mop |=MO_ATOM_SUBALIGN ;/* slightly stronger than required */ + } + mop |= a->df <<MO_ASHIFT ;/* MO_ALIGN */ + + d16 =tcg_temp_new_i128 (); +tcg_gen_qemu_ld_i128 (d16, addr, ctx->mem_idx, mop); + + tcg_gen_st_i128(d16, tcg_env, offsetof(CPUMIPSState, active_fpu.fpr[d0]));
You cannot write to slots that have ...
target/mips/tcg/msa_translate.c TRANS(FTINT_U, trans_msa_2rf, gen_helper_msa_ftint_u_df); · line 794
Quoted 5 lines
target/mips/tcg/msa_translate.c +5
-0+ +if (mo_endian (ctx) !=MO_LE ) { +if (a->df ==1 ) { +tcg_gen_hswap_i64 (msa_wr_d[d0], msa_wr_d[d0]); +tcg_gen_hswap_i64 (msa_wr_d[d1], msa_wr_d[d1]);
... tcg globals associated with them.
You need
tcg_gen_extr_i128_i64(msa_wr_d[lo], msa_wr_d[hi], d16);
to extract the halves into existing TCGv_i64.
I can't follow the endianness assumptions in msa_helper.c. I suspect it can't handle both big and little-endian host.
But hswap and wswap don't match bswap16x4 and bswap32x2,
Before:
LE load, then bswap elements without swapping element ordering.
After:
LE load, then swap element ordering without bswap elements.
I think you were looking for:
BE load, then swap element ordering without bswap elements.
But in any case, it's an algorithm change.
r~
RFC PATCH v4 2/2 target/mips: Translate MSA vector store opcode (ST.df)
In reply to Philippe Mathieu-DaudéReplace helpers by translation.
Remove legacy cpu_st*_data_ra() calls, replacing by tcg_gen_qemu_st() which allow to respect atomicity.
Remove the ensure_writable_pages() hack and the bswap NxM helpers.
--- target/mips/tcg/msa_helper.h.inc | 8 --- target/mips/tcg/msa_helper.c | 104 ------------------------------- target/mips/tcg/msa_translate.c | 54 ++++++++++++---- 3 files changed, 42 insertions(+), 124 deletions(-)
target/mips/tcg/msa_helper.h.inc +0 -8
@@ -432,11 +432,3 @@ DEF_HELPER_4(msa_ftint_s_df, void, env, i32, i32, i32) DEF_HELPER_4(msa_ftint_u_df, void, env, i32, i32, i32) DEF_HELPER_4(msa_ffint_s_df, void, env, i32, i32, i32) DEF_HELPER_4(msa_ffint_u_df, void, env, i32, i32, i32) - -#define MSALDST_PROTO(type) \ -DEF_HELPER_3(msa_st_ ## type, void, env, i32, tl) -MSALDST_PROTO(b) -MSALDST_PROTO(h) -MSALDST_PROTO(w) -MSALDST_PROTO(d) -#undef MSALDST_PROTO
target/mips/tcg/msa_helper.c +0 -104
107 lines not on this page · raw message
target/mips/tcg/msa_translate.c +42 -12
83 lines not on this page · raw message
Signature · 1 line
2.53.0