target/hexagon: Stop using the legacy native-endian APIs
v2 cover target/hexagon: Stop using the legacy native-endian APIs
v2: patch #2 was incomplete
Hexagon is always little-endian, making the conversion easy.
Philippe Mathieu-Daudé (3):
target/hexagon: Inline translator_ldl()
target/hexagon: Use little-endian variant of cpu_ld/st_data*() configs/targets: Forbid Hexagon to use legacy native endianness API
configs/targets/hexagon-linux-user.mak | 1 - target/hexagon/macros.h | 6 +++--- target/hexagon/op_helper.c | 6 +++--- target/hexagon/translate.c | 11 +++++++---- 4 files changed, 13 insertions(+), 11 deletions(-)
Signature · 1 line
2.52.0
PATCH v2 1/3 target/hexagon: Inline translator_ldl()
translator_ldl() is defined in "exec/translator.h" as:
198 static inline uint32_t
199 translator_ldl(CPUArchState *env, DisasContextBase *db, vaddr pc)
200 {
201 return translator_ldl_end(env, db, pc, MO_TE);
202 }Directly use the inlined form, expanding MO_TE -> MO_LE since Hexagon use little-endian order.
--- target/hexagon/translate.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
target/hexagon/translate.c +7 -4
@@ -203,8 +203,9 @@ static int read_packet_words(CPUHexagonState *env, DisasContext *ctx,memset (words,0 ,PACKET_WORDS_MAX *sizeof (uint32_t ));for (nwords =0 ; !found_end && nwords <PACKET_WORDS_MAX ; nwords++) { words[nwords] = -translator_ldl (env, &ctx->base, - ctx->base.pc_next + nwords *sizeof (uint32_t )); +translator_ldl_end (env, &ctx->base, + ctx->base.pc_next + nwords *sizeof (uint32_t ), +MO_LE ); found_end =is_packet_end (words[nwords]); }if (!found_end) {
@@ -966,8 +967,10 @@ static bool pkt_crosses_page(CPUHexagonState *env, DisasContext *ctx)int nwords;for (nwords =0 ; !found_end && nwords <PACKET_WORDS_MAX ; nwords++) { -uint32_t word =translator_ldl (env, &ctx->base, - ctx->base.pc_next + nwords *sizeof (uint32_t )); +uint32_t word =translator_ldl_end (env, &ctx->base, + ctx->base.pc_next + + nwords *sizeof (uint32_t ), +MO_LE ); found_end =is_packet_end (word); }uint32_t next_ptr = ctx->base.pc_next + nwords *sizeof (uint32_t );
Signature · 1 line
2.52.0
PATCH v2 2/3 target/hexagon: Use little-endian variant of cpu_ld/st_data*()
In reply to Philippe Mathieu-DaudéWe only build the Hexagon target using little endianness order, therefore the cpu_ld/st_data*() definitions expand to the little endian declarations. Use the explicit little-endian variants.
Mechanical change running:
$ tgt=hexagon; \
end=le; \
for op in data mmuidx_ra; do \
for ac in uw sw l q; do \
sed -i -e "s/cpu_ld${ac}_${op}/cpu_ld${ac}_${end}_${op}/" \
$(git grep -l cpu_ target/${tgt}/); \
done;
for ac in w l q; do \
sed -i -e "s/cpu_st${ac}_${op}/cpu_st${ac}_${end}_${op}/" \
$(git grep -l cpu_ target/${tgt}/); \
done;
done--- target/hexagon/macros.h | 6 +++--- target/hexagon/op_helper.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)
target/hexagon/macros.h +3 -3
@@ -519,9 +519,9 @@ static inline TCGv gen_read_ireg(TCGv result, TCGv val, int shift)#define fLOAD (NUM ,SIZE ,SIGN ,EA ,DST ) MEM_LOAD##SIZE##SIGN(DST, EA)#else #define MEM_LOAD1 cpu_ldub_data_ra -#define MEM_LOAD2 cpu_lduw_data_ra -#define MEM_LOAD4 cpu_ldl_data_ra -#define MEM_LOAD8 cpu_ldq_data_ra +#define MEM_LOAD2 cpu_lduw_le_data_ra +#define MEM_LOAD4 cpu_ldl_le_data_ra +#define MEM_LOAD8 cpu_ldq_le_data_ra#define fLOAD (NUM ,SIZE ,SIGN ,EA ,DST ) \ do { \
target/hexagon/op_helper.c +3 -3
@@ -77,13 +77,13 @@ static void commit_store(CPUHexagonState *env, int slot_num, uintptr_t ra)cpu_stb_data_ra (env, va, env->mem_log_stores[slot_num].data32, ra);break ;case 2 : -cpu_stw_data_ra (env, va, env->mem_log_stores[slot_num].data32, ra); +cpu_stw_le_data_ra (env, va, env->mem_log_stores[slot_num].data32, ra);break ;case 4 : -cpu_stl_data_ra (env, va, env->mem_log_stores[slot_num].data32, ra); +cpu_stl_le_data_ra (env, va, env->mem_log_stores[slot_num].data32, ra);break ;case 8 : -cpu_stq_data_ra (env, va, env->mem_log_stores[slot_num].data64, ra); +cpu_stq_le_data_ra (env, va, env->mem_log_stores[slot_num].data64, ra);break ;default :g_assert_not_reached ();
Signature · 1 line
2.52.0
PATCH v2 3/3 configs/targets: Forbid Hexagon to use legacy native endianness API
In reply to Philippe Mathieu-DaudéThe qemu-hexagon binary is buildable without a single use of the legacy "native endian" API. Unset the transitional TARGET_USE_LEGACY_NATIVE_ENDIAN_API definition to forbid further uses of the legacy API.
Preliminary commits related to this change:
- beb38fda0f0 target/hexagon: Replace MO_TE -> MO_LE
- fdcb7483ae0 target/hexagon: Explode MO_TExx -> MO_TE | MO_xx
--- configs/targets/hexagon-linux-user.mak | 1 - 1 file changed, 1 deletion(-)
configs/targets/hexagon-linux-user.mak +0 -1
@@ -3,4 +3,3 @@ TARGET_XML_FILES=gdb-xml/hexagon-core.xml gdb-xml/hexagon-hvx.xml TARGET_SYSTBL=syscall.tbl TARGET_SYSTBL_ABI=common,32,hexagon,time32,stat64,rlimit,renameat TARGET_LONG_BITS=32 -TARGET_USE_LEGACY_NATIVE_ENDIAN_API=y
Signature · 1 line
2.52.0