target/arm: SB, PredInv, CondM, FRINT extensions
v3 cover target/arm: SB, PredInv, CondM, FRINT extensions
These 5 extensions are small, and all previous editions have minor patch conflicts with master. Therefore, rebase them all together for simplicity.
r~
Richard Henderson (10):
target/arm: Split out arm_sctlr
target/arm: Implement ARMv8.0-SB
target/arm: Implement ARMv8.0-PredInv
target/arm: Split helper_msr_i_pstate into 3 target/arm: Add set/clear_pstate_bits, share gen_ss_advance target/arm: Rearrange disas_data_proc_reg target/arm: Implement ARMv8.4-CondM
target/arm: Implement ARMv8.5-CondM
target/arm: Restructure handle_fp_1src_{single,double} target/arm: Implement ARMv8.5-FRINT
target/arm/cpu.h | 64 ++++- target/arm/helper-a64.h | 3 + target/arm/helper.h | 8 +- target/arm/internals.h | 15 ++ target/arm/translate.h | 34 +++ linux-user/elfload.c | 2 + target/arm/cpu.c | 2 + target/arm/cpu64.c | 6 + target/arm/helper-a64.c | 30 +++ target/arm/helper.c | 63 ++++- target/arm/op_helper.c | 47 ---- target/arm/translate-a64.c | 476 ++++++++++++++++++++++++++++--------- target/arm/translate.c | 33 ++- target/arm/vfp_helper.c | 96 ++++++++ 14 files changed, 688 insertions(+), 191 deletions(-)
Signature · 1 line
2.17.2
PATCH v3 1/10 target/arm: Split out arm_sctlr
Minimize the number of places that will need updating when the virtual host extensions are added.
--- target/arm/cpu.h | 26 ++++++++++++++++---------- target/arm/helper.c | 8 ++------ 2 files changed, 18 insertions(+), 16 deletions(-)
target/arm/cpu.h +16 -10
@@ -3042,11 +3042,20 @@ static inline bool arm_sctlr_b(CPUARMState *env) (env->cp15.sctlr_el[1 ] &SCTLR_B ) !=0 ; } +static inline uint64_t arm_sctlr (CPUARMState *env,int el) +{ +if (el ==0 ) { +/* FIXME: ARMv8.1-VHE S2 translation regime. */ +return env->cp15.sctlr_el[1 ]; + }else { +return env->cp15.sctlr_el[el]; + } +} + +/* Return true if the processor is in big-endian mode. */ static inline bool arm_cpu_data_is_big_endian (CPUARMState *env) { -int cur_el; -/* In 32bit endianness is determined by looking at CPSR's E bit */ if (!is_a64 (env)) {return
@@ -3065,15 +3074,12 @@ static inline bool arm_cpu_data_is_big_endian(CPUARMState *env)arm_sctlr_b (env) || #endif ((env->uncached_cpsr & CPSR_E) ? 1 : 0); + }else { +int cur_el =arm_current_el (env); +uint64_t sctlr =arm_sctlr (env, cur_el); + +return (sctlr & (cur_el ?SCTLR_EE :SCTLR_E0E )) !=0 ; } - - cur_el =arm_current_el (env); - -if (cur_el ==0 ) { -return (env->cp15.sctlr_el[1 ] &SCTLR_E0E ) !=0 ; - } - -return (env->cp15.sctlr_el[cur_el] &SCTLR_EE ) !=0 ; }#include "exec/cpu-all.h"
target/arm/helper.c +2 -6
@@ -12854,12 +12854,8 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, flags =FIELD_DP32 (flags,TBFLAG_A64 ,ZCR_LEN , zcr_len); } -if (current_el ==0 ) { -/* FIXME: ARMv8.1-VHE S2 translation regime. */ - sctlr = env->cp15.sctlr_el[1 ]; - }else { - sctlr = env->cp15.sctlr_el[current_el]; - } + sctlr =arm_sctlr (env, current_el); +if (cpu_isar_feature (aa64_pauth, cpu)) {/* * In order to save space in flags, we record only whether
Signature · 1 line
2.17.2
PATCH v3 2/10 target/arm: Implement ARMv8.0-SB
In reply to Richard Henderson--- target/arm/cpu.h | 10 ++++++++++ linux-user/elfload.c | 1 + target/arm/cpu.c | 1 + target/arm/cpu64.c | 2 ++ target/arm/translate-a64.c | 14 ++++++++++++++ target/arm/translate.c | 22 ++++++++++++++++++++++ 6 files changed, 50 insertions(+)
target/arm/cpu.h +10 -0
@@ -3307,6 +3307,11 @@ static inline bool isar_feature_aa32_fhm(const ARMISARegisters *id)return FIELD_EX32 (id->id_isar6,ID_ISAR6 ,FHM ) !=0 ; } +static inline bool isar_feature_aa32_sb (const ARMISARegisters *id) +{ +return FIELD_EX32 (id->id_isar6,ID_ISAR6 ,SB ) !=0 ; +} +static inline bool isar_feature_aa32_fp16_arith (const ARMISARegisters *id) {/*
@@ -3445,6 +3450,11 @@ static inline bool isar_feature_aa64_pauth(const ARMISARegisters *id) FIELD_DP64(0, ID_AA64ISAR1, GPI, 0xf))) != 0; } +static inline bool isar_feature_aa64_sb (const ARMISARegisters *id) +{ +return FIELD_EX64 (id->id_aa64isar1,ID_AA64ISAR1 ,SB ) !=0 ; +} +static inline bool isar_feature_aa64_fp16 (const ARMISARegisters *id) {/* We always set the AdvSIMD and FP fields identically wrt FP16. */
linux-user/elfload.c +1 -0
@@ -604,6 +604,7 @@ static uint32_t get_elf_hwcap(void)GET_FEATURE_ID (aa64_pauth,ARM_HWCAP_A64_PACA |ARM_HWCAP_A64_PACG );GET_FEATURE_ID (aa64_fhm,ARM_HWCAP_A64_ASIMDFHM );GET_FEATURE_ID (aa64_jscvt,ARM_HWCAP_A64_JSCVT ); +GET_FEATURE_ID (aa64_sb,ARM_HWCAP_A64_SB );#undef GET_FEATURE_ID
target/arm/cpu.c +1 -0
@@ -2021,6 +2021,7 @@ static void arm_max_initfn(Object *obj) t =FIELD_DP32 (t,ID_ISAR6 ,JSCVT ,1 ); t =FIELD_DP32 (t,ID_ISAR6 ,DP ,1 ); t =FIELD_DP32 (t,ID_ISAR6 ,FHM ,1 ); + t =FIELD_DP32 (t,ID_ISAR6 ,SB ,1 ); cpu->isar.id_isar6 = t; t = cpu->id_mmfr4;
target/arm/cpu64.c +2 -0
@@ -318,6 +318,7 @@ static void aarch64_max_initfn(Object *obj) t =FIELD_DP64 (t,ID_AA64ISAR1 ,API ,0 ); t =FIELD_DP64 (t,ID_AA64ISAR1 ,GPA ,1 ); t =FIELD_DP64 (t,ID_AA64ISAR1 ,GPI ,0 ); + t =FIELD_DP64 (t,ID_AA64ISAR1 ,SB ,1 ); cpu->isar.id_aa64isar1 = t; t = cpu->isar.id_aa64pfr0;
@@ -349,6 +350,7 @@ static void aarch64_max_initfn(Object *obj) u =FIELD_DP32 (u,ID_ISAR6 ,JSCVT ,1 ); u =FIELD_DP32 (u,ID_ISAR6 ,DP ,1 ); u =FIELD_DP32 (u,ID_ISAR6 ,FHM ,1 ); + u =FIELD_DP32 (u,ID_ISAR6 ,SB ,1 ); cpu->isar.id_isar6 = u;/*
target/arm/translate-a64.c +14 -0
@@ -1637,7 +1637,21 @@ static void handle_sync(DisasContext *s, uint32_t insn,reset_btype (s);gen_goto_tb (s,0 , s->pc);return ; + +case 7 :/* SB */ +if (crm !=0 || !dc_isar_feature (aa64_sb, s)) { + goto do_unallocated; + } +/* +* TODO: There is no speculation barrier opcode for TCG; +* MB and end the TB instead. +*/ +tcg_gen_mb (TCG_MO_ALL |TCG_BAR_SC ); +gen_goto_tb (s,0 , s->pc); +return ; +default : + do_unallocated:unallocated_encoding (s);return ; }
target/arm/translate.c +22 -0
@@ -9282,6 +9282,17 @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)*/ gen_goto_tb (s,0 , s->pc & ~1 );return ; +case 7 :/* sb */ +if ((insn &0xf ) || !dc_isar_feature (aa32_sb, s)) { + goto illegal_op; + } +/* +* TODO: There is no speculation barrier opcode +* for TCG; MB and end the TB instead. +*/ +tcg_gen_mb (TCG_MO_ALL |TCG_BAR_SC ); +gen_goto_tb (s,0 , s->pc & ~1 ); +return ;default : goto illegal_op; }
@@ -11900,6 +11911,17 @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn)*/ gen_goto_tb (s,0 , s->pc & ~1 );break ; +case 7 :/* sb */ +if ((insn &0xf ) || !dc_isar_feature (aa32_sb, s)) { + goto illegal_op; + } +/* +* TODO: There is no speculation barrier opcode +* for TCG; MB and end the TB instead. +*/ +tcg_gen_mb (TCG_MO_ALL |TCG_BAR_SC ); +gen_goto_tb (s,0 , s->pc & ~1 ); +break ;default : goto illegal_op; }
Signature · 1 line
2.17.2
PATCH v3 3/10 target/arm: Implement ARMv8.0-PredInv
In reply to Richard Henderson--- target/arm/cpu.h | 13 ++++++++++- target/arm/cpu.c | 1 + target/arm/cpu64.c | 2 ++ target/arm/helper.c | 55 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 1 deletion(-)
target/arm/cpu.h +12 -1
@@ -1060,7 +1060,8 @@ void pmu_init(ARMCPU *cpu);#define SCTLR_R (1U << 9)/* up to v6; RAZ in v7 */ #define SCTLR_UMA (1U << 9)/* v8 onward, AArch64 only */ #define SCTLR_F (1U << 10)/* up to v6 */ -#define SCTLR_SW (1U << 10)/* v7, RES0 in v8 */ +#define SCTLR_SW (1U << 10)/* v7 */ +#define SCTLR_EnRCTX (1U << 10)/* in v8.0-PredInv */ #define SCTLR_Z (1U << 11)/* in v7, RES1 in v8 */ #define SCTLR_EOS (1U << 11)/* v8.5-ExS */ #define SCTLR_I (1U << 12)
@@ -3312,6 +3313,11 @@ static inline bool isar_feature_aa32_sb(const ARMISARegisters *id)return FIELD_EX32 (id->id_isar6,ID_ISAR6 ,SB ) !=0 ; } +static inline bool isar_feature_aa32_predinv (const ARMISARegisters *id) +{ +return FIELD_EX32 (id->id_isar6,ID_ISAR6 ,SPECRES ) !=0 ; +} +static inline bool isar_feature_aa32_fp16_arith (const ARMISARegisters *id) {/*
@@ -3455,6 +3461,11 @@ static inline bool isar_feature_aa64_sb(const ARMISARegisters *id)return FIELD_EX64 (id->id_aa64isar1,ID_AA64ISAR1 ,SB ) !=0 ; } +static inline bool isar_feature_aa64_predinv (const ARMISARegisters *id) +{ +return FIELD_EX64 (id->id_aa64isar1,ID_AA64ISAR1 ,SPECRES ) !=0 ; +} +static inline bool isar_feature_aa64_fp16 (const ARMISARegisters *id) {/* We always set the AdvSIMD and FP fields identically wrt FP16. */
target/arm/cpu.c +1 -0
@@ -2022,6 +2022,7 @@ static void arm_max_initfn(Object *obj) t =FIELD_DP32 (t,ID_ISAR6 ,DP ,1 ); t =FIELD_DP32 (t,ID_ISAR6 ,FHM ,1 ); t =FIELD_DP32 (t,ID_ISAR6 ,SB ,1 ); + t =FIELD_DP32 (t,ID_ISAR6 ,SPECRES ,1 ); cpu->isar.id_isar6 = t; t = cpu->id_mmfr4;
target/arm/cpu64.c +2 -0
@@ -319,6 +319,7 @@ static void aarch64_max_initfn(Object *obj) t =FIELD_DP64 (t,ID_AA64ISAR1 ,GPA ,1 ); t =FIELD_DP64 (t,ID_AA64ISAR1 ,GPI ,0 ); t =FIELD_DP64 (t,ID_AA64ISAR1 ,SB ,1 ); + t =FIELD_DP64 (t,ID_AA64ISAR1 ,SPECRES ,1 ); cpu->isar.id_aa64isar1 = t; t = cpu->isar.id_aa64pfr0;
@@ -351,6 +352,7 @@ static void aarch64_max_initfn(Object *obj) u =FIELD_DP32 (u,ID_ISAR6 ,DP ,1 ); u =FIELD_DP32 (u,ID_ISAR6 ,FHM ,1 ); u =FIELD_DP32 (u,ID_ISAR6 ,SB ,1 ); + u =FIELD_DP32 (u,ID_ISAR6 ,SPECRES ,1 ); cpu->isar.id_isar6 = u;/*
target/arm/helper.c +55 -0
67 lines not on this page · raw message
Signature · 1 line
2.17.2
PATCH v3 4/10 target/arm: Split helper_msr_i_pstate into 3
In reply to Richard HendersonThe EL0+UMA check is unique to DAIF. While SPSel had avoided the check by nature of already checking EL >= 1, the other post v8.0 extensions to MSR (imm) allow EL0 and do not require UMA. Avoid the unconditional write to pc and use raise_exception_ra to unwind.
--- target/arm/helper-a64.h | 3 +++ target/arm/helper.h | 1 - target/arm/internals.h | 15 ++++++++++++++ target/arm/helper-a64.c | 30 +++++++++++++++++++++++++++ target/arm/op_helper.c | 42 -------------------------------------- target/arm/translate-a64.c | 41 ++++++++++++++++++++++--------------- 6 files changed, 73 insertions(+), 59 deletions(-)
target/arm/helper-a64.h +3 -0
@@ -19,6 +19,9 @@ DEF_HELPER_FLAGS_2(udiv64, TCG_CALL_NO_RWG_SE, i64, i64, i64) DEF_HELPER_FLAGS_2(sdiv64, TCG_CALL_NO_RWG_SE, s64, s64, s64) DEF_HELPER_FLAGS_1(rbit64, TCG_CALL_NO_RWG_SE, i64, i64) +DEF_HELPER_2(msr_i_spsel, void, env, i32) +DEF_HELPER_2(msr_i_daifset, void, env, i32) +DEF_HELPER_2(msr_i_daifclear, void, env, i32) DEF_HELPER_3(vfp_cmph_a64, i64, f16, f16, ptr) DEF_HELPER_3(vfp_cmpeh_a64, i64, f16, f16, ptr)DEF_HELPER_3 (vfp_cmps_a64, i64, f32, f32, ptr)
target/arm/helper.h +0 -1
@@ -77,7 +77,6 @@ DEF_HELPER_2(get_cp_reg, i32, env, ptr) DEF_HELPER_3(set_cp_reg64, void, env, ptr, i64) DEF_HELPER_2(get_cp_reg64, i64, env, ptr) -DEF_HELPER_3(msr_i_pstate, void, env, i32, i32) DEF_HELPER_1(clear_pstate_ss, void, env)DEF_HELPER_2 (get_r13_banked, i32, env, i32)
target/arm/internals.h +15 -0
@@ -968,4 +968,19 @@ ARMVAParameters aa64_va_parameters_both(CPUARMState *env, uint64_t va,ARMVAParameters aa64_va_parameters (CPUARMState *env,uint64_t va,ARMMMUIdx mmu_idx,bool data); +static inline int exception_target_el (CPUARMState *env) +{ +int target_el =MAX (1 ,arm_current_el (env)); + +/* +* No such thing as secure EL1 if EL3 is aarch32, +* so update the target EL to EL3 in this case. +*/ +if (arm_is_secure (env) && !arm_el_is_aa64 (env,3 ) && target_el ==1 ) { + target_el =3 ; + } + +return target_el; +} +#endif
target/arm/helper-a64.c +30 -0
@@ -61,6 +61,36 @@ uint64_t HELPER(rbit64)(uint64_t x)return revbit64 (x); } +void HELPER (msr_i_spsel )(CPUARMState *env,uint32_t imm) +{ +update_spsel (env, imm); +} + +static void daif_check (CPUARMState *env,uint32_t op, +uint32_t imm,uintptr_t ra) +{ +/* DAIF update to PSTATE. This is OK from EL0 only if UMA is set. */ +if (arm_current_el (env) ==0 && !(env->cp15.sctlr_el[1 ] &SCTLR_UMA )) { +raise_exception_ra (env,EXCP_UDEF , +syn_aa64_sysregtrap (0 ,extract32 (op,0 ,3 ), +extract32 (op,3 ,3 ),4 , + imm,0x1f ,0 ), +exception_target_el (env), ra); + } +} + +void HELPER (msr_i_daifset )(CPUARMState *env,uint32_t imm) +{ +daif_check (env,0x1e , imm,GETPC ()); + env->daif |= (imm <<6 ) &PSTATE_DAIF ; +} + +void HELPER (msr_i_daifclear )(CPUARMState *env,uint32_t imm) +{ +daif_check (env,0x1f , imm,GETPC ()); + env->daif &= ~((imm <<6 ) &PSTATE_DAIF ); +} +/* Convert a softfloat float_relation_ (as returned by * the float*_compare functions) to the correct ARM * NZCV flag state.
target/arm/op_helper.c +0 -42
54 lines not on this page · raw message
target/arm/translate-a64.c +25 -16
54 lines not on this page · raw message
Signature · 1 line
2.17.2
PATCH v3 5/10 target/arm: Add set/clear_pstate_bits, share gen_ss_advance
In reply to Richard HendersonWe do not need an out-of-line helper for manipulating bits in pstate. While changing things, share the implementation of gen_ss_advance.
---
v3: Assert no manual change to CACHED_PSTATE_BITS,
merged in from a previously separate patch.
--- target/arm/helper.h | 2 -- target/arm/translate.h | 34 ++++++++++++++++++++++++++++++++++ target/arm/op_helper.c | 5 ----- target/arm/translate-a64.c | 11 ----------- target/arm/translate.c | 11 ----------- 5 files changed, 34 insertions(+), 29 deletions(-)
target/arm/helper.h +0 -2
@@ -77,8 +77,6 @@ DEF_HELPER_2(get_cp_reg, i32, env, ptr) DEF_HELPER_3(set_cp_reg64, void, env, ptr, i64) DEF_HELPER_2(get_cp_reg64, i64, env, ptr) -DEF_HELPER_1(clear_pstate_ss, void, env) - DEF_HELPER_2(get_r13_banked, i32, env, i32)DEF_HELPER_3 (set_r13_banked, void, env, i32, i32)
target/arm/translate.h +34 -0
@@ -202,6 +202,40 @@ static inline TCGv_i32 get_ahp_flag(void)return ret; } +/* Set bits within PSTATE. */ +static inline void set_pstate_bits (uint32_t bits) +{ +TCGv_i32 p =tcg_temp_new_i32 (); + +tcg_debug_assert (!(bits &CACHED_PSTATE_BITS )); + +tcg_gen_ld_i32 (p, cpu_env, offsetof(CPUARMState , pstate)); +tcg_gen_ori_i32 (p, p, bits); +tcg_gen_st_i32 (p, cpu_env, offsetof(CPUARMState , pstate)); +tcg_temp_free_i32 (p); +} + +/* Clear bits within PSTATE. */ +static inline void clear_pstate_bits (uint32_t bits) +{ +TCGv_i32 p =tcg_temp_new_i32 (); + +tcg_debug_assert (!(bits &CACHED_PSTATE_BITS )); + +tcg_gen_ld_i32 (p, cpu_env, offsetof(CPUARMState , pstate)); +tcg_gen_andi_i32 (p, p, ~bits); +tcg_gen_st_i32 (p, cpu_env, offsetof(CPUARMState , pstate)); +tcg_temp_free_i32 (p); +} + +/* If the singlestep state is Active-not-pending, advance to Active-pending. */ +static inline void gen_ss_advance (DisasContext *s) +{ +if (s->ss_active) { + s->pstate_ss =0 ; +clear_pstate_bits (PSTATE_SS ); + } +}/* Vector operations shared between ARM and AArch64. */ extern const GVecGen3 bsl_op;
target/arm/op_helper.c +0 -5
@@ -861,11 +861,6 @@ uint64_t HELPER(get_cp_reg64)(CPUARMState *env, void *rip)return res; } -void HELPER (clear_pstate_ss )(CPUARMState *env) -{ - env->pstate &= ~PSTATE_SS ; -} -void HELPER (pre_hvc )(CPUARMState *env) {ARMCPU *cpu =arm_env_get_cpu (env);
target/arm/translate-a64.c +0 -11
@@ -421,17 +421,6 @@ static void gen_exception_bkpt_insn(DisasContext *s, int offset, s->base.is_jmp =DISAS_NORETURN ; } -static void gen_ss_advance (DisasContext *s) -{ -/* If the singlestep state is Active-not-pending, advance to -* Active-pending. -*/ -if (s->ss_active) { - s->pstate_ss =0 ; -gen_helper_clear_pstate_ss (cpu_env); - } -} -static void gen_step_complete_exception (DisasContext *s) {/* We just completed step of an insn. Move from Active-not-pending
target/arm/translate.c +0 -11
@@ -298,17 +298,6 @@ static void gen_exception(int excp, uint32_t syndrome, uint32_t target_el)tcg_temp_free_i32 (tcg_excp); } -static void gen_ss_advance (DisasContext *s) -{ -/* If the singlestep state is Active-not-pending, advance to -* Active-pending. -*/ -if (s->ss_active) { - s->pstate_ss =0 ; -gen_helper_clear_pstate_ss (cpu_env); - } -} -static void gen_step_complete_exception (DisasContext *s) {/* We just completed step of an insn. Move from Active-not-pending
Signature · 1 line
2.17.2
PATCH v3 6/10 target/arm: Rearrange disas_data_proc_reg
In reply to Richard HendersonThis decoding more closely matches the ARMv8.4 Table C4-6, Encoding table for Data Processing - Register Group.
In particular, op2 == 0 is now more than just Add/sub (with carry).
--- target/arm/translate-a64.c | 98 ++++++++++++++++++++++---------------- 1 file changed, 57 insertions(+), 41 deletions(-)
target/arm/translate-a64.c +57 -41
@@ -4494,11 +4494,10 @@ static void disas_data_proc_3src(DisasContext *s, uint32_t insn) }/* Add/subtract (with carry) -* 31 30 29 28 27 26 25 24 23 22 21 20 16 15 10 9 5 4 0 -* +--+--+--+------------------------+------+---------+------+-----+ -* |sf|op| S| 1 1 0 1 0 0 0 0 | rm | opcode2 | Rn | Rd | -* +--+--+--+------------------------+------+---------+------+-----+ -* [000000] +* 31 30 29 28 27 26 25 24 23 22 21 20 16 15 10 9 5 4 0 +* +--+--+--+------------------------+------+-------------+------+-----+ +* |sf|op| S| 1 1 0 1 0 0 0 0 | rm | 0 0 0 0 0 0 | Rn | Rd | +* +--+--+--+------------------------+------+-------------+------+-----+ */ static void disas_adc_sbc (DisasContext *s,uint32_t insn)
@@ -4506,11 +4505,6 @@ static void disas_adc_sbc(DisasContext *s, uint32_t insn)unsigned int sf, op, setflags, rm, rn, rd;TCGv_i64 tcg_y, tcg_rn, tcg_rd; -if (extract32 (insn,10 ,6 ) !=0 ) { -unallocated_encoding (s); -return ; - } - sf =extract32 (insn,31 ,1 ); op =extract32 (insn,30 ,1 ); setflags =extract32 (insn,29 ,1 );
@@ -5164,47 +5158,69 @@ static void disas_data_proc_2src(DisasContext *s, uint32_t insn) } } -/* Data processing - register */ +/* +* Data processing - register +* 31 30 29 28 25 21 20 16 10 0 +* +--+---+--+---+-------+-----+-------+-------+---------+ +* | |op0| |op1| 1 0 1 | op2 | | op3 | | +* +--+---+--+---+-------+-----+-------+-------+---------+ +*/ static void disas_data_proc_reg (DisasContext *s,uint32_t insn) { -switch (extract32 (insn,24 ,5 )) { -case 0x0a :/* Logical (shifted register) */ -disas_logic_reg (s, insn); -break ; -case 0x0b :/* Add/subtract */ -if (insn & (1 <<21 )) {/* (extended register) */ -disas_add_sub_ext_reg (s, insn); +int op0 =extract32 (insn,30 ,1 ); +int op1 =extract32 (insn,28 ,1 ); +int op2 =extract32 (insn,21 ,4 ); +int op3 =extract32 (insn,10 ,6 ); + +if (!op1) { +if (op2 &8 ) { +if (op2 &1 ) { +/* Add/sub (extended register) */ +disas_add_sub_ext_reg (s, insn); + }else { +/* Add/sub (shifted register) */ +disas_add_sub_reg (s, insn); + } }else { -disas_add_sub_reg (s, insn); +/* Logical (shifted register) */ +disas_logic_reg (s, insn); } -break ; -case 0x1b :/* Data-processing (3 source) */ -disas_data_proc_3src (s, insn); -break ; -case 0x1a : -switch (extract32 (insn,21 ,3 )) { -case 0x0 :/* Add/subtract (with carry) */ +return ; + } + +switch (op2) { +case 0x0 : +switch (op3) { +case 0x00 :/* Add/subtract (with carry) */ disas_adc_sbc (s, insn);break ; -case 0x2 :/* Conditional compare */ -disas_cc (s, insn);/* both imm and reg forms */ -break ; -case 0x4 :/* Conditional select */ -disas_cond_select (s, insn); -break ; -case 0x6 :/* Data-processing */ -if (insn & (1 <<30 )) {/* (1 source) */ -disas_data_proc_1src (s, insn); - }else {/* (2 source) */ -disas_data_proc_2src (s, insn); - } -break ; +default : -unallocated_encoding (s); -break ; + goto do_unallocated; }break ; + +case 0x2 :/* Conditional compare */ +disas_cc (s, insn);/* both imm and reg forms */ +break ; + +case 0x4 :/* Conditional select */ +disas_cond_select (s, insn); +break ; + +case 0x6 :/* Data-processing */ +if (op0) {/* (1 source) */ +disas_data_proc_1src (s, insn); + }else {/* (2 source) */ +disas_data_proc_2src (s, insn); + } +break ; + case 0x8 ... 0xf: /* (3 source) */ +disas_data_proc_3src (s, insn); +break ; +default : + do_unallocated:unallocated_encoding (s);break ; }
Signature · 1 line
2.17.2
PATCH v3 7/10 target/arm: Implement ARMv8.4-CondM
In reply to Richard Henderson--- target/arm/cpu.h | 5 ++ linux-user/elfload.c | 1 + target/arm/cpu64.c | 1 + target/arm/translate-a64.c | 97 +++++++++++++++++++++++++++++++++++++- 4 files changed, 103 insertions(+), 1 deletion(-)
target/arm/cpu.h +5 -0
@@ -3431,6 +3431,11 @@ static inline bool isar_feature_aa64_fhm(const ARMISARegisters *id)return FIELD_EX64 (id->id_aa64isar0,ID_AA64ISAR0 ,FHM ) !=0 ; } +static inline bool isar_feature_aa64_condm_4 (const ARMISARegisters *id) +{ +return FIELD_EX64 (id->id_aa64isar0,ID_AA64ISAR0 ,TS ) !=0 ; +} +static inline bool isar_feature_aa64_jscvt (const ARMISARegisters *id) {return FIELD_EX64 (id->id_aa64isar1,ID_AA64ISAR1 ,JSCVT ) !=0 ;
linux-user/elfload.c +1 -0
@@ -605,6 +605,7 @@ static uint32_t get_elf_hwcap(void)GET_FEATURE_ID (aa64_fhm,ARM_HWCAP_A64_ASIMDFHM );GET_FEATURE_ID (aa64_jscvt,ARM_HWCAP_A64_JSCVT );GET_FEATURE_ID (aa64_sb,ARM_HWCAP_A64_SB ); +GET_FEATURE_ID (aa64_condm_4,ARM_HWCAP_A64_FLAGM );#undef GET_FEATURE_ID
target/arm/cpu64.c +1 -0
@@ -309,6 +309,7 @@ static void aarch64_max_initfn(Object *obj) t =FIELD_DP64 (t,ID_AA64ISAR0 ,SM4 ,1 ); t =FIELD_DP64 (t,ID_AA64ISAR0 ,DP ,1 ); t =FIELD_DP64 (t,ID_AA64ISAR0 ,FHM ,1 ); + t =FIELD_DP64 (t,ID_AA64ISAR0 ,TS ,1 ); cpu->isar.id_aa64isar0 = t; t = cpu->isar.id_aa64isar1;
target/arm/translate-a64.c +96 -1
121 lines not on this page · raw message
Signature · 1 line
2.17.2
PATCH v3 8/10 target/arm: Implement ARMv8.5-CondM
In reply to Richard Henderson---
v2: Update ID_AA64ISAR0.TS.
--- target/arm/cpu.h | 5 ++++ target/arm/cpu64.c | 2 +- target/arm/translate-a64.c | 58 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 1 deletion(-)
target/arm/cpu.h +5 -0
@@ -3436,6 +3436,11 @@ static inline bool isar_feature_aa64_condm_4(const ARMISARegisters *id)return FIELD_EX64 (id->id_aa64isar0,ID_AA64ISAR0 ,TS ) !=0 ; } +static inline bool isar_feature_aa64_condm_5 (const ARMISARegisters *id) +{ +return FIELD_EX64 (id->id_aa64isar0,ID_AA64ISAR0 ,TS ) >=2 ; +} +static inline bool isar_feature_aa64_jscvt (const ARMISARegisters *id) {return FIELD_EX64 (id->id_aa64isar1,ID_AA64ISAR1 ,JSCVT ) !=0 ;
target/arm/cpu64.c +1 -1
@@ -309,7 +309,7 @@ static void aarch64_max_initfn(Object *obj) t =FIELD_DP64 (t,ID_AA64ISAR0 ,SM4 ,1 ); t =FIELD_DP64 (t,ID_AA64ISAR0 ,DP ,1 ); t =FIELD_DP64 (t,ID_AA64ISAR0 ,FHM ,1 ); - t =FIELD_DP64 (t,ID_AA64ISAR0 ,TS ,1 ); + t =FIELD_DP64 (t,ID_AA64ISAR0 ,TS ,2 );/* v8.5-CondM */ cpu->isar.id_aa64isar0 = t; t = cpu->isar.id_aa64isar1;
target/arm/translate-a64.c +58 -0
70 lines not on this page · raw message
Signature · 1 line
2.17.2
PATCH v3 9/10 target/arm: Restructure handle_fp_1src_{single, double}
In reply to Richard HendersonThis will allow sharing code that adjusts rmode beyond the existing users.
--- target/arm/translate-a64.c | 90 +++++++++++++++++++++----------------- 1 file changed, 49 insertions(+), 41 deletions(-)
target/arm/translate-a64.c +49 -41
@@ -5686,55 +5686,59 @@ static void handle_fp_1src_half(DisasContext *s, int opcode, int rd, int rn)/* Floating-point data-processing (1 source) - single precision */ static void handle_fp_1src_single (DisasContext *s,int opcode,int rd,int rn) { +void (*gen_fpst)(TCGv_i32 ,TCGv_i32 ,TCGv_ptr ); +TCGv_i32 tcg_op, tcg_res;TCGv_ptr fpst; -TCGv_i32 tcg_op; -TCGv_i32 tcg_res; +int rmode =-1 ; - fpst =get_fpstatus_ptr (false); tcg_op =read_fp_sreg (s, rn); tcg_res =tcg_temp_new_i32 ();switch (opcode) {case 0x0 :/* FMOV */ tcg_gen_mov_i32 (tcg_res, tcg_op); -break ; + goto done;case 0x1 :/* FABS */ gen_helper_vfp_abss (tcg_res, tcg_op); -break ; + goto done;case 0x2 :/* FNEG */ gen_helper_vfp_negs (tcg_res, tcg_op); -break ; + goto done;case 0x3 :/* FSQRT */ gen_helper_vfp_sqrts (tcg_res, tcg_op, cpu_env); -break ; + goto done;case 0x8 :/* FRINTN */ case 0x9 :/* FRINTP */ case 0xa :/* FRINTM */ case 0xb :/* FRINTZ */ case 0xc :/* FRINTA */ - { -TCGv_i32 tcg_rmode =tcg_const_i32 (arm_rmode_to_sf (opcode &7 )); - -gen_helper_set_rmode (tcg_rmode, tcg_rmode, fpst); -gen_helper_rints (tcg_res, tcg_op, fpst); - -gen_helper_set_rmode (tcg_rmode, tcg_rmode, fpst); -tcg_temp_free_i32 (tcg_rmode); + rmode =arm_rmode_to_sf (opcode &7 ); + gen_fpst = gen_helper_rints;break ; - }case 0xe :/* FRINTX */ -gen_helper_rints_exact (tcg_res, tcg_op, fpst); + gen_fpst = gen_helper_rints_exact;break ;case 0xf :/* FRINTI */ -gen_helper_rints (tcg_res, tcg_op, fpst); + gen_fpst = gen_helper_rints;break ;default : -abort (); +g_assert_not_reached (); } -write_fp_sreg (s, rd, tcg_res); - + fpst =get_fpstatus_ptr (false); +if (rmode >=0 ) { +TCGv_i32 tcg_rmode =tcg_const_i32 (rmode); +gen_helper_set_rmode (tcg_rmode, tcg_rmode, fpst); +gen_fpst (tcg_res, tcg_op, fpst); +gen_helper_set_rmode (tcg_rmode, tcg_rmode, fpst); +tcg_temp_free_i32 (tcg_rmode); + }else { +gen_fpst (tcg_res, tcg_op, fpst); + }tcg_temp_free_ptr (fpst); + + done: +write_fp_sreg (s, rd, tcg_res);tcg_temp_free_i32 (tcg_op);tcg_temp_free_i32 (tcg_res); }
@@ -5742,9 +5746,10 @@ static void handle_fp_1src_single(DisasContext *s, int opcode, int rd, int rn)/* Floating-point data-processing (1 source) - double precision */ static void handle_fp_1src_double (DisasContext *s,int opcode,int rd,int rn) { +void (*gen_fpst)(TCGv_i64 ,TCGv_i64 ,TCGv_ptr ); +TCGv_i64 tcg_op, tcg_res;TCGv_ptr fpst; -TCGv_i64 tcg_op; -TCGv_i64 tcg_res; +int rmode =-1 ;switch (opcode) {case 0x0 :/* FMOV */
@@ -5752,48 +5757,51 @@ static void handle_fp_1src_double(DisasContext *s, int opcode, int rd, int rn)return ; } - fpst =get_fpstatus_ptr (false); tcg_op =read_fp_dreg (s, rn); tcg_res =tcg_temp_new_i64 ();switch (opcode) {case 0x1 :/* FABS */ gen_helper_vfp_absd (tcg_res, tcg_op); -break ; + goto done;case 0x2 :/* FNEG */ gen_helper_vfp_negd (tcg_res, tcg_op); -break ; + goto done;case 0x3 :/* FSQRT */ gen_helper_vfp_sqrtd (tcg_res, tcg_op, cpu_env); -break ; + goto done;case 0x8 :/* FRINTN */ case 0x9 :/* FRINTP */ case 0xa :/* FRINTM */ case 0xb :/* FRINTZ */ case 0xc :/* FRINTA */ - { -TCGv_i32 tcg_rmode =tcg_const_i32 (arm_rmode_to_sf (opcode &7 )); - -gen_helper_set_rmode (tcg_rmode, tcg_rmode, fpst); -gen_helper_rintd (tcg_res, tcg_op, fpst); - -gen_helper_set_rmode (tcg_rmode, tcg_rmode, fpst); -tcg_temp_free_i32 (tcg_rmode); + rmode =arm_rmode_to_sf (opcode &7 ); + gen_fpst = gen_helper_rintd;break ; - }case 0xe :/* FRINTX */ -gen_helper_rintd_exact (tcg_res, tcg_op, fpst); + gen_fpst = gen_helper_rintd_exact;break ;case 0xf :/* FRINTI */ -gen_helper_rintd (tcg_res, tcg_op, fpst); + gen_fpst = gen_helper_rintd;break ;default : -abort (); +g_assert_not_reached (); } -write_fp_dreg (s, rd, tcg_res); - + fpst =get_fpstatus_ptr (false); +if (rmode >=0 ) { +TCGv_i32 tcg_rmode =tcg_const_i32 (rmode); +gen_helper_set_rmode (tcg_rmode, tcg_rmode, fpst); +gen_fpst (tcg_res, tcg_op, fpst); +gen_helper_set_rmode (tcg_rmode, tcg_rmode, fpst); +tcg_temp_free_i32 (tcg_rmode); + }else { +gen_fpst (tcg_res, tcg_op, fpst); + }tcg_temp_free_ptr (fpst); + + done: +write_fp_dreg (s, rd, tcg_res);tcg_temp_free_i64 (tcg_op);tcg_temp_free_i64 (tcg_res); }
Signature · 1 line
2.17.2
PATCH v3 10/10 target/arm: Implement ARMv8.5-FRINT
In reply to Richard Henderson--- target/arm/cpu.h | 5 ++ target/arm/helper.h | 5 ++ target/arm/cpu64.c | 1 + target/arm/translate-a64.c | 71 ++++++++++++++++++++++++++-- target/arm/vfp_helper.c | 96 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 173 insertions(+), 5 deletions(-)
target/arm/cpu.h +5 -0
@@ -3476,6 +3476,11 @@ static inline bool isar_feature_aa64_predinv(const ARMISARegisters *id)return FIELD_EX64 (id->id_aa64isar1,ID_AA64ISAR1 ,SPECRES ) !=0 ; } +static inline bool isar_feature_aa64_frint (const ARMISARegisters *id) +{ +return FIELD_EX64 (id->id_aa64isar1,ID_AA64ISAR1 ,FRINTTS ) !=0 ; +} +static inline bool isar_feature_aa64_fp16 (const ARMISARegisters *id) {/* We always set the AdvSIMD and FP fields identically wrt FP16. */
target/arm/helper.h +5 -0
@@ -683,6 +683,11 @@ DEF_HELPER_FLAGS_5(gvec_fmlal_idx_a32, TCG_CALL_NO_RWG,DEF_HELPER_FLAGS_5 (gvec_fmlal_idx_a64,TCG_CALL_NO_RWG , void, ptr, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_2(frint32_s, TCG_CALL_NO_RWG, f32, f32, ptr) +DEF_HELPER_FLAGS_2(frint64_s, TCG_CALL_NO_RWG, f32, f32, ptr) +DEF_HELPER_FLAGS_2(frint32_d, TCG_CALL_NO_RWG, f64, f64, ptr) +DEF_HELPER_FLAGS_2(frint64_d, TCG_CALL_NO_RWG, f64, f64, ptr) +#ifdef TARGET_AARCH64 #include "helper-a64.h" #include "helper-sve.h"
target/arm/cpu64.c +1 -0
@@ -321,6 +321,7 @@ static void aarch64_max_initfn(Object *obj) t =FIELD_DP64 (t,ID_AA64ISAR1 ,GPI ,0 ); t =FIELD_DP64 (t,ID_AA64ISAR1 ,SB ,1 ); t =FIELD_DP64 (t,ID_AA64ISAR1 ,SPECRES ,1 ); + t =FIELD_DP64 (t,ID_AA64ISAR1 ,FRINTTS ,1 ); cpu->isar.id_aa64isar1 = t; t = cpu->isar.id_aa64pfr0;
target/arm/translate-a64.c +66 -5
137 lines not on this page · raw message
target/arm/vfp_helper.c +96 -0
99 lines not on this page · raw message
Signature · 1 line
2.17.2
Peter Maydell
AppliedQuoted 9 lines · Richard Henderson
These 5 extensions are small, and all previous editions have minor patch conflicts with master. Therefore, rebase them all together for simplicity.
r~
Applied to target-arm.next, thanks.
-- PMM