ARM v8.1 simd + v8.3 complex insns
v2 cover ARM v8.1 simd + v8.3 complex insns
I've incorporated Alex's feedback from v1, and have now rebased upon Alex's work so that the complex insns now support fp16.
r~
Richard Henderson (11):
target/arm: Add ARM_FEATURE_V8_1_SIMD
target/arm: Decode aa64 armv8.1 scalar three same extra target/arm: Decode aa64 armv8.1 three same extra target/arm: Decode aa64 armv8.1 scalar/vector x indexed element target/arm: Decode aa32 armv8.1 three same target/arm: Decode aa32 armv8.1 two reg and a scalar target/arm: Add ARM_FEATURE_V8_FCMA
target/arm: Decode aa64 armv8.3 fcadd
target/arm: Decode aa64 armv8.3 fcmla
target/arm: Decode aa32 armv8.3 3-same
target/arm: Decode aa32 armv8.3 2-reg-index
target/arm/cpu.h | 2 + target/arm/helper.h | 31 ++++ linux-user/elfload.c | 10 ++ target/arm/advsimd_helper.c | 420 ++++++++++++++++++++++++++++++++++++++++++++ target/arm/cpu.c | 2 + target/arm/cpu64.c | 2 + target/arm/translate-a64.c | 382 ++++++++++++++++++++++++++++++++++++---- target/arm/translate.c | 239 ++++++++++++++++++++++--- target/arm/Makefile.objs | 2 +- 9 files changed, 1032 insertions(+), 58 deletions(-) create mode 100644 target/arm/advsimd_helper.c
Signature · 1 line
2.14.3
PATCH v2 1/11 target/arm: Add ARM_FEATURE_V8_1_SIMD
Enable it for the "any" CPU used by *-linux-user.
--- target/arm/cpu.h | 1 + linux-user/elfload.c | 9 +++++++++ target/arm/cpu.c | 1 + target/arm/cpu64.c | 1 + 4 files changed, 12 insertions(+)
target/arm/cpu.h +1 -0
@@ -1351,6 +1351,7 @@ enum arm_features {ARM_FEATURE_VBAR ,/* has cp15 VBAR */ ARM_FEATURE_M_SECURITY ,/* M profile Security Extension */ ARM_FEATURE_JAZELLE ,/* has (trivial) Jazelle implementation */ +ARM_FEATURE_V8_1_SIMD ,/* has ARMv8.1-SIMD */ ARM_FEATURE_V8_FP16, /* implements v8.2 half-precision float */ };
linux-user/elfload.c +9 -0
@@ -512,6 +512,14 @@ enum {ARM_HWCAP_A64_SHA1 =1 <<5 ,ARM_HWCAP_A64_SHA2 =1 <<6 ,ARM_HWCAP_A64_CRC32 =1 <<7 , +ARM_HWCAP_A64_ATOMICS =1 <<8 , +ARM_HWCAP_A64_FPHP =1 <<9 , +ARM_HWCAP_A64_ASIMDHP =1 <<10 , +ARM_HWCAP_A64_CPUID =1 <<11 , +ARM_HWCAP_A64_ASIMDRDM =1 <<12 , +ARM_HWCAP_A64_JSCVT =1 <<13 , +ARM_HWCAP_A64_FCMA =1 <<14 , + ARM_HWCAP_A64_LRCPC = 1 << 15, };#define ELF_HWCAP get_elf_hwcap()
@@ -532,6 +540,7 @@ static uint32_t get_elf_hwcap(void)GET_FEATURE (ARM_FEATURE_V8_SHA1 ,ARM_HWCAP_A64_SHA1 );GET_FEATURE (ARM_FEATURE_V8_SHA256 ,ARM_HWCAP_A64_SHA2 );GET_FEATURE (ARM_FEATURE_CRC ,ARM_HWCAP_A64_CRC32 ); +GET_FEATURE (ARM_FEATURE_V8_1_SIMD ,ARM_HWCAP_A64_ASIMDRDM );#undef GET_FEATUREreturn hwcaps;
target/arm/cpu.c +1 -0
@@ -1628,6 +1628,7 @@ static void arm_any_initfn(Object *obj)set_feature (&cpu->env,ARM_FEATURE_V8_SHA256 );set_feature (&cpu->env,ARM_FEATURE_V8_PMULL );set_feature (&cpu->env,ARM_FEATURE_CRC ); +set_feature (&cpu->env,ARM_FEATURE_V8_1_SIMD ); cpu->midr = 0xffffffff; }#endif
target/arm/cpu64.c +1 -0
@@ -226,6 +226,7 @@ static void aarch64_any_initfn(Object *obj)set_feature (&cpu->env,ARM_FEATURE_V8_SHA256 );set_feature (&cpu->env,ARM_FEATURE_V8_PMULL );set_feature (&cpu->env,ARM_FEATURE_CRC ); +set_feature (&cpu->env,ARM_FEATURE_V8_1_SIMD );set_feature (&cpu->env,ARM_FEATURE_V8_FP16 ); cpu->ctr =0x80038003 ;/* 32 byte I and D cacheline size, VIPT icache */ cpu->dcz_blocksize =7 ;/* 512 bytes */
Signature · 1 line
2.14.3
Re: [Qemu-arm] [PATCH v2 01/11] target/arm: Add ARM_FEATURE_V8_1_SIMD
Quoted 16 lines · Richard Henderson
Enable it for the "any" CPU used by *-linux-user.
Reviewed-by Alex Bennée <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- target/arm/cpu.h | 1 + linux-user/elfload.c | 9 +++++++++ target/arm/cpu.c | 1 + target/arm/cpu64.c | 1 + 4 files changed, 12 insertions(+)target/arm/cpu.h +0
-0
target/arm/cpu.h enum arm_features { · line 1356
Quoted 6 lines
target/arm/cpu.h +1
-0@@ -1351,6 +1351,7 @@ enum arm_features {ARM_FEATURE_VBAR ,/* has cp15 VBAR */ ARM_FEATURE_M_SECURITY ,/* M profile Security Extension */ ARM_FEATURE_JAZELLE ,/* has (trivial) Jazelle implementation */ +ARM_FEATURE_V8_1_SIMD ,/* has ARMv8.1-SIMD */ ARM_FEATURE_V8_FP16, /* implements v8.2 half-precision float */ };
I kind of prefer the kernel's choice of ASIMDRDM rather than V8_1_SIMD, but the latter is the official architectural feature name, so oh well.
thanks
-- PMM
PATCH v2 2/11 target/arm: Decode aa64 armv8.1 scalar three same extra
In reply to Richard Henderson--- target/arm/helper.h | 4 ++ target/arm/advsimd_helper.c | 109 ++++++++++++++++++++++++++++++++++++++++++++ target/arm/translate-a64.c | 90 ++++++++++++++++++++++++++++++++++++ target/arm/Makefile.objs | 2 +- 4 files changed, 204 insertions(+), 1 deletion(-) create mode 100644 target/arm/advsimd_helper.c
target/arm/helper.h +4 -0
@@ -366,8 +366,12 @@ DEF_HELPER_FLAGS_1(neon_rbit_u8, TCG_CALL_NO_RWG_SE, i32, i32) DEF_HELPER_3(neon_qdmulh_s16, i32, env, i32, i32) DEF_HELPER_3(neon_qrdmulh_s16, i32, env, i32, i32) +DEF_HELPER_4(neon_qrdmlah_s16, i32, env, i32, i32, i32) +DEF_HELPER_4(neon_qrdmlsh_s16, i32, env, i32, i32, i32) DEF_HELPER_3(neon_qdmulh_s32, i32, env, i32, i32) DEF_HELPER_3(neon_qrdmulh_s32, i32, env, i32, i32) +DEF_HELPER_4(neon_qrdmlah_s32, i32, env, s32, s32, s32) +DEF_HELPER_4(neon_qrdmlsh_s32, i32, env, s32, s32, s32) DEF_HELPER_1(neon_narrow_u8, i32, i64)DEF_HELPER_1 (neon_narrow_u16, i32, i64)
target/arm/advsimd_helper.c new file +109 -0
109 lines not on this page · raw message
target/arm/translate-a64.c +90 -0
102 lines not on this page · raw message
target/arm/Makefile.objs +1 -1
@@ -5,7 +5,7 @@ obj-$(call land,$(CONFIG_KVM),$(call lnot,$(TARGET_AARCH64))) += kvm32.o obj-$(call land,$(CONFIG_KVM),$(TARGET_AARCH64)) += kvm64.o obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o obj-y += translate.o op_helper.o helper.o cpu.o -obj-y += neon_helper.o iwmmxt_helper.o +obj-y += neon_helper.o iwmmxt_helper.o advsimd_helper.o obj-y += gdbstub.o obj-$(TARGET_AARCH64) += cpu64.o translate-a64.o helper-a64.o gdbstub64.o obj-y += crypto_helper.o
Signature · 1 line
2.14.3
PATCH v2 3/11 target/arm: Decode aa64 armv8.1 three same extra
In reply to Richard Henderson--- target/arm/helper.h | 9 +++++ target/arm/advsimd_helper.c | 74 ++++++++++++++++++++++++++++++++++++++++ target/arm/translate-a64.c | 83 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 166 insertions(+)
target/arm/helper.h +9 -0
@@ -558,6 +558,15 @@ DEF_HELPER_2(dc_zva, void, env, i64) DEF_HELPER_FLAGS_2(neon_pmull_64_lo, TCG_CALL_NO_RWG_SE, i64, i64, i64) DEF_HELPER_FLAGS_2(neon_pmull_64_hi, TCG_CALL_NO_RWG_SE, i64, i64, i64) +DEF_HELPER_FLAGS_5 (gvec_qrdmlah_s16,TCG_CALL_NO_RWG , + void, ptr, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_5 (gvec_qrdmlsh_s16,TCG_CALL_NO_RWG , + void, ptr, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_5 (gvec_qrdmlah_s32,TCG_CALL_NO_RWG , + void, ptr, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_5 (gvec_qrdmlsh_s32,TCG_CALL_NO_RWG , + void, ptr, ptr, ptr, ptr, i32) +#ifdef TARGET_AARCH64 #include "helper-a64.h" #endif
target/arm/advsimd_helper.c +74 -0
101 lines not on this page · raw message
target/arm/translate-a64.c +83 -0
96 lines not on this page · raw message
Signature · 1 line
2.14.3
Re: [Qemu-arm] [PATCH v2 03/11] target/arm: Decode aa64 armv8.1 three same extra
Quoted 6 lines · Richard Henderson
Signed-off-by Richard Henderson <[email protected]>--- target/arm/helper.h | 9 +++++ target/arm/advsimd_helper.c | 74 ++++++++++++++++++++++++++++++++++++++++ target/arm/translate-a64.c | 83 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 166 insertions(+)
thanks
-- PMM
PATCH v2 4/11 target/arm: Decode aa64 armv8.1 scalar/vector x indexed element
In reply to Richard Henderson--- target/arm/translate-a64.c | 46 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-)
target/arm/translate-a64.c +40 -6
@@ -11857,12 +11857,23 @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) is_long = true;/* fall through */ case 0xc :/* SQDMULH */ -case 0xd :/* SQRDMULH */ if (u) {unallocated_encoding (s);return ; }break ; +case 0xd :/* SQRDMULH / SQRDMLAH */ +if (u && !arm_dc_feature (s,ARM_FEATURE_V8_1_SIMD )) { +unallocated_encoding (s); +return ; + } +break ; +case 0xf :/* SQRDMLSH */ +if (!u || !arm_dc_feature (s,ARM_FEATURE_V8_1_SIMD )) { +unallocated_encoding (s); +return ; + } +break ;case 0x8 :/* MUL */ if (u || is_scalar) {unallocated_encoding (s);
@@ -12100,13 +12111,36 @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) tcg_op, tcg_idx); }break ; -case 0xd :/* SQRDMULH */ +case 0xd :/* SQRDMULH / SQRDMLAH */ +if (u) {/* SQRDMLAH */ +read_vec_element_i32 (s, tcg_res, rd, pass, + is_scalar ? size :MO_32 ); +if (size ==1 ) { +gen_helper_neon_qrdmlah_s16 (tcg_res, cpu_env, + tcg_op, tcg_idx, tcg_res); + }else { +gen_helper_neon_qrdmlah_s32 (tcg_res, cpu_env, + tcg_op, tcg_idx, tcg_res); + } + }else {/* SQRDMULH */ +if (size ==1 ) { +gen_helper_neon_qrdmulh_s16 (tcg_res, cpu_env, + tcg_op, tcg_idx); + }else { +gen_helper_neon_qrdmulh_s32 (tcg_res, cpu_env, + tcg_op, tcg_idx); + } + } +break ; +case 0xf :/* SQRDMLSH */ +read_vec_element_i32 (s, tcg_res, rd, pass, + is_scalar ? size :MO_32 );if (size ==1 ) { -gen_helper_neon_qrdmulh_s16 (tcg_res, cpu_env, - tcg_op, tcg_idx); +gen_helper_neon_qrdmlsh_s16 (tcg_res, cpu_env, + tcg_op, tcg_idx, tcg_res); }else { -gen_helper_neon_qrdmulh_s32 (tcg_res, cpu_env, - tcg_op, tcg_idx); +gen_helper_neon_qrdmlsh_s32 (tcg_res, cpu_env, + tcg_op, tcg_idx, tcg_res); }break ;default :
Signature · 1 line
2.14.3
PATCH v2 5/11 target/arm: Decode aa32 armv8.1 three same
In reply to Richard Henderson--- target/arm/translate.c | 85 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 66 insertions(+), 19 deletions(-)
target/arm/translate.c +66 -19
@@ -25,6 +25,7 @@#include "disas/disas.h" #include "exec/exec-all.h" #include "tcg-op.h" +#include "tcg-op-gvec.h" #include "qemu/log.h" #include "qemu/bitops.h" #include "arm_ldst.h"
@@ -5364,9 +5365,9 @@ static void gen_neon_narrow_op(int op, int u, int size,#define NEON_3R_VPMAX 20#define NEON_3R_VPMIN 21#define NEON_3R_VQDMULH_VQRDMULH 22 -#define NEON_3R_VPADD 23 +#define NEON_3R_VPADD_VQRDMLAH 23#define NEON_3R_SHA 24/* SHA1C,SHA1P,SHA1M,SHA1SU0,SHA256H{2},SHA256SU1 */ -#define NEON_3R_VFM 25/* VFMA, VFMS : float fused multiply-add */ +#define NEON_3R_VFM_VQRDMLSH 25/* VFMA, VFMS : float fused multiply-add */ #define NEON_3R_FLOAT_ARITH 26/* float VADD, VSUB, VPADD, VABD */ #define NEON_3R_FLOAT_MULTIPLY 27/* float VMLA, VMLS, VMUL */ #define NEON_3R_FLOAT_CMP 28/* float VCEQ, VCGE, VCGT */
@@ -5398,9 +5399,9 @@ static const uint8_t neon_3r_sizes[] = { [NEON_3R_VPMAX] = 0x7, [NEON_3R_VPMIN] = 0x7, [NEON_3R_VQDMULH_VQRDMULH] = 0x6, - [NEON_3R_VPADD] = 0x7, + [NEON_3R_VPADD_VQRDMLAH] = 0x7, [NEON_3R_SHA] = 0xf, /* size field encodes op type */ - [NEON_3R_VFM] = 0x5, /* size bit 1 encodes op */ + [NEON_3R_VFM_VQRDMLSH] = 0x7, /* For VFM, size bit 1 encodes op */ [NEON_3R_FLOAT_ARITH] = 0x5, /* size bit 1 encodes op */ [NEON_3R_FLOAT_MULTIPLY] = 0x5, /* size bit 1 encodes op */ [NEON_3R_FLOAT_CMP] = 0x5, /* size bit 1 encodes op */
@@ -5579,6 +5580,22 @@ static const uint8_t neon_2rm_sizes[] = { [NEON_2RM_VCVT_UF] = 0x4, }; + +/* Expand v8.1 simd helper. */ +static int do_v81_helper (DisasContext *s,gen_helper_gvec_3_ptr *fn, +int q,int rd,int rn,int rm) +{ +if (arm_dc_feature (s,ARM_FEATURE_V8_1_SIMD )) { +int opr_sz = (1 + q) *8 ; +tcg_gen_gvec_3_ptr (vfp_reg_offset (1 , rd), +vfp_reg_offset (1 , rn), +vfp_reg_offset (1 , rm), cpu_env, + opr_sz, opr_sz,0 , fn); +return 0 ; + } +return 1 ; +} +/* Translate a NEON data processing instruction. Return nonzero if the instruction is invalid. We process data in a mixture of 32-bit and 64-bit chunks.
@@ -5630,12 +5647,12 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)if (q && ((rd | rn | rm) &1 )) {return 1 ; } -/* -* The SHA-1/SHA-256 3-register instructions require special treatment -* here, as their size field is overloaded as an op type selector, and -* they all consume their input in a single pass. -*/ -if (op ==NEON_3R_SHA ) { +switch (op) { +case NEON_3R_SHA : +/* The SHA-1/SHA-256 3-register instructions require special +* treatment here, as their size field is overloaded as an +* op type selector, and they all consume their input in a +* single pass. */ if (!q) {return 1 ; }
@@ -5672,6 +5689,40 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)tcg_temp_free_i32 (tmp2);tcg_temp_free_i32 (tmp3);return 0 ; + +case NEON_3R_VPADD_VQRDMLAH : +if (!u) { +break ;/* VPADD */ + } +/* VQRDMLAH */ +switch (size) { +case 1 : +return do_v81_helper (s, gen_helper_gvec_qrdmlah_s16, + q, rd, rn, rm); +case 2 : +return do_v81_helper (s, gen_helper_gvec_qrdmlah_s32, + q, rd, rn, rm); + } +return 1 ; + +case NEON_3R_VFM_VQRDMLSH : +if (!u) { +/* VFM, VFMS */ +if ((5 & (1 << size)) ==0 ) { +return 1 ; + } +break ; + } +/* VQRDMLSH */ +switch (size) { +case 1 : +return do_v81_helper (s, gen_helper_gvec_qrdmlsh_s16, + q, rd, rn, rm); +case 2 : +return do_v81_helper (s, gen_helper_gvec_qrdmlsh_s32, + q, rd, rn, rm); + } +return 1 ; }if (size ==3 && op !=NEON_3R_LOGIC ) {/* 64-bit element instructions. */
@@ -5757,11 +5808,7 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) rm = rtmp; }break ; -case NEON_3R_VPADD : -if (u) { -return 1 ; - } -/* Fall through */ +case NEON_3R_VPADD_VQRDMLAH :case NEON_3R_VPMAX :case NEON_3R_VPMIN : pairwise =1 ;
@@ -5795,8 +5842,8 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)return 1 ; }break ; -case NEON_3R_VFM : -if (!arm_dc_feature (s,ARM_FEATURE_VFP4 ) || u) { +case NEON_3R_VFM_VQRDMLSH : +if (!arm_dc_feature (s,ARM_FEATURE_VFP4 )) {return 1 ; }break ;
@@ -5993,7 +6040,7 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) } }break ; -case NEON_3R_VPADD : +case NEON_3R_VPADD_VQRDMLAH :switch (size) {case 0 :gen_helper_neon_padd_u8 (tmp, tmp, tmp2);break ;case 1 :gen_helper_neon_padd_u16 (tmp, tmp, tmp2);break ;
@@ -6092,7 +6139,7 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) } }break ; -case NEON_3R_VFM : +case NEON_3R_VFM_VQRDMLSH : {/* VFMA, VFMS: fused multiply-add */ TCGv_ptr fpstatus =get_fpstatus_ptr (1 );
Signature · 1 line
2.14.3
Re: [Qemu-arm] [PATCH v2 05/11] target/arm: Decode aa32 armv8.1 three same
Quoted 18 lines · Richard Henderson
Signed-off-by Richard Henderson <[email protected]>--- target/arm/translate.c | 85 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 66 insertions(+), 19 deletions(-)target/arm/translate.c +1
-0@@ -25,6 +25,7 @@#include "disas/disas.h" #include "exec/exec-all.h" #include "tcg-op.h" +#include "tcg-op-gvec.h" #include "qemu/log.h" #include "qemu/bitops.h" #include "arm_ldst.h"
target/arm/translate.c static void gen_neon_narrow_op(int op, int u, int size, · line 5370
Quoted 8 lines
target/arm/translate.c +2
-2@@ -5364,9 +5365,9 @@ static void gen_neon_narrow_op(int op, int u, int size,#define NEON_3R_VPMAX 20#define NEON_3R_VPMIN 21#define NEON_3R_VQDMULH_VQRDMULH 22 -#define NEON_3R_VPADD 23 +#define NEON_3R_VPADD_VQRDMLAH 23#define NEON_3R_SHA 24/* SHA1C,SHA1P,SHA1M,SHA1SU0,SHA256H{2},SHA256SU1 */ -#define NEON_3R_VFM 25/* VFMA, VFMS : float fused multiply-add */ +#define NEON_3R_VFM_VQRDMLSH 25/* VFMA, VFMS : float fused multiply-add */
If this case includes VQRDLMSH as well now, then the comment needs updating. I would suggest just /* VFMA, VFMS, VQRDMLSH */
Quoted 10 lines
target/arm/translate.c +0
-2#define NEON_3R_FLOAT_ARITH 26/* float VADD, VSUB, VPADD, VABD */ #define NEON_3R_FLOAT_MULTIPLY 27/* float VMLA, VMLS, VMUL */ #define NEON_3R_FLOAT_CMP 28/* float VCEQ, VCGE, VCGT */ @@ -5630,12 +5647,12 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)if (q && ((rd | rn | rm) &1 )) {return 1 ; } -/* -* The SHA-1/SHA-256 3-register instructions require special treatment
target/arm/translate.c static int disas_neon_data_insn(DisasContext *s, uint32_t insn) · line 5655
Quoted 10 lines
target/arm/translate.c +6
-4-* here, as their size field is overloaded as an op type selector, and -* they all consume their input in a single pass. -*/ -if (op ==NEON_3R_SHA ) { +switch (op) { +case NEON_3R_SHA : +/* The SHA-1/SHA-256 3-register instructions require special +* treatment here, as their size field is overloaded as an +* op type selector, and they all consume their input in a +* single pass. */
You've lost the newline before the '*/' here.
Quoted 17 lines
target/arm/translate.c +10
-0if (!q) {return 1 ; }@@ -5672,6 +5689,40 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)tcg_temp_free_i32 (tmp2);tcg_temp_free_i32 (tmp3);return 0 ; + +case NEON_3R_VPADD_VQRDMLAH : +if (!u) { +break ;/* VPADD */ + } +/* VQRDMLAH */ +switch (size) { +case 1 : +return do_v81_helper (s, gen_helper_gvec_qrdmlah_s16, + q, rd, rn, rm);
target/arm/translate.c static int disas_neon_data_insn(DisasContext *s, uint32_t insn) · line 5711
Quoted 10 lines
target/arm/translate.c +10
-0+case 2 : +return do_v81_helper (s, gen_helper_gvec_qrdmlah_s32, + q, rd, rn, rm); + } +return 1 ; + +case NEON_3R_VFM_VQRDMLSH : +if (!u) { +/* VFM, VFMS */ +if ((5 & (1 << size)) ==0 ) {
You could write this 'if (size == 1)' (since the neon_e3r_sizes[] check has already ruled out bit 3 being set)...
Otherwise
thanks
-- PMM
PATCH v2 6/11 target/arm: Decode aa32 armv8.1 two reg and a scalar
In reply to Richard Henderson--- target/arm/translate.c | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-)
target/arm/translate.c +35 -3
@@ -6973,11 +6973,43 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) }neon_store_reg64 (cpu_V0, rd + pass); } +break ; +case 14 :/* VQRDMLAH scalar */ +case 15 :/* VQRDMLSH scalar */ +if (!arm_dc_feature (s,ARM_FEATURE_V8_1_SIMD )) { +return 1 ; + } +if (u && ((rd | rn) &1 )) { +return 1 ; + } + tmp2 =neon_get_scalar (size, rm); +for (pass =0 ; pass < (u ?4 :2 ); pass++) { +void (*fn)(TCGv_i32 ,TCGv_env ,TCGv_i32 , +TCGv_i32 ,TCGv_i32 ); - + tmp =neon_load_reg (rn, pass); + tmp3 =neon_load_reg (rd, pass); +if (op ==14 ) { +if (size ==1 ) { + fn = gen_helper_neon_qrdmlah_s16; + }else { + fn = gen_helper_neon_qrdmlah_s32; + } + }else { +if (size ==1 ) { + fn = gen_helper_neon_qrdmlsh_s16; + }else { + fn = gen_helper_neon_qrdmlsh_s32; + } + } +fn (tmp, cpu_env, tmp, tmp2, tmp3); +tcg_temp_free_i32 (tmp3); +neon_store_reg (rd, pass, tmp); + } +tcg_temp_free_i32 (tmp2);break ; -default :/* 14 and 15 are RESERVED */ -return 1 ; +default : +g_assert_not_reached (); } } }else {/* size == 3 */
Signature · 1 line
2.14.3
Re: [Qemu-arm] [PATCH v2 06/11] target/arm: Decode aa32 armv8.1 two reg and a scalar
Quoted 12 lines · Richard Henderson
Signed-off-by Richard Henderson <[email protected]>--- target/arm/translate.c | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-)target/arm/translate.c +0
-0@@ -6973,11 +6973,43 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) }neon_store_reg64 (cpu_V0, rd + pass);
target/arm/translate.c static int disas_neon_data_insn(DisasContext *s, uint32_t insn) · line 6984
Quoted 10 lines
target/arm/translate.c +9
-0} +break ; +case 14 :/* VQRDMLAH scalar */ +case 15 :/* VQRDMLSH scalar */ +if (!arm_dc_feature (s,ARM_FEATURE_V8_1_SIMD )) { +return 1 ; + } +if (u && ((rd | rn) &1 )) { +return 1 ; + }
The pseudocode also has UNDEF if Q==1 && Vm<0> == 1 -- have we already done that test earlier? I can't see it, but our neon decode code is quite hard to read...
target/arm/translate.c static int disas_neon_data_insn(DisasContext *s, uint32_t insn) · line 6988
Quoted 4 lines
target/arm/translate.c +4
-0+ tmp2 =neon_get_scalar (size, rm); +for (pass =0 ; pass < (u ?4 :2 ); pass++) { +void (*fn)(TCGv_i32 ,TCGv_env ,TCGv_i32 , +TCGv_i32 ,TCGv_i32 );
Can we define a typedef for this, please ?
Quoted 31 lines
target/arm/translate.c +22
-4- + tmp =neon_load_reg (rn, pass); + tmp3 =neon_load_reg (rd, pass); +if (op ==14 ) { +if (size ==1 ) { + fn = gen_helper_neon_qrdmlah_s16; + }else { + fn = gen_helper_neon_qrdmlah_s32; + } + }else { +if (size ==1 ) { + fn = gen_helper_neon_qrdmlsh_s16; + }else { + fn = gen_helper_neon_qrdmlsh_s32; + } + } +fn (tmp, cpu_env, tmp, tmp2, tmp3); +tcg_temp_free_i32 (tmp3); +neon_store_reg (rd, pass, tmp); + } +tcg_temp_free_i32 (tmp2);break ; -default :/* 14 and 15 are RESERVED */ -return 1 ; +default : +g_assert_not_reached (); } } }else {/* size == 3 */ --
Quoted 1 line
2.14.3
Otherwise
thanks
-- PMM
Re: [Qemu-devel] [PATCH v2 06/11] target/arm: Decode aa32 armv8.1 two reg and a scalar
Quoted 18 lines · Peter Maydell
Quoted 16 lines · Richard Henderson
Signed-off-by Richard Henderson <[email protected]>--- target/arm/translate.c | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-)target/arm/translate.c +3
-0@@ -6973,11 +6973,43 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) }neon_store_reg64 (cpu_V0, rd + pass); } +break ; +case 14 :/* VQRDMLAH scalar */ +case 15 :/* VQRDMLSH scalar */
Quoted 8 lines
target/arm/translate.c static int disas_neon_data_insn(DisasContext *s, uint32_t insn) · line 6984
Quoted 6 lines
target/arm/translate.c +6
-0+if (!arm_dc_feature (s,ARM_FEATURE_V8_1_SIMD )) { +return 1 ; + } +if (u && ((rd | rn) &1 )) { +return 1 ; + }The pseudocode also has UNDEF if Q==1 && Vm<0> == 1 ....
Not for the indexed version, encoding A2.
Quoted 7 lines
target/arm/translate.c static int disas_neon_data_insn(DisasContext *s, uint32_t insn) · line 6988
Quoted 5 lines
target/arm/translate.c +4
-0+ tmp2 =neon_get_scalar (size, rm); +for (pass =0 ; pass < (u ?4 :2 ); pass++) { +void (*fn)(TCGv_i32 ,TCGv_env ,TCGv_i32 , +TCGv_i32 ,TCGv_i32 );Can we define a typedef for this, please ?
What would you name it?
r~
Re: [Qemu-arm] [PATCH v2 06/11] target/arm: Decode aa32 armv8.1 two reg and a scalar
Quoted 28 lines · Richard Henderson
Quoted 18 lines · Peter Maydell
Quoted 16 lines · Richard Henderson
Signed-off-by Richard Henderson <[email protected]>--- target/arm/translate.c | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-)target/arm/translate.c +3
-0@@ -6973,11 +6973,43 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) }neon_store_reg64 (cpu_V0, rd + pass); } +break ; +case 14 :/* VQRDMLAH scalar */ +case 15 :/* VQRDMLSH scalar */ Quoted 8 lines
target/arm/translate.c static int disas_neon_data_insn(DisasContext *s, uint32_t insn) · line 6984
Quoted 6 lines
target/arm/translate.c +6
-0+if (!arm_dc_feature (s,ARM_FEATURE_V8_1_SIMD )) { +return 1 ; + } +if (u && ((rd | rn) &1 )) { +return 1 ; + }The pseudocode also has UNDEF if Q==1 && Vm<0> == 1 ....
Quoted 1 line
Not for the indexed version, encoding A2.
Ah, yes.
Quoted 9 lines
Quoted 7 lines
target/arm/translate.c static int disas_neon_data_insn(DisasContext *s, uint32_t insn) · line 6988
Quoted 5 lines
target/arm/translate.c +4
-0+ tmp2 =neon_get_scalar (size, rm); +for (pass =0 ; pass < (u ?4 :2 ); pass++) { +void (*fn)(TCGv_i32 ,TCGv_env ,TCGv_i32 , +TCGv_i32 ,TCGv_i32 );Can we define a typedef for this, please ?
What would you name it?
NeonGenThreeOpEnvFn would fit the naming scheme we've got in translate-a64.c.
thanks
-- PMM
Re: [Qemu-arm] [PATCH v2 06/11] target/arm: Decode aa32 armv8.1 two reg and a scalar
In reply to Richard HendersonQuoted 1 line · Richard Henderson
Signed-off-by Richard Henderson <[email protected]>
Quoted 56 lines
--- target/arm/translate.c | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-)target/arm/translate.c +35
-3@@ -6973,11 +6973,43 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) }neon_store_reg64 (cpu_V0, rd + pass); } +break ; +case 14 :/* VQRDMLAH scalar */ +case 15 :/* VQRDMLSH scalar */ +if (!arm_dc_feature (s,ARM_FEATURE_V8_1_SIMD )) { +return 1 ; + } +if (u && ((rd | rn) &1 )) { +return 1 ; + } + tmp2 =neon_get_scalar (size, rm); +for (pass =0 ; pass < (u ?4 :2 ); pass++) { +void (*fn)(TCGv_i32 ,TCGv_env ,TCGv_i32 , +TCGv_i32 ,TCGv_i32 ); - + tmp =neon_load_reg (rn, pass); + tmp3 =neon_load_reg (rd, pass); +if (op ==14 ) { +if (size ==1 ) { + fn = gen_helper_neon_qrdmlah_s16; + }else { + fn = gen_helper_neon_qrdmlah_s32; + } + }else { +if (size ==1 ) { + fn = gen_helper_neon_qrdmlsh_s16; + }else { + fn = gen_helper_neon_qrdmlsh_s32; + } + } +fn (tmp, cpu_env, tmp, tmp2, tmp3); +tcg_temp_free_i32 (tmp3); +neon_store_reg (rd, pass, tmp); + } +tcg_temp_free_i32 (tmp2);break ; -default :/* 14 and 15 are RESERVED */ -return 1 ; +default : +g_assert_not_reached (); } } }else {/* size == 3 */
PATCH v2 7/11 target/arm: Add ARM_FEATURE_V8_FCMA
In reply to Richard HendersonEnable it for the "any" CPU used by *-linux-user.
--- target/arm/cpu.h | 1 + linux-user/elfload.c | 1 + target/arm/cpu.c | 1 + target/arm/cpu64.c | 1 + 4 files changed, 4 insertions(+)
target/arm/cpu.h +1 -0
@@ -1353,6 +1353,7 @@ enum arm_features {ARM_FEATURE_JAZELLE ,/* has (trivial) Jazelle implementation */ ARM_FEATURE_V8_1_SIMD ,/* has ARMv8.1-SIMD */ ARM_FEATURE_V8_FP16 ,/* implements v8.2 half-precision float */ + ARM_FEATURE_V8_FCMA, /* has complex number part of v8.3 extensions. */ };static inline int arm_feature (CPUARMState *env,int feature)
linux-user/elfload.c +1 -0
@@ -541,6 +541,7 @@ static uint32_t get_elf_hwcap(void)GET_FEATURE (ARM_FEATURE_V8_SHA256 ,ARM_HWCAP_A64_SHA2 );GET_FEATURE (ARM_FEATURE_CRC ,ARM_HWCAP_A64_CRC32 );GET_FEATURE (ARM_FEATURE_V8_1_SIMD ,ARM_HWCAP_A64_ASIMDRDM ); +GET_FEATURE (ARM_FEATURE_V8_FCMA ,ARM_HWCAP_A64_FCMA );#undef GET_FEATUREreturn hwcaps;
target/arm/cpu.c +1 -0
@@ -1629,6 +1629,7 @@ static void arm_any_initfn(Object *obj)set_feature (&cpu->env,ARM_FEATURE_V8_PMULL );set_feature (&cpu->env,ARM_FEATURE_CRC );set_feature (&cpu->env,ARM_FEATURE_V8_1_SIMD ); +set_feature (&cpu->env,ARM_FEATURE_V8_FCMA ); cpu->midr = 0xffffffff; }#endif
target/arm/cpu64.c +1 -0
@@ -228,6 +228,7 @@ static void aarch64_any_initfn(Object *obj)set_feature (&cpu->env,ARM_FEATURE_CRC );set_feature (&cpu->env,ARM_FEATURE_V8_1_SIMD );set_feature (&cpu->env,ARM_FEATURE_V8_FP16 ); +set_feature (&cpu->env,ARM_FEATURE_V8_FCMA ); cpu->ctr =0x80038003 ;/* 32 byte I and D cacheline size, VIPT icache */ cpu->dcz_blocksize =7 ;/* 512 bytes */ }
Signature · 1 line
2.14.3
Re: [Qemu-arm] [PATCH v2 07/11] target/arm: Add ARM_FEATURE_V8_FCMA
Quoted 16 lines · Richard Henderson
Enable it for the "any" CPU used by *-linux-user.
Reviewed-by Alex Bennée <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- target/arm/cpu.h | 1 + linux-user/elfload.c | 1 + target/arm/cpu.c | 1 + target/arm/cpu64.c | 1 + 4 files changed, 4 insertions(+)target/arm/cpu.h +0
-0
target/arm/cpu.h enum arm_features { · line 1356
Quoted 4 lines
target/arm/cpu.h +1
-0@@ -1353,6 +1353,7 @@ enum arm_features {ARM_FEATURE_JAZELLE ,/* has (trivial) Jazelle implementation */ ARM_FEATURE_V8_1_SIMD ,/* has ARMv8.1-SIMD */ ARM_FEATURE_V8_FP16 ,/* implements v8.2 half-precision float */ + ARM_FEATURE_V8_FCMA, /* has complex number part of v8.3 extensions. */
This is a bit inconsistent. If we're going with the architectural feature names this is "ARMv8.3-CompNum", so ARM_FEATURE_V8_3_COMPNUM. If we're going with the ID_AA64ISARn_EL1 field names then ARM_FEATURE_V8_1_SIMD should be ARM_FEATURE_V8_RDM...
target/arm/cpu.h enum arm_features { · line 1357
Quoted 1 line
target/arm/cpu.h +0
-0};
thanks
-- PMM
Re: [Qemu-devel] [PATCH v2 07/11] target/arm: Add ARM_FEATURE_V8_FCMA
Quoted 13 lines · Peter Maydell
Quoted 11 lines · Richard Henderson
Enable it for the "any" CPU used by *-linux-user.
Reviewed-by Alex Bennée <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- target/arm/cpu.h | 1 + linux-user/elfload.c | 1 + target/arm/cpu.c | 1 + target/arm/cpu64.c | 1 + 4 files changed, 4 insertions(+)
Quoted 14 lines
target/arm/cpu.h enum arm_features { · line 1356
Quoted 9 lines
target/arm/cpu.h +1
-0@@ -1353,6 +1353,7 @@ enum arm_features {ARM_FEATURE_JAZELLE ,/* has (trivial) Jazelle implementation */ ARM_FEATURE_V8_1_SIMD ,/* has ARMv8.1-SIMD */ ARM_FEATURE_V8_FP16 ,/* implements v8.2 half-precision float */ + ARM_FEATURE_V8_FCMA, /* has complex number part of v8.3 extensions. */This is a bit inconsistent. If we're going with the architectural feature names this is "ARMv8.3-CompNum", so
ARM_FEATURE_V8_3_COMPNUM. If we're going with theID_AA64ISARn_EL1field names thenARM_FEATURE_V8_1_SIMDshould beARM_FEATURE_V8_RDM...
You preferred ASIMDRDM earlier. Does this mean you prefer V8_RDM?
I hadn't noticed I was being inconsistent as to whence I drew my names. Gimme your preferred names and I'll use 'em.
r~
PATCH v2 8/11 target/arm: Decode aa64 armv8.3 fcadd
In reply to Richard Henderson--- target/arm/helper.h | 7 ++++ target/arm/advsimd_helper.c | 93 +++++++++++++++++++++++++++++++++++++++++++++ target/arm/translate-a64.c | 36 +++++++++++++++++- 3 files changed, 135 insertions(+), 1 deletion(-)
target/arm/helper.h +7 -0
@@ -567,6 +567,13 @@ DEF_HELPER_FLAGS_5(gvec_qrdmlah_s32, TCG_CALL_NO_RWG,DEF_HELPER_FLAGS_5 (gvec_qrdmlsh_s32,TCG_CALL_NO_RWG , void, ptr, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_5 (gvec_fcaddh,TCG_CALL_NO_RWG , + void, ptr, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_5 (gvec_fcadds,TCG_CALL_NO_RWG , + void, ptr, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_5 (gvec_fcaddd,TCG_CALL_NO_RWG , + void, ptr, ptr, ptr, ptr, i32) +#ifdef TARGET_AARCH64 #include "helper-a64.h" #endif
target/arm/advsimd_helper.c +93 -0
102 lines not on this page · raw message
target/arm/translate-a64.c +35 -1
@@ -10696,7 +10696,8 @@ static void disas_simd_three_reg_same_extra(DisasContext *s, uint32_t insn)int size =extract32 (insn,22 ,2 );bool u =extract32 (insn,29 ,1 );bool is_q =extract32 (insn,30 ,1 ); -int feature; +int feature, data; +TCGv_ptr fpst;if (!u) {unallocated_encoding (s);
@@ -10712,6 +10713,14 @@ static void disas_simd_three_reg_same_extra(DisasContext *s, uint32_t insn) } feature =ARM_FEATURE_V8_1_SIMD ;break ; +case 0xc :/* FCADD, #90 */ +case 0xe :/* FCADD, #270 */ +if (size ==0 || (size ==3 && !is_q)) { +unallocated_encoding (s); +return ; + } + feature =ARM_FEATURE_V8_FCMA ; +break ;default :unallocated_encoding (s);return ;
@@ -10758,6 +10767,31 @@ static void disas_simd_three_reg_same_extra(DisasContext *s, uint32_t insn) 0, fn_gvec_ptr);break ; +case 0xc :/* FCADD, #90 */ +case 0xe :/* FCADD, #270 */ +switch (size) { +case 1 : + fn_gvec_ptr = gen_helper_gvec_fcaddh; +break ; +case 2 : + fn_gvec_ptr = gen_helper_gvec_fcadds; +break ; +case 3 : + fn_gvec_ptr = gen_helper_gvec_fcaddd; +break ; +default : +g_assert_not_reached (); + } + data =extract32 (opcode,1 ,1 ); + fpst =get_fpstatus_ptr (size ==1 ); +tcg_gen_gvec_3_ptr (vec_full_reg_offset (s, rd), +vec_full_reg_offset (s, rn), +vec_full_reg_offset (s, rm), fpst, + is_q ?16 :8 ,vec_full_reg_size (s), + data, fn_gvec_ptr); +tcg_temp_free_ptr (fpst); +break ; +default :g_assert_not_reached (); }
Signature · 1 line
2.14.3
Re: [Qemu-arm] [PATCH v2 08/11] target/arm: Decode aa64 armv8.3 fcadd
Quoted 58 lines · Richard Henderson
Reviewed-by Alex Bennée <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- target/arm/helper.h | 7 ++++ target/arm/advsimd_helper.c | 93 +++++++++++++++++++++++++++++++++++++++++++++ target/arm/translate-a64.c | 36 +++++++++++++++++- 3 files changed, 135 insertions(+), 1 deletion(-)target/arm/helper.h +7
-0@@ -567,6 +567,13 @@ DEF_HELPER_FLAGS_5(gvec_qrdmlah_s32, TCG_CALL_NO_RWG,DEF_HELPER_FLAGS_5 (gvec_qrdmlsh_s32,TCG_CALL_NO_RWG , void, ptr, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_5 (gvec_fcaddh,TCG_CALL_NO_RWG , + void, ptr, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_5 (gvec_fcadds,TCG_CALL_NO_RWG , + void, ptr, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_5 (gvec_fcaddd,TCG_CALL_NO_RWG , + void, ptr, ptr, ptr, ptr, i32) +#ifdef TARGET_AARCH64 #include "helper-a64.h" #endif target/arm/advsimd_helper.c +17
-0@@ -24,6 +24,18 @@#include "tcg/tcg-gvec-desc.h" +/* Note that vector data is stored in host-endian 64-bit chunks, +so addressing units smaller than that needs a host-endian fixup. */ +#ifdef HOST_WORDS_BIGENDIAN +#define H1 (x) ((x) ^ 7) +#define H2 (x) ((x) ^ 3) +#define H4 (x) ((x) ^ 1) +#else +#define H1 (x) (x) +#define H2 (x) (x) +#define H4 (x) (x) +#endif +#define SET_QC () env->vfp.xregs[ARM_VFP_FPSCR] |= CPSR_Qstatic void clear_tail (void *vd,uintptr_t opr_sz,uintptr_t max_sz)@@ -181,3 +193,84 @@ void HELPER(gvec_qrdmlsh_s32)(void *vd, void *vn, void *vm, }clear_tail (d, opr_sz,simd_maxsz (desc)); } + +void HELPER (gvec_fcaddh )(void *vd,void *vn,void *vm, +void *vfpst,uint32_t desc) +{ +uintptr_t opr_sz =simd_oprsz (desc);
target/arm/advsimd_helper.c void HELPER(gvec_qrdmlsh_s32)(void *vd, void *vn, void *vm, · line 210
Quoted 10 lines
target/arm/advsimd_helper.c +10
-0+float16 *d = vd; +float16 *n = vn; +float16 *m = vm; +float_status *fpst = vfpst; +uint32_t neg_real =extract32 (desc,SIMD_DATA_SHIFT ,1 ); +uint32_t neg_imag = neg_real ^1 ; +uintptr_t i; + + neg_real <<=15 ; + neg_imag <<=15 ;
This took me a little while to figure out, given that it's somewhat different from the pseudocode. (I think I was also thrown by the <<= 15 being done on its own line rather than in the assignment.) A comment might help?
Quoted 81 lines
target/arm/advsimd_helper.c +66
-0+ +for (i =0 ; i < opr_sz /2 ; i +=2 ) { +float16 e0 = n[H2 (i)]; +float16 e1 = m[H2 (i +1 )] ^ neg_imag; +float16 e2 = n[H2 (i +1 )]; +float16 e3 = m[H2 (i)] ^ neg_real; + + d[H2 (i)] =float16_add (e0, e1, fpst); + d[H2 (i +1 )] =float16_add (e2, e3, fpst); + } +clear_tail (d, opr_sz,simd_maxsz (desc)); +} + +void HELPER (gvec_fcadds )(void *vd,void *vn,void *vm, +void *vfpst,uint32_t desc) +{ +uintptr_t opr_sz =simd_oprsz (desc); +float32 *d = vd; +float32 *n = vn; +float32 *m = vm; +float_status *fpst = vfpst; +uint32_t neg_real =extract32 (desc,SIMD_DATA_SHIFT ,1 ); +uint32_t neg_imag = neg_real ^1 ; +uintptr_t i; + + neg_real <<=31 ; + neg_imag <<=31 ; + +for (i =0 ; i < opr_sz /4 ; i +=2 ) { +float32 e0 = n[H4 (i)]; +float32 e1 = m[H4 (i +1 )] ^ neg_imag; +float32 e2 = n[H4 (i +1 )]; +float32 e3 = m[H4 (i)] ^ neg_real; + + d[H4 (i)] =float32_add (e0, e1, fpst); + d[H4 (i +1 )] =float32_add (e2, e3, fpst); + } +clear_tail (d, opr_sz,simd_maxsz (desc)); +} + +void HELPER (gvec_fcaddd )(void *vd,void *vn,void *vm, +void *vfpst,uint32_t desc) +{ +uintptr_t opr_sz =simd_oprsz (desc); +float64 *d = vd; +float64 *n = vn; +float64 *m = vm; +float_status *fpst = vfpst; +uint64_t neg_real =extract64 (desc,SIMD_DATA_SHIFT ,1 ); +uint64_t neg_imag = neg_real ^1 ; +uintptr_t i; + + neg_real <<=63 ; + neg_imag <<=63 ; + +for (i =0 ; i < opr_sz /8 ; i +=2 ) { +float64 e0 = n[i]; +float64 e1 = m[i +1 ] ^ neg_imag; +float64 e2 = n[i +1 ]; +float64 e3 = m[i] ^ neg_real; + + d[i] =float64_add (e0, e1, fpst); + d[i +1 ] =float64_add (e2, e3, fpst); + } +clear_tail (d, opr_sz,simd_maxsz (desc)); +}target/arm/translate-a64.c +2
-1@@ -10696,7 +10696,8 @@ static void disas_simd_three_reg_same_extra(DisasContext *s, uint32_t insn)int size =extract32 (insn,22 ,2 );bool u =extract32 (insn,29 ,1 );bool is_q =extract32 (insn,30 ,1 ); -int feature; +int feature, data; +TCGv_ptr fpst;if (!u) {unallocated_encoding (s);
target/arm/translate-a64.c static void disas_simd_three_reg_same_extra(DisasContext *s, uint32_t insn) · line 10721
Quoted 9 lines
target/arm/translate-a64.c +6
-0@@ -10712,6 +10713,14 @@ static void disas_simd_three_reg_same_extra(DisasContext *s, uint32_t insn) } feature =ARM_FEATURE_V8_1_SIMD ;break ; +case 0xc :/* FCADD, #90 */ +case 0xe :/* FCADD, #270 */ +if (size ==0 || (size ==3 && !is_q)) { +unallocated_encoding (s); +return ; + }
The pseudocode says you need to also check whether the FP16 extension is supported, or else UNDEF on size == 1.
Quoted 15 lines
target/arm/translate-a64.c +8
-0+ feature =ARM_FEATURE_V8_FCMA ; +break ;default :unallocated_encoding (s);return ;@@ -10758,6 +10767,31 @@ static void disas_simd_three_reg_same_extra(DisasContext *s, uint32_t insn) 0, fn_gvec_ptr);break ; +case 0xc :/* FCADD, #90 */ +case 0xe :/* FCADD, #270 */ +switch (size) { +case 1 : + fn_gvec_ptr = gen_helper_gvec_fcaddh; +break ;
target/arm/translate-a64.c static void disas_simd_three_reg_same_extra(DisasContext *s, uint32_t insn) · line 10785
Quoted 10 lines
target/arm/translate-a64.c +10
-0+case 2 : + fn_gvec_ptr = gen_helper_gvec_fcadds; +break ; +case 3 : + fn_gvec_ptr = gen_helper_gvec_fcaddd; +break ; +default : +g_assert_not_reached (); + } + data =extract32 (opcode,1 ,1 );
The pseudocode calls this field "rot", which is a bit more descriptive than "data".
Quoted 13 lines
target/arm/translate-a64.c +9
-1+ fpst =get_fpstatus_ptr (size ==1 ); +tcg_gen_gvec_3_ptr (vec_full_reg_offset (s, rd), +vec_full_reg_offset (s, rn), +vec_full_reg_offset (s, rm), fpst, + is_q ?16 :8 ,vec_full_reg_size (s), + data, fn_gvec_ptr); +tcg_temp_free_ptr (fpst); +break ; +default :g_assert_not_reached (); } --
Quoted 1 line
2.14.3
Otherwise I think this looks OK.
thanks
-- PMM
PATCH v2 9/11 target/arm: Decode aa64 armv8.3 fcmla
In reply to Richard Henderson--- target/arm/helper.h | 11 ++++ target/arm/advsimd_helper.c | 144 ++++++++++++++++++++++++++++++++++++++++++ target/arm/translate-a64.c | 149 ++++++++++++++++++++++++++++++++------------ 3 files changed, 265 insertions(+), 39 deletions(-)
target/arm/helper.h +11 -0
@@ -574,6 +574,17 @@ DEF_HELPER_FLAGS_5(gvec_fcadds, TCG_CALL_NO_RWG,DEF_HELPER_FLAGS_5 (gvec_fcaddd,TCG_CALL_NO_RWG , void, ptr, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_5 (gvec_fcmlah,TCG_CALL_NO_RWG , + void, ptr, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_5 (gvec_fcmlah_idx,TCG_CALL_NO_RWG , + void, ptr, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_5 (gvec_fcmlas,TCG_CALL_NO_RWG , + void, ptr, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_5 (gvec_fcmlas_idx,TCG_CALL_NO_RWG , + void, ptr, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_5 (gvec_fcmlad,TCG_CALL_NO_RWG , + void, ptr, ptr, ptr, ptr, i32) +#ifdef TARGET_AARCH64 #include "helper-a64.h" #endif
target/arm/advsimd_helper.c +144 -0
147 lines not on this page · raw message
target/arm/translate-a64.c +110 -39
226 lines not on this page · raw message
Signature · 1 line
2.14.3
Re: [Qemu-devel] [PATCH v2 09/11] target/arm: Decode aa64 armv8.3 fcmla
Quoted 49 lines · Richard Henderson
Signed-off-by Richard Henderson <[email protected]>--- target/arm/helper.h | 11 ++++ target/arm/advsimd_helper.c | 144 ++++++++++++++++++++++++++++++++++++++++++ target/arm/translate-a64.c | 149 ++++++++++++++++++++++++++++++++------------ 3 files changed, 265 insertions(+), 39 deletions(-)target/arm/helper.h +11
-0@@ -574,6 +574,17 @@ DEF_HELPER_FLAGS_5(gvec_fcadds, TCG_CALL_NO_RWG,DEF_HELPER_FLAGS_5 (gvec_fcaddd,TCG_CALL_NO_RWG , void, ptr, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_5 (gvec_fcmlah,TCG_CALL_NO_RWG , + void, ptr, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_5 (gvec_fcmlah_idx,TCG_CALL_NO_RWG , + void, ptr, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_5 (gvec_fcmlas,TCG_CALL_NO_RWG , + void, ptr, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_5 (gvec_fcmlas_idx,TCG_CALL_NO_RWG , + void, ptr, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_5 (gvec_fcmlad,TCG_CALL_NO_RWG , + void, ptr, ptr, ptr, ptr, i32) +#ifdef TARGET_AARCH64 #include "helper-a64.h" #endif target/arm/advsimd_helper.c +12
-0@@ -274,3 +274,147 @@ void HELPER(gvec_fcaddd)(void *vd, void *vn, void *vm, }clear_tail (d, opr_sz,simd_maxsz (desc)); } + +void HELPER (gvec_fcmlah )(void *vd,void *vn,void *vm, +void *vfpst,uint32_t desc) +{ +uintptr_t opr_sz =simd_oprsz (desc); +float16 *d = vd; +float16 *n = vn; +float16 *m = vm; +float_status *fpst = vfpst; +intptr_t flip =extract32 (desc,SIMD_DATA_SHIFT ,1 ); +uint32_t neg_imag =extract32 (desc,SIMD_DATA_SHIFT +1 ,1 ); +uint32_t neg_real = flip ^ neg_imag;
target/arm/advsimd_helper.c void HELPER(gvec_fcaddd)(void *vd, void *vn, void *vm, · line 298
Quoted 10 lines
target/arm/advsimd_helper.c +10
-0+uintptr_t i; + + neg_real <<=15 ; + neg_imag <<=15 ; + +for (i =0 ; i < opr_sz /2 ; i +=2 ) { +float16 e0 = n[H2 (i + flip)]; +float16 e1 = m[H2 (i + flip)] ^ neg_real; +float16 e2 = e0; +float16 e3 = m[H2 (i +1 - flip)] ^ neg_imag;
This is again rather confusing to compare against the pseudocode. What order are your e0/e1/e2/e3 compared to the pseudocode's element1/element2/element3/element4 ?
Quoted 150 lines
target/arm/advsimd_helper.c +122
-0+ + d[H2 (i)] =float16_muladd (e0, e1, d[H2 (i)],0 , fpst); + d[H2 (i +1 )] =float16_muladd (e2, e3, d[H2 (i +1 )],0 , fpst); + } +clear_tail (d, opr_sz,simd_maxsz (desc)); +} + +void HELPER (gvec_fcmlah_idx )(void *vd,void *vn,void *vm, +void *vfpst,uint32_t desc) +{ +uintptr_t opr_sz =simd_oprsz (desc); +float16 *d = vd; +float16 *n = vn; +float16 *m = vm; +float_status *fpst = vfpst; +intptr_t flip =extract32 (desc,SIMD_DATA_SHIFT ,1 ); +uint32_t neg_imag =extract32 (desc,SIMD_DATA_SHIFT +1 ,1 ); +uint32_t neg_real = flip ^ neg_imag; +uintptr_t i; +float16 e1 = m[H2 (flip)]; +float16 e3 = m[H2 (1 - flip)]; + + neg_real <<=15 ; + neg_imag <<=15 ; + e1 ^= neg_real; + e3 ^= neg_imag; + +for (i =0 ; i < opr_sz /2 ; i +=2 ) { +float16 e0 = n[H2 (i + flip)]; +float16 e2 = e0; + + d[H2 (i)] =float16_muladd (e0, e1, d[H2 (i)],0 , fpst); + d[H2 (i +1 )] =float16_muladd (e2, e3, d[H2 (i +1 )],0 , fpst); + } +clear_tail (d, opr_sz,simd_maxsz (desc)); +} + +void HELPER (gvec_fcmlas )(void *vd,void *vn,void *vm, +void *vfpst,uint32_t desc) +{ +uintptr_t opr_sz =simd_oprsz (desc); +float32 *d = vd; +float32 *n = vn; +float32 *m = vm; +float_status *fpst = vfpst; +intptr_t flip =extract32 (desc,SIMD_DATA_SHIFT ,1 ); +uint32_t neg_imag =extract32 (desc,SIMD_DATA_SHIFT +1 ,1 ); +uint32_t neg_real = flip ^ neg_imag; +uintptr_t i; + + neg_real <<=31 ; + neg_imag <<=31 ; + +for (i =0 ; i < opr_sz /4 ; i +=2 ) { +float32 e0 = n[H4 (i + flip)]; +float32 e1 = m[H4 (i + flip)] ^ neg_real; +float32 e2 = e0; +float32 e3 = m[H4 (i +1 - flip)] ^ neg_imag; + + d[H4 (i)] =float32_muladd (e0, e1, d[H4 (i)],0 , fpst); + d[H4 (i +1 )] =float32_muladd (e2, e3, d[H4 (i +1 )],0 , fpst); + } +clear_tail (d, opr_sz,simd_maxsz (desc)); +} + +void HELPER (gvec_fcmlas_idx )(void *vd,void *vn,void *vm, +void *vfpst,uint32_t desc) +{ +uintptr_t opr_sz =simd_oprsz (desc); +float32 *d = vd; +float32 *n = vn; +float32 *m = vm; +float_status *fpst = vfpst; +intptr_t flip =extract32 (desc,SIMD_DATA_SHIFT ,1 ); +uint32_t neg_imag =extract32 (desc,SIMD_DATA_SHIFT +1 ,1 ); +uint32_t neg_real = flip ^ neg_imag; +uintptr_t i; +float32 e1 = m[H4 (flip)]; +float32 e3 = m[H4 (1 - flip)]; + + neg_real <<=31 ; + neg_imag <<=31 ; + e1 ^= neg_real; + e3 ^= neg_imag; + +for (i =0 ; i < opr_sz /4 ; i +=2 ) { +float32 e0 = n[H4 (i + flip)]; +float32 e2 = e0; + + d[H4 (i)] =float32_muladd (e0, e1, d[H4 (i)],0 , fpst); + d[H4 (i +1 )] =float32_muladd (e2, e3, d[H4 (i +1 )],0 , fpst); + } +clear_tail (d, opr_sz,simd_maxsz (desc)); +} + +void HELPER (gvec_fcmlad )(void *vd,void *vn,void *vm, +void *vfpst,uint32_t desc) +{ +uintptr_t opr_sz =simd_oprsz (desc); +float64 *d = vd; +float64 *n = vn; +float64 *m = vm; +float_status *fpst = vfpst; +intptr_t flip =extract32 (desc,SIMD_DATA_SHIFT ,1 ); +uint64_t neg_imag =extract32 (desc,SIMD_DATA_SHIFT +1 ,1 ); +uint64_t neg_real = flip ^ neg_imag; +uintptr_t i; + + neg_real <<=63 ; + neg_imag <<=63 ; + +for (i =0 ; i < opr_sz /8 ; i +=2 ) { +float64 e0 = n[i + flip]; +float64 e1 = m[i + flip] ^ neg_real; +float64 e2 = e0; +float64 e3 = m[i +1 - flip] ^ neg_imag; + + d[i] =float64_muladd (e0, e1, d[i],0 , fpst); + d[i +1 ] =float64_muladd (e2, e3, d[i +1 ],0 , fpst); + } +clear_tail (d, opr_sz,simd_maxsz (desc)); +}target/arm/translate-a64.c +13
-0@@ -10713,6 +10713,10 @@ static void disas_simd_three_reg_same_extra(DisasContext *s, uint32_t insn) } feature =ARM_FEATURE_V8_1_SIMD ;break ; +case 0x8 :/* FCMLA, #0 */ +case 0x9 :/* FCMLA, #90 */ +case 0xa :/* FCMLA, #180 */ +case 0xb :/* FCMLA, #270 */ case 0xc :/* FCADD, #90 */ case 0xe :/* FCADD, #270 */ if (size ==0 || (size ==3 && !is_q)) {@@ -10767,6 +10771,26 @@ static void disas_simd_three_reg_same_extra(DisasContext *s, uint32_t insn) 0, fn_gvec_ptr);break ; +case 0x8 :/* FCMLA, #0 */ +case 0x9 :/* FCMLA, #90 */ +case 0xa :/* FCMLA, #180 */ +case 0xb :/* FCMLA, #270 */ +switch (size) { +case 1 : + fn_gvec_ptr = gen_helper_gvec_fcmlah; +break ; +case 2 :
target/arm/translate-a64.c static void disas_simd_three_reg_same_extra(DisasContext *s, uint32_t insn) · line 10792
Quoted 10 lines
target/arm/translate-a64.c +10
-0+ fn_gvec_ptr = gen_helper_gvec_fcmlas; +break ; +case 3 : + fn_gvec_ptr = gen_helper_gvec_fcmlad; +break ; +default : +g_assert_not_reached (); + } + data =extract32 (opcode,0 ,2 ); + goto do_fpst;
These need the "size 0b01 is UNDEF unless FP16 extn present" check too.
Quoted 24 lines
target/arm/translate-a64.c +4
-3+case 0xc :/* FCADD, #90 */ case 0xe :/* FCADD, #270 */ switch (size) {@@ -10783,6 +10807,7 @@ static void disas_simd_three_reg_same_extra(DisasContext *s, uint32_t insn)g_assert_not_reached (); } data =extract32 (opcode,1 ,1 ); + do_fpst: fpst =get_fpstatus_ptr (size ==1 ); tcg_gen_gvec_3_ptr(vec_full_reg_offset(s, rd), vec_full_reg_offset(s, rn),@@ -11864,80 +11889,80 @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn)int rn =extract32 (insn,5 ,5 );int rd =extract32 (insn,0 ,5 );bool is_long = false; -bool is_fp = false; +int is_fp =0 ; +bool is_fp16 = false;int index;TCGv_ptr fpst; -switch (opcode) { -case 0x0 :/* MLA */
target/arm/translate-a64.c static void disas_simd_indexed(DisasContext *s, uint32_t insn) · line 11904
Quoted 10 lines
target/arm/translate-a64.c +5
-2-case 0x4 :/* MLS */ -if (!u || is_scalar) { +switch (16 * u + opcode) { +case 0x00 :/* MLA */ +case 0x04 :/* MLS */ +case 0x08 :/* MUL */ +if (is_scalar) {unallocated_encoding (s);return ; }
This would all be easier to read if "refactor to switch on u:opcode" was a separate patch from adding the new insns.
thanks
-- PMM
Re: [Qemu-devel] [PATCH v2 09/11] target/arm: Decode aa64 armv8.3 fcmla
Quoted 17 lines · Peter Maydell
Quoted 17 lines
target/arm/advsimd_helper.c +17
-0+void HELPER (gvec_fcmlah )(void *vd,void *vn,void *vm, +void *vfpst,uint32_t desc) +{ +uintptr_t opr_sz =simd_oprsz (desc); +float16 *d = vd; +float16 *n = vn; +float16 *m = vm; +float_status *fpst = vfpst; +intptr_t flip =extract32 (desc,SIMD_DATA_SHIFT ,1 ); +uint32_t neg_imag =extract32 (desc,SIMD_DATA_SHIFT +1 ,1 ); +uint32_t neg_real = flip ^ neg_imag; +uintptr_t i; + + neg_real <<=15 ; + neg_imag <<=15 ; + +for (i =0 ; i < opr_sz /2 ; i +=2 ) {
Quoted 8 lines
target/arm/advsimd_helper.c void HELPER(gvec_fcaddd)(void *vd, void *vn, void *vm, · line 298
Quoted 4 lines
target/arm/advsimd_helper.c +4
-0+float16 e0 = n[H2 (i + flip)]; +float16 e1 = m[H2 (i + flip)] ^ neg_real; +float16 e2 = e0; +float16 e3 = m[H2 (i +1 - flip)] ^ neg_imag;This is again rather confusing to compare against the pseudocode. What order are your e0/e1/e2/e3 compared to the pseudocode's element1/element2/element3/element4 ?
The SVE pseudocode for the same operation is clearer than that in the main ARM ARM, and is nearer to what I used:
for e = 0 to elements-1
if ElemP[mask, e, esize] == '1' then
pair = e - (e MOD 2); // index of first element in pair
addend = Elem[result, e, esize];
if IsEven(e) then // real part
// realD = realA [+-] flip ? (imagN * imagM) : (realN * realM)
element1 = Elem[operand1, pair + flip, esize];
element2 = Elem[operand2, pair + flip, esize];
if neg_real then element2 = FPNeg(element2);
else // imaginary part
// imagD = imagA [+-] flip ? (imagN * realM) : (realN * imagM)
element1 = Elem[operand1, pair + flip, esize];
element2 = Elem[operand2, pair + (1 - flip), esize];
if neg_imag then element2 = FPNeg(element2);
Elem[result, e, esize] = FPMulAdd(addend, element1, element2, FPCR);In my version, e0/e1 are element1/element2 (real) and e2/e3 are element1/element2 (imag).
r~
Re: [Qemu-arm] [PATCH v2 09/11] target/arm: Decode aa64 armv8.3 fcmla
Quoted 46 lines · Richard Henderson
Quoted 17 lines · Peter Maydell
Quoted 17 lines
target/arm/advsimd_helper.c +17
-0+void HELPER (gvec_fcmlah )(void *vd,void *vn,void *vm, +void *vfpst,uint32_t desc) +{ +uintptr_t opr_sz =simd_oprsz (desc); +float16 *d = vd; +float16 *n = vn; +float16 *m = vm; +float_status *fpst = vfpst; +intptr_t flip =extract32 (desc,SIMD_DATA_SHIFT ,1 ); +uint32_t neg_imag =extract32 (desc,SIMD_DATA_SHIFT +1 ,1 ); +uint32_t neg_real = flip ^ neg_imag; +uintptr_t i; + + neg_real <<=15 ; + neg_imag <<=15 ; + +for (i =0 ; i < opr_sz /2 ; i +=2 ) {Quoted 8 lines
target/arm/advsimd_helper.c void HELPER(gvec_fcaddd)(void *vd, void *vn, void *vm, · line 298
Quoted 4 lines
target/arm/advsimd_helper.c +4
-0+float16 e0 = n[H2 (i + flip)]; +float16 e1 = m[H2 (i + flip)] ^ neg_real; +float16 e2 = e0; +float16 e3 = m[H2 (i +1 - flip)] ^ neg_imag;This is again rather confusing to compare against the pseudocode. What order are your e0/e1/e2/e3 compared to the pseudocode's element1/element2/element3/element4 ?
The SVE pseudocode for the same operation is clearer than that in the main ARM ARM, and is nearer to what I used:
for e = 0 to elements-1 if ElemP[mask, e, esize] == '1' then pair = e - (e MOD 2); // index of first element in pair addend = Elem[result, e, esize]; if IsEven(e) then // real part // realD = realA [+-] flip ? (imagN * imagM) : (realN * realM) element1 = Elem[operand1, pair + flip, esize]; element2 = Elem[operand2, pair + flip, esize]; if neg_real then element2 = FPNeg(element2); else // imaginary part // imagD = imagA [+-] flip ? (imagN * realM) : (realN * imagM) element1 = Elem[operand1, pair + flip, esize]; element2 = Elem[operand2, pair + (1 - flip), esize]; if neg_imag then element2 = FPNeg(element2); Elem[result, e, esize] = FPMulAdd(addend, element1, element2, FPCR);
Quoted 2 lines
In my version, e0/e1 are element1/element2 (real) and e2/e3 are element1/element2 (imag).
Thanks. Could we use the same indexing (1/2/3/4) as the final Arm ARM pseudocode?
thanks
-- PMM
Re: [Qemu-arm] [PATCH v2 09/11] target/arm: Decode aa64 armv8.3 fcmla
Quoted 19 lines · Peter Maydell
Quoted 19 lines
The SVE pseudocode for the same operation is clearer than that in the main ARM ARM, and is nearer to what I used:
for e = 0 to elements-1 if ElemP[mask, e, esize] == '1' then pair = e - (e MOD 2); // index of first element in pair addend = Elem[result, e, esize]; if IsEven(e) then // real part // realD = realA [+-] flip ? (imagN * imagM) : (realN * realM) element1 = Elem[operand1, pair + flip, esize]; element2 = Elem[operand2, pair + flip, esize]; if neg_real then element2 = FPNeg(element2); else // imaginary part // imagD = imagA [+-] flip ? (imagN * realM) : (realN * imagM) element1 = Elem[operand1, pair + flip, esize]; element2 = Elem[operand2, pair + (1 - flip), esize]; if neg_imag then element2 = FPNeg(element2); Elem[result, e, esize] = FPMulAdd(addend, element1, element2, FPCR);
Quoted 5 lines
Quoted 2 lines
In my version, e0/e1 are element1/element2 (real) and e2/e3 are element1/element2 (imag).
Thanks. Could we use the same indexing (1/2/3/4) as the final Arm ARM pseudocode?
Done.
r~
PATCH v2 10/11 target/arm: Decode aa32 armv8.3 3-same
In reply to Richard Henderson--- target/arm/translate.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+)
target/arm/translate.c +65 -0
@@ -7662,6 +7662,65 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)return 0 ; } +/* ARMv8.3 reclaims a portion of the LDC2/STC2 coprocessor 8 space. */ + +static int disas_neon_insn_cp8_3same (DisasContext *s,uint32_t insn) +{ +void (*fn_gvec_ptr)(TCGv_ptr ,TCGv_ptr ,TCGv_ptr ,TCGv_ptr ,TCGv_i32 ); +int rd, rn, rm, rot, size, opr_sz; +TCGv_ptr fpst; +bool q; + +/* FIXME: this access check should not take precedence over UNDEF +* for invalid encodings; we will generate incorrect syndrome information +* for attempts to execute invalid vfp/neon encodings with FP disabled. +*/ +if (s->fp_excp_el) { +gen_exception_insn (s,4 ,EXCP_UDEF , +syn_fp_access_trap (1 ,0xe , false), s->fp_excp_el); +return 0 ; + } +if (!s->vfp_enabled) { +return 1 ; + } +if (!arm_dc_feature (s,ARM_FEATURE_V8_FCMA )) { +return 1 ; + } + + q =extract32 (insn,6 ,1 ); + size =extract32 (insn,20 ,1 ); +VFP_DREG_D (rd, insn); +VFP_DREG_N (rn, insn); +VFP_DREG_M (rm, insn); +if ((rd | rn | rm) & q) { +return 1 ; + } + +if (extract32 (insn,21 ,1 )) { +/* VCMLA */ + rot =extract32 (insn,23 ,2 ); + fn_gvec_ptr = size ? gen_helper_gvec_fcmlas : gen_helper_gvec_fcmlah; + }else if (extract32 (insn,23 ,1 )) { +/* VCADD */ + rot =extract32 (insn,24 ,1 ); + fn_gvec_ptr = size ? gen_helper_gvec_fcadds : gen_helper_gvec_fcaddh; + }else { +/* Assuming the register fields remain, only bit 24 remains undecoded: +* 1111_110x_0d0s_nnnn_dddd_1000_nqm0_mmmm +*/ +return 1 ; + } + + opr_sz = (1 + q) *8 ; + fpst =get_fpstatus_ptr (1 ); +tcg_gen_gvec_3_ptr (vfp_reg_offset (1 , rd), +vfp_reg_offset (1 , rn), +vfp_reg_offset (1 , rm), fpst, + opr_sz, opr_sz, rot, fn_gvec_ptr); +tcg_temp_free_ptr (fpst); +return 0 ; +} +static int disas_coproc_insn (DisasContext *s,uint32_t insn) {int cpnum, is64, crn, crm, opc1, opc2, isread, rt, rt2;
@@ -8406,6 +8465,12 @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) } } } + }else if ((insn &0x0e000f10 ) ==0x0c000800 ) { +/* ARMv8.3 neon ldc2/stc2 coprocessor 8 extension. */ +if (disas_neon_insn_cp8_3same (s, insn)) { + goto illegal_op; + } +return ; }else if ((insn &0x0fe00000 ) ==0x0c400000 ) {/* Coprocessor double register transfer. */ ARCH(5TE);
Signature · 1 line
2.14.3
Re: [Qemu-arm] [PATCH v2 10/11] target/arm: Decode aa32 armv8.3 3-same
Quoted 76 lines · Richard Henderson
Signed-off-by Richard Henderson <[email protected]>--- target/arm/translate.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+)target/arm/translate.c +59
-0@@ -7662,6 +7662,65 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)return 0 ; } +/* ARMv8.3 reclaims a portion of the LDC2/STC2 coprocessor 8 space. */ + +static int disas_neon_insn_cp8_3same (DisasContext *s,uint32_t insn) +{ +void (*fn_gvec_ptr)(TCGv_ptr ,TCGv_ptr ,TCGv_ptr ,TCGv_ptr ,TCGv_i32 ); +int rd, rn, rm, rot, size, opr_sz; +TCGv_ptr fpst; +bool q; + +/* FIXME: this access check should not take precedence over UNDEF +* for invalid encodings; we will generate incorrect syndrome information +* for attempts to execute invalid vfp/neon encodings with FP disabled. +*/ +if (s->fp_excp_el) { +gen_exception_insn (s,4 ,EXCP_UDEF , +syn_fp_access_trap (1 ,0xe , false), s->fp_excp_el); +return 0 ; + } +if (!s->vfp_enabled) { +return 1 ; + } +if (!arm_dc_feature (s,ARM_FEATURE_V8_FCMA )) { +return 1 ; + } + + q =extract32 (insn,6 ,1 ); + size =extract32 (insn,20 ,1 ); +VFP_DREG_D (rd, insn); +VFP_DREG_N (rn, insn); +VFP_DREG_M (rm, insn); +if ((rd | rn | rm) & q) { +return 1 ; + } + +if (extract32 (insn,21 ,1 )) { +/* VCMLA */ + rot =extract32 (insn,23 ,2 ); + fn_gvec_ptr = size ? gen_helper_gvec_fcmlas : gen_helper_gvec_fcmlah; + }else if (extract32 (insn,23 ,1 )) { +/* VCADD */ + rot =extract32 (insn,24 ,1 ); + fn_gvec_ptr = size ? gen_helper_gvec_fcadds : gen_helper_gvec_fcaddh; + }else { +/* Assuming the register fields remain, only bit 24 remains undecoded: +* 1111_110x_0d0s_nnnn_dddd_1000_nqm0_mmmm +*/ +return 1 ; + } + + opr_sz = (1 + q) *8 ; + fpst =get_fpstatus_ptr (1 ); +tcg_gen_gvec_3_ptr (vfp_reg_offset (1 , rd), +vfp_reg_offset (1 , rn), +vfp_reg_offset (1 , rm), fpst, + opr_sz, opr_sz, rot, fn_gvec_ptr); +tcg_temp_free_ptr (fpst); +return 0 ; +} +static int disas_coproc_insn (DisasContext *s,uint32_t insn) {int cpnum, is64, crn, crm, opc1, opc2, isread, rt, rt2;
target/arm/translate.c static void disas_arm_insn(DisasContext *s, unsigned int insn) · line 8468
Quoted 4 lines
target/arm/translate.c +1
-0@@ -8406,6 +8465,12 @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) } } } + }else if ((insn &0x0e000f10 ) ==0x0c000800 ) {
I think we should guard this with an ARM_FEATURE_V8 check, so that for pre-v8 CPUs we fall back to the usual "treat it as a coprocessor" codepath. (In theory it should work out the same either way, but specifically limiting this to v8 makes it easier to be sure that it's not changing the behaviour where it shouldn't.)
target/arm/translate.c static void disas_arm_insn(DisasContext *s, unsigned int insn) · line 8472
Quoted 4 lines
target/arm/translate.c +4
-0+/* ARMv8.3 neon ldc2/stc2 coprocessor 8 extension. */ +if (disas_neon_insn_cp8_3same (s, insn)) { + goto illegal_op; + }
This doesn't seem to line up with the Arm ARM decode. Your pattern and mask give
op0 = 0x, op1 = 100, op2 = 0 and also bit 8 = 0.
The ARM has 3reg-same decoded with
op0 = 0x, op1 = 1x0, op2 = x
(and some insns in the 3reg-same group have bit 8 == 1, like VSDOT and VUDOT.)
target/arm/translate.c static void disas_arm_insn(DisasContext *s, unsigned int insn) · line 8476
Quoted 4 lines
target/arm/translate.c +1
-0+return ; }else if ((insn &0x0fe00000 ) ==0x0c400000 ) {/* Coprocessor double register transfer. */ ARCH(5TE);
How are you proposing to do the Thumb decoding? Try to share some of the 3same-vs-2reg+scalar decode part, or just have them both do a similar kind of decode and call the disas_neon_insn_cp8_3same/cp8_index functions?
thanks
-- PMM
Re: [Qemu-devel] [PATCH v2 10/11] target/arm: Decode aa32 armv8.3 3-same
Quoted 8 lines · Peter Maydell
This doesn't seem to line up with the Arm ARM decode. Your pattern and mask give
op0 = 0x, op1 = 100, op2 = 0 and also bit 8 = 0.
The ARM has 3reg-same decoded with
op0 = 0x, op1 = 1x0, op2 = x(and some insns in the 3reg-same group have bit 8 == 1, like VSDOT and VUDOT.)
Ah, more v8.2 instructions that I wasn't even looking at...
Quoted 4 lines
How are you proposing to do the Thumb decoding? Try to share some of the 3same-vs-2reg+scalar decode part, or just have them both do a similar kind of decode and call the disas_neon_insn_cp8_3same/cp8_index functions?
Hmm. I thought this was working via the "translate into the equivalent ARM encoding" path. But it couldn't possibly be doing so, since disas_neon_insn_cp8_3same is not a subroutine of disas_neon_data_insn.
I guess I'll have to verify that RISU is testing what I thought it was...
r~
Re: [Qemu-arm] [PATCH v2 10/11] target/arm: Decode aa32 armv8.3 3-same
In reply to Richard HendersonQuoted 16 lines · Richard Henderson
Signed-off-by Richard Henderson <[email protected]>--- target/arm/translate.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+)target/arm/translate.c +3
-0@@ -7662,6 +7662,65 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)return 0 ; } +/* ARMv8.3 reclaims a portion of the LDC2/STC2 coprocessor 8 space. */ + +static int disas_neon_insn_cp8_3same (DisasContext *s,uint32_t insn)
target/arm/translate.c static int disas_neon_data_insn(DisasContext *s, uint32_t insn) · line 7677
Quoted 10 lines
target/arm/translate.c +10
-0+{ +void (*fn_gvec_ptr)(TCGv_ptr ,TCGv_ptr ,TCGv_ptr ,TCGv_ptr ,TCGv_i32 ); +int rd, rn, rm, rot, size, opr_sz; +TCGv_ptr fpst; +bool q; + +/* FIXME: this access check should not take precedence over UNDEF +* for invalid encodings; we will generate incorrect syndrome information +* for attempts to execute invalid vfp/neon encodings with FP disabled. +*/
(Forgot this bit before hitting send on the other email...)
Unlike the sprawling disas_vfp_insn(), we're in a position to get the order of checks right here. Just move it and the vfp_enabled test a bit further down...
Quoted 25 lines
target/arm/translate.c +25
-0+if (s->fp_excp_el) { +gen_exception_insn (s,4 ,EXCP_UDEF , +syn_fp_access_trap (1 ,0xe , false), s->fp_excp_el); +return 0 ; + } +if (!s->vfp_enabled) { +return 1 ; + } +if (!arm_dc_feature (s,ARM_FEATURE_V8_FCMA )) { +return 1 ; + } + + q =extract32 (insn,6 ,1 ); + size =extract32 (insn,20 ,1 ); +VFP_DREG_D (rd, insn); +VFP_DREG_N (rn, insn); +VFP_DREG_M (rm, insn); +if ((rd | rn | rm) & q) { +return 1 ; + } + +if (extract32 (insn,21 ,1 )) { +/* VCMLA */ + rot =extract32 (insn,23 ,2 ); + fn_gvec_ptr = size ? gen_helper_gvec_fcmlas : gen_helper_gvec_fcmlah;
target/arm/translate.c static int disas_neon_data_insn(DisasContext *s, uint32_t insn) · line 7712
Quoted 10 lines
target/arm/translate.c +10
-0+ }else if (extract32 (insn,23 ,1 )) { +/* VCADD */ + rot =extract32 (insn,24 ,1 ); + fn_gvec_ptr = size ? gen_helper_gvec_fcadds : gen_helper_gvec_fcaddh; + }else { +/* Assuming the register fields remain, only bit 24 remains undecoded: +* 1111_110x_0d0s_nnnn_dddd_1000_nqm0_mmmm +*/ +return 1 ; + }
...to here.
target/arm/translate.c static int disas_neon_data_insn(DisasContext *s, uint32_t insn) · line 7723
Quoted 11 lines
target/arm/translate.c +11
-0+ + opr_sz = (1 + q) *8 ; + fpst =get_fpstatus_ptr (1 ); +tcg_gen_gvec_3_ptr (vfp_reg_offset (1 , rd), +vfp_reg_offset (1 , rn), +vfp_reg_offset (1 , rm), fpst, + opr_sz, opr_sz, rot, fn_gvec_ptr); +tcg_temp_free_ptr (fpst); +return 0 ; +} +
thanks
-- PMM
PATCH v2 11/11 target/arm: Decode aa32 armv8.3 2-reg-index
In reply to Richard Henderson--- target/arm/translate.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+)
target/arm/translate.c +51 -0
@@ -7721,6 +7721,51 @@ static int disas_neon_insn_cp8_3same(DisasContext *s, uint32_t insn)return 0 ; } +/* ARMv8.3 reclaims a portion of the CDP2 coprocessor 8 space. */ + +static int disas_neon_insn_cp8_index (DisasContext *s,uint32_t insn) +{ +int rd, rn, rm, rot, size, opr_sz; +TCGv_ptr fpst; +bool q; + +/* FIXME: this access check should not take precedence over UNDEF +* for invalid encodings; we will generate incorrect syndrome information +* for attempts to execute invalid vfp/neon encodings with FP disabled. +*/ +if (s->fp_excp_el) { +gen_exception_insn (s,4 ,EXCP_UDEF , +syn_fp_access_trap (1 ,0xe , false), s->fp_excp_el); +return 0 ; + } +if (!s->vfp_enabled || !arm_dc_feature (s,ARM_FEATURE_V8_FCMA )) { +return 1 ; + } + + q =extract32 (insn,6 ,1 ); + size =extract32 (insn,23 ,1 ); + +VFP_DREG_D (rd, insn); +VFP_DREG_N (rn, insn); +VFP_DREG_M (rm, insn); +if ((rd | rn) & q) { +return 1 ; + } + +/* This entire space is VCMLA (indexed). */ + rot =extract32 (insn,20 ,2 ); + opr_sz = (1 + q) *8 ; + fpst =get_fpstatus_ptr (1 ); +tcg_gen_gvec_3_ptr (vfp_reg_offset (1 , rd), +vfp_reg_offset (1 , rn), +vfp_reg_offset (1 , rm), fpst, + opr_sz, opr_sz, rot, + size ? gen_helper_gvec_fcmlas_idx + : gen_helper_gvec_fcmlah_idx); +tcg_temp_free_ptr (fpst); +return 0 ; +} +static int disas_coproc_insn (DisasContext *s,uint32_t insn) {int cpnum, is64, crn, crm, opc1, opc2, isread, rt, rt2;
@@ -8471,6 +8516,12 @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) goto illegal_op; }return ; + }else if ((insn &0x0f000f10 ) ==0x0e000800 ) { +/* ARMv8.3 neon cdp2 coprocessor 8 extension. */ +if (disas_neon_insn_cp8_index (s, insn)) { + goto illegal_op; + } +return ; }else if ((insn &0x0fe00000 ) ==0x0c400000 ) {/* Coprocessor double register transfer. */ ARCH(5TE);
Signature · 1 line
2.14.3
Re: [Qemu-arm] [PATCH v2 11/11] target/arm: Decode aa32 armv8.3 2-reg-index
Quoted 15 lines · Richard Henderson
Signed-off-by Richard Henderson <[email protected]>--- target/arm/translate.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+)target/arm/translate.c +2
-0@@ -7721,6 +7721,51 @@ static int disas_neon_insn_cp8_3same(DisasContext *s, uint32_t insn)return 0 ; } +/* ARMv8.3 reclaims a portion of the CDP2 coprocessor 8 space. */ +
target/arm/translate.c static int disas_neon_insn_cp8_3same(DisasContext *s, uint32_t insn) · line 7735
Quoted 10 lines
target/arm/translate.c +10
-0+static int disas_neon_insn_cp8_index (DisasContext *s,uint32_t insn) +{ +int rd, rn, rm, rot, size, opr_sz; +TCGv_ptr fpst; +bool q; + +/* FIXME: this access check should not take precedence over UNDEF +* for invalid encodings; we will generate incorrect syndrome information +* for attempts to execute invalid vfp/neon encodings with FP disabled. +*/
Again, we can push this test down to where it belongs in this new code.
Quoted 39 lines
target/arm/translate.c +33
-0+if (s->fp_excp_el) { +gen_exception_insn (s,4 ,EXCP_UDEF , +syn_fp_access_trap (1 ,0xe , false), s->fp_excp_el); +return 0 ; + } +if (!s->vfp_enabled || !arm_dc_feature (s,ARM_FEATURE_V8_FCMA )) { +return 1 ; + } + + q =extract32 (insn,6 ,1 ); + size =extract32 (insn,23 ,1 ); + +VFP_DREG_D (rd, insn); +VFP_DREG_N (rn, insn); +VFP_DREG_M (rm, insn); +if ((rd | rn) & q) { +return 1 ; + } + +/* This entire space is VCMLA (indexed). */ + rot =extract32 (insn,20 ,2 ); + opr_sz = (1 + q) *8 ; + fpst =get_fpstatus_ptr (1 ); +tcg_gen_gvec_3_ptr (vfp_reg_offset (1 , rd), +vfp_reg_offset (1 , rn), +vfp_reg_offset (1 , rm), fpst, + opr_sz, opr_sz, rot, + size ? gen_helper_gvec_fcmlas_idx + : gen_helper_gvec_fcmlah_idx); +tcg_temp_free_ptr (fpst); +return 0 ; +} +static int disas_coproc_insn (DisasContext *s,uint32_t insn) {int cpnum, is64, crn, crm, opc1, opc2, isread, rt, rt2;@@ -8471,6 +8516,12 @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) goto illegal_op; }
target/arm/translate.c static void disas_arm_insn(DisasContext *s, unsigned int insn) · line 8527
Quoted 10 lines
target/arm/translate.c +6
-0return ; + }else if ((insn &0x0f000f10 ) ==0x0e000800 ) { +/* ARMv8.3 neon cdp2 coprocessor 8 extension. */ +if (disas_neon_insn_cp8_index (s, insn)) { + goto illegal_op; + } +return ; }else if ((insn &0x0fe00000 ) ==0x0c400000 ) {/* Coprocessor double register transfer. */ ARCH(5TE);
Similar remarks as for patch 10 about decode, and how we're going to deal with thumb.
thanks
-- PMM