target/openrisc updates
cover target/openrisc updates
The first three fix an MTTCG race on cpu_R[0], now that we do code generation in parallel.
Then some updates to the SPRs, cpuid checks for existing float insns, adding the new v1.3 instructions.
I've run this through the gcc testsuite as
make check-gcc \
RUNTESTFLAGS='--target_board=or1k-qemu/-mhard-float/-mdouble-float execute.exp'
=== gcc Summary ===
# of expected passes 103979 # of unexpected failures 26 # of expected failures 400 # of unresolved testcases 1 # of unsupported tests 2539
Of the 26, none are obviously floating-point related.
r~
Richard Henderson (13):
target/openrisc: Add DisasContext parameter to check_r0_write target/openrisc: Replace cpu register array with a function target/openrisc: Cache R0 in DisasContext target/openrisc: Make VR and PPC read-only target/openrisc: Move VR, UPR, DMMCFGR, IMMCFGR to cpu init target/openrisc: Add VR2 and AVR special processor registers target/openrisc: Fix lf.ftoi.s
target/openrisc: Check CPUCFG_OF32S for float insns target/openrisc: Add support for ORFPX64A32 target/openrisc: Implement unordered fp comparisons target/openrisc: Implement move to/from FPCSR target/openrisc: Implement l.adrp
target/openrisc: Update cpu "any" to v1.3
linux-user/openrisc/target_elf.h | 2 +- target/openrisc/cpu.h | 24 +- target/openrisc/helper.h | 6 + target/openrisc/cpu.c | 30 +- target/openrisc/disas.c | 81 ++++ target/openrisc/fpu_helper.c | 49 ++- target/openrisc/machine.c | 11 + target/openrisc/sys_helper.c | 38 +- target/openrisc/translate.c | 716 +++++++++++++++++++++++-------- target/openrisc/insns.decode | 45 ++ 10 files changed, 774 insertions(+), 228 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/13 target/openrisc: Add DisasContext parameter to check_r0_write
We will need this context in the next patch.
--- target/openrisc/translate.c | 96 +++++++++++++++++++------------------ 1 file changed, 49 insertions(+), 47 deletions(-)
target/openrisc/translate.c +49 -47
@@ -163,14 +163,16 @@ static void check_ov64s(DisasContext *dc)} #endif*/ -/* We're about to write to REG. On the off-chance that the user is -writing to R0, re-instate the architectural register. */ -#define check_r0_write (reg) \ - do { \ - if (unlikely(reg == 0)) { \ - cpu_R[0] = cpu_R0; \ - } \ - } while (0) +/* +* We're about to write to REG. On the off-chance that the user is +* writing to R0, re-instate the architectural register. +*/ +static void check_r0_write (DisasContext *dc,int reg) +{ +if (unlikely (reg ==0 )) { + cpu_R[0 ] = cpu_R0; + } +}static void gen_ove_cy (DisasContext *dc) {
@@ -436,98 +438,98 @@ static void gen_msbu(DisasContext *dc, TCGv srca, TCGv srcb)static bool trans_l_add (DisasContext *dc,arg_dab *a) { -check_r0_write (a->d); +check_r0_write (dc, a->d);gen_add (dc, cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]);return true; }static bool trans_l_addc (DisasContext *dc,arg_dab *a) { -check_r0_write (a->d); +check_r0_write (dc, a->d);gen_addc (dc, cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]);return true; }static bool trans_l_sub (DisasContext *dc,arg_dab *a) { -check_r0_write (a->d); +check_r0_write (dc, a->d);gen_sub (dc, cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]);return true; }static bool trans_l_and (DisasContext *dc,arg_dab *a) { -check_r0_write (a->d); +check_r0_write (dc, a->d);tcg_gen_and_tl (cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]);return true; }static bool trans_l_or (DisasContext *dc,arg_dab *a) { -check_r0_write (a->d); +check_r0_write (dc, a->d);tcg_gen_or_tl (cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]);return true; }static bool trans_l_xor (DisasContext *dc,arg_dab *a) { -check_r0_write (a->d); +check_r0_write (dc, a->d);tcg_gen_xor_tl (cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]);return true; }static bool trans_l_sll (DisasContext *dc,arg_dab *a) { -check_r0_write (a->d); +check_r0_write (dc, a->d);tcg_gen_shl_tl (cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]);return true; }static bool trans_l_srl (DisasContext *dc,arg_dab *a) { -check_r0_write (a->d); +check_r0_write (dc, a->d);tcg_gen_shr_tl (cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]);return true; }static bool trans_l_sra (DisasContext *dc,arg_dab *a) { -check_r0_write (a->d); +check_r0_write (dc, a->d);tcg_gen_sar_tl (cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]);return true; }static bool trans_l_ror (DisasContext *dc,arg_dab *a) { -check_r0_write (a->d); +check_r0_write (dc, a->d);tcg_gen_rotr_tl (cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]);return true; }static bool trans_l_exths (DisasContext *dc,arg_da *a) { -check_r0_write (a->d); +check_r0_write (dc, a->d);tcg_gen_ext16s_tl (cpu_R[a->d], cpu_R[a->a]);return true; }static bool trans_l_extbs (DisasContext *dc,arg_da *a) { -check_r0_write (a->d); +check_r0_write (dc, a->d);tcg_gen_ext8s_tl (cpu_R[a->d], cpu_R[a->a]);return true; }static bool trans_l_exthz (DisasContext *dc,arg_da *a) { -check_r0_write (a->d); +check_r0_write (dc, a->d);tcg_gen_ext16u_tl (cpu_R[a->d], cpu_R[a->a]);return true; }static bool trans_l_extbz (DisasContext *dc,arg_da *a) { -check_r0_write (a->d); +check_r0_write (dc, a->d);tcg_gen_ext8u_tl (cpu_R[a->d], cpu_R[a->a]);return true; }
@@ -536,7 +538,7 @@ static bool trans_l_cmov(DisasContext *dc, arg_dab *a) {TCGv zero; -check_r0_write (a->d); +check_r0_write (dc, a->d); zero =tcg_const_tl (0 );tcg_gen_movcond_tl (TCG_COND_NE , cpu_R[a->d], cpu_sr_f, zero, cpu_R[a->a], cpu_R[a->b]);
@@ -546,7 +548,7 @@ static bool trans_l_cmov(DisasContext *dc, arg_dab *a)static bool trans_l_ff1 (DisasContext *dc,arg_da *a) { -check_r0_write (a->d); +check_r0_write (dc, a->d);tcg_gen_ctzi_tl (cpu_R[a->d], cpu_R[a->a],-1 );tcg_gen_addi_tl (cpu_R[a->d], cpu_R[a->d],1 );return true;
@@ -554,7 +556,7 @@ static bool trans_l_ff1(DisasContext *dc, arg_da *a)static bool trans_l_fl1 (DisasContext *dc,arg_da *a) { -check_r0_write (a->d); +check_r0_write (dc, a->d);tcg_gen_clzi_tl (cpu_R[a->d], cpu_R[a->a],TARGET_LONG_BITS );tcg_gen_subfi_tl (cpu_R[a->d],TARGET_LONG_BITS , cpu_R[a->d]);return true;
@@ -562,28 +564,28 @@ static bool trans_l_fl1(DisasContext *dc, arg_da *a)static bool trans_l_mul (DisasContext *dc,arg_dab *a) { -check_r0_write (a->d); +check_r0_write (dc, a->d);gen_mul (dc, cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]);return true; }static bool trans_l_mulu (DisasContext *dc,arg_dab *a) { -check_r0_write (a->d); +check_r0_write (dc, a->d);gen_mulu (dc, cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]);return true; }static bool trans_l_div (DisasContext *dc,arg_dab *a) { -check_r0_write (a->d); +check_r0_write (dc, a->d);gen_div (dc, cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]);return true; }static bool trans_l_divu (DisasContext *dc,arg_dab *a) { -check_r0_write (a->d); +check_r0_write (dc, a->d);gen_divu (dc, cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]);return true; }
@@ -671,7 +673,7 @@ static bool trans_l_lwa(DisasContext *dc, arg_load *a) {TCGv ea; -check_r0_write (a->d); +check_r0_write (dc, a->d); ea =tcg_temp_new ();tcg_gen_addi_tl (ea, cpu_R[a->a], a->i);tcg_gen_qemu_ld_tl (cpu_R[a->d], ea, dc->mem_idx,MO_TEUL );
@@ -685,7 +687,7 @@ static void do_load(DisasContext *dc, arg_load *a, TCGMemOp mop) {TCGv ea; -check_r0_write (a->d); +check_r0_write (dc, a->d); ea =tcg_temp_new ();tcg_gen_addi_tl (ea, cpu_R[a->a], a->i);tcg_gen_qemu_ld_tl (cpu_R[a->d], ea, dc->mem_idx, mop);
@@ -798,7 +800,7 @@ static bool trans_l_addi(DisasContext *dc, arg_rri *a) {TCGv t0; -check_r0_write (a->d); +check_r0_write (dc, a->d); t0 =tcg_const_tl (a->i);gen_add (dc, cpu_R[a->d], cpu_R[a->a], t0);tcg_temp_free (t0);
@@ -809,7 +811,7 @@ static bool trans_l_addic(DisasContext *dc, arg_rri *a) {TCGv t0; -check_r0_write (a->d); +check_r0_write (dc, a->d); t0 =tcg_const_tl (a->i);gen_addc (dc, cpu_R[a->d], cpu_R[a->a], t0);tcg_temp_free (t0);
@@ -820,7 +822,7 @@ static bool trans_l_muli(DisasContext *dc, arg_rri *a) {TCGv t0; -check_r0_write (a->d); +check_r0_write (dc, a->d); t0 =tcg_const_tl (a->i);gen_mul (dc, cpu_R[a->d], cpu_R[a->a], t0);tcg_temp_free (t0);
@@ -839,28 +841,28 @@ static bool trans_l_maci(DisasContext *dc, arg_l_maci *a)static bool trans_l_andi (DisasContext *dc,arg_rrk *a) { -check_r0_write (a->d); +check_r0_write (dc, a->d);tcg_gen_andi_tl (cpu_R[a->d], cpu_R[a->a], a->k);return true; }static bool trans_l_ori (DisasContext *dc,arg_rrk *a) { -check_r0_write (a->d); +check_r0_write (dc, a->d);tcg_gen_ori_tl (cpu_R[a->d], cpu_R[a->a], a->k);return true; }static bool trans_l_xori (DisasContext *dc,arg_rri *a) { -check_r0_write (a->d); +check_r0_write (dc, a->d);tcg_gen_xori_tl (cpu_R[a->d], cpu_R[a->a], a->i);return true; }static bool trans_l_mfspr (DisasContext *dc,arg_l_mfspr *a) { -check_r0_write (a->d); +check_r0_write (dc, a->d);if (is_user (dc)) {gen_illegal_exception (dc);
@@ -927,42 +929,42 @@ static bool trans_l_msbu(DisasContext *dc, arg_ab *a)static bool trans_l_slli (DisasContext *dc,arg_dal *a) { -check_r0_write (a->d); +check_r0_write (dc, a->d);tcg_gen_shli_tl (cpu_R[a->d], cpu_R[a->a], a->l & (TARGET_LONG_BITS -1 ));return true; }static bool trans_l_srli (DisasContext *dc,arg_dal *a) { -check_r0_write (a->d); +check_r0_write (dc, a->d);tcg_gen_shri_tl (cpu_R[a->d], cpu_R[a->a], a->l & (TARGET_LONG_BITS -1 ));return true; }static bool trans_l_srai (DisasContext *dc,arg_dal *a) { -check_r0_write (a->d); +check_r0_write (dc, a->d);tcg_gen_sari_tl (cpu_R[a->d], cpu_R[a->a], a->l & (TARGET_LONG_BITS -1 ));return true; }static bool trans_l_rori (DisasContext *dc,arg_dal *a) { -check_r0_write (a->d); +check_r0_write (dc, a->d);tcg_gen_rotri_tl (cpu_R[a->d], cpu_R[a->a], a->l & (TARGET_LONG_BITS -1 ));return true; }static bool trans_l_movhi (DisasContext *dc,arg_l_movhi *a) { -check_r0_write (a->d); +check_r0_write (dc, a->d);tcg_gen_movi_tl (cpu_R[a->d], a->k <<16 );return true; }static bool trans_l_macrc (DisasContext *dc,arg_l_macrc *a) { -check_r0_write (a->d); +check_r0_write (dc, a->d);tcg_gen_trunc_i64_tl (cpu_R[a->d], cpu_mac);tcg_gen_movi_i64 (cpu_mac,0 );return true;
@@ -1134,7 +1136,7 @@ static bool trans_l_rfe(DisasContext *dc, arg_l_rfe *a)static void do_fp2 (DisasContext *dc,arg_da *a,void (*fn)(TCGv ,TCGv_env ,TCGv )) { -check_r0_write (a->d); +check_r0_write (dc, a->d);fn (cpu_R[a->d], cpu_env, cpu_R[a->a]);gen_helper_update_fpcsr (cpu_env); }
@@ -1142,7 +1144,7 @@ static void do_fp2(DisasContext *dc, arg_da *a,static void do_fp3 (DisasContext *dc,arg_dab *a,void (*fn)(TCGv ,TCGv_env ,TCGv ,TCGv )) { -check_r0_write (a->d); +check_r0_write (dc, a->d);fn (cpu_R[a->d], cpu_env, cpu_R[a->a], cpu_R[a->b]);gen_helper_update_fpcsr (cpu_env); }
@@ -1206,7 +1208,7 @@ static bool trans_lf_ftoi_s(DisasContext *dc, arg_da *a)static bool trans_lf_madd_s (DisasContext *dc,arg_dab *a) { -check_r0_write (a->d); +check_r0_write (dc, a->d);gen_helper_float_madd_s (cpu_R[a->d], cpu_env, cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]);gen_helper_update_fpcsr (cpu_env);
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH 01/13] target/openrisc: Add DisasContext parameter to check_r0_write
Quoted 3 lines · Richard Henderson
We will need this context in the next patch.
Signed-off-by Richard Henderson <[email protected]>
PATCH 2/13 target/openrisc: Replace cpu register array with a function
In reply to Richard HendersonThe writes to cpu_R[0] are now a race across threads, now that we do code generation in parallel. Stage the change by introducing a function to return the temp for R0.
--- target/openrisc/translate.c | 213 ++++++++++++++++++++---------------- 1 file changed, 116 insertions(+), 97 deletions(-)
target/openrisc/translate.c +116 -97
@@ -63,7 +63,7 @@ static inline bool is_user(DisasContext *dc)#include "decode.inc.c" static TCGv cpu_sr; -static TCGv cpu_R[32 ]; +static TCGv cpu_regs[32 ];static TCGv cpu_R0;static TCGv cpu_pc;static TCGv jmp_pc;/* l.jr/l.jalr temp pc */
@@ -117,12 +117,12 @@ void openrisc_translate_init(void) offsetof(CPUOpenRISCState , mac), "mac");for (i =0 ; i <32 ; i++) { - cpu_R[i] =tcg_global_mem_new (cpu_env, - offsetof(CPUOpenRISCState , - shadow_gpr[0][i]), - regnames[i]); + cpu_regs[i] =tcg_global_mem_new (cpu_env, + offsetof(CPUOpenRISCState , + shadow_gpr[0][i]), + regnames[i]); } - cpu_R0 = cpu_R[0 ]; + cpu_R0 = cpu_regs[0 ]; }static void gen_exception (DisasContext *dc,unsigned int excp)
@@ -163,6 +163,11 @@ static void check_ov64s(DisasContext *dc)} #endif*/ +static TCGv cpu_R (DisasContext *dc,int reg) +{ +return cpu_regs[reg]; +} +/* * We're about to write to REG. On the off-chance that the user is * writing to R0, re-instate the architectural register.
@@ -170,7 +175,7 @@ static void check_ov64s(DisasContext *dc)static void check_r0_write (DisasContext *dc,int reg) {if (unlikely (reg ==0 )) { - cpu_R[0 ] = cpu_R0; + cpu_regs[0 ] = cpu_R0; } }
@@ -439,98 +444,98 @@ static void gen_msbu(DisasContext *dc, TCGv srca, TCGv srcb)static bool trans_l_add (DisasContext *dc,arg_dab *a) {check_r0_write (dc, a->d); -gen_add (dc, cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]); +gen_add (dc,cpu_R (dc, a->d),cpu_R (dc, a->a),cpu_R (dc, a->b));return true; }static bool trans_l_addc (DisasContext *dc,arg_dab *a) {check_r0_write (dc, a->d); -gen_addc (dc, cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]); +gen_addc (dc,cpu_R (dc, a->d),cpu_R (dc, a->a),cpu_R (dc, a->b));return true; }static bool trans_l_sub (DisasContext *dc,arg_dab *a) {check_r0_write (dc, a->d); -gen_sub (dc, cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]); +gen_sub (dc,cpu_R (dc, a->d),cpu_R (dc, a->a),cpu_R (dc, a->b));return true; }static bool trans_l_and (DisasContext *dc,arg_dab *a) {check_r0_write (dc, a->d); -tcg_gen_and_tl (cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]); +tcg_gen_and_tl (cpu_R (dc, a->d),cpu_R (dc, a->a),cpu_R (dc, a->b));return true; }static bool trans_l_or (DisasContext *dc,arg_dab *a) {check_r0_write (dc, a->d); -tcg_gen_or_tl (cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]); +tcg_gen_or_tl (cpu_R (dc, a->d),cpu_R (dc, a->a),cpu_R (dc, a->b));return true; }static bool trans_l_xor (DisasContext *dc,arg_dab *a) {check_r0_write (dc, a->d); -tcg_gen_xor_tl (cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]); +tcg_gen_xor_tl (cpu_R (dc, a->d),cpu_R (dc, a->a),cpu_R (dc, a->b));return true; }static bool trans_l_sll (DisasContext *dc,arg_dab *a) {check_r0_write (dc, a->d); -tcg_gen_shl_tl (cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]); +tcg_gen_shl_tl (cpu_R (dc, a->d),cpu_R (dc, a->a),cpu_R (dc, a->b));return true; }static bool trans_l_srl (DisasContext *dc,arg_dab *a) {check_r0_write (dc, a->d); -tcg_gen_shr_tl (cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]); +tcg_gen_shr_tl (cpu_R (dc, a->d),cpu_R (dc, a->a),cpu_R (dc, a->b));return true; }static bool trans_l_sra (DisasContext *dc,arg_dab *a) {check_r0_write (dc, a->d); -tcg_gen_sar_tl (cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]); +tcg_gen_sar_tl (cpu_R (dc, a->d),cpu_R (dc, a->a),cpu_R (dc, a->b));return true; }static bool trans_l_ror (DisasContext *dc,arg_dab *a) {check_r0_write (dc, a->d); -tcg_gen_rotr_tl (cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]); +tcg_gen_rotr_tl (cpu_R (dc, a->d),cpu_R (dc, a->a),cpu_R (dc, a->b));return true; }static bool trans_l_exths (DisasContext *dc,arg_da *a) {check_r0_write (dc, a->d); -tcg_gen_ext16s_tl (cpu_R[a->d], cpu_R[a->a]); +tcg_gen_ext16s_tl (cpu_R (dc, a->d),cpu_R (dc, a->a));return true; }static bool trans_l_extbs (DisasContext *dc,arg_da *a) {check_r0_write (dc, a->d); -tcg_gen_ext8s_tl (cpu_R[a->d], cpu_R[a->a]); +tcg_gen_ext8s_tl (cpu_R (dc, a->d),cpu_R (dc, a->a));return true; }static bool trans_l_exthz (DisasContext *dc,arg_da *a) {check_r0_write (dc, a->d); -tcg_gen_ext16u_tl (cpu_R[a->d], cpu_R[a->a]); +tcg_gen_ext16u_tl (cpu_R (dc, a->d),cpu_R (dc, a->a));return true; }static bool trans_l_extbz (DisasContext *dc,arg_da *a) {check_r0_write (dc, a->d); -tcg_gen_ext8u_tl (cpu_R[a->d], cpu_R[a->a]); +tcg_gen_ext8u_tl (cpu_R (dc, a->d),cpu_R (dc, a->a));return true; }
@@ -540,8 +545,8 @@ static bool trans_l_cmov(DisasContext *dc, arg_dab *a)check_r0_write (dc, a->d); zero =tcg_const_tl (0 ); -tcg_gen_movcond_tl (TCG_COND_NE , cpu_R[a->d], cpu_sr_f, zero, - cpu_R[a->a], cpu_R[a->b]); +tcg_gen_movcond_tl (TCG_COND_NE ,cpu_R (dc, a->d), cpu_sr_f, zero, +cpu_R (dc, a->a),cpu_R (dc, a->b));tcg_temp_free (zero);return true; }
@@ -549,56 +554,56 @@ static bool trans_l_cmov(DisasContext *dc, arg_dab *a)static bool trans_l_ff1 (DisasContext *dc,arg_da *a) {check_r0_write (dc, a->d); -tcg_gen_ctzi_tl (cpu_R[a->d], cpu_R[a->a],-1 ); -tcg_gen_addi_tl (cpu_R[a->d], cpu_R[a->d],1 ); +tcg_gen_ctzi_tl (cpu_R (dc, a->d),cpu_R (dc, a->a),-1 ); +tcg_gen_addi_tl (cpu_R (dc, a->d),cpu_R (dc, a->d),1 );return true; }static bool trans_l_fl1 (DisasContext *dc,arg_da *a) {check_r0_write (dc, a->d); -tcg_gen_clzi_tl (cpu_R[a->d], cpu_R[a->a],TARGET_LONG_BITS ); -tcg_gen_subfi_tl (cpu_R[a->d],TARGET_LONG_BITS , cpu_R[a->d]); +tcg_gen_clzi_tl (cpu_R (dc, a->d),cpu_R (dc, a->a),TARGET_LONG_BITS ); +tcg_gen_subfi_tl (cpu_R (dc, a->d),TARGET_LONG_BITS ,cpu_R (dc, a->d));return true; }static bool trans_l_mul (DisasContext *dc,arg_dab *a) {check_r0_write (dc, a->d); -gen_mul (dc, cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]); +gen_mul (dc,cpu_R (dc, a->d),cpu_R (dc, a->a),cpu_R (dc, a->b));return true; }static bool trans_l_mulu (DisasContext *dc,arg_dab *a) {check_r0_write (dc, a->d); -gen_mulu (dc, cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]); +gen_mulu (dc,cpu_R (dc, a->d),cpu_R (dc, a->a),cpu_R (dc, a->b));return true; }static bool trans_l_div (DisasContext *dc,arg_dab *a) {check_r0_write (dc, a->d); -gen_div (dc, cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]); +gen_div (dc,cpu_R (dc, a->d),cpu_R (dc, a->a),cpu_R (dc, a->b));return true; }static bool trans_l_divu (DisasContext *dc,arg_dab *a) {check_r0_write (dc, a->d); -gen_divu (dc, cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]); +gen_divu (dc,cpu_R (dc, a->d),cpu_R (dc, a->a),cpu_R (dc, a->b));return true; }static bool trans_l_muld (DisasContext *dc,arg_ab *a) { -gen_muld (dc, cpu_R[a->a], cpu_R[a->b]); +gen_muld (dc,cpu_R (dc, a->a),cpu_R (dc, a->b));return true; }static bool trans_l_muldu (DisasContext *dc,arg_ab *a) { -gen_muldu (dc, cpu_R[a->a], cpu_R[a->b]); +gen_muldu (dc,cpu_R (dc, a->a),cpu_R (dc, a->b));return true; }
@@ -617,7 +622,7 @@ 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 ; -tcg_gen_movi_tl (cpu_R[9 ], ret_pc); +tcg_gen_movi_tl (cpu_regs[9 ], ret_pc);/* Optimize jal being used to load the PC for PIC. */ if (tmp_pc != ret_pc) {tcg_gen_movi_tl (jmp_pc, tmp_pc);
@@ -656,15 +661,15 @@ static bool trans_l_bnf(DisasContext *dc, arg_l_bf *a)static bool trans_l_jr (DisasContext *dc,arg_l_jr *a) { -tcg_gen_mov_tl (jmp_pc, cpu_R[a->b]); +tcg_gen_mov_tl (jmp_pc,cpu_R (dc, a->b)); dc->delayed_branch =2 ;return true; }static bool trans_l_jalr (DisasContext *dc,arg_l_jalr *a) { -tcg_gen_mov_tl (jmp_pc, cpu_R[a->b]); -tcg_gen_movi_tl (cpu_R[9 ], dc->base.pc_next +8 ); +tcg_gen_mov_tl (jmp_pc,cpu_R (dc, a->b)); +tcg_gen_movi_tl (cpu_regs[9 ], dc->base.pc_next +8 ); dc->delayed_branch =2 ;return true; }
@@ -675,10 +680,10 @@ 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[a->a], a->i); -tcg_gen_qemu_ld_tl (cpu_R[a->d], ea, dc->mem_idx,MO_TEUL ); +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_mov_tl (cpu_lock_addr, ea); -tcg_gen_mov_tl (cpu_lock_value, cpu_R[a->d]); +tcg_gen_mov_tl (cpu_lock_value,cpu_R (dc, a->d));tcg_temp_free (ea);return true; }
@@ -689,8 +694,8 @@ static void do_load(DisasContext *dc, arg_load *a, TCGMemOp mop)check_r0_write (dc, a->d); ea =tcg_temp_new (); -tcg_gen_addi_tl (ea, cpu_R[a->a], a->i); -tcg_gen_qemu_ld_tl (cpu_R[a->d], ea, dc->mem_idx, mop); +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);tcg_temp_free (ea); }
@@ -736,13 +741,13 @@ static bool trans_l_swa(DisasContext *dc, arg_store *a)TCGLabel *lab_fail, *lab_done; ea =tcg_temp_new (); -tcg_gen_addi_tl (ea, cpu_R[a->a], a->i); +tcg_gen_addi_tl (ea,cpu_R (dc, a->a), a->i);/* For TB_FLAGS_R0_0, the branch below invalidates the temporary assigned -to cpu_R[0]. Since l.swa is quite often immediately followed by a +to cpu_regs[0]. Since l.swa is quite often immediately followed by a branch, don't bother reallocating; finish the TB using the "real" R0. This also takes care of RB input across the branch. */ - cpu_R[0 ] = cpu_R0; + cpu_regs[0 ] = cpu_R0; lab_fail =gen_new_label (); lab_done =gen_new_label ();
@@ -751,7 +756,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[a->b], dc->mem_idx,MO_TEUL ); + cpu_regs[a->b], dc->mem_idx,MO_TEUL );tcg_gen_setcond_tl (TCG_COND_EQ , cpu_sr_f, val, cpu_lock_value);tcg_temp_free (val);
@@ -768,8 +773,8 @@ static bool trans_l_swa(DisasContext *dc, arg_store *a)static void do_store (DisasContext *dc,arg_store *a,TCGMemOp mop) {TCGv t0 =tcg_temp_new (); -tcg_gen_addi_tl (t0, cpu_R[a->a], a->i); -tcg_gen_qemu_st_tl (cpu_R[a->b], t0, dc->mem_idx, mop); +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);tcg_temp_free (t0); }
@@ -802,7 +807,7 @@ static bool trans_l_addi(DisasContext *dc, arg_rri *a)check_r0_write (dc, a->d); t0 =tcg_const_tl (a->i); -gen_add (dc, cpu_R[a->d], cpu_R[a->a], t0); +gen_add (dc,cpu_R (dc, a->d),cpu_R (dc, a->a), t0);tcg_temp_free (t0);return true; }
@@ -813,7 +818,7 @@ static bool trans_l_addic(DisasContext *dc, arg_rri *a)check_r0_write (dc, a->d); t0 =tcg_const_tl (a->i); -gen_addc (dc, cpu_R[a->d], cpu_R[a->a], t0); +gen_addc (dc,cpu_R (dc, a->d),cpu_R (dc, a->a), t0);tcg_temp_free (t0);return true; }
@@ -824,7 +829,7 @@ static bool trans_l_muli(DisasContext *dc, arg_rri *a)check_r0_write (dc, a->d); t0 =tcg_const_tl (a->i); -gen_mul (dc, cpu_R[a->d], cpu_R[a->a], t0); +gen_mul (dc,cpu_R (dc, a->d),cpu_R (dc, a->a), t0);tcg_temp_free (t0);return true; }
@@ -834,7 +839,7 @@ static bool trans_l_maci(DisasContext *dc, arg_l_maci *a)TCGv t0; t0 =tcg_const_tl (a->i); -gen_mac (dc, cpu_R[a->a], t0); +gen_mac (dc,cpu_R (dc, a->a), t0);tcg_temp_free (t0);return true; }
@@ -842,21 +847,21 @@ static bool trans_l_maci(DisasContext *dc, arg_l_maci *a)static bool trans_l_andi (DisasContext *dc,arg_rrk *a) {check_r0_write (dc, a->d); -tcg_gen_andi_tl (cpu_R[a->d], cpu_R[a->a], a->k); +tcg_gen_andi_tl (cpu_R (dc, a->d),cpu_R (dc, a->a), a->k);return true; }static bool trans_l_ori (DisasContext *dc,arg_rrk *a) {check_r0_write (dc, a->d); -tcg_gen_ori_tl (cpu_R[a->d], cpu_R[a->a], a->k); +tcg_gen_ori_tl (cpu_R (dc, a->d),cpu_R (dc, a->a), a->k);return true; }static bool trans_l_xori (DisasContext *dc,arg_rri *a) {check_r0_write (dc, a->d); -tcg_gen_xori_tl (cpu_R[a->d], cpu_R[a->a], a->i); +tcg_gen_xori_tl (cpu_R (dc, a->d),cpu_R (dc, a->a), a->i);return true; }
@@ -868,8 +873,8 @@ static bool trans_l_mfspr(DisasContext *dc, arg_l_mfspr *a)gen_illegal_exception (dc); }else {TCGv spr =tcg_temp_new (); -tcg_gen_ori_tl (spr, cpu_R[a->a], a->k); -gen_helper_mfspr (cpu_R[a->d], cpu_env, cpu_R[a->d], spr); +tcg_gen_ori_tl (spr,cpu_R (dc, a->a), a->k); +gen_helper_mfspr (cpu_R (dc, a->d), cpu_env,cpu_R (dc, a->d), spr);tcg_temp_free (spr); }return true;
@@ -896,8 +901,8 @@ static bool trans_l_mtspr(DisasContext *dc, arg_l_mtspr *a) dc->base.is_jmp =DISAS_EXIT ; spr =tcg_temp_new (); -tcg_gen_ori_tl (spr, cpu_R[a->a], a->k); -gen_helper_mtspr (cpu_env, spr, cpu_R[a->b]); +tcg_gen_ori_tl (spr,cpu_R (dc, a->a), a->k); +gen_helper_mtspr (cpu_env, spr,cpu_R (dc, a->b));tcg_temp_free (spr); }return true;
@@ -905,188 +910,202 @@ static bool trans_l_mtspr(DisasContext *dc, arg_l_mtspr *a)static bool trans_l_mac (DisasContext *dc,arg_ab *a) { -gen_mac (dc, cpu_R[a->a], cpu_R[a->b]); +gen_mac (dc,cpu_R (dc, a->a),cpu_R (dc, a->b));return true; }static bool trans_l_msb (DisasContext *dc,arg_ab *a) { -gen_msb (dc, cpu_R[a->a], cpu_R[a->b]); +gen_msb (dc,cpu_R (dc, a->a),cpu_R (dc, a->b));return true; }static bool trans_l_macu (DisasContext *dc,arg_ab *a) { -gen_macu (dc, cpu_R[a->a], cpu_R[a->b]); +gen_macu (dc,cpu_R (dc, a->a),cpu_R (dc, a->b));return true; }static bool trans_l_msbu (DisasContext *dc,arg_ab *a) { -gen_msbu (dc, cpu_R[a->a], cpu_R[a->b]); +gen_msbu (dc,cpu_R (dc, a->a),cpu_R (dc, a->b));return true; }static bool trans_l_slli (DisasContext *dc,arg_dal *a) {check_r0_write (dc, a->d); -tcg_gen_shli_tl (cpu_R[a->d], cpu_R[a->a], a->l & (TARGET_LONG_BITS -1 )); +tcg_gen_shli_tl (cpu_R (dc, a->d),cpu_R (dc, a->a), + a->l & (TARGET_LONG_BITS -1 ));return true; }static bool trans_l_srli (DisasContext *dc,arg_dal *a) {check_r0_write (dc, a->d); -tcg_gen_shri_tl (cpu_R[a->d], cpu_R[a->a], a->l & (TARGET_LONG_BITS -1 )); +tcg_gen_shri_tl (cpu_R (dc, a->d),cpu_R (dc, a->a), + a->l & (TARGET_LONG_BITS -1 ));return true; }static bool trans_l_srai (DisasContext *dc,arg_dal *a) {check_r0_write (dc, a->d); -tcg_gen_sari_tl (cpu_R[a->d], cpu_R[a->a], a->l & (TARGET_LONG_BITS -1 )); +tcg_gen_sari_tl (cpu_R (dc, a->d),cpu_R (dc, a->a), + a->l & (TARGET_LONG_BITS -1 ));return true; }static bool trans_l_rori (DisasContext *dc,arg_dal *a) {check_r0_write (dc, a->d); -tcg_gen_rotri_tl (cpu_R[a->d], cpu_R[a->a], a->l & (TARGET_LONG_BITS -1 )); +tcg_gen_rotri_tl (cpu_R (dc, a->d),cpu_R (dc, a->a), + a->l & (TARGET_LONG_BITS -1 ));return true; }static bool trans_l_movhi (DisasContext *dc,arg_l_movhi *a) {check_r0_write (dc, a->d); -tcg_gen_movi_tl (cpu_R[a->d], a->k <<16 ); +tcg_gen_movi_tl (cpu_R (dc, a->d), a->k <<16 );return true; }static bool trans_l_macrc (DisasContext *dc,arg_l_macrc *a) {check_r0_write (dc, a->d); -tcg_gen_trunc_i64_tl (cpu_R[a->d], cpu_mac); +tcg_gen_trunc_i64_tl (cpu_R (dc, a->d), cpu_mac);tcg_gen_movi_i64 (cpu_mac,0 );return true; }static bool trans_l_sfeq (DisasContext *dc,arg_ab *a) { -tcg_gen_setcond_tl (TCG_COND_EQ , cpu_sr_f, cpu_R[a->a], cpu_R[a->b]); +tcg_gen_setcond_tl (TCG_COND_EQ , cpu_sr_f, +cpu_R (dc, a->a),cpu_R (dc, a->b));return true; }static bool trans_l_sfne (DisasContext *dc,arg_ab *a) { -tcg_gen_setcond_tl (TCG_COND_NE , cpu_sr_f, cpu_R[a->a], cpu_R[a->b]); +tcg_gen_setcond_tl (TCG_COND_NE , cpu_sr_f, +cpu_R (dc, a->a),cpu_R (dc, a->b));return true; }static bool trans_l_sfgtu (DisasContext *dc,arg_ab *a) { -tcg_gen_setcond_tl (TCG_COND_GTU , cpu_sr_f, cpu_R[a->a], cpu_R[a->b]); +tcg_gen_setcond_tl (TCG_COND_GTU , cpu_sr_f, +cpu_R (dc, a->a),cpu_R (dc, a->b));return true; }static bool trans_l_sfgeu (DisasContext *dc,arg_ab *a) { -tcg_gen_setcond_tl (TCG_COND_GEU , cpu_sr_f, cpu_R[a->a], cpu_R[a->b]); +tcg_gen_setcond_tl (TCG_COND_GEU , cpu_sr_f, +cpu_R (dc, a->a),cpu_R (dc, a->b));return true; }static bool trans_l_sfltu (DisasContext *dc,arg_ab *a) { -tcg_gen_setcond_tl (TCG_COND_LTU , cpu_sr_f, cpu_R[a->a], cpu_R[a->b]); +tcg_gen_setcond_tl (TCG_COND_LTU , cpu_sr_f, +cpu_R (dc, a->a),cpu_R (dc, a->b));return true; }static bool trans_l_sfleu (DisasContext *dc,arg_ab *a) { -tcg_gen_setcond_tl (TCG_COND_LEU , cpu_sr_f, cpu_R[a->a], cpu_R[a->b]); +tcg_gen_setcond_tl (TCG_COND_LEU , cpu_sr_f, +cpu_R (dc, a->a),cpu_R (dc, a->b));return true; }static bool trans_l_sfgts (DisasContext *dc,arg_ab *a) { -tcg_gen_setcond_tl (TCG_COND_GT , cpu_sr_f, cpu_R[a->a], cpu_R[a->b]); +tcg_gen_setcond_tl (TCG_COND_GT , cpu_sr_f, +cpu_R (dc, a->a),cpu_R (dc, a->b));return true; }static bool trans_l_sfges (DisasContext *dc,arg_ab *a) { -tcg_gen_setcond_tl (TCG_COND_GE , cpu_sr_f, cpu_R[a->a], cpu_R[a->b]); +tcg_gen_setcond_tl (TCG_COND_GE , cpu_sr_f, +cpu_R (dc, a->a),cpu_R (dc, a->b));return true; }static bool trans_l_sflts (DisasContext *dc,arg_ab *a) { -tcg_gen_setcond_tl (TCG_COND_LT , cpu_sr_f, cpu_R[a->a], cpu_R[a->b]); +tcg_gen_setcond_tl (TCG_COND_LT , cpu_sr_f, +cpu_R (dc, a->a),cpu_R (dc, a->b));return true; }static bool trans_l_sfles (DisasContext *dc,arg_ab *a) { -tcg_gen_setcond_tl (TCG_COND_LE , cpu_sr_f, cpu_R[a->a], cpu_R[a->b]); +tcg_gen_setcond_tl (TCG_COND_LE , + cpu_sr_f,cpu_R (dc, a->a),cpu_R (dc, a->b));return true; }static bool trans_l_sfeqi (DisasContext *dc,arg_ai *a) { -tcg_gen_setcondi_tl (TCG_COND_EQ , cpu_sr_f, cpu_R[a->a], a->i); +tcg_gen_setcondi_tl (TCG_COND_EQ , cpu_sr_f,cpu_R (dc, a->a), a->i);return true; }static bool trans_l_sfnei (DisasContext *dc,arg_ai *a) { -tcg_gen_setcondi_tl (TCG_COND_NE , cpu_sr_f, cpu_R[a->a], a->i); +tcg_gen_setcondi_tl (TCG_COND_NE , cpu_sr_f,cpu_R (dc, a->a), a->i);return true; }static bool trans_l_sfgtui (DisasContext *dc,arg_ai *a) { -tcg_gen_setcondi_tl (TCG_COND_GTU , cpu_sr_f, cpu_R[a->a], a->i); +tcg_gen_setcondi_tl (TCG_COND_GTU , cpu_sr_f,cpu_R (dc, a->a), a->i);return true; }static bool trans_l_sfgeui (DisasContext *dc,arg_ai *a) { -tcg_gen_setcondi_tl (TCG_COND_GEU , cpu_sr_f, cpu_R[a->a], a->i); +tcg_gen_setcondi_tl (TCG_COND_GEU , cpu_sr_f,cpu_R (dc, a->a), a->i);return true; }static bool trans_l_sfltui (DisasContext *dc,arg_ai *a) { -tcg_gen_setcondi_tl (TCG_COND_LTU , cpu_sr_f, cpu_R[a->a], a->i); +tcg_gen_setcondi_tl (TCG_COND_LTU , cpu_sr_f,cpu_R (dc, a->a), a->i);return true; }static bool trans_l_sfleui (DisasContext *dc,arg_ai *a) { -tcg_gen_setcondi_tl (TCG_COND_LEU , cpu_sr_f, cpu_R[a->a], a->i); +tcg_gen_setcondi_tl (TCG_COND_LEU , cpu_sr_f,cpu_R (dc, a->a), a->i);return true; }static bool trans_l_sfgtsi (DisasContext *dc,arg_ai *a) { -tcg_gen_setcondi_tl (TCG_COND_GT , cpu_sr_f, cpu_R[a->a], a->i); +tcg_gen_setcondi_tl (TCG_COND_GT , cpu_sr_f,cpu_R (dc, a->a), a->i);return true; }static bool trans_l_sfgesi (DisasContext *dc,arg_ai *a) { -tcg_gen_setcondi_tl (TCG_COND_GE , cpu_sr_f, cpu_R[a->a], a->i); +tcg_gen_setcondi_tl (TCG_COND_GE , cpu_sr_f,cpu_R (dc, a->a), a->i);return true; }static bool trans_l_sfltsi (DisasContext *dc,arg_ai *a) { -tcg_gen_setcondi_tl (TCG_COND_LT , cpu_sr_f, cpu_R[a->a], a->i); +tcg_gen_setcondi_tl (TCG_COND_LT , cpu_sr_f,cpu_R (dc, a->a), a->i);return true; }static bool trans_l_sflesi (DisasContext *dc,arg_ai *a) { -tcg_gen_setcondi_tl (TCG_COND_LE , cpu_sr_f, cpu_R[a->a], a->i); +tcg_gen_setcondi_tl (TCG_COND_LE , cpu_sr_f,cpu_R (dc, a->a), a->i);return true; }
@@ -1137,7 +1156,7 @@ static void do_fp2(DisasContext *dc, arg_da *a, void (*fn)(TCGv, TCGv_env, TCGv)) {check_r0_write (dc, a->d); -fn (cpu_R[a->d], cpu_env, cpu_R[a->a]); +fn (cpu_R (dc, a->d), cpu_env,cpu_R (dc, a->a));gen_helper_update_fpcsr (cpu_env); }
@@ -1145,7 +1164,7 @@ static void do_fp3(DisasContext *dc, arg_dab *a, void (*fn)(TCGv, TCGv_env, TCGv, TCGv)) {check_r0_write (dc, a->d); -fn (cpu_R[a->d], cpu_env, cpu_R[a->a], cpu_R[a->b]); +fn (cpu_R (dc, a->d), cpu_env,cpu_R (dc, a->a),cpu_R (dc, a->b));gen_helper_update_fpcsr (cpu_env); }
@@ -1154,9 +1173,9 @@ static void do_fpcmp(DisasContext *dc, arg_ab *a, bool inv, bool swap) {if (swap) { -fn (cpu_sr_f, cpu_env, cpu_R[a->b], cpu_R[a->a]); +fn (cpu_sr_f, cpu_env,cpu_R (dc, a->b),cpu_R (dc, a->a)); }else { -fn (cpu_sr_f, cpu_env, cpu_R[a->a], cpu_R[a->b]); +fn (cpu_sr_f, cpu_env,cpu_R (dc, a->a),cpu_R (dc, a->b)); }if (inv) {tcg_gen_xori_tl (cpu_sr_f, cpu_sr_f,1 );
@@ -1209,8 +1228,8 @@ static bool trans_lf_ftoi_s(DisasContext *dc, arg_da *a)static bool trans_lf_madd_s (DisasContext *dc,arg_dab *a) {check_r0_write (dc, a->d); -gen_helper_float_madd_s (cpu_R[a->d], cpu_env, cpu_R[a->d], - cpu_R[a->a], cpu_R[a->b]); +gen_helper_float_madd_s (cpu_R (dc, a->d), cpu_env,cpu_R (dc, a->d), +cpu_R (dc, a->a),cpu_R (dc, a->b));gen_helper_update_fpcsr (cpu_env);return true; }
@@ -1273,9 +1292,9 @@ static void openrisc_tr_tb_start(DisasContextBase *db, CPUState *cs)/* Allow the TCG optimizer to see that R0 == 0, when it's true, which is the common case. */ if (dc->tb_flags &TB_FLAGS_R0_0 ) { - cpu_R[0 ] =tcg_const_tl (0 ); + cpu_regs[0 ] =tcg_const_tl (0 ); }else { - cpu_R[0 ] = cpu_R0; + cpu_regs[0 ] = cpu_R0; } }
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH 02/13] target/openrisc: Replace cpu register array with a function
Quoted 5 lines · Richard Henderson
The writes to cpu_R[0] are now a race across threads, now that we do code generation in parallel. Stage the change by introducing a function to return the temp for R0.
Signed-off-by Richard Henderson <[email protected]>
PATCH 3/13 target/openrisc: Cache R0 in DisasContext
In reply to Richard HendersonFinish the race condition fix from the previous patch.
--- target/openrisc/translate.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
target/openrisc/translate.c +12 -7
@@ -48,6 +48,9 @@ typedef struct DisasContext {/* If not -1, jmp_pc contains this value and so is a direct jump. */ target_ulong jmp_pc_imm; + +/* The temporary corresponding to register 0 for this compilation. */ +TCGv R0 ; } DisasContext;static inline bool is_user (DisasContext *dc)
@@ -64,7 +67,6 @@ static inline bool is_user(DisasContext *dc)static TCGv cpu_sr;static TCGv cpu_regs[32 ]; -static TCGv cpu_R0;static TCGv cpu_pc;static TCGv jmp_pc;/* l.jr/l.jalr temp pc */ static TCGv cpu_ppc;
@@ -122,7 +124,6 @@ void openrisc_translate_init(void) shadow_gpr[0][i]), regnames[i]); } - cpu_R0 = cpu_regs[0 ]; }static void gen_exception (DisasContext *dc,unsigned int excp)
@@ -165,7 +166,11 @@ static void check_ov64s(DisasContext *dc)static TCGv cpu_R (DisasContext *dc,int reg) { -return cpu_regs[reg]; +if (reg ==0 ) { +return dc->R0; + }else { +return cpu_regs[reg]; + } }/*
@@ -175,7 +180,7 @@ static TCGv cpu_R(DisasContext *dc, int reg)static void check_r0_write (DisasContext *dc,int reg) {if (unlikely (reg ==0 )) { - cpu_regs[0 ] = cpu_R0; + dc->R0 = cpu_regs[0 ]; } }
@@ -747,7 +752,7 @@ static bool trans_l_swa(DisasContext *dc, arg_store *a)to cpu_regs[0]. Since l.swa is quite often immediately followed by a branch, don't bother reallocating; finish the TB using the "real" R0. This also takes care of RB input across the branch. */ - cpu_regs[0 ] = cpu_R0; + dc->R0 = cpu_regs[0 ]; lab_fail =gen_new_label (); lab_done =gen_new_label ();
@@ -1292,9 +1297,9 @@ static void openrisc_tr_tb_start(DisasContextBase *db, CPUState *cs)/* Allow the TCG optimizer to see that R0 == 0, when it's true, which is the common case. */ if (dc->tb_flags &TB_FLAGS_R0_0 ) { - cpu_regs[0 ] =tcg_const_tl (0 ); + dc->R0 =tcg_const_tl (0 ); }else { - cpu_regs[0 ] = cpu_R0; + dc->R0 = cpu_regs[0 ]; } }
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH 03/13] target/openrisc: Cache R0 in DisasContext
Quoted 3 lines · Richard Henderson
Finish the race condition fix from the previous patch.
Signed-off-by Richard Henderson <[email protected]>
PATCH 4/13 target/openrisc: Make VR and PPC read-only
In reply to Richard HendersonThese SPRs are read-only. The writes can simply be ignored, as we already do for other read-only (or missing) registers. There is no reason to mask the value in env->vr.
--- target/openrisc/cpu.h | 3 --- target/openrisc/sys_helper.c | 10 +--------- 2 files changed, 1 insertion(+), 12 deletions(-)
target/openrisc/cpu.h +0 -3
@@ -68,9 +68,6 @@ enum { (reg) |= ((v &0x1f ) <<2 );\ }while (0 ) -/* Version Register */ -#define SPR_VR 0xFFFF003F - /* Interrupt */#define NR_IRQS 32
target/openrisc/sys_helper.c +1 -9
@@ -39,10 +39,6 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong spr, target_ulong rb)int idx;switch (spr) { -case TO_SPR (0 ,0 ):/* VR */ - env->vr = rb; -break ; -case TO_SPR (0 ,11 ):/* EVBAR */ env->evbar = rb;break ;
@@ -62,10 +58,6 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong spr, target_ulong rb)cpu_set_sr (env, rb);break ; -case TO_SPR (0 ,18 ):/* PPC */ - env->ppc = rb; -break ; -case TO_SPR (0 ,32 ):/* EPCR */ env->epcr = rb;break ;
@@ -204,7 +196,7 @@ target_ulong HELPER(mfspr)(CPUOpenRISCState *env, target_ulong rd,switch (spr) {case TO_SPR (0 ,0 ):/* VR */ -return env->vr &SPR_VR ; +return env->vr;case TO_SPR (0 ,1 ):/* UPR */ return env->upr;/* TT, DM, IM, UP present */
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH 04/13] target/openrisc: Make VR and PPC read-only
Quoted 5 lines · Richard Henderson
These SPRs are read-only. The writes can simply be ignored, as we already do for other read-only (or missing) registers. There is no reason to mask the value in
env->vr.Signed-off-by Richard Henderson <[email protected]>
PATCH 5/13 target/openrisc: Move VR, UPR, DMMCFGR, IMMCFGR to cpu init
In reply to Richard HendersonThese registers are read-only and implementation specific. Initiailize VR for the first time; take the OR1200 values from the verilog source.
--- target/openrisc/cpu.h | 8 ++++---- target/openrisc/cpu.c | 23 ++++++++++++++++------- target/openrisc/sys_helper.c | 4 ++-- 3 files changed, 22 insertions(+), 13 deletions(-)
target/openrisc/cpu.h +4 -4
@@ -260,10 +260,6 @@ typedef struct CPUOpenRISCState {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;/* Supervisor register, without SR_{F,CY,OV} */ -uint32_t vr;/* Version register */ -uint32_t upr;/* Unit presence register */ -uint32_t dmmucfgr;/* DMMU configure register */ -uint32_t immucfgr;/* IMMU configure register */ uint32_t esr;/* Exception supervisor register */ uint32_t evbar;/* Exception vector base address register */ uint32_t pmr;/* Power Management Register */
@@ -283,7 +279,11 @@ typedef struct CPUOpenRISCState {struct {} end_reset_fields;/* Fields from here on are preserved across CPU reset. */ +uint32_t vr;/* Version register */ +uint32_t upr;/* Unit presence register */ uint32_t cpucfgr;/* CPU configure register */ +uint32_t dmmucfgr;/* DMMU configure register */ +uint32_t immucfgr;/* IMMU configure register */ #ifndef CONFIG_USER_ONLY QEMUTimer *timer;
target/openrisc/cpu.c +16 -7
@@ -56,13 +56,6 @@ static void openrisc_cpu_reset(CPUState *s) cpu->env.lock_addr =-1 ; s->exception_index =-1 ; - cpu->env.upr =UPR_UP |UPR_DMP |UPR_IMP |UPR_PICP |UPR_TTP | -UPR_PMP ; - cpu->env.dmmucfgr = (DMMUCFGR_NTW & (0 <<2 )) - | (DMMUCFGR_NTS & (ctz32 (TLB_SIZE ) <<2 )); - cpu->env.immucfgr = (IMMUCFGR_NTW & (0 <<2 )) - | (IMMUCFGR_NTS & (ctz32 (TLB_SIZE ) <<2 )); -#ifndef CONFIG_USER_ONLY cpu->env.picmr =0x00000000 ; cpu->env.picsr =0x00000000 ;
@@ -117,15 +110,31 @@ static void or1200_initfn(Object *obj) {OpenRISCCPU *cpu =OPENRISC_CPU (obj); + cpu->env.vr =0x13000008 ; + cpu->env.upr =UPR_UP |UPR_DMP |UPR_IMP |UPR_PICP |UPR_TTP |UPR_PMP ; cpu->env.cpucfgr =CPUCFGR_NSGF |CPUCFGR_OB32S |CPUCFGR_OF32S |CPUCFGR_EVBARP ; + +/* 1Way, TLB_SIZE entries. */ + cpu->env.dmmucfgr = (DMMUCFGR_NTW & (0 <<2 )) + | (DMMUCFGR_NTS & (ctz32 (TLB_SIZE ) <<2 )); + cpu->env.immucfgr = (IMMUCFGR_NTW & (0 <<2 )) + | (IMMUCFGR_NTS & (ctz32 (TLB_SIZE ) <<2 )); }static void openrisc_any_initfn (Object *obj) {OpenRISCCPU *cpu =OPENRISC_CPU (obj); + cpu->env.vr =0x13000000 ; + cpu->env.upr =UPR_UP |UPR_DMP |UPR_IMP |UPR_PICP |UPR_TTP |UPR_PMP ; cpu->env.cpucfgr =CPUCFGR_NSGF |CPUCFGR_OB32S |CPUCFGR_EVBARP ; + +/* 1Way, TLB_SIZE entries. */ + cpu->env.dmmucfgr = (DMMUCFGR_NTW & (0 <<2 )) + | (DMMUCFGR_NTS & (ctz32 (TLB_SIZE ) <<2 )); + cpu->env.immucfgr = (IMMUCFGR_NTW & (0 <<2 )) + | (IMMUCFGR_NTS & (ctz32 (TLB_SIZE ) <<2 )); }static void openrisc_cpu_class_init (ObjectClass *oc,void *data)
target/openrisc/sys_helper.c +2 -2
@@ -199,13 +199,13 @@ target_ulong HELPER(mfspr)(CPUOpenRISCState *env, target_ulong rd,return env->vr;case TO_SPR (0 ,1 ):/* UPR */ -return env->upr;/* TT, DM, IM, UP present */ +return env->upr;case TO_SPR (0 ,2 ):/* CPUCFGR */ return env->cpucfgr;case TO_SPR (0 ,3 ):/* DMMUCFGR */ -return env->dmmucfgr;/* 1Way, 64 entries */ +return env->dmmucfgr;case TO_SPR (0 ,4 ):/* IMMUCFGR */ return env->immucfgr;
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH 05/13] target/openrisc: Move VR, UPR, DMMCFGR, IMMCFGR to cpu init
Quoted 5 lines · Richard Henderson
These registers are read-only and implementation specific. Initiailize VR for the first time; take the OR1200 values from the verilog source.
Signed-off-by Richard Henderson <[email protected]>
Quoted 22 lines
--- target/openrisc/cpu.h | 8 ++++---- target/openrisc/cpu.c | 23 ++++++++++++++++------- target/openrisc/sys_helper.c | 4 ++-- 3 files changed, 22 insertions(+), 13 deletions(-)target/openrisc/cpu.h +0
-4@@ -260,10 +260,6 @@ typedef struct CPUOpenRISCState {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;/* Supervisor register, without SR_{F,CY,OV} */ -uint32_t vr;/* Version register */ -uint32_t upr;/* Unit presence register */ -uint32_t dmmucfgr;/* DMMU configure register */ -uint32_t immucfgr;/* IMMU configure register */ uint32_t esr;/* Exception supervisor register */ uint32_t evbar;/* Exception vector base address register */ uint32_t pmr;/* Power Management Register */
target/openrisc/cpu.h typedef struct CPUOpenRISCState { · line 286
Quoted 8 lines
target/openrisc/cpu.h +4
-0@@ -283,7 +279,11 @@ typedef struct CPUOpenRISCState {struct {} end_reset_fields;/* Fields from here on are preserved across CPU reset. */ +uint32_t vr;/* Version register */ +uint32_t upr;/* Unit presence register */ uint32_t cpucfgr;/* CPU configure register */ +uint32_t dmmucfgr;/* DMMU configure register */ +uint32_t immucfgr;/* IMMU configure register */
Note for me, others, just moving these doesn't require updating the machine serialization.
PATCH 6/13 target/openrisc: Add VR2 and AVR special processor registers
In reply to Richard HendersonUpdate the CPUCFG bits to arch v1.3.
Include support for AVRP for cpu "any".
--- target/openrisc/cpu.h | 11 +++++++---- target/openrisc/cpu.c | 8 ++++++-- target/openrisc/sys_helper.c | 6 ++++++ 3 files changed, 19 insertions(+), 6 deletions(-)
target/openrisc/cpu.h +7 -4
@@ -96,11 +96,12 @@ enum {CPUCFGR_OF32S = (1 <<7 ),CPUCFGR_OF64S = (1 <<8 ),CPUCFGR_OV64S = (1 <<9 ), -/* CPUCFGR_ND = (1 << 10), */ -/* CPUCFGR_AVRP = (1 << 11), */ +CPUCFGR_ND = (1 <<10 ), +CPUCFGR_AVRP = (1 <<11 ),CPUCFGR_EVBARP = (1 <<12 ), - /* CPUCFGR_ISRP = (1 << 13), */ - /* CPUCFGR_AECSRP = (1 << 14), */ +CPUCFGR_ISRP = (1 <<13 ), +CPUCFGR_AECSRP = (1 <<14 ), + CPUCFGR_OF64A32S = (1 << 15), };/* DMMU configure register */
@@ -280,6 +281,8 @@ typedef struct CPUOpenRISCState {/* Fields from here on are preserved across CPU reset. */ uint32_t vr;/* Version register */ +uint32_t vr2;/* Version register 2 */ +uint32_t avr;/* Architecture version register */ uint32_t upr;/* Unit presence register */ uint32_t cpucfgr;/* CPU configure register */ uint32_t dmmucfgr;/* DMMU configure register */
target/openrisc/cpu.c +6 -2
@@ -126,9 +126,13 @@ static void openrisc_any_initfn(Object *obj) {OpenRISCCPU *cpu =OPENRISC_CPU (obj); - cpu->env.vr =0x13000000 ; + cpu->env.vr =0x13000040 ;/* Obsolete VER + UVRP for new SPRs */ + cpu->env.vr2 =0 ;/* No version specific id */ + cpu->env.avr =0x01010000 ;/* Architecture v1.1 */ + cpu->env.upr =UPR_UP |UPR_DMP |UPR_IMP |UPR_PICP |UPR_TTP |UPR_PMP ; - cpu->env.cpucfgr =CPUCFGR_NSGF |CPUCFGR_OB32S |CPUCFGR_EVBARP ; + cpu->env.cpucfgr =CPUCFGR_NSGF |CPUCFGR_OB32S | +CPUCFGR_AVRP |CPUCFGR_EVBARP ;/* 1Way, TLB_SIZE entries. */ cpu->env.dmmucfgr = (DMMUCFGR_NTW & (0 <<2 ))
target/openrisc/sys_helper.c +6 -0
@@ -210,6 +210,12 @@ target_ulong HELPER(mfspr)(CPUOpenRISCState *env, target_ulong rd,case TO_SPR (0 ,4 ):/* IMMUCFGR */ return env->immucfgr; +case TO_SPR (0 ,9 ):/* VR2 */ +return env->vr2; + +case TO_SPR (0 ,10 ):/* AVR */ +return env->avr; +case TO_SPR (0 ,11 ):/* EVBAR */ return env->evbar;
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH 06/13] target/openrisc: Add VR2 and AVR special processor registers
Quoted 32 lines · Richard Henderson
Update the CPUCFG bits to arch v1.3.
Include support for AVRP for cpu "any".Signed-off-by Richard Henderson <[email protected]>--- target/openrisc/cpu.h | 11 +++++++---- target/openrisc/cpu.c | 8 ++++++-- target/openrisc/sys_helper.c | 6 ++++++ 3 files changed, 19 insertions(+), 6 deletions(-)target/openrisc/cpu.h +5
-4@@ -96,11 +96,12 @@ enum {CPUCFGR_OF32S = (1 <<7 ),CPUCFGR_OF64S = (1 <<8 ),CPUCFGR_OV64S = (1 <<9 ), -/* CPUCFGR_ND = (1 << 10), */ -/* CPUCFGR_AVRP = (1 << 11), */ +CPUCFGR_ND = (1 <<10 ), +CPUCFGR_AVRP = (1 <<11 ),CPUCFGR_EVBARP = (1 <<12 ), - /* CPUCFGR_ISRP = (1 << 13), */ - /* CPUCFGR_AECSRP = (1 << 14), */ +CPUCFGR_ISRP = (1 <<13 ), +CPUCFGR_AECSRP = (1 <<14 ), + CPUCFGR_OF64A32S = (1 << 15), };/* DMMU configure register */
target/openrisc/cpu.h typedef struct CPUOpenRISCState { · line 285
Quoted 5 lines
target/openrisc/cpu.h +2
-0@@ -280,6 +281,8 @@ typedef struct CPUOpenRISCState {/* Fields from here on are preserved across CPU reset. */ uint32_t vr;/* Version register */ +uint32_t vr2;/* Version register 2 */ +uint32_t avr;/* Architecture version register */
Do you need to update the serialization in machine.c?
Re: [Qemu-devel] [PATCH 06/13] target/openrisc: Add VR2 and AVR special processor registers
Quoted 6 lines · Stafford Horne
target/openrisc/cpu.h typedef struct CPUOpenRISCState { · line 285
Quoted 4 lines
/* Fields from here on are preserved across CPU reset. */
uint32_tvr; /* Version register */target/openrisc/cpu.h +2
-0+uint32_t vr2;/* Version register 2 */ +uint32_t avr;/* Architecture version register */ Do you need to update the serialization in
machine.c?
I don't think so, because these are invariant for the cpu type. It is not valid to migrate state to a different cpu.
The VR, DMMUCFGR, IMMUCFGR entries that you pointed out wrt the previous patch wouldn't need to be in the serialization if they weren't already there.
r~
PATCH 7/13 target/openrisc: Fix lf.ftoi.s
In reply to Richard HendersonThe specification of this insn is round-to-zero.
--- target/openrisc/fpu_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/openrisc/fpu_helper.c +1 -1
@@ -78,7 +78,7 @@ uint64_t HELPER(ftoid)(CPUOpenRISCState *env, uint64_t val)uint32_t HELPER (ftois )(CPUOpenRISCState *env,uint32_t val) { -return float32_to_int32 (val, &env->fp_status); +return float32_to_int32_round_to_zero (val, &env->fp_status); }#define FLOAT_CALC (name) \
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH 07/13] target/openrisc: Fix lf.ftoi.s
Quoted 3 lines · Richard Henderson
The specification of this insn is round-to-zero.
Signed-off-by Richard Henderson <[email protected]>
Quoted 20 lines
--- target/openrisc/fpu_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/openrisc/fpu_helper.c +1
-1@@ -78,7 +78,7 @@ uint64_t HELPER(ftoid)(CPUOpenRISCState *env, uint64_t val)uint32_t HELPER (ftois )(CPUOpenRISCState *env,uint32_t val) { -return float32_to_int32 (val, &env->fp_status); +return float32_to_int32_round_to_zero (val, &env->fp_status); }#define FLOAT_CALC (name) \Signature · 1 line
2.17.1
PATCH 8/13 target/openrisc: Check CPUCFG_OF32S for float insns
In reply to Richard HendersonMake sure the OF32S insns are enabled before allowing execution. Include the missing bit for cpu "any".
--- target/openrisc/cpu.c | 2 +- target/openrisc/translate.c | 84 ++++++++++++++++--------------------- 2 files changed, 36 insertions(+), 50 deletions(-)
target/openrisc/cpu.c +1 -1
@@ -131,7 +131,7 @@ static void openrisc_any_initfn(Object *obj) cpu->env.avr =0x01010000 ;/* Architecture v1.1 */ cpu->env.upr =UPR_UP |UPR_DMP |UPR_IMP |UPR_PICP |UPR_TTP |UPR_PMP ; - cpu->env.cpucfgr =CPUCFGR_NSGF |CPUCFGR_OB32S | + cpu->env.cpucfgr =CPUCFGR_NSGF |CPUCFGR_OB32S |CPUCFGR_OF32S |CPUCFGR_AVRP |CPUCFGR_EVBARP ;/* 1Way, TLB_SIZE entries. */
target/openrisc/translate.c +35 -49
193 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH 08/13] target/openrisc: Check CPUCFG_OF32S for float insns
Quoted 4 lines · Richard Henderson
Make sure the OF32S insns are enabled before allowing execution. Include the missing bit for cpu "any".
Signed-off-by Richard Henderson <[email protected]>
PATCH 9/13 target/openrisc: Add support for ORFPX64A32
In reply to Richard HendersonThis is hardware support for double-precision floating-point using pairs of 32-bit registers. Fix a latent bug in the heretofore unused helper_itofd. Include the bit for cpu "any".
--- linux-user/openrisc/target_elf.h | 2 +- target/openrisc/helper.h | 2 + target/openrisc/cpu.c | 2 +- target/openrisc/disas.c | 56 ++++++++ target/openrisc/fpu_helper.c | 14 +- target/openrisc/translate.c | 230 +++++++++++++++++++++++++++++++ target/openrisc/insns.decode | 31 +++++ 7 files changed, 333 insertions(+), 4 deletions(-)
linux-user/openrisc/target_elf.h +1 -1
@@ -9,6 +9,6 @@#define OPENRISC_TARGET_ELF_H static inline const char *cpu_get_model (uint32_t eflags) { -return "or1200" ; +return "any" ; }#endif
target/openrisc/helper.h +2 -0
@@ -30,6 +30,8 @@ DEF_HELPER_FLAGS_2(itofd, TCG_CALL_NO_RWG, i64, env, i64) DEF_HELPER_FLAGS_2(itofs, TCG_CALL_NO_RWG, i32, env, i32) DEF_HELPER_FLAGS_2(ftoid, TCG_CALL_NO_RWG, i64, env, i64) DEF_HELPER_FLAGS_2(ftois, TCG_CALL_NO_RWG, i32, env, i32) +DEF_HELPER_FLAGS_2(stod, TCG_CALL_NO_RWG, i64, env, i32) +DEF_HELPER_FLAGS_2(dtos, TCG_CALL_NO_RWG, i32, env, i64) DEF_HELPER_FLAGS_4(float_madd_s, TCG_CALL_NO_RWG, i32, env, i32, i32, i32)DEF_HELPER_FLAGS_4 (float_madd_d,TCG_CALL_NO_RWG , i64, env, i64, i64, i64)
target/openrisc/cpu.c +1 -1
@@ -132,7 +132,7 @@ static void openrisc_any_initfn(Object *obj) cpu->env.upr =UPR_UP |UPR_DMP |UPR_IMP |UPR_PICP |UPR_TTP |UPR_PMP ; cpu->env.cpucfgr =CPUCFGR_NSGF |CPUCFGR_OB32S |CPUCFGR_OF32S | -CPUCFGR_AVRP |CPUCFGR_EVBARP ; +CPUCFGR_AVRP |CPUCFGR_EVBARP |CPUCFGR_OF64A32S ;/* 1Way, TLB_SIZE entries. */ cpu->env.dmmucfgr = (DMMUCFGR_NTW & (0 <<2 ))
target/openrisc/disas.c +56 -0
59 lines not on this page · raw message
target/openrisc/fpu_helper.c +12 -2
@@ -63,7 +63,7 @@ void HELPER(update_fpcsr)(CPUOpenRISCState *env)uint64_t HELPER (itofd )(CPUOpenRISCState *env,uint64_t val) { -return int32_to_float64 (val, &env->fp_status); +return int64_to_float64 (val, &env->fp_status); }uint32_t HELPER (itofs )(CPUOpenRISCState *env,uint32_t val)
@@ -73,7 +73,7 @@ uint32_t HELPER(itofs)(CPUOpenRISCState *env, uint32_t val)uint64_t HELPER (ftoid )(CPUOpenRISCState *env,uint64_t val) { -return float32_to_int64 (val, &env->fp_status); +return float64_to_int64_round_to_zero (val, &env->fp_status); }uint32_t HELPER (ftois )(CPUOpenRISCState *env,uint32_t val)
@@ -81,6 +81,16 @@ uint32_t HELPER(ftois)(CPUOpenRISCState *env, uint32_t val)return float32_to_int32_round_to_zero (val, &env->fp_status); } +uint64_t HELPER (stod )(CPUOpenRISCState *env,uint32_t val) +{ +return float32_to_float64 (val, &env->fp_status); +} + +uint32_t HELPER (dtos )(CPUOpenRISCState *env,uint64_t val) +{ +return float64_to_float32 (val, &env->fp_status); +} +#define FLOAT_CALC (name) \ uint64_t helper_float_ ## name ## _d(CPUOpenRISCState *env, \ uint64_t fdt0, uint64_t fdt1) \
target/openrisc/translate.c +230 -0
242 lines not on this page · raw message
target/openrisc/insns.decode +31 -0
@@ -22,6 +22,9 @@ &ab a b &dal d a l &ai a i +&dab_pair d a b dp ap bp +&ab_pair a b ap bp +&da_pair d a dp ap #### # System Instructions
@@ -187,3 +190,31 @@ lf_sfgt_s 110010 ----- a:5 b:5 --- 00001010 lf_sfge_s 110010 ----- a:5 b:5 --- 00001011 lf_sflt_s 110010 ----- a:5 b:5 --- 00001100 lf_sfle_s 110010 ----- a:5 b:5 --- 00001101 + +#### +# DP Instructions +#### + +@dab_pair ...... d:5 a:5 b:5 dp:1 ap:1 bp:1 ........ &dab_pair +@ab_pair ...... ..... a:5 b:5 . ap:1 bp:1 ........ &ab_pair +@da_pair ...... d:5 a:5 ..... dp:1 ap:1 . ........ &da_pair + +lf_add_d 110010 ..... ..... ..... ... 00010000 @dab_pair +lf_sub_d 110010 ..... ..... ..... ... 00010001 @dab_pair +lf_mul_d 110010 ..... ..... ..... ... 00010010 @dab_pair +lf_div_d 110010 ..... ..... ..... ... 00010011 @dab_pair +lf_rem_d 110010 ..... ..... ..... ... 00010110 @dab_pair +lf_madd_d 110010 ..... ..... ..... ... 00010111 @dab_pair + +lf_itof_d 110010 ..... ..... 00000 ..0 00010100 @da_pair +lf_ftoi_d 110010 ..... ..... 00000 ..0 00010101 @da_pair + +lf_stod_d 110010 d:5 a:5 00000 dp:1 0 0 00110100 +lf_dtos_d 110010 d:5 a:5 00000 0 ap:1 0 00110101 + +lf_sfeq_d 110010 00000 ..... ..... 0.. 00011000 @ab_pair +lf_sfne_d 110010 00000 ..... ..... 0.. 00011001 @ab_pair +lf_sfgt_d 110010 00000 ..... ..... 0.. 00011010 @ab_pair +lf_sfge_d 110010 00000 ..... ..... 0.. 00011011 @ab_pair +lf_sflt_d 110010 00000 ..... ..... 0.. 00011100 @ab_pair +lf_sfle_d 110010 00000 ..... ..... 0.. 00011101 @ab_pair
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH 09/13] target/openrisc: Add support for ORFPX64A32
Quoted 5 lines · Richard Henderson
This is hardware support for double-precision floating-point using pairs of 32-bit registers. Fix a latent bug in the heretofore unused
helper_itofd. Include the bit for cpu "any".Signed-off-by Richard Henderson <[email protected]>
PATCH 10/13 target/openrisc: Implement unordered fp comparisons
In reply to Richard HendersonThese were added to the 1.3 spec. For OF32S, validate AVR. But OF64A32 is itself new to 1.3 so no extra check needed.
--- target/openrisc/helper.h | 4 ++ target/openrisc/disas.c | 24 ++++++++++ target/openrisc/fpu_helper.c | 20 +++++++++ target/openrisc/translate.c | 85 ++++++++++++++++++++++++++++++++++++ target/openrisc/insns.decode | 12 +++++ 5 files changed, 145 insertions(+)
target/openrisc/helper.h +4 -0
@@ -52,6 +52,10 @@ DEF_HELPER_FLAGS_3(float_ ## op ## _d, TCG_CALL_NO_RWG, tl, env, i64, i64) FOP_CMP(eq) FOP_CMP(lt) FOP_CMP(le) +FOP_CMP(un) +FOP_CMP(ueq) +FOP_CMP(ule) +FOP_CMP(ult)#undef FOP_CMP/* interrupt */
target/openrisc/disas.c +24 -0
@@ -166,6 +166,12 @@ FP_INSN(sfgt, s, "r%d, r%d", a->a, a->b) FP_INSN(sfge, s, "r%d, r%d", a->a, a->b) FP_INSN(sflt, s, "r%d, r%d", a->a, a->b) FP_INSN(sfle, s, "r%d, r%d", a->a, a->b) +FP_INSN(sfun, s, "r%d, r%d", a->a, a->b) +FP_INSN(sfueq, s, "r%d, r%d", a->a, a->b) +FP_INSN(sfuge, s, "r%d, r%d", a->a, a->b) +FP_INSN(sfugt, s, "r%d, r%d", a->a, a->b) +FP_INSN(sfule, s, "r%d, r%d", a->a, a->b) +FP_INSN(sfult, s, "r%d, r%d", a->a, a->b) FP_INSN(add, d, "r%d,r%d, r%d,r%d, r%d,r%d", a->d, a->d + a->dp + 1,
@@ -222,3 +228,21 @@ FP_INSN(sflt, d, "r%d,r%d, r%d,r%d",FP_INSN (sfle, d,"r%d,r%d, r%d,r%d" , a->a, a->a + a->ap +1 , a->b, a->b + a->bp + 1) +FP_INSN (sfun, d,"r%d,r%d, r%d,r%d" , + a->a, a->a + a->ap +1 , + a->b, a->b + a->bp + 1) +FP_INSN (sfueq, d,"r%d,r%d, r%d,r%d" , + a->a, a->a + a->ap +1 , + a->b, a->b + a->bp + 1) +FP_INSN (sfuge, d,"r%d,r%d, r%d,r%d" , + a->a, a->a + a->ap +1 , + a->b, a->b + a->bp + 1) +FP_INSN (sfugt, d,"r%d,r%d, r%d,r%d" , + a->a, a->a + a->ap +1 , + a->b, a->b + a->bp + 1) +FP_INSN (sfule, d,"r%d,r%d, r%d,r%d" , + a->a, a->a + a->ap +1 , + a->b, a->b + a->bp + 1) +FP_INSN (sfult, d,"r%d,r%d, r%d,r%d" , + a->a, a->a + a->ap +1 , + a->b, a->b + a->bp +1 )
target/openrisc/fpu_helper.c +20 -0
@@ -135,4 +135,24 @@ target_ulong helper_float_ ## name ## _s(CPUOpenRISCState *env, \ FLOAT_CMP(le, le) FLOAT_CMP(lt, lt) FLOAT_CMP(eq, eq_quiet) +FLOAT_CMP(un, unordered_quiet)#undef FLOAT_CMP + +#define FLOAT_UCMP (name, expr) \ +target_ulong helper_float_ ## name ## _d(CPUOpenRISCState *env, \ + uint64_t fdt0, uint64_t fdt1) \ +{ \ + int r = float64_compare_quiet(fdt0, fdt1, &env->fp_status); \ + return expr; \ +} \ +target_ulong helper_float_ ## name ## _s(CPUOpenRISCState *env, \ + uint32_t fdt0, uint32_t fdt1) \ +{ \ + int r = float32_compare_quiet(fdt0, fdt1, &env->fp_status); \ + return expr; \ +} + +FLOAT_UCMP(ueq, r == float_relation_equal || r == float_relation_unordered) +FLOAT_UCMP(ult, r == float_relation_less || r == float_relation_unordered) +FLOAT_UCMP(ule, r != float_relation_greater) +#undef FLOAT_UCMP
target/openrisc/translate.c +85 -0
115 lines not on this page · raw message
target/openrisc/insns.decode +12 -0
@@ -190,6 +190,12 @@ lf_sfgt_s 110010 ----- a:5 b:5 --- 00001010 lf_sfge_s 110010 ----- a:5 b:5 --- 00001011 lf_sflt_s 110010 ----- a:5 b:5 --- 00001100 lf_sfle_s 110010 ----- a:5 b:5 --- 00001101 +lf_sfueq_s 110010 ----- a:5 b:5 --- 00101000 +lf_sfuge_s 110010 ----- a:5 b:5 --- 00101011 +lf_sfugt_s 110010 ----- a:5 b:5 --- 00101010 +lf_sfule_s 110010 ----- a:5 b:5 --- 00101101 +lf_sfult_s 110010 ----- a:5 b:5 --- 00101100 +lf_sfun_s 110010 ----- a:5 b:5 --- 00101110 #### # DP Instructions
@@ -218,3 +224,9 @@ lf_sfgt_d 110010 00000 ..... ..... 0.. 00011010 @ab_pair lf_sfge_d 110010 00000 ..... ..... 0.. 00011011 @ab_pair lf_sflt_d 110010 00000 ..... ..... 0.. 00011100 @ab_pair lf_sfle_d 110010 00000 ..... ..... 0.. 00011101 @ab_pair +lf_sfueq_d 110010 00000 ..... ..... 0.. 00111000 @ab_pair +lf_sfuge_d 110010 00000 ..... ..... 0.. 00111011 @ab_pair +lf_sfugt_d 110010 00000 ..... ..... 0.. 00111010 @ab_pair +lf_sfule_d 110010 00000 ..... ..... 0.. 00111101 @ab_pair +lf_sfult_d 110010 00000 ..... ..... 0.. 00111100 @ab_pair +lf_sfun_d 110010 00000 ..... ..... 0.. 00111110 @ab_pair
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH 10/13] target/openrisc: Implement unordered fp comparisons
Quoted 4 lines · Richard Henderson
These were added to the 1.3 spec. For OF32S, validate AVR. But OF64A32 is itself new to 1.3 so no extra check needed.
Signed-off-by Richard Henderson <[email protected]>
PATCH 11/13 target/openrisc: Implement move to/from FPCSR
In reply to Richard Henderson--- target/openrisc/cpu.h | 2 ++ target/openrisc/cpu.c | 1 + target/openrisc/fpu_helper.c | 13 +++++++++++++ target/openrisc/machine.c | 11 +++++++++++ target/openrisc/sys_helper.c | 18 ++++++++++++------ 5 files changed, 39 insertions(+), 6 deletions(-)
target/openrisc/cpu.h +2 -0
@@ -413,6 +413,8 @@ static inline void cpu_set_sr(CPUOpenRISCState *env, uint32_t val) env->sr = (val & ~(SR_F | SR_CY | SR_OV)) | SR_FO; } +void cpu_set_fpcsr (CPUOpenRISCState *env,uint32_t val); +#define CPU_INTERRUPT_TIMER CPU_INTERRUPT_TGT_INT_0#endif /* OPENRISC_CPU_H */
target/openrisc/cpu.c +1 -0
@@ -55,6 +55,7 @@ static void openrisc_cpu_reset(CPUState *s) cpu->env.sr =SR_FO |SR_SM ; cpu->env.lock_addr =-1 ; s->exception_index =-1 ; +cpu_set_fpcsr (&cpu->env,0 );#ifndef CONFIG_USER_ONLY cpu->env.picmr =0x00000000 ;
target/openrisc/fpu_helper.c +13 -0
@@ -61,6 +61,19 @@ void HELPER(update_fpcsr)(CPUOpenRISCState *env) } } +void cpu_set_fpcsr (CPUOpenRISCState *env,uint32_t val) +{ +static const int rm_to_sf[] = { + float_round_nearest_even, + float_round_to_zero, + float_round_up, + float_round_down + }; + + env->fpcsr = val &0x7ff ; +set_float_rounding_mode (rm_to_sf[extract32 (val,1 ,2 )], &env->fp_status); +} +uint64_t HELPER (itofd )(CPUOpenRISCState *env,uint64_t val) {return int64_to_float64 (val, &env->fp_status);
target/openrisc/machine.c +11 -0
@@ -121,10 +121,21 @@ static const VMStateDescription vmstate_env = { } }; +static int cpu_post_load (void *opaque,int version_id) +{ +OpenRISCCPU *cpu = opaque; +CPUOpenRISCState *env = &cpu->env; + +/* Update env->fp_status to match env->fpcsr. */ +cpu_set_fpcsr (env, env->fpcsr); +return 0 ; +} +const VMStateDescription vmstate_openrisc_cpu = { .name ="cpu" , .version_id =1 , .minimum_version_id =1 , + .post_load = cpu_post_load, .fields = (VMStateField []) {VMSTATE_CPU (),VMSTATE_STRUCT (env, OpenRISCCPU,1 , vmstate_env, CPUOpenRISCState),
target/openrisc/sys_helper.c +12 -6
@@ -37,8 +37,10 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong spr, target_ulong rb)CPUState *cs =env_cpu (env);target_ulong mr;int idx; +#endif switch (spr) { +#ifndef CONFIG_USER_ONLY case TO_SPR (0 ,11 ):/* EVBAR */ env->evbar = rb;break ;
@@ -179,10 +181,12 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong spr, target_ulong rb) }cpu_openrisc_timer_update (cpu);break ; -default : +#endif + +case TO_SPR (0 ,20 ):/* FPCSR */ +cpu_set_fpcsr (env, rb);break ; } -#endif } target_ulong HELPER(mfspr)(CPUOpenRISCState *env, target_ulong rd,
@@ -193,8 +197,10 @@ target_ulong HELPER(mfspr)(CPUOpenRISCState *env, target_ulong rd,OpenRISCCPU *cpu =env_archcpu (env);CPUState *cs =env_cpu (env);int idx; +#endif switch (spr) { +#ifndef CONFIG_USER_ONLY case TO_SPR (0 ,0 ):/* VR */ return env->vr;
@@ -303,12 +309,12 @@ target_ulong HELPER(mfspr)(CPUOpenRISCState *env, target_ulong rd,case TO_SPR (10 ,1 ):/* TTCR */ cpu_openrisc_count_update (cpu);return cpu_openrisc_count_get (cpu); - -default : - break; - }#endif +case TO_SPR (0 ,20 ):/* FPCSR */ +return env->fpcsr; + } +/* for rd is passed in, if rd unchanged, just keep it back. */ return rd; }
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH 11/13] target/openrisc: Implement move to/from FPCSR
Quoted 1 line · Richard Henderson
Signed-off-by Richard Henderson <[email protected]>
PATCH 12/13 target/openrisc: Implement l.adrp
In reply to Richard HendersonThis was added to the 1.3 spec.
--- target/openrisc/disas.c | 1 + target/openrisc/translate.c | 13 +++++++++++++ target/openrisc/insns.decode | 2 ++ 3 files changed, 16 insertions(+)
target/openrisc/disas.c +1 -0
@@ -98,6 +98,7 @@ INSN(sw, "%d(r%d), r%d", a->i, a->a, a->b) INSN(sb, "%d(r%d), r%d", a->i, a->a, a->b) INSN(sh, "%d(r%d), r%d", a->i, a->a, a->b) INSN(nop, "") +INSN(adrp, "r%d, %d", a->d, a->i) INSN(addi, "r%d, r%d, %d", a->d, a->a, a->i) INSN(addic, "r%d, r%d, %d", a->d, a->a, a->i)INSN (muli,"r%d, r%d, %d" , a->d, a->a, a->i)
target/openrisc/translate.c +13 -0
@@ -799,6 +799,19 @@ static bool trans_l_nop(DisasContext *dc, arg_l_nop *a)return true; } +static bool trans_l_adrp (DisasContext *dc,arg_l_adrp *a) +{ +if (!check_v1_3 (dc)) { +return false; + } +check_r0_write (dc, a->d); + +tcg_gen_movi_i32 (cpu_R (dc, a->d), + (dc->base.pc_next &TARGET_PAGE_MASK ) + + ((target_long )a->i <<TARGET_PAGE_BITS )); +return true; +} +static bool trans_l_addi (DisasContext *dc,arg_rri *a) {TCGv t0;
target/openrisc/insns.decode +2 -0
@@ -102,6 +102,8 @@ l_maci 010011 ----- a:5 i:s16 l_movhi 000110 d:5 ----0 k:16 l_macrc 000110 d:5 ----1 00000000 00000000 +l_adrp 000010 d:5 i:s21 + #### # Arithmetic Instructions ####
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH 12/13] target/openrisc: Implement l.adrp
Quoted 3 lines · Richard Henderson
This was added to the 1.3 spec.
Signed-off-by Richard Henderson <[email protected]>
PATCH 13/13 target/openrisc: Update cpu "any" to v1.3
In reply to Richard HendersonNow that the two updates from v3.1 are implemented, update the "any" cpu to enable it.
--- target/openrisc/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/openrisc/cpu.c +1 -1
@@ -129,7 +129,7 @@ static void openrisc_any_initfn(Object *obj) cpu->env.vr =0x13000040 ;/* Obsolete VER + UVRP for new SPRs */ cpu->env.vr2 =0 ;/* No version specific id */ - cpu->env.avr =0x01010000 ;/* Architecture v1.1 */ + cpu->env.avr =0x01030000 ;/* Architecture v1.3 */ cpu->env.upr =UPR_UP |UPR_DMP |UPR_IMP |UPR_PICP |UPR_TTP |UPR_PMP ; cpu->env.cpucfgr = CPUCFGR_NSGF | CPUCFGR_OB32S | CPUCFGR_OF32S |
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH 13/13] target/openrisc: Update cpu "any" to v1.3
Quoted 2 lines · Richard Henderson
Now that the two updates from v3.1 are implemented, update the "any" cpu to enable it.
It should say 1.3 not 3.1 above.
Quoted 1 line
Signed-off-by Richard Henderson <[email protected]>
Other than that.
Quoted 13 lines · Richard Henderson
The first three fix an MTTCG race on cpu_R[0], now that we do code generation in parallel.
Then some updates to the SPRs, cpuid checks for existing float insns, adding the new v1.3 instructions.
I've run this through the gcc testsuite as
make check-gcc \
RUNTESTFLAGS='--target_board=or1k-qemu/-mhard-float/-mdouble-float execute.exp'=== gcc Summary ===
Quoted 8 lines
# of expected passes 103979 # of unexpected failures 26 # of expected failures 400 # of unresolved testcases 1 # of unsupported tests 2539Of the 26, none are obviously floating-point related.
Hi Richard,
Thanks for all of that. I assume you will be taking care of upstreaming this?
FYI, I have been working on getting an old [glibc port][0] ready for upstreaming. There still is a lot of testing and cleanup to be done. But so far the work has uncovered 2 bugs in OpenRISC binutils and gcc. I cced you on both of those, did you see them?
- binutils (*) : https://sourceware.org/ml/binutils/2019-08/msg00214.html
- gcc : https://gcc.gnu.org/ml/gcc-patches/2019-08/msg01549.html
* the binutils patch is already pushed upstream.
[0] https://github.com/stffrdhrn/or1k-glibc/tree/upstream-rebase
Sorry for hijacking this thread.
-Stafford