target/sparc: Use explicit big-endian LD/ST API
v4 cover target/sparc: Use explicit big-endian LD/ST API
v4:
- Centralize sign-extension (clearly out of my comfort zone)
- Remove bswap in LD_code()
SPARC is big-endian. Use the explicit 'big'
endianness instead of the 'native' one.
Forbid further uses of legacy APIs.
Philippe Mathieu-Daudé (5):
qemu/int128: Add int128_signextend()
accel/tcg: Have cpu_ld*_mmu() methods consider the MO_SIGN flag target/sparc: Remove dubious swapping in LD_code() helper target/sparc: Replace MO_TE -> MO_BE
configs/targets: Forbid SPARC to use legacy native endianness APIs
configs/targets/sparc-linux-user.mak | 1 + configs/targets/sparc-softmmu.mak | 1 + configs/targets/sparc32plus-linux-user.mak | 1 + configs/targets/sparc64-linux-user.mak | 1 + configs/targets/sparc64-softmmu.mak | 1 + include/qemu/int128.h | 10 ++++ accel/tcg/cputlb.c | 37 +++++++++++--- target/sparc/ldst_helper.c | 18 ------- target/sparc/translate.c | 58 +++++++++++----------- tests/unit/test-int128.c | 22 ++++++++ 10 files changed, 97 insertions(+), 53 deletions(-)
Signature · 1 line
2.52.0
RFC PATCH v4 1/5 qemu/int128: Add int128_signextend()
Add a method to sign-extend a Int128, along with unit tests.
--- include/qemu/int128.h | 10 ++++++++++ tests/unit/test-int128.c | 22 ++++++++++++++++++++++ 2 files changed, 32 insertions(+)
include/qemu/int128.h +10 -0
@@ -62,6 +62,11 @@ static inline Int128 int128_exts64(int64_t a)return a; } +static inline Int128 int128_signextend (Int128 a) +{ +return int128_gethi (a) ? a :int128_exts64 (int128_getlo (a)); +} +static inline Int128 int128_not (Int128 a) {return ~a;
@@ -295,6 +300,11 @@ static inline Int128 int128_exts64(int64_t a)return int128_make128 (a, (a <0 ) ?-1 :0 ); } +static inline Int128 int128_signextend (Int128 a) +{ +return a.hi ? a :int128_exts64 (a.lo); +} +static inline Int128 int128_not (Int128 a) {return int128_make128 (~a.lo, ~a.hi);
tests/unit/test-int128.c +22 -0
@@ -255,6 +255,27 @@ static void test_urshift(void) 0x8000000000000000ULL); } +static void __attribute__((__noinline__)) ATTRIBUTE_NOCLONE +test_signextend_one (uint64_t ah,uint64_t al,uint64_t rh,uint64_t rl) +{ +Int128 r =int128_make128 (rl, rh); +Int128 s =int128_signextend (int128_make128 (al, ah)); + g_assert_cmphex(int128_getlo(r), ==, int128_getlo(s)); + g_assert_cmphex(int128_gethi(r), ==, int128_gethi(s)); +} + +static void test_signextend (void ) +{ +test_signextend_one (0x0000000000000000ULL ,0x0000000000000001ULL , +0x0000000000000000ULL ,0x0000000000000001ULL ); +test_signextend_one (0x0000000000000000ULL ,0x7FFFFFFFFFFFFFFEULL , +0x0000000000000000ULL ,0x7FFFFFFFFFFFFFFEULL ); +test_signextend_one (0x0000000000000000ULL ,0x8000000000000001ULL , +0xFFFFFFFFFFFFFFFFULL ,0x8000000000000001ULL ); +test_signextend_one (0xFFFFFFFFFFFFFFFFULL ,0xFFFFFFFFFFFFFFFEULL , +0xFFFFFFFFFFFFFFFFULL ,0xFFFFFFFFFFFFFFFEULL ); +} +int main (int argc,char **argv) {g_test_init (&argc, &argv,NULL );
@@ -269,5 +290,6 @@ int main(int argc, char **argv)g_test_add_func ("/int128/int128_gt" , test_gt);g_test_add_func ("/int128/int128_rshift" , test_rshift);g_test_add_func ("/int128/int128_urshift" , test_urshift); +g_test_add_func ("/int128/int128_signextend" , test_signextend);return g_test_run (); }
Signature · 1 line
2.52.0
Re: [RFC PATCH v4 1/5] qemu/int128: Add int128_signextend()
Quoted 1 line · Philippe Mathieu-Daudé
Add a method to sign-extend a Int128, along with unit tests.
What in the world does this mean?
I can't imagine a real use for this:
include/qemu/int128.h static inline Int128 int128_exts64(int64_t a) · line 306
Quoted 4 lines
include/qemu/int128.h +4
-0+static inline Int128 int128_signextend (Int128 a) +{ +return a.hi ? a :int128_exts64 (a.lo); +}
r~
Re: [RFC PATCH v4 1/5] qemu/int128: Add int128_signextend()
Quoted 11 lines · Richard Henderson
Quoted 1 line · Philippe Mathieu-Daudé
Add a method to sign-extend a Int128, along with unit tests.
What in the world does this mean?
I can't imagine a real use for this:
include/qemu/int128.h static inline Int128 int128_exts64(int64_t a) · line 306
Quoted 4 lines
include/qemu/int128.h +4
-0+static inline Int128 int128_signextend (Int128 a) +{ + return a.hi ? a : int128_exts64(a.lo); +}
Should we ignore MO_SIGN in do_ld16_mmu() in the
next patch then?
Re: [RFC PATCH v4 1/5] qemu/int128: Add int128_signextend()
Quoted 8 lines · Philippe Mathieu-Daudé
Quoted 7 lines · Richard Henderson
Quoted 1 line · Philippe Mathieu-Daudé
Add a method to sign-extend a Int128, along with unit tests.
What in the world does this mean?
I can't imagine a real use for this:
Quoted 7 lines
Quoted 4 lines
include/qemu/int128.h static inline Int128 int128_exts64(int64_t a) · line 306
Quoted 4 lines
include/qemu/int128.h +4
-0+static inline Int128 int128_signextend (Int128 a) +{ + return a.hi ? a : int128_exts64(a.lo); +}Should we ignore
MO_SIGNindo_ld16_mmu()in the
next patch then?
Well, since the next patch is broken... yes.
r~
RFC PATCH v4 2/5 accel/tcg: Have cpu_ld*_mmu() methods consider the MO_SIGN flag
In reply to Philippe Mathieu-DaudéSign-extend the result when the MO_SIGN flag is requested in TCG common CPU TLB handling.
Remote the SPARC specific handling.
--- accel/tcg/cputlb.c | 37 +++++++++++++++++++++++++++++++------ target/sparc/ldst_helper.c | 9 --------- 2 files changed, 31 insertions(+), 15 deletions(-)
accel/tcg/cputlb.c +31 -6
@@ -2296,12 +2296,18 @@ static uint8_t do_ld1_mmu(CPUState *cpu, vaddr addr, MemOpIdx oi, {MMULookupLocals l;bool crosspage; +uint8_t ret;cpu_req_mo (cpu,TCG_MO_LD_LD |TCG_MO_ST_LD ); crosspage =mmu_lookup (cpu, addr, oi, ra, access_type, &l);tcg_debug_assert (!crosspage); -return do_ld_1 (cpu, &l.page[0 ], l.mmu_idx, access_type, ra); + ret =do_ld_1 (cpu, &l.page[0 ], l.mmu_idx, access_type, ra); + +if (l.memop &MO_SIGN ) { + ret = (int8_t )ret; + } +return ret; } static uint16_t do_ld2_mmu(CPUState *cpu, vaddr addr, MemOpIdx oi,
@@ -2315,7 +2321,8 @@ static uint16_t do_ld2_mmu(CPUState *cpu, vaddr addr, MemOpIdx oi,cpu_req_mo (cpu,TCG_MO_LD_LD |TCG_MO_ST_LD ); crosspage =mmu_lookup (cpu, addr, oi, ra, access_type, &l);if (likely (!crosspage)) { -return do_ld_2 (cpu, &l.page[0 ], l.mmu_idx, access_type, l.memop, ra); + ret =do_ld_2 (cpu, &l.page[0 ], l.mmu_idx, access_type, l.memop, ra); + goto return_signextended; } a =do_ld_1 (cpu, &l.page[0 ], l.mmu_idx, access_type, ra);
@@ -2326,6 +2333,10 @@ static uint16_t do_ld2_mmu(CPUState *cpu, vaddr addr, MemOpIdx oi, }else { ret = b | (a <<8 ); } +return_signextended: +if (l.memop &MO_SIGN ) { + ret = (int16_t )ret; + }return ret; }
@@ -2339,7 +2350,8 @@ static uint32_t do_ld4_mmu(CPUState *cpu, vaddr addr, MemOpIdx oi,cpu_req_mo (cpu,TCG_MO_LD_LD |TCG_MO_ST_LD ); crosspage =mmu_lookup (cpu, addr, oi, ra, access_type, &l);if (likely (!crosspage)) { -return do_ld_4 (cpu, &l.page[0 ], l.mmu_idx, access_type, l.memop, ra); + ret =do_ld_4 (cpu, &l.page[0 ], l.mmu_idx, access_type, l.memop, ra); + goto return_signextended; } ret =do_ld_beN (cpu, &l.page[0 ],0 , l.mmu_idx, access_type, l.memop, ra);
@@ -2347,6 +2359,10 @@ static uint32_t do_ld4_mmu(CPUState *cpu, vaddr addr, MemOpIdx oi,if ((l.memop &MO_BSWAP ) ==MO_LE ) { ret =bswap32 (ret); } +return_signextended: +if (l.memop &MO_SIGN ) { + ret = (int32_t )ret; + }return ret; }
@@ -2360,7 +2376,8 @@ static uint64_t do_ld8_mmu(CPUState *cpu, vaddr addr, MemOpIdx oi,cpu_req_mo (cpu,TCG_MO_LD_LD |TCG_MO_ST_LD ); crosspage =mmu_lookup (cpu, addr, oi, ra, access_type, &l);if (likely (!crosspage)) { -return do_ld_8 (cpu, &l.page[0 ], l.mmu_idx, access_type, l.memop, ra); + ret =do_ld_8 (cpu, &l.page[0 ], l.mmu_idx, access_type, l.memop, ra); + goto return_signextended; } ret =do_ld_beN (cpu, &l.page[0 ],0 , l.mmu_idx, access_type, l.memop, ra);
@@ -2368,6 +2385,10 @@ static uint64_t do_ld8_mmu(CPUState *cpu, vaddr addr, MemOpIdx oi,if ((l.memop &MO_BSWAP ) ==MO_LE ) { ret =bswap64 (ret); } +return_signextended: +if (l.memop &MO_SIGN ) { + ret = (int64_t )ret; + }return ret; }
@@ -2396,7 +2417,7 @@ static Int128 do_ld16_mmu(CPUState *cpu, vaddr addr, ret =bswap128 (ret); } } -return ret; + goto return_signextended; } first = l.page[0 ].size;
@@ -2410,7 +2431,7 @@ static Int128 do_ld16_mmu(CPUState *cpu, vaddr addr, }else { ret =int128_make128 (b, a); } -return ret; + goto return_signextended; }if (first <8 ) {
@@ -2429,6 +2450,10 @@ static Int128 do_ld16_mmu(CPUState *cpu, vaddr addr,if ((l.memop &MO_BSWAP ) ==MO_LE ) { ret =bswap128 (ret); } +return_signextended: +if (l.memop &MO_SIGN ) { + ret =int128_signextend (ret); + }return ret; }
target/sparc/ldst_helper.c +0 -9
@@ -1163,27 +1163,18 @@ uint64_t helper_ld_code(CPUSPARCState *env, target_ulong addr, uint32_t oi)switch (mop &MO_SIZE ) {case MO_8 : ret =cpu_ldb_code_mmu (env, addr, oi, ra); -if (mop &MO_SIGN ) { - ret = (int8_t )ret; - }break ;case MO_16 : ret =cpu_ldw_code_mmu (env, addr, oi, ra);if ((mop &MO_BSWAP ) !=MO_TE ) { ret =bswap16 (ret); } -if (mop &MO_SIGN ) { - ret = (int16_t )ret; - }break ;case MO_32 : ret =cpu_ldl_code_mmu (env, addr, oi, ra);if ((mop &MO_BSWAP ) !=MO_TE ) { ret =bswap32 (ret); } -if (mop &MO_SIGN ) { - ret = (int32_t )ret; - }break ;case MO_64 : ret =cpu_ldq_code_mmu (env, addr, oi, ra);
Signature · 1 line
2.52.0
Re: [RFC PATCH v4 2/5] accel/tcg: Have cpu_ld*_mmu() methods consider the MO_SIGN flag
Quoted 23 lines · Philippe Mathieu-Daudé
Sign-extend the result when the
MO_SIGNflag is requested in TCG common CPU TLB handling.Remote the SPARC specific handling.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- accel/tcg/cputlb.c | 37 +++++++++++++++++++++++++++++++------ target/sparc/ldst_helper.c | 9 --------- 2 files changed, 31 insertions(+), 15 deletions(-)accel/tcg/cputlb.c +1
-0@@ -2296,12 +2296,18 @@ static uint8_t do_ld1_mmu(CPUState *cpu, vaddr addr, MemOpIdx oi, {MMULookupLocals l;bool crosspage; +uint8_t ret;cpu_req_mo (cpu,TCG_MO_LD_LD |TCG_MO_ST_LD ); crosspage =mmu_lookup (cpu, addr, oi, ra, access_type, &l);
accel/tcg/cputlb.c static uint8_t do_ld1_mmu(CPUState *cpu, vaddr addr, MemOpIdx oi, · line 2311
Quoted 10 lines
accel/tcg/cputlb.c +6
-1tcg_debug_assert (!crosspage); -return do_ld_1 (cpu, &l.page[0 ], l.mmu_idx, access_type, ra); + ret =do_ld_1 (cpu, &l.page[0 ], l.mmu_idx, access_type, ra); + +if (l.memop &MO_SIGN ) { + ret = (int8_t )ret; + } +return ret; }
Nope. The return type is uint8_t, so this doesn't change anything at all.
r~
Re: [RFC PATCH v4 2/5] accel/tcg: Have cpu_ld*_mmu() methods consider the MO_SIGN flag
Quoted 27 lines · Richard Henderson
Quoted 26 lines · Philippe Mathieu-Daudé
Sign-extend the result when the
MO_SIGNflag is requested in TCG common CPU TLB handling.Remote the SPARC specific handling.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
accel/tcg/cputlb.c | 37 +++++++++++++++++++++++++++++++------target/sparc/ldst_helper.c| 9 ---------2 files changed, 31 insertions(+), 15 deletions(-)accel/tcg/cputlb.c +2
-1@@ -2296,12 +2296,18 @@ static uint8_t do_ld1_mmu(CPUState *cpu, vaddr addr, MemOpIdx oi, { MMULookupLocals l; bool crosspage; + uint8_t ret; cpu_req_mo(cpu, TCG_MO_LD_LD | TCG_MO_ST_LD); crosspage = mmu_lookup(cpu, addr, oi, ra, access_type, &l); tcg_debug_assert(!crosspage); - return do_ld_1(cpu, &l.page[0], l.mmu_idx, access_type, ra); + ret = do_ld_1(cpu, &l.page[0], l.mmu_idx, access_type, ra);
Quoted 8 lines
accel/tcg/cputlb.c static uint8_t do_ld1_mmu(CPUState *cpu, vaddr addr, MemOpIdx oi, · line 2311
Quoted 6 lines
accel/tcg/cputlb.c +5
-0+ + if (l.memop & MO_SIGN) { + ret = (int8_t)ret; + } + return ret; }Nope. The return type is
uint8_t, so this doesn't change anything at all.
Oh, right <:)
PATCH v4 3/5 target/sparc: Remove dubious swapping in LD_code() helper
In reply to Philippe Mathieu-DaudéSince the endianness is contained in %oi, cpu_ld*_code_mmu() has already honored it. Swapping again makes no sense. Remove the bswap() calls.
--- target/sparc/ldst_helper.c | 9 --------- 1 file changed, 9 deletions(-)
target/sparc/ldst_helper.c +0 -9
@@ -1166,21 +1166,12 @@ uint64_t helper_ld_code(CPUSPARCState *env, target_ulong addr, uint32_t oi)break ;case MO_16 : ret =cpu_ldw_code_mmu (env, addr, oi, ra); -if ((mop &MO_BSWAP ) !=MO_TE ) { - ret =bswap16 (ret); - }break ;case MO_32 : ret =cpu_ldl_code_mmu (env, addr, oi, ra); -if ((mop &MO_BSWAP ) !=MO_TE ) { - ret =bswap32 (ret); - }break ;case MO_64 : ret =cpu_ldq_code_mmu (env, addr, oi, ra); -if ((mop &MO_BSWAP ) !=MO_TE ) { - ret =bswap64 (ret); - }break ;default :g_assert_not_reached ();
Signature · 1 line
2.52.0
Re: [PATCH v4 3/5] target/sparc: Remove dubious swapping in LD_code() helper
Quoted 10 lines · Philippe Mathieu-Daudé
Since the endianness is contained in %oi, cpu_ld*_code_mmu() has already honored it. Swapping again makes no sense. Remove the
bswap()calls.Fixes 2786a3f8d3a ("Use GET_ASI_CODE for ASI_KERNELTXT / ASI_USERTXT")Reported-by Richard Henderson <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/sparc/ldst_helper.c | 9 --------- 1 file changed, 9 deletions(-)
r~
Quoted 27 lines
target/sparc/ldst_helper.c +0
-9@@ -1166,21 +1166,12 @@ uint64_t helper_ld_code(CPUSPARCState *env, target_ulong addr, uint32_t oi)break ;case MO_16 : ret =cpu_ldw_code_mmu (env, addr, oi, ra); -if ((mop &MO_BSWAP ) !=MO_TE ) { - ret =bswap16 (ret); - }break ;case MO_32 : ret =cpu_ldl_code_mmu (env, addr, oi, ra); -if ((mop &MO_BSWAP ) !=MO_TE ) { - ret =bswap32 (ret); - }break ;case MO_64 : ret =cpu_ldq_code_mmu (env, addr, oi, ra); -if ((mop &MO_BSWAP ) !=MO_TE ) { - ret =bswap64 (ret); - }break ;default :g_assert_not_reached ();
Re: [PATCH v4 3/5] target/sparc: Remove dubious swapping in LD_code() helper
In reply to Philippe Mathieu-DaudéQuoted 7 lines · Philippe Mathieu-Daudé
Since the endianness is contained in %oi, cpu_ld*_code_mmu() has already honored it. Swapping again makes no sense. Remove the
bswap()calls.Fixes 2786a3f8d3a ("Use GET_ASI_CODE for ASI_KERNELTXT / ASI_USERTXT")Reported-by Richard Henderson <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>
This one feels like a qemu-stable material, is it not? (The talk's about 10.0.x, 10.1.x, 10.2.x series, where single-binary conversions weren't at the stage we're at now).
Thanks,
/mjt
Quoted 30 lines
--- target/sparc/ldst_helper.c | 9 --------- 1 file changed, 9 deletions(-)target/sparc/ldst_helper.c +0
-9@@ -1166,21 +1166,12 @@ uint64_t helper_ld_code(CPUSPARCState *env, target_ulong addr, uint32_t oi)break ;case MO_16 : ret =cpu_ldw_code_mmu (env, addr, oi, ra); -if ((mop &MO_BSWAP ) !=MO_TE ) { - ret =bswap16 (ret); - }break ;case MO_32 : ret =cpu_ldl_code_mmu (env, addr, oi, ra); -if ((mop &MO_BSWAP ) !=MO_TE ) { - ret =bswap32 (ret); - }break ;case MO_64 : ret =cpu_ldq_code_mmu (env, addr, oi, ra); -if ((mop &MO_BSWAP ) !=MO_TE ) { - ret =bswap64 (ret); - }break ;default :g_assert_not_reached ();
PATCH v4 4/5 target/sparc: Replace MO_TE -> MO_BE
In reply to Philippe Mathieu-DaudéWe only build the SPARC targets using big endianness order, therefore the MO_TE definitions expand to the big endian one. Use the latter which is more explicit.
Mechanical change running:
$ sed -i -e s/MO_TE/MO_BE/ \
$(git grep -wl MO_TE target/sparc/)--- target/sparc/translate.c | 58 ++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 29 deletions(-)
target/sparc/translate.c +29 -29
@@ -1764,7 +1764,7 @@ static DisasASI resolve_asi(DisasContext *dc, int asi, MemOp memop)case ASI_FL16_SL :case ASI_FL16_P :case ASI_FL16_PL : - memop =MO_TEUW ; + memop =MO_BEUW ; type =GET_ASI_SHORT ;break ; }
@@ -2215,7 +2215,7 @@ static void gen_ldda_asi(DisasContext *dc, DisasASI *da, TCGv addr, int rd)* byte swapped. We perform one 128-bit LE load, so must swap * the order of the writebacks. */ -if ((mop &MO_BSWAP ) ==MO_TE ) { +if ((mop &MO_BSWAP ) ==MO_BE ) {tcg_gen_extr_i128_i64 (lo, hi, t); }else {tcg_gen_extr_i128_i64 (hi, lo, t);
@@ -2235,7 +2235,7 @@ static void gen_ldda_asi(DisasContext *dc, DisasASI *da, TCGv addr, int rd)/* Note that LE ldda acts as if each 32-bit register result is byte swapped. Having just performed one 64-bit bswap, we need now to swap the writebacks. */ -if ((da->memop &MO_BSWAP ) ==MO_TE ) { +if ((da->memop &MO_BSWAP ) ==MO_BE ) {tcg_gen_extr_i64_tl (lo, hi, tmp); }else {tcg_gen_extr_i64_tl (hi, lo, tmp);
@@ -2252,7 +2252,7 @@ static void gen_ldda_asi(DisasContext *dc, DisasASI *da, TCGv addr, int rd)gen_helper_ld_code (tmp, tcg_env, addr,tcg_constant_i32 (oi));/* See above. */ -if ((da->memop &MO_BSWAP ) ==MO_TE ) { +if ((da->memop &MO_BSWAP ) ==MO_BE ) {tcg_gen_extr_i64_tl (lo, hi, tmp); }else {tcg_gen_extr_i64_tl (hi, lo, tmp);
@@ -2277,7 +2277,7 @@ static void gen_ldda_asi(DisasContext *dc, DisasASI *da, TCGv addr, int rd)gen_helper_ld_asi (tmp, tcg_env, addr, r_asi, r_mop);/* See above. */ -if ((da->memop &MO_BSWAP ) ==MO_TE ) { +if ((da->memop &MO_BSWAP ) ==MO_BE ) {tcg_gen_extr_i64_tl (lo, hi, tmp); }else {tcg_gen_extr_i64_tl (hi, lo, tmp);
@@ -2310,7 +2310,7 @@ static void gen_stda_asi(DisasContext *dc, DisasASI *da, TCGv addr, int rd)* byte swapped. We perform one 128-bit LE store, so must swap * the order of the construction. */ -if ((mop &MO_BSWAP ) ==MO_TE ) { +if ((mop &MO_BSWAP ) ==MO_BE ) {tcg_gen_concat_i64_i128 (t, lo, hi); }else {tcg_gen_concat_i64_i128 (t, hi, lo);
@@ -2329,7 +2329,7 @@ static void gen_stda_asi(DisasContext *dc, DisasASI *da, TCGv addr, int rd)/* Note that LE stda acts as if each 32-bit register result is byte swapped. We will perform one 64-bit LE store, so now we must swap the order of the construction. */ -if ((da->memop &MO_BSWAP ) ==MO_TE ) { +if ((da->memop &MO_BSWAP ) ==MO_BE ) {tcg_gen_concat_tl_i64 (t64, lo, hi); }else {tcg_gen_concat_tl_i64 (t64, hi, lo);
@@ -2345,7 +2345,7 @@ static void gen_stda_asi(DisasContext *dc, DisasASI *da, TCGv addr, int rd)* See comments for GET_ASI_COPY above. */ { -MemOp mop =MO_TE |MO_128 |MO_ATOM_IFALIGN_PAIR ; +MemOp mop =MO_BE |MO_128 |MO_ATOM_IFALIGN_PAIR ;TCGv_i64 t8 =tcg_temp_new_i64 ();TCGv_i128 t16 =tcg_temp_new_i128 ();TCGv daddr =tcg_temp_new ();
@@ -2368,7 +2368,7 @@ static void gen_stda_asi(DisasContext *dc, DisasASI *da, TCGv addr, int rd)TCGv_i64 t64 =tcg_temp_new_i64 ();/* See above. */ -if ((da->memop &MO_BSWAP ) ==MO_TE ) { +if ((da->memop &MO_BSWAP ) ==MO_BE ) {tcg_gen_concat_tl_i64 (t64, lo, hi); }else {tcg_gen_concat_tl_i64 (t64, hi, lo);
@@ -4428,13 +4428,13 @@ static bool do_ld_gpr(DisasContext *dc, arg_r_r_ri_asi *a, MemOp mop)return advance_pc (dc); } -TRANS(LDUW, ALL, do_ld_gpr, a, MO_TEUL) +TRANS(LDUW, ALL, do_ld_gpr, a, MO_BEUL) TRANS(LDUB, ALL, do_ld_gpr, a, MO_UB) -TRANS(LDUH, ALL, do_ld_gpr, a, MO_TEUW) +TRANS(LDUH, ALL, do_ld_gpr, a, MO_BEUW) TRANS(LDSB, ALL, do_ld_gpr, a, MO_SB) -TRANS(LDSH, ALL, do_ld_gpr, a, MO_TESW) -TRANS(LDSW, 64, do_ld_gpr, a, MO_TESL) -TRANS(LDX, 64, do_ld_gpr, a, MO_TEUQ) +TRANS(LDSH, ALL, do_ld_gpr, a, MO_BESW) +TRANS(LDSW, 64, do_ld_gpr, a, MO_BESL) +TRANS(LDX, 64, do_ld_gpr, a, MO_BEUQ)static bool do_st_gpr (DisasContext *dc,arg_r_r_ri_asi *a,MemOp mop) {
@@ -4451,10 +4451,10 @@ static bool do_st_gpr(DisasContext *dc, arg_r_r_ri_asi *a, MemOp mop)return advance_pc (dc); } -TRANS(STW, ALL, do_st_gpr, a, MO_TEUL) +TRANS(STW, ALL, do_st_gpr, a, MO_BEUL) TRANS(STB, ALL, do_st_gpr, a, MO_UB) -TRANS(STH, ALL, do_st_gpr, a, MO_TEUW) -TRANS(STX, 64, do_st_gpr, a, MO_TEUQ) +TRANS(STH, ALL, do_st_gpr, a, MO_BEUW) +TRANS(STX, 64, do_st_gpr, a, MO_BEUQ)static bool trans_LDD (DisasContext *dc,arg_r_r_ri_asi *a) {
@@ -4468,7 +4468,7 @@ static bool trans_LDD(DisasContext *dc, arg_r_r_ri_asi *a)if (addr ==NULL ) {return false; } - da =resolve_asi (dc, a->asi,MO_TEUQ ); + da =resolve_asi (dc, a->asi,MO_BEUQ );gen_ldda_asi (dc, &da, addr, a->rd);return advance_pc (dc); }
@@ -4485,7 +4485,7 @@ static bool trans_STD(DisasContext *dc, arg_r_r_ri_asi *a)if (addr ==NULL ) {return false; } - da =resolve_asi (dc, a->asi,MO_TEUQ ); + da =resolve_asi (dc, a->asi,MO_BEUQ );gen_stda_asi (dc, &da, addr, a->rd);return advance_pc (dc); }
@@ -4516,7 +4516,7 @@ static bool trans_SWAP(DisasContext *dc, arg_r_r_ri_asi *a)if (addr ==NULL ) {return false; } - da =resolve_asi (dc, a->asi,MO_TEUL ); + da =resolve_asi (dc, a->asi,MO_BEUL ); dst =gen_dest_gpr (dc, a->rd); src =gen_load_gpr (dc, a->rd);
@@ -4544,8 +4544,8 @@ static bool do_casa(DisasContext *dc, arg_r_r_ri_asi *a, MemOp mop)return advance_pc (dc); } -TRANS(CASA, CASA, do_casa, a, MO_TEUL) -TRANS(CASXA, 64, do_casa, a, MO_TEUQ) +TRANS(CASA, CASA, do_casa, a, MO_BEUL) +TRANS(CASXA, 64, do_casa, a, MO_BEUQ)static bool do_ld_fpr (DisasContext *dc,arg_r_r_ri_asi *a,MemOp sz) {
@@ -4561,7 +4561,7 @@ static bool do_ld_fpr(DisasContext *dc, arg_r_r_ri_asi *a, MemOp sz)if (sz ==MO_128 &&gen_trap_float128 (dc)) {return true; } - da =resolve_asi (dc, a->asi,MO_TE | sz); + da =resolve_asi (dc, a->asi,MO_BE | sz);gen_ldf_asi (dc, &da, sz, addr, a->rd);gen_update_fprs_dirty (dc, a->rd);return advance_pc (dc);
@@ -4590,7 +4590,7 @@ static bool do_st_fpr(DisasContext *dc, arg_r_r_ri_asi *a, MemOp sz)if (sz ==MO_128 &&gen_trap_float128 (dc)) {return true; } - da =resolve_asi (dc, a->asi,MO_TE | sz); + da =resolve_asi (dc, a->asi,MO_BE | sz);gen_stf_asi (dc, &da, sz, addr, a->rd);return advance_pc (dc); }
@@ -4629,7 +4629,7 @@ static bool trans_STDFQ(DisasContext *dc, arg_STDFQ *a)/* Store the single element from the queue. */ TCGv_i64 fq =tcg_temp_new_i64 (); tcg_gen_ld_i64(fq, tcg_env, offsetof(CPUSPARCState, fq.d)); -tcg_gen_qemu_st_i64 (fq, addr, dc->mem_idx,MO_TEUQ |MO_ALIGN_4 ); +tcg_gen_qemu_st_i64 (fq, addr, dc->mem_idx,MO_BEUQ |MO_ALIGN_4 );/* Mark the queue empty, transitioning to fp_execute state. */ tcg_gen_st_i32(tcg_constant_i32(0), tcg_env,
@@ -4655,7 +4655,7 @@ static bool trans_LDFSR(DisasContext *dc, arg_r_r_ri *a) } tmp =tcg_temp_new_i32 (); -tcg_gen_qemu_ld_i32 (tmp, addr, dc->mem_idx,MO_TEUL |MO_ALIGN ); +tcg_gen_qemu_ld_i32 (tmp, addr, dc->mem_idx,MO_BEUL |MO_ALIGN );tcg_gen_extract_i32 (cpu_fcc[0 ], tmp,FSR_FCC0_SHIFT ,2 );/* LDFSR does not change FCC[1-3]. */
@@ -4679,7 +4679,7 @@ static bool do_ldxfsr(DisasContext *dc, arg_r_r_ri *a, bool entire) } t64 =tcg_temp_new_i64 (); -tcg_gen_qemu_ld_i64 (t64, addr, dc->mem_idx,MO_TEUQ |MO_ALIGN ); +tcg_gen_qemu_ld_i64 (t64, addr, dc->mem_idx,MO_BEUQ |MO_ALIGN ); lo =tcg_temp_new_i32 (); hi = cpu_fcc[3 ];
@@ -4722,8 +4722,8 @@ static bool do_stfsr(DisasContext *dc, arg_r_r_ri *a, MemOp mop)return advance_pc (dc); } -TRANS(STFSR, ALL, do_stfsr, a, MO_TEUL) -TRANS(STXFSR, 64, do_stfsr, a, MO_TEUQ) +TRANS(STFSR, ALL, do_stfsr, a, MO_BEUL) +TRANS(STXFSR, 64, do_stfsr, a, MO_BEUQ)static bool do_fc (DisasContext *dc,int rd,int32_t c) {
Signature · 1 line
2.52.0
Re: [PATCH v4 4/5] target/sparc: Replace MO_TE -> MO_BE
Quoted 6 lines · Philippe Mathieu-Daudé
We only build the SPARC targets using big endianness order, therefore the
MO_TEdefinitions expand to the big endian one. Use the latter which is more explicit.Mechanical change running:
Quoted 8 lines
$ sed -i -e s/MO_TE/MO_BE/ \ $(git grep -wl MO_TE target/sparc/)Signed-off-by Philippe Mathieu-Daudé<[email protected]>Reviewed-by Manos Pitsidianakis<[email protected]>--- target/sparc/translate.c | 58 ++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 29 deletions(-)
r~
PATCH v4 5/5 configs/targets: Forbid SPARC to use legacy native endianness APIs
In reply to Philippe Mathieu-DaudéAll SPARC-related binaries are buildable without a single use of the legacy "native endian" API. Set the transitional TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API definition to forbid further uses of the legacy API.
--- configs/targets/sparc-linux-user.mak | 1 + configs/targets/sparc-softmmu.mak | 1 + configs/targets/sparc32plus-linux-user.mak | 1 + configs/targets/sparc64-linux-user.mak | 1 + configs/targets/sparc64-softmmu.mak | 1 + 5 files changed, 5 insertions(+)
configs/targets/sparc-linux-user.mak +1 -0
@@ -3,3 +3,4 @@ TARGET_SYSTBL_ABI=common,32 TARGET_SYSTBL=syscall.tbl TARGET_BIG_ENDIAN=y TARGET_LONG_BITS=32 +TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y
configs/targets/sparc-softmmu.mak +1 -0
@@ -1,3 +1,4 @@ TARGET_ARCH=sparc TARGET_BIG_ENDIAN=y TARGET_LONG_BITS=32 +TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y
configs/targets/sparc32plus-linux-user.mak +1 -0
@@ -6,3 +6,4 @@ TARGET_SYSTBL_ABI=common,32 TARGET_SYSTBL=syscall.tbl TARGET_BIG_ENDIAN=y TARGET_LONG_BITS=64 +TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y
configs/targets/sparc64-linux-user.mak +1 -0
@@ -6,3 +6,4 @@ TARGET_SYSTBL=syscall.tbl TARGET_BIG_ENDIAN=y TARGET_XML_FILES=gdb-xml/sparc64-core.xml TARGET_LONG_BITS=64 +TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y
configs/targets/sparc64-softmmu.mak +1 -0
@@ -4,3 +4,4 @@ TARGET_BIG_ENDIAN=y TARGET_XML_FILES=gdb-xml/sparc64-core.xml TARGET_LONG_BITS=64 TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y +TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y
Signature · 1 line
2.52.0
Re: [PATCH v4 5/5] configs/targets: Forbid SPARC to use legacy native endianness APIs
Quoted 7 lines · Philippe Mathieu-Daudé
All SPARC-related binaries are buildable without a single use of the legacy "native endian" API. Set the transitional
TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_APIdefinition to forbid further uses of the legacy API.Signed-off-by Philippe Mathieu-Daudé<[email protected]>Reviewed-by Manos Pitsidianakis<[email protected]>
Quoted 7 lines
--- configs/targets/sparc-linux-user.mak | 1 + configs/targets/sparc-softmmu.mak | 1 + configs/targets/sparc32plus-linux-user.mak | 1 + configs/targets/sparc64-linux-user.mak | 1 + configs/targets/sparc64-softmmu.mak | 1 + 5 files changed, 5 insertions(+)
r~