target/openrisc: Remove all uses of target_[u]long types
v3 cover target/openrisc: Remove all uses of target_[u]long types
Missing review: 7 -> 11
v3:
- Introduce mo_endian() helper
v2:
- Remove 'TARGET_LONG_BITS != 32' dead code
- Addressed Anton's review comments (MO_TE -> MO_BE)
Remove all the target_[u]long uses in OpenRISC frontend.
Based-on: <[email protected]>
Philippe Mathieu-Daudé (13):
target/openrisc: Replace VMSTATE_UINTTL() -> VMSTATE_UINT32() target/openrisc: Do not use target_ulong for @mr in MTSPR helper target/openrisc: Remove unused cpu_openrisc_map_address_*() handlers target/openrisc: Remove target_ulong use in raise_mmu_exception() target/openrisc: Use vaddr type for $pc jumps target/openrisc: Remove 'TARGET_LONG_BITS != 32' dead code target/openrisc: Explode MO_TExx -> MO_TE | MO_xx target/openrisc: Conceal MO_TE within do_load() target/openrisc: Conceal MO_TE within do_store() target/openrisc: Introduce mo_endian() helper target/openrisc: Replace MO_TE -> MO_BE
target/openrisc: Inline tcg_gen_trunc_i64_tl() target/openrisc: Replace target_ulong -> uint32_t
target/openrisc/cpu.h | 31 +-- target/openrisc/helper.h | 8 +- target/openrisc/fpu_helper.c | 8 +- target/openrisc/machine.c | 20 +- target/openrisc/mmu.c | 7 +- target/openrisc/sys_helper.c | 7 +- target/openrisc/translate.c | 459 +++++++++++++++++------------------ 7 files changed, 260 insertions(+), 280 deletions(-)
Signature · 1 line
2.51.0
PATCH v3 1/13 target/openrisc: Replace VMSTATE_UINTTL() -> VMSTATE_UINT32()
Both OpenRISCTLBEntry fields are of uint32_t type. Use the appropriate VMSTATE_UINT32() macro.
There is no functional change (the migration stream is not modified), because the OpenRISC targets are only built as 32-bit:
$ git grep TARGET_LONG_BITS configs/targets/or1k-* configs/targets/or1k-linux-user.mak:5:TARGET_LONG_BITS=32 configs/targets/or1k-softmmu.mak:5:TARGET_LONG_BITS=32
--- target/openrisc/machine.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
target/openrisc/machine.c +2 -2
@@ -26,8 +26,8 @@ static const VMStateDescription vmstate_tlb_entry = { .version_id = 1, .minimum_version_id = 1, .fields = (const VMStateField []) { -VMSTATE_UINTTL (mr, OpenRISCTLBEntry), -VMSTATE_UINTTL (tr, OpenRISCTLBEntry), +VMSTATE_UINT32 (mr, OpenRISCTLBEntry), +VMSTATE_UINT32 (tr, OpenRISCTLBEntry),VMSTATE_END_OF_LIST () } };
Signature · 1 line
2.51.0
PATCH v3 2/13 target/openrisc: Do not use target_ulong for @mr in MTSPR helper
In reply to Philippe Mathieu-DaudéOpenRISCTLBEntry::@mr field is a uint32_t type since its introduction in commit 726fe045720 ("target-or32: Add MMU support").
--- target/openrisc/sys_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/openrisc/sys_helper.c +1 -1
@@ -45,7 +45,7 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong spr, target_ulong rb)OpenRISCCPU *cpu =env_archcpu (env);#ifndef CONFIG_USER_ONLY CPUState *cs =env_cpu (env); -target_ulong mr; +uint32_t mr;int idx;#endif
Signature · 1 line
2.51.0
PATCH v3 3/13 target/openrisc: Remove unused cpu_openrisc_map_address_*() handlers
In reply to Philippe Mathieu-DaudéCommit 23d45ebdb19 ("target/openrisc: Remove indirect function calls for mmu") removed the last uses of both cpu_openrisc_map_address_code() and cpu_openrisc_map_address_data() helpers.
--- target/openrisc/cpu.h | 9 --------- 1 file changed, 9 deletions(-)
target/openrisc/cpu.h +0 -9
@@ -220,15 +220,6 @@ typedef struct OpenRISCTLBEntry {typedef struct CPUOpenRISCTLBContext {OpenRISCTLBEntry itlb[TLB_SIZE ];OpenRISCTLBEntry dtlb[TLB_SIZE ]; - -int (*cpu_openrisc_map_address_code)(OpenRISCCPU *cpu, -hwaddr *physical, -int *prot, -target_ulong address,int rw); -int (*cpu_openrisc_map_address_data)(OpenRISCCPU *cpu, -hwaddr *physical, -int *prot, -target_ulong address,int rw); }CPUOpenRISCTLBContext ;#endif
Signature · 1 line
2.51.0
PATCH v3 4/13 target/openrisc: Remove target_ulong use in raise_mmu_exception()
In reply to Philippe Mathieu-DaudéTCGCPUOps::tlb_fill() handler provides a vaddr type (since commit 7510454e3e7 "cpu: Turn cpu_handle_mmu_fault() into a CPUClass hook").
Do not inline get_phys_nommu(), rely on the linker to optimize at linking time.
--- target/openrisc/mmu.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
target/openrisc/mmu.c +3 -4
@@ -28,15 +28,14 @@#include "qemu/host-utils.h" #include "hw/loader.h" -static inline void get_phys_nommu (hwaddr *phys_addr,int *prot, -target_ulong address) +static void get_phys_nommu (hwaddr *phys_addr,int *prot,vaddr address) { *phys_addr = address; *prot =PAGE_READ |PAGE_WRITE |PAGE_EXEC ; }static int get_phys_mmu (OpenRISCCPU *cpu,hwaddr *phys_addr,int *prot, -target_ulong addr,int need,bool super) +vaddr addr,int need,bool super) {int idx = (addr >>TARGET_PAGE_BITS ) &TLB_MASK ;uint32_t imr = cpu->env.tlb.itlb[idx].mr;
@@ -95,7 +94,7 @@ static int get_phys_mmu(OpenRISCCPU *cpu, hwaddr *phys_addr, int *prot, } } -static void raise_mmu_exception (OpenRISCCPU *cpu,target_ulong address, +static void raise_mmu_exception (OpenRISCCPU *cpu,vaddr address,int exception) {CPUState *cs =CPU (cpu);
Signature · 1 line
2.51.0
PATCH v3 5/13 target/openrisc: Use vaddr type for $pc jumps
In reply to Philippe Mathieu-Daudétranslator_use_goto_tb() expects a vaddr type since commit b1c09220b4c ("accel/tcg: Replace target_ulong with vaddr in translator_*()").
--- target/openrisc/translate.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
target/openrisc/translate.c +6 -6
@@ -51,7 +51,7 @@ typedef struct DisasContext {uint32_t avr;/* If not -1, jmp_pc contains this value and so is a direct jump. */ -target_ulong jmp_pc_imm; +vaddr jmp_pc_imm;/* The temporary corresponding to register 0 for this compilation. */ TCGv R0 ;
@@ -580,7 +580,7 @@ static bool trans_l_muldu(DisasContext *dc, arg_ab *a)static bool trans_l_j (DisasContext *dc,arg_l_j *a) { -target_ulong tmp_pc = dc->base.pc_next + a->n *4 ; +vaddr tmp_pc = dc->base.pc_next + a->n *4 ;tcg_gen_movi_tl (jmp_pc, tmp_pc); dc->jmp_pc_imm = tmp_pc;
@@ -590,8 +590,8 @@ static bool trans_l_j(DisasContext *dc, arg_l_j *a)static bool trans_l_jal (DisasContext *dc,arg_l_jal *a) { -target_ulong tmp_pc = dc->base.pc_next + a->n *4 ; -target_ulong ret_pc = dc->base.pc_next +8 ; +vaddr tmp_pc = dc->base.pc_next + a->n *4 ; +vaddr ret_pc = dc->base.pc_next +8 ;tcg_gen_movi_tl (cpu_regs[9 ], ret_pc);/* Optimize jal being used to load the PC for PIC. */
@@ -605,7 +605,7 @@ static bool trans_l_jal(DisasContext *dc, arg_l_jal *a)static void do_bf (DisasContext *dc,arg_l_bf *a,TCGCond cond) { -target_ulong tmp_pc = dc->base.pc_next + a->n *4 ; +vaddr tmp_pc = dc->base.pc_next + a->n *4 ;TCGv t_next =tcg_constant_tl (dc->base.pc_next +8 );TCGv t_true =tcg_constant_tl (tmp_pc);
@@ -1586,7 +1586,7 @@ static void openrisc_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)static void openrisc_tr_tb_stop (DisasContextBase *dcbase,CPUState *cs) {DisasContext *dc =container_of (dcbase, DisasContext, base); -target_ulong jmp_dest; +vaddr jmp_dest;/* If we have already exited the TB, nothing following has effect. */ if (dc->base.is_jmp ==DISAS_NORETURN ) {
Signature · 1 line
2.51.0
PATCH v3 6/13 target/openrisc: Remove 'TARGET_LONG_BITS != 32' dead code
In reply to Philippe Mathieu-DaudéThe OpenRISC targets are only built as 32-bit:
$ git grep TARGET_LONG_BITS configs/targets/or1k-* configs/targets/or1k-linux-user.mak:5:TARGET_LONG_BITS=32 configs/targets/or1k-softmmu.mak:5:TARGET_LONG_BITS=32
Remove the dead code guarded within TARGET_LONG_BITS != 32.
--- target/openrisc/translate.c | 33 ++++----------------------------- 1 file changed, 4 insertions(+), 29 deletions(-)
target/openrisc/translate.c +4 -29
@@ -298,19 +298,8 @@ static void gen_muld(DisasContext *dc, TCGv srca, TCGv srcb)tcg_gen_ext_tl_i64 (t1, srca);tcg_gen_ext_tl_i64 (t2, srcb); -if (TARGET_LONG_BITS ==32 ) { -tcg_gen_mul_i64 (cpu_mac, t1, t2); -tcg_gen_movi_tl (cpu_sr_ov,0 ); - }else { -TCGv_i64 high =tcg_temp_new_i64 (); - -tcg_gen_muls2_i64 (cpu_mac, high, t1, t2); -tcg_gen_sari_i64 (t1, cpu_mac,63 ); -tcg_gen_negsetcond_i64 (TCG_COND_NE , t1, t1, high); -tcg_gen_trunc_i64_tl (cpu_sr_ov, t1); - -gen_ove_ov (dc); - } +tcg_gen_mul_i64 (cpu_mac, t1, t2); +tcg_gen_movi_tl (cpu_sr_ov,0 ); }static void gen_muldu (DisasContext *dc,TCGv srca,TCGv srcb)
@@ -320,18 +309,8 @@ static void gen_muldu(DisasContext *dc, TCGv srca, TCGv srcb)tcg_gen_extu_tl_i64 (t1, srca);tcg_gen_extu_tl_i64 (t2, srcb); -if (TARGET_LONG_BITS ==32 ) { -tcg_gen_mul_i64 (cpu_mac, t1, t2); -tcg_gen_movi_tl (cpu_sr_cy,0 ); - }else { -TCGv_i64 high =tcg_temp_new_i64 (); - -tcg_gen_mulu2_i64 (cpu_mac, high, t1, t2); -tcg_gen_setcondi_i64 (TCG_COND_NE , high, high,0 ); -tcg_gen_trunc_i64_tl (cpu_sr_cy, high); - -gen_ove_cy (dc); - } +tcg_gen_mul_i64 (cpu_mac, t1, t2); +tcg_gen_movi_tl (cpu_sr_cy,0 ); }static void gen_mac (DisasContext *dc,TCGv srca,TCGv srcb)
@@ -349,11 +328,7 @@ static void gen_mac(DisasContext *dc, TCGv srca, TCGv srcb)tcg_gen_xor_i64 (t1, t1, cpu_mac);tcg_gen_andc_i64 (t1, t1, t2); -#if TARGET_LONG_BITS ==32 tcg_gen_extrh_i64_i32 (cpu_sr_ov, t1); -#else -tcg_gen_mov_i64 (cpu_sr_ov, t1); -#endif gen_ove_ov (dc); }
Signature · 1 line
2.51.0
PATCH v3 7/13 target/openrisc: Explode MO_TExx -> MO_TE | MO_xx
In reply to Philippe Mathieu-DaudéExtract the implicit MO_TE definition in order to replace it in the next commit.
Mechanical change using:
$ for n in UW UL UQ UO SW SL SQ; do \
sed -i -e "s/MO_TE$n/MO_TE | MO_$n/" \
$(git grep -l MO_TE$n target/openrisc); \
done--- target/openrisc/translate.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
target/openrisc/translate.c +8 -8
@@ -622,7 +622,7 @@ static bool trans_l_lwa(DisasContext *dc, arg_load *a)check_r0_write (dc, a->d); ea =tcg_temp_new ();tcg_gen_addi_tl (ea,cpu_R (dc, a->a), a->i); -tcg_gen_qemu_ld_tl (cpu_R (dc, a->d), ea, dc->mem_idx,MO_TEUL ); +tcg_gen_qemu_ld_tl (cpu_R (dc, a->d), ea, dc->mem_idx,MO_TE |MO_UL );tcg_gen_mov_tl (cpu_lock_addr, ea);tcg_gen_mov_tl (cpu_lock_value,cpu_R (dc, a->d));return true;
@@ -640,13 +640,13 @@ static void do_load(DisasContext *dc, arg_load *a, MemOp mop)static bool trans_l_lwz (DisasContext *dc,arg_load *a) { -do_load (dc, a,MO_TEUL ); +do_load (dc, a,MO_TE |MO_UL );return true; }static bool trans_l_lws (DisasContext *dc,arg_load *a) { -do_load (dc, a,MO_TESL ); +do_load (dc, a,MO_TE |MO_SL );return true; }
@@ -664,13 +664,13 @@ static bool trans_l_lbs(DisasContext *dc, arg_load *a)static bool trans_l_lhz (DisasContext *dc,arg_load *a) { -do_load (dc, a,MO_TEUW ); +do_load (dc, a,MO_TE |MO_UW );return true; }static bool trans_l_lhs (DisasContext *dc,arg_load *a) { -do_load (dc, a,MO_TESW ); +do_load (dc, a,MO_TE |MO_SW );return true; }
@@ -688,7 +688,7 @@ static bool trans_l_swa(DisasContext *dc, arg_store *a) val =tcg_temp_new ();tcg_gen_atomic_cmpxchg_tl (val, cpu_lock_addr, cpu_lock_value, -cpu_R (dc, a->b), dc->mem_idx,MO_TEUL ); +cpu_R (dc, a->b), dc->mem_idx,MO_TE |MO_UL );tcg_gen_setcond_tl (TCG_COND_EQ , cpu_sr_f, val, cpu_lock_value);tcg_gen_br (lab_done);
@@ -710,7 +710,7 @@ static void do_store(DisasContext *dc, arg_store *a, MemOp mop)static bool trans_l_sw (DisasContext *dc,arg_store *a) { -do_store (dc, a,MO_TEUL ); +do_store (dc, a,MO_TE |MO_UL );return true; }
@@ -722,7 +722,7 @@ static bool trans_l_sb(DisasContext *dc, arg_store *a)static bool trans_l_sh (DisasContext *dc,arg_store *a) { -do_store (dc, a,MO_TEUW ); +do_store (dc, a,MO_TE |MO_UW );return true; }
Signature · 1 line
2.51.0
Re: [PATCH v3 07/13] target/openrisc: Explode MO_TExx -> MO_TE | MO_xx
Quoted 10 lines · Philippe Mathieu-Daudé
Extract the implicit
MO_TEdefinition in order to replace it in the next commit.Mechanical change using:
$ for n in UW UL UQ UO SW SL SQ; do \ sed -i -e "s/MO_TE$n/MO_TE | MO_$n/" \ $(git grep -l MO_TE$n target/openrisc); \ done
Quoted 4 lines
Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- target/openrisc/translate.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
r~
PATCH v3 8/13 target/openrisc: Conceal MO_TE within do_load()
In reply to Philippe Mathieu-Daudé--- target/openrisc/translate.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
target/openrisc/translate.c +5 -4
@@ -633,6 +633,7 @@ static void do_load(DisasContext *dc, arg_load *a, MemOp mop)TCGv ea;check_r0_write (dc, a->d); + mop |=MO_TE ; ea =tcg_temp_new ();tcg_gen_addi_tl (ea,cpu_R (dc, a->a), a->i);tcg_gen_qemu_ld_tl (cpu_R (dc, a->d), ea, dc->mem_idx, mop);
@@ -640,13 +641,13 @@ static void do_load(DisasContext *dc, arg_load *a, MemOp mop)static bool trans_l_lwz (DisasContext *dc,arg_load *a) { -do_load (dc, a,MO_TE |MO_UL ); +do_load (dc, a,MO_UL );return true; }static bool trans_l_lws (DisasContext *dc,arg_load *a) { -do_load (dc, a,MO_TE |MO_SL ); +do_load (dc, a,MO_SL );return true; }
@@ -664,13 +665,13 @@ static bool trans_l_lbs(DisasContext *dc, arg_load *a)static bool trans_l_lhz (DisasContext *dc,arg_load *a) { -do_load (dc, a,MO_TE |MO_UW ); +do_load (dc, a,MO_UW );return true; }static bool trans_l_lhs (DisasContext *dc,arg_load *a) { -do_load (dc, a,MO_TE |MO_SW ); +do_load (dc, a,MO_SW );return true; }
Signature · 1 line
2.51.0
Re: [PATCH v3 08/13] target/openrisc: Conceal MO_TE within do_load()
Quoted 4 lines · Philippe Mathieu-Daudé
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/openrisc/translate.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
r~
PATCH v3 9/13 target/openrisc: Conceal MO_TE within do_store()
In reply to Philippe Mathieu-Daudé--- target/openrisc/translate.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
target/openrisc/translate.c +4 -2
@@ -705,13 +705,15 @@ static bool trans_l_swa(DisasContext *dc, arg_store *a)static void do_store (DisasContext *dc,arg_store *a,MemOp mop) {TCGv t0 =tcg_temp_new (); + + mop |=MO_TE ;tcg_gen_addi_tl (t0,cpu_R (dc, a->a), a->i);tcg_gen_qemu_st_tl (cpu_R (dc, a->b), t0, dc->mem_idx, mop); }static bool trans_l_sw (DisasContext *dc,arg_store *a) { -do_store (dc, a,MO_TE |MO_UL ); +do_store (dc, a,MO_UL );return true; }
@@ -723,7 +725,7 @@ static bool trans_l_sb(DisasContext *dc, arg_store *a)static bool trans_l_sh (DisasContext *dc,arg_store *a) { -do_store (dc, a,MO_TE |MO_UW ); +do_store (dc, a,MO_UW );return true; }
Signature · 1 line
2.51.0
Re: [PATCH v3 09/13] target/openrisc: Conceal MO_TE within do_store()
Quoted 4 lines · Philippe Mathieu-Daudé
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/openrisc/translate.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
r~
PATCH v3 10/13 target/openrisc: Introduce mo_endian() helper
In reply to Philippe Mathieu-Daudémo_endian() returns the target endianness.
--- target/openrisc/translate.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
target/openrisc/translate.c +11 -4
@@ -59,6 +59,11 @@ typedef struct DisasContext {TCGv zero; } DisasContext; +static inline MemOp mo_endian (DisasContext *dc) +{ +return MO_TE ; +} +static inline bool is_user (DisasContext *dc) {#ifdef CONFIG_USER_ONLY
@@ -622,7 +627,8 @@ static bool trans_l_lwa(DisasContext *dc, arg_load *a)check_r0_write (dc, a->d); ea =tcg_temp_new ();tcg_gen_addi_tl (ea,cpu_R (dc, a->a), a->i); -tcg_gen_qemu_ld_tl (cpu_R (dc, a->d), ea, dc->mem_idx,MO_TE |MO_UL ); +tcg_gen_qemu_ld_tl (cpu_R (dc, a->d), ea, dc->mem_idx, +mo_endian (dc) |MO_UL );tcg_gen_mov_tl (cpu_lock_addr, ea);tcg_gen_mov_tl (cpu_lock_value,cpu_R (dc, a->d));return true;
@@ -633,7 +639,7 @@ static void do_load(DisasContext *dc, arg_load *a, MemOp mop)TCGv ea;check_r0_write (dc, a->d); - mop |=MO_TE ; + mop |=mo_endian (dc); ea =tcg_temp_new ();tcg_gen_addi_tl (ea,cpu_R (dc, a->a), a->i);tcg_gen_qemu_ld_tl (cpu_R (dc, a->d), ea, dc->mem_idx, mop);
@@ -689,7 +695,8 @@ static bool trans_l_swa(DisasContext *dc, arg_store *a) val =tcg_temp_new ();tcg_gen_atomic_cmpxchg_tl (val, cpu_lock_addr, cpu_lock_value, -cpu_R (dc, a->b), dc->mem_idx,MO_TE |MO_UL ); +cpu_R (dc, a->b), dc->mem_idx, +mo_endian (dc) |MO_UL );tcg_gen_setcond_tl (TCG_COND_EQ , cpu_sr_f, val, cpu_lock_value);tcg_gen_br (lab_done);
@@ -706,7 +713,7 @@ static void do_store(DisasContext *dc, arg_store *a, MemOp mop) {TCGv t0 =tcg_temp_new (); - mop |=MO_TE ; + mop |=mo_endian (dc);tcg_gen_addi_tl (t0,cpu_R (dc, a->a), a->i);tcg_gen_qemu_st_tl (cpu_R (dc, a->b), t0, dc->mem_idx, mop); }
Signature · 1 line
2.51.0
Re: [PATCH v3 10/13] target/openrisc: Introduce mo_endian() helper
Quoted 6 lines · Philippe Mathieu-Daudé
mo_endian()returns the target endianness.Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- target/openrisc/translate.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
r~
PATCH v3 11/13 target/openrisc: Replace MO_TE -> MO_BE
In reply to Philippe Mathieu-DaudéWe only build the OpenRISC targets using big endianness order:
$ git grep TARGET_BIG_ENDIAN configs/targets/or1k-* configs/targets/or1k-linux-user.mak:2:TARGET_BIG_ENDIAN=y configs/targets/or1k-softmmu.mak:2:TARGET_BIG_ENDIAN=y
Therefore the MO_TE definition always expands to MO_BE. Use the latter to simplify.
--- target/openrisc/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/openrisc/translate.c +1 -1
@@ -61,7 +61,7 @@ typedef struct DisasContext {static inline MemOp mo_endian (DisasContext *dc) { -return MO_TE ; +return MO_BE ; }static inline bool is_user (DisasContext *dc)
Signature · 1 line
2.51.0
Re: [PATCH v3 11/13] target/openrisc: Replace MO_TE -> MO_BE
Quoted 19 lines · Philippe Mathieu-Daudé
We only build the OpenRISC targets using big endianness order:
$ git grep TARGET_BIG_ENDIAN configs/targets/or1k-* configs/targets/or1k-linux-user.mak:2:TARGET_BIG_ENDIAN=y configs/targets/or1k-softmmu.mak:2:TARGET_BIG_ENDIAN=yTherefore the
MO_TEdefinition always expands toMO_BE. Use the latter to simplify.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/openrisc/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/openrisc/translate.c +0
-0
target/openrisc/translate.c typedef struct DisasContext { · line 67
Quoted 8 lines
target/openrisc/translate.c +1
-1@@ -61,7 +61,7 @@ typedef struct DisasContext {static inline MemOp mo_endian (DisasContext *dc) { -return MO_TE ; +return MO_BE ; }static inline bool is_user (DisasContext *dc)
Add the same sort of 'little-endian enabled by SR[LEE]' comment that you did for RISC-V.
Otherwise,
r~
Re: [PATCH v3 11/13] target/openrisc: Replace MO_TE -> MO_BE
Quoted 15 lines · Richard Henderson
Quoted 14 lines · Philippe Mathieu-Daudé
We only build the OpenRISC targets using big endianness order:
$ git grep TARGET_BIG_ENDIAN configs/targets/or1k-* configs/targets/or1k-linux-user.mak:2:TARGET_BIG_ENDIAN=y configs/targets/or1k-softmmu.mak:2:TARGET_BIG_ENDIAN=yTherefore the
MO_TEdefinition always expands toMO_BE. Use the latter to simplify.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
target/openrisc/translate.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines
target/openrisc/translate.c typedef struct DisasContext { · line 65
Quoted 11 lines
target/openrisc/translate.c +1
-1@@ -61,7 +61,7 @@ typedef struct DisasContext { static inline MemOp mo_endian(DisasContext *dc) { - return MO_TE; + return MO_BE; } static inline bool is_user(DisasContext *dc)Add the same sort of 'little-endian enabled by SR[LEE]' comment that you did for RISC-V.
I squashed:
/* The SR_LEE bit sets the (little) endianness, but we don't
implement it. */
Quoted 3 lines
Otherwise,
Reviewed-by Richard Henderson <[email protected]>
Thanks!
PATCH v3 12/13 target/openrisc: Inline tcg_gen_trunc_i64_tl()
In reply to Philippe Mathieu-DaudéThe OpenRISC targets are only built as 32-bit, so tcg_gen_trunc_i64_tl expands to tcg_gen_extrl_i64_i32(). Use the latter to simplify the next commit mechanical change.
--- target/openrisc/translate.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
target/openrisc/translate.c +3 -3
@@ -350,7 +350,7 @@ static void gen_macu(DisasContext *dc, TCGv srca, TCGv srcb)/* Note that overflow is only computed during addition stage. */ tcg_gen_add_i64 (cpu_mac, cpu_mac, t1);tcg_gen_setcond_i64 (TCG_COND_LTU , t1, cpu_mac, t1); -tcg_gen_trunc_i64_tl (cpu_sr_cy, t1); +tcg_gen_extrl_i64_i32 (cpu_sr_cy, t1);gen_ove_cy (dc); }
@@ -391,7 +391,7 @@ static void gen_msbu(DisasContext *dc, TCGv srca, TCGv srcb)/* Note that overflow is only computed during subtraction stage. */ tcg_gen_setcond_i64 (TCG_COND_LTU , t2, cpu_mac, t1);tcg_gen_sub_i64 (cpu_mac, cpu_mac, t1); -tcg_gen_trunc_i64_tl (cpu_sr_cy, t2); +tcg_gen_extrl_i64_i32 (cpu_sr_cy, t2);gen_ove_cy (dc); }
@@ -914,7 +914,7 @@ static bool trans_l_movhi(DisasContext *dc, arg_l_movhi *a)static bool trans_l_macrc (DisasContext *dc,arg_l_macrc *a) {check_r0_write (dc, a->d); -tcg_gen_trunc_i64_tl (cpu_R (dc, a->d), cpu_mac); +tcg_gen_extrl_i64_i32 (cpu_R (dc, a->d), cpu_mac);tcg_gen_movi_i64 (cpu_mac,0 );return true; }
Signature · 1 line
2.51.0
PATCH v3 13/13 target/openrisc: Replace target_ulong -> uint32_t
In reply to Philippe Mathieu-DaudéThe OpenRISC targets are only built as 32-bit:
$ git grep TARGET_LONG_BITS configs/targets/or1k-* configs/targets/or1k-linux-user.mak:5:TARGET_LONG_BITS=32 configs/targets/or1k-softmmu.mak:5:TARGET_LONG_BITS=32
Therefore target_ulong always expands to uint32_t. Replace and adapt the API uses mechanically:
target_ulong -> uint32_t
target_long -> int32_t
tl -> i32
TCGv -> TCGv_i32
tcg_temp_new -> tcg_temp_new_i32
tcg_global_mem_new -> tcg_global_mem_new_i32
VMSTATE_UINTTL -> VMSTATE_UINT32
There is no functional change (the migration stream is not modified).
--- target/openrisc/cpu.h | 22 +- target/openrisc/helper.h | 8 +- target/openrisc/fpu_helper.c | 8 +- target/openrisc/machine.c | 16 +- target/openrisc/sys_helper.c | 5 +- target/openrisc/translate.c | 392 ++++++++++++++++++----------------- 6 files changed, 228 insertions(+), 223 deletions(-)
target/openrisc/cpu.h +11 -11
@@ -224,20 +224,20 @@ typedef struct CPUOpenRISCTLBContext {#endif typedef struct CPUArchState { - target_ulong shadow_gpr[16][32]; /* Shadow registers */ + uint32_t shadow_gpr[16][32]; /* Shadow registers */ - target_ulong pc; /* Program counter */ - target_ulong ppc; /* Prev PC */ - target_ulong jmp_pc; /* Jump PC */ + uint32_t pc; /* Program counter */ + uint32_t ppc; /* Prev PC */ + uint32_t jmp_pc; /* Jump PC */ uint64_t mac; /* Multiply registers MACHI:MACLO */ - target_ulong epcr; /* Exception PC register */ - target_ulong eear; /* Exception EA register */ + uint32_t epcr; /* Exception PC register */ + uint32_t eear; /* Exception EA register */ - target_ulong sr_f; /* the SR_F bit, values 0, 1. */ - target_ulong sr_cy; /* the SR_CY bit, values 0, 1. */ - target_long sr_ov; /* the SR_OV bit (in the sign bit only) */ + uint32_t sr_f; /* the SR_F bit, values 0, 1. */ + uint32_t sr_cy; /* the SR_CY bit, values 0, 1. */ + int32_t sr_ov; /* the SR_OV bit (in the sign bit only) */ uint32_t sr; /* Supervisor register, without SR_{F,CY,OV} */ uint32_t esr; /* Exception supervisor register */ uint32_t evbar; /* Exception vector base address register */
@@ -245,8 +245,8 @@ typedef struct CPUArchState {uint32_t fpcsr;/* Float register */ float_status fp_status; -target_ulong lock_addr; -target_ulong lock_value; +uint32_t lock_addr; +uint32_t lock_value;uint32_t dflag;/* In delay slot (boolean) */
target/openrisc/helper.h +4 -4
@@ -47,8 +47,8 @@ FOP_CALC(rem)#undef FOP_CALC#define FOP_CMP (op) \ -DEF_HELPER_FLAGS_3(float_ ## op ## _s, TCG_CALL_NO_RWG, tl, env, i32, i32) \ -DEF_HELPER_FLAGS_3(float_ ## op ## _d, TCG_CALL_NO_RWG, tl, env, i64, i64) +DEF_HELPER_FLAGS_3(float_ ## op ## _s, TCG_CALL_NO_RWG, i32, env, i32, i32) \ +DEF_HELPER_FLAGS_3(float_ ## op ## _d, TCG_CALL_NO_RWG, i32, env, i64, i64) FOP_CMP(eq) FOP_CMP(lt) FOP_CMP(le)
@@ -62,5 +62,5 @@ FOP_CMP(ult)DEF_HELPER_FLAGS_1 (rfe,0 , void, env) /* sys */ -DEF_HELPER_FLAGS_3(mtspr, 0, void, env, tl, tl) -DEF_HELPER_FLAGS_3 (mfspr,TCG_CALL_NO_WG , tl, env, tl, tl) +DEF_HELPER_FLAGS_3(mtspr, 0, void, env, i32, i32) +DEF_HELPER_FLAGS_3 (mfspr,TCG_CALL_NO_WG , i32, env, i32, i32)
target/openrisc/fpu_helper.c +4 -4
@@ -146,10 +146,10 @@ uint32_t helper_float_madd_s(CPUOpenRISCState *env, uint32_t a,#define FLOAT_CMP (name, impl) \ -target_ulong helper_float_ ## name ## _d(CPUOpenRISCState *env, \ +uint32_t helper_float_ ## name ## _d(CPUOpenRISCState *env, \ uint64_t fdt0, uint64_t fdt1) \ { return float64_ ## impl(fdt0, fdt1, &env->fp_status); } \ -target_ulong helper_float_ ## name ## _s(CPUOpenRISCState *env, \ +uint32_t helper_float_ ## name ## _s(CPUOpenRISCState *env, \ uint32_t fdt0, uint32_t fdt1) \ { return float32_ ## impl(fdt0, fdt1, &env->fp_status); }
@@ -160,13 +160,13 @@ FLOAT_CMP(un, unordered_quiet)#undef FLOAT_CMP#define FLOAT_UCMP (name, expr) \ -target_ulong helper_float_ ## name ## _d(CPUOpenRISCState *env, \ +uint32_t helper_float_ ## name ## _d(CPUOpenRISCState *env, \ uint64_t fdt0, uint64_t fdt1) \ { \ FloatRelation r = float64_compare_quiet(fdt0, fdt1, &env->fp_status); \ return expr; \ } \ -target_ulong helper_float_ ## name ## _s(CPUOpenRISCState *env, \ +uint32_t helper_float_ ## name ## _s(CPUOpenRISCState *env, \ uint32_t fdt0, uint32_t fdt1) \ { \ FloatRelation r = float32_compare_quiet(fdt0, fdt1, &env->fp_status); \
target/openrisc/machine.c +8 -8
@@ -72,14 +72,14 @@ static const VMStateDescription vmstate_env = { .version_id = 6, .minimum_version_id = 6, .fields = (const VMStateField []) { -VMSTATE_UINTTL_2DARRAY (shadow_gpr, CPUOpenRISCState,16 ,32 ), -VMSTATE_UINTTL (pc, CPUOpenRISCState), -VMSTATE_UINTTL (ppc, CPUOpenRISCState), -VMSTATE_UINTTL (jmp_pc, CPUOpenRISCState), -VMSTATE_UINTTL (lock_addr, CPUOpenRISCState), -VMSTATE_UINTTL (lock_value, CPUOpenRISCState), -VMSTATE_UINTTL (epcr, CPUOpenRISCState), -VMSTATE_UINTTL (eear, CPUOpenRISCState), +VMSTATE_UINT32_2DARRAY (shadow_gpr, CPUOpenRISCState,16 ,32 ), +VMSTATE_UINT32 (pc, CPUOpenRISCState), +VMSTATE_UINT32 (ppc, CPUOpenRISCState), +VMSTATE_UINT32 (jmp_pc, CPUOpenRISCState), +VMSTATE_UINT32 (lock_addr, CPUOpenRISCState), +VMSTATE_UINT32 (lock_value, CPUOpenRISCState), +VMSTATE_UINT32 (epcr, CPUOpenRISCState), +VMSTATE_UINT32 (eear, CPUOpenRISCState),/* Save the architecture value of the SR, not the internally expanded version. Since this architecture value does not
target/openrisc/sys_helper.c +2 -3
@@ -40,7 +40,7 @@ static inline bool is_user(CPUOpenRISCState *env)#endif } -void HELPER (mtspr )(CPUOpenRISCState *env,target_ulong spr,target_ulong rb) +void HELPER (mtspr )(CPUOpenRISCState *env,uint32_t spr,uint32_t rb) {OpenRISCCPU *cpu =env_archcpu (env);#ifndef CONFIG_USER_ONLY
@@ -213,8 +213,7 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong spr, target_ulong rb)#endif } -target_ulong HELPER (mfspr )(CPUOpenRISCState *env,target_ulong rd, -target_ulong spr) +uint32_t HELPER (mfspr )(CPUOpenRISCState *env,uint32_t rd,uint32_t spr) {OpenRISCCPU *cpu =env_archcpu (env);#ifndef CONFIG_USER_ONLY
target/openrisc/translate.c +199 -193
994 lines not on this page · raw message
Signature · 1 line
2.51.0
Quoted 4 lines · Philippe Mathieu-Daudé
Remove all the target_[u]long uses in OpenRISC frontend.
Based-on: <[email protected]>
Quoted 14 lines
Philippe Mathieu-Daudé (13):
target/openrisc: ReplaceVMSTATE_UINTTL()->VMSTATE_UINT32()target/openrisc: Do not usetarget_ulongfor @mr in MTSPR helper target/openrisc: Remove unused cpu_openrisc_map_address_*() handlers target/openrisc: Removetarget_ulonguse inraise_mmu_exception()target/openrisc: Use vaddr type for $pc jumps target/openrisc: Remove 'TARGET_LONG_BITS!= 32' dead code target/openrisc: ExplodeMO_TExx->MO_TE|MO_xxtarget/openrisc: ConcealMO_TEwithindo_load()target/openrisc: ConcealMO_TEwithindo_store()target/openrisc: Introducemo_endian()helper target/openrisc: ReplaceMO_TE->MO_BE
target/openrisc: Inlinetcg_gen_trunc_i64_tl()target/openrisc: Replacetarget_ulong->uint32_t
Series queued, thanks!