1 | First set of arm patches for 6.2. I have a lot more in my | 1 | Two small bugfixes, plus most of RTH's refactoring of cpregs |
---|---|---|---|
2 | to-review queue still... | 2 | handling. |
3 | 3 | ||
4 | -- PMM | 4 | -- PMM |
5 | 5 | ||
6 | The following changes since commit d42685765653ec155fdf60910662f8830bdb2cef: | 6 | The following changes since commit 1fba9dc71a170b3a05b9d3272dd8ecfe7f26e215: |
7 | 7 | ||
8 | Open 6.2 development tree (2021-08-25 10:25:12 +0100) | 8 | Merge tag 'pull-request-2022-05-04' of https://gitlab.com/thuth/qemu into staging (2022-05-04 08:07:02 -0700) |
9 | 9 | ||
10 | are available in the Git repository at: | 10 | are available in the Git repository at: |
11 | 11 | ||
12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210825 | 12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220505 |
13 | 13 | ||
14 | for you to fetch changes up to 24b1a6aa43615be22c7ee66bd68ec5675f6a6a9a: | 14 | for you to fetch changes up to 99a50d1a67c602126fc2b3a4812d3000eba9bf34: |
15 | 15 | ||
16 | docs: Document how to use gdb with unix sockets (2021-08-25 10:48:51 +0100) | 16 | target/arm: read access to performance counters from EL0 (2022-05-05 09:36:22 +0100) |
17 | 17 | ||
18 | ---------------------------------------------------------------- | 18 | ---------------------------------------------------------------- |
19 | target-arm queue: | 19 | target-arm queue: |
20 | * More MVE emulation work | 20 | * Enable read access to performance counters from EL0 |
21 | * Implement M-profile trapping on division by zero | 21 | * Enable SCTLR_EL1.BT0 for aarch64-linux-user |
22 | * kvm: use RCU_READ_LOCK_GUARD() in kvm_arch_fixup_msi_route() | 22 | * Refactoring of cpreg handling |
23 | * hw/char/pl011: add support for sending break | ||
24 | * fsl-imx6ul: Instantiate SAI1/2/3 and ASRC as unimplemented devices | ||
25 | * hw/dma/pl330: Add memory region to replace default | ||
26 | * sbsa-ref: Rename SBSA_GWDT enum value | ||
27 | * fsl-imx7: Instantiate SAI1/2/3 as unimplemented devices | ||
28 | * docs: Document how to use gdb with unix sockets | ||
29 | 23 | ||
30 | ---------------------------------------------------------------- | 24 | ---------------------------------------------------------------- |
31 | Eduardo Habkost (1): | 25 | Alex Zuepke (1): |
32 | sbsa-ref: Rename SBSA_GWDT enum value | 26 | target/arm: read access to performance counters from EL0 |
33 | 27 | ||
34 | Guenter Roeck (2): | 28 | Richard Henderson (22): |
35 | fsl-imx6ul: Instantiate SAI1/2/3 and ASRC as unimplemented devices | 29 | target/arm: Enable SCTLR_EL1.BT0 for aarch64-linux-user |
36 | fsl-imx7: Instantiate SAI1/2/3 as unimplemented devices | 30 | target/arm: Split out cpregs.h |
31 | target/arm: Reorg CPAccessResult and access_check_cp_reg | ||
32 | target/arm: Replace sentinels with ARRAY_SIZE in cpregs.h | ||
33 | target/arm: Make some more cpreg data static const | ||
34 | target/arm: Reorg ARMCPRegInfo type field bits | ||
35 | target/arm: Avoid bare abort() or assert(0) | ||
36 | target/arm: Change cpreg access permissions to enum | ||
37 | target/arm: Name CPState type | ||
38 | target/arm: Name CPSecureState type | ||
39 | target/arm: Drop always-true test in define_arm_vh_e2h_redirects_aliases | ||
40 | target/arm: Store cpregs key in the hash table directly | ||
41 | target/arm: Merge allocation of the cpreg and its name | ||
42 | target/arm: Hoist computation of key in add_cpreg_to_hashtable | ||
43 | target/arm: Consolidate cpreg updates in add_cpreg_to_hashtable | ||
44 | target/arm: Use bool for is64 and ns in add_cpreg_to_hashtable | ||
45 | target/arm: Hoist isbanked computation in add_cpreg_to_hashtable | ||
46 | target/arm: Perform override check early in add_cpreg_to_hashtable | ||
47 | target/arm: Reformat comments in add_cpreg_to_hashtable | ||
48 | target/arm: Remove HOST_BIG_ENDIAN ifdef in add_cpreg_to_hashtable | ||
49 | target/arm: Add isar predicates for FEAT_Debugv8p2 | ||
50 | target/arm: Add isar_feature_{aa64,any}_ras | ||
37 | 51 | ||
38 | Hamza Mahfooz (1): | 52 | target/arm/cpregs.h | 453 ++++++++++++++++++++++++++++++++++++++ |
39 | target/arm: kvm: use RCU_READ_LOCK_GUARD() in kvm_arch_fixup_msi_route() | 53 | target/arm/cpu.h | 393 +++------------------------------ |
40 | 54 | hw/arm/pxa2xx.c | 2 +- | |
41 | Jan Luebbe (1): | 55 | hw/arm/pxa2xx_pic.c | 2 +- |
42 | hw/char/pl011: add support for sending break | 56 | hw/intc/arm_gicv3_cpuif.c | 6 +- |
43 | 57 | hw/intc/arm_gicv3_kvm.c | 3 +- | |
44 | Peter Maydell (37): | 58 | target/arm/cpu.c | 25 +-- |
45 | target/arm: Note that we handle VMOVL as a special case of VSHLL | 59 | target/arm/cpu64.c | 2 +- |
46 | target/arm: Print MVE VPR in CPU dumps | 60 | target/arm/cpu_tcg.c | 5 +- |
47 | target/arm: Fix MVE VSLI by 0 and VSRI by <dt> | 61 | target/arm/gdbstub.c | 5 +- |
48 | target/arm: Fix signed VADDV | 62 | target/arm/helper.c | 358 +++++++++++++----------------- |
49 | target/arm: Fix mask handling for MVE narrowing operations | 63 | target/arm/hvf/hvf.c | 2 +- |
50 | target/arm: Fix 48-bit saturating shifts | 64 | target/arm/kvm-stub.c | 4 +- |
51 | target/arm: Fix MVE 48-bit SQRSHRL for small right shifts | 65 | target/arm/kvm.c | 4 +- |
52 | target/arm: Fix calculation of LTP mask when LR is 0 | 66 | target/arm/machine.c | 4 +- |
53 | target/arm: Factor out mve_eci_mask() | 67 | target/arm/op_helper.c | 57 ++--- |
54 | target/arm: Fix VPT advance when ECI is non-zero | 68 | target/arm/translate-a64.c | 14 +- |
55 | target/arm: Fix VLDRB/H/W for predicated elements | 69 | target/arm/translate-neon.c | 2 +- |
56 | target/arm: Implement MVE VMULL (polynomial) | 70 | target/arm/translate.c | 13 +- |
57 | target/arm: Implement MVE incrementing/decrementing dup insns | 71 | tests/tcg/aarch64/bti-3.c | 42 ++++ |
58 | target/arm: Factor out gen_vpst() | 72 | tests/tcg/aarch64/Makefile.target | 6 +- |
59 | target/arm: Implement MVE integer vector comparisons | 73 | 21 files changed, 738 insertions(+), 664 deletions(-) |
60 | target/arm: Implement MVE integer vector-vs-scalar comparisons | 74 | create mode 100644 target/arm/cpregs.h |
61 | target/arm: Implement MVE VPSEL | 75 | create mode 100644 tests/tcg/aarch64/bti-3.c |
62 | target/arm: Implement MVE VMLAS | ||
63 | target/arm: Implement MVE shift-by-scalar | ||
64 | target/arm: Move 'x' and 'a' bit definitions into vmlaldav formats | ||
65 | target/arm: Implement MVE integer min/max across vector | ||
66 | target/arm: Implement MVE VABAV | ||
67 | target/arm: Implement MVE narrowing moves | ||
68 | target/arm: Rename MVEGenDualAccOpFn to MVEGenLongDualAccOpFn | ||
69 | target/arm: Implement MVE VMLADAV and VMLSLDAV | ||
70 | target/arm: Implement MVE VMLA | ||
71 | target/arm: Implement MVE saturating doubling multiply accumulates | ||
72 | target/arm: Implement MVE VQABS, VQNEG | ||
73 | target/arm: Implement MVE VMAXA, VMINA | ||
74 | target/arm: Implement MVE VMOV to/from 2 general-purpose registers | ||
75 | target/arm: Implement MVE VPNOT | ||
76 | target/arm: Implement MVE VCTP | ||
77 | target/arm: Implement MVE scatter-gather insns | ||
78 | target/arm: Implement MVE scatter-gather immediate forms | ||
79 | target/arm: Implement MVE interleaving loads/stores | ||
80 | target/arm: Re-indent sdiv and udiv helpers | ||
81 | target/arm: Implement M-profile trapping on division by zero | ||
82 | |||
83 | Sebastian Meyer (1): | ||
84 | docs: Document how to use gdb with unix sockets | ||
85 | |||
86 | Wen, Jianxian (1): | ||
87 | hw/dma/pl330: Add memory region to replace default | ||
88 | |||
89 | docs/system/gdb.rst | 26 +- | ||
90 | include/hw/arm/fsl-imx7.h | 5 + | ||
91 | target/arm/cpu.h | 1 + | ||
92 | target/arm/helper-mve.h | 283 ++++++++++ | ||
93 | target/arm/helper.h | 4 +- | ||
94 | target/arm/translate-a32.h | 2 + | ||
95 | target/arm/vec_internal.h | 11 + | ||
96 | target/arm/mve.decode | 226 +++++++- | ||
97 | target/arm/t32.decode | 1 + | ||
98 | hw/arm/exynos4210.c | 3 + | ||
99 | hw/arm/fsl-imx6ul.c | 12 + | ||
100 | hw/arm/fsl-imx7.c | 7 + | ||
101 | hw/arm/sbsa-ref.c | 6 +- | ||
102 | hw/arm/xilinx_zynq.c | 3 + | ||
103 | hw/char/pl011.c | 6 + | ||
104 | hw/dma/pl330.c | 26 +- | ||
105 | target/arm/cpu.c | 3 + | ||
106 | target/arm/helper.c | 34 +- | ||
107 | target/arm/kvm.c | 17 +- | ||
108 | target/arm/m_helper.c | 4 + | ||
109 | target/arm/mve_helper.c | 1254 ++++++++++++++++++++++++++++++++++++++++++-- | ||
110 | target/arm/translate-mve.c | 877 ++++++++++++++++++++++++++++++- | ||
111 | target/arm/translate-vfp.c | 2 +- | ||
112 | target/arm/translate.c | 37 +- | ||
113 | target/arm/vec_helper.c | 14 +- | ||
114 | 25 files changed, 2746 insertions(+), 118 deletions(-) | ||
115 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Although the architecture doesn't define it as an alias, VMOVL | ||
2 | (vector move long) is encoded as a VSHLL with a zero shift. | ||
3 | Add a comment in the decode file noting that we handle VMOVL | ||
4 | as part of VSHLL. | ||
5 | 1 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | --- | ||
9 | target/arm/mve.decode | 2 ++ | ||
10 | 1 file changed, 2 insertions(+) | ||
11 | |||
12 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/arm/mve.decode | ||
15 | +++ b/target/arm/mve.decode | ||
16 | @@ -XXX,XX +XXX,XX @@ VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_h | ||
17 | VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_w | ||
18 | |||
19 | # VSHLL T1 encoding; the T2 VSHLL encoding is elsewhere in this file | ||
20 | +# Note that VMOVL is encoded as "VSHLL with a zero shift count"; we | ||
21 | +# implement it that way rather than special-casing it in the decode. | ||
22 | VSHLL_BS 111 0 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_b | ||
23 | VSHLL_BS 111 0 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_h | ||
24 | |||
25 | -- | ||
26 | 2.20.1 | ||
27 | |||
28 | diff view generated by jsdifflib |
1 | Implement the MVE interleaving load/store functions VLD2, VLD4, VST2 | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | and VST4. VLD2 loads 16 bytes of data from memory and writes to 2 | ||
3 | consecutive Qregs; VLD4 loads 16 bytes of data from memory and writes | ||
4 | to 4 consecutive Qregs. The 'pattern' field in the encoding | ||
5 | determines the offset into memory which is accessed and also which | ||
6 | elements in the Qregs are written to. (The intention is that a | ||
7 | sequence of four consecutive VLD4 with different pattern values | ||
8 | performs a complete de-interleaving load of 64 bytes into all | ||
9 | elements of the 4 Qregs.) VST2 and VST4 do the same, but for stores. | ||
10 | 2 | ||
3 | This controls whether the PACI{A,B}SP instructions trap with BTYPE=3 | ||
4 | (indirect branch from register other than x16/x17). The linux kernel | ||
5 | sets this in bti_enable(). | ||
6 | |||
7 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/998 | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Message-id: 20220427042312.294300-1-richard.henderson@linaro.org | ||
11 | [PMM: remove stray change to makefile comment] | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | --- | 13 | --- |
14 | target/arm/helper-mve.h | 48 ++++++ | 14 | target/arm/cpu.c | 2 ++ |
15 | target/arm/mve.decode | 11 ++ | 15 | tests/tcg/aarch64/bti-3.c | 42 +++++++++++++++++++++++++++++++ |
16 | target/arm/mve_helper.c | 342 +++++++++++++++++++++++++++++++++++++ | 16 | tests/tcg/aarch64/Makefile.target | 6 ++--- |
17 | target/arm/translate-mve.c | 94 ++++++++++ | 17 | 3 files changed, 47 insertions(+), 3 deletions(-) |
18 | 4 files changed, 495 insertions(+) | 18 | create mode 100644 tests/tcg/aarch64/bti-3.c |
19 | 19 | ||
20 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 20 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
21 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/helper-mve.h | 22 | --- a/target/arm/cpu.c |
23 | +++ b/target/arm/helper-mve.h | 23 | +++ b/target/arm/cpu.c |
24 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vldrd_sg_wb_ud, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 24 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(DeviceState *dev) |
25 | DEF_HELPER_FLAGS_4(mve_vstrw_sg_wb_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 25 | /* Enable all PAC keys. */ |
26 | DEF_HELPER_FLAGS_4(mve_vstrd_sg_wb_ud, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 26 | env->cp15.sctlr_el[1] |= (SCTLR_EnIA | SCTLR_EnIB | |
27 | 27 | SCTLR_EnDA | SCTLR_EnDB); | |
28 | +DEF_HELPER_FLAGS_3(mve_vld20b, TCG_CALL_NO_WG, void, env, i32, i32) | 28 | + /* Trap on btype=3 for PACIxSP. */ |
29 | +DEF_HELPER_FLAGS_3(mve_vld20h, TCG_CALL_NO_WG, void, env, i32, i32) | 29 | + env->cp15.sctlr_el[1] |= SCTLR_BT0; |
30 | +DEF_HELPER_FLAGS_3(mve_vld20w, TCG_CALL_NO_WG, void, env, i32, i32) | 30 | /* and to the FP/Neon instructions */ |
31 | env->cp15.cpacr_el1 = deposit64(env->cp15.cpacr_el1, 20, 2, 3); | ||
32 | /* and to the SVE instructions */ | ||
33 | diff --git a/tests/tcg/aarch64/bti-3.c b/tests/tcg/aarch64/bti-3.c | ||
34 | new file mode 100644 | ||
35 | index XXXXXXX..XXXXXXX | ||
36 | --- /dev/null | ||
37 | +++ b/tests/tcg/aarch64/bti-3.c | ||
38 | @@ -XXX,XX +XXX,XX @@ | ||
39 | +/* | ||
40 | + * BTI vs PACIASP | ||
41 | + */ | ||
31 | + | 42 | + |
32 | +DEF_HELPER_FLAGS_3(mve_vld21b, TCG_CALL_NO_WG, void, env, i32, i32) | 43 | +#include "bti-crt.inc.c" |
33 | +DEF_HELPER_FLAGS_3(mve_vld21h, TCG_CALL_NO_WG, void, env, i32, i32) | ||
34 | +DEF_HELPER_FLAGS_3(mve_vld21w, TCG_CALL_NO_WG, void, env, i32, i32) | ||
35 | + | 44 | + |
36 | +DEF_HELPER_FLAGS_3(mve_vld40b, TCG_CALL_NO_WG, void, env, i32, i32) | 45 | +static void skip2_sigill(int sig, siginfo_t *info, ucontext_t *uc) |
37 | +DEF_HELPER_FLAGS_3(mve_vld40h, TCG_CALL_NO_WG, void, env, i32, i32) | ||
38 | +DEF_HELPER_FLAGS_3(mve_vld40w, TCG_CALL_NO_WG, void, env, i32, i32) | ||
39 | + | ||
40 | +DEF_HELPER_FLAGS_3(mve_vld41b, TCG_CALL_NO_WG, void, env, i32, i32) | ||
41 | +DEF_HELPER_FLAGS_3(mve_vld41h, TCG_CALL_NO_WG, void, env, i32, i32) | ||
42 | +DEF_HELPER_FLAGS_3(mve_vld41w, TCG_CALL_NO_WG, void, env, i32, i32) | ||
43 | + | ||
44 | +DEF_HELPER_FLAGS_3(mve_vld42b, TCG_CALL_NO_WG, void, env, i32, i32) | ||
45 | +DEF_HELPER_FLAGS_3(mve_vld42h, TCG_CALL_NO_WG, void, env, i32, i32) | ||
46 | +DEF_HELPER_FLAGS_3(mve_vld42w, TCG_CALL_NO_WG, void, env, i32, i32) | ||
47 | + | ||
48 | +DEF_HELPER_FLAGS_3(mve_vld43b, TCG_CALL_NO_WG, void, env, i32, i32) | ||
49 | +DEF_HELPER_FLAGS_3(mve_vld43h, TCG_CALL_NO_WG, void, env, i32, i32) | ||
50 | +DEF_HELPER_FLAGS_3(mve_vld43w, TCG_CALL_NO_WG, void, env, i32, i32) | ||
51 | + | ||
52 | +DEF_HELPER_FLAGS_3(mve_vst20b, TCG_CALL_NO_WG, void, env, i32, i32) | ||
53 | +DEF_HELPER_FLAGS_3(mve_vst20h, TCG_CALL_NO_WG, void, env, i32, i32) | ||
54 | +DEF_HELPER_FLAGS_3(mve_vst20w, TCG_CALL_NO_WG, void, env, i32, i32) | ||
55 | + | ||
56 | +DEF_HELPER_FLAGS_3(mve_vst21b, TCG_CALL_NO_WG, void, env, i32, i32) | ||
57 | +DEF_HELPER_FLAGS_3(mve_vst21h, TCG_CALL_NO_WG, void, env, i32, i32) | ||
58 | +DEF_HELPER_FLAGS_3(mve_vst21w, TCG_CALL_NO_WG, void, env, i32, i32) | ||
59 | + | ||
60 | +DEF_HELPER_FLAGS_3(mve_vst40b, TCG_CALL_NO_WG, void, env, i32, i32) | ||
61 | +DEF_HELPER_FLAGS_3(mve_vst40h, TCG_CALL_NO_WG, void, env, i32, i32) | ||
62 | +DEF_HELPER_FLAGS_3(mve_vst40w, TCG_CALL_NO_WG, void, env, i32, i32) | ||
63 | + | ||
64 | +DEF_HELPER_FLAGS_3(mve_vst41b, TCG_CALL_NO_WG, void, env, i32, i32) | ||
65 | +DEF_HELPER_FLAGS_3(mve_vst41h, TCG_CALL_NO_WG, void, env, i32, i32) | ||
66 | +DEF_HELPER_FLAGS_3(mve_vst41w, TCG_CALL_NO_WG, void, env, i32, i32) | ||
67 | + | ||
68 | +DEF_HELPER_FLAGS_3(mve_vst42b, TCG_CALL_NO_WG, void, env, i32, i32) | ||
69 | +DEF_HELPER_FLAGS_3(mve_vst42h, TCG_CALL_NO_WG, void, env, i32, i32) | ||
70 | +DEF_HELPER_FLAGS_3(mve_vst42w, TCG_CALL_NO_WG, void, env, i32, i32) | ||
71 | + | ||
72 | +DEF_HELPER_FLAGS_3(mve_vst43b, TCG_CALL_NO_WG, void, env, i32, i32) | ||
73 | +DEF_HELPER_FLAGS_3(mve_vst43h, TCG_CALL_NO_WG, void, env, i32, i32) | ||
74 | +DEF_HELPER_FLAGS_3(mve_vst43w, TCG_CALL_NO_WG, void, env, i32, i32) | ||
75 | + | ||
76 | DEF_HELPER_FLAGS_3(mve_vdup, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
77 | |||
78 | DEF_HELPER_FLAGS_4(mve_vidupb, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) | ||
79 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
80 | index XXXXXXX..XXXXXXX 100644 | ||
81 | --- a/target/arm/mve.decode | ||
82 | +++ b/target/arm/mve.decode | ||
83 | @@ -XXX,XX +XXX,XX @@ | ||
84 | &vabav qn qm rda size | ||
85 | &vldst_sg qd qm rn size msize os | ||
86 | &vldst_sg_imm qd qm a w imm | ||
87 | +&vldst_il qd rn size pat w | ||
88 | |||
89 | # scatter-gather memory size is in bits 6:4 | ||
90 | %sg_msize 6:1 4:1 | ||
91 | @@ -XXX,XX +XXX,XX @@ | ||
92 | @vldst_sg_imm .... .... a:1 . w:1 . .... .... .... . imm:7 &vldst_sg_imm \ | ||
93 | qd=%qd qm=%qn | ||
94 | |||
95 | +# Deinterleaving load/interleaving store | ||
96 | +@vldst_il .... .... .. w:1 . rn:4 .... ... size:2 pat:2 ..... &vldst_il \ | ||
97 | + qd=%qd | ||
98 | + | ||
99 | @1op .... .... .... size:2 .. .... .... .... .... &1op qd=%qd qm=%qm | ||
100 | @1op_nosz .... .... .... .... .... .... .... .... &1op qd=%qd qm=%qm size=0 | ||
101 | @2op .... .... .. size:2 .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn | ||
102 | @@ -XXX,XX +XXX,XX @@ VLDRD_sg_imm 111 1 1101 ... 1 ... 0 ... 1 1111 .... .... @vldst_sg_imm | ||
103 | VSTRW_sg_imm 111 1 1101 ... 0 ... 0 ... 1 1110 .... .... @vldst_sg_imm | ||
104 | VSTRD_sg_imm 111 1 1101 ... 0 ... 0 ... 1 1111 .... .... @vldst_sg_imm | ||
105 | |||
106 | +# deinterleaving loads/interleaving stores | ||
107 | +VLD2 1111 1100 1 .. 1 .... ... 1 111 .. .. 00000 @vldst_il | ||
108 | +VLD4 1111 1100 1 .. 1 .... ... 1 111 .. .. 00001 @vldst_il | ||
109 | +VST2 1111 1100 1 .. 0 .... ... 1 111 .. .. 00000 @vldst_il | ||
110 | +VST4 1111 1100 1 .. 0 .... ... 1 111 .. .. 00001 @vldst_il | ||
111 | + | ||
112 | # Moves between 2 32-bit vector lanes and 2 general purpose registers | ||
113 | VMOV_to_2gp 1110 1100 0 . 00 rt2:4 ... 0 1111 000 idx:1 rt:4 qd=%qd | ||
114 | VMOV_from_2gp 1110 1100 0 . 01 rt2:4 ... 0 1111 000 idx:1 rt:4 qd=%qd | ||
115 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
116 | index XXXXXXX..XXXXXXX 100644 | ||
117 | --- a/target/arm/mve_helper.c | ||
118 | +++ b/target/arm/mve_helper.c | ||
119 | @@ -XXX,XX +XXX,XX @@ DO_VLDR64_SG(vldrd_sg_wb_ud, ADDR_ADD, true) | ||
120 | DO_VSTR_SG(vstrw_sg_wb_uw, stl, 4, uint32_t, ADDR_ADD, true) | ||
121 | DO_VSTR64_SG(vstrd_sg_wb_ud, ADDR_ADD, true) | ||
122 | |||
123 | +/* | ||
124 | + * Deinterleaving loads/interleaving stores. | ||
125 | + * | ||
126 | + * For these helpers we are passed the index of the first Qreg | ||
127 | + * (VLD2/VST2 will also access Qn+1, VLD4/VST4 access Qn .. Qn+3) | ||
128 | + * and the value of the base address register Rn. | ||
129 | + * The helpers are specialized for pattern and element size, so | ||
130 | + * for instance vld42h is VLD4 with pattern 2, element size MO_16. | ||
131 | + * | ||
132 | + * These insns are beatwise but not predicated, so we must honour ECI, | ||
133 | + * but need not look at mve_element_mask(). | ||
134 | + * | ||
135 | + * The pseudocode implements these insns with multiple memory accesses | ||
136 | + * of the element size, but rules R_VVVG and R_FXDM permit us to make | ||
137 | + * one 32-bit memory access per beat. | ||
138 | + */ | ||
139 | +#define DO_VLD4B(OP, O1, O2, O3, O4) \ | ||
140 | + void HELPER(mve_##OP)(CPUARMState *env, uint32_t qnidx, \ | ||
141 | + uint32_t base) \ | ||
142 | + { \ | ||
143 | + int beat, e; \ | ||
144 | + uint16_t mask = mve_eci_mask(env); \ | ||
145 | + static const uint8_t off[4] = { O1, O2, O3, O4 }; \ | ||
146 | + uint32_t addr, data; \ | ||
147 | + for (beat = 0; beat < 4; beat++, mask >>= 4) { \ | ||
148 | + if ((mask & 1) == 0) { \ | ||
149 | + /* ECI says skip this beat */ \ | ||
150 | + continue; \ | ||
151 | + } \ | ||
152 | + addr = base + off[beat] * 4; \ | ||
153 | + data = cpu_ldl_le_data_ra(env, addr, GETPC()); \ | ||
154 | + for (e = 0; e < 4; e++, data >>= 8) { \ | ||
155 | + uint8_t *qd = (uint8_t *)aa32_vfp_qreg(env, qnidx + e); \ | ||
156 | + qd[H1(off[beat])] = data; \ | ||
157 | + } \ | ||
158 | + } \ | ||
159 | + } | ||
160 | + | ||
161 | +#define DO_VLD4H(OP, O1, O2) \ | ||
162 | + void HELPER(mve_##OP)(CPUARMState *env, uint32_t qnidx, \ | ||
163 | + uint32_t base) \ | ||
164 | + { \ | ||
165 | + int beat; \ | ||
166 | + uint16_t mask = mve_eci_mask(env); \ | ||
167 | + static const uint8_t off[4] = { O1, O1, O2, O2 }; \ | ||
168 | + uint32_t addr, data; \ | ||
169 | + int y; /* y counts 0 2 0 2 */ \ | ||
170 | + uint16_t *qd; \ | ||
171 | + for (beat = 0, y = 0; beat < 4; beat++, mask >>= 4, y ^= 2) { \ | ||
172 | + if ((mask & 1) == 0) { \ | ||
173 | + /* ECI says skip this beat */ \ | ||
174 | + continue; \ | ||
175 | + } \ | ||
176 | + addr = base + off[beat] * 8 + (beat & 1) * 4; \ | ||
177 | + data = cpu_ldl_le_data_ra(env, addr, GETPC()); \ | ||
178 | + qd = (uint16_t *)aa32_vfp_qreg(env, qnidx + y); \ | ||
179 | + qd[H2(off[beat])] = data; \ | ||
180 | + data >>= 16; \ | ||
181 | + qd = (uint16_t *)aa32_vfp_qreg(env, qnidx + y + 1); \ | ||
182 | + qd[H2(off[beat])] = data; \ | ||
183 | + } \ | ||
184 | + } | ||
185 | + | ||
186 | +#define DO_VLD4W(OP, O1, O2, O3, O4) \ | ||
187 | + void HELPER(mve_##OP)(CPUARMState *env, uint32_t qnidx, \ | ||
188 | + uint32_t base) \ | ||
189 | + { \ | ||
190 | + int beat; \ | ||
191 | + uint16_t mask = mve_eci_mask(env); \ | ||
192 | + static const uint8_t off[4] = { O1, O2, O3, O4 }; \ | ||
193 | + uint32_t addr, data; \ | ||
194 | + uint32_t *qd; \ | ||
195 | + int y; \ | ||
196 | + for (beat = 0; beat < 4; beat++, mask >>= 4) { \ | ||
197 | + if ((mask & 1) == 0) { \ | ||
198 | + /* ECI says skip this beat */ \ | ||
199 | + continue; \ | ||
200 | + } \ | ||
201 | + addr = base + off[beat] * 4; \ | ||
202 | + data = cpu_ldl_le_data_ra(env, addr, GETPC()); \ | ||
203 | + y = (beat + (O1 & 2)) & 3; \ | ||
204 | + qd = (uint32_t *)aa32_vfp_qreg(env, qnidx + y); \ | ||
205 | + qd[H4(off[beat] >> 2)] = data; \ | ||
206 | + } \ | ||
207 | + } | ||
208 | + | ||
209 | +DO_VLD4B(vld40b, 0, 1, 10, 11) | ||
210 | +DO_VLD4B(vld41b, 2, 3, 12, 13) | ||
211 | +DO_VLD4B(vld42b, 4, 5, 14, 15) | ||
212 | +DO_VLD4B(vld43b, 6, 7, 8, 9) | ||
213 | + | ||
214 | +DO_VLD4H(vld40h, 0, 5) | ||
215 | +DO_VLD4H(vld41h, 1, 6) | ||
216 | +DO_VLD4H(vld42h, 2, 7) | ||
217 | +DO_VLD4H(vld43h, 3, 4) | ||
218 | + | ||
219 | +DO_VLD4W(vld40w, 0, 1, 10, 11) | ||
220 | +DO_VLD4W(vld41w, 2, 3, 12, 13) | ||
221 | +DO_VLD4W(vld42w, 4, 5, 14, 15) | ||
222 | +DO_VLD4W(vld43w, 6, 7, 8, 9) | ||
223 | + | ||
224 | +#define DO_VLD2B(OP, O1, O2, O3, O4) \ | ||
225 | + void HELPER(mve_##OP)(CPUARMState *env, uint32_t qnidx, \ | ||
226 | + uint32_t base) \ | ||
227 | + { \ | ||
228 | + int beat, e; \ | ||
229 | + uint16_t mask = mve_eci_mask(env); \ | ||
230 | + static const uint8_t off[4] = { O1, O2, O3, O4 }; \ | ||
231 | + uint32_t addr, data; \ | ||
232 | + uint8_t *qd; \ | ||
233 | + for (beat = 0; beat < 4; beat++, mask >>= 4) { \ | ||
234 | + if ((mask & 1) == 0) { \ | ||
235 | + /* ECI says skip this beat */ \ | ||
236 | + continue; \ | ||
237 | + } \ | ||
238 | + addr = base + off[beat] * 2; \ | ||
239 | + data = cpu_ldl_le_data_ra(env, addr, GETPC()); \ | ||
240 | + for (e = 0; e < 4; e++, data >>= 8) { \ | ||
241 | + qd = (uint8_t *)aa32_vfp_qreg(env, qnidx + (e & 1)); \ | ||
242 | + qd[H1(off[beat] + (e >> 1))] = data; \ | ||
243 | + } \ | ||
244 | + } \ | ||
245 | + } | ||
246 | + | ||
247 | +#define DO_VLD2H(OP, O1, O2, O3, O4) \ | ||
248 | + void HELPER(mve_##OP)(CPUARMState *env, uint32_t qnidx, \ | ||
249 | + uint32_t base) \ | ||
250 | + { \ | ||
251 | + int beat; \ | ||
252 | + uint16_t mask = mve_eci_mask(env); \ | ||
253 | + static const uint8_t off[4] = { O1, O2, O3, O4 }; \ | ||
254 | + uint32_t addr, data; \ | ||
255 | + int e; \ | ||
256 | + uint16_t *qd; \ | ||
257 | + for (beat = 0; beat < 4; beat++, mask >>= 4) { \ | ||
258 | + if ((mask & 1) == 0) { \ | ||
259 | + /* ECI says skip this beat */ \ | ||
260 | + continue; \ | ||
261 | + } \ | ||
262 | + addr = base + off[beat] * 4; \ | ||
263 | + data = cpu_ldl_le_data_ra(env, addr, GETPC()); \ | ||
264 | + for (e = 0; e < 2; e++, data >>= 16) { \ | ||
265 | + qd = (uint16_t *)aa32_vfp_qreg(env, qnidx + e); \ | ||
266 | + qd[H2(off[beat])] = data; \ | ||
267 | + } \ | ||
268 | + } \ | ||
269 | + } | ||
270 | + | ||
271 | +#define DO_VLD2W(OP, O1, O2, O3, O4) \ | ||
272 | + void HELPER(mve_##OP)(CPUARMState *env, uint32_t qnidx, \ | ||
273 | + uint32_t base) \ | ||
274 | + { \ | ||
275 | + int beat; \ | ||
276 | + uint16_t mask = mve_eci_mask(env); \ | ||
277 | + static const uint8_t off[4] = { O1, O2, O3, O4 }; \ | ||
278 | + uint32_t addr, data; \ | ||
279 | + uint32_t *qd; \ | ||
280 | + for (beat = 0; beat < 4; beat++, mask >>= 4) { \ | ||
281 | + if ((mask & 1) == 0) { \ | ||
282 | + /* ECI says skip this beat */ \ | ||
283 | + continue; \ | ||
284 | + } \ | ||
285 | + addr = base + off[beat]; \ | ||
286 | + data = cpu_ldl_le_data_ra(env, addr, GETPC()); \ | ||
287 | + qd = (uint32_t *)aa32_vfp_qreg(env, qnidx + (beat & 1)); \ | ||
288 | + qd[H4(off[beat] >> 3)] = data; \ | ||
289 | + } \ | ||
290 | + } | ||
291 | + | ||
292 | +DO_VLD2B(vld20b, 0, 2, 12, 14) | ||
293 | +DO_VLD2B(vld21b, 4, 6, 8, 10) | ||
294 | + | ||
295 | +DO_VLD2H(vld20h, 0, 1, 6, 7) | ||
296 | +DO_VLD2H(vld21h, 2, 3, 4, 5) | ||
297 | + | ||
298 | +DO_VLD2W(vld20w, 0, 4, 24, 28) | ||
299 | +DO_VLD2W(vld21w, 8, 12, 16, 20) | ||
300 | + | ||
301 | +#define DO_VST4B(OP, O1, O2, O3, O4) \ | ||
302 | + void HELPER(mve_##OP)(CPUARMState *env, uint32_t qnidx, \ | ||
303 | + uint32_t base) \ | ||
304 | + { \ | ||
305 | + int beat, e; \ | ||
306 | + uint16_t mask = mve_eci_mask(env); \ | ||
307 | + static const uint8_t off[4] = { O1, O2, O3, O4 }; \ | ||
308 | + uint32_t addr, data; \ | ||
309 | + for (beat = 0; beat < 4; beat++, mask >>= 4) { \ | ||
310 | + if ((mask & 1) == 0) { \ | ||
311 | + /* ECI says skip this beat */ \ | ||
312 | + continue; \ | ||
313 | + } \ | ||
314 | + addr = base + off[beat] * 4; \ | ||
315 | + data = 0; \ | ||
316 | + for (e = 3; e >= 0; e--) { \ | ||
317 | + uint8_t *qd = (uint8_t *)aa32_vfp_qreg(env, qnidx + e); \ | ||
318 | + data = (data << 8) | qd[H1(off[beat])]; \ | ||
319 | + } \ | ||
320 | + cpu_stl_le_data_ra(env, addr, data, GETPC()); \ | ||
321 | + } \ | ||
322 | + } | ||
323 | + | ||
324 | +#define DO_VST4H(OP, O1, O2) \ | ||
325 | + void HELPER(mve_##OP)(CPUARMState *env, uint32_t qnidx, \ | ||
326 | + uint32_t base) \ | ||
327 | + { \ | ||
328 | + int beat; \ | ||
329 | + uint16_t mask = mve_eci_mask(env); \ | ||
330 | + static const uint8_t off[4] = { O1, O1, O2, O2 }; \ | ||
331 | + uint32_t addr, data; \ | ||
332 | + int y; /* y counts 0 2 0 2 */ \ | ||
333 | + uint16_t *qd; \ | ||
334 | + for (beat = 0, y = 0; beat < 4; beat++, mask >>= 4, y ^= 2) { \ | ||
335 | + if ((mask & 1) == 0) { \ | ||
336 | + /* ECI says skip this beat */ \ | ||
337 | + continue; \ | ||
338 | + } \ | ||
339 | + addr = base + off[beat] * 8 + (beat & 1) * 4; \ | ||
340 | + qd = (uint16_t *)aa32_vfp_qreg(env, qnidx + y); \ | ||
341 | + data = qd[H2(off[beat])]; \ | ||
342 | + qd = (uint16_t *)aa32_vfp_qreg(env, qnidx + y + 1); \ | ||
343 | + data |= qd[H2(off[beat])] << 16; \ | ||
344 | + cpu_stl_le_data_ra(env, addr, data, GETPC()); \ | ||
345 | + } \ | ||
346 | + } | ||
347 | + | ||
348 | +#define DO_VST4W(OP, O1, O2, O3, O4) \ | ||
349 | + void HELPER(mve_##OP)(CPUARMState *env, uint32_t qnidx, \ | ||
350 | + uint32_t base) \ | ||
351 | + { \ | ||
352 | + int beat; \ | ||
353 | + uint16_t mask = mve_eci_mask(env); \ | ||
354 | + static const uint8_t off[4] = { O1, O2, O3, O4 }; \ | ||
355 | + uint32_t addr, data; \ | ||
356 | + uint32_t *qd; \ | ||
357 | + int y; \ | ||
358 | + for (beat = 0; beat < 4; beat++, mask >>= 4) { \ | ||
359 | + if ((mask & 1) == 0) { \ | ||
360 | + /* ECI says skip this beat */ \ | ||
361 | + continue; \ | ||
362 | + } \ | ||
363 | + addr = base + off[beat] * 4; \ | ||
364 | + y = (beat + (O1 & 2)) & 3; \ | ||
365 | + qd = (uint32_t *)aa32_vfp_qreg(env, qnidx + y); \ | ||
366 | + data = qd[H4(off[beat] >> 2)]; \ | ||
367 | + cpu_stl_le_data_ra(env, addr, data, GETPC()); \ | ||
368 | + } \ | ||
369 | + } | ||
370 | + | ||
371 | +DO_VST4B(vst40b, 0, 1, 10, 11) | ||
372 | +DO_VST4B(vst41b, 2, 3, 12, 13) | ||
373 | +DO_VST4B(vst42b, 4, 5, 14, 15) | ||
374 | +DO_VST4B(vst43b, 6, 7, 8, 9) | ||
375 | + | ||
376 | +DO_VST4H(vst40h, 0, 5) | ||
377 | +DO_VST4H(vst41h, 1, 6) | ||
378 | +DO_VST4H(vst42h, 2, 7) | ||
379 | +DO_VST4H(vst43h, 3, 4) | ||
380 | + | ||
381 | +DO_VST4W(vst40w, 0, 1, 10, 11) | ||
382 | +DO_VST4W(vst41w, 2, 3, 12, 13) | ||
383 | +DO_VST4W(vst42w, 4, 5, 14, 15) | ||
384 | +DO_VST4W(vst43w, 6, 7, 8, 9) | ||
385 | + | ||
386 | +#define DO_VST2B(OP, O1, O2, O3, O4) \ | ||
387 | + void HELPER(mve_##OP)(CPUARMState *env, uint32_t qnidx, \ | ||
388 | + uint32_t base) \ | ||
389 | + { \ | ||
390 | + int beat, e; \ | ||
391 | + uint16_t mask = mve_eci_mask(env); \ | ||
392 | + static const uint8_t off[4] = { O1, O2, O3, O4 }; \ | ||
393 | + uint32_t addr, data; \ | ||
394 | + uint8_t *qd; \ | ||
395 | + for (beat = 0; beat < 4; beat++, mask >>= 4) { \ | ||
396 | + if ((mask & 1) == 0) { \ | ||
397 | + /* ECI says skip this beat */ \ | ||
398 | + continue; \ | ||
399 | + } \ | ||
400 | + addr = base + off[beat] * 2; \ | ||
401 | + data = 0; \ | ||
402 | + for (e = 3; e >= 0; e--) { \ | ||
403 | + qd = (uint8_t *)aa32_vfp_qreg(env, qnidx + (e & 1)); \ | ||
404 | + data = (data << 8) | qd[H1(off[beat] + (e >> 1))]; \ | ||
405 | + } \ | ||
406 | + cpu_stl_le_data_ra(env, addr, data, GETPC()); \ | ||
407 | + } \ | ||
408 | + } | ||
409 | + | ||
410 | +#define DO_VST2H(OP, O1, O2, O3, O4) \ | ||
411 | + void HELPER(mve_##OP)(CPUARMState *env, uint32_t qnidx, \ | ||
412 | + uint32_t base) \ | ||
413 | + { \ | ||
414 | + int beat; \ | ||
415 | + uint16_t mask = mve_eci_mask(env); \ | ||
416 | + static const uint8_t off[4] = { O1, O2, O3, O4 }; \ | ||
417 | + uint32_t addr, data; \ | ||
418 | + int e; \ | ||
419 | + uint16_t *qd; \ | ||
420 | + for (beat = 0; beat < 4; beat++, mask >>= 4) { \ | ||
421 | + if ((mask & 1) == 0) { \ | ||
422 | + /* ECI says skip this beat */ \ | ||
423 | + continue; \ | ||
424 | + } \ | ||
425 | + addr = base + off[beat] * 4; \ | ||
426 | + data = 0; \ | ||
427 | + for (e = 1; e >= 0; e--) { \ | ||
428 | + qd = (uint16_t *)aa32_vfp_qreg(env, qnidx + e); \ | ||
429 | + data = (data << 16) | qd[H2(off[beat])]; \ | ||
430 | + } \ | ||
431 | + cpu_stl_le_data_ra(env, addr, data, GETPC()); \ | ||
432 | + } \ | ||
433 | + } | ||
434 | + | ||
435 | +#define DO_VST2W(OP, O1, O2, O3, O4) \ | ||
436 | + void HELPER(mve_##OP)(CPUARMState *env, uint32_t qnidx, \ | ||
437 | + uint32_t base) \ | ||
438 | + { \ | ||
439 | + int beat; \ | ||
440 | + uint16_t mask = mve_eci_mask(env); \ | ||
441 | + static const uint8_t off[4] = { O1, O2, O3, O4 }; \ | ||
442 | + uint32_t addr, data; \ | ||
443 | + uint32_t *qd; \ | ||
444 | + for (beat = 0; beat < 4; beat++, mask >>= 4) { \ | ||
445 | + if ((mask & 1) == 0) { \ | ||
446 | + /* ECI says skip this beat */ \ | ||
447 | + continue; \ | ||
448 | + } \ | ||
449 | + addr = base + off[beat]; \ | ||
450 | + qd = (uint32_t *)aa32_vfp_qreg(env, qnidx + (beat & 1)); \ | ||
451 | + data = qd[H4(off[beat] >> 3)]; \ | ||
452 | + cpu_stl_le_data_ra(env, addr, data, GETPC()); \ | ||
453 | + } \ | ||
454 | + } | ||
455 | + | ||
456 | +DO_VST2B(vst20b, 0, 2, 12, 14) | ||
457 | +DO_VST2B(vst21b, 4, 6, 8, 10) | ||
458 | + | ||
459 | +DO_VST2H(vst20h, 0, 1, 6, 7) | ||
460 | +DO_VST2H(vst21h, 2, 3, 4, 5) | ||
461 | + | ||
462 | +DO_VST2W(vst20w, 0, 4, 24, 28) | ||
463 | +DO_VST2W(vst21w, 8, 12, 16, 20) | ||
464 | + | ||
465 | /* | ||
466 | * The mergemask(D, R, M) macro performs the operation "*D = R" but | ||
467 | * storing only the bytes which correspond to 1 bits in M, | ||
468 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
469 | index XXXXXXX..XXXXXXX 100644 | ||
470 | --- a/target/arm/translate-mve.c | ||
471 | +++ b/target/arm/translate-mve.c | ||
472 | @@ -XXX,XX +XXX,XX @@ static inline int vidup_imm(DisasContext *s, int x) | ||
473 | |||
474 | typedef void MVEGenLdStFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
475 | typedef void MVEGenLdStSGFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
476 | +typedef void MVEGenLdStIlFn(TCGv_ptr, TCGv_i32, TCGv_i32); | ||
477 | typedef void MVEGenOneOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
478 | typedef void MVEGenTwoOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
479 | typedef void MVEGenTwoOpScalarFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
480 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSTRD_sg_imm(DisasContext *s, arg_vldst_sg_imm *a) | ||
481 | return do_ldst_sg_imm(s, a, fns[a->w], MO_64); | ||
482 | } | ||
483 | |||
484 | +static bool do_vldst_il(DisasContext *s, arg_vldst_il *a, MVEGenLdStIlFn *fn, | ||
485 | + int addrinc) | ||
486 | +{ | 46 | +{ |
487 | + TCGv_i32 rn; | 47 | + uc->uc_mcontext.pc += 8; |
488 | + | 48 | + uc->uc_mcontext.pstate = 1; |
489 | + if (!dc_isar_feature(aa32_mve, s) || | ||
490 | + !mve_check_qreg_bank(s, a->qd) || | ||
491 | + !fn || (a->rn == 13 && a->w) || a->rn == 15) { | ||
492 | + /* Variously UNPREDICTABLE or UNDEF or related-encoding */ | ||
493 | + return false; | ||
494 | + } | ||
495 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
496 | + return true; | ||
497 | + } | ||
498 | + | ||
499 | + rn = load_reg(s, a->rn); | ||
500 | + /* | ||
501 | + * We pass the index of Qd, not a pointer, because the helper must | ||
502 | + * access multiple Q registers starting at Qd and working up. | ||
503 | + */ | ||
504 | + fn(cpu_env, tcg_constant_i32(a->qd), rn); | ||
505 | + | ||
506 | + if (a->w) { | ||
507 | + tcg_gen_addi_i32(rn, rn, addrinc); | ||
508 | + store_reg(s, a->rn, rn); | ||
509 | + } else { | ||
510 | + tcg_temp_free_i32(rn); | ||
511 | + } | ||
512 | + mve_update_and_store_eci(s); | ||
513 | + return true; | ||
514 | +} | 49 | +} |
515 | + | 50 | + |
516 | +/* This macro is just to make the arrays more compact in these functions */ | 51 | +#define BTYPE_1() \ |
517 | +#define F(N) gen_helper_mve_##N | 52 | + asm("mov %0,#1; adr x16, 1f; br x16; 1: hint #25; mov %0,#0" \ |
53 | + : "=r"(skipped) : : "x16", "x30") | ||
518 | + | 54 | + |
519 | +static bool trans_VLD2(DisasContext *s, arg_vldst_il *a) | 55 | +#define BTYPE_2() \ |
56 | + asm("mov %0,#1; adr x16, 1f; blr x16; 1: hint #25; mov %0,#0" \ | ||
57 | + : "=r"(skipped) : : "x16", "x30") | ||
58 | + | ||
59 | +#define BTYPE_3() \ | ||
60 | + asm("mov %0,#1; adr x15, 1f; br x15; 1: hint #25; mov %0,#0" \ | ||
61 | + : "=r"(skipped) : : "x15", "x30") | ||
62 | + | ||
63 | +#define TEST(WHICH, EXPECT) \ | ||
64 | + do { WHICH(); fail += skipped ^ EXPECT; } while (0) | ||
65 | + | ||
66 | +int main() | ||
520 | +{ | 67 | +{ |
521 | + static MVEGenLdStIlFn * const fns[4][4] = { | 68 | + int fail = 0; |
522 | + { F(vld20b), F(vld20h), F(vld20w), NULL, }, | 69 | + int skipped; |
523 | + { F(vld21b), F(vld21h), F(vld21w), NULL, }, | 70 | + |
524 | + { NULL, NULL, NULL, NULL }, | 71 | + /* Signal-like with SA_SIGINFO. */ |
525 | + { NULL, NULL, NULL, NULL }, | 72 | + signal_info(SIGILL, skip2_sigill); |
526 | + }; | 73 | + |
527 | + if (a->qd > 6) { | 74 | + /* With SCTLR_EL1.BT0 set, PACIASP is not compatible with type=3. */ |
528 | + return false; | 75 | + TEST(BTYPE_1, 0); |
529 | + } | 76 | + TEST(BTYPE_2, 0); |
530 | + return do_vldst_il(s, a, fns[a->pat][a->size], 32); | 77 | + TEST(BTYPE_3, 1); |
78 | + | ||
79 | + return fail; | ||
531 | +} | 80 | +} |
532 | + | 81 | diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target |
533 | +static bool trans_VLD4(DisasContext *s, arg_vldst_il *a) | 82 | index XXXXXXX..XXXXXXX 100644 |
534 | +{ | 83 | --- a/tests/tcg/aarch64/Makefile.target |
535 | + static MVEGenLdStIlFn * const fns[4][4] = { | 84 | +++ b/tests/tcg/aarch64/Makefile.target |
536 | + { F(vld40b), F(vld40h), F(vld40w), NULL, }, | 85 | @@ -XXX,XX +XXX,XX @@ endif |
537 | + { F(vld41b), F(vld41h), F(vld41w), NULL, }, | 86 | # BTI Tests |
538 | + { F(vld42b), F(vld42h), F(vld42w), NULL, }, | 87 | # bti-1 tests the elf notes, so we require special compiler support. |
539 | + { F(vld43b), F(vld43h), F(vld43w), NULL, }, | 88 | ifneq ($(CROSS_CC_HAS_ARMV8_BTI),) |
540 | + }; | 89 | -AARCH64_TESTS += bti-1 |
541 | + if (a->qd > 4) { | 90 | -bti-1: CFLAGS += -mbranch-protection=standard |
542 | + return false; | 91 | -bti-1: LDFLAGS += -nostdlib |
543 | + } | 92 | +AARCH64_TESTS += bti-1 bti-3 |
544 | + return do_vldst_il(s, a, fns[a->pat][a->size], 64); | 93 | +bti-1 bti-3: CFLAGS += -mbranch-protection=standard |
545 | +} | 94 | +bti-1 bti-3: LDFLAGS += -nostdlib |
546 | + | 95 | endif |
547 | +static bool trans_VST2(DisasContext *s, arg_vldst_il *a) | 96 | # bti-2 tests PROT_BTI, so no special compiler support required. |
548 | +{ | 97 | AARCH64_TESTS += bti-2 |
549 | + static MVEGenLdStIlFn * const fns[4][4] = { | ||
550 | + { F(vst20b), F(vst20h), F(vst20w), NULL, }, | ||
551 | + { F(vst21b), F(vst21h), F(vst21w), NULL, }, | ||
552 | + { NULL, NULL, NULL, NULL }, | ||
553 | + { NULL, NULL, NULL, NULL }, | ||
554 | + }; | ||
555 | + if (a->qd > 6) { | ||
556 | + return false; | ||
557 | + } | ||
558 | + return do_vldst_il(s, a, fns[a->pat][a->size], 32); | ||
559 | +} | ||
560 | + | ||
561 | +static bool trans_VST4(DisasContext *s, arg_vldst_il *a) | ||
562 | +{ | ||
563 | + static MVEGenLdStIlFn * const fns[4][4] = { | ||
564 | + { F(vst40b), F(vst40h), F(vst40w), NULL, }, | ||
565 | + { F(vst41b), F(vst41h), F(vst41w), NULL, }, | ||
566 | + { F(vst42b), F(vst42h), F(vst42w), NULL, }, | ||
567 | + { F(vst43b), F(vst43h), F(vst43w), NULL, }, | ||
568 | + }; | ||
569 | + if (a->qd > 4) { | ||
570 | + return false; | ||
571 | + } | ||
572 | + return do_vldst_il(s, a, fns[a->pat][a->size], 64); | ||
573 | +} | ||
574 | + | ||
575 | +#undef F | ||
576 | + | ||
577 | static bool trans_VDUP(DisasContext *s, arg_VDUP *a) | ||
578 | { | ||
579 | TCGv_ptr qd; | ||
580 | -- | 98 | -- |
581 | 2.20.1 | 99 | 2.25.1 |
582 | |||
583 | diff view generated by jsdifflib |
1 | Unlike A-profile, for M-profile the UDIV and SDIV insns can be | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | configured to raise an exception on division by zero, using the CCR | ||
3 | DIV_0_TRP bit. | ||
4 | 2 | ||
5 | Implement support for setting this bit by making the helper functions | 3 | Move ARMCPRegInfo and all related declarations to a new |
6 | raise the appropriate exception. | 4 | internal header, out of the public cpu.h. |
7 | 5 | ||
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20220501055028.646596-2-richard.henderson@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20210730151636.17254-3-peter.maydell@linaro.org | ||
11 | --- | 11 | --- |
12 | target/arm/cpu.h | 1 + | 12 | target/arm/cpregs.h | 413 +++++++++++++++++++++++++++++++++++++ |
13 | target/arm/helper.h | 4 ++-- | 13 | target/arm/cpu.h | 368 --------------------------------- |
14 | target/arm/helper.c | 19 +++++++++++++++++-- | 14 | hw/arm/pxa2xx.c | 1 + |
15 | target/arm/m_helper.c | 4 ++++ | 15 | hw/arm/pxa2xx_pic.c | 1 + |
16 | target/arm/translate.c | 4 ++-- | 16 | hw/intc/arm_gicv3_cpuif.c | 1 + |
17 | 5 files changed, 26 insertions(+), 6 deletions(-) | 17 | hw/intc/arm_gicv3_kvm.c | 2 + |
18 | target/arm/cpu.c | 1 + | ||
19 | target/arm/cpu64.c | 1 + | ||
20 | target/arm/cpu_tcg.c | 1 + | ||
21 | target/arm/gdbstub.c | 3 +- | ||
22 | target/arm/helper.c | 1 + | ||
23 | target/arm/op_helper.c | 1 + | ||
24 | target/arm/translate-a64.c | 4 +- | ||
25 | target/arm/translate.c | 3 +- | ||
26 | 14 files changed, 427 insertions(+), 374 deletions(-) | ||
27 | create mode 100644 target/arm/cpregs.h | ||
18 | 28 | ||
29 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h | ||
30 | new file mode 100644 | ||
31 | index XXXXXXX..XXXXXXX | ||
32 | --- /dev/null | ||
33 | +++ b/target/arm/cpregs.h | ||
34 | @@ -XXX,XX +XXX,XX @@ | ||
35 | +/* | ||
36 | + * QEMU ARM CP Register access and descriptions | ||
37 | + * | ||
38 | + * Copyright (c) 2022 Linaro Ltd | ||
39 | + * | ||
40 | + * This program is free software; you can redistribute it and/or | ||
41 | + * modify it under the terms of the GNU General Public License | ||
42 | + * as published by the Free Software Foundation; either version 2 | ||
43 | + * of the License, or (at your option) any later version. | ||
44 | + * | ||
45 | + * This program is distributed in the hope that it will be useful, | ||
46 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
47 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
48 | + * GNU General Public License for more details. | ||
49 | + * | ||
50 | + * You should have received a copy of the GNU General Public License | ||
51 | + * along with this program; if not, see | ||
52 | + * <http://www.gnu.org/licenses/gpl-2.0.html> | ||
53 | + */ | ||
54 | + | ||
55 | +#ifndef TARGET_ARM_CPREGS_H | ||
56 | +#define TARGET_ARM_CPREGS_H | ||
57 | + | ||
58 | +/* | ||
59 | + * ARMCPRegInfo type field bits. If the SPECIAL bit is set this is a | ||
60 | + * special-behaviour cp reg and bits [11..8] indicate what behaviour | ||
61 | + * it has. Otherwise it is a simple cp reg, where CONST indicates that | ||
62 | + * TCG can assume the value to be constant (ie load at translate time) | ||
63 | + * and 64BIT indicates a 64 bit wide coprocessor register. SUPPRESS_TB_END | ||
64 | + * indicates that the TB should not be ended after a write to this register | ||
65 | + * (the default is that the TB ends after cp writes). OVERRIDE permits | ||
66 | + * a register definition to override a previous definition for the | ||
67 | + * same (cp, is64, crn, crm, opc1, opc2) tuple: either the new or the | ||
68 | + * old must have the OVERRIDE bit set. | ||
69 | + * ALIAS indicates that this register is an alias view of some underlying | ||
70 | + * state which is also visible via another register, and that the other | ||
71 | + * register is handling migration and reset; registers marked ALIAS will not be | ||
72 | + * migrated but may have their state set by syncing of register state from KVM. | ||
73 | + * NO_RAW indicates that this register has no underlying state and does not | ||
74 | + * support raw access for state saving/loading; it will not be used for either | ||
75 | + * migration or KVM state synchronization. (Typically this is for "registers" | ||
76 | + * which are actually used as instructions for cache maintenance and so on.) | ||
77 | + * IO indicates that this register does I/O and therefore its accesses | ||
78 | + * need to be marked with gen_io_start() and also end the TB. In particular, | ||
79 | + * registers which implement clocks or timers require this. | ||
80 | + * RAISES_EXC is for when the read or write hook might raise an exception; | ||
81 | + * the generated code will synchronize the CPU state before calling the hook | ||
82 | + * so that it is safe for the hook to call raise_exception(). | ||
83 | + * NEWEL is for writes to registers that might change the exception | ||
84 | + * level - typically on older ARM chips. For those cases we need to | ||
85 | + * re-read the new el when recomputing the translation flags. | ||
86 | + */ | ||
87 | +#define ARM_CP_SPECIAL 0x0001 | ||
88 | +#define ARM_CP_CONST 0x0002 | ||
89 | +#define ARM_CP_64BIT 0x0004 | ||
90 | +#define ARM_CP_SUPPRESS_TB_END 0x0008 | ||
91 | +#define ARM_CP_OVERRIDE 0x0010 | ||
92 | +#define ARM_CP_ALIAS 0x0020 | ||
93 | +#define ARM_CP_IO 0x0040 | ||
94 | +#define ARM_CP_NO_RAW 0x0080 | ||
95 | +#define ARM_CP_NOP (ARM_CP_SPECIAL | 0x0100) | ||
96 | +#define ARM_CP_WFI (ARM_CP_SPECIAL | 0x0200) | ||
97 | +#define ARM_CP_NZCV (ARM_CP_SPECIAL | 0x0300) | ||
98 | +#define ARM_CP_CURRENTEL (ARM_CP_SPECIAL | 0x0400) | ||
99 | +#define ARM_CP_DC_ZVA (ARM_CP_SPECIAL | 0x0500) | ||
100 | +#define ARM_CP_DC_GVA (ARM_CP_SPECIAL | 0x0600) | ||
101 | +#define ARM_CP_DC_GZVA (ARM_CP_SPECIAL | 0x0700) | ||
102 | +#define ARM_LAST_SPECIAL ARM_CP_DC_GZVA | ||
103 | +#define ARM_CP_FPU 0x1000 | ||
104 | +#define ARM_CP_SVE 0x2000 | ||
105 | +#define ARM_CP_NO_GDB 0x4000 | ||
106 | +#define ARM_CP_RAISES_EXC 0x8000 | ||
107 | +#define ARM_CP_NEWEL 0x10000 | ||
108 | +/* Used only as a terminator for ARMCPRegInfo lists */ | ||
109 | +#define ARM_CP_SENTINEL 0xfffff | ||
110 | +/* Mask of only the flag bits in a type field */ | ||
111 | +#define ARM_CP_FLAG_MASK 0x1f0ff | ||
112 | + | ||
113 | +/* | ||
114 | + * Valid values for ARMCPRegInfo state field, indicating which of | ||
115 | + * the AArch32 and AArch64 execution states this register is visible in. | ||
116 | + * If the reginfo doesn't explicitly specify then it is AArch32 only. | ||
117 | + * If the reginfo is declared to be visible in both states then a second | ||
118 | + * reginfo is synthesised for the AArch32 view of the AArch64 register, | ||
119 | + * such that the AArch32 view is the lower 32 bits of the AArch64 one. | ||
120 | + * Note that we rely on the values of these enums as we iterate through | ||
121 | + * the various states in some places. | ||
122 | + */ | ||
123 | +enum { | ||
124 | + ARM_CP_STATE_AA32 = 0, | ||
125 | + ARM_CP_STATE_AA64 = 1, | ||
126 | + ARM_CP_STATE_BOTH = 2, | ||
127 | +}; | ||
128 | + | ||
129 | +/* | ||
130 | + * ARM CP register secure state flags. These flags identify security state | ||
131 | + * attributes for a given CP register entry. | ||
132 | + * The existence of both or neither secure and non-secure flags indicates that | ||
133 | + * the register has both a secure and non-secure hash entry. A single one of | ||
134 | + * these flags causes the register to only be hashed for the specified | ||
135 | + * security state. | ||
136 | + * Although definitions may have any combination of the S/NS bits, each | ||
137 | + * registered entry will only have one to identify whether the entry is secure | ||
138 | + * or non-secure. | ||
139 | + */ | ||
140 | +enum { | ||
141 | + ARM_CP_SECSTATE_S = (1 << 0), /* bit[0]: Secure state register */ | ||
142 | + ARM_CP_SECSTATE_NS = (1 << 1), /* bit[1]: Non-secure state register */ | ||
143 | +}; | ||
144 | + | ||
145 | +/* | ||
146 | + * Return true if cptype is a valid type field. This is used to try to | ||
147 | + * catch errors where the sentinel has been accidentally left off the end | ||
148 | + * of a list of registers. | ||
149 | + */ | ||
150 | +static inline bool cptype_valid(int cptype) | ||
151 | +{ | ||
152 | + return ((cptype & ~ARM_CP_FLAG_MASK) == 0) | ||
153 | + || ((cptype & ARM_CP_SPECIAL) && | ||
154 | + ((cptype & ~ARM_CP_FLAG_MASK) <= ARM_LAST_SPECIAL)); | ||
155 | +} | ||
156 | + | ||
157 | +/* | ||
158 | + * Access rights: | ||
159 | + * We define bits for Read and Write access for what rev C of the v7-AR ARM ARM | ||
160 | + * defines as PL0 (user), PL1 (fiq/irq/svc/abt/und/sys, ie privileged), and | ||
161 | + * PL2 (hyp). The other level which has Read and Write bits is Secure PL1 | ||
162 | + * (ie any of the privileged modes in Secure state, or Monitor mode). | ||
163 | + * If a register is accessible in one privilege level it's always accessible | ||
164 | + * in higher privilege levels too. Since "Secure PL1" also follows this rule | ||
165 | + * (ie anything visible in PL2 is visible in S-PL1, some things are only | ||
166 | + * visible in S-PL1) but "Secure PL1" is a bit of a mouthful, we bend the | ||
167 | + * terminology a little and call this PL3. | ||
168 | + * In AArch64 things are somewhat simpler as the PLx bits line up exactly | ||
169 | + * with the ELx exception levels. | ||
170 | + * | ||
171 | + * If access permissions for a register are more complex than can be | ||
172 | + * described with these bits, then use a laxer set of restrictions, and | ||
173 | + * do the more restrictive/complex check inside a helper function. | ||
174 | + */ | ||
175 | +#define PL3_R 0x80 | ||
176 | +#define PL3_W 0x40 | ||
177 | +#define PL2_R (0x20 | PL3_R) | ||
178 | +#define PL2_W (0x10 | PL3_W) | ||
179 | +#define PL1_R (0x08 | PL2_R) | ||
180 | +#define PL1_W (0x04 | PL2_W) | ||
181 | +#define PL0_R (0x02 | PL1_R) | ||
182 | +#define PL0_W (0x01 | PL1_W) | ||
183 | + | ||
184 | +/* | ||
185 | + * For user-mode some registers are accessible to EL0 via a kernel | ||
186 | + * trap-and-emulate ABI. In this case we define the read permissions | ||
187 | + * as actually being PL0_R. However some bits of any given register | ||
188 | + * may still be masked. | ||
189 | + */ | ||
190 | +#ifdef CONFIG_USER_ONLY | ||
191 | +#define PL0U_R PL0_R | ||
192 | +#else | ||
193 | +#define PL0U_R PL1_R | ||
194 | +#endif | ||
195 | + | ||
196 | +#define PL3_RW (PL3_R | PL3_W) | ||
197 | +#define PL2_RW (PL2_R | PL2_W) | ||
198 | +#define PL1_RW (PL1_R | PL1_W) | ||
199 | +#define PL0_RW (PL0_R | PL0_W) | ||
200 | + | ||
201 | +typedef enum CPAccessResult { | ||
202 | + /* Access is permitted */ | ||
203 | + CP_ACCESS_OK = 0, | ||
204 | + /* | ||
205 | + * Access fails due to a configurable trap or enable which would | ||
206 | + * result in a categorized exception syndrome giving information about | ||
207 | + * the failing instruction (ie syndrome category 0x3, 0x4, 0x5, 0x6, | ||
208 | + * 0xc or 0x18). The exception is taken to the usual target EL (EL1 or | ||
209 | + * PL1 if in EL0, otherwise to the current EL). | ||
210 | + */ | ||
211 | + CP_ACCESS_TRAP = 1, | ||
212 | + /* | ||
213 | + * Access fails and results in an exception syndrome 0x0 ("uncategorized"). | ||
214 | + * Note that this is not a catch-all case -- the set of cases which may | ||
215 | + * result in this failure is specifically defined by the architecture. | ||
216 | + */ | ||
217 | + CP_ACCESS_TRAP_UNCATEGORIZED = 2, | ||
218 | + /* As CP_ACCESS_TRAP, but for traps directly to EL2 or EL3 */ | ||
219 | + CP_ACCESS_TRAP_EL2 = 3, | ||
220 | + CP_ACCESS_TRAP_EL3 = 4, | ||
221 | + /* As CP_ACCESS_UNCATEGORIZED, but for traps directly to EL2 or EL3 */ | ||
222 | + CP_ACCESS_TRAP_UNCATEGORIZED_EL2 = 5, | ||
223 | + CP_ACCESS_TRAP_UNCATEGORIZED_EL3 = 6, | ||
224 | +} CPAccessResult; | ||
225 | + | ||
226 | +typedef struct ARMCPRegInfo ARMCPRegInfo; | ||
227 | + | ||
228 | +/* | ||
229 | + * Access functions for coprocessor registers. These cannot fail and | ||
230 | + * may not raise exceptions. | ||
231 | + */ | ||
232 | +typedef uint64_t CPReadFn(CPUARMState *env, const ARMCPRegInfo *opaque); | ||
233 | +typedef void CPWriteFn(CPUARMState *env, const ARMCPRegInfo *opaque, | ||
234 | + uint64_t value); | ||
235 | +/* Access permission check functions for coprocessor registers. */ | ||
236 | +typedef CPAccessResult CPAccessFn(CPUARMState *env, | ||
237 | + const ARMCPRegInfo *opaque, | ||
238 | + bool isread); | ||
239 | +/* Hook function for register reset */ | ||
240 | +typedef void CPResetFn(CPUARMState *env, const ARMCPRegInfo *opaque); | ||
241 | + | ||
242 | +#define CP_ANY 0xff | ||
243 | + | ||
244 | +/* Definition of an ARM coprocessor register */ | ||
245 | +struct ARMCPRegInfo { | ||
246 | + /* Name of register (useful mainly for debugging, need not be unique) */ | ||
247 | + const char *name; | ||
248 | + /* | ||
249 | + * Location of register: coprocessor number and (crn,crm,opc1,opc2) | ||
250 | + * tuple. Any of crm, opc1 and opc2 may be CP_ANY to indicate a | ||
251 | + * 'wildcard' field -- any value of that field in the MRC/MCR insn | ||
252 | + * will be decoded to this register. The register read and write | ||
253 | + * callbacks will be passed an ARMCPRegInfo with the crn/crm/opc1/opc2 | ||
254 | + * used by the program, so it is possible to register a wildcard and | ||
255 | + * then behave differently on read/write if necessary. | ||
256 | + * For 64 bit registers, only crm and opc1 are relevant; crn and opc2 | ||
257 | + * must both be zero. | ||
258 | + * For AArch64-visible registers, opc0 is also used. | ||
259 | + * Since there are no "coprocessors" in AArch64, cp is purely used as a | ||
260 | + * way to distinguish (for KVM's benefit) guest-visible system registers | ||
261 | + * from demuxed ones provided to preserve the "no side effects on | ||
262 | + * KVM register read/write from QEMU" semantics. cp==0x13 is guest | ||
263 | + * visible (to match KVM's encoding); cp==0 will be converted to | ||
264 | + * cp==0x13 when the ARMCPRegInfo is registered, for convenience. | ||
265 | + */ | ||
266 | + uint8_t cp; | ||
267 | + uint8_t crn; | ||
268 | + uint8_t crm; | ||
269 | + uint8_t opc0; | ||
270 | + uint8_t opc1; | ||
271 | + uint8_t opc2; | ||
272 | + /* Execution state in which this register is visible: ARM_CP_STATE_* */ | ||
273 | + int state; | ||
274 | + /* Register type: ARM_CP_* bits/values */ | ||
275 | + int type; | ||
276 | + /* Access rights: PL*_[RW] */ | ||
277 | + int access; | ||
278 | + /* Security state: ARM_CP_SECSTATE_* bits/values */ | ||
279 | + int secure; | ||
280 | + /* | ||
281 | + * The opaque pointer passed to define_arm_cp_regs_with_opaque() when | ||
282 | + * this register was defined: can be used to hand data through to the | ||
283 | + * register read/write functions, since they are passed the ARMCPRegInfo*. | ||
284 | + */ | ||
285 | + void *opaque; | ||
286 | + /* | ||
287 | + * Value of this register, if it is ARM_CP_CONST. Otherwise, if | ||
288 | + * fieldoffset is non-zero, the reset value of the register. | ||
289 | + */ | ||
290 | + uint64_t resetvalue; | ||
291 | + /* | ||
292 | + * Offset of the field in CPUARMState for this register. | ||
293 | + * This is not needed if either: | ||
294 | + * 1. type is ARM_CP_CONST or one of the ARM_CP_SPECIALs | ||
295 | + * 2. both readfn and writefn are specified | ||
296 | + */ | ||
297 | + ptrdiff_t fieldoffset; /* offsetof(CPUARMState, field) */ | ||
298 | + | ||
299 | + /* | ||
300 | + * Offsets of the secure and non-secure fields in CPUARMState for the | ||
301 | + * register if it is banked. These fields are only used during the static | ||
302 | + * registration of a register. During hashing the bank associated | ||
303 | + * with a given security state is copied to fieldoffset which is used from | ||
304 | + * there on out. | ||
305 | + * | ||
306 | + * It is expected that register definitions use either fieldoffset or | ||
307 | + * bank_fieldoffsets in the definition but not both. It is also expected | ||
308 | + * that both bank offsets are set when defining a banked register. This | ||
309 | + * use indicates that a register is banked. | ||
310 | + */ | ||
311 | + ptrdiff_t bank_fieldoffsets[2]; | ||
312 | + | ||
313 | + /* | ||
314 | + * Function for making any access checks for this register in addition to | ||
315 | + * those specified by the 'access' permissions bits. If NULL, no extra | ||
316 | + * checks required. The access check is performed at runtime, not at | ||
317 | + * translate time. | ||
318 | + */ | ||
319 | + CPAccessFn *accessfn; | ||
320 | + /* | ||
321 | + * Function for handling reads of this register. If NULL, then reads | ||
322 | + * will be done by loading from the offset into CPUARMState specified | ||
323 | + * by fieldoffset. | ||
324 | + */ | ||
325 | + CPReadFn *readfn; | ||
326 | + /* | ||
327 | + * Function for handling writes of this register. If NULL, then writes | ||
328 | + * will be done by writing to the offset into CPUARMState specified | ||
329 | + * by fieldoffset. | ||
330 | + */ | ||
331 | + CPWriteFn *writefn; | ||
332 | + /* | ||
333 | + * Function for doing a "raw" read; used when we need to copy | ||
334 | + * coprocessor state to the kernel for KVM or out for | ||
335 | + * migration. This only needs to be provided if there is also a | ||
336 | + * readfn and it has side effects (for instance clear-on-read bits). | ||
337 | + */ | ||
338 | + CPReadFn *raw_readfn; | ||
339 | + /* | ||
340 | + * Function for doing a "raw" write; used when we need to copy KVM | ||
341 | + * kernel coprocessor state into userspace, or for inbound | ||
342 | + * migration. This only needs to be provided if there is also a | ||
343 | + * writefn and it masks out "unwritable" bits or has write-one-to-clear | ||
344 | + * or similar behaviour. | ||
345 | + */ | ||
346 | + CPWriteFn *raw_writefn; | ||
347 | + /* | ||
348 | + * Function for resetting the register. If NULL, then reset will be done | ||
349 | + * by writing resetvalue to the field specified in fieldoffset. If | ||
350 | + * fieldoffset is 0 then no reset will be done. | ||
351 | + */ | ||
352 | + CPResetFn *resetfn; | ||
353 | + | ||
354 | + /* | ||
355 | + * "Original" writefn and readfn. | ||
356 | + * For ARMv8.1-VHE register aliases, we overwrite the read/write | ||
357 | + * accessor functions of various EL1/EL0 to perform the runtime | ||
358 | + * check for which sysreg should actually be modified, and then | ||
359 | + * forwards the operation. Before overwriting the accessors, | ||
360 | + * the original function is copied here, so that accesses that | ||
361 | + * really do go to the EL1/EL0 version proceed normally. | ||
362 | + * (The corresponding EL2 register is linked via opaque.) | ||
363 | + */ | ||
364 | + CPReadFn *orig_readfn; | ||
365 | + CPWriteFn *orig_writefn; | ||
366 | +}; | ||
367 | + | ||
368 | +/* | ||
369 | + * Macros which are lvalues for the field in CPUARMState for the | ||
370 | + * ARMCPRegInfo *ri. | ||
371 | + */ | ||
372 | +#define CPREG_FIELD32(env, ri) \ | ||
373 | + (*(uint32_t *)((char *)(env) + (ri)->fieldoffset)) | ||
374 | +#define CPREG_FIELD64(env, ri) \ | ||
375 | + (*(uint64_t *)((char *)(env) + (ri)->fieldoffset)) | ||
376 | + | ||
377 | +#define REGINFO_SENTINEL { .type = ARM_CP_SENTINEL } | ||
378 | + | ||
379 | +void define_arm_cp_regs_with_opaque(ARMCPU *cpu, | ||
380 | + const ARMCPRegInfo *regs, void *opaque); | ||
381 | +void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, | ||
382 | + const ARMCPRegInfo *regs, void *opaque); | ||
383 | +static inline void define_arm_cp_regs(ARMCPU *cpu, const ARMCPRegInfo *regs) | ||
384 | +{ | ||
385 | + define_arm_cp_regs_with_opaque(cpu, regs, 0); | ||
386 | +} | ||
387 | +static inline void define_one_arm_cp_reg(ARMCPU *cpu, const ARMCPRegInfo *regs) | ||
388 | +{ | ||
389 | + define_one_arm_cp_reg_with_opaque(cpu, regs, 0); | ||
390 | +} | ||
391 | +const ARMCPRegInfo *get_arm_cp_reginfo(GHashTable *cpregs, uint32_t encoded_cp); | ||
392 | + | ||
393 | +/* | ||
394 | + * Definition of an ARM co-processor register as viewed from | ||
395 | + * userspace. This is used for presenting sanitised versions of | ||
396 | + * registers to userspace when emulating the Linux AArch64 CPU | ||
397 | + * ID/feature ABI (advertised as HWCAP_CPUID). | ||
398 | + */ | ||
399 | +typedef struct ARMCPRegUserSpaceInfo { | ||
400 | + /* Name of register */ | ||
401 | + const char *name; | ||
402 | + | ||
403 | + /* Is the name actually a glob pattern */ | ||
404 | + bool is_glob; | ||
405 | + | ||
406 | + /* Only some bits are exported to user space */ | ||
407 | + uint64_t exported_bits; | ||
408 | + | ||
409 | + /* Fixed bits are applied after the mask */ | ||
410 | + uint64_t fixed_bits; | ||
411 | +} ARMCPRegUserSpaceInfo; | ||
412 | + | ||
413 | +#define REGUSERINFO_SENTINEL { .name = NULL } | ||
414 | + | ||
415 | +void modify_arm_cp_regs(ARMCPRegInfo *regs, const ARMCPRegUserSpaceInfo *mods); | ||
416 | + | ||
417 | +/* CPWriteFn that can be used to implement writes-ignored behaviour */ | ||
418 | +void arm_cp_write_ignore(CPUARMState *env, const ARMCPRegInfo *ri, | ||
419 | + uint64_t value); | ||
420 | +/* CPReadFn that can be used for read-as-zero behaviour */ | ||
421 | +uint64_t arm_cp_read_zero(CPUARMState *env, const ARMCPRegInfo *ri); | ||
422 | + | ||
423 | +/* | ||
424 | + * CPResetFn that does nothing, for use if no reset is required even | ||
425 | + * if fieldoffset is non zero. | ||
426 | + */ | ||
427 | +void arm_cp_reset_ignore(CPUARMState *env, const ARMCPRegInfo *opaque); | ||
428 | + | ||
429 | +/* | ||
430 | + * Return true if this reginfo struct's field in the cpu state struct | ||
431 | + * is 64 bits wide. | ||
432 | + */ | ||
433 | +static inline bool cpreg_field_is_64bit(const ARMCPRegInfo *ri) | ||
434 | +{ | ||
435 | + return (ri->state == ARM_CP_STATE_AA64) || (ri->type & ARM_CP_64BIT); | ||
436 | +} | ||
437 | + | ||
438 | +static inline bool cp_access_ok(int current_el, | ||
439 | + const ARMCPRegInfo *ri, int isread) | ||
440 | +{ | ||
441 | + return (ri->access >> ((current_el * 2) + isread)) & 1; | ||
442 | +} | ||
443 | + | ||
444 | +/* Raw read of a coprocessor register (as needed for migration, etc) */ | ||
445 | +uint64_t read_raw_cp_reg(CPUARMState *env, const ARMCPRegInfo *ri); | ||
446 | + | ||
447 | +#endif /* TARGET_ARM_CPREGS_H */ | ||
19 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 448 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
20 | index XXXXXXX..XXXXXXX 100644 | 449 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/cpu.h | 450 | --- a/target/arm/cpu.h |
22 | +++ b/target/arm/cpu.h | 451 | +++ b/target/arm/cpu.h |
23 | @@ -XXX,XX +XXX,XX @@ | 452 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid) |
24 | #define EXCP_LAZYFP 20 /* v7M fault during lazy FP stacking */ | 453 | return kvmid; |
25 | #define EXCP_LSERR 21 /* v8M LSERR SecureFault */ | 454 | } |
26 | #define EXCP_UNALIGNED 22 /* v7M UNALIGNED UsageFault */ | 455 | |
27 | +#define EXCP_DIVBYZERO 23 /* v7M DIVBYZERO UsageFault */ | 456 | -/* ARMCPRegInfo type field bits. If the SPECIAL bit is set this is a |
28 | /* NB: add new EXCP_ defines to the array in arm_log_exception() too */ | 457 | - * special-behaviour cp reg and bits [11..8] indicate what behaviour |
29 | 458 | - * it has. Otherwise it is a simple cp reg, where CONST indicates that | |
30 | #define ARMV7M_EXCP_RESET 1 | 459 | - * TCG can assume the value to be constant (ie load at translate time) |
31 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 460 | - * and 64BIT indicates a 64 bit wide coprocessor register. SUPPRESS_TB_END |
32 | index XXXXXXX..XXXXXXX 100644 | 461 | - * indicates that the TB should not be ended after a write to this register |
33 | --- a/target/arm/helper.h | 462 | - * (the default is that the TB ends after cp writes). OVERRIDE permits |
34 | +++ b/target/arm/helper.h | 463 | - * a register definition to override a previous definition for the |
35 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(add_saturate, i32, env, i32, i32) | 464 | - * same (cp, is64, crn, crm, opc1, opc2) tuple: either the new or the |
36 | DEF_HELPER_3(sub_saturate, i32, env, i32, i32) | 465 | - * old must have the OVERRIDE bit set. |
37 | DEF_HELPER_3(add_usaturate, i32, env, i32, i32) | 466 | - * ALIAS indicates that this register is an alias view of some underlying |
38 | DEF_HELPER_3(sub_usaturate, i32, env, i32, i32) | 467 | - * state which is also visible via another register, and that the other |
39 | -DEF_HELPER_FLAGS_2(sdiv, TCG_CALL_NO_RWG_SE, s32, s32, s32) | 468 | - * register is handling migration and reset; registers marked ALIAS will not be |
40 | -DEF_HELPER_FLAGS_2(udiv, TCG_CALL_NO_RWG_SE, i32, i32, i32) | 469 | - * migrated but may have their state set by syncing of register state from KVM. |
41 | +DEF_HELPER_FLAGS_3(sdiv, TCG_CALL_NO_RWG, s32, env, s32, s32) | 470 | - * NO_RAW indicates that this register has no underlying state and does not |
42 | +DEF_HELPER_FLAGS_3(udiv, TCG_CALL_NO_RWG, i32, env, i32, i32) | 471 | - * support raw access for state saving/loading; it will not be used for either |
43 | DEF_HELPER_FLAGS_1(rbit, TCG_CALL_NO_RWG_SE, i32, i32) | 472 | - * migration or KVM state synchronization. (Typically this is for "registers" |
44 | 473 | - * which are actually used as instructions for cache maintenance and so on.) | |
45 | #define PAS_OP(pfx) \ | 474 | - * IO indicates that this register does I/O and therefore its accesses |
475 | - * need to be marked with gen_io_start() and also end the TB. In particular, | ||
476 | - * registers which implement clocks or timers require this. | ||
477 | - * RAISES_EXC is for when the read or write hook might raise an exception; | ||
478 | - * the generated code will synchronize the CPU state before calling the hook | ||
479 | - * so that it is safe for the hook to call raise_exception(). | ||
480 | - * NEWEL is for writes to registers that might change the exception | ||
481 | - * level - typically on older ARM chips. For those cases we need to | ||
482 | - * re-read the new el when recomputing the translation flags. | ||
483 | - */ | ||
484 | -#define ARM_CP_SPECIAL 0x0001 | ||
485 | -#define ARM_CP_CONST 0x0002 | ||
486 | -#define ARM_CP_64BIT 0x0004 | ||
487 | -#define ARM_CP_SUPPRESS_TB_END 0x0008 | ||
488 | -#define ARM_CP_OVERRIDE 0x0010 | ||
489 | -#define ARM_CP_ALIAS 0x0020 | ||
490 | -#define ARM_CP_IO 0x0040 | ||
491 | -#define ARM_CP_NO_RAW 0x0080 | ||
492 | -#define ARM_CP_NOP (ARM_CP_SPECIAL | 0x0100) | ||
493 | -#define ARM_CP_WFI (ARM_CP_SPECIAL | 0x0200) | ||
494 | -#define ARM_CP_NZCV (ARM_CP_SPECIAL | 0x0300) | ||
495 | -#define ARM_CP_CURRENTEL (ARM_CP_SPECIAL | 0x0400) | ||
496 | -#define ARM_CP_DC_ZVA (ARM_CP_SPECIAL | 0x0500) | ||
497 | -#define ARM_CP_DC_GVA (ARM_CP_SPECIAL | 0x0600) | ||
498 | -#define ARM_CP_DC_GZVA (ARM_CP_SPECIAL | 0x0700) | ||
499 | -#define ARM_LAST_SPECIAL ARM_CP_DC_GZVA | ||
500 | -#define ARM_CP_FPU 0x1000 | ||
501 | -#define ARM_CP_SVE 0x2000 | ||
502 | -#define ARM_CP_NO_GDB 0x4000 | ||
503 | -#define ARM_CP_RAISES_EXC 0x8000 | ||
504 | -#define ARM_CP_NEWEL 0x10000 | ||
505 | -/* Used only as a terminator for ARMCPRegInfo lists */ | ||
506 | -#define ARM_CP_SENTINEL 0xfffff | ||
507 | -/* Mask of only the flag bits in a type field */ | ||
508 | -#define ARM_CP_FLAG_MASK 0x1f0ff | ||
509 | - | ||
510 | -/* Valid values for ARMCPRegInfo state field, indicating which of | ||
511 | - * the AArch32 and AArch64 execution states this register is visible in. | ||
512 | - * If the reginfo doesn't explicitly specify then it is AArch32 only. | ||
513 | - * If the reginfo is declared to be visible in both states then a second | ||
514 | - * reginfo is synthesised for the AArch32 view of the AArch64 register, | ||
515 | - * such that the AArch32 view is the lower 32 bits of the AArch64 one. | ||
516 | - * Note that we rely on the values of these enums as we iterate through | ||
517 | - * the various states in some places. | ||
518 | - */ | ||
519 | -enum { | ||
520 | - ARM_CP_STATE_AA32 = 0, | ||
521 | - ARM_CP_STATE_AA64 = 1, | ||
522 | - ARM_CP_STATE_BOTH = 2, | ||
523 | -}; | ||
524 | - | ||
525 | -/* ARM CP register secure state flags. These flags identify security state | ||
526 | - * attributes for a given CP register entry. | ||
527 | - * The existence of both or neither secure and non-secure flags indicates that | ||
528 | - * the register has both a secure and non-secure hash entry. A single one of | ||
529 | - * these flags causes the register to only be hashed for the specified | ||
530 | - * security state. | ||
531 | - * Although definitions may have any combination of the S/NS bits, each | ||
532 | - * registered entry will only have one to identify whether the entry is secure | ||
533 | - * or non-secure. | ||
534 | - */ | ||
535 | -enum { | ||
536 | - ARM_CP_SECSTATE_S = (1 << 0), /* bit[0]: Secure state register */ | ||
537 | - ARM_CP_SECSTATE_NS = (1 << 1), /* bit[1]: Non-secure state register */ | ||
538 | -}; | ||
539 | - | ||
540 | -/* Return true if cptype is a valid type field. This is used to try to | ||
541 | - * catch errors where the sentinel has been accidentally left off the end | ||
542 | - * of a list of registers. | ||
543 | - */ | ||
544 | -static inline bool cptype_valid(int cptype) | ||
545 | -{ | ||
546 | - return ((cptype & ~ARM_CP_FLAG_MASK) == 0) | ||
547 | - || ((cptype & ARM_CP_SPECIAL) && | ||
548 | - ((cptype & ~ARM_CP_FLAG_MASK) <= ARM_LAST_SPECIAL)); | ||
549 | -} | ||
550 | - | ||
551 | -/* Access rights: | ||
552 | - * We define bits for Read and Write access for what rev C of the v7-AR ARM ARM | ||
553 | - * defines as PL0 (user), PL1 (fiq/irq/svc/abt/und/sys, ie privileged), and | ||
554 | - * PL2 (hyp). The other level which has Read and Write bits is Secure PL1 | ||
555 | - * (ie any of the privileged modes in Secure state, or Monitor mode). | ||
556 | - * If a register is accessible in one privilege level it's always accessible | ||
557 | - * in higher privilege levels too. Since "Secure PL1" also follows this rule | ||
558 | - * (ie anything visible in PL2 is visible in S-PL1, some things are only | ||
559 | - * visible in S-PL1) but "Secure PL1" is a bit of a mouthful, we bend the | ||
560 | - * terminology a little and call this PL3. | ||
561 | - * In AArch64 things are somewhat simpler as the PLx bits line up exactly | ||
562 | - * with the ELx exception levels. | ||
563 | - * | ||
564 | - * If access permissions for a register are more complex than can be | ||
565 | - * described with these bits, then use a laxer set of restrictions, and | ||
566 | - * do the more restrictive/complex check inside a helper function. | ||
567 | - */ | ||
568 | -#define PL3_R 0x80 | ||
569 | -#define PL3_W 0x40 | ||
570 | -#define PL2_R (0x20 | PL3_R) | ||
571 | -#define PL2_W (0x10 | PL3_W) | ||
572 | -#define PL1_R (0x08 | PL2_R) | ||
573 | -#define PL1_W (0x04 | PL2_W) | ||
574 | -#define PL0_R (0x02 | PL1_R) | ||
575 | -#define PL0_W (0x01 | PL1_W) | ||
576 | - | ||
577 | -/* | ||
578 | - * For user-mode some registers are accessible to EL0 via a kernel | ||
579 | - * trap-and-emulate ABI. In this case we define the read permissions | ||
580 | - * as actually being PL0_R. However some bits of any given register | ||
581 | - * may still be masked. | ||
582 | - */ | ||
583 | -#ifdef CONFIG_USER_ONLY | ||
584 | -#define PL0U_R PL0_R | ||
585 | -#else | ||
586 | -#define PL0U_R PL1_R | ||
587 | -#endif | ||
588 | - | ||
589 | -#define PL3_RW (PL3_R | PL3_W) | ||
590 | -#define PL2_RW (PL2_R | PL2_W) | ||
591 | -#define PL1_RW (PL1_R | PL1_W) | ||
592 | -#define PL0_RW (PL0_R | PL0_W) | ||
593 | - | ||
594 | /* Return the highest implemented Exception Level */ | ||
595 | static inline int arm_highest_el(CPUARMState *env) | ||
596 | { | ||
597 | @@ -XXX,XX +XXX,XX @@ static inline int arm_current_el(CPUARMState *env) | ||
598 | } | ||
599 | } | ||
600 | |||
601 | -typedef struct ARMCPRegInfo ARMCPRegInfo; | ||
602 | - | ||
603 | -typedef enum CPAccessResult { | ||
604 | - /* Access is permitted */ | ||
605 | - CP_ACCESS_OK = 0, | ||
606 | - /* Access fails due to a configurable trap or enable which would | ||
607 | - * result in a categorized exception syndrome giving information about | ||
608 | - * the failing instruction (ie syndrome category 0x3, 0x4, 0x5, 0x6, | ||
609 | - * 0xc or 0x18). The exception is taken to the usual target EL (EL1 or | ||
610 | - * PL1 if in EL0, otherwise to the current EL). | ||
611 | - */ | ||
612 | - CP_ACCESS_TRAP = 1, | ||
613 | - /* Access fails and results in an exception syndrome 0x0 ("uncategorized"). | ||
614 | - * Note that this is not a catch-all case -- the set of cases which may | ||
615 | - * result in this failure is specifically defined by the architecture. | ||
616 | - */ | ||
617 | - CP_ACCESS_TRAP_UNCATEGORIZED = 2, | ||
618 | - /* As CP_ACCESS_TRAP, but for traps directly to EL2 or EL3 */ | ||
619 | - CP_ACCESS_TRAP_EL2 = 3, | ||
620 | - CP_ACCESS_TRAP_EL3 = 4, | ||
621 | - /* As CP_ACCESS_UNCATEGORIZED, but for traps directly to EL2 or EL3 */ | ||
622 | - CP_ACCESS_TRAP_UNCATEGORIZED_EL2 = 5, | ||
623 | - CP_ACCESS_TRAP_UNCATEGORIZED_EL3 = 6, | ||
624 | -} CPAccessResult; | ||
625 | - | ||
626 | -/* Access functions for coprocessor registers. These cannot fail and | ||
627 | - * may not raise exceptions. | ||
628 | - */ | ||
629 | -typedef uint64_t CPReadFn(CPUARMState *env, const ARMCPRegInfo *opaque); | ||
630 | -typedef void CPWriteFn(CPUARMState *env, const ARMCPRegInfo *opaque, | ||
631 | - uint64_t value); | ||
632 | -/* Access permission check functions for coprocessor registers. */ | ||
633 | -typedef CPAccessResult CPAccessFn(CPUARMState *env, | ||
634 | - const ARMCPRegInfo *opaque, | ||
635 | - bool isread); | ||
636 | -/* Hook function for register reset */ | ||
637 | -typedef void CPResetFn(CPUARMState *env, const ARMCPRegInfo *opaque); | ||
638 | - | ||
639 | -#define CP_ANY 0xff | ||
640 | - | ||
641 | -/* Definition of an ARM coprocessor register */ | ||
642 | -struct ARMCPRegInfo { | ||
643 | - /* Name of register (useful mainly for debugging, need not be unique) */ | ||
644 | - const char *name; | ||
645 | - /* Location of register: coprocessor number and (crn,crm,opc1,opc2) | ||
646 | - * tuple. Any of crm, opc1 and opc2 may be CP_ANY to indicate a | ||
647 | - * 'wildcard' field -- any value of that field in the MRC/MCR insn | ||
648 | - * will be decoded to this register. The register read and write | ||
649 | - * callbacks will be passed an ARMCPRegInfo with the crn/crm/opc1/opc2 | ||
650 | - * used by the program, so it is possible to register a wildcard and | ||
651 | - * then behave differently on read/write if necessary. | ||
652 | - * For 64 bit registers, only crm and opc1 are relevant; crn and opc2 | ||
653 | - * must both be zero. | ||
654 | - * For AArch64-visible registers, opc0 is also used. | ||
655 | - * Since there are no "coprocessors" in AArch64, cp is purely used as a | ||
656 | - * way to distinguish (for KVM's benefit) guest-visible system registers | ||
657 | - * from demuxed ones provided to preserve the "no side effects on | ||
658 | - * KVM register read/write from QEMU" semantics. cp==0x13 is guest | ||
659 | - * visible (to match KVM's encoding); cp==0 will be converted to | ||
660 | - * cp==0x13 when the ARMCPRegInfo is registered, for convenience. | ||
661 | - */ | ||
662 | - uint8_t cp; | ||
663 | - uint8_t crn; | ||
664 | - uint8_t crm; | ||
665 | - uint8_t opc0; | ||
666 | - uint8_t opc1; | ||
667 | - uint8_t opc2; | ||
668 | - /* Execution state in which this register is visible: ARM_CP_STATE_* */ | ||
669 | - int state; | ||
670 | - /* Register type: ARM_CP_* bits/values */ | ||
671 | - int type; | ||
672 | - /* Access rights: PL*_[RW] */ | ||
673 | - int access; | ||
674 | - /* Security state: ARM_CP_SECSTATE_* bits/values */ | ||
675 | - int secure; | ||
676 | - /* The opaque pointer passed to define_arm_cp_regs_with_opaque() when | ||
677 | - * this register was defined: can be used to hand data through to the | ||
678 | - * register read/write functions, since they are passed the ARMCPRegInfo*. | ||
679 | - */ | ||
680 | - void *opaque; | ||
681 | - /* Value of this register, if it is ARM_CP_CONST. Otherwise, if | ||
682 | - * fieldoffset is non-zero, the reset value of the register. | ||
683 | - */ | ||
684 | - uint64_t resetvalue; | ||
685 | - /* Offset of the field in CPUARMState for this register. | ||
686 | - * | ||
687 | - * This is not needed if either: | ||
688 | - * 1. type is ARM_CP_CONST or one of the ARM_CP_SPECIALs | ||
689 | - * 2. both readfn and writefn are specified | ||
690 | - */ | ||
691 | - ptrdiff_t fieldoffset; /* offsetof(CPUARMState, field) */ | ||
692 | - | ||
693 | - /* Offsets of the secure and non-secure fields in CPUARMState for the | ||
694 | - * register if it is banked. These fields are only used during the static | ||
695 | - * registration of a register. During hashing the bank associated | ||
696 | - * with a given security state is copied to fieldoffset which is used from | ||
697 | - * there on out. | ||
698 | - * | ||
699 | - * It is expected that register definitions use either fieldoffset or | ||
700 | - * bank_fieldoffsets in the definition but not both. It is also expected | ||
701 | - * that both bank offsets are set when defining a banked register. This | ||
702 | - * use indicates that a register is banked. | ||
703 | - */ | ||
704 | - ptrdiff_t bank_fieldoffsets[2]; | ||
705 | - | ||
706 | - /* Function for making any access checks for this register in addition to | ||
707 | - * those specified by the 'access' permissions bits. If NULL, no extra | ||
708 | - * checks required. The access check is performed at runtime, not at | ||
709 | - * translate time. | ||
710 | - */ | ||
711 | - CPAccessFn *accessfn; | ||
712 | - /* Function for handling reads of this register. If NULL, then reads | ||
713 | - * will be done by loading from the offset into CPUARMState specified | ||
714 | - * by fieldoffset. | ||
715 | - */ | ||
716 | - CPReadFn *readfn; | ||
717 | - /* Function for handling writes of this register. If NULL, then writes | ||
718 | - * will be done by writing to the offset into CPUARMState specified | ||
719 | - * by fieldoffset. | ||
720 | - */ | ||
721 | - CPWriteFn *writefn; | ||
722 | - /* Function for doing a "raw" read; used when we need to copy | ||
723 | - * coprocessor state to the kernel for KVM or out for | ||
724 | - * migration. This only needs to be provided if there is also a | ||
725 | - * readfn and it has side effects (for instance clear-on-read bits). | ||
726 | - */ | ||
727 | - CPReadFn *raw_readfn; | ||
728 | - /* Function for doing a "raw" write; used when we need to copy KVM | ||
729 | - * kernel coprocessor state into userspace, or for inbound | ||
730 | - * migration. This only needs to be provided if there is also a | ||
731 | - * writefn and it masks out "unwritable" bits or has write-one-to-clear | ||
732 | - * or similar behaviour. | ||
733 | - */ | ||
734 | - CPWriteFn *raw_writefn; | ||
735 | - /* Function for resetting the register. If NULL, then reset will be done | ||
736 | - * by writing resetvalue to the field specified in fieldoffset. If | ||
737 | - * fieldoffset is 0 then no reset will be done. | ||
738 | - */ | ||
739 | - CPResetFn *resetfn; | ||
740 | - | ||
741 | - /* | ||
742 | - * "Original" writefn and readfn. | ||
743 | - * For ARMv8.1-VHE register aliases, we overwrite the read/write | ||
744 | - * accessor functions of various EL1/EL0 to perform the runtime | ||
745 | - * check for which sysreg should actually be modified, and then | ||
746 | - * forwards the operation. Before overwriting the accessors, | ||
747 | - * the original function is copied here, so that accesses that | ||
748 | - * really do go to the EL1/EL0 version proceed normally. | ||
749 | - * (The corresponding EL2 register is linked via opaque.) | ||
750 | - */ | ||
751 | - CPReadFn *orig_readfn; | ||
752 | - CPWriteFn *orig_writefn; | ||
753 | -}; | ||
754 | - | ||
755 | -/* Macros which are lvalues for the field in CPUARMState for the | ||
756 | - * ARMCPRegInfo *ri. | ||
757 | - */ | ||
758 | -#define CPREG_FIELD32(env, ri) \ | ||
759 | - (*(uint32_t *)((char *)(env) + (ri)->fieldoffset)) | ||
760 | -#define CPREG_FIELD64(env, ri) \ | ||
761 | - (*(uint64_t *)((char *)(env) + (ri)->fieldoffset)) | ||
762 | - | ||
763 | -#define REGINFO_SENTINEL { .type = ARM_CP_SENTINEL } | ||
764 | - | ||
765 | -void define_arm_cp_regs_with_opaque(ARMCPU *cpu, | ||
766 | - const ARMCPRegInfo *regs, void *opaque); | ||
767 | -void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, | ||
768 | - const ARMCPRegInfo *regs, void *opaque); | ||
769 | -static inline void define_arm_cp_regs(ARMCPU *cpu, const ARMCPRegInfo *regs) | ||
770 | -{ | ||
771 | - define_arm_cp_regs_with_opaque(cpu, regs, 0); | ||
772 | -} | ||
773 | -static inline void define_one_arm_cp_reg(ARMCPU *cpu, const ARMCPRegInfo *regs) | ||
774 | -{ | ||
775 | - define_one_arm_cp_reg_with_opaque(cpu, regs, 0); | ||
776 | -} | ||
777 | -const ARMCPRegInfo *get_arm_cp_reginfo(GHashTable *cpregs, uint32_t encoded_cp); | ||
778 | - | ||
779 | -/* | ||
780 | - * Definition of an ARM co-processor register as viewed from | ||
781 | - * userspace. This is used for presenting sanitised versions of | ||
782 | - * registers to userspace when emulating the Linux AArch64 CPU | ||
783 | - * ID/feature ABI (advertised as HWCAP_CPUID). | ||
784 | - */ | ||
785 | -typedef struct ARMCPRegUserSpaceInfo { | ||
786 | - /* Name of register */ | ||
787 | - const char *name; | ||
788 | - | ||
789 | - /* Is the name actually a glob pattern */ | ||
790 | - bool is_glob; | ||
791 | - | ||
792 | - /* Only some bits are exported to user space */ | ||
793 | - uint64_t exported_bits; | ||
794 | - | ||
795 | - /* Fixed bits are applied after the mask */ | ||
796 | - uint64_t fixed_bits; | ||
797 | -} ARMCPRegUserSpaceInfo; | ||
798 | - | ||
799 | -#define REGUSERINFO_SENTINEL { .name = NULL } | ||
800 | - | ||
801 | -void modify_arm_cp_regs(ARMCPRegInfo *regs, const ARMCPRegUserSpaceInfo *mods); | ||
802 | - | ||
803 | -/* CPWriteFn that can be used to implement writes-ignored behaviour */ | ||
804 | -void arm_cp_write_ignore(CPUARMState *env, const ARMCPRegInfo *ri, | ||
805 | - uint64_t value); | ||
806 | -/* CPReadFn that can be used for read-as-zero behaviour */ | ||
807 | -uint64_t arm_cp_read_zero(CPUARMState *env, const ARMCPRegInfo *ri); | ||
808 | - | ||
809 | -/* CPResetFn that does nothing, for use if no reset is required even | ||
810 | - * if fieldoffset is non zero. | ||
811 | - */ | ||
812 | -void arm_cp_reset_ignore(CPUARMState *env, const ARMCPRegInfo *opaque); | ||
813 | - | ||
814 | -/* Return true if this reginfo struct's field in the cpu state struct | ||
815 | - * is 64 bits wide. | ||
816 | - */ | ||
817 | -static inline bool cpreg_field_is_64bit(const ARMCPRegInfo *ri) | ||
818 | -{ | ||
819 | - return (ri->state == ARM_CP_STATE_AA64) || (ri->type & ARM_CP_64BIT); | ||
820 | -} | ||
821 | - | ||
822 | -static inline bool cp_access_ok(int current_el, | ||
823 | - const ARMCPRegInfo *ri, int isread) | ||
824 | -{ | ||
825 | - return (ri->access >> ((current_el * 2) + isread)) & 1; | ||
826 | -} | ||
827 | - | ||
828 | -/* Raw read of a coprocessor register (as needed for migration, etc) */ | ||
829 | -uint64_t read_raw_cp_reg(CPUARMState *env, const ARMCPRegInfo *ri); | ||
830 | - | ||
831 | /** | ||
832 | * write_list_to_cpustate | ||
833 | * @cpu: ARMCPU | ||
834 | diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c | ||
835 | index XXXXXXX..XXXXXXX 100644 | ||
836 | --- a/hw/arm/pxa2xx.c | ||
837 | +++ b/hw/arm/pxa2xx.c | ||
838 | @@ -XXX,XX +XXX,XX @@ | ||
839 | #include "qemu/cutils.h" | ||
840 | #include "qemu/log.h" | ||
841 | #include "qom/object.h" | ||
842 | +#include "target/arm/cpregs.h" | ||
843 | |||
844 | static struct { | ||
845 | hwaddr io_base; | ||
846 | diff --git a/hw/arm/pxa2xx_pic.c b/hw/arm/pxa2xx_pic.c | ||
847 | index XXXXXXX..XXXXXXX 100644 | ||
848 | --- a/hw/arm/pxa2xx_pic.c | ||
849 | +++ b/hw/arm/pxa2xx_pic.c | ||
850 | @@ -XXX,XX +XXX,XX @@ | ||
851 | #include "hw/sysbus.h" | ||
852 | #include "migration/vmstate.h" | ||
853 | #include "qom/object.h" | ||
854 | +#include "target/arm/cpregs.h" | ||
855 | |||
856 | #define ICIP 0x00 /* Interrupt Controller IRQ Pending register */ | ||
857 | #define ICMR 0x04 /* Interrupt Controller Mask register */ | ||
858 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c | ||
859 | index XXXXXXX..XXXXXXX 100644 | ||
860 | --- a/hw/intc/arm_gicv3_cpuif.c | ||
861 | +++ b/hw/intc/arm_gicv3_cpuif.c | ||
862 | @@ -XXX,XX +XXX,XX @@ | ||
863 | #include "gicv3_internal.h" | ||
864 | #include "hw/irq.h" | ||
865 | #include "cpu.h" | ||
866 | +#include "target/arm/cpregs.h" | ||
867 | |||
868 | /* | ||
869 | * Special case return value from hppvi_index(); must be larger than | ||
870 | diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c | ||
871 | index XXXXXXX..XXXXXXX 100644 | ||
872 | --- a/hw/intc/arm_gicv3_kvm.c | ||
873 | +++ b/hw/intc/arm_gicv3_kvm.c | ||
874 | @@ -XXX,XX +XXX,XX @@ | ||
875 | #include "vgic_common.h" | ||
876 | #include "migration/blocker.h" | ||
877 | #include "qom/object.h" | ||
878 | +#include "target/arm/cpregs.h" | ||
879 | + | ||
880 | |||
881 | #ifdef DEBUG_GICV3_KVM | ||
882 | #define DPRINTF(fmt, ...) \ | ||
883 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
884 | index XXXXXXX..XXXXXXX 100644 | ||
885 | --- a/target/arm/cpu.c | ||
886 | +++ b/target/arm/cpu.c | ||
887 | @@ -XXX,XX +XXX,XX @@ | ||
888 | #include "kvm_arm.h" | ||
889 | #include "disas/capstone.h" | ||
890 | #include "fpu/softfloat.h" | ||
891 | +#include "cpregs.h" | ||
892 | |||
893 | static void arm_cpu_set_pc(CPUState *cs, vaddr value) | ||
894 | { | ||
895 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
896 | index XXXXXXX..XXXXXXX 100644 | ||
897 | --- a/target/arm/cpu64.c | ||
898 | +++ b/target/arm/cpu64.c | ||
899 | @@ -XXX,XX +XXX,XX @@ | ||
900 | #include "hvf_arm.h" | ||
901 | #include "qapi/visitor.h" | ||
902 | #include "hw/qdev-properties.h" | ||
903 | +#include "cpregs.h" | ||
904 | |||
905 | |||
906 | #ifndef CONFIG_USER_ONLY | ||
907 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | ||
908 | index XXXXXXX..XXXXXXX 100644 | ||
909 | --- a/target/arm/cpu_tcg.c | ||
910 | +++ b/target/arm/cpu_tcg.c | ||
911 | @@ -XXX,XX +XXX,XX @@ | ||
912 | #if !defined(CONFIG_USER_ONLY) | ||
913 | #include "hw/boards.h" | ||
914 | #endif | ||
915 | +#include "cpregs.h" | ||
916 | |||
917 | /* CPU models. These are not needed for the AArch64 linux-user build. */ | ||
918 | #if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64) | ||
919 | diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c | ||
920 | index XXXXXXX..XXXXXXX 100644 | ||
921 | --- a/target/arm/gdbstub.c | ||
922 | +++ b/target/arm/gdbstub.c | ||
923 | @@ -XXX,XX +XXX,XX @@ | ||
924 | */ | ||
925 | #include "qemu/osdep.h" | ||
926 | #include "cpu.h" | ||
927 | -#include "internals.h" | ||
928 | #include "exec/gdbstub.h" | ||
929 | +#include "internals.h" | ||
930 | +#include "cpregs.h" | ||
931 | |||
932 | typedef struct RegisterSysregXmlParam { | ||
933 | CPUState *cs; | ||
46 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 934 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
47 | index XXXXXXX..XXXXXXX 100644 | 935 | index XXXXXXX..XXXXXXX 100644 |
48 | --- a/target/arm/helper.c | 936 | --- a/target/arm/helper.c |
49 | +++ b/target/arm/helper.c | 937 | +++ b/target/arm/helper.c |
50 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(sxtb16)(uint32_t x) | 938 | @@ -XXX,XX +XXX,XX @@ |
51 | return res; | 939 | #include "exec/cpu_ldst.h" |
52 | } | 940 | #include "semihosting/common-semi.h" |
53 | 941 | #endif | |
54 | +static void handle_possible_div0_trap(CPUARMState *env, uintptr_t ra) | 942 | +#include "cpregs.h" |
55 | +{ | 943 | |
56 | + /* | 944 | #define ARM_CPU_FREQ 1000000000 /* FIXME: 1 GHz, should be configurable */ |
57 | + * Take a division-by-zero exception if necessary; otherwise return | 945 | #define PMCR_NUM_COUNTERS 4 /* QEMU IMPDEF choice */ |
58 | + * to get the usual non-trapping division behaviour (result of 0) | 946 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c |
59 | + */ | 947 | index XXXXXXX..XXXXXXX 100644 |
60 | + if (arm_feature(env, ARM_FEATURE_M) | 948 | --- a/target/arm/op_helper.c |
61 | + && (env->v7m.ccr[env->v7m.secure] & R_V7M_CCR_DIV_0_TRP_MASK)) { | 949 | +++ b/target/arm/op_helper.c |
62 | + raise_exception_ra(env, EXCP_DIVBYZERO, 0, 1, ra); | 950 | @@ -XXX,XX +XXX,XX @@ |
63 | + } | 951 | #include "internals.h" |
64 | +} | 952 | #include "exec/exec-all.h" |
65 | + | 953 | #include "exec/cpu_ldst.h" |
66 | uint32_t HELPER(uxtb16)(uint32_t x) | 954 | +#include "cpregs.h" |
67 | { | 955 | |
68 | uint32_t res; | 956 | #define SIGNBIT (uint32_t)0x80000000 |
69 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(uxtb16)(uint32_t x) | 957 | #define SIGNBIT64 ((uint64_t)1 << 63) |
70 | return res; | 958 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
71 | } | 959 | index XXXXXXX..XXXXXXX 100644 |
72 | 960 | --- a/target/arm/translate-a64.c | |
73 | -int32_t HELPER(sdiv)(int32_t num, int32_t den) | 961 | +++ b/target/arm/translate-a64.c |
74 | +int32_t HELPER(sdiv)(CPUARMState *env, int32_t num, int32_t den) | 962 | @@ -XXX,XX +XXX,XX @@ |
75 | { | 963 | #include "translate.h" |
76 | if (den == 0) { | 964 | #include "internals.h" |
77 | + handle_possible_div0_trap(env, GETPC()); | 965 | #include "qemu/host-utils.h" |
78 | return 0; | 966 | - |
79 | } | 967 | #include "semihosting/semihost.h" |
80 | if (num == INT_MIN && den == -1) { | 968 | #include "exec/gen-icount.h" |
81 | @@ -XXX,XX +XXX,XX @@ int32_t HELPER(sdiv)(int32_t num, int32_t den) | 969 | - |
82 | return num / den; | 970 | #include "exec/helper-proto.h" |
83 | } | 971 | #include "exec/helper-gen.h" |
84 | 972 | #include "exec/log.h" | |
85 | -uint32_t HELPER(udiv)(uint32_t num, uint32_t den) | 973 | - |
86 | +uint32_t HELPER(udiv)(CPUARMState *env, uint32_t num, uint32_t den) | 974 | +#include "cpregs.h" |
87 | { | 975 | #include "translate-a64.h" |
88 | if (den == 0) { | 976 | #include "qemu/atomic128.h" |
89 | + handle_possible_div0_trap(env, GETPC()); | 977 | |
90 | return 0; | ||
91 | } | ||
92 | return num / den; | ||
93 | @@ -XXX,XX +XXX,XX @@ void arm_log_exception(int idx) | ||
94 | [EXCP_LAZYFP] = "v7M exception during lazy FP stacking", | ||
95 | [EXCP_LSERR] = "v8M LSERR UsageFault", | ||
96 | [EXCP_UNALIGNED] = "v7M UNALIGNED UsageFault", | ||
97 | + [EXCP_DIVBYZERO] = "v7M DIVBYZERO UsageFault", | ||
98 | }; | ||
99 | |||
100 | if (idx >= 0 && idx < ARRAY_SIZE(excnames)) { | ||
101 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | ||
102 | index XXXXXXX..XXXXXXX 100644 | ||
103 | --- a/target/arm/m_helper.c | ||
104 | +++ b/target/arm/m_helper.c | ||
105 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | ||
106 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure); | ||
107 | env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNALIGNED_MASK; | ||
108 | break; | ||
109 | + case EXCP_DIVBYZERO: | ||
110 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure); | ||
111 | + env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_DIVBYZERO_MASK; | ||
112 | + break; | ||
113 | case EXCP_SWI: | ||
114 | /* The PC already points to the next instruction. */ | ||
115 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SVC, env->v7m.secure); | ||
116 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 978 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
117 | index XXXXXXX..XXXXXXX 100644 | 979 | index XXXXXXX..XXXXXXX 100644 |
118 | --- a/target/arm/translate.c | 980 | --- a/target/arm/translate.c |
119 | +++ b/target/arm/translate.c | 981 | +++ b/target/arm/translate.c |
120 | @@ -XXX,XX +XXX,XX @@ static bool op_div(DisasContext *s, arg_rrr *a, bool u) | 982 | @@ -XXX,XX +XXX,XX @@ |
121 | t1 = load_reg(s, a->rn); | 983 | #include "qemu/bitops.h" |
122 | t2 = load_reg(s, a->rm); | 984 | #include "arm_ldst.h" |
123 | if (u) { | 985 | #include "semihosting/semihost.h" |
124 | - gen_helper_udiv(t1, t1, t2); | 986 | - |
125 | + gen_helper_udiv(t1, cpu_env, t1, t2); | 987 | #include "exec/helper-proto.h" |
126 | } else { | 988 | #include "exec/helper-gen.h" |
127 | - gen_helper_sdiv(t1, t1, t2); | 989 | - |
128 | + gen_helper_sdiv(t1, cpu_env, t1, t2); | 990 | #include "exec/log.h" |
129 | } | 991 | +#include "cpregs.h" |
130 | tcg_temp_free_i32(t2); | 992 | |
131 | store_reg(s, a->rd, t1); | 993 | |
994 | #define ENABLE_ARCH_4T arm_dc_feature(s, ARM_FEATURE_V4T) | ||
132 | -- | 995 | -- |
133 | 2.20.1 | 996 | 2.25.1 |
134 | 997 | ||
135 | 998 | diff view generated by jsdifflib |
1 | Implement the MVE VLDR/VSTR insns which do scatter-gather using base | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | addresses from Qm plus or minus an immediate offset (possibly with | ||
3 | writeback). Note that writeback is not predicated but it does have | ||
4 | to honour ECI state, so we have to add an eci_mask check to the | ||
5 | VSTR_SG macros (the VLDR_SG macros already needed this to be able | ||
6 | to distinguish "skip beat" from "set predicated element to 0"). | ||
7 | 2 | ||
3 | Rearrange the values of the enumerators of CPAccessResult | ||
4 | so that we may directly extract the target el. For the two | ||
5 | special cases in access_check_cp_reg, use CPAccessResult. | ||
6 | |||
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20220501055028.646596-3-richard.henderson@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | --- | 12 | --- |
11 | target/arm/helper-mve.h | 5 +++ | 13 | target/arm/cpregs.h | 26 ++++++++++++-------- |
12 | target/arm/mve.decode | 10 +++++ | 14 | target/arm/op_helper.c | 56 +++++++++++++++++++++--------------------- |
13 | target/arm/mve_helper.c | 91 ++++++++++++++++++++++++-------------- | 15 | 2 files changed, 44 insertions(+), 38 deletions(-) |
14 | target/arm/translate-mve.c | 72 ++++++++++++++++++++++++++++++ | ||
15 | 4 files changed, 146 insertions(+), 32 deletions(-) | ||
16 | 16 | ||
17 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 17 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h |
18 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/helper-mve.h | 19 | --- a/target/arm/cpregs.h |
20 | +++ b/target/arm/helper-mve.h | 20 | +++ b/target/arm/cpregs.h |
21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vstrh_sg_os_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 21 | @@ -XXX,XX +XXX,XX @@ static inline bool cptype_valid(int cptype) |
22 | DEF_HELPER_FLAGS_4(mve_vstrw_sg_os_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 22 | typedef enum CPAccessResult { |
23 | DEF_HELPER_FLAGS_4(mve_vstrd_sg_os_ud, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 23 | /* Access is permitted */ |
24 | 24 | CP_ACCESS_OK = 0, | |
25 | +DEF_HELPER_FLAGS_4(mve_vldrw_sg_wb_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
26 | +DEF_HELPER_FLAGS_4(mve_vldrd_sg_wb_ud, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
27 | +DEF_HELPER_FLAGS_4(mve_vstrw_sg_wb_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
28 | +DEF_HELPER_FLAGS_4(mve_vstrd_sg_wb_ud, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
29 | + | 25 | + |
30 | DEF_HELPER_FLAGS_3(mve_vdup, TCG_CALL_NO_WG, void, env, ptr, i32) | 26 | + /* |
31 | 27 | + * Combined with one of the following, the low 2 bits indicate the | |
32 | DEF_HELPER_FLAGS_4(mve_vidupb, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) | 28 | + * target exception level. If 0, the exception is taken to the usual |
33 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | 29 | + * target EL (EL1 or PL1 if in EL0, otherwise to the current EL). |
30 | + */ | ||
31 | + CP_ACCESS_EL_MASK = 3, | ||
32 | + | ||
33 | /* | ||
34 | * Access fails due to a configurable trap or enable which would | ||
35 | * result in a categorized exception syndrome giving information about | ||
36 | * the failing instruction (ie syndrome category 0x3, 0x4, 0x5, 0x6, | ||
37 | - * 0xc or 0x18). The exception is taken to the usual target EL (EL1 or | ||
38 | - * PL1 if in EL0, otherwise to the current EL). | ||
39 | + * 0xc or 0x18). | ||
40 | */ | ||
41 | - CP_ACCESS_TRAP = 1, | ||
42 | + CP_ACCESS_TRAP = (1 << 2), | ||
43 | + CP_ACCESS_TRAP_EL2 = CP_ACCESS_TRAP | 2, | ||
44 | + CP_ACCESS_TRAP_EL3 = CP_ACCESS_TRAP | 3, | ||
45 | + | ||
46 | /* | ||
47 | * Access fails and results in an exception syndrome 0x0 ("uncategorized"). | ||
48 | * Note that this is not a catch-all case -- the set of cases which may | ||
49 | * result in this failure is specifically defined by the architecture. | ||
50 | */ | ||
51 | - CP_ACCESS_TRAP_UNCATEGORIZED = 2, | ||
52 | - /* As CP_ACCESS_TRAP, but for traps directly to EL2 or EL3 */ | ||
53 | - CP_ACCESS_TRAP_EL2 = 3, | ||
54 | - CP_ACCESS_TRAP_EL3 = 4, | ||
55 | - /* As CP_ACCESS_UNCATEGORIZED, but for traps directly to EL2 or EL3 */ | ||
56 | - CP_ACCESS_TRAP_UNCATEGORIZED_EL2 = 5, | ||
57 | - CP_ACCESS_TRAP_UNCATEGORIZED_EL3 = 6, | ||
58 | + CP_ACCESS_TRAP_UNCATEGORIZED = (2 << 2), | ||
59 | + CP_ACCESS_TRAP_UNCATEGORIZED_EL2 = CP_ACCESS_TRAP_UNCATEGORIZED | 2, | ||
60 | + CP_ACCESS_TRAP_UNCATEGORIZED_EL3 = CP_ACCESS_TRAP_UNCATEGORIZED | 3, | ||
61 | } CPAccessResult; | ||
62 | |||
63 | typedef struct ARMCPRegInfo ARMCPRegInfo; | ||
64 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | 65 | index XXXXXXX..XXXXXXX 100644 |
35 | --- a/target/arm/mve.decode | 66 | --- a/target/arm/op_helper.c |
36 | +++ b/target/arm/mve.decode | 67 | +++ b/target/arm/op_helper.c |
37 | @@ -XXX,XX +XXX,XX @@ | 68 | @@ -XXX,XX +XXX,XX @@ void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome, |
38 | &vmaxv qm rda size | 69 | uint32_t isread) |
39 | &vabav qn qm rda size | 70 | { |
40 | &vldst_sg qd qm rn size msize os | 71 | const ARMCPRegInfo *ri = rip; |
41 | +&vldst_sg_imm qd qm a w imm | 72 | + CPAccessResult res = CP_ACCESS_OK; |
42 | 73 | int target_el; | |
43 | # scatter-gather memory size is in bits 6:4 | 74 | |
44 | %sg_msize 6:1 4:1 | 75 | if (arm_feature(env, ARM_FEATURE_XSCALE) && ri->cp < 14 |
45 | @@ -XXX,XX +XXX,XX @@ | 76 | && extract32(env->cp15.c15_cpar, ri->cp, 1) == 0) { |
46 | @vldst_sg .... .... .... rn:4 .... ... size:2 ... ... os:1 &vldst_sg \ | 77 | - raise_exception(env, EXCP_UDEF, syndrome, exception_target_el(env)); |
47 | qd=%qd qm=%qm msize=%sg_msize | 78 | + res = CP_ACCESS_TRAP; |
48 | 79 | + goto fail; | |
49 | +# Qm is in the fields usually labeled Qn | ||
50 | +@vldst_sg_imm .... .... a:1 . w:1 . .... .... .... . imm:7 &vldst_sg_imm \ | ||
51 | + qd=%qd qm=%qn | ||
52 | + | ||
53 | @1op .... .... .... size:2 .. .... .... .... .... &1op qd=%qd qm=%qm | ||
54 | @1op_nosz .... .... .... .... .... .... .... .... &1op qd=%qd qm=%qm size=0 | ||
55 | @2op .... .... .. size:2 .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn | ||
56 | @@ -XXX,XX +XXX,XX @@ VLDR_S_sg 111 0 1100 1 . 01 .... ... 0 111 . .... .... @vldst_sg | ||
57 | VLDR_U_sg 111 1 1100 1 . 01 .... ... 0 111 . .... .... @vldst_sg | ||
58 | VSTR_sg 111 0 1100 1 . 00 .... ... 0 111 . .... .... @vldst_sg | ||
59 | |||
60 | +VLDRW_sg_imm 111 1 1101 ... 1 ... 0 ... 1 1110 .... .... @vldst_sg_imm | ||
61 | +VLDRD_sg_imm 111 1 1101 ... 1 ... 0 ... 1 1111 .... .... @vldst_sg_imm | ||
62 | +VSTRW_sg_imm 111 1 1101 ... 0 ... 0 ... 1 1110 .... .... @vldst_sg_imm | ||
63 | +VSTRD_sg_imm 111 1 1101 ... 0 ... 0 ... 1 1111 .... .... @vldst_sg_imm | ||
64 | + | ||
65 | # Moves between 2 32-bit vector lanes and 2 general purpose registers | ||
66 | VMOV_to_2gp 1110 1100 0 . 00 rt2:4 ... 0 1111 000 idx:1 rt:4 qd=%qd | ||
67 | VMOV_from_2gp 1110 1100 0 . 01 rt2:4 ... 0 1111 000 idx:1 rt:4 qd=%qd | ||
68 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
69 | index XXXXXXX..XXXXXXX 100644 | ||
70 | --- a/target/arm/mve_helper.c | ||
71 | +++ b/target/arm/mve_helper.c | ||
72 | @@ -XXX,XX +XXX,XX @@ DO_VSTR(vstrh_w, 2, stw, 4, int32_t) | ||
73 | * For loads, predicated lanes are zeroed instead of retaining | ||
74 | * their previous values. | ||
75 | */ | ||
76 | -#define DO_VLDR_SG(OP, LDTYPE, ESIZE, TYPE, OFFTYPE, ADDRFN) \ | ||
77 | +#define DO_VLDR_SG(OP, LDTYPE, ESIZE, TYPE, OFFTYPE, ADDRFN, WB) \ | ||
78 | void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm, \ | ||
79 | uint32_t base) \ | ||
80 | { \ | ||
81 | @@ -XXX,XX +XXX,XX @@ DO_VSTR(vstrh_w, 2, stw, 4, int32_t) | ||
82 | addr = ADDRFN(base, m[H##ESIZE(e)]); \ | ||
83 | d[H##ESIZE(e)] = (mask & 1) ? \ | ||
84 | cpu_##LDTYPE##_data_ra(env, addr, GETPC()) : 0; \ | ||
85 | + if (WB) { \ | ||
86 | + m[H##ESIZE(e)] = addr; \ | ||
87 | + } \ | ||
88 | } \ | ||
89 | mve_advance_vpt(env); \ | ||
90 | } | 80 | } |
91 | 81 | ||
92 | /* We know here TYPE is unsigned so always the same as the offset type */ | 82 | /* |
93 | -#define DO_VSTR_SG(OP, STTYPE, ESIZE, TYPE, ADDRFN) \ | 83 | @@ -XXX,XX +XXX,XX @@ void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome, |
94 | +#define DO_VSTR_SG(OP, STTYPE, ESIZE, TYPE, ADDRFN, WB) \ | 84 | mask &= ~((1 << 4) | (1 << 14)); |
95 | void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm, \ | 85 | |
96 | uint32_t base) \ | 86 | if (env->cp15.hstr_el2 & mask) { |
97 | { \ | 87 | - target_el = 2; |
98 | TYPE *d = vd; \ | 88 | - goto exept; |
99 | TYPE *m = vm; \ | 89 | + res = CP_ACCESS_TRAP_EL2; |
100 | uint16_t mask = mve_element_mask(env); \ | 90 | + goto fail; |
101 | + uint16_t eci_mask = mve_eci_mask(env); \ | 91 | } |
102 | unsigned e; \ | ||
103 | uint32_t addr; \ | ||
104 | - for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
105 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE, eci_mask >>= ESIZE) { \ | ||
106 | + if (!(eci_mask & 1)) { \ | ||
107 | + continue; \ | ||
108 | + } \ | ||
109 | addr = ADDRFN(base, m[H##ESIZE(e)]); \ | ||
110 | if (mask & 1) { \ | ||
111 | cpu_##STTYPE##_data_ra(env, addr, d[H##ESIZE(e)], GETPC()); \ | ||
112 | } \ | ||
113 | + if (WB) { \ | ||
114 | + m[H##ESIZE(e)] = addr; \ | ||
115 | + } \ | ||
116 | } \ | ||
117 | mve_advance_vpt(env); \ | ||
118 | } | 92 | } |
119 | @@ -XXX,XX +XXX,XX @@ DO_VSTR(vstrh_w, 2, stw, 4, int32_t) | 93 | |
120 | * accesses, controlled by the predicate mask for the relevant beat, | 94 | - if (!ri->accessfn) { |
121 | * and with a single 32-bit offset in the first of the two Qm elements. | 95 | + if (ri->accessfn) { |
122 | * Note that for QEMU our IMPDEF AIRCR.ENDIANNESS is always 0 (little). | 96 | + res = ri->accessfn(env, ri, isread); |
123 | + * Address writeback happens on the odd beats and updates the address | 97 | + } |
124 | + * stored in the even-beat element. | 98 | + if (likely(res == CP_ACCESS_OK)) { |
125 | */ | 99 | return; |
126 | -#define DO_VLDR64_SG(OP, ADDRFN) \ | ||
127 | +#define DO_VLDR64_SG(OP, ADDRFN, WB) \ | ||
128 | void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm, \ | ||
129 | uint32_t base) \ | ||
130 | { \ | ||
131 | @@ -XXX,XX +XXX,XX @@ DO_VSTR(vstrh_w, 2, stw, 4, int32_t) | ||
132 | addr = ADDRFN(base, m[H4(e & ~1)]); \ | ||
133 | addr += 4 * (e & 1); \ | ||
134 | d[H4(e)] = (mask & 1) ? cpu_ldl_data_ra(env, addr, GETPC()) : 0; \ | ||
135 | + if (WB && (e & 1)) { \ | ||
136 | + m[H4(e & ~1)] = addr - 4; \ | ||
137 | + } \ | ||
138 | } \ | ||
139 | mve_advance_vpt(env); \ | ||
140 | } | 100 | } |
141 | 101 | ||
142 | -#define DO_VSTR64_SG(OP, ADDRFN) \ | 102 | - switch (ri->accessfn(env, ri, isread)) { |
143 | +#define DO_VSTR64_SG(OP, ADDRFN, WB) \ | 103 | - case CP_ACCESS_OK: |
144 | void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm, \ | 104 | - return; |
145 | uint32_t base) \ | 105 | + fail: |
146 | { \ | 106 | + switch (res & ~CP_ACCESS_EL_MASK) { |
147 | uint32_t *d = vd; \ | 107 | case CP_ACCESS_TRAP: |
148 | uint32_t *m = vm; \ | 108 | - target_el = exception_target_el(env); |
149 | uint16_t mask = mve_element_mask(env); \ | 109 | - break; |
150 | + uint16_t eci_mask = mve_eci_mask(env); \ | 110 | - case CP_ACCESS_TRAP_EL2: |
151 | unsigned e; \ | 111 | - /* Requesting a trap to EL2 when we're in EL3 is |
152 | uint32_t addr; \ | 112 | - * a bug in the access function. |
153 | - for (e = 0; e < 16 / 4; e++, mask >>= 4) { \ | 113 | - */ |
154 | + for (e = 0; e < 16 / 4; e++, mask >>= 4, eci_mask >>= 4) { \ | 114 | - assert(arm_current_el(env) != 3); |
155 | + if (!(eci_mask & 1)) { \ | 115 | - target_el = 2; |
156 | + continue; \ | 116 | - break; |
157 | + } \ | 117 | - case CP_ACCESS_TRAP_EL3: |
158 | addr = ADDRFN(base, m[H4(e & ~1)]); \ | 118 | - target_el = 3; |
159 | addr += 4 * (e & 1); \ | 119 | break; |
160 | if (mask & 1) { \ | 120 | case CP_ACCESS_TRAP_UNCATEGORIZED: |
161 | cpu_stl_data_ra(env, addr, d[H4(e)], GETPC()); \ | 121 | - target_el = exception_target_el(env); |
162 | } \ | 122 | - syndrome = syn_uncategorized(); |
163 | + if (WB && (e & 1)) { \ | 123 | - break; |
164 | + m[H4(e & ~1)] = addr - 4; \ | 124 | - case CP_ACCESS_TRAP_UNCATEGORIZED_EL2: |
165 | + } \ | 125 | - target_el = 2; |
166 | } \ | 126 | - syndrome = syn_uncategorized(); |
167 | mve_advance_vpt(env); \ | 127 | - break; |
128 | - case CP_ACCESS_TRAP_UNCATEGORIZED_EL3: | ||
129 | - target_el = 3; | ||
130 | syndrome = syn_uncategorized(); | ||
131 | break; | ||
132 | default: | ||
133 | g_assert_not_reached(); | ||
168 | } | 134 | } |
169 | @@ -XXX,XX +XXX,XX @@ DO_VSTR(vstrh_w, 2, stw, 4, int32_t) | 135 | |
170 | #define ADDR_ADD_OSW(BASE, OFFSET) ((BASE) + ((OFFSET) << 2)) | 136 | -exept: |
171 | #define ADDR_ADD_OSD(BASE, OFFSET) ((BASE) + ((OFFSET) << 3)) | 137 | + target_el = res & CP_ACCESS_EL_MASK; |
172 | 138 | + switch (target_el) { | |
173 | -DO_VLDR_SG(vldrb_sg_sh, ldsb, 2, int16_t, uint16_t, ADDR_ADD) | 139 | + case 0: |
174 | -DO_VLDR_SG(vldrb_sg_sw, ldsb, 4, int32_t, uint32_t, ADDR_ADD) | 140 | + target_el = exception_target_el(env); |
175 | -DO_VLDR_SG(vldrh_sg_sw, ldsw, 4, int32_t, uint32_t, ADDR_ADD) | 141 | + break; |
176 | +DO_VLDR_SG(vldrb_sg_sh, ldsb, 2, int16_t, uint16_t, ADDR_ADD, false) | 142 | + case 2: |
177 | +DO_VLDR_SG(vldrb_sg_sw, ldsb, 4, int32_t, uint32_t, ADDR_ADD, false) | 143 | + assert(arm_current_el(env) != 3); |
178 | +DO_VLDR_SG(vldrh_sg_sw, ldsw, 4, int32_t, uint32_t, ADDR_ADD, false) | 144 | + assert(arm_is_el2_enabled(env)); |
179 | 145 | + break; | |
180 | -DO_VLDR_SG(vldrb_sg_ub, ldub, 1, uint8_t, uint8_t, ADDR_ADD) | 146 | + case 3: |
181 | -DO_VLDR_SG(vldrb_sg_uh, ldub, 2, uint16_t, uint16_t, ADDR_ADD) | 147 | + assert(arm_feature(env, ARM_FEATURE_EL3)); |
182 | -DO_VLDR_SG(vldrb_sg_uw, ldub, 4, uint32_t, uint32_t, ADDR_ADD) | 148 | + break; |
183 | -DO_VLDR_SG(vldrh_sg_uh, lduw, 2, uint16_t, uint16_t, ADDR_ADD) | 149 | + default: |
184 | -DO_VLDR_SG(vldrh_sg_uw, lduw, 4, uint32_t, uint32_t, ADDR_ADD) | 150 | + /* No "direct" traps to EL1 */ |
185 | -DO_VLDR_SG(vldrw_sg_uw, ldl, 4, uint32_t, uint32_t, ADDR_ADD) | 151 | + g_assert_not_reached(); |
186 | -DO_VLDR64_SG(vldrd_sg_ud, ADDR_ADD) | ||
187 | +DO_VLDR_SG(vldrb_sg_ub, ldub, 1, uint8_t, uint8_t, ADDR_ADD, false) | ||
188 | +DO_VLDR_SG(vldrb_sg_uh, ldub, 2, uint16_t, uint16_t, ADDR_ADD, false) | ||
189 | +DO_VLDR_SG(vldrb_sg_uw, ldub, 4, uint32_t, uint32_t, ADDR_ADD, false) | ||
190 | +DO_VLDR_SG(vldrh_sg_uh, lduw, 2, uint16_t, uint16_t, ADDR_ADD, false) | ||
191 | +DO_VLDR_SG(vldrh_sg_uw, lduw, 4, uint32_t, uint32_t, ADDR_ADD, false) | ||
192 | +DO_VLDR_SG(vldrw_sg_uw, ldl, 4, uint32_t, uint32_t, ADDR_ADD, false) | ||
193 | +DO_VLDR64_SG(vldrd_sg_ud, ADDR_ADD, false) | ||
194 | |||
195 | -DO_VLDR_SG(vldrh_sg_os_sw, ldsw, 4, int32_t, uint32_t, ADDR_ADD_OSH) | ||
196 | -DO_VLDR_SG(vldrh_sg_os_uh, lduw, 2, uint16_t, uint16_t, ADDR_ADD_OSH) | ||
197 | -DO_VLDR_SG(vldrh_sg_os_uw, lduw, 4, uint32_t, uint32_t, ADDR_ADD_OSH) | ||
198 | -DO_VLDR_SG(vldrw_sg_os_uw, ldl, 4, uint32_t, uint32_t, ADDR_ADD_OSW) | ||
199 | -DO_VLDR64_SG(vldrd_sg_os_ud, ADDR_ADD_OSD) | ||
200 | +DO_VLDR_SG(vldrh_sg_os_sw, ldsw, 4, int32_t, uint32_t, ADDR_ADD_OSH, false) | ||
201 | +DO_VLDR_SG(vldrh_sg_os_uh, lduw, 2, uint16_t, uint16_t, ADDR_ADD_OSH, false) | ||
202 | +DO_VLDR_SG(vldrh_sg_os_uw, lduw, 4, uint32_t, uint32_t, ADDR_ADD_OSH, false) | ||
203 | +DO_VLDR_SG(vldrw_sg_os_uw, ldl, 4, uint32_t, uint32_t, ADDR_ADD_OSW, false) | ||
204 | +DO_VLDR64_SG(vldrd_sg_os_ud, ADDR_ADD_OSD, false) | ||
205 | |||
206 | -DO_VSTR_SG(vstrb_sg_ub, stb, 1, uint8_t, ADDR_ADD) | ||
207 | -DO_VSTR_SG(vstrb_sg_uh, stb, 2, uint16_t, ADDR_ADD) | ||
208 | -DO_VSTR_SG(vstrb_sg_uw, stb, 4, uint32_t, ADDR_ADD) | ||
209 | -DO_VSTR_SG(vstrh_sg_uh, stw, 2, uint16_t, ADDR_ADD) | ||
210 | -DO_VSTR_SG(vstrh_sg_uw, stw, 4, uint32_t, ADDR_ADD) | ||
211 | -DO_VSTR_SG(vstrw_sg_uw, stl, 4, uint32_t, ADDR_ADD) | ||
212 | -DO_VSTR64_SG(vstrd_sg_ud, ADDR_ADD) | ||
213 | +DO_VSTR_SG(vstrb_sg_ub, stb, 1, uint8_t, ADDR_ADD, false) | ||
214 | +DO_VSTR_SG(vstrb_sg_uh, stb, 2, uint16_t, ADDR_ADD, false) | ||
215 | +DO_VSTR_SG(vstrb_sg_uw, stb, 4, uint32_t, ADDR_ADD, false) | ||
216 | +DO_VSTR_SG(vstrh_sg_uh, stw, 2, uint16_t, ADDR_ADD, false) | ||
217 | +DO_VSTR_SG(vstrh_sg_uw, stw, 4, uint32_t, ADDR_ADD, false) | ||
218 | +DO_VSTR_SG(vstrw_sg_uw, stl, 4, uint32_t, ADDR_ADD, false) | ||
219 | +DO_VSTR64_SG(vstrd_sg_ud, ADDR_ADD, false) | ||
220 | |||
221 | -DO_VSTR_SG(vstrh_sg_os_uh, stw, 2, uint16_t, ADDR_ADD_OSH) | ||
222 | -DO_VSTR_SG(vstrh_sg_os_uw, stw, 4, uint32_t, ADDR_ADD_OSH) | ||
223 | -DO_VSTR_SG(vstrw_sg_os_uw, stl, 4, uint32_t, ADDR_ADD_OSW) | ||
224 | -DO_VSTR64_SG(vstrd_sg_os_ud, ADDR_ADD_OSD) | ||
225 | +DO_VSTR_SG(vstrh_sg_os_uh, stw, 2, uint16_t, ADDR_ADD_OSH, false) | ||
226 | +DO_VSTR_SG(vstrh_sg_os_uw, stw, 4, uint32_t, ADDR_ADD_OSH, false) | ||
227 | +DO_VSTR_SG(vstrw_sg_os_uw, stl, 4, uint32_t, ADDR_ADD_OSW, false) | ||
228 | +DO_VSTR64_SG(vstrd_sg_os_ud, ADDR_ADD_OSD, false) | ||
229 | + | ||
230 | +DO_VLDR_SG(vldrw_sg_wb_uw, ldl, 4, uint32_t, uint32_t, ADDR_ADD, true) | ||
231 | +DO_VLDR64_SG(vldrd_sg_wb_ud, ADDR_ADD, true) | ||
232 | +DO_VSTR_SG(vstrw_sg_wb_uw, stl, 4, uint32_t, ADDR_ADD, true) | ||
233 | +DO_VSTR64_SG(vstrd_sg_wb_ud, ADDR_ADD, true) | ||
234 | |||
235 | /* | ||
236 | * The mergemask(D, R, M) macro performs the operation "*D = R" but | ||
237 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
238 | index XXXXXXX..XXXXXXX 100644 | ||
239 | --- a/target/arm/translate-mve.c | ||
240 | +++ b/target/arm/translate-mve.c | ||
241 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSTR_sg(DisasContext *s, arg_vldst_sg *a) | ||
242 | |||
243 | #undef F | ||
244 | |||
245 | +static bool do_ldst_sg_imm(DisasContext *s, arg_vldst_sg_imm *a, | ||
246 | + MVEGenLdStSGFn *fn, unsigned msize) | ||
247 | +{ | ||
248 | + uint32_t offset; | ||
249 | + TCGv_ptr qd, qm; | ||
250 | + | ||
251 | + if (!dc_isar_feature(aa32_mve, s) || | ||
252 | + !mve_check_qreg_bank(s, a->qd | a->qm) || | ||
253 | + !fn) { | ||
254 | + return false; | ||
255 | + } | 152 | + } |
256 | + | 153 | + |
257 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | 154 | raise_exception(env, EXCP_UDEF, syndrome, target_el); |
258 | + return true; | 155 | } |
259 | + } | 156 | |
260 | + | ||
261 | + offset = a->imm << msize; | ||
262 | + if (!a->a) { | ||
263 | + offset = -offset; | ||
264 | + } | ||
265 | + | ||
266 | + qd = mve_qreg_ptr(a->qd); | ||
267 | + qm = mve_qreg_ptr(a->qm); | ||
268 | + fn(cpu_env, qd, qm, tcg_constant_i32(offset)); | ||
269 | + tcg_temp_free_ptr(qd); | ||
270 | + tcg_temp_free_ptr(qm); | ||
271 | + mve_update_eci(s); | ||
272 | + return true; | ||
273 | +} | ||
274 | + | ||
275 | +static bool trans_VLDRW_sg_imm(DisasContext *s, arg_vldst_sg_imm *a) | ||
276 | +{ | ||
277 | + static MVEGenLdStSGFn * const fns[] = { | ||
278 | + gen_helper_mve_vldrw_sg_uw, | ||
279 | + gen_helper_mve_vldrw_sg_wb_uw, | ||
280 | + }; | ||
281 | + if (a->qd == a->qm) { | ||
282 | + return false; /* UNPREDICTABLE */ | ||
283 | + } | ||
284 | + return do_ldst_sg_imm(s, a, fns[a->w], MO_32); | ||
285 | +} | ||
286 | + | ||
287 | +static bool trans_VLDRD_sg_imm(DisasContext *s, arg_vldst_sg_imm *a) | ||
288 | +{ | ||
289 | + static MVEGenLdStSGFn * const fns[] = { | ||
290 | + gen_helper_mve_vldrd_sg_ud, | ||
291 | + gen_helper_mve_vldrd_sg_wb_ud, | ||
292 | + }; | ||
293 | + if (a->qd == a->qm) { | ||
294 | + return false; /* UNPREDICTABLE */ | ||
295 | + } | ||
296 | + return do_ldst_sg_imm(s, a, fns[a->w], MO_64); | ||
297 | +} | ||
298 | + | ||
299 | +static bool trans_VSTRW_sg_imm(DisasContext *s, arg_vldst_sg_imm *a) | ||
300 | +{ | ||
301 | + static MVEGenLdStSGFn * const fns[] = { | ||
302 | + gen_helper_mve_vstrw_sg_uw, | ||
303 | + gen_helper_mve_vstrw_sg_wb_uw, | ||
304 | + }; | ||
305 | + return do_ldst_sg_imm(s, a, fns[a->w], MO_32); | ||
306 | +} | ||
307 | + | ||
308 | +static bool trans_VSTRD_sg_imm(DisasContext *s, arg_vldst_sg_imm *a) | ||
309 | +{ | ||
310 | + static MVEGenLdStSGFn * const fns[] = { | ||
311 | + gen_helper_mve_vstrd_sg_ud, | ||
312 | + gen_helper_mve_vstrd_sg_wb_ud, | ||
313 | + }; | ||
314 | + return do_ldst_sg_imm(s, a, fns[a->w], MO_64); | ||
315 | +} | ||
316 | + | ||
317 | static bool trans_VDUP(DisasContext *s, arg_VDUP *a) | ||
318 | { | ||
319 | TCGv_ptr qd; | ||
320 | -- | 157 | -- |
321 | 2.20.1 | 158 | 2.25.1 |
322 | 159 | ||
323 | 160 | diff view generated by jsdifflib |
1 | Implement the MVE incrementing/decrementing dup insns VIDUP, VDDUP, | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | VIWDUP and VDWDUP. These fill the elements of a vector with | ||
3 | successively incrementing values, starting at the offset specified in | ||
4 | a general purpose register. The final value of the offset is written | ||
5 | back to this register. The wrapping variants take a second general | ||
6 | purpose register which specifies the point where the count should | ||
7 | wrap back to 0. | ||
8 | 2 | ||
3 | Remove a possible source of error by removing REGINFO_SENTINEL | ||
4 | and using ARRAY_SIZE (convinently hidden inside a macro) to | ||
5 | find the end of the set of regs being registered or modified. | ||
6 | |||
7 | The space saved by not having the extra array element reduces | ||
8 | the executable's .data.rel.ro section by about 9k. | ||
9 | |||
10 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Message-id: 20220501055028.646596-4-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | --- | 15 | --- |
12 | target/arm/helper-mve.h | 12 ++++ | 16 | target/arm/cpregs.h | 53 +++++++++--------- |
13 | target/arm/mve.decode | 25 ++++++++ | 17 | hw/arm/pxa2xx.c | 1 - |
14 | target/arm/mve_helper.c | 63 +++++++++++++++++++ | 18 | hw/arm/pxa2xx_pic.c | 1 - |
15 | target/arm/translate-mve.c | 120 +++++++++++++++++++++++++++++++++++++ | 19 | hw/intc/arm_gicv3_cpuif.c | 5 -- |
16 | 4 files changed, 220 insertions(+) | 20 | hw/intc/arm_gicv3_kvm.c | 1 - |
21 | target/arm/cpu64.c | 1 - | ||
22 | target/arm/cpu_tcg.c | 4 -- | ||
23 | target/arm/helper.c | 111 ++++++++------------------------------ | ||
24 | 8 files changed, 48 insertions(+), 129 deletions(-) | ||
17 | 25 | ||
18 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 26 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h |
19 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/helper-mve.h | 28 | --- a/target/arm/cpregs.h |
21 | +++ b/target/arm/helper-mve.h | 29 | +++ b/target/arm/cpregs.h |
22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vstrh_w, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
23 | |||
24 | DEF_HELPER_FLAGS_3(mve_vdup, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
25 | |||
26 | +DEF_HELPER_FLAGS_4(mve_vidupb, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) | ||
27 | +DEF_HELPER_FLAGS_4(mve_viduph, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) | ||
28 | +DEF_HELPER_FLAGS_4(mve_vidupw, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) | ||
29 | + | ||
30 | +DEF_HELPER_FLAGS_5(mve_viwdupb, TCG_CALL_NO_WG, i32, env, ptr, i32, i32, i32) | ||
31 | +DEF_HELPER_FLAGS_5(mve_viwduph, TCG_CALL_NO_WG, i32, env, ptr, i32, i32, i32) | ||
32 | +DEF_HELPER_FLAGS_5(mve_viwdupw, TCG_CALL_NO_WG, i32, env, ptr, i32, i32, i32) | ||
33 | + | ||
34 | +DEF_HELPER_FLAGS_5(mve_vdwdupb, TCG_CALL_NO_WG, i32, env, ptr, i32, i32, i32) | ||
35 | +DEF_HELPER_FLAGS_5(mve_vdwduph, TCG_CALL_NO_WG, i32, env, ptr, i32, i32, i32) | ||
36 | +DEF_HELPER_FLAGS_5(mve_vdwdupw, TCG_CALL_NO_WG, i32, env, ptr, i32, i32, i32) | ||
37 | + | ||
38 | DEF_HELPER_FLAGS_3(mve_vclsb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
39 | DEF_HELPER_FLAGS_3(mve_vclsh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
40 | DEF_HELPER_FLAGS_3(mve_vclsw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
41 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/target/arm/mve.decode | ||
44 | +++ b/target/arm/mve.decode | ||
45 | @@ -XXX,XX +XXX,XX @@ | 30 | @@ -XXX,XX +XXX,XX @@ |
46 | &2scalar qd qn rm size | 31 | #define ARM_CP_NO_GDB 0x4000 |
47 | &1imm qd imm cmode op | 32 | #define ARM_CP_RAISES_EXC 0x8000 |
48 | &2shift qd qm shift size | 33 | #define ARM_CP_NEWEL 0x10000 |
49 | +&vidup qd rn size imm | 34 | -/* Used only as a terminator for ARMCPRegInfo lists */ |
50 | +&viwdup qd rn rm size imm | 35 | -#define ARM_CP_SENTINEL 0xfffff |
51 | 36 | /* Mask of only the flag bits in a type field */ | |
52 | @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 | 37 | #define ARM_CP_FLAG_MASK 0x1f0ff |
53 | # Note that both Rn and Qd are 3 bits only (no D bit) | 38 | |
54 | @@ -XXX,XX +XXX,XX @@ VDUP 1110 1110 1 1 10 ... 0 .... 1011 . 0 0 1 0000 @vdup size=0 | 39 | @@ -XXX,XX +XXX,XX @@ enum { |
55 | VDUP 1110 1110 1 0 10 ... 0 .... 1011 . 0 1 1 0000 @vdup size=1 | 40 | ARM_CP_SECSTATE_NS = (1 << 1), /* bit[1]: Non-secure state register */ |
56 | VDUP 1110 1110 1 0 10 ... 0 .... 1011 . 0 0 1 0000 @vdup size=2 | 41 | }; |
57 | 42 | ||
58 | +# Incrementing and decrementing dup | 43 | -/* |
59 | + | 44 | - * Return true if cptype is a valid type field. This is used to try to |
60 | +# VIDUP, VDDUP format immediate: 1 << (immh:imml) | 45 | - * catch errors where the sentinel has been accidentally left off the end |
61 | +%imm_vidup 7:1 0:1 !function=vidup_imm | 46 | - * of a list of registers. |
62 | + | 47 | - */ |
63 | +# VIDUP, VDDUP registers: Rm bits [3:1] from insn, bit 0 is 1; | 48 | -static inline bool cptype_valid(int cptype) |
64 | +# Rn bits [3:1] from insn, bit 0 is 0 | 49 | -{ |
65 | +%vidup_rm 1:3 !function=times_2_plus_1 | 50 | - return ((cptype & ~ARM_CP_FLAG_MASK) == 0) |
66 | +%vidup_rn 17:3 !function=times_2 | 51 | - || ((cptype & ARM_CP_SPECIAL) && |
67 | + | 52 | - ((cptype & ~ARM_CP_FLAG_MASK) <= ARM_LAST_SPECIAL)); |
68 | +@vidup .... .... . . size:2 .... .... .... .... .... \ | 53 | -} |
69 | + qd=%qd imm=%imm_vidup rn=%vidup_rn &vidup | 54 | - |
70 | +@viwdup .... .... . . size:2 .... .... .... .... .... \ | 55 | /* |
71 | + qd=%qd imm=%imm_vidup rm=%vidup_rm rn=%vidup_rn &viwdup | 56 | * Access rights: |
72 | +{ | 57 | * We define bits for Read and Write access for what rev C of the v7-AR ARM ARM |
73 | + VIDUP 1110 1110 0 . .. ... 1 ... 0 1111 . 110 111 . @vidup | 58 | @@ -XXX,XX +XXX,XX @@ struct ARMCPRegInfo { |
74 | + VIWDUP 1110 1110 0 . .. ... 1 ... 0 1111 . 110 ... . @viwdup | 59 | #define CPREG_FIELD64(env, ri) \ |
75 | +} | 60 | (*(uint64_t *)((char *)(env) + (ri)->fieldoffset)) |
76 | +{ | 61 | |
77 | + VDDUP 1110 1110 0 . .. ... 1 ... 1 1111 . 110 111 . @vidup | 62 | -#define REGINFO_SENTINEL { .type = ARM_CP_SENTINEL } |
78 | + VDWDUP 1110 1110 0 . .. ... 1 ... 1 1111 . 110 ... . @viwdup | 63 | +void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, const ARMCPRegInfo *reg, |
79 | +} | 64 | + void *opaque); |
80 | + | 65 | |
81 | # multiply-add long dual accumulate | 66 | -void define_arm_cp_regs_with_opaque(ARMCPU *cpu, |
82 | # rdahi: bits [3:1] from insn, bit 0 is 1 | 67 | - const ARMCPRegInfo *regs, void *opaque); |
83 | # rdalo: bits [3:1] from insn, bit 0 is 0 | 68 | -void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, |
84 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | 69 | - const ARMCPRegInfo *regs, void *opaque); |
85 | index XXXXXXX..XXXXXXX 100644 | 70 | -static inline void define_arm_cp_regs(ARMCPU *cpu, const ARMCPRegInfo *regs) |
86 | --- a/target/arm/mve_helper.c | 71 | -{ |
87 | +++ b/target/arm/mve_helper.c | 72 | - define_arm_cp_regs_with_opaque(cpu, regs, 0); |
88 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(mve_sqrshr)(CPUARMState *env, uint32_t n, uint32_t shift) | 73 | -} |
74 | static inline void define_one_arm_cp_reg(ARMCPU *cpu, const ARMCPRegInfo *regs) | ||
89 | { | 75 | { |
90 | return do_sqrshl_bhs(n, -(int8_t)shift, 32, true, &env->QF); | 76 | - define_one_arm_cp_reg_with_opaque(cpu, regs, 0); |
77 | + define_one_arm_cp_reg_with_opaque(cpu, regs, NULL); | ||
91 | } | 78 | } |
92 | + | 79 | + |
93 | +#define DO_VIDUP(OP, ESIZE, TYPE, FN) \ | 80 | +void define_arm_cp_regs_with_opaque_len(ARMCPU *cpu, const ARMCPRegInfo *regs, |
94 | + uint32_t HELPER(mve_##OP)(CPUARMState *env, void *vd, \ | 81 | + void *opaque, size_t len); |
95 | + uint32_t offset, uint32_t imm) \ | ||
96 | + { \ | ||
97 | + TYPE *d = vd; \ | ||
98 | + uint16_t mask = mve_element_mask(env); \ | ||
99 | + unsigned e; \ | ||
100 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
101 | + mergemask(&d[H##ESIZE(e)], offset, mask); \ | ||
102 | + offset = FN(offset, imm); \ | ||
103 | + } \ | ||
104 | + mve_advance_vpt(env); \ | ||
105 | + return offset; \ | ||
106 | + } | ||
107 | + | 82 | + |
108 | +#define DO_VIWDUP(OP, ESIZE, TYPE, FN) \ | 83 | +#define define_arm_cp_regs_with_opaque(CPU, REGS, OPAQUE) \ |
109 | + uint32_t HELPER(mve_##OP)(CPUARMState *env, void *vd, \ | 84 | + do { \ |
110 | + uint32_t offset, uint32_t wrap, \ | 85 | + QEMU_BUILD_BUG_ON(ARRAY_SIZE(REGS) == 0); \ |
111 | + uint32_t imm) \ | 86 | + define_arm_cp_regs_with_opaque_len(CPU, REGS, OPAQUE, \ |
112 | + { \ | 87 | + ARRAY_SIZE(REGS)); \ |
113 | + TYPE *d = vd; \ | 88 | + } while (0) |
114 | + uint16_t mask = mve_element_mask(env); \ | ||
115 | + unsigned e; \ | ||
116 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
117 | + mergemask(&d[H##ESIZE(e)], offset, mask); \ | ||
118 | + offset = FN(offset, wrap, imm); \ | ||
119 | + } \ | ||
120 | + mve_advance_vpt(env); \ | ||
121 | + return offset; \ | ||
122 | + } | ||
123 | + | 89 | + |
124 | +#define DO_VIDUP_ALL(OP, FN) \ | 90 | +#define define_arm_cp_regs(CPU, REGS) \ |
125 | + DO_VIDUP(OP##b, 1, int8_t, FN) \ | 91 | + define_arm_cp_regs_with_opaque(CPU, REGS, NULL) |
126 | + DO_VIDUP(OP##h, 2, int16_t, FN) \ | ||
127 | + DO_VIDUP(OP##w, 4, int32_t, FN) | ||
128 | + | 92 | + |
129 | +#define DO_VIWDUP_ALL(OP, FN) \ | 93 | const ARMCPRegInfo *get_arm_cp_reginfo(GHashTable *cpregs, uint32_t encoded_cp); |
130 | + DO_VIWDUP(OP##b, 1, int8_t, FN) \ | 94 | |
131 | + DO_VIWDUP(OP##h, 2, int16_t, FN) \ | 95 | /* |
132 | + DO_VIWDUP(OP##w, 4, int32_t, FN) | 96 | @@ -XXX,XX +XXX,XX @@ typedef struct ARMCPRegUserSpaceInfo { |
97 | uint64_t fixed_bits; | ||
98 | } ARMCPRegUserSpaceInfo; | ||
99 | |||
100 | -#define REGUSERINFO_SENTINEL { .name = NULL } | ||
101 | +void modify_arm_cp_regs_with_len(ARMCPRegInfo *regs, size_t regs_len, | ||
102 | + const ARMCPRegUserSpaceInfo *mods, | ||
103 | + size_t mods_len); | ||
104 | |||
105 | -void modify_arm_cp_regs(ARMCPRegInfo *regs, const ARMCPRegUserSpaceInfo *mods); | ||
106 | +#define modify_arm_cp_regs(REGS, MODS) \ | ||
107 | + do { \ | ||
108 | + QEMU_BUILD_BUG_ON(ARRAY_SIZE(REGS) == 0); \ | ||
109 | + QEMU_BUILD_BUG_ON(ARRAY_SIZE(MODS) == 0); \ | ||
110 | + modify_arm_cp_regs_with_len(REGS, ARRAY_SIZE(REGS), \ | ||
111 | + MODS, ARRAY_SIZE(MODS)); \ | ||
112 | + } while (0) | ||
113 | |||
114 | /* CPWriteFn that can be used to implement writes-ignored behaviour */ | ||
115 | void arm_cp_write_ignore(CPUARMState *env, const ARMCPRegInfo *ri, | ||
116 | diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c | ||
117 | index XXXXXXX..XXXXXXX 100644 | ||
118 | --- a/hw/arm/pxa2xx.c | ||
119 | +++ b/hw/arm/pxa2xx.c | ||
120 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pxa_cp_reginfo[] = { | ||
121 | { .name = "PWRMODE", .cp = 14, .crn = 7, .crm = 0, .opc1 = 0, .opc2 = 0, | ||
122 | .access = PL1_RW, .type = ARM_CP_IO, | ||
123 | .readfn = arm_cp_read_zero, .writefn = pxa2xx_pwrmode_write }, | ||
124 | - REGINFO_SENTINEL | ||
125 | }; | ||
126 | |||
127 | static void pxa2xx_setup_cp14(PXA2xxState *s) | ||
128 | diff --git a/hw/arm/pxa2xx_pic.c b/hw/arm/pxa2xx_pic.c | ||
129 | index XXXXXXX..XXXXXXX 100644 | ||
130 | --- a/hw/arm/pxa2xx_pic.c | ||
131 | +++ b/hw/arm/pxa2xx_pic.c | ||
132 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pxa_pic_cp_reginfo[] = { | ||
133 | REGINFO_FOR_PIC_CP("ICLR2", 8), | ||
134 | REGINFO_FOR_PIC_CP("ICFP2", 9), | ||
135 | REGINFO_FOR_PIC_CP("ICPR2", 0xa), | ||
136 | - REGINFO_SENTINEL | ||
137 | }; | ||
138 | |||
139 | static const MemoryRegionOps pxa2xx_pic_ops = { | ||
140 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c | ||
141 | index XXXXXXX..XXXXXXX 100644 | ||
142 | --- a/hw/intc/arm_gicv3_cpuif.c | ||
143 | +++ b/hw/intc/arm_gicv3_cpuif.c | ||
144 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gicv3_cpuif_reginfo[] = { | ||
145 | .readfn = icc_igrpen1_el3_read, | ||
146 | .writefn = icc_igrpen1_el3_write, | ||
147 | }, | ||
148 | - REGINFO_SENTINEL | ||
149 | }; | ||
150 | |||
151 | static uint64_t ich_ap_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
152 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gicv3_cpuif_hcr_reginfo[] = { | ||
153 | .readfn = ich_vmcr_read, | ||
154 | .writefn = ich_vmcr_write, | ||
155 | }, | ||
156 | - REGINFO_SENTINEL | ||
157 | }; | ||
158 | |||
159 | static const ARMCPRegInfo gicv3_cpuif_ich_apxr1_reginfo[] = { | ||
160 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gicv3_cpuif_ich_apxr1_reginfo[] = { | ||
161 | .readfn = ich_ap_read, | ||
162 | .writefn = ich_ap_write, | ||
163 | }, | ||
164 | - REGINFO_SENTINEL | ||
165 | }; | ||
166 | |||
167 | static const ARMCPRegInfo gicv3_cpuif_ich_apxr23_reginfo[] = { | ||
168 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gicv3_cpuif_ich_apxr23_reginfo[] = { | ||
169 | .readfn = ich_ap_read, | ||
170 | .writefn = ich_ap_write, | ||
171 | }, | ||
172 | - REGINFO_SENTINEL | ||
173 | }; | ||
174 | |||
175 | static void gicv3_cpuif_el_change_hook(ARMCPU *cpu, void *opaque) | ||
176 | @@ -XXX,XX +XXX,XX @@ void gicv3_init_cpuif(GICv3State *s) | ||
177 | .readfn = ich_lr_read, | ||
178 | .writefn = ich_lr_write, | ||
179 | }, | ||
180 | - REGINFO_SENTINEL | ||
181 | }; | ||
182 | define_arm_cp_regs(cpu, lr_regset); | ||
183 | } | ||
184 | diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c | ||
185 | index XXXXXXX..XXXXXXX 100644 | ||
186 | --- a/hw/intc/arm_gicv3_kvm.c | ||
187 | +++ b/hw/intc/arm_gicv3_kvm.c | ||
188 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gicv3_cpuif_reginfo[] = { | ||
189 | */ | ||
190 | .resetfn = arm_gicv3_icc_reset, | ||
191 | }, | ||
192 | - REGINFO_SENTINEL | ||
193 | }; | ||
194 | |||
195 | /** | ||
196 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
197 | index XXXXXXX..XXXXXXX 100644 | ||
198 | --- a/target/arm/cpu64.c | ||
199 | +++ b/target/arm/cpu64.c | ||
200 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cortex_a72_a57_a53_cp_reginfo[] = { | ||
201 | { .name = "L2MERRSR", | ||
202 | .cp = 15, .opc1 = 3, .crm = 15, | ||
203 | .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 }, | ||
204 | - REGINFO_SENTINEL | ||
205 | }; | ||
206 | |||
207 | static void aarch64_a57_initfn(Object *obj) | ||
208 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | ||
209 | index XXXXXXX..XXXXXXX 100644 | ||
210 | --- a/target/arm/cpu_tcg.c | ||
211 | +++ b/target/arm/cpu_tcg.c | ||
212 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cortexa8_cp_reginfo[] = { | ||
213 | .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
214 | { .name = "L2AUXCR", .cp = 15, .crn = 9, .crm = 0, .opc1 = 1, .opc2 = 2, | ||
215 | .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
216 | - REGINFO_SENTINEL | ||
217 | }; | ||
218 | |||
219 | static void cortex_a8_initfn(Object *obj) | ||
220 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cortexa9_cp_reginfo[] = { | ||
221 | .access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST }, | ||
222 | { .name = "TLB_ATTR", .cp = 15, .crn = 15, .crm = 7, .opc1 = 5, .opc2 = 2, | ||
223 | .access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST }, | ||
224 | - REGINFO_SENTINEL | ||
225 | }; | ||
226 | |||
227 | static void cortex_a9_initfn(Object *obj) | ||
228 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cortexa15_cp_reginfo[] = { | ||
229 | #endif | ||
230 | { .name = "L2ECTLR", .cp = 15, .crn = 9, .crm = 0, .opc1 = 1, .opc2 = 3, | ||
231 | .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
232 | - REGINFO_SENTINEL | ||
233 | }; | ||
234 | |||
235 | static void cortex_a7_initfn(Object *obj) | ||
236 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cortexr5_cp_reginfo[] = { | ||
237 | .access = PL1_RW, .type = ARM_CP_CONST }, | ||
238 | { .name = "DCACHE_INVAL", .cp = 15, .opc1 = 0, .crn = 15, .crm = 5, | ||
239 | .opc2 = 0, .access = PL1_W, .type = ARM_CP_NOP }, | ||
240 | - REGINFO_SENTINEL | ||
241 | }; | ||
242 | |||
243 | static void cortex_r5_initfn(Object *obj) | ||
244 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
245 | index XXXXXXX..XXXXXXX 100644 | ||
246 | --- a/target/arm/helper.c | ||
247 | +++ b/target/arm/helper.c | ||
248 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cp_reginfo[] = { | ||
249 | .secure = ARM_CP_SECSTATE_S, | ||
250 | .fieldoffset = offsetof(CPUARMState, cp15.contextidr_s), | ||
251 | .resetvalue = 0, .writefn = contextidr_write, .raw_writefn = raw_write, }, | ||
252 | - REGINFO_SENTINEL | ||
253 | }; | ||
254 | |||
255 | static const ARMCPRegInfo not_v8_cp_reginfo[] = { | ||
256 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo not_v8_cp_reginfo[] = { | ||
257 | { .name = "CACHEMAINT", .cp = 15, .crn = 7, .crm = CP_ANY, | ||
258 | .opc1 = 0, .opc2 = CP_ANY, .access = PL1_W, | ||
259 | .type = ARM_CP_NOP | ARM_CP_OVERRIDE }, | ||
260 | - REGINFO_SENTINEL | ||
261 | }; | ||
262 | |||
263 | static const ARMCPRegInfo not_v6_cp_reginfo[] = { | ||
264 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo not_v6_cp_reginfo[] = { | ||
265 | */ | ||
266 | { .name = "WFI_v5", .cp = 15, .crn = 7, .crm = 8, .opc1 = 0, .opc2 = 2, | ||
267 | .access = PL1_W, .type = ARM_CP_WFI }, | ||
268 | - REGINFO_SENTINEL | ||
269 | }; | ||
270 | |||
271 | static const ARMCPRegInfo not_v7_cp_reginfo[] = { | ||
272 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo not_v7_cp_reginfo[] = { | ||
273 | .opc1 = 0, .opc2 = 0, .access = PL1_RW, .type = ARM_CP_NOP }, | ||
274 | { .name = "NMRR", .cp = 15, .crn = 10, .crm = 2, | ||
275 | .opc1 = 0, .opc2 = 1, .access = PL1_RW, .type = ARM_CP_NOP }, | ||
276 | - REGINFO_SENTINEL | ||
277 | }; | ||
278 | |||
279 | static void cpacr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
280 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6_cp_reginfo[] = { | ||
281 | .crn = 1, .crm = 0, .opc1 = 0, .opc2 = 2, .accessfn = cpacr_access, | ||
282 | .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.cpacr_el1), | ||
283 | .resetfn = cpacr_reset, .writefn = cpacr_write, .readfn = cpacr_read }, | ||
284 | - REGINFO_SENTINEL | ||
285 | }; | ||
286 | |||
287 | typedef struct pm_event { | ||
288 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | ||
289 | { .name = "TLBIMVAA", .cp = 15, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 3, | ||
290 | .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, | ||
291 | .writefn = tlbimvaa_write }, | ||
292 | - REGINFO_SENTINEL | ||
293 | }; | ||
294 | |||
295 | static const ARMCPRegInfo v7mp_cp_reginfo[] = { | ||
296 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7mp_cp_reginfo[] = { | ||
297 | { .name = "TLBIMVAAIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 3, | ||
298 | .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, | ||
299 | .writefn = tlbimvaa_is_write }, | ||
300 | - REGINFO_SENTINEL | ||
301 | }; | ||
302 | |||
303 | static const ARMCPRegInfo pmovsset_cp_reginfo[] = { | ||
304 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pmovsset_cp_reginfo[] = { | ||
305 | .fieldoffset = offsetof(CPUARMState, cp15.c9_pmovsr), | ||
306 | .writefn = pmovsset_write, | ||
307 | .raw_writefn = raw_write }, | ||
308 | - REGINFO_SENTINEL | ||
309 | }; | ||
310 | |||
311 | static void teecr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
312 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo t2ee_cp_reginfo[] = { | ||
313 | { .name = "TEEHBR", .cp = 14, .crn = 1, .crm = 0, .opc1 = 6, .opc2 = 0, | ||
314 | .access = PL0_RW, .fieldoffset = offsetof(CPUARMState, teehbr), | ||
315 | .accessfn = teehbr_access, .resetvalue = 0 }, | ||
316 | - REGINFO_SENTINEL | ||
317 | }; | ||
318 | |||
319 | static const ARMCPRegInfo v6k_cp_reginfo[] = { | ||
320 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6k_cp_reginfo[] = { | ||
321 | .bank_fieldoffsets = { offsetoflow32(CPUARMState, cp15.tpidrprw_s), | ||
322 | offsetoflow32(CPUARMState, cp15.tpidrprw_ns) }, | ||
323 | .resetvalue = 0 }, | ||
324 | - REGINFO_SENTINEL | ||
325 | }; | ||
326 | |||
327 | #ifndef CONFIG_USER_ONLY | ||
328 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = { | ||
329 | .fieldoffset = offsetof(CPUARMState, cp15.c14_timer[GTIMER_SEC].cval), | ||
330 | .writefn = gt_sec_cval_write, .raw_writefn = raw_write, | ||
331 | }, | ||
332 | - REGINFO_SENTINEL | ||
333 | }; | ||
334 | |||
335 | static CPAccessResult e2h_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
336 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = { | ||
337 | .access = PL0_R, .type = ARM_CP_NO_RAW | ARM_CP_IO, | ||
338 | .readfn = gt_virt_cnt_read, | ||
339 | }, | ||
340 | - REGINFO_SENTINEL | ||
341 | }; | ||
342 | |||
343 | #endif | ||
344 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vapa_cp_reginfo[] = { | ||
345 | .access = PL1_W, .accessfn = ats_access, | ||
346 | .writefn = ats_write, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC }, | ||
347 | #endif | ||
348 | - REGINFO_SENTINEL | ||
349 | }; | ||
350 | |||
351 | /* Return basic MPU access permission bits. */ | ||
352 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pmsav7_cp_reginfo[] = { | ||
353 | .fieldoffset = offsetof(CPUARMState, pmsav7.rnr[M_REG_NS]), | ||
354 | .writefn = pmsav7_rgnr_write, | ||
355 | .resetfn = arm_cp_reset_ignore }, | ||
356 | - REGINFO_SENTINEL | ||
357 | }; | ||
358 | |||
359 | static const ARMCPRegInfo pmsav5_cp_reginfo[] = { | ||
360 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pmsav5_cp_reginfo[] = { | ||
361 | { .name = "946_PRBS7", .cp = 15, .crn = 6, .crm = 7, .opc1 = 0, | ||
362 | .opc2 = CP_ANY, .access = PL1_RW, .resetvalue = 0, | ||
363 | .fieldoffset = offsetof(CPUARMState, cp15.c6_region[7]) }, | ||
364 | - REGINFO_SENTINEL | ||
365 | }; | ||
366 | |||
367 | static void vmsa_ttbcr_raw_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
368 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vmsa_pmsa_cp_reginfo[] = { | ||
369 | .access = PL1_RW, .accessfn = access_tvm_trvm, | ||
370 | .fieldoffset = offsetof(CPUARMState, cp15.far_el[1]), | ||
371 | .resetvalue = 0, }, | ||
372 | - REGINFO_SENTINEL | ||
373 | }; | ||
374 | |||
375 | static const ARMCPRegInfo vmsa_cp_reginfo[] = { | ||
376 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vmsa_cp_reginfo[] = { | ||
377 | /* No offsetoflow32 -- pass the entire TCR to writefn/raw_writefn. */ | ||
378 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.tcr_el[3]), | ||
379 | offsetof(CPUARMState, cp15.tcr_el[1])} }, | ||
380 | - REGINFO_SENTINEL | ||
381 | }; | ||
382 | |||
383 | /* Note that unlike TTBCR, writing to TTBCR2 does not require flushing | ||
384 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo omap_cp_reginfo[] = { | ||
385 | { .name = "C9", .cp = 15, .crn = 9, | ||
386 | .crm = CP_ANY, .opc1 = CP_ANY, .opc2 = CP_ANY, .access = PL1_RW, | ||
387 | .type = ARM_CP_CONST | ARM_CP_OVERRIDE, .resetvalue = 0 }, | ||
388 | - REGINFO_SENTINEL | ||
389 | }; | ||
390 | |||
391 | static void xscale_cpar_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
392 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo xscale_cp_reginfo[] = { | ||
393 | { .name = "XSCALE_UNLOCK_DCACHE", | ||
394 | .cp = 15, .opc1 = 0, .crn = 9, .crm = 2, .opc2 = 1, | ||
395 | .access = PL1_W, .type = ARM_CP_NOP }, | ||
396 | - REGINFO_SENTINEL | ||
397 | }; | ||
398 | |||
399 | static const ARMCPRegInfo dummy_c15_cp_reginfo[] = { | ||
400 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo dummy_c15_cp_reginfo[] = { | ||
401 | .access = PL1_RW, | ||
402 | .type = ARM_CP_CONST | ARM_CP_NO_RAW | ARM_CP_OVERRIDE, | ||
403 | .resetvalue = 0 }, | ||
404 | - REGINFO_SENTINEL | ||
405 | }; | ||
406 | |||
407 | static const ARMCPRegInfo cache_dirty_status_cp_reginfo[] = { | ||
408 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cache_dirty_status_cp_reginfo[] = { | ||
409 | { .name = "CDSR", .cp = 15, .crn = 7, .crm = 10, .opc1 = 0, .opc2 = 6, | ||
410 | .access = PL1_R, .type = ARM_CP_CONST | ARM_CP_NO_RAW, | ||
411 | .resetvalue = 0 }, | ||
412 | - REGINFO_SENTINEL | ||
413 | }; | ||
414 | |||
415 | static const ARMCPRegInfo cache_block_ops_cp_reginfo[] = { | ||
416 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cache_block_ops_cp_reginfo[] = { | ||
417 | .access = PL0_W, .type = ARM_CP_NOP|ARM_CP_64BIT }, | ||
418 | { .name = "CIDCR", .cp = 15, .crm = 14, .opc1 = 0, | ||
419 | .access = PL1_W, .type = ARM_CP_NOP|ARM_CP_64BIT }, | ||
420 | - REGINFO_SENTINEL | ||
421 | }; | ||
422 | |||
423 | static const ARMCPRegInfo cache_test_clean_cp_reginfo[] = { | ||
424 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cache_test_clean_cp_reginfo[] = { | ||
425 | { .name = "TCI_DCACHE", .cp = 15, .crn = 7, .crm = 14, .opc1 = 0, .opc2 = 3, | ||
426 | .access = PL0_R, .type = ARM_CP_CONST | ARM_CP_NO_RAW, | ||
427 | .resetvalue = (1 << 30) }, | ||
428 | - REGINFO_SENTINEL | ||
429 | }; | ||
430 | |||
431 | static const ARMCPRegInfo strongarm_cp_reginfo[] = { | ||
432 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo strongarm_cp_reginfo[] = { | ||
433 | .crm = CP_ANY, .opc1 = CP_ANY, .opc2 = CP_ANY, | ||
434 | .access = PL1_RW, .resetvalue = 0, | ||
435 | .type = ARM_CP_CONST | ARM_CP_OVERRIDE | ARM_CP_NO_RAW }, | ||
436 | - REGINFO_SENTINEL | ||
437 | }; | ||
438 | |||
439 | static uint64_t midr_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
440 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo lpae_cp_reginfo[] = { | ||
441 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.ttbr1_s), | ||
442 | offsetof(CPUARMState, cp15.ttbr1_ns) }, | ||
443 | .writefn = vmsa_ttbr_write, }, | ||
444 | - REGINFO_SENTINEL | ||
445 | }; | ||
446 | |||
447 | static uint64_t aa64_fpcr_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
448 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | ||
449 | .access = PL1_RW, .accessfn = access_trap_aa32s_el1, | ||
450 | .writefn = sdcr_write, | ||
451 | .fieldoffset = offsetoflow32(CPUARMState, cp15.mdcr_el3) }, | ||
452 | - REGINFO_SENTINEL | ||
453 | }; | ||
454 | |||
455 | /* Used to describe the behaviour of EL2 regs when EL2 does not exist. */ | ||
456 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el3_no_el2_cp_reginfo[] = { | ||
457 | .type = ARM_CP_CONST, | ||
458 | .cp = 15, .opc1 = 4, .crn = 6, .crm = 0, .opc2 = 2, | ||
459 | .access = PL2_RW, .resetvalue = 0 }, | ||
460 | - REGINFO_SENTINEL | ||
461 | }; | ||
462 | |||
463 | /* Ditto, but for registers which exist in ARMv8 but not v7 */ | ||
464 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el3_no_el2_v8_cp_reginfo[] = { | ||
465 | .cp = 15, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 4, | ||
466 | .access = PL2_RW, | ||
467 | .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
468 | - REGINFO_SENTINEL | ||
469 | }; | ||
470 | |||
471 | static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask) | ||
472 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = { | ||
473 | .cp = 15, .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 3, | ||
474 | .access = PL2_RW, | ||
475 | .fieldoffset = offsetof(CPUARMState, cp15.hstr_el2) }, | ||
476 | - REGINFO_SENTINEL | ||
477 | }; | ||
478 | |||
479 | static const ARMCPRegInfo el2_v8_cp_reginfo[] = { | ||
480 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_v8_cp_reginfo[] = { | ||
481 | .access = PL2_RW, | ||
482 | .fieldoffset = offsetofhigh32(CPUARMState, cp15.hcr_el2), | ||
483 | .writefn = hcr_writehigh }, | ||
484 | - REGINFO_SENTINEL | ||
485 | }; | ||
486 | |||
487 | static CPAccessResult sel2_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
488 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_sec_cp_reginfo[] = { | ||
489 | .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 6, .opc2 = 2, | ||
490 | .access = PL2_RW, .accessfn = sel2_access, | ||
491 | .fieldoffset = offsetof(CPUARMState, cp15.vstcr_el2) }, | ||
492 | - REGINFO_SENTINEL | ||
493 | }; | ||
494 | |||
495 | static CPAccessResult nsacr_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
496 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el3_cp_reginfo[] = { | ||
497 | .opc0 = 1, .opc1 = 6, .crn = 8, .crm = 7, .opc2 = 5, | ||
498 | .access = PL3_W, .type = ARM_CP_NO_RAW, | ||
499 | .writefn = tlbi_aa64_vae3_write }, | ||
500 | - REGINFO_SENTINEL | ||
501 | }; | ||
502 | |||
503 | #ifndef CONFIG_USER_ONLY | ||
504 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_cp_reginfo[] = { | ||
505 | .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 0, | ||
506 | .access = PL1_RW, .accessfn = access_tda, | ||
507 | .type = ARM_CP_NOP }, | ||
508 | - REGINFO_SENTINEL | ||
509 | }; | ||
510 | |||
511 | static const ARMCPRegInfo debug_lpae_cp_reginfo[] = { | ||
512 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_lpae_cp_reginfo[] = { | ||
513 | .access = PL0_R, .type = ARM_CP_CONST|ARM_CP_64BIT, .resetvalue = 0 }, | ||
514 | { .name = "DBGDSAR", .cp = 14, .crm = 2, .opc1 = 0, | ||
515 | .access = PL0_R, .type = ARM_CP_CONST|ARM_CP_64BIT, .resetvalue = 0 }, | ||
516 | - REGINFO_SENTINEL | ||
517 | }; | ||
518 | |||
519 | /* Return the exception level to which exceptions should be taken | ||
520 | @@ -XXX,XX +XXX,XX @@ static void define_debug_regs(ARMCPU *cpu) | ||
521 | .fieldoffset = offsetof(CPUARMState, cp15.dbgbcr[i]), | ||
522 | .writefn = dbgbcr_write, .raw_writefn = raw_write | ||
523 | }, | ||
524 | - REGINFO_SENTINEL | ||
525 | }; | ||
526 | define_arm_cp_regs(cpu, dbgregs); | ||
527 | } | ||
528 | @@ -XXX,XX +XXX,XX @@ static void define_debug_regs(ARMCPU *cpu) | ||
529 | .fieldoffset = offsetof(CPUARMState, cp15.dbgwcr[i]), | ||
530 | .writefn = dbgwcr_write, .raw_writefn = raw_write | ||
531 | }, | ||
532 | - REGINFO_SENTINEL | ||
533 | }; | ||
534 | define_arm_cp_regs(cpu, dbgregs); | ||
535 | } | ||
536 | @@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu) | ||
537 | .type = ARM_CP_IO, | ||
538 | .readfn = pmevtyper_readfn, .writefn = pmevtyper_writefn, | ||
539 | .raw_writefn = pmevtyper_rawwrite }, | ||
540 | - REGINFO_SENTINEL | ||
541 | }; | ||
542 | define_arm_cp_regs(cpu, pmev_regs); | ||
543 | g_free(pmevcntr_name); | ||
544 | @@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu) | ||
545 | .cp = 15, .opc1 = 0, .crn = 9, .crm = 14, .opc2 = 5, | ||
546 | .access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST, | ||
547 | .resetvalue = extract64(cpu->pmceid1, 32, 32) }, | ||
548 | - REGINFO_SENTINEL | ||
549 | }; | ||
550 | define_arm_cp_regs(cpu, v81_pmu_regs); | ||
551 | } | ||
552 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo lor_reginfo[] = { | ||
553 | .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 7, | ||
554 | .access = PL1_R, .accessfn = access_lor_ns, | ||
555 | .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
556 | - REGINFO_SENTINEL | ||
557 | }; | ||
558 | |||
559 | #ifdef TARGET_AARCH64 | ||
560 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pauth_reginfo[] = { | ||
561 | .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 1, .opc2 = 3, | ||
562 | .access = PL1_RW, .accessfn = access_pauth, | ||
563 | .fieldoffset = offsetof(CPUARMState, keys.apib.hi) }, | ||
564 | - REGINFO_SENTINEL | ||
565 | }; | ||
566 | |||
567 | static const ARMCPRegInfo tlbirange_reginfo[] = { | ||
568 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo tlbirange_reginfo[] = { | ||
569 | .opc0 = 1, .opc1 = 6, .crn = 8, .crm = 6, .opc2 = 5, | ||
570 | .access = PL3_W, .type = ARM_CP_NO_RAW, | ||
571 | .writefn = tlbi_aa64_rvae3_write }, | ||
572 | - REGINFO_SENTINEL | ||
573 | }; | ||
574 | |||
575 | static const ARMCPRegInfo tlbios_reginfo[] = { | ||
576 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo tlbios_reginfo[] = { | ||
577 | .opc0 = 1, .opc1 = 6, .crn = 8, .crm = 1, .opc2 = 5, | ||
578 | .access = PL3_W, .type = ARM_CP_NO_RAW, | ||
579 | .writefn = tlbi_aa64_vae3is_write }, | ||
580 | - REGINFO_SENTINEL | ||
581 | }; | ||
582 | |||
583 | static uint64_t rndr_readfn(CPUARMState *env, const ARMCPRegInfo *ri) | ||
584 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo rndr_reginfo[] = { | ||
585 | .type = ARM_CP_NO_RAW | ARM_CP_SUPPRESS_TB_END | ARM_CP_IO, | ||
586 | .opc0 = 3, .opc1 = 3, .crn = 2, .crm = 4, .opc2 = 1, | ||
587 | .access = PL0_R, .readfn = rndr_readfn }, | ||
588 | - REGINFO_SENTINEL | ||
589 | }; | ||
590 | |||
591 | #ifndef CONFIG_USER_ONLY | ||
592 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo dcpop_reg[] = { | ||
593 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 12, .opc2 = 1, | ||
594 | .access = PL0_W, .type = ARM_CP_NO_RAW | ARM_CP_SUPPRESS_TB_END, | ||
595 | .accessfn = aa64_cacheop_poc_access, .writefn = dccvap_writefn }, | ||
596 | - REGINFO_SENTINEL | ||
597 | }; | ||
598 | |||
599 | static const ARMCPRegInfo dcpodp_reg[] = { | ||
600 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo dcpodp_reg[] = { | ||
601 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 13, .opc2 = 1, | ||
602 | .access = PL0_W, .type = ARM_CP_NO_RAW | ARM_CP_SUPPRESS_TB_END, | ||
603 | .accessfn = aa64_cacheop_poc_access, .writefn = dccvap_writefn }, | ||
604 | - REGINFO_SENTINEL | ||
605 | }; | ||
606 | #endif /*CONFIG_USER_ONLY*/ | ||
607 | |||
608 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo mte_reginfo[] = { | ||
609 | { .name = "DC_CIGDSW", .state = ARM_CP_STATE_AA64, | ||
610 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 14, .opc2 = 6, | ||
611 | .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw }, | ||
612 | - REGINFO_SENTINEL | ||
613 | }; | ||
614 | |||
615 | static const ARMCPRegInfo mte_tco_ro_reginfo[] = { | ||
616 | { .name = "TCO", .state = ARM_CP_STATE_AA64, | ||
617 | .opc0 = 3, .opc1 = 3, .crn = 4, .crm = 2, .opc2 = 7, | ||
618 | .type = ARM_CP_CONST, .access = PL0_RW, }, | ||
619 | - REGINFO_SENTINEL | ||
620 | }; | ||
621 | |||
622 | static const ARMCPRegInfo mte_el0_cacheop_reginfo[] = { | ||
623 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo mte_el0_cacheop_reginfo[] = { | ||
624 | .accessfn = aa64_zva_access, | ||
625 | #endif | ||
626 | }, | ||
627 | - REGINFO_SENTINEL | ||
628 | }; | ||
629 | |||
630 | #endif | ||
631 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo predinv_reginfo[] = { | ||
632 | { .name = "CPPRCTX", .state = ARM_CP_STATE_AA32, | ||
633 | .cp = 15, .opc1 = 0, .crn = 7, .crm = 3, .opc2 = 7, | ||
634 | .type = ARM_CP_NOP, .access = PL0_W, .accessfn = access_predinv }, | ||
635 | - REGINFO_SENTINEL | ||
636 | }; | ||
637 | |||
638 | static uint64_t ccsidr2_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
639 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo ccsidr2_reginfo[] = { | ||
640 | .access = PL1_R, | ||
641 | .accessfn = access_aa64_tid2, | ||
642 | .readfn = ccsidr2_read, .type = ARM_CP_NO_RAW }, | ||
643 | - REGINFO_SENTINEL | ||
644 | }; | ||
645 | |||
646 | static CPAccessResult access_aa64_tid3(CPUARMState *env, const ARMCPRegInfo *ri, | ||
647 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo jazelle_regs[] = { | ||
648 | .cp = 14, .crn = 2, .crm = 0, .opc1 = 7, .opc2 = 0, | ||
649 | .accessfn = access_joscr_jmcr, | ||
650 | .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
651 | - REGINFO_SENTINEL | ||
652 | }; | ||
653 | |||
654 | static const ARMCPRegInfo vhe_reginfo[] = { | ||
655 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vhe_reginfo[] = { | ||
656 | .access = PL2_RW, .accessfn = e2h_access, | ||
657 | .writefn = gt_virt_cval_write, .raw_writefn = raw_write }, | ||
658 | #endif | ||
659 | - REGINFO_SENTINEL | ||
660 | }; | ||
661 | |||
662 | #ifndef CONFIG_USER_ONLY | ||
663 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo ats1e1_reginfo[] = { | ||
664 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 9, .opc2 = 1, | ||
665 | .access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, | ||
666 | .writefn = ats_write64 }, | ||
667 | - REGINFO_SENTINEL | ||
668 | }; | ||
669 | |||
670 | static const ARMCPRegInfo ats1cp_reginfo[] = { | ||
671 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo ats1cp_reginfo[] = { | ||
672 | .cp = 15, .opc1 = 0, .crn = 7, .crm = 9, .opc2 = 1, | ||
673 | .access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, | ||
674 | .writefn = ats_write }, | ||
675 | - REGINFO_SENTINEL | ||
676 | }; | ||
677 | #endif | ||
678 | |||
679 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo actlr2_hactlr2_reginfo[] = { | ||
680 | .cp = 15, .opc1 = 4, .crn = 1, .crm = 0, .opc2 = 3, | ||
681 | .access = PL2_RW, .type = ARM_CP_CONST, | ||
682 | .resetvalue = 0 }, | ||
683 | - REGINFO_SENTINEL | ||
684 | }; | ||
685 | |||
686 | void register_cp_regs_for_features(ARMCPU *cpu) | ||
687 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
688 | .access = PL1_R, .type = ARM_CP_CONST, | ||
689 | .accessfn = access_aa32_tid3, | ||
690 | .resetvalue = cpu->isar.id_isar6 }, | ||
691 | - REGINFO_SENTINEL | ||
692 | }; | ||
693 | define_arm_cp_regs(cpu, v6_idregs); | ||
694 | define_arm_cp_regs(cpu, v6_cp_reginfo); | ||
695 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
696 | .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 7, | ||
697 | .access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST, | ||
698 | .resetvalue = cpu->pmceid1 }, | ||
699 | - REGINFO_SENTINEL | ||
700 | }; | ||
701 | #ifdef CONFIG_USER_ONLY | ||
702 | ARMCPRegUserSpaceInfo v8_user_idregs[] = { | ||
703 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
704 | .exported_bits = 0x000000f0ffffffff }, | ||
705 | { .name = "ID_AA64ISAR*_EL1_RESERVED", | ||
706 | .is_glob = true }, | ||
707 | - REGUSERINFO_SENTINEL | ||
708 | }; | ||
709 | modify_arm_cp_regs(v8_idregs, v8_user_idregs); | ||
710 | #endif | ||
711 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
712 | .access = PL2_RW, | ||
713 | .resetvalue = vmpidr_def, | ||
714 | .fieldoffset = offsetof(CPUARMState, cp15.vmpidr_el2) }, | ||
715 | - REGINFO_SENTINEL | ||
716 | }; | ||
717 | define_arm_cp_regs(cpu, vpidr_regs); | ||
718 | define_arm_cp_regs(cpu, el2_cp_reginfo); | ||
719 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
720 | .access = PL2_RW, .accessfn = access_el3_aa32ns, | ||
721 | .type = ARM_CP_NO_RAW, | ||
722 | .writefn = arm_cp_write_ignore, .readfn = mpidr_read }, | ||
723 | - REGINFO_SENTINEL | ||
724 | }; | ||
725 | define_arm_cp_regs(cpu, vpidr_regs); | ||
726 | define_arm_cp_regs(cpu, el3_no_el2_cp_reginfo); | ||
727 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
728 | .raw_writefn = raw_write, .writefn = sctlr_write, | ||
729 | .fieldoffset = offsetof(CPUARMState, cp15.sctlr_el[3]), | ||
730 | .resetvalue = cpu->reset_sctlr }, | ||
731 | - REGINFO_SENTINEL | ||
732 | }; | ||
733 | |||
734 | define_arm_cp_regs(cpu, el3_regs); | ||
735 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
736 | { .name = "DUMMY", | ||
737 | .cp = 15, .crn = 0, .crm = 7, .opc1 = 0, .opc2 = CP_ANY, | ||
738 | .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
739 | - REGINFO_SENTINEL | ||
740 | }; | ||
741 | ARMCPRegInfo id_v8_midr_cp_reginfo[] = { | ||
742 | { .name = "MIDR_EL1", .state = ARM_CP_STATE_BOTH, | ||
743 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
744 | .access = PL1_R, | ||
745 | .accessfn = access_aa64_tid1, | ||
746 | .type = ARM_CP_CONST, .resetvalue = cpu->revidr }, | ||
747 | - REGINFO_SENTINEL | ||
748 | }; | ||
749 | ARMCPRegInfo id_cp_reginfo[] = { | ||
750 | /* These are common to v8 and pre-v8 */ | ||
751 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
752 | .access = PL1_R, | ||
753 | .accessfn = access_aa32_tid1, | ||
754 | .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
755 | - REGINFO_SENTINEL | ||
756 | }; | ||
757 | /* TLBTR is specific to VMSA */ | ||
758 | ARMCPRegInfo id_tlbtr_reginfo = { | ||
759 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
760 | { .name = "MIDR_EL1", | ||
761 | .exported_bits = 0x00000000ffffffff }, | ||
762 | { .name = "REVIDR_EL1" }, | ||
763 | - REGUSERINFO_SENTINEL | ||
764 | }; | ||
765 | modify_arm_cp_regs(id_v8_midr_cp_reginfo, id_v8_user_midr_cp_reginfo); | ||
766 | #endif | ||
767 | if (arm_feature(env, ARM_FEATURE_OMAPCP) || | ||
768 | arm_feature(env, ARM_FEATURE_STRONGARM)) { | ||
769 | - ARMCPRegInfo *r; | ||
770 | + size_t i; | ||
771 | /* Register the blanket "writes ignored" value first to cover the | ||
772 | * whole space. Then update the specific ID registers to allow write | ||
773 | * access, so that they ignore writes rather than causing them to | ||
774 | * UNDEF. | ||
775 | */ | ||
776 | define_one_arm_cp_reg(cpu, &crn0_wi_reginfo); | ||
777 | - for (r = id_pre_v8_midr_cp_reginfo; | ||
778 | - r->type != ARM_CP_SENTINEL; r++) { | ||
779 | - r->access = PL1_RW; | ||
780 | + for (i = 0; i < ARRAY_SIZE(id_pre_v8_midr_cp_reginfo); ++i) { | ||
781 | + id_pre_v8_midr_cp_reginfo[i].access = PL1_RW; | ||
782 | } | ||
783 | - for (r = id_cp_reginfo; r->type != ARM_CP_SENTINEL; r++) { | ||
784 | - r->access = PL1_RW; | ||
785 | + for (i = 0; i < ARRAY_SIZE(id_cp_reginfo); ++i) { | ||
786 | + id_cp_reginfo[i].access = PL1_RW; | ||
787 | } | ||
788 | id_mpuir_reginfo.access = PL1_RW; | ||
789 | id_tlbtr_reginfo.access = PL1_RW; | ||
790 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
791 | { .name = "MPIDR_EL1", .state = ARM_CP_STATE_BOTH, | ||
792 | .opc0 = 3, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 5, | ||
793 | .access = PL1_R, .readfn = mpidr_read, .type = ARM_CP_NO_RAW }, | ||
794 | - REGINFO_SENTINEL | ||
795 | }; | ||
796 | #ifdef CONFIG_USER_ONLY | ||
797 | ARMCPRegUserSpaceInfo mpidr_user_cp_reginfo[] = { | ||
798 | { .name = "MPIDR_EL1", | ||
799 | .fixed_bits = 0x0000000080000000 }, | ||
800 | - REGUSERINFO_SENTINEL | ||
801 | }; | ||
802 | modify_arm_cp_regs(mpidr_cp_reginfo, mpidr_user_cp_reginfo); | ||
803 | #endif | ||
804 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
805 | .opc0 = 3, .opc1 = 6, .crn = 1, .crm = 0, .opc2 = 1, | ||
806 | .access = PL3_RW, .type = ARM_CP_CONST, | ||
807 | .resetvalue = 0 }, | ||
808 | - REGINFO_SENTINEL | ||
809 | }; | ||
810 | define_arm_cp_regs(cpu, auxcr_reginfo); | ||
811 | if (cpu_isar_feature(aa32_ac2, cpu)) { | ||
812 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
813 | .type = ARM_CP_CONST, | ||
814 | .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 3, .opc2 = 0, | ||
815 | .access = PL1_R, .resetvalue = cpu->reset_cbar }, | ||
816 | - REGINFO_SENTINEL | ||
817 | }; | ||
818 | /* We don't implement a r/w 64 bit CBAR currently */ | ||
819 | assert(arm_feature(env, ARM_FEATURE_CBAR_RO)); | ||
820 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
821 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.vbar_s), | ||
822 | offsetof(CPUARMState, cp15.vbar_ns) }, | ||
823 | .resetvalue = 0 }, | ||
824 | - REGINFO_SENTINEL | ||
825 | }; | ||
826 | define_arm_cp_regs(cpu, vbar_cp_reginfo); | ||
827 | } | ||
828 | @@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, | ||
829 | r->writefn); | ||
830 | } | ||
831 | } | ||
832 | - /* Bad type field probably means missing sentinel at end of reg list */ | ||
833 | - assert(cptype_valid(r->type)); | ||
133 | + | 834 | + |
134 | +static uint32_t do_add_wrap(uint32_t offset, uint32_t wrap, uint32_t imm) | 835 | for (crm = crmmin; crm <= crmmax; crm++) { |
135 | +{ | 836 | for (opc1 = opc1min; opc1 <= opc1max; opc1++) { |
136 | + offset += imm; | 837 | for (opc2 = opc2min; opc2 <= opc2max; opc2++) { |
137 | + if (offset == wrap) { | 838 | @@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, |
138 | + offset = 0; | 839 | } |
139 | + } | 840 | } |
140 | + return offset; | 841 | |
141 | +} | 842 | -void define_arm_cp_regs_with_opaque(ARMCPU *cpu, |
843 | - const ARMCPRegInfo *regs, void *opaque) | ||
844 | +/* Define a whole list of registers */ | ||
845 | +void define_arm_cp_regs_with_opaque_len(ARMCPU *cpu, const ARMCPRegInfo *regs, | ||
846 | + void *opaque, size_t len) | ||
847 | { | ||
848 | - /* Define a whole list of registers */ | ||
849 | - const ARMCPRegInfo *r; | ||
850 | - for (r = regs; r->type != ARM_CP_SENTINEL; r++) { | ||
851 | - define_one_arm_cp_reg_with_opaque(cpu, r, opaque); | ||
852 | + size_t i; | ||
853 | + for (i = 0; i < len; ++i) { | ||
854 | + define_one_arm_cp_reg_with_opaque(cpu, regs + i, opaque); | ||
855 | } | ||
856 | } | ||
857 | |||
858 | @@ -XXX,XX +XXX,XX @@ void define_arm_cp_regs_with_opaque(ARMCPU *cpu, | ||
859 | * user-space cannot alter any values and dynamic values pertaining to | ||
860 | * execution state are hidden from user space view anyway. | ||
861 | */ | ||
862 | -void modify_arm_cp_regs(ARMCPRegInfo *regs, const ARMCPRegUserSpaceInfo *mods) | ||
863 | +void modify_arm_cp_regs_with_len(ARMCPRegInfo *regs, size_t regs_len, | ||
864 | + const ARMCPRegUserSpaceInfo *mods, | ||
865 | + size_t mods_len) | ||
866 | { | ||
867 | - const ARMCPRegUserSpaceInfo *m; | ||
868 | - ARMCPRegInfo *r; | ||
869 | - | ||
870 | - for (m = mods; m->name; m++) { | ||
871 | + for (size_t mi = 0; mi < mods_len; ++mi) { | ||
872 | + const ARMCPRegUserSpaceInfo *m = mods + mi; | ||
873 | GPatternSpec *pat = NULL; | ||
142 | + | 874 | + |
143 | +static uint32_t do_sub_wrap(uint32_t offset, uint32_t wrap, uint32_t imm) | 875 | if (m->is_glob) { |
144 | +{ | 876 | pat = g_pattern_spec_new(m->name); |
145 | + if (offset == 0) { | 877 | } |
146 | + offset = wrap; | 878 | - for (r = regs; r->type != ARM_CP_SENTINEL; r++) { |
147 | + } | 879 | + for (size_t ri = 0; ri < regs_len; ++ri) { |
148 | + offset -= imm; | 880 | + ARMCPRegInfo *r = regs + ri; |
149 | + return offset; | ||
150 | +} | ||
151 | + | 881 | + |
152 | +DO_VIDUP_ALL(vidup, DO_ADD) | 882 | if (pat && g_pattern_match_string(pat, r->name)) { |
153 | +DO_VIWDUP_ALL(viwdup, do_add_wrap) | 883 | r->type = ARM_CP_CONST; |
154 | +DO_VIWDUP_ALL(vdwdup, do_sub_wrap) | 884 | r->access = PL0U_R; |
155 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
156 | index XXXXXXX..XXXXXXX 100644 | ||
157 | --- a/target/arm/translate-mve.c | ||
158 | +++ b/target/arm/translate-mve.c | ||
159 | @@ -XXX,XX +XXX,XX @@ | ||
160 | #include "translate.h" | ||
161 | #include "translate-a32.h" | ||
162 | |||
163 | +static inline int vidup_imm(DisasContext *s, int x) | ||
164 | +{ | ||
165 | + return 1 << x; | ||
166 | +} | ||
167 | + | ||
168 | /* Include the generated decoder */ | ||
169 | #include "decode-mve.c.inc" | ||
170 | |||
171 | @@ -XXX,XX +XXX,XX @@ typedef void MVEGenTwoOpShiftFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
172 | typedef void MVEGenDualAccOpFn(TCGv_i64, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
173 | typedef void MVEGenVADDVFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
174 | typedef void MVEGenOneOpImmFn(TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
175 | +typedef void MVEGenVIDUPFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32, TCGv_i32); | ||
176 | +typedef void MVEGenVIWDUPFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32, TCGv_i32, TCGv_i32); | ||
177 | |||
178 | /* Return the offset of a Qn register (same semantics as aa32_vfp_qreg()) */ | ||
179 | static inline long mve_qreg_offset(unsigned reg) | ||
180 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSHLC(DisasContext *s, arg_VSHLC *a) | ||
181 | mve_update_eci(s); | ||
182 | return true; | ||
183 | } | ||
184 | + | ||
185 | +static bool do_vidup(DisasContext *s, arg_vidup *a, MVEGenVIDUPFn *fn) | ||
186 | +{ | ||
187 | + TCGv_ptr qd; | ||
188 | + TCGv_i32 rn; | ||
189 | + | ||
190 | + /* | ||
191 | + * Vector increment/decrement with wrap and duplicate (VIDUP, VDDUP). | ||
192 | + * This fills the vector with elements of successively increasing | ||
193 | + * or decreasing values, starting from Rn. | ||
194 | + */ | ||
195 | + if (!dc_isar_feature(aa32_mve, s) || !mve_check_qreg_bank(s, a->qd)) { | ||
196 | + return false; | ||
197 | + } | ||
198 | + if (a->size == MO_64) { | ||
199 | + /* size 0b11 is another encoding */ | ||
200 | + return false; | ||
201 | + } | ||
202 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
203 | + return true; | ||
204 | + } | ||
205 | + | ||
206 | + qd = mve_qreg_ptr(a->qd); | ||
207 | + rn = load_reg(s, a->rn); | ||
208 | + fn(rn, cpu_env, qd, rn, tcg_constant_i32(a->imm)); | ||
209 | + store_reg(s, a->rn, rn); | ||
210 | + tcg_temp_free_ptr(qd); | ||
211 | + mve_update_eci(s); | ||
212 | + return true; | ||
213 | +} | ||
214 | + | ||
215 | +static bool do_viwdup(DisasContext *s, arg_viwdup *a, MVEGenVIWDUPFn *fn) | ||
216 | +{ | ||
217 | + TCGv_ptr qd; | ||
218 | + TCGv_i32 rn, rm; | ||
219 | + | ||
220 | + /* | ||
221 | + * Vector increment/decrement with wrap and duplicate (VIWDUp, VDWDUP) | ||
222 | + * This fills the vector with elements of successively increasing | ||
223 | + * or decreasing values, starting from Rn. Rm specifies a point where | ||
224 | + * the count wraps back around to 0. The updated offset is written back | ||
225 | + * to Rn. | ||
226 | + */ | ||
227 | + if (!dc_isar_feature(aa32_mve, s) || !mve_check_qreg_bank(s, a->qd)) { | ||
228 | + return false; | ||
229 | + } | ||
230 | + if (!fn || a->rm == 13 || a->rm == 15) { | ||
231 | + /* | ||
232 | + * size 0b11 is another encoding; Rm == 13 is UNPREDICTABLE; | ||
233 | + * Rm == 13 is VIWDUP, VDWDUP. | ||
234 | + */ | ||
235 | + return false; | ||
236 | + } | ||
237 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
238 | + return true; | ||
239 | + } | ||
240 | + | ||
241 | + qd = mve_qreg_ptr(a->qd); | ||
242 | + rn = load_reg(s, a->rn); | ||
243 | + rm = load_reg(s, a->rm); | ||
244 | + fn(rn, cpu_env, qd, rn, rm, tcg_constant_i32(a->imm)); | ||
245 | + store_reg(s, a->rn, rn); | ||
246 | + tcg_temp_free_ptr(qd); | ||
247 | + tcg_temp_free_i32(rm); | ||
248 | + mve_update_eci(s); | ||
249 | + return true; | ||
250 | +} | ||
251 | + | ||
252 | +static bool trans_VIDUP(DisasContext *s, arg_vidup *a) | ||
253 | +{ | ||
254 | + static MVEGenVIDUPFn * const fns[] = { | ||
255 | + gen_helper_mve_vidupb, | ||
256 | + gen_helper_mve_viduph, | ||
257 | + gen_helper_mve_vidupw, | ||
258 | + NULL, | ||
259 | + }; | ||
260 | + return do_vidup(s, a, fns[a->size]); | ||
261 | +} | ||
262 | + | ||
263 | +static bool trans_VDDUP(DisasContext *s, arg_vidup *a) | ||
264 | +{ | ||
265 | + static MVEGenVIDUPFn * const fns[] = { | ||
266 | + gen_helper_mve_vidupb, | ||
267 | + gen_helper_mve_viduph, | ||
268 | + gen_helper_mve_vidupw, | ||
269 | + NULL, | ||
270 | + }; | ||
271 | + /* VDDUP is just like VIDUP but with a negative immediate */ | ||
272 | + a->imm = -a->imm; | ||
273 | + return do_vidup(s, a, fns[a->size]); | ||
274 | +} | ||
275 | + | ||
276 | +static bool trans_VIWDUP(DisasContext *s, arg_viwdup *a) | ||
277 | +{ | ||
278 | + static MVEGenVIWDUPFn * const fns[] = { | ||
279 | + gen_helper_mve_viwdupb, | ||
280 | + gen_helper_mve_viwduph, | ||
281 | + gen_helper_mve_viwdupw, | ||
282 | + NULL, | ||
283 | + }; | ||
284 | + return do_viwdup(s, a, fns[a->size]); | ||
285 | +} | ||
286 | + | ||
287 | +static bool trans_VDWDUP(DisasContext *s, arg_viwdup *a) | ||
288 | +{ | ||
289 | + static MVEGenVIWDUPFn * const fns[] = { | ||
290 | + gen_helper_mve_vdwdupb, | ||
291 | + gen_helper_mve_vdwduph, | ||
292 | + gen_helper_mve_vdwdupw, | ||
293 | + NULL, | ||
294 | + }; | ||
295 | + return do_viwdup(s, a, fns[a->size]); | ||
296 | +} | ||
297 | -- | 885 | -- |
298 | 2.20.1 | 886 | 2.25.1 |
299 | 887 | ||
300 | 888 | diff view generated by jsdifflib |
1 | Implement the MVE saturating doubling multiply accumulate insns | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | VQDMLAH, VQRDMLAH, VQDMLASH and VQRDMLASH. These perform a multiply, | ||
3 | double, add the accumulator shifted by the element size, possibly | ||
4 | round, saturate to twice the element size, then take the high half of | ||
5 | the result. The *MLAH insns do vector * scalar + vector, and the | ||
6 | *MLASH insns do vector * vector + scalar. | ||
7 | 2 | ||
3 | These particular data structures are not modified at runtime. | ||
4 | |||
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220501055028.646596-5-richard.henderson@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | --- | 10 | --- |
11 | target/arm/helper-mve.h | 16 +++++++ | 11 | target/arm/helper.c | 16 ++++++++-------- |
12 | target/arm/mve.decode | 5 ++ | 12 | 1 file changed, 8 insertions(+), 8 deletions(-) |
13 | target/arm/mve_helper.c | 95 ++++++++++++++++++++++++++++++++++++++ | ||
14 | target/arm/translate-mve.c | 4 ++ | ||
15 | 4 files changed, 120 insertions(+) | ||
16 | 13 | ||
17 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 14 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
18 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/helper-mve.h | 16 | --- a/target/arm/helper.c |
20 | +++ b/target/arm/helper-mve.h | 17 | +++ b/target/arm/helper.c |
21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vmlasb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 18 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
22 | DEF_HELPER_FLAGS_4(mve_vmlash, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 19 | .resetvalue = cpu->pmceid1 }, |
23 | DEF_HELPER_FLAGS_4(mve_vmlasw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 20 | }; |
24 | 21 | #ifdef CONFIG_USER_ONLY | |
25 | +DEF_HELPER_FLAGS_4(mve_vqdmlahb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 22 | - ARMCPRegUserSpaceInfo v8_user_idregs[] = { |
26 | +DEF_HELPER_FLAGS_4(mve_vqdmlahh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 23 | + static const ARMCPRegUserSpaceInfo v8_user_idregs[] = { |
27 | +DEF_HELPER_FLAGS_4(mve_vqdmlahw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 24 | { .name = "ID_AA64PFR0_EL1", |
28 | + | 25 | .exported_bits = 0x000f000f00ff0000, |
29 | +DEF_HELPER_FLAGS_4(mve_vqrdmlahb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 26 | .fixed_bits = 0x0000000000000011 }, |
30 | +DEF_HELPER_FLAGS_4(mve_vqrdmlahh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 27 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
31 | +DEF_HELPER_FLAGS_4(mve_vqrdmlahw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 28 | */ |
32 | + | 29 | if (arm_feature(env, ARM_FEATURE_EL3)) { |
33 | +DEF_HELPER_FLAGS_4(mve_vqdmlashb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 30 | if (arm_feature(env, ARM_FEATURE_AARCH64)) { |
34 | +DEF_HELPER_FLAGS_4(mve_vqdmlashh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 31 | - ARMCPRegInfo nsacr = { |
35 | +DEF_HELPER_FLAGS_4(mve_vqdmlashw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 32 | + static const ARMCPRegInfo nsacr = { |
36 | + | 33 | .name = "NSACR", .type = ARM_CP_CONST, |
37 | +DEF_HELPER_FLAGS_4(mve_vqrdmlashb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 34 | .cp = 15, .opc1 = 0, .crn = 1, .crm = 1, .opc2 = 2, |
38 | +DEF_HELPER_FLAGS_4(mve_vqrdmlashh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 35 | .access = PL1_RW, .accessfn = nsacr_access, |
39 | +DEF_HELPER_FLAGS_4(mve_vqrdmlashw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 36 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
40 | + | 37 | }; |
41 | DEF_HELPER_FLAGS_4(mve_vmlaldavsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | 38 | define_one_arm_cp_reg(cpu, &nsacr); |
42 | DEF_HELPER_FLAGS_4(mve_vmlaldavsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | 39 | } else { |
43 | DEF_HELPER_FLAGS_4(mve_vmlaldavxsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | 40 | - ARMCPRegInfo nsacr = { |
44 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | 41 | + static const ARMCPRegInfo nsacr = { |
45 | index XXXXXXX..XXXXXXX 100644 | 42 | .name = "NSACR", |
46 | --- a/target/arm/mve.decode | 43 | .cp = 15, .opc1 = 0, .crn = 1, .crm = 1, .opc2 = 2, |
47 | +++ b/target/arm/mve.decode | 44 | .access = PL3_RW | PL1_R, |
48 | @@ -XXX,XX +XXX,XX @@ VQRDMULH_scalar 1111 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | 45 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
49 | VMLA 111- 1110 0 . .. ... 1 ... 0 1110 . 100 .... @2scalar | 46 | } |
50 | VMLAS 111- 1110 0 . .. ... 1 ... 1 1110 . 100 .... @2scalar | 47 | } else { |
51 | 48 | if (arm_feature(env, ARM_FEATURE_V8)) { | |
52 | +VQRDMLAH 1110 1110 0 . .. ... 0 ... 0 1110 . 100 .... @2scalar | 49 | - ARMCPRegInfo nsacr = { |
53 | +VQRDMLASH 1110 1110 0 . .. ... 0 ... 1 1110 . 100 .... @2scalar | 50 | + static const ARMCPRegInfo nsacr = { |
54 | +VQDMLAH 1110 1110 0 . .. ... 0 ... 0 1110 . 110 .... @2scalar | 51 | .name = "NSACR", .type = ARM_CP_CONST, |
55 | +VQDMLASH 1110 1110 0 . .. ... 0 ... 1 1110 . 110 .... @2scalar | 52 | .cp = 15, .opc1 = 0, .crn = 1, .crm = 1, .opc2 = 2, |
56 | + | 53 | .access = PL1_R, |
57 | # Vector add across vector | 54 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
58 | { | 55 | .access = PL1_R, .type = ARM_CP_CONST, |
59 | VADDV 111 u:1 1110 1111 size:2 01 ... 0 1111 0 0 a:1 0 qm:3 0 rda=%rdalo | 56 | .resetvalue = cpu->pmsav7_dregion << 8 |
60 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | 57 | }; |
61 | index XXXXXXX..XXXXXXX 100644 | 58 | - ARMCPRegInfo crn0_wi_reginfo = { |
62 | --- a/target/arm/mve_helper.c | 59 | + static const ARMCPRegInfo crn0_wi_reginfo = { |
63 | +++ b/target/arm/mve_helper.c | 60 | .name = "CRN0_WI", .cp = 15, .crn = 0, .crm = CP_ANY, |
64 | @@ -XXX,XX +XXX,XX @@ DO_VQDMLADH_OP(vqrdmlsdhxw, 4, int32_t, 1, 1, do_vqdmlsdh_w) | 61 | .opc1 = CP_ANY, .opc2 = CP_ANY, .access = PL1_W, |
65 | mve_advance_vpt(env); \ | 62 | .type = ARM_CP_NOP | ARM_CP_OVERRIDE |
63 | }; | ||
64 | #ifdef CONFIG_USER_ONLY | ||
65 | - ARMCPRegUserSpaceInfo id_v8_user_midr_cp_reginfo[] = { | ||
66 | + static const ARMCPRegUserSpaceInfo id_v8_user_midr_cp_reginfo[] = { | ||
67 | { .name = "MIDR_EL1", | ||
68 | .exported_bits = 0x00000000ffffffff }, | ||
69 | { .name = "REVIDR_EL1" }, | ||
70 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
71 | .access = PL1_R, .readfn = mpidr_read, .type = ARM_CP_NO_RAW }, | ||
72 | }; | ||
73 | #ifdef CONFIG_USER_ONLY | ||
74 | - ARMCPRegUserSpaceInfo mpidr_user_cp_reginfo[] = { | ||
75 | + static const ARMCPRegUserSpaceInfo mpidr_user_cp_reginfo[] = { | ||
76 | { .name = "MPIDR_EL1", | ||
77 | .fixed_bits = 0x0000000080000000 }, | ||
78 | }; | ||
79 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
66 | } | 80 | } |
67 | 81 | ||
68 | +#define DO_2OP_SAT_ACC_SCALAR(OP, ESIZE, TYPE, FN) \ | 82 | if (arm_feature(env, ARM_FEATURE_VBAR)) { |
69 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, \ | 83 | - ARMCPRegInfo vbar_cp_reginfo[] = { |
70 | + uint32_t rm) \ | 84 | + static const ARMCPRegInfo vbar_cp_reginfo[] = { |
71 | + { \ | 85 | { .name = "VBAR", .state = ARM_CP_STATE_BOTH, |
72 | + TYPE *d = vd, *n = vn; \ | 86 | .opc0 = 3, .crn = 12, .crm = 0, .opc1 = 0, .opc2 = 0, |
73 | + TYPE m = rm; \ | 87 | .access = PL1_RW, .writefn = vbar_write, |
74 | + uint16_t mask = mve_element_mask(env); \ | ||
75 | + unsigned e; \ | ||
76 | + bool qc = false; \ | ||
77 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
78 | + bool sat = false; \ | ||
79 | + mergemask(&d[H##ESIZE(e)], \ | ||
80 | + FN(d[H##ESIZE(e)], n[H##ESIZE(e)], m, &sat), \ | ||
81 | + mask); \ | ||
82 | + qc |= sat & mask & 1; \ | ||
83 | + } \ | ||
84 | + if (qc) { \ | ||
85 | + env->vfp.qc[0] = qc; \ | ||
86 | + } \ | ||
87 | + mve_advance_vpt(env); \ | ||
88 | + } | ||
89 | + | ||
90 | /* provide unsigned 2-op scalar helpers for all sizes */ | ||
91 | #define DO_2OP_SCALAR_U(OP, FN) \ | ||
92 | DO_2OP_SCALAR(OP##b, 1, uint8_t, FN) \ | ||
93 | @@ -XXX,XX +XXX,XX @@ DO_2OP_SAT_SCALAR(vqrdmulh_scalarb, 1, int8_t, DO_QRDMULH_B) | ||
94 | DO_2OP_SAT_SCALAR(vqrdmulh_scalarh, 2, int16_t, DO_QRDMULH_H) | ||
95 | DO_2OP_SAT_SCALAR(vqrdmulh_scalarw, 4, int32_t, DO_QRDMULH_W) | ||
96 | |||
97 | +static int8_t do_vqdmlah_b(int8_t a, int8_t b, int8_t c, int round, bool *sat) | ||
98 | +{ | ||
99 | + int64_t r = (int64_t)a * b * 2 + ((int64_t)c << 8) + (round << 7); | ||
100 | + return do_sat_bhw(r, INT16_MIN, INT16_MAX, sat) >> 8; | ||
101 | +} | ||
102 | + | ||
103 | +static int16_t do_vqdmlah_h(int16_t a, int16_t b, int16_t c, | ||
104 | + int round, bool *sat) | ||
105 | +{ | ||
106 | + int64_t r = (int64_t)a * b * 2 + ((int64_t)c << 16) + (round << 15); | ||
107 | + return do_sat_bhw(r, INT32_MIN, INT32_MAX, sat) >> 16; | ||
108 | +} | ||
109 | + | ||
110 | +static int32_t do_vqdmlah_w(int32_t a, int32_t b, int32_t c, | ||
111 | + int round, bool *sat) | ||
112 | +{ | ||
113 | + /* | ||
114 | + * Architecturally we should do the entire add, double, round | ||
115 | + * and then check for saturation. We do three saturating adds, | ||
116 | + * but we need to be careful about the order. If the first | ||
117 | + * m1 + m2 saturates then it's impossible for the *2+rc to | ||
118 | + * bring it back into the non-saturated range. However, if | ||
119 | + * m1 + m2 is negative then it's possible that doing the doubling | ||
120 | + * would take the intermediate result below INT64_MAX and the | ||
121 | + * addition of the rounding constant then brings it back in range. | ||
122 | + * So we add half the rounding constant and half the "c << esize" | ||
123 | + * before doubling rather than adding the rounding constant after | ||
124 | + * the doubling. | ||
125 | + */ | ||
126 | + int64_t m1 = (int64_t)a * b; | ||
127 | + int64_t m2 = (int64_t)c << 31; | ||
128 | + int64_t r; | ||
129 | + if (sadd64_overflow(m1, m2, &r) || | ||
130 | + sadd64_overflow(r, (round << 30), &r) || | ||
131 | + sadd64_overflow(r, r, &r)) { | ||
132 | + *sat = true; | ||
133 | + return r < 0 ? INT32_MAX : INT32_MIN; | ||
134 | + } | ||
135 | + return r >> 32; | ||
136 | +} | ||
137 | + | ||
138 | +/* | ||
139 | + * The *MLAH insns are vector * scalar + vector; | ||
140 | + * the *MLASH insns are vector * vector + scalar | ||
141 | + */ | ||
142 | +#define DO_VQDMLAH_B(D, N, M, S) do_vqdmlah_b(N, M, D, 0, S) | ||
143 | +#define DO_VQDMLAH_H(D, N, M, S) do_vqdmlah_h(N, M, D, 0, S) | ||
144 | +#define DO_VQDMLAH_W(D, N, M, S) do_vqdmlah_w(N, M, D, 0, S) | ||
145 | +#define DO_VQRDMLAH_B(D, N, M, S) do_vqdmlah_b(N, M, D, 1, S) | ||
146 | +#define DO_VQRDMLAH_H(D, N, M, S) do_vqdmlah_h(N, M, D, 1, S) | ||
147 | +#define DO_VQRDMLAH_W(D, N, M, S) do_vqdmlah_w(N, M, D, 1, S) | ||
148 | + | ||
149 | +#define DO_VQDMLASH_B(D, N, M, S) do_vqdmlah_b(N, D, M, 0, S) | ||
150 | +#define DO_VQDMLASH_H(D, N, M, S) do_vqdmlah_h(N, D, M, 0, S) | ||
151 | +#define DO_VQDMLASH_W(D, N, M, S) do_vqdmlah_w(N, D, M, 0, S) | ||
152 | +#define DO_VQRDMLASH_B(D, N, M, S) do_vqdmlah_b(N, D, M, 1, S) | ||
153 | +#define DO_VQRDMLASH_H(D, N, M, S) do_vqdmlah_h(N, D, M, 1, S) | ||
154 | +#define DO_VQRDMLASH_W(D, N, M, S) do_vqdmlah_w(N, D, M, 1, S) | ||
155 | + | ||
156 | +DO_2OP_SAT_ACC_SCALAR(vqdmlahb, 1, int8_t, DO_VQDMLAH_B) | ||
157 | +DO_2OP_SAT_ACC_SCALAR(vqdmlahh, 2, int16_t, DO_VQDMLAH_H) | ||
158 | +DO_2OP_SAT_ACC_SCALAR(vqdmlahw, 4, int32_t, DO_VQDMLAH_W) | ||
159 | +DO_2OP_SAT_ACC_SCALAR(vqrdmlahb, 1, int8_t, DO_VQRDMLAH_B) | ||
160 | +DO_2OP_SAT_ACC_SCALAR(vqrdmlahh, 2, int16_t, DO_VQRDMLAH_H) | ||
161 | +DO_2OP_SAT_ACC_SCALAR(vqrdmlahw, 4, int32_t, DO_VQRDMLAH_W) | ||
162 | + | ||
163 | +DO_2OP_SAT_ACC_SCALAR(vqdmlashb, 1, int8_t, DO_VQDMLASH_B) | ||
164 | +DO_2OP_SAT_ACC_SCALAR(vqdmlashh, 2, int16_t, DO_VQDMLASH_H) | ||
165 | +DO_2OP_SAT_ACC_SCALAR(vqdmlashw, 4, int32_t, DO_VQDMLASH_W) | ||
166 | +DO_2OP_SAT_ACC_SCALAR(vqrdmlashb, 1, int8_t, DO_VQRDMLASH_B) | ||
167 | +DO_2OP_SAT_ACC_SCALAR(vqrdmlashh, 2, int16_t, DO_VQRDMLASH_H) | ||
168 | +DO_2OP_SAT_ACC_SCALAR(vqrdmlashw, 4, int32_t, DO_VQRDMLASH_W) | ||
169 | + | ||
170 | /* Vector by scalar plus vector */ | ||
171 | #define DO_VMLA(D, N, M) ((N) * (M) + (D)) | ||
172 | |||
173 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
174 | index XXXXXXX..XXXXXXX 100644 | ||
175 | --- a/target/arm/translate-mve.c | ||
176 | +++ b/target/arm/translate-mve.c | ||
177 | @@ -XXX,XX +XXX,XX @@ DO_2OP_SCALAR(VQRDMULH_scalar, vqrdmulh_scalar) | ||
178 | DO_2OP_SCALAR(VBRSR, vbrsr) | ||
179 | DO_2OP_SCALAR(VMLA, vmla) | ||
180 | DO_2OP_SCALAR(VMLAS, vmlas) | ||
181 | +DO_2OP_SCALAR(VQDMLAH, vqdmlah) | ||
182 | +DO_2OP_SCALAR(VQRDMLAH, vqrdmlah) | ||
183 | +DO_2OP_SCALAR(VQDMLASH, vqdmlash) | ||
184 | +DO_2OP_SCALAR(VQRDMLASH, vqrdmlash) | ||
185 | |||
186 | static bool trans_VQDMULLB_scalar(DisasContext *s, arg_2scalar *a) | ||
187 | { | ||
188 | -- | 88 | -- |
189 | 2.20.1 | 89 | 2.25.1 |
190 | 90 | ||
191 | 91 | diff view generated by jsdifflib |
1 | Implement the MVE VCTP insn, which sets the VPR.P0 predicate bits so | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | as to predicate any element at index Rn or greater is predicated. As | 2 | |
3 | with VPNOT, this insn itself is predicable and subject to beatwise | 3 | Instead of defining ARM_CP_FLAG_MASK to remove flags, |
4 | execution. | 4 | define ARM_CP_SPECIAL_MASK to isolate special cases. |
5 | 5 | Sort the specials to the low bits. Use an enum. | |
6 | The calculation of the mask is the same as is used to determine | 6 | |
7 | ltpmask in mve_element_mask(), but we precalculate masklen in | 7 | Split the large comment block so as to document each |
8 | generated code to avoid having to have 4 helpers specialized by size. | 8 | value separately. |
9 | 9 | ||
10 | We put the decode line in with the low-overhead-loop insns in | 10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
11 | t32.decode because it's logically part of that collection of insn | 11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
12 | patterns, even though it is an MVE only insn. | 12 | Message-id: 20220501055028.646596-6-richard.henderson@linaro.org |
13 | |||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | --- | 14 | --- |
17 | target/arm/helper-mve.h | 2 ++ | 15 | target/arm/cpregs.h | 130 +++++++++++++++++++++++-------------- |
18 | target/arm/translate-a32.h | 1 + | 16 | target/arm/cpu.c | 4 +- |
19 | target/arm/t32.decode | 1 + | 17 | target/arm/helper.c | 4 +- |
20 | target/arm/mve_helper.c | 20 ++++++++++++++++++++ | 18 | target/arm/translate-a64.c | 6 +- |
21 | target/arm/translate-mve.c | 2 +- | 19 | target/arm/translate.c | 6 +- |
22 | target/arm/translate.c | 33 +++++++++++++++++++++++++++++++++ | 20 | 5 files changed, 92 insertions(+), 58 deletions(-) |
23 | 6 files changed, 58 insertions(+), 1 deletion(-) | 21 | |
24 | 22 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h | |
25 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 23 | index XXXXXXX..XXXXXXX 100644 |
26 | index XXXXXXX..XXXXXXX 100644 | 24 | --- a/target/arm/cpregs.h |
27 | --- a/target/arm/helper-mve.h | 25 | +++ b/target/arm/cpregs.h |
28 | +++ b/target/arm/helper-mve.h | 26 | @@ -XXX,XX +XXX,XX @@ |
29 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_veor, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 27 | #define TARGET_ARM_CPREGS_H |
30 | DEF_HELPER_FLAGS_4(mve_vpsel, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 28 | |
31 | DEF_HELPER_FLAGS_1(mve_vpnot, TCG_CALL_NO_WG, void, env) | 29 | /* |
32 | 30 | - * ARMCPRegInfo type field bits. If the SPECIAL bit is set this is a | |
33 | +DEF_HELPER_FLAGS_2(mve_vctp, TCG_CALL_NO_WG, void, env, i32) | 31 | - * special-behaviour cp reg and bits [11..8] indicate what behaviour |
32 | - * it has. Otherwise it is a simple cp reg, where CONST indicates that | ||
33 | - * TCG can assume the value to be constant (ie load at translate time) | ||
34 | - * and 64BIT indicates a 64 bit wide coprocessor register. SUPPRESS_TB_END | ||
35 | - * indicates that the TB should not be ended after a write to this register | ||
36 | - * (the default is that the TB ends after cp writes). OVERRIDE permits | ||
37 | - * a register definition to override a previous definition for the | ||
38 | - * same (cp, is64, crn, crm, opc1, opc2) tuple: either the new or the | ||
39 | - * old must have the OVERRIDE bit set. | ||
40 | - * ALIAS indicates that this register is an alias view of some underlying | ||
41 | - * state which is also visible via another register, and that the other | ||
42 | - * register is handling migration and reset; registers marked ALIAS will not be | ||
43 | - * migrated but may have their state set by syncing of register state from KVM. | ||
44 | - * NO_RAW indicates that this register has no underlying state and does not | ||
45 | - * support raw access for state saving/loading; it will not be used for either | ||
46 | - * migration or KVM state synchronization. (Typically this is for "registers" | ||
47 | - * which are actually used as instructions for cache maintenance and so on.) | ||
48 | - * IO indicates that this register does I/O and therefore its accesses | ||
49 | - * need to be marked with gen_io_start() and also end the TB. In particular, | ||
50 | - * registers which implement clocks or timers require this. | ||
51 | - * RAISES_EXC is for when the read or write hook might raise an exception; | ||
52 | - * the generated code will synchronize the CPU state before calling the hook | ||
53 | - * so that it is safe for the hook to call raise_exception(). | ||
54 | - * NEWEL is for writes to registers that might change the exception | ||
55 | - * level - typically on older ARM chips. For those cases we need to | ||
56 | - * re-read the new el when recomputing the translation flags. | ||
57 | + * ARMCPRegInfo type field bits: | ||
58 | */ | ||
59 | -#define ARM_CP_SPECIAL 0x0001 | ||
60 | -#define ARM_CP_CONST 0x0002 | ||
61 | -#define ARM_CP_64BIT 0x0004 | ||
62 | -#define ARM_CP_SUPPRESS_TB_END 0x0008 | ||
63 | -#define ARM_CP_OVERRIDE 0x0010 | ||
64 | -#define ARM_CP_ALIAS 0x0020 | ||
65 | -#define ARM_CP_IO 0x0040 | ||
66 | -#define ARM_CP_NO_RAW 0x0080 | ||
67 | -#define ARM_CP_NOP (ARM_CP_SPECIAL | 0x0100) | ||
68 | -#define ARM_CP_WFI (ARM_CP_SPECIAL | 0x0200) | ||
69 | -#define ARM_CP_NZCV (ARM_CP_SPECIAL | 0x0300) | ||
70 | -#define ARM_CP_CURRENTEL (ARM_CP_SPECIAL | 0x0400) | ||
71 | -#define ARM_CP_DC_ZVA (ARM_CP_SPECIAL | 0x0500) | ||
72 | -#define ARM_CP_DC_GVA (ARM_CP_SPECIAL | 0x0600) | ||
73 | -#define ARM_CP_DC_GZVA (ARM_CP_SPECIAL | 0x0700) | ||
74 | -#define ARM_LAST_SPECIAL ARM_CP_DC_GZVA | ||
75 | -#define ARM_CP_FPU 0x1000 | ||
76 | -#define ARM_CP_SVE 0x2000 | ||
77 | -#define ARM_CP_NO_GDB 0x4000 | ||
78 | -#define ARM_CP_RAISES_EXC 0x8000 | ||
79 | -#define ARM_CP_NEWEL 0x10000 | ||
80 | -/* Mask of only the flag bits in a type field */ | ||
81 | -#define ARM_CP_FLAG_MASK 0x1f0ff | ||
82 | +enum { | ||
83 | + /* | ||
84 | + * Register must be handled specially during translation. | ||
85 | + * The method is one of the values below: | ||
86 | + */ | ||
87 | + ARM_CP_SPECIAL_MASK = 0x000f, | ||
88 | + /* Special: no change to PE state: writes ignored, reads ignored. */ | ||
89 | + ARM_CP_NOP = 0x0001, | ||
90 | + /* Special: sysreg is WFI, for v5 and v6. */ | ||
91 | + ARM_CP_WFI = 0x0002, | ||
92 | + /* Special: sysreg is NZCV. */ | ||
93 | + ARM_CP_NZCV = 0x0003, | ||
94 | + /* Special: sysreg is CURRENTEL. */ | ||
95 | + ARM_CP_CURRENTEL = 0x0004, | ||
96 | + /* Special: sysreg is DC ZVA or similar. */ | ||
97 | + ARM_CP_DC_ZVA = 0x0005, | ||
98 | + ARM_CP_DC_GVA = 0x0006, | ||
99 | + ARM_CP_DC_GZVA = 0x0007, | ||
34 | + | 100 | + |
35 | DEF_HELPER_FLAGS_4(mve_vaddb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 101 | + /* Flag: reads produce resetvalue; writes ignored. */ |
36 | DEF_HELPER_FLAGS_4(mve_vaddh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 102 | + ARM_CP_CONST = 1 << 4, |
37 | DEF_HELPER_FLAGS_4(mve_vaddw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 103 | + /* Flag: For ARM_CP_STATE_AA32, sysreg is 64-bit. */ |
38 | diff --git a/target/arm/translate-a32.h b/target/arm/translate-a32.h | 104 | + ARM_CP_64BIT = 1 << 5, |
39 | index XXXXXXX..XXXXXXX 100644 | 105 | + /* |
40 | --- a/target/arm/translate-a32.h | 106 | + * Flag: TB should not be ended after a write to this register |
41 | +++ b/target/arm/translate-a32.h | 107 | + * (the default is that the TB ends after cp writes). |
42 | @@ -XXX,XX +XXX,XX @@ long neon_element_offset(int reg, int element, MemOp memop); | 108 | + */ |
43 | void gen_rev16(TCGv_i32 dest, TCGv_i32 var); | 109 | + ARM_CP_SUPPRESS_TB_END = 1 << 6, |
44 | void clear_eci_state(DisasContext *s); | 110 | + /* |
45 | bool mve_eci_check(DisasContext *s); | 111 | + * Flag: Permit a register definition to override a previous definition |
46 | +void mve_update_eci(DisasContext *s); | 112 | + * for the same (cp, is64, crn, crm, opc1, opc2) tuple: either the new |
47 | void mve_update_and_store_eci(DisasContext *s); | 113 | + * or the old must have the ARM_CP_OVERRIDE bit set. |
48 | bool mve_skip_vmov(DisasContext *s, int vn, int index, int size); | 114 | + */ |
49 | 115 | + ARM_CP_OVERRIDE = 1 << 7, | |
50 | diff --git a/target/arm/t32.decode b/target/arm/t32.decode | 116 | + /* |
51 | index XXXXXXX..XXXXXXX 100644 | 117 | + * Flag: Register is an alias view of some underlying state which is also |
52 | --- a/target/arm/t32.decode | 118 | + * visible via another register, and that the other register is handling |
53 | +++ b/target/arm/t32.decode | 119 | + * migration and reset; registers marked ARM_CP_ALIAS will not be migrated |
54 | @@ -XXX,XX +XXX,XX @@ BL 1111 0. .......... 11.1 ............ @branch24 | 120 | + * but may have their state set by syncing of register state from KVM. |
55 | # This is DLSTP | 121 | + */ |
56 | DLS 1111 0 0000 0 size:2 rn:4 1110 0000 0000 0001 | 122 | + ARM_CP_ALIAS = 1 << 8, |
57 | } | 123 | + /* |
58 | + VCTP 1111 0 0000 0 size:2 rn:4 1110 1000 0000 0001 | 124 | + * Flag: Register does I/O and therefore its accesses need to be marked |
59 | ] | 125 | + * with gen_io_start() and also end the TB. In particular, registers which |
60 | } | 126 | + * implement clocks or timers require this. |
61 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | 127 | + */ |
62 | index XXXXXXX..XXXXXXX 100644 | 128 | + ARM_CP_IO = 1 << 9, |
63 | --- a/target/arm/mve_helper.c | 129 | + /* |
64 | +++ b/target/arm/mve_helper.c | 130 | + * Flag: Register has no underlying state and does not support raw access |
65 | @@ -XXX,XX +XXX,XX @@ void HELPER(mve_vpnot)(CPUARMState *env) | 131 | + * for state saving/loading; it will not be used for either migration or |
66 | mve_advance_vpt(env); | 132 | + * KVM state synchronization. Typically this is for "registers" which are |
67 | } | 133 | + * actually used as instructions for cache maintenance and so on. |
68 | 134 | + */ | |
69 | +/* | 135 | + ARM_CP_NO_RAW = 1 << 10, |
70 | + * VCTP: P0 unexecuted bits unchanged, predicated bits zeroed, | 136 | + /* |
71 | + * otherwise set according to value of Rn. The calculation of | 137 | + * Flag: The read or write hook might raise an exception; the generated |
72 | + * newmask here works in the same way as the calculation of the | 138 | + * code will synchronize the CPU state before calling the hook so that it |
73 | + * ltpmask in mve_element_mask(), but we have pre-calculated | 139 | + * is safe for the hook to call raise_exception(). |
74 | + * the masklen in the generated code. | 140 | + */ |
75 | + */ | 141 | + ARM_CP_RAISES_EXC = 1 << 11, |
76 | +void HELPER(mve_vctp)(CPUARMState *env, uint32_t masklen) | 142 | + /* |
77 | +{ | 143 | + * Flag: Writes to the sysreg might change the exception level - typically |
78 | + uint16_t mask = mve_element_mask(env); | 144 | + * on older ARM chips. For those cases we need to re-read the new el when |
79 | + uint16_t eci_mask = mve_eci_mask(env); | 145 | + * recomputing the translation flags. |
80 | + uint16_t newmask; | 146 | + */ |
81 | + | 147 | + ARM_CP_NEWEL = 1 << 12, |
82 | + assert(masklen <= 16); | 148 | + /* |
83 | + newmask = masklen ? MAKE_64BIT_MASK(0, masklen) : 0; | 149 | + * Flag: Access check for this sysreg is identical to accessing FPU state |
84 | + newmask &= mask; | 150 | + * from an instruction: use translation fp_access_check(). |
85 | + env->v7m.vpr = (env->v7m.vpr & ~(uint32_t)eci_mask) | (newmask & eci_mask); | 151 | + */ |
86 | + mve_advance_vpt(env); | 152 | + ARM_CP_FPU = 1 << 13, |
87 | +} | 153 | + /* |
88 | + | 154 | + * Flag: Access check for this sysreg is identical to accessing SVE state |
89 | #define DO_1OP_SAT(OP, ESIZE, TYPE, FN) \ | 155 | + * from an instruction: use translation sve_access_check(). |
90 | void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm) \ | 156 | + */ |
91 | { \ | 157 | + ARM_CP_SVE = 1 << 14, |
92 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | 158 | + /* Flag: Do not expose in gdb sysreg xml. */ |
93 | index XXXXXXX..XXXXXXX 100644 | 159 | + ARM_CP_NO_GDB = 1 << 15, |
94 | --- a/target/arm/translate-mve.c | 160 | +}; |
95 | +++ b/target/arm/translate-mve.c | 161 | |
96 | @@ -XXX,XX +XXX,XX @@ bool mve_eci_check(DisasContext *s) | 162 | /* |
97 | } | 163 | * Valid values for ARMCPRegInfo state field, indicating which of |
98 | } | 164 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
99 | 165 | index XXXXXXX..XXXXXXX 100644 | |
100 | -static void mve_update_eci(DisasContext *s) | 166 | --- a/target/arm/cpu.c |
101 | +void mve_update_eci(DisasContext *s) | 167 | +++ b/target/arm/cpu.c |
102 | { | 168 | @@ -XXX,XX +XXX,XX @@ static void cp_reg_reset(gpointer key, gpointer value, gpointer opaque) |
103 | /* | 169 | ARMCPRegInfo *ri = value; |
104 | * The helper function will always update the CPUState field, | 170 | ARMCPU *cpu = opaque; |
171 | |||
172 | - if (ri->type & (ARM_CP_SPECIAL | ARM_CP_ALIAS)) { | ||
173 | + if (ri->type & (ARM_CP_SPECIAL_MASK | ARM_CP_ALIAS)) { | ||
174 | return; | ||
175 | } | ||
176 | |||
177 | @@ -XXX,XX +XXX,XX @@ static void cp_reg_check_reset(gpointer key, gpointer value, gpointer opaque) | ||
178 | ARMCPU *cpu = opaque; | ||
179 | uint64_t oldvalue, newvalue; | ||
180 | |||
181 | - if (ri->type & (ARM_CP_SPECIAL | ARM_CP_ALIAS | ARM_CP_NO_RAW)) { | ||
182 | + if (ri->type & (ARM_CP_SPECIAL_MASK | ARM_CP_ALIAS | ARM_CP_NO_RAW)) { | ||
183 | return; | ||
184 | } | ||
185 | |||
186 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
187 | index XXXXXXX..XXXXXXX 100644 | ||
188 | --- a/target/arm/helper.c | ||
189 | +++ b/target/arm/helper.c | ||
190 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
191 | * multiple times. Special registers (ie NOP/WFI) are | ||
192 | * never migratable and not even raw-accessible. | ||
193 | */ | ||
194 | - if ((r->type & ARM_CP_SPECIAL)) { | ||
195 | + if (r->type & ARM_CP_SPECIAL_MASK) { | ||
196 | r2->type |= ARM_CP_NO_RAW; | ||
197 | } | ||
198 | if (((r->crm == CP_ANY) && crm != 0) || | ||
199 | @@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, | ||
200 | /* Check that the register definition has enough info to handle | ||
201 | * reads and writes if they are permitted. | ||
202 | */ | ||
203 | - if (!(r->type & (ARM_CP_SPECIAL|ARM_CP_CONST))) { | ||
204 | + if (!(r->type & (ARM_CP_SPECIAL_MASK | ARM_CP_CONST))) { | ||
205 | if (r->access & PL3_R) { | ||
206 | assert((r->fieldoffset || | ||
207 | (r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1])) || | ||
208 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
209 | index XXXXXXX..XXXXXXX 100644 | ||
210 | --- a/target/arm/translate-a64.c | ||
211 | +++ b/target/arm/translate-a64.c | ||
212 | @@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, | ||
213 | } | ||
214 | |||
215 | /* Handle special cases first */ | ||
216 | - switch (ri->type & ~(ARM_CP_FLAG_MASK & ~ARM_CP_SPECIAL)) { | ||
217 | + switch (ri->type & ARM_CP_SPECIAL_MASK) { | ||
218 | + case 0: | ||
219 | + break; | ||
220 | case ARM_CP_NOP: | ||
221 | return; | ||
222 | case ARM_CP_NZCV: | ||
223 | @@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, | ||
224 | } | ||
225 | return; | ||
226 | default: | ||
227 | - break; | ||
228 | + g_assert_not_reached(); | ||
229 | } | ||
230 | if ((ri->type & ARM_CP_FPU) && !fp_access_check(s)) { | ||
231 | return; | ||
105 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 232 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
106 | index XXXXXXX..XXXXXXX 100644 | 233 | index XXXXXXX..XXXXXXX 100644 |
107 | --- a/target/arm/translate.c | 234 | --- a/target/arm/translate.c |
108 | +++ b/target/arm/translate.c | 235 | +++ b/target/arm/translate.c |
109 | @@ -XXX,XX +XXX,XX @@ static bool trans_LCTP(DisasContext *s, arg_LCTP *a) | 236 | @@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64, |
110 | return true; | 237 | } |
111 | } | 238 | |
112 | 239 | /* Handle special cases first */ | |
113 | +static bool trans_VCTP(DisasContext *s, arg_VCTP *a) | 240 | - switch (ri->type & ~(ARM_CP_FLAG_MASK & ~ARM_CP_SPECIAL)) { |
114 | +{ | 241 | + switch (ri->type & ARM_CP_SPECIAL_MASK) { |
115 | + /* | 242 | + case 0: |
116 | + * M-profile Create Vector Tail Predicate. This insn is itself | 243 | + break; |
117 | + * predicated and is subject to beatwise execution. | 244 | case ARM_CP_NOP: |
118 | + */ | 245 | return; |
119 | + TCGv_i32 rn_shifted, masklen; | 246 | case ARM_CP_WFI: |
120 | + | 247 | @@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64, |
121 | + if (!dc_isar_feature(aa32_mve, s) || a->rn == 13 || a->rn == 15) { | 248 | s->base.is_jmp = DISAS_WFI; |
122 | + return false; | 249 | return; |
123 | + } | 250 | default: |
124 | + | 251 | - break; |
125 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | 252 | + g_assert_not_reached(); |
126 | + return true; | 253 | } |
127 | + } | 254 | |
128 | + | 255 | if ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) && (ri->type & ARM_CP_IO)) { |
129 | + /* | ||
130 | + * We pre-calculate the mask length here to avoid having | ||
131 | + * to have multiple helpers specialized for size. | ||
132 | + * We pass the helper "rn <= (1 << (4 - size)) ? (rn << size) : 16". | ||
133 | + */ | ||
134 | + rn_shifted = tcg_temp_new_i32(); | ||
135 | + masklen = load_reg(s, a->rn); | ||
136 | + tcg_gen_shli_i32(rn_shifted, masklen, a->size); | ||
137 | + tcg_gen_movcond_i32(TCG_COND_LEU, masklen, | ||
138 | + masklen, tcg_constant_i32(1 << (4 - a->size)), | ||
139 | + rn_shifted, tcg_constant_i32(16)); | ||
140 | + gen_helper_mve_vctp(cpu_env, masklen); | ||
141 | + tcg_temp_free_i32(masklen); | ||
142 | + tcg_temp_free_i32(rn_shifted); | ||
143 | + mve_update_eci(s); | ||
144 | + return true; | ||
145 | +} | ||
146 | |||
147 | static bool op_tbranch(DisasContext *s, arg_tbranch *a, bool half) | ||
148 | { | ||
149 | -- | 256 | -- |
150 | 2.20.1 | 257 | 2.25.1 |
151 | |||
152 | diff view generated by jsdifflib |
1 | From: Hamza Mahfooz <someguy@effective-light.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | As per commit 5626f8c6d468 ("rcu: Add automatically released rcu_read_lock | 3 | Standardize on g_assert_not_reached() for "should not happen". |
4 | variants"), RCU_READ_LOCK_GUARD() should be used instead of | 4 | Retain abort() when preceeded by fprintf or error_report. |
5 | rcu_read_{un}lock(). | ||
6 | 5 | ||
7 | Signed-off-by: Hamza Mahfooz <someguy@effective-light.com> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Message-id: 20210727235201.11491-1-someguy@effective-light.com | 8 | Message-id: 20220501055028.646596-7-richard.henderson@linaro.org |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 10 | --- |
12 | target/arm/kvm.c | 17 ++++++++--------- | 11 | target/arm/helper.c | 7 +++---- |
13 | 1 file changed, 8 insertions(+), 9 deletions(-) | 12 | target/arm/hvf/hvf.c | 2 +- |
13 | target/arm/kvm-stub.c | 4 ++-- | ||
14 | target/arm/kvm.c | 4 ++-- | ||
15 | target/arm/machine.c | 4 ++-- | ||
16 | target/arm/translate-a64.c | 4 ++-- | ||
17 | target/arm/translate-neon.c | 2 +- | ||
18 | target/arm/translate.c | 4 ++-- | ||
19 | 8 files changed, 15 insertions(+), 16 deletions(-) | ||
14 | 20 | ||
21 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/target/arm/helper.c | ||
24 | +++ b/target/arm/helper.c | ||
25 | @@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, | ||
26 | break; | ||
27 | default: | ||
28 | /* broken reginfo with out-of-range opc1 */ | ||
29 | - assert(false); | ||
30 | - break; | ||
31 | + g_assert_not_reached(); | ||
32 | } | ||
33 | /* assert our permissions are not too lax (stricter is fine) */ | ||
34 | assert((r->access & ~mask) == 0); | ||
35 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address, | ||
36 | break; | ||
37 | default: | ||
38 | /* Never happens, but compiler isn't smart enough to tell. */ | ||
39 | - abort(); | ||
40 | + g_assert_not_reached(); | ||
41 | } | ||
42 | } | ||
43 | *prot = ap_to_rw_prot(env, mmu_idx, ap, domain_prot); | ||
44 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address, | ||
45 | break; | ||
46 | default: | ||
47 | /* Never happens, but compiler isn't smart enough to tell. */ | ||
48 | - abort(); | ||
49 | + g_assert_not_reached(); | ||
50 | } | ||
51 | } | ||
52 | if (domain_prot == 3) { | ||
53 | diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/target/arm/hvf/hvf.c | ||
56 | +++ b/target/arm/hvf/hvf.c | ||
57 | @@ -XXX,XX +XXX,XX @@ int hvf_vcpu_exec(CPUState *cpu) | ||
58 | /* we got kicked, no exit to process */ | ||
59 | return 0; | ||
60 | default: | ||
61 | - assert(0); | ||
62 | + g_assert_not_reached(); | ||
63 | } | ||
64 | |||
65 | hvf_sync_vtimer(cpu); | ||
66 | diff --git a/target/arm/kvm-stub.c b/target/arm/kvm-stub.c | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/target/arm/kvm-stub.c | ||
69 | +++ b/target/arm/kvm-stub.c | ||
70 | @@ -XXX,XX +XXX,XX @@ | ||
71 | |||
72 | bool write_kvmstate_to_list(ARMCPU *cpu) | ||
73 | { | ||
74 | - abort(); | ||
75 | + g_assert_not_reached(); | ||
76 | } | ||
77 | |||
78 | bool write_list_to_kvmstate(ARMCPU *cpu, int level) | ||
79 | { | ||
80 | - abort(); | ||
81 | + g_assert_not_reached(); | ||
82 | } | ||
15 | diff --git a/target/arm/kvm.c b/target/arm/kvm.c | 83 | diff --git a/target/arm/kvm.c b/target/arm/kvm.c |
16 | index XXXXXXX..XXXXXXX 100644 | 84 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/kvm.c | 85 | --- a/target/arm/kvm.c |
18 | +++ b/target/arm/kvm.c | 86 | +++ b/target/arm/kvm.c |
19 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route, | 87 | @@ -XXX,XX +XXX,XX @@ bool write_kvmstate_to_list(ARMCPU *cpu) |
20 | hwaddr xlat, len, doorbell_gpa; | 88 | ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &r); |
21 | MemoryRegionSection mrs; | 89 | break; |
22 | MemoryRegion *mr; | 90 | default: |
23 | - int ret = 1; | 91 | - abort(); |
24 | 92 | + g_assert_not_reached(); | |
25 | if (as == &address_space_memory) { | 93 | } |
26 | return 0; | 94 | if (ret) { |
27 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route, | 95 | ok = false; |
28 | 96 | @@ -XXX,XX +XXX,XX @@ bool write_list_to_kvmstate(ARMCPU *cpu, int level) | |
29 | /* MSI doorbell address is translated by an IOMMU */ | 97 | r.addr = (uintptr_t)(cpu->cpreg_values + i); |
30 | 98 | break; | |
31 | - rcu_read_lock(); | 99 | default: |
32 | + RCU_READ_LOCK_GUARD(); | 100 | - abort(); |
33 | + | 101 | + g_assert_not_reached(); |
34 | mr = address_space_translate(as, address, &xlat, &len, true, | 102 | } |
35 | MEMTXATTRS_UNSPECIFIED); | 103 | ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &r); |
36 | + | 104 | if (ret) { |
37 | if (!mr) { | 105 | diff --git a/target/arm/machine.c b/target/arm/machine.c |
38 | - goto unlock; | 106 | index XXXXXXX..XXXXXXX 100644 |
39 | + return 1; | 107 | --- a/target/arm/machine.c |
108 | +++ b/target/arm/machine.c | ||
109 | @@ -XXX,XX +XXX,XX @@ static int cpu_pre_save(void *opaque) | ||
110 | if (kvm_enabled()) { | ||
111 | if (!write_kvmstate_to_list(cpu)) { | ||
112 | /* This should never fail */ | ||
113 | - abort(); | ||
114 | + g_assert_not_reached(); | ||
115 | } | ||
116 | |||
117 | /* | ||
118 | @@ -XXX,XX +XXX,XX @@ static int cpu_pre_save(void *opaque) | ||
119 | } else { | ||
120 | if (!write_cpustate_to_list(cpu, false)) { | ||
121 | /* This should never fail. */ | ||
122 | - abort(); | ||
123 | + g_assert_not_reached(); | ||
124 | } | ||
40 | } | 125 | } |
41 | + | 126 | |
42 | mrs = memory_region_find(mr, xlat, 1); | 127 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
43 | + | 128 | index XXXXXXX..XXXXXXX 100644 |
44 | if (!mrs.mr) { | 129 | --- a/target/arm/translate-a64.c |
45 | - goto unlock; | 130 | +++ b/target/arm/translate-a64.c |
46 | + return 1; | 131 | @@ -XXX,XX +XXX,XX @@ static void handle_fp_1src_half(DisasContext *s, int opcode, int rd, int rn) |
132 | gen_helper_advsimd_rinth(tcg_res, tcg_op, fpst); | ||
133 | break; | ||
134 | default: | ||
135 | - abort(); | ||
136 | + g_assert_not_reached(); | ||
47 | } | 137 | } |
48 | 138 | ||
49 | doorbell_gpa = mrs.offset_within_address_space; | 139 | write_fp_sreg(s, rd, tcg_res); |
50 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route, | 140 | @@ -XXX,XX +XXX,XX @@ static void handle_fp_fcvt(DisasContext *s, int opcode, |
51 | 141 | break; | |
52 | trace_kvm_arm_fixup_msi_route(address, doorbell_gpa); | 142 | } |
53 | 143 | default: | |
54 | - ret = 0; | 144 | - abort(); |
55 | - | 145 | + g_assert_not_reached(); |
56 | -unlock: | 146 | } |
57 | - rcu_read_unlock(); | ||
58 | - return ret; | ||
59 | + return 0; | ||
60 | } | 147 | } |
61 | 148 | ||
62 | int kvm_arch_add_msi_route_post(struct kvm_irq_routing_entry *route, | 149 | diff --git a/target/arm/translate-neon.c b/target/arm/translate-neon.c |
150 | index XXXXXXX..XXXXXXX 100644 | ||
151 | --- a/target/arm/translate-neon.c | ||
152 | +++ b/target/arm/translate-neon.c | ||
153 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_single(DisasContext *s, arg_VLDST_single *a) | ||
154 | } | ||
155 | break; | ||
156 | default: | ||
157 | - abort(); | ||
158 | + g_assert_not_reached(); | ||
159 | } | ||
160 | if ((vd + a->stride * (nregs - 1)) > 31) { | ||
161 | /* | ||
162 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
163 | index XXXXXXX..XXXXXXX 100644 | ||
164 | --- a/target/arm/translate.c | ||
165 | +++ b/target/arm/translate.c | ||
166 | @@ -XXX,XX +XXX,XX @@ static void gen_srs(DisasContext *s, | ||
167 | offset = 4; | ||
168 | break; | ||
169 | default: | ||
170 | - abort(); | ||
171 | + g_assert_not_reached(); | ||
172 | } | ||
173 | tcg_gen_addi_i32(addr, addr, offset); | ||
174 | tmp = load_reg(s, 14); | ||
175 | @@ -XXX,XX +XXX,XX @@ static void gen_srs(DisasContext *s, | ||
176 | offset = 0; | ||
177 | break; | ||
178 | default: | ||
179 | - abort(); | ||
180 | + g_assert_not_reached(); | ||
181 | } | ||
182 | tcg_gen_addi_i32(addr, addr, offset); | ||
183 | gen_helper_set_r13_banked(cpu_env, tcg_constant_i32(mode), addr); | ||
63 | -- | 184 | -- |
64 | 2.20.1 | 185 | 2.25.1 |
65 | |||
66 | diff view generated by jsdifflib |
1 | From: Guenter Roeck <linux@roeck-us.net> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Instantiate SAI1/2/3 as unimplemented devices to avoid Linux kernel crashes | 3 | Create a typedef as well, and use it in ARMCPRegInfo. |
4 | such as the following. | 4 | This won't be perfect for debugging, but it'll nicely |
5 | display the most common cases. | ||
5 | 6 | ||
6 | Unhandled fault: external abort on non-linefetch (0x808) at 0xd19b0000 | ||
7 | pgd = (ptrval) | ||
8 | [d19b0000] *pgd=82711811, *pte=308a0653, *ppte=308a0453 | ||
9 | Internal error: : 808 [#1] SMP ARM | ||
10 | Modules linked in: | ||
11 | CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.14.0-rc5 #1 | ||
12 | ... | ||
13 | [<c095e974>] (regmap_mmio_write32le) from [<c095eb48>] (regmap_mmio_write+0x3c/0x54) | ||
14 | [<c095eb48>] (regmap_mmio_write) from [<c09580f4>] (_regmap_write+0x4c/0x1f0) | ||
15 | [<c09580f4>] (_regmap_write) from [<c0959b28>] (regmap_write+0x3c/0x60) | ||
16 | [<c0959b28>] (regmap_write) from [<c0d41130>] (fsl_sai_runtime_resume+0x9c/0x1ec) | ||
17 | [<c0d41130>] (fsl_sai_runtime_resume) from [<c0942464>] (__rpm_callback+0x3c/0x108) | ||
18 | [<c0942464>] (__rpm_callback) from [<c0942590>] (rpm_callback+0x60/0x64) | ||
19 | [<c0942590>] (rpm_callback) from [<c0942b60>] (rpm_resume+0x5cc/0x808) | ||
20 | [<c0942b60>] (rpm_resume) from [<c0942dfc>] (__pm_runtime_resume+0x60/0xa0) | ||
21 | [<c0942dfc>] (__pm_runtime_resume) from [<c0d4231c>] (fsl_sai_probe+0x2b8/0x65c) | ||
22 | [<c0d4231c>] (fsl_sai_probe) from [<c0935b08>] (platform_probe+0x58/0xb8) | ||
23 | [<c0935b08>] (platform_probe) from [<c0933264>] (really_probe.part.0+0x9c/0x334) | ||
24 | [<c0933264>] (really_probe.part.0) from [<c093359c>] (__driver_probe_device+0xa0/0x138) | ||
25 | [<c093359c>] (__driver_probe_device) from [<c0933664>] (driver_probe_device+0x30/0xc8) | ||
26 | [<c0933664>] (driver_probe_device) from [<c0933c88>] (__driver_attach+0x90/0x130) | ||
27 | [<c0933c88>] (__driver_attach) from [<c0931060>] (bus_for_each_dev+0x78/0xb8) | ||
28 | [<c0931060>] (bus_for_each_dev) from [<c093254c>] (bus_add_driver+0xf0/0x1d8) | ||
29 | [<c093254c>] (bus_add_driver) from [<c0934a30>] (driver_register+0x88/0x118) | ||
30 | [<c0934a30>] (driver_register) from [<c01022c0>] (do_one_initcall+0x7c/0x3a4) | ||
31 | [<c01022c0>] (do_one_initcall) from [<c1601204>] (kernel_init_freeable+0x198/0x22c) | ||
32 | [<c1601204>] (kernel_init_freeable) from [<c0f5ff2c>] (kernel_init+0x10/0x128) | ||
33 | [<c0f5ff2c>] (kernel_init) from [<c010013c>] (ret_from_fork+0x14/0x38) | ||
34 | |||
35 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | ||
36 | Message-id: 20210810175607.538090-1-linux@roeck-us.net | ||
37 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20220501055028.646596-8-richard.henderson@linaro.org | ||
38 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
39 | --- | 11 | --- |
40 | include/hw/arm/fsl-imx7.h | 5 +++++ | 12 | target/arm/cpregs.h | 44 +++++++++++++++++++++++--------------------- |
41 | hw/arm/fsl-imx7.c | 7 +++++++ | 13 | target/arm/helper.c | 2 +- |
42 | 2 files changed, 12 insertions(+) | 14 | 2 files changed, 24 insertions(+), 22 deletions(-) |
43 | 15 | ||
44 | diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h | 16 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h |
45 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
46 | --- a/include/hw/arm/fsl-imx7.h | 18 | --- a/target/arm/cpregs.h |
47 | +++ b/include/hw/arm/fsl-imx7.h | 19 | +++ b/target/arm/cpregs.h |
48 | @@ -XXX,XX +XXX,XX @@ enum FslIMX7MemoryMap { | 20 | @@ -XXX,XX +XXX,XX @@ enum { |
49 | FSL_IMX7_UART6_ADDR = 0x30A80000, | 21 | * described with these bits, then use a laxer set of restrictions, and |
50 | FSL_IMX7_UART7_ADDR = 0x30A90000, | 22 | * do the more restrictive/complex check inside a helper function. |
51 | 23 | */ | |
52 | + FSL_IMX7_SAI1_ADDR = 0x308A0000, | 24 | -#define PL3_R 0x80 |
53 | + FSL_IMX7_SAI2_ADDR = 0x308B0000, | 25 | -#define PL3_W 0x40 |
54 | + FSL_IMX7_SAI3_ADDR = 0x308C0000, | 26 | -#define PL2_R (0x20 | PL3_R) |
55 | + FSL_IMX7_SAIn_SIZE = 0x10000, | 27 | -#define PL2_W (0x10 | PL3_W) |
56 | + | 28 | -#define PL1_R (0x08 | PL2_R) |
57 | FSL_IMX7_ENET1_ADDR = 0x30BE0000, | 29 | -#define PL1_W (0x04 | PL2_W) |
58 | FSL_IMX7_ENET2_ADDR = 0x30BF0000, | 30 | -#define PL0_R (0x02 | PL1_R) |
59 | 31 | -#define PL0_W (0x01 | PL1_W) | |
60 | diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c | 32 | +typedef enum { |
33 | + PL3_R = 0x80, | ||
34 | + PL3_W = 0x40, | ||
35 | + PL2_R = 0x20 | PL3_R, | ||
36 | + PL2_W = 0x10 | PL3_W, | ||
37 | + PL1_R = 0x08 | PL2_R, | ||
38 | + PL1_W = 0x04 | PL2_W, | ||
39 | + PL0_R = 0x02 | PL1_R, | ||
40 | + PL0_W = 0x01 | PL1_W, | ||
41 | |||
42 | -/* | ||
43 | - * For user-mode some registers are accessible to EL0 via a kernel | ||
44 | - * trap-and-emulate ABI. In this case we define the read permissions | ||
45 | - * as actually being PL0_R. However some bits of any given register | ||
46 | - * may still be masked. | ||
47 | - */ | ||
48 | + /* | ||
49 | + * For user-mode some registers are accessible to EL0 via a kernel | ||
50 | + * trap-and-emulate ABI. In this case we define the read permissions | ||
51 | + * as actually being PL0_R. However some bits of any given register | ||
52 | + * may still be masked. | ||
53 | + */ | ||
54 | #ifdef CONFIG_USER_ONLY | ||
55 | -#define PL0U_R PL0_R | ||
56 | + PL0U_R = PL0_R, | ||
57 | #else | ||
58 | -#define PL0U_R PL1_R | ||
59 | + PL0U_R = PL1_R, | ||
60 | #endif | ||
61 | |||
62 | -#define PL3_RW (PL3_R | PL3_W) | ||
63 | -#define PL2_RW (PL2_R | PL2_W) | ||
64 | -#define PL1_RW (PL1_R | PL1_W) | ||
65 | -#define PL0_RW (PL0_R | PL0_W) | ||
66 | + PL3_RW = PL3_R | PL3_W, | ||
67 | + PL2_RW = PL2_R | PL2_W, | ||
68 | + PL1_RW = PL1_R | PL1_W, | ||
69 | + PL0_RW = PL0_R | PL0_W, | ||
70 | +} CPAccessRights; | ||
71 | |||
72 | typedef enum CPAccessResult { | ||
73 | /* Access is permitted */ | ||
74 | @@ -XXX,XX +XXX,XX @@ struct ARMCPRegInfo { | ||
75 | /* Register type: ARM_CP_* bits/values */ | ||
76 | int type; | ||
77 | /* Access rights: PL*_[RW] */ | ||
78 | - int access; | ||
79 | + CPAccessRights access; | ||
80 | /* Security state: ARM_CP_SECSTATE_* bits/values */ | ||
81 | int secure; | ||
82 | /* | ||
83 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
61 | index XXXXXXX..XXXXXXX 100644 | 84 | index XXXXXXX..XXXXXXX 100644 |
62 | --- a/hw/arm/fsl-imx7.c | 85 | --- a/target/arm/helper.c |
63 | +++ b/hw/arm/fsl-imx7.c | 86 | +++ b/target/arm/helper.c |
64 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | 87 | @@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, |
65 | create_unimplemented_device("can1", FSL_IMX7_CAN1_ADDR, FSL_IMX7_CANn_SIZE); | 88 | * to encompass the generic architectural permission check. |
66 | create_unimplemented_device("can2", FSL_IMX7_CAN2_ADDR, FSL_IMX7_CANn_SIZE); | ||
67 | |||
68 | + /* | ||
69 | + * SAI (Audio SSI (Synchronous Serial Interface)) | ||
70 | + */ | ||
71 | + create_unimplemented_device("sai1", FSL_IMX7_SAI1_ADDR, FSL_IMX7_SAIn_SIZE); | ||
72 | + create_unimplemented_device("sai2", FSL_IMX7_SAI2_ADDR, FSL_IMX7_SAIn_SIZE); | ||
73 | + create_unimplemented_device("sai2", FSL_IMX7_SAI3_ADDR, FSL_IMX7_SAIn_SIZE); | ||
74 | + | ||
75 | /* | ||
76 | * OCOTP | ||
77 | */ | 89 | */ |
90 | if (r->state != ARM_CP_STATE_AA32) { | ||
91 | - int mask = 0; | ||
92 | + CPAccessRights mask; | ||
93 | switch (r->opc1) { | ||
94 | case 0: | ||
95 | /* min_EL EL1, but some accessible to EL0 via kernel ABI */ | ||
78 | -- | 96 | -- |
79 | 2.20.1 | 97 | 2.25.1 |
80 | |||
81 | diff view generated by jsdifflib |
1 | The MVEGenDualAccOpFn is a bit misnamed, since it is used for | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | the "long dual accumulate" operations that use a 64-bit | ||
3 | accumulator. Rename it to MVEGenLongDualAccOpFn so we can | ||
4 | use the former name for the 32-bit accumulator insns. | ||
5 | 2 | ||
3 | Give this enum a name and use in ARMCPRegInfo, | ||
4 | add_cpreg_to_hashtable and define_one_arm_cp_reg_with_opaque. | ||
5 | |||
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20220501055028.646596-9-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | --- | 11 | --- |
9 | target/arm/translate-mve.c | 16 ++++++++-------- | 12 | target/arm/cpregs.h | 6 +++--- |
10 | 1 file changed, 8 insertions(+), 8 deletions(-) | 13 | target/arm/helper.c | 6 ++++-- |
14 | 2 files changed, 7 insertions(+), 5 deletions(-) | ||
11 | 15 | ||
12 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | 16 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h |
13 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/target/arm/translate-mve.c | 18 | --- a/target/arm/cpregs.h |
15 | +++ b/target/arm/translate-mve.c | 19 | +++ b/target/arm/cpregs.h |
16 | @@ -XXX,XX +XXX,XX @@ typedef void MVEGenOneOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | 20 | @@ -XXX,XX +XXX,XX @@ enum { |
17 | typedef void MVEGenTwoOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_ptr); | 21 | * Note that we rely on the values of these enums as we iterate through |
18 | typedef void MVEGenTwoOpScalarFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | 22 | * the various states in some places. |
19 | typedef void MVEGenTwoOpShiftFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | 23 | */ |
20 | -typedef void MVEGenDualAccOpFn(TCGv_i64, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i64); | 24 | -enum { |
21 | +typedef void MVEGenLongDualAccOpFn(TCGv_i64, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i64); | 25 | +typedef enum { |
22 | typedef void MVEGenVADDVFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32); | 26 | ARM_CP_STATE_AA32 = 0, |
23 | typedef void MVEGenOneOpImmFn(TCGv_ptr, TCGv_ptr, TCGv_i64); | 27 | ARM_CP_STATE_AA64 = 1, |
24 | typedef void MVEGenVIDUPFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32, TCGv_i32); | 28 | ARM_CP_STATE_BOTH = 2, |
25 | @@ -XXX,XX +XXX,XX @@ static bool trans_VQDMULLT_scalar(DisasContext *s, arg_2scalar *a) | 29 | -}; |
30 | +} CPState; | ||
31 | |||
32 | /* | ||
33 | * ARM CP register secure state flags. These flags identify security state | ||
34 | @@ -XXX,XX +XXX,XX @@ struct ARMCPRegInfo { | ||
35 | uint8_t opc1; | ||
36 | uint8_t opc2; | ||
37 | /* Execution state in which this register is visible: ARM_CP_STATE_* */ | ||
38 | - int state; | ||
39 | + CPState state; | ||
40 | /* Register type: ARM_CP_* bits/values */ | ||
41 | int type; | ||
42 | /* Access rights: PL*_[RW] */ | ||
43 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/target/arm/helper.c | ||
46 | +++ b/target/arm/helper.c | ||
47 | @@ -XXX,XX +XXX,XX @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) | ||
26 | } | 48 | } |
27 | 49 | ||
28 | static bool do_long_dual_acc(DisasContext *s, arg_vmlaldav *a, | 50 | static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
29 | - MVEGenDualAccOpFn *fn) | 51 | - void *opaque, int state, int secstate, |
30 | + MVEGenLongDualAccOpFn *fn) | 52 | + void *opaque, CPState state, int secstate, |
53 | int crm, int opc1, int opc2, | ||
54 | const char *name) | ||
31 | { | 55 | { |
32 | TCGv_ptr qn, qm; | 56 | @@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, |
33 | TCGv_i64 rda; | 57 | * bits; the ARM_CP_64BIT* flag applies only to the AArch32 view of |
34 | @@ -XXX,XX +XXX,XX @@ static bool do_long_dual_acc(DisasContext *s, arg_vmlaldav *a, | 58 | * the register, if any. |
35 | 59 | */ | |
36 | static bool trans_VMLALDAV_S(DisasContext *s, arg_vmlaldav *a) | 60 | - int crm, opc1, opc2, state; |
37 | { | 61 | + int crm, opc1, opc2; |
38 | - static MVEGenDualAccOpFn * const fns[4][2] = { | 62 | int crmmin = (r->crm == CP_ANY) ? 0 : r->crm; |
39 | + static MVEGenLongDualAccOpFn * const fns[4][2] = { | 63 | int crmmax = (r->crm == CP_ANY) ? 15 : r->crm; |
40 | { NULL, NULL }, | 64 | int opc1min = (r->opc1 == CP_ANY) ? 0 : r->opc1; |
41 | { gen_helper_mve_vmlaldavsh, gen_helper_mve_vmlaldavxsh }, | 65 | int opc1max = (r->opc1 == CP_ANY) ? 7 : r->opc1; |
42 | { gen_helper_mve_vmlaldavsw, gen_helper_mve_vmlaldavxsw }, | 66 | int opc2min = (r->opc2 == CP_ANY) ? 0 : r->opc2; |
43 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMLALDAV_S(DisasContext *s, arg_vmlaldav *a) | 67 | int opc2max = (r->opc2 == CP_ANY) ? 7 : r->opc2; |
44 | 68 | + CPState state; | |
45 | static bool trans_VMLALDAV_U(DisasContext *s, arg_vmlaldav *a) | 69 | + |
46 | { | 70 | /* 64 bit registers have only CRm and Opc1 fields */ |
47 | - static MVEGenDualAccOpFn * const fns[4][2] = { | 71 | assert(!((r->type & ARM_CP_64BIT) && (r->opc2 || r->crn))); |
48 | + static MVEGenLongDualAccOpFn * const fns[4][2] = { | 72 | /* op0 only exists in the AArch64 encodings */ |
49 | { NULL, NULL }, | ||
50 | { gen_helper_mve_vmlaldavuh, NULL }, | ||
51 | { gen_helper_mve_vmlaldavuw, NULL }, | ||
52 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMLALDAV_U(DisasContext *s, arg_vmlaldav *a) | ||
53 | |||
54 | static bool trans_VMLSLDAV(DisasContext *s, arg_vmlaldav *a) | ||
55 | { | ||
56 | - static MVEGenDualAccOpFn * const fns[4][2] = { | ||
57 | + static MVEGenLongDualAccOpFn * const fns[4][2] = { | ||
58 | { NULL, NULL }, | ||
59 | { gen_helper_mve_vmlsldavsh, gen_helper_mve_vmlsldavxsh }, | ||
60 | { gen_helper_mve_vmlsldavsw, gen_helper_mve_vmlsldavxsw }, | ||
61 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMLSLDAV(DisasContext *s, arg_vmlaldav *a) | ||
62 | |||
63 | static bool trans_VRMLALDAVH_S(DisasContext *s, arg_vmlaldav *a) | ||
64 | { | ||
65 | - static MVEGenDualAccOpFn * const fns[] = { | ||
66 | + static MVEGenLongDualAccOpFn * const fns[] = { | ||
67 | gen_helper_mve_vrmlaldavhsw, gen_helper_mve_vrmlaldavhxsw, | ||
68 | }; | ||
69 | return do_long_dual_acc(s, a, fns[a->x]); | ||
70 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRMLALDAVH_S(DisasContext *s, arg_vmlaldav *a) | ||
71 | |||
72 | static bool trans_VRMLALDAVH_U(DisasContext *s, arg_vmlaldav *a) | ||
73 | { | ||
74 | - static MVEGenDualAccOpFn * const fns[] = { | ||
75 | + static MVEGenLongDualAccOpFn * const fns[] = { | ||
76 | gen_helper_mve_vrmlaldavhuw, NULL, | ||
77 | }; | ||
78 | return do_long_dual_acc(s, a, fns[a->x]); | ||
79 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRMLALDAVH_U(DisasContext *s, arg_vmlaldav *a) | ||
80 | |||
81 | static bool trans_VRMLSLDAVH(DisasContext *s, arg_vmlaldav *a) | ||
82 | { | ||
83 | - static MVEGenDualAccOpFn * const fns[] = { | ||
84 | + static MVEGenLongDualAccOpFn * const fns[] = { | ||
85 | gen_helper_mve_vrmlsldavhsw, gen_helper_mve_vrmlsldavhxsw, | ||
86 | }; | ||
87 | return do_long_dual_acc(s, a, fns[a->x]); | ||
88 | -- | 73 | -- |
89 | 2.20.1 | 74 | 2.25.1 |
90 | 75 | ||
91 | 76 | diff view generated by jsdifflib |
1 | From: "Wen, Jianxian" <Jianxian.Wen@verisilicon.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Add property memory region which can connect with IOMMU region to support SMMU translate. | 3 | Give this enum a name and use in ARMCPRegInfo and add_cpreg_to_hashtable. |
4 | Add the enumerator ARM_CP_SECSTATE_BOTH to clarify how 0 | ||
5 | is handled in define_one_arm_cp_reg_with_opaque. | ||
4 | 6 | ||
5 | Signed-off-by: Jianxian Wen <jianxian.wen@verisilicon.com> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 4C23C17B8E87E74E906A25A3254A03F4FA1FEC31@SHASXM03.verisilicon.com | 9 | Message-id: 20220501055028.646596-10-richard.henderson@linaro.org |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 11 | --- |
10 | hw/arm/exynos4210.c | 3 +++ | 12 | target/arm/cpregs.h | 7 ++++--- |
11 | hw/arm/xilinx_zynq.c | 3 +++ | 13 | target/arm/helper.c | 7 +++++-- |
12 | hw/dma/pl330.c | 26 ++++++++++++++++++++++---- | 14 | 2 files changed, 9 insertions(+), 5 deletions(-) |
13 | 3 files changed, 28 insertions(+), 4 deletions(-) | ||
14 | 15 | ||
15 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | 16 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h |
16 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/arm/exynos4210.c | 18 | --- a/target/arm/cpregs.h |
18 | +++ b/hw/arm/exynos4210.c | 19 | +++ b/target/arm/cpregs.h |
19 | @@ -XXX,XX +XXX,XX @@ static DeviceState *pl330_create(uint32_t base, qemu_or_irq *orgate, | 20 | @@ -XXX,XX +XXX,XX @@ typedef enum { |
20 | int i; | 21 | * registered entry will only have one to identify whether the entry is secure |
21 | 22 | * or non-secure. | |
22 | dev = qdev_new("pl330"); | 23 | */ |
23 | + object_property_set_link(OBJECT(dev), "memory", | 24 | -enum { |
24 | + OBJECT(get_system_memory()), | 25 | +typedef enum { |
25 | + &error_fatal); | 26 | + ARM_CP_SECSTATE_BOTH = 0, /* define one cpreg for each secstate */ |
26 | qdev_prop_set_uint8(dev, "num_events", nevents); | 27 | ARM_CP_SECSTATE_S = (1 << 0), /* bit[0]: Secure state register */ |
27 | qdev_prop_set_uint8(dev, "num_chnls", 8); | 28 | ARM_CP_SECSTATE_NS = (1 << 1), /* bit[1]: Non-secure state register */ |
28 | qdev_prop_set_uint8(dev, "num_periph_req", nreq); | 29 | -}; |
29 | diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c | 30 | +} CPSecureState; |
31 | |||
32 | /* | ||
33 | * Access rights: | ||
34 | @@ -XXX,XX +XXX,XX @@ struct ARMCPRegInfo { | ||
35 | /* Access rights: PL*_[RW] */ | ||
36 | CPAccessRights access; | ||
37 | /* Security state: ARM_CP_SECSTATE_* bits/values */ | ||
38 | - int secure; | ||
39 | + CPSecureState secure; | ||
40 | /* | ||
41 | * The opaque pointer passed to define_arm_cp_regs_with_opaque() when | ||
42 | * this register was defined: can be used to hand data through to the | ||
43 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | 44 | index XXXXXXX..XXXXXXX 100644 |
31 | --- a/hw/arm/xilinx_zynq.c | 45 | --- a/target/arm/helper.c |
32 | +++ b/hw/arm/xilinx_zynq.c | 46 | +++ b/target/arm/helper.c |
33 | @@ -XXX,XX +XXX,XX @@ static void zynq_init(MachineState *machine) | 47 | @@ -XXX,XX +XXX,XX @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) |
34 | sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[39-IRQ_OFFSET]); | ||
35 | |||
36 | dev = qdev_new("pl330"); | ||
37 | + object_property_set_link(OBJECT(dev), "memory", | ||
38 | + OBJECT(address_space_mem), | ||
39 | + &error_fatal); | ||
40 | qdev_prop_set_uint8(dev, "num_chnls", 8); | ||
41 | qdev_prop_set_uint8(dev, "num_periph_req", 4); | ||
42 | qdev_prop_set_uint8(dev, "num_events", 16); | ||
43 | diff --git a/hw/dma/pl330.c b/hw/dma/pl330.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/hw/dma/pl330.c | ||
46 | +++ b/hw/dma/pl330.c | ||
47 | @@ -XXX,XX +XXX,XX @@ struct PL330State { | ||
48 | uint8_t num_faulting; | ||
49 | uint8_t periph_busy[PL330_PERIPH_NUM]; | ||
50 | |||
51 | + /* Memory region that DMA operation access */ | ||
52 | + MemoryRegion *mem_mr; | ||
53 | + AddressSpace *mem_as; | ||
54 | }; | ||
55 | |||
56 | #define TYPE_PL330 "pl330" | ||
57 | @@ -XXX,XX +XXX,XX @@ static inline const PL330InsnDesc *pl330_fetch_insn(PL330Chan *ch) | ||
58 | uint8_t opcode; | ||
59 | int i; | ||
60 | |||
61 | - dma_memory_read(&address_space_memory, ch->pc, &opcode, 1); | ||
62 | + dma_memory_read(ch->parent->mem_as, ch->pc, &opcode, 1); | ||
63 | for (i = 0; insn_desc[i].size; i++) { | ||
64 | if ((opcode & insn_desc[i].opmask) == insn_desc[i].opcode) { | ||
65 | return &insn_desc[i]; | ||
66 | @@ -XXX,XX +XXX,XX @@ static inline void pl330_exec_insn(PL330Chan *ch, const PL330InsnDesc *insn) | ||
67 | uint8_t buf[PL330_INSN_MAXSIZE]; | ||
68 | |||
69 | assert(insn->size <= PL330_INSN_MAXSIZE); | ||
70 | - dma_memory_read(&address_space_memory, ch->pc, buf, insn->size); | ||
71 | + dma_memory_read(ch->parent->mem_as, ch->pc, buf, insn->size); | ||
72 | insn->exec(ch, buf[0], &buf[1], insn->size - 1); | ||
73 | } | 48 | } |
74 | 49 | ||
75 | @@ -XXX,XX +XXX,XX @@ static int pl330_exec_cycle(PL330Chan *channel) | 50 | static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
76 | if (q != NULL && q->len <= pl330_fifo_num_free(&s->fifo)) { | 51 | - void *opaque, CPState state, int secstate, |
77 | int len = q->len - (q->addr & (q->len - 1)); | 52 | + void *opaque, CPState state, |
78 | 53 | + CPSecureState secstate, | |
79 | - dma_memory_read(&address_space_memory, q->addr, buf, len); | 54 | int crm, int opc1, int opc2, |
80 | + dma_memory_read(s->mem_as, q->addr, buf, len); | 55 | const char *name) |
81 | trace_pl330_exec_cycle(q->addr, len); | 56 | { |
82 | if (trace_event_get_state_backends(TRACE_PL330_HEXDUMP)) { | 57 | @@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, |
83 | pl330_hexdump(buf, len); | 58 | r->secure, crm, opc1, opc2, |
84 | @@ -XXX,XX +XXX,XX @@ static int pl330_exec_cycle(PL330Chan *channel) | 59 | r->name); |
85 | fifo_res = pl330_fifo_get(&s->fifo, buf, len, q->tag); | 60 | break; |
86 | } | 61 | - default: |
87 | if (fifo_res == PL330_FIFO_OK || q->z) { | 62 | + case ARM_CP_SECSTATE_BOTH: |
88 | - dma_memory_write(&address_space_memory, q->addr, buf, len); | 63 | name = g_strdup_printf("%s_S", r->name); |
89 | + dma_memory_write(s->mem_as, q->addr, buf, len); | 64 | add_cpreg_to_hashtable(cpu, r, opaque, state, |
90 | trace_pl330_exec_cycle(q->addr, len); | 65 | ARM_CP_SECSTATE_S, |
91 | if (trace_event_get_state_backends(TRACE_PL330_HEXDUMP)) { | 66 | @@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, |
92 | pl330_hexdump(buf, len); | 67 | ARM_CP_SECSTATE_NS, |
93 | @@ -XXX,XX +XXX,XX @@ static void pl330_realize(DeviceState *dev, Error **errp) | 68 | crm, opc1, opc2, r->name); |
94 | "dma", PL330_IOMEM_SIZE); | 69 | break; |
95 | sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem); | 70 | + default: |
96 | 71 | + g_assert_not_reached(); | |
97 | + if (!s->mem_mr) { | 72 | } |
98 | + error_setg(errp, "'memory' link is not set"); | 73 | } else { |
99 | + return; | 74 | /* AArch64 registers get mapped to non-secure instance |
100 | + } else if (s->mem_mr == get_system_memory()) { | ||
101 | + /* Avoid creating new AS for system memory. */ | ||
102 | + s->mem_as = &address_space_memory; | ||
103 | + } else { | ||
104 | + s->mem_as = g_new0(AddressSpace, 1); | ||
105 | + address_space_init(s->mem_as, s->mem_mr, | ||
106 | + memory_region_name(s->mem_mr)); | ||
107 | + } | ||
108 | + | ||
109 | s->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, pl330_exec_cycle_timer, s); | ||
110 | |||
111 | s->cfg[0] = (s->mgr_ns_at_rst ? 0x4 : 0) | | ||
112 | @@ -XXX,XX +XXX,XX @@ static Property pl330_properties[] = { | ||
113 | DEFINE_PROP_UINT8("rd_q_dep", PL330State, rd_q_dep, 16), | ||
114 | DEFINE_PROP_UINT16("data_buffer_dep", PL330State, data_buffer_dep, 256), | ||
115 | |||
116 | + DEFINE_PROP_LINK("memory", PL330State, mem_mr, | ||
117 | + TYPE_MEMORY_REGION, MemoryRegion *), | ||
118 | + | ||
119 | DEFINE_PROP_END_OF_LIST(), | ||
120 | }; | ||
121 | |||
122 | -- | 75 | -- |
123 | 2.20.1 | 76 | 2.25.1 |
124 | |||
125 | diff view generated by jsdifflib |
1 | From: Eduardo Habkost <ehabkost@redhat.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The SBSA_GWDT enum value conflicts with the SBSA_GWDT() QOM type | 3 | The new_key field is always non-zero -- drop the if. |
4 | checking helper, preventing us from using a OBJECT_DEFINE* or | ||
5 | DEFINE_INSTANCE_CHECKER macro for the SBSA_GWDT() wrapper. | ||
6 | 4 | ||
7 | If I understand the SBSA 6.0 specification correctly, the signal | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | being connected to IRQ 16 is the WS0 output signal from the | ||
9 | Generic Watchdog. Rename the enum value to SBSA_GWDT_WS0 to be | ||
10 | more explicit and avoid the name conflict. | ||
11 | |||
12 | Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> | ||
13 | Message-id: 20210806023119.431680-1-ehabkost@redhat.com | ||
14 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Message-id: 20220501055028.646596-11-richard.henderson@linaro.org | ||
8 | [PMM: reinstated dropped PL3_RW mask] | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 10 | --- |
17 | hw/arm/sbsa-ref.c | 6 +++--- | 11 | target/arm/helper.c | 23 +++++++++++------------ |
18 | 1 file changed, 3 insertions(+), 3 deletions(-) | 12 | 1 file changed, 11 insertions(+), 12 deletions(-) |
19 | 13 | ||
20 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c | 14 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
21 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/arm/sbsa-ref.c | 16 | --- a/target/arm/helper.c |
23 | +++ b/hw/arm/sbsa-ref.c | 17 | +++ b/target/arm/helper.c |
24 | @@ -XXX,XX +XXX,XX @@ enum { | 18 | @@ -XXX,XX +XXX,XX @@ static void define_arm_vh_e2h_redirects_aliases(ARMCPU *cpu) |
25 | SBSA_GIC_DIST, | 19 | |
26 | SBSA_GIC_REDIST, | 20 | for (i = 0; i < ARRAY_SIZE(aliases); i++) { |
27 | SBSA_SECURE_EC, | 21 | const struct E2HAlias *a = &aliases[i]; |
28 | - SBSA_GWDT, | 22 | - ARMCPRegInfo *src_reg, *dst_reg; |
29 | + SBSA_GWDT_WS0, | 23 | + ARMCPRegInfo *src_reg, *dst_reg, *new_reg; |
30 | SBSA_GWDT_REFRESH, | 24 | + uint32_t *new_key; |
31 | SBSA_GWDT_CONTROL, | 25 | + bool ok; |
32 | SBSA_SMMU, | 26 | |
33 | @@ -XXX,XX +XXX,XX @@ static const int sbsa_ref_irqmap[] = { | 27 | if (a->feature && !a->feature(&cpu->isar)) { |
34 | [SBSA_AHCI] = 10, | 28 | continue; |
35 | [SBSA_EHCI] = 11, | 29 | @@ -XXX,XX +XXX,XX @@ static void define_arm_vh_e2h_redirects_aliases(ARMCPU *cpu) |
36 | [SBSA_SMMU] = 12, /* ... to 15 */ | 30 | g_assert(src_reg->opaque == NULL); |
37 | - [SBSA_GWDT] = 16, | 31 | |
38 | + [SBSA_GWDT_WS0] = 16, | 32 | /* Create alias before redirection so we dup the right data. */ |
39 | }; | 33 | - if (a->new_key) { |
40 | 34 | - ARMCPRegInfo *new_reg = g_memdup(src_reg, sizeof(ARMCPRegInfo)); | |
41 | static const char * const valid_cpus[] = { | 35 | - uint32_t *new_key = g_memdup(&a->new_key, sizeof(uint32_t)); |
42 | @@ -XXX,XX +XXX,XX @@ static void create_wdt(const SBSAMachineState *sms) | 36 | - bool ok; |
43 | hwaddr cbase = sbsa_ref_memmap[SBSA_GWDT_CONTROL].base; | 37 | + new_reg = g_memdup(src_reg, sizeof(ARMCPRegInfo)); |
44 | DeviceState *dev = qdev_new(TYPE_WDT_SBSA); | 38 | + new_key = g_memdup(&a->new_key, sizeof(uint32_t)); |
45 | SysBusDevice *s = SYS_BUS_DEVICE(dev); | 39 | |
46 | - int irq = sbsa_ref_irqmap[SBSA_GWDT]; | 40 | - new_reg->name = a->new_name; |
47 | + int irq = sbsa_ref_irqmap[SBSA_GWDT_WS0]; | 41 | - new_reg->type |= ARM_CP_ALIAS; |
48 | 42 | - /* Remove PL1/PL0 access, leaving PL2/PL3 R/W in place. */ | |
49 | sysbus_realize_and_unref(s, &error_fatal); | 43 | - new_reg->access &= PL2_RW | PL3_RW; |
50 | sysbus_mmio_map(s, 0, rbase); | 44 | + new_reg->name = a->new_name; |
45 | + new_reg->type |= ARM_CP_ALIAS; | ||
46 | + /* Remove PL1/PL0 access, leaving PL2/PL3 R/W in place. */ | ||
47 | + new_reg->access &= PL2_RW | PL3_RW; | ||
48 | |||
49 | - ok = g_hash_table_insert(cpu->cp_regs, new_key, new_reg); | ||
50 | - g_assert(ok); | ||
51 | - } | ||
52 | + ok = g_hash_table_insert(cpu->cp_regs, new_key, new_reg); | ||
53 | + g_assert(ok); | ||
54 | |||
55 | src_reg->opaque = dst_reg; | ||
56 | src_reg->orig_readfn = src_reg->readfn ?: raw_read; | ||
51 | -- | 57 | -- |
52 | 2.20.1 | 58 | 2.25.1 |
53 | |||
54 | diff view generated by jsdifflib |
1 | Implement the MVE VMAXA and VMINA insns, which take the absolute | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | value of the signed elements in the input vector and then accumulate | ||
3 | the unsigned max or min into the destination vector. | ||
4 | 2 | ||
3 | Cast the uint32_t key into a gpointer directly, which | ||
4 | allows us to avoid allocating storage for each key. | ||
5 | |||
6 | Use g_hash_table_lookup when we already have a gpointer | ||
7 | (e.g. for callbacks like count_cpreg), or when using | ||
8 | get_arm_cp_reginfo would require casting away const. | ||
9 | |||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Message-id: 20220501055028.646596-12-richard.henderson@linaro.org | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | --- | 14 | --- |
8 | target/arm/helper-mve.h | 8 ++++++++ | 15 | target/arm/cpu.c | 4 ++-- |
9 | target/arm/mve.decode | 4 ++++ | 16 | target/arm/gdbstub.c | 2 +- |
10 | target/arm/mve_helper.c | 26 ++++++++++++++++++++++++++ | 17 | target/arm/helper.c | 41 ++++++++++++++++++----------------------- |
11 | target/arm/translate-mve.c | 2 ++ | 18 | 3 files changed, 21 insertions(+), 26 deletions(-) |
12 | 4 files changed, 40 insertions(+) | ||
13 | 19 | ||
14 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 20 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
15 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/helper-mve.h | 22 | --- a/target/arm/cpu.c |
17 | +++ b/target/arm/helper-mve.h | 23 | +++ b/target/arm/cpu.c |
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vqnegb, TCG_CALL_NO_WG, void, env, ptr, ptr) | 24 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_initfn(Object *obj) |
19 | DEF_HELPER_FLAGS_3(mve_vqnegh, TCG_CALL_NO_WG, void, env, ptr, ptr) | 25 | ARMCPU *cpu = ARM_CPU(obj); |
20 | DEF_HELPER_FLAGS_3(mve_vqnegw, TCG_CALL_NO_WG, void, env, ptr, ptr) | 26 | |
21 | 27 | cpu_set_cpustate_pointers(cpu); | |
22 | +DEF_HELPER_FLAGS_3(mve_vmaxab, TCG_CALL_NO_WG, void, env, ptr, ptr) | 28 | - cpu->cp_regs = g_hash_table_new_full(g_int_hash, g_int_equal, |
23 | +DEF_HELPER_FLAGS_3(mve_vmaxah, TCG_CALL_NO_WG, void, env, ptr, ptr) | 29 | - g_free, cpreg_hashtable_data_destroy); |
24 | +DEF_HELPER_FLAGS_3(mve_vmaxaw, TCG_CALL_NO_WG, void, env, ptr, ptr) | 30 | + cpu->cp_regs = g_hash_table_new_full(g_direct_hash, g_direct_equal, |
25 | + | 31 | + NULL, cpreg_hashtable_data_destroy); |
26 | +DEF_HELPER_FLAGS_3(mve_vminab, TCG_CALL_NO_WG, void, env, ptr, ptr) | 32 | |
27 | +DEF_HELPER_FLAGS_3(mve_vminah, TCG_CALL_NO_WG, void, env, ptr, ptr) | 33 | QLIST_INIT(&cpu->pre_el_change_hooks); |
28 | +DEF_HELPER_FLAGS_3(mve_vminaw, TCG_CALL_NO_WG, void, env, ptr, ptr) | 34 | QLIST_INIT(&cpu->el_change_hooks); |
29 | + | 35 | diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c |
30 | DEF_HELPER_FLAGS_3(mve_vmovnbb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
31 | DEF_HELPER_FLAGS_3(mve_vmovnbh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
32 | DEF_HELPER_FLAGS_3(mve_vmovntb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
33 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
34 | index XXXXXXX..XXXXXXX 100644 | 36 | index XXXXXXX..XXXXXXX 100644 |
35 | --- a/target/arm/mve.decode | 37 | --- a/target/arm/gdbstub.c |
36 | +++ b/target/arm/mve.decode | 38 | +++ b/target/arm/gdbstub.c |
37 | @@ -XXX,XX +XXX,XX @@ VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op | 39 | @@ -XXX,XX +XXX,XX @@ static void arm_gen_one_xml_sysreg_tag(GString *s, DynamicGDBXMLInfo *dyn_xml, |
38 | VQMOVUNB 111 0 1110 0 . 11 .. 01 ... 0 1110 1 0 . 0 ... 1 @1op | 40 | static void arm_register_sysreg_for_xml(gpointer key, gpointer value, |
39 | VQMOVN_BS 111 0 1110 0 . 11 .. 11 ... 0 1110 0 0 . 0 ... 1 @1op | 41 | gpointer p) |
40 | 42 | { | |
41 | + VMAXA 111 0 1110 0 . 11 .. 11 ... 0 1110 1 0 . 0 ... 1 @1op | 43 | - uint32_t ri_key = *(uint32_t *)key; |
42 | + | 44 | + uint32_t ri_key = (uintptr_t)key; |
43 | VMULH_S 111 0 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op | 45 | ARMCPRegInfo *ri = value; |
46 | RegisterSysregXmlParam *param = (RegisterSysregXmlParam *)p; | ||
47 | GString *s = param->s; | ||
48 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/target/arm/helper.c | ||
51 | +++ b/target/arm/helper.c | ||
52 | @@ -XXX,XX +XXX,XX @@ bool write_list_to_cpustate(ARMCPU *cpu) | ||
53 | static void add_cpreg_to_list(gpointer key, gpointer opaque) | ||
54 | { | ||
55 | ARMCPU *cpu = opaque; | ||
56 | - uint64_t regidx; | ||
57 | - const ARMCPRegInfo *ri; | ||
58 | - | ||
59 | - regidx = *(uint32_t *)key; | ||
60 | - ri = get_arm_cp_reginfo(cpu->cp_regs, regidx); | ||
61 | + uint32_t regidx = (uintptr_t)key; | ||
62 | + const ARMCPRegInfo *ri = get_arm_cp_reginfo(cpu->cp_regs, regidx); | ||
63 | |||
64 | if (!(ri->type & (ARM_CP_NO_RAW|ARM_CP_ALIAS))) { | ||
65 | cpu->cpreg_indexes[cpu->cpreg_array_len] = cpreg_to_kvm_id(regidx); | ||
66 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_list(gpointer key, gpointer opaque) | ||
67 | static void count_cpreg(gpointer key, gpointer opaque) | ||
68 | { | ||
69 | ARMCPU *cpu = opaque; | ||
70 | - uint64_t regidx; | ||
71 | const ARMCPRegInfo *ri; | ||
72 | |||
73 | - regidx = *(uint32_t *)key; | ||
74 | - ri = get_arm_cp_reginfo(cpu->cp_regs, regidx); | ||
75 | + ri = g_hash_table_lookup(cpu->cp_regs, key); | ||
76 | |||
77 | if (!(ri->type & (ARM_CP_NO_RAW|ARM_CP_ALIAS))) { | ||
78 | cpu->cpreg_array_len++; | ||
79 | @@ -XXX,XX +XXX,XX @@ static void count_cpreg(gpointer key, gpointer opaque) | ||
80 | |||
81 | static gint cpreg_key_compare(gconstpointer a, gconstpointer b) | ||
82 | { | ||
83 | - uint64_t aidx = cpreg_to_kvm_id(*(uint32_t *)a); | ||
84 | - uint64_t bidx = cpreg_to_kvm_id(*(uint32_t *)b); | ||
85 | + uint64_t aidx = cpreg_to_kvm_id((uintptr_t)a); | ||
86 | + uint64_t bidx = cpreg_to_kvm_id((uintptr_t)b); | ||
87 | |||
88 | if (aidx > bidx) { | ||
89 | return 1; | ||
90 | @@ -XXX,XX +XXX,XX @@ static void define_arm_vh_e2h_redirects_aliases(ARMCPU *cpu) | ||
91 | for (i = 0; i < ARRAY_SIZE(aliases); i++) { | ||
92 | const struct E2HAlias *a = &aliases[i]; | ||
93 | ARMCPRegInfo *src_reg, *dst_reg, *new_reg; | ||
94 | - uint32_t *new_key; | ||
95 | bool ok; | ||
96 | |||
97 | if (a->feature && !a->feature(&cpu->isar)) { | ||
98 | continue; | ||
99 | } | ||
100 | |||
101 | - src_reg = g_hash_table_lookup(cpu->cp_regs, &a->src_key); | ||
102 | - dst_reg = g_hash_table_lookup(cpu->cp_regs, &a->dst_key); | ||
103 | + src_reg = g_hash_table_lookup(cpu->cp_regs, | ||
104 | + (gpointer)(uintptr_t)a->src_key); | ||
105 | + dst_reg = g_hash_table_lookup(cpu->cp_regs, | ||
106 | + (gpointer)(uintptr_t)a->dst_key); | ||
107 | g_assert(src_reg != NULL); | ||
108 | g_assert(dst_reg != NULL); | ||
109 | |||
110 | @@ -XXX,XX +XXX,XX @@ static void define_arm_vh_e2h_redirects_aliases(ARMCPU *cpu) | ||
111 | |||
112 | /* Create alias before redirection so we dup the right data. */ | ||
113 | new_reg = g_memdup(src_reg, sizeof(ARMCPRegInfo)); | ||
114 | - new_key = g_memdup(&a->new_key, sizeof(uint32_t)); | ||
115 | |||
116 | new_reg->name = a->new_name; | ||
117 | new_reg->type |= ARM_CP_ALIAS; | ||
118 | /* Remove PL1/PL0 access, leaving PL2/PL3 R/W in place. */ | ||
119 | new_reg->access &= PL2_RW | PL3_RW; | ||
120 | |||
121 | - ok = g_hash_table_insert(cpu->cp_regs, new_key, new_reg); | ||
122 | + ok = g_hash_table_insert(cpu->cp_regs, | ||
123 | + (gpointer)(uintptr_t)a->new_key, new_reg); | ||
124 | g_assert(ok); | ||
125 | |||
126 | src_reg->opaque = dst_reg; | ||
127 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
128 | /* Private utility function for define_one_arm_cp_reg_with_opaque(): | ||
129 | * add a single reginfo struct to the hash table. | ||
130 | */ | ||
131 | - uint32_t *key = g_new(uint32_t, 1); | ||
132 | + uint32_t key; | ||
133 | ARMCPRegInfo *r2 = g_memdup(r, sizeof(ARMCPRegInfo)); | ||
134 | int is64 = (r->type & ARM_CP_64BIT) ? 1 : 0; | ||
135 | int ns = (secstate & ARM_CP_SECSTATE_NS) ? 1 : 0; | ||
136 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
137 | if (r->cp == 0 || r->state == ARM_CP_STATE_BOTH) { | ||
138 | r2->cp = CP_REG_ARM64_SYSREG_CP; | ||
139 | } | ||
140 | - *key = ENCODE_AA64_CP_REG(r2->cp, r2->crn, crm, | ||
141 | - r2->opc0, opc1, opc2); | ||
142 | + key = ENCODE_AA64_CP_REG(r2->cp, r2->crn, crm, | ||
143 | + r2->opc0, opc1, opc2); | ||
144 | } else { | ||
145 | - *key = ENCODE_CP_REG(r2->cp, is64, ns, r2->crn, crm, opc1, opc2); | ||
146 | + key = ENCODE_CP_REG(r2->cp, is64, ns, r2->crn, crm, opc1, opc2); | ||
147 | } | ||
148 | if (opaque) { | ||
149 | r2->opaque = opaque; | ||
150 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
151 | * requested. | ||
152 | */ | ||
153 | if (!(r->type & ARM_CP_OVERRIDE)) { | ||
154 | - ARMCPRegInfo *oldreg; | ||
155 | - oldreg = g_hash_table_lookup(cpu->cp_regs, key); | ||
156 | + const ARMCPRegInfo *oldreg = get_arm_cp_reginfo(cpu->cp_regs, key); | ||
157 | if (oldreg && !(oldreg->type & ARM_CP_OVERRIDE)) { | ||
158 | fprintf(stderr, "Register redefined: cp=%d %d bit " | ||
159 | "crn=%d crm=%d opc1=%d opc2=%d, " | ||
160 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
161 | g_assert_not_reached(); | ||
162 | } | ||
163 | } | ||
164 | - g_hash_table_insert(cpu->cp_regs, key, r2); | ||
165 | + g_hash_table_insert(cpu->cp_regs, (gpointer)(uintptr_t)key, r2); | ||
44 | } | 166 | } |
45 | 167 | ||
46 | @@ -XXX,XX +XXX,XX @@ VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op | 168 | |
47 | VQMOVUNT 111 0 1110 0 . 11 .. 01 ... 1 1110 1 0 . 0 ... 1 @1op | 169 | @@ -XXX,XX +XXX,XX @@ void modify_arm_cp_regs_with_len(ARMCPRegInfo *regs, size_t regs_len, |
48 | VQMOVN_TS 111 0 1110 0 . 11 .. 11 ... 1 1110 0 0 . 0 ... 1 @1op | 170 | |
49 | 171 | const ARMCPRegInfo *get_arm_cp_reginfo(GHashTable *cpregs, uint32_t encoded_cp) | |
50 | + VMINA 111 0 1110 0 . 11 .. 11 ... 1 1110 1 0 . 0 ... 1 @1op | 172 | { |
51 | + | 173 | - return g_hash_table_lookup(cpregs, &encoded_cp); |
52 | VRMULH_S 111 0 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op | 174 | + return g_hash_table_lookup(cpregs, (gpointer)(uintptr_t)encoded_cp); |
53 | } | 175 | } |
54 | 176 | ||
55 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | 177 | void arm_cp_write_ignore(CPUARMState *env, const ARMCPRegInfo *ri, |
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/target/arm/mve_helper.c | ||
58 | +++ b/target/arm/mve_helper.c | ||
59 | @@ -XXX,XX +XXX,XX @@ DO_1OP_SAT(vqabsw, 4, int32_t, DO_VQABS_W) | ||
60 | DO_1OP_SAT(vqnegb, 1, int8_t, DO_VQNEG_B) | ||
61 | DO_1OP_SAT(vqnegh, 2, int16_t, DO_VQNEG_H) | ||
62 | DO_1OP_SAT(vqnegw, 4, int32_t, DO_VQNEG_W) | ||
63 | + | ||
64 | +/* | ||
65 | + * VMAXA, VMINA: vd is unsigned; vm is signed, and we take its | ||
66 | + * absolute value; we then do an unsigned comparison. | ||
67 | + */ | ||
68 | +#define DO_VMAXMINA(OP, ESIZE, STYPE, UTYPE, FN) \ | ||
69 | + void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm) \ | ||
70 | + { \ | ||
71 | + UTYPE *d = vd; \ | ||
72 | + STYPE *m = vm; \ | ||
73 | + uint16_t mask = mve_element_mask(env); \ | ||
74 | + unsigned e; \ | ||
75 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
76 | + UTYPE r = DO_ABS(m[H##ESIZE(e)]); \ | ||
77 | + r = FN(d[H##ESIZE(e)], r); \ | ||
78 | + mergemask(&d[H##ESIZE(e)], r, mask); \ | ||
79 | + } \ | ||
80 | + mve_advance_vpt(env); \ | ||
81 | + } | ||
82 | + | ||
83 | +DO_VMAXMINA(vmaxab, 1, int8_t, uint8_t, DO_MAX) | ||
84 | +DO_VMAXMINA(vmaxah, 2, int16_t, uint16_t, DO_MAX) | ||
85 | +DO_VMAXMINA(vmaxaw, 4, int32_t, uint32_t, DO_MAX) | ||
86 | +DO_VMAXMINA(vminab, 1, int8_t, uint8_t, DO_MIN) | ||
87 | +DO_VMAXMINA(vminah, 2, int16_t, uint16_t, DO_MIN) | ||
88 | +DO_VMAXMINA(vminaw, 4, int32_t, uint32_t, DO_MIN) | ||
89 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
90 | index XXXXXXX..XXXXXXX 100644 | ||
91 | --- a/target/arm/translate-mve.c | ||
92 | +++ b/target/arm/translate-mve.c | ||
93 | @@ -XXX,XX +XXX,XX @@ DO_1OP(VABS, vabs) | ||
94 | DO_1OP(VNEG, vneg) | ||
95 | DO_1OP(VQABS, vqabs) | ||
96 | DO_1OP(VQNEG, vqneg) | ||
97 | +DO_1OP(VMAXA, vmaxa) | ||
98 | +DO_1OP(VMINA, vmina) | ||
99 | |||
100 | /* Narrowing moves: only size 0 and 1 are valid */ | ||
101 | #define DO_VMOVN(INSN, FN) \ | ||
102 | -- | 178 | -- |
103 | 2.20.1 | 179 | 2.25.1 |
104 | |||
105 | diff view generated by jsdifflib |
1 | Include the MVE VPR register value in the CPU dumps produced by | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | arm_cpu_dump_state() if we are printing FPU information. This | ||
3 | makes it easier to interpret debug logs when predication is | ||
4 | active. | ||
5 | 2 | ||
3 | Simplify freeing cp_regs hash table entries by using a single | ||
4 | allocation for the entire value. | ||
5 | |||
6 | This fixes a theoretical bug if we were to ever free the entire | ||
7 | hash table, because we've been installing string literal constants | ||
8 | into the cpreg structure in define_arm_vh_e2h_redirects_aliases. | ||
9 | However, at present we only free entries created for AArch32 | ||
10 | wildcard cpregs which get overwritten by more specific cpregs, | ||
11 | so this bug is never exposed. | ||
12 | |||
13 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Message-id: 20220501055028.646596-13-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | --- | 17 | --- |
9 | target/arm/cpu.c | 3 +++ | 18 | target/arm/cpu.c | 16 +--------------- |
10 | 1 file changed, 3 insertions(+) | 19 | target/arm/helper.c | 10 ++++++++-- |
20 | 2 files changed, 9 insertions(+), 17 deletions(-) | ||
11 | 21 | ||
12 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 22 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
13 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/target/arm/cpu.c | 24 | --- a/target/arm/cpu.c |
15 | +++ b/target/arm/cpu.c | 25 | +++ b/target/arm/cpu.c |
16 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags) | 26 | @@ -XXX,XX +XXX,XX @@ uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz) |
17 | i, v); | 27 | return (Aff1 << ARM_AFF1_SHIFT) | Aff0; |
18 | } | ||
19 | qemu_fprintf(f, "FPSCR: %08x\n", vfp_get_fpscr(env)); | ||
20 | + if (cpu_isar_feature(aa32_mve, cpu)) { | ||
21 | + qemu_fprintf(f, "VPR: %08x\n", env->v7m.vpr); | ||
22 | + } | ||
23 | } | ||
24 | } | 28 | } |
25 | 29 | ||
30 | -static void cpreg_hashtable_data_destroy(gpointer data) | ||
31 | -{ | ||
32 | - /* | ||
33 | - * Destroy function for cpu->cp_regs hashtable data entries. | ||
34 | - * We must free the name string because it was g_strdup()ed in | ||
35 | - * add_cpreg_to_hashtable(). It's OK to cast away the 'const' | ||
36 | - * from r->name because we know we definitely allocated it. | ||
37 | - */ | ||
38 | - ARMCPRegInfo *r = data; | ||
39 | - | ||
40 | - g_free((void *)r->name); | ||
41 | - g_free(r); | ||
42 | -} | ||
43 | - | ||
44 | static void arm_cpu_initfn(Object *obj) | ||
45 | { | ||
46 | ARMCPU *cpu = ARM_CPU(obj); | ||
47 | |||
48 | cpu_set_cpustate_pointers(cpu); | ||
49 | cpu->cp_regs = g_hash_table_new_full(g_direct_hash, g_direct_equal, | ||
50 | - NULL, cpreg_hashtable_data_destroy); | ||
51 | + NULL, g_free); | ||
52 | |||
53 | QLIST_INIT(&cpu->pre_el_change_hooks); | ||
54 | QLIST_INIT(&cpu->el_change_hooks); | ||
55 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/target/arm/helper.c | ||
58 | +++ b/target/arm/helper.c | ||
59 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
60 | * add a single reginfo struct to the hash table. | ||
61 | */ | ||
62 | uint32_t key; | ||
63 | - ARMCPRegInfo *r2 = g_memdup(r, sizeof(ARMCPRegInfo)); | ||
64 | + ARMCPRegInfo *r2; | ||
65 | int is64 = (r->type & ARM_CP_64BIT) ? 1 : 0; | ||
66 | int ns = (secstate & ARM_CP_SECSTATE_NS) ? 1 : 0; | ||
67 | + size_t name_len; | ||
68 | + | ||
69 | + /* Combine cpreg and name into one allocation. */ | ||
70 | + name_len = strlen(name) + 1; | ||
71 | + r2 = g_malloc(sizeof(*r2) + name_len); | ||
72 | + *r2 = *r; | ||
73 | + r2->name = memcpy(r2 + 1, name, name_len); | ||
74 | |||
75 | - r2->name = g_strdup(name); | ||
76 | /* Reset the secure state to the specific incoming state. This is | ||
77 | * necessary as the register may have been defined with both states. | ||
78 | */ | ||
26 | -- | 79 | -- |
27 | 2.20.1 | 80 | 2.25.1 |
28 | |||
29 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | In the MVE shift-and-insert insns, we special case VSLI by 0 | ||
2 | and VSRI by <dt>. VSRI by <dt> means "don't update the destination", | ||
3 | which is what we've implemented. However VSLI by 0 is "set | ||
4 | destination to the input", so we don't want to use the same | ||
5 | special-casing that we do for VSRI by <dt>. | ||
6 | 1 | ||
7 | Since the generic logic gives the right answer for a shift | ||
8 | by 0, just use that. | ||
9 | |||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | --- | ||
13 | target/arm/mve_helper.c | 9 +++++---- | ||
14 | 1 file changed, 5 insertions(+), 4 deletions(-) | ||
15 | |||
16 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/arm/mve_helper.c | ||
19 | +++ b/target/arm/mve_helper.c | ||
20 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT_S(vrshli_s, DO_VRSHLS) | ||
21 | uint16_t mask; \ | ||
22 | uint64_t shiftmask; \ | ||
23 | unsigned e; \ | ||
24 | - if (shift == 0 || shift == ESIZE * 8) { \ | ||
25 | + if (shift == ESIZE * 8) { \ | ||
26 | /* \ | ||
27 | - * Only VSLI can shift by 0; only VSRI can shift by <dt>. \ | ||
28 | - * The generic logic would give the right answer for 0 but \ | ||
29 | - * fails for <dt>. \ | ||
30 | + * Only VSRI can shift by <dt>; it should mean "don't \ | ||
31 | + * update the destination". The generic logic can't handle \ | ||
32 | + * this because it would try to shift by an out-of-range \ | ||
33 | + * amount, so special case it here. \ | ||
34 | */ \ | ||
35 | goto done; \ | ||
36 | } \ | ||
37 | -- | ||
38 | 2.20.1 | ||
39 | |||
40 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | A cut-and-paste error meant we handled signed VADDV like | ||
2 | unsigned VADDV; fix the type used. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | target/arm/mve_helper.c | 6 +++--- | ||
8 | 1 file changed, 3 insertions(+), 3 deletions(-) | ||
9 | |||
10 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/target/arm/mve_helper.c | ||
13 | +++ b/target/arm/mve_helper.c | ||
14 | @@ -XXX,XX +XXX,XX @@ DO_LDAVH(vrmlsldavhxsw, int32_t, int64_t, true, true) | ||
15 | return ra; \ | ||
16 | } \ | ||
17 | |||
18 | -DO_VADDV(vaddvsb, 1, uint8_t) | ||
19 | -DO_VADDV(vaddvsh, 2, uint16_t) | ||
20 | -DO_VADDV(vaddvsw, 4, uint32_t) | ||
21 | +DO_VADDV(vaddvsb, 1, int8_t) | ||
22 | +DO_VADDV(vaddvsh, 2, int16_t) | ||
23 | +DO_VADDV(vaddvsw, 4, int32_t) | ||
24 | DO_VADDV(vaddvub, 1, uint8_t) | ||
25 | DO_VADDV(vaddvuh, 2, uint16_t) | ||
26 | DO_VADDV(vaddvuw, 4, uint32_t) | ||
27 | -- | ||
28 | 2.20.1 | ||
29 | |||
30 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | In the MVE helpers for the narrowing operations (DO_VSHRN and | ||
2 | DO_VSHRN_SAT) we were using the wrong bits of the predicate mask for | ||
3 | the 'top' versions of the insn. This is because the loop works over | ||
4 | the double-sized input elements and shifts the predicate mask by that | ||
5 | many bits each time, but when we write out the half-sized output we | ||
6 | must look at the mask bits for whichever half of the element we are | ||
7 | writing to. | ||
8 | 1 | ||
9 | Correct this by shifting the whole mask right by ESIZE bits for the | ||
10 | 'top' insns. This allows us also to simplify the saturation bit | ||
11 | checking (where we had noticed that we needed to look at a different | ||
12 | mask bit for the 'top' insn.) | ||
13 | |||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | --- | ||
17 | target/arm/mve_helper.c | 4 +++- | ||
18 | 1 file changed, 3 insertions(+), 1 deletion(-) | ||
19 | |||
20 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/target/arm/mve_helper.c | ||
23 | +++ b/target/arm/mve_helper.c | ||
24 | @@ -XXX,XX +XXX,XX @@ DO_VSHLL_ALL(vshllt, true) | ||
25 | TYPE *d = vd; \ | ||
26 | uint16_t mask = mve_element_mask(env); \ | ||
27 | unsigned le; \ | ||
28 | + mask >>= ESIZE * TOP; \ | ||
29 | for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \ | ||
30 | TYPE r = FN(m[H##LESIZE(le)], shift); \ | ||
31 | mergemask(&d[H##ESIZE(le * 2 + TOP)], r, mask); \ | ||
32 | @@ -XXX,XX +XXX,XX @@ static inline int32_t do_sat_bhs(int64_t val, int64_t min, int64_t max, | ||
33 | uint16_t mask = mve_element_mask(env); \ | ||
34 | bool qc = false; \ | ||
35 | unsigned le; \ | ||
36 | + mask >>= ESIZE * TOP; \ | ||
37 | for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \ | ||
38 | bool sat = false; \ | ||
39 | TYPE r = FN(m[H##LESIZE(le)], shift, &sat); \ | ||
40 | mergemask(&d[H##ESIZE(le * 2 + TOP)], r, mask); \ | ||
41 | - qc |= sat && (mask & 1 << (TOP * ESIZE)); \ | ||
42 | + qc |= sat & mask & 1; \ | ||
43 | } \ | ||
44 | if (qc) { \ | ||
45 | env->vfp.qc[0] = qc; \ | ||
46 | -- | ||
47 | 2.20.1 | ||
48 | |||
49 | diff view generated by jsdifflib |
1 | Implement the MVE gather-loads and scatter-stores which | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | form the address by adding a base value from a scalar | ||
3 | register to an offset in each element of a vector. | ||
4 | 2 | ||
3 | Move the computation of key to the top of the function. | ||
4 | Hoist the resolution of cp as well, as an input to the | ||
5 | computation of key. | ||
6 | |||
7 | This will be required by a subsequent patch. | ||
8 | |||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Message-id: 20220501055028.646596-14-richard.henderson@linaro.org | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | --- | 13 | --- |
8 | target/arm/helper-mve.h | 32 +++++++++ | 14 | target/arm/helper.c | 49 +++++++++++++++++++++++++-------------------- |
9 | target/arm/mve.decode | 12 ++++ | 15 | 1 file changed, 27 insertions(+), 22 deletions(-) |
10 | target/arm/mve_helper.c | 129 +++++++++++++++++++++++++++++++++++++ | ||
11 | target/arm/translate-mve.c | 97 ++++++++++++++++++++++++++++ | ||
12 | 4 files changed, 270 insertions(+) | ||
13 | 16 | ||
14 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 17 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
15 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/helper-mve.h | 19 | --- a/target/arm/helper.c |
17 | +++ b/target/arm/helper-mve.h | 20 | +++ b/target/arm/helper.c |
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vstrb_h, TCG_CALL_NO_WG, void, env, ptr, i32) | 21 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
19 | DEF_HELPER_FLAGS_3(mve_vstrb_w, TCG_CALL_NO_WG, void, env, ptr, i32) | 22 | ARMCPRegInfo *r2; |
20 | DEF_HELPER_FLAGS_3(mve_vstrh_w, TCG_CALL_NO_WG, void, env, ptr, i32) | 23 | int is64 = (r->type & ARM_CP_64BIT) ? 1 : 0; |
21 | 24 | int ns = (secstate & ARM_CP_SECSTATE_NS) ? 1 : 0; | |
22 | +DEF_HELPER_FLAGS_4(mve_vldrb_sg_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 25 | + int cp = r->cp; |
23 | +DEF_HELPER_FLAGS_4(mve_vldrb_sg_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 26 | size_t name_len; |
24 | +DEF_HELPER_FLAGS_4(mve_vldrh_sg_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 27 | |
25 | + | 28 | + switch (state) { |
26 | +DEF_HELPER_FLAGS_4(mve_vldrb_sg_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 29 | + case ARM_CP_STATE_AA32: |
27 | +DEF_HELPER_FLAGS_4(mve_vldrb_sg_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 30 | + /* We assume it is a cp15 register if the .cp field is left unset. */ |
28 | +DEF_HELPER_FLAGS_4(mve_vldrb_sg_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 31 | + if (cp == 0 && r->state == ARM_CP_STATE_BOTH) { |
29 | +DEF_HELPER_FLAGS_4(mve_vldrh_sg_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 32 | + cp = 15; |
30 | +DEF_HELPER_FLAGS_4(mve_vldrh_sg_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 33 | + } |
31 | +DEF_HELPER_FLAGS_4(mve_vldrw_sg_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 34 | + key = ENCODE_CP_REG(cp, is64, ns, r->crn, crm, opc1, opc2); |
32 | +DEF_HELPER_FLAGS_4(mve_vldrd_sg_ud, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 35 | + break; |
33 | + | 36 | + case ARM_CP_STATE_AA64: |
34 | +DEF_HELPER_FLAGS_4(mve_vstrb_sg_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 37 | + /* |
35 | +DEF_HELPER_FLAGS_4(mve_vstrb_sg_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 38 | + * To allow abbreviation of ARMCPRegInfo definitions, we treat |
36 | +DEF_HELPER_FLAGS_4(mve_vstrb_sg_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 39 | + * cp == 0 as equivalent to the value for "standard guest-visible |
37 | +DEF_HELPER_FLAGS_4(mve_vstrh_sg_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 40 | + * sysreg". STATE_BOTH definitions are also always "standard sysreg" |
38 | +DEF_HELPER_FLAGS_4(mve_vstrh_sg_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 41 | + * in their AArch64 view (the .cp value may be non-zero for the |
39 | +DEF_HELPER_FLAGS_4(mve_vstrw_sg_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 42 | + * benefit of the AArch32 view). |
40 | +DEF_HELPER_FLAGS_4(mve_vstrd_sg_ud, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 43 | + */ |
41 | + | 44 | + if (cp == 0 || r->state == ARM_CP_STATE_BOTH) { |
42 | +DEF_HELPER_FLAGS_4(mve_vldrh_sg_os_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 45 | + cp = CP_REG_ARM64_SYSREG_CP; |
43 | + | 46 | + } |
44 | +DEF_HELPER_FLAGS_4(mve_vldrh_sg_os_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 47 | + key = ENCODE_AA64_CP_REG(cp, r->crn, crm, r->opc0, opc1, opc2); |
45 | +DEF_HELPER_FLAGS_4(mve_vldrh_sg_os_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 48 | + break; |
46 | +DEF_HELPER_FLAGS_4(mve_vldrw_sg_os_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 49 | + default: |
47 | +DEF_HELPER_FLAGS_4(mve_vldrd_sg_os_ud, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 50 | + g_assert_not_reached(); |
48 | + | ||
49 | +DEF_HELPER_FLAGS_4(mve_vstrh_sg_os_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
50 | +DEF_HELPER_FLAGS_4(mve_vstrh_sg_os_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
51 | +DEF_HELPER_FLAGS_4(mve_vstrw_sg_os_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
52 | +DEF_HELPER_FLAGS_4(mve_vstrd_sg_os_ud, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
53 | + | ||
54 | DEF_HELPER_FLAGS_3(mve_vdup, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
55 | |||
56 | DEF_HELPER_FLAGS_4(mve_vidupb, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) | ||
57 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
58 | index XXXXXXX..XXXXXXX 100644 | ||
59 | --- a/target/arm/mve.decode | ||
60 | +++ b/target/arm/mve.decode | ||
61 | @@ -XXX,XX +XXX,XX @@ | ||
62 | &shl_scalar qda rm size | ||
63 | &vmaxv qm rda size | ||
64 | &vabav qn qm rda size | ||
65 | +&vldst_sg qd qm rn size msize os | ||
66 | + | ||
67 | +# scatter-gather memory size is in bits 6:4 | ||
68 | +%sg_msize 6:1 4:1 | ||
69 | |||
70 | @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 | ||
71 | # Note that both Rn and Qd are 3 bits only (no D bit) | ||
72 | @vldst_wn ... u:1 ... . . . . l:1 . rn:3 qd:3 . ... .. imm:7 &vldr_vstr | ||
73 | |||
74 | +@vldst_sg .... .... .... rn:4 .... ... size:2 ... ... os:1 &vldst_sg \ | ||
75 | + qd=%qd qm=%qm msize=%sg_msize | ||
76 | + | ||
77 | @1op .... .... .... size:2 .. .... .... .... .... &1op qd=%qd qm=%qm | ||
78 | @1op_nosz .... .... .... .... .... .... .... .... &1op qd=%qd qm=%qm size=0 | ||
79 | @2op .... .... .. size:2 .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn | ||
80 | @@ -XXX,XX +XXX,XX @@ VLDR_VSTR 1110110 1 a:1 . w:1 . .... ... 111101 ....... @vldr_vstr \ | ||
81 | VLDR_VSTR 1110110 1 a:1 . w:1 . .... ... 111110 ....... @vldr_vstr \ | ||
82 | size=2 p=1 | ||
83 | |||
84 | +# gather loads/scatter stores | ||
85 | +VLDR_S_sg 111 0 1100 1 . 01 .... ... 0 111 . .... .... @vldst_sg | ||
86 | +VLDR_U_sg 111 1 1100 1 . 01 .... ... 0 111 . .... .... @vldst_sg | ||
87 | +VSTR_sg 111 0 1100 1 . 00 .... ... 0 111 . .... .... @vldst_sg | ||
88 | + | ||
89 | # Moves between 2 32-bit vector lanes and 2 general purpose registers | ||
90 | VMOV_to_2gp 1110 1100 0 . 00 rt2:4 ... 0 1111 000 idx:1 rt:4 qd=%qd | ||
91 | VMOV_from_2gp 1110 1100 0 . 01 rt2:4 ... 0 1111 000 idx:1 rt:4 qd=%qd | ||
92 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
93 | index XXXXXXX..XXXXXXX 100644 | ||
94 | --- a/target/arm/mve_helper.c | ||
95 | +++ b/target/arm/mve_helper.c | ||
96 | @@ -XXX,XX +XXX,XX @@ DO_VSTR(vstrh_w, 2, stw, 4, int32_t) | ||
97 | #undef DO_VLDR | ||
98 | #undef DO_VSTR | ||
99 | |||
100 | +/* | ||
101 | + * Gather loads/scatter stores. Here each element of Qm specifies | ||
102 | + * an offset to use from the base register Rm. In the _os_ versions | ||
103 | + * that offset is scaled by the element size. | ||
104 | + * For loads, predicated lanes are zeroed instead of retaining | ||
105 | + * their previous values. | ||
106 | + */ | ||
107 | +#define DO_VLDR_SG(OP, LDTYPE, ESIZE, TYPE, OFFTYPE, ADDRFN) \ | ||
108 | + void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm, \ | ||
109 | + uint32_t base) \ | ||
110 | + { \ | ||
111 | + TYPE *d = vd; \ | ||
112 | + OFFTYPE *m = vm; \ | ||
113 | + uint16_t mask = mve_element_mask(env); \ | ||
114 | + uint16_t eci_mask = mve_eci_mask(env); \ | ||
115 | + unsigned e; \ | ||
116 | + uint32_t addr; \ | ||
117 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE, eci_mask >>= ESIZE) { \ | ||
118 | + if (!(eci_mask & 1)) { \ | ||
119 | + continue; \ | ||
120 | + } \ | ||
121 | + addr = ADDRFN(base, m[H##ESIZE(e)]); \ | ||
122 | + d[H##ESIZE(e)] = (mask & 1) ? \ | ||
123 | + cpu_##LDTYPE##_data_ra(env, addr, GETPC()) : 0; \ | ||
124 | + } \ | ||
125 | + mve_advance_vpt(env); \ | ||
126 | + } | 51 | + } |
127 | + | 52 | + |
128 | +/* We know here TYPE is unsigned so always the same as the offset type */ | 53 | /* Combine cpreg and name into one allocation. */ |
129 | +#define DO_VSTR_SG(OP, STTYPE, ESIZE, TYPE, ADDRFN) \ | 54 | name_len = strlen(name) + 1; |
130 | + void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm, \ | 55 | r2 = g_malloc(sizeof(*r2) + name_len); |
131 | + uint32_t base) \ | 56 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
132 | + { \ | 57 | } |
133 | + TYPE *d = vd; \ | 58 | |
134 | + TYPE *m = vm; \ | 59 | if (r->state == ARM_CP_STATE_BOTH) { |
135 | + uint16_t mask = mve_element_mask(env); \ | 60 | - /* We assume it is a cp15 register if the .cp field is left unset. |
136 | + unsigned e; \ | 61 | - */ |
137 | + uint32_t addr; \ | 62 | - if (r2->cp == 0) { |
138 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | 63 | - r2->cp = 15; |
139 | + addr = ADDRFN(base, m[H##ESIZE(e)]); \ | 64 | - } |
140 | + if (mask & 1) { \ | 65 | - |
141 | + cpu_##STTYPE##_data_ra(env, addr, d[H##ESIZE(e)], GETPC()); \ | 66 | #if HOST_BIG_ENDIAN |
142 | + } \ | 67 | if (r2->fieldoffset) { |
143 | + } \ | 68 | r2->fieldoffset += sizeof(uint32_t); |
144 | + mve_advance_vpt(env); \ | 69 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
145 | + } | 70 | #endif |
146 | + | 71 | } |
147 | +/* | 72 | } |
148 | + * 64-bit accesses are slightly different: they are done as two 32-bit | 73 | - if (state == ARM_CP_STATE_AA64) { |
149 | + * accesses, controlled by the predicate mask for the relevant beat, | 74 | - /* To allow abbreviation of ARMCPRegInfo |
150 | + * and with a single 32-bit offset in the first of the two Qm elements. | 75 | - * definitions, we treat cp == 0 as equivalent to |
151 | + * Note that for QEMU our IMPDEF AIRCR.ENDIANNESS is always 0 (little). | 76 | - * the value for "standard guest-visible sysreg". |
152 | + */ | 77 | - * STATE_BOTH definitions are also always "standard |
153 | +#define DO_VLDR64_SG(OP, ADDRFN) \ | 78 | - * sysreg" in their AArch64 view (the .cp value may |
154 | + void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm, \ | 79 | - * be non-zero for the benefit of the AArch32 view). |
155 | + uint32_t base) \ | 80 | - */ |
156 | + { \ | 81 | - if (r->cp == 0 || r->state == ARM_CP_STATE_BOTH) { |
157 | + uint32_t *d = vd; \ | 82 | - r2->cp = CP_REG_ARM64_SYSREG_CP; |
158 | + uint32_t *m = vm; \ | 83 | - } |
159 | + uint16_t mask = mve_element_mask(env); \ | 84 | - key = ENCODE_AA64_CP_REG(r2->cp, r2->crn, crm, |
160 | + uint16_t eci_mask = mve_eci_mask(env); \ | 85 | - r2->opc0, opc1, opc2); |
161 | + unsigned e; \ | 86 | - } else { |
162 | + uint32_t addr; \ | 87 | - key = ENCODE_CP_REG(r2->cp, is64, ns, r2->crn, crm, opc1, opc2); |
163 | + for (e = 0; e < 16 / 4; e++, mask >>= 4, eci_mask >>= 4) { \ | 88 | - } |
164 | + if (!(eci_mask & 1)) { \ | 89 | if (opaque) { |
165 | + continue; \ | 90 | r2->opaque = opaque; |
166 | + } \ | 91 | } |
167 | + addr = ADDRFN(base, m[H4(e & ~1)]); \ | 92 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
168 | + addr += 4 * (e & 1); \ | 93 | /* Make sure reginfo passed to helpers for wildcarded regs |
169 | + d[H4(e)] = (mask & 1) ? cpu_ldl_data_ra(env, addr, GETPC()) : 0; \ | 94 | * has the correct crm/opc1/opc2 for this reg, not CP_ANY: |
170 | + } \ | 95 | */ |
171 | + mve_advance_vpt(env); \ | 96 | + r2->cp = cp; |
172 | + } | 97 | r2->crm = crm; |
173 | + | 98 | r2->opc1 = opc1; |
174 | +#define DO_VSTR64_SG(OP, ADDRFN) \ | 99 | r2->opc2 = opc2; |
175 | + void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm, \ | ||
176 | + uint32_t base) \ | ||
177 | + { \ | ||
178 | + uint32_t *d = vd; \ | ||
179 | + uint32_t *m = vm; \ | ||
180 | + uint16_t mask = mve_element_mask(env); \ | ||
181 | + unsigned e; \ | ||
182 | + uint32_t addr; \ | ||
183 | + for (e = 0; e < 16 / 4; e++, mask >>= 4) { \ | ||
184 | + addr = ADDRFN(base, m[H4(e & ~1)]); \ | ||
185 | + addr += 4 * (e & 1); \ | ||
186 | + if (mask & 1) { \ | ||
187 | + cpu_stl_data_ra(env, addr, d[H4(e)], GETPC()); \ | ||
188 | + } \ | ||
189 | + } \ | ||
190 | + mve_advance_vpt(env); \ | ||
191 | + } | ||
192 | + | ||
193 | +#define ADDR_ADD(BASE, OFFSET) ((BASE) + (OFFSET)) | ||
194 | +#define ADDR_ADD_OSH(BASE, OFFSET) ((BASE) + ((OFFSET) << 1)) | ||
195 | +#define ADDR_ADD_OSW(BASE, OFFSET) ((BASE) + ((OFFSET) << 2)) | ||
196 | +#define ADDR_ADD_OSD(BASE, OFFSET) ((BASE) + ((OFFSET) << 3)) | ||
197 | + | ||
198 | +DO_VLDR_SG(vldrb_sg_sh, ldsb, 2, int16_t, uint16_t, ADDR_ADD) | ||
199 | +DO_VLDR_SG(vldrb_sg_sw, ldsb, 4, int32_t, uint32_t, ADDR_ADD) | ||
200 | +DO_VLDR_SG(vldrh_sg_sw, ldsw, 4, int32_t, uint32_t, ADDR_ADD) | ||
201 | + | ||
202 | +DO_VLDR_SG(vldrb_sg_ub, ldub, 1, uint8_t, uint8_t, ADDR_ADD) | ||
203 | +DO_VLDR_SG(vldrb_sg_uh, ldub, 2, uint16_t, uint16_t, ADDR_ADD) | ||
204 | +DO_VLDR_SG(vldrb_sg_uw, ldub, 4, uint32_t, uint32_t, ADDR_ADD) | ||
205 | +DO_VLDR_SG(vldrh_sg_uh, lduw, 2, uint16_t, uint16_t, ADDR_ADD) | ||
206 | +DO_VLDR_SG(vldrh_sg_uw, lduw, 4, uint32_t, uint32_t, ADDR_ADD) | ||
207 | +DO_VLDR_SG(vldrw_sg_uw, ldl, 4, uint32_t, uint32_t, ADDR_ADD) | ||
208 | +DO_VLDR64_SG(vldrd_sg_ud, ADDR_ADD) | ||
209 | + | ||
210 | +DO_VLDR_SG(vldrh_sg_os_sw, ldsw, 4, int32_t, uint32_t, ADDR_ADD_OSH) | ||
211 | +DO_VLDR_SG(vldrh_sg_os_uh, lduw, 2, uint16_t, uint16_t, ADDR_ADD_OSH) | ||
212 | +DO_VLDR_SG(vldrh_sg_os_uw, lduw, 4, uint32_t, uint32_t, ADDR_ADD_OSH) | ||
213 | +DO_VLDR_SG(vldrw_sg_os_uw, ldl, 4, uint32_t, uint32_t, ADDR_ADD_OSW) | ||
214 | +DO_VLDR64_SG(vldrd_sg_os_ud, ADDR_ADD_OSD) | ||
215 | + | ||
216 | +DO_VSTR_SG(vstrb_sg_ub, stb, 1, uint8_t, ADDR_ADD) | ||
217 | +DO_VSTR_SG(vstrb_sg_uh, stb, 2, uint16_t, ADDR_ADD) | ||
218 | +DO_VSTR_SG(vstrb_sg_uw, stb, 4, uint32_t, ADDR_ADD) | ||
219 | +DO_VSTR_SG(vstrh_sg_uh, stw, 2, uint16_t, ADDR_ADD) | ||
220 | +DO_VSTR_SG(vstrh_sg_uw, stw, 4, uint32_t, ADDR_ADD) | ||
221 | +DO_VSTR_SG(vstrw_sg_uw, stl, 4, uint32_t, ADDR_ADD) | ||
222 | +DO_VSTR64_SG(vstrd_sg_ud, ADDR_ADD) | ||
223 | + | ||
224 | +DO_VSTR_SG(vstrh_sg_os_uh, stw, 2, uint16_t, ADDR_ADD_OSH) | ||
225 | +DO_VSTR_SG(vstrh_sg_os_uw, stw, 4, uint32_t, ADDR_ADD_OSH) | ||
226 | +DO_VSTR_SG(vstrw_sg_os_uw, stl, 4, uint32_t, ADDR_ADD_OSW) | ||
227 | +DO_VSTR64_SG(vstrd_sg_os_ud, ADDR_ADD_OSD) | ||
228 | + | ||
229 | /* | ||
230 | * The mergemask(D, R, M) macro performs the operation "*D = R" but | ||
231 | * storing only the bytes which correspond to 1 bits in M, | ||
232 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
233 | index XXXXXXX..XXXXXXX 100644 | ||
234 | --- a/target/arm/translate-mve.c | ||
235 | +++ b/target/arm/translate-mve.c | ||
236 | @@ -XXX,XX +XXX,XX @@ static inline int vidup_imm(DisasContext *s, int x) | ||
237 | #include "decode-mve.c.inc" | ||
238 | |||
239 | typedef void MVEGenLdStFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
240 | +typedef void MVEGenLdStSGFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
241 | typedef void MVEGenOneOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
242 | typedef void MVEGenTwoOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
243 | typedef void MVEGenTwoOpScalarFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
244 | @@ -XXX,XX +XXX,XX @@ DO_VLDST_WIDE_NARROW(VLDSTB_H, vldrb_sh, vldrb_uh, vstrb_h, MO_8) | ||
245 | DO_VLDST_WIDE_NARROW(VLDSTB_W, vldrb_sw, vldrb_uw, vstrb_w, MO_8) | ||
246 | DO_VLDST_WIDE_NARROW(VLDSTH_W, vldrh_sw, vldrh_uw, vstrh_w, MO_16) | ||
247 | |||
248 | +static bool do_ldst_sg(DisasContext *s, arg_vldst_sg *a, MVEGenLdStSGFn fn) | ||
249 | +{ | ||
250 | + TCGv_i32 addr; | ||
251 | + TCGv_ptr qd, qm; | ||
252 | + | ||
253 | + if (!dc_isar_feature(aa32_mve, s) || | ||
254 | + !mve_check_qreg_bank(s, a->qd | a->qm) || | ||
255 | + !fn || a->rn == 15) { | ||
256 | + /* Rn case is UNPREDICTABLE */ | ||
257 | + return false; | ||
258 | + } | ||
259 | + | ||
260 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
261 | + return true; | ||
262 | + } | ||
263 | + | ||
264 | + addr = load_reg(s, a->rn); | ||
265 | + | ||
266 | + qd = mve_qreg_ptr(a->qd); | ||
267 | + qm = mve_qreg_ptr(a->qm); | ||
268 | + fn(cpu_env, qd, qm, addr); | ||
269 | + tcg_temp_free_ptr(qd); | ||
270 | + tcg_temp_free_ptr(qm); | ||
271 | + tcg_temp_free_i32(addr); | ||
272 | + mve_update_eci(s); | ||
273 | + return true; | ||
274 | +} | ||
275 | + | ||
276 | +/* | ||
277 | + * The naming scheme here is "vldrb_sg_sh == in-memory byte loads | ||
278 | + * signextended to halfword elements in register". _os_ indicates that | ||
279 | + * the offsets in Qm should be scaled by the element size. | ||
280 | + */ | ||
281 | +/* This macro is just to make the arrays more compact in these functions */ | ||
282 | +#define F(N) gen_helper_mve_##N | ||
283 | + | ||
284 | +/* VLDRB/VSTRB (ie msize 1) with OS=1 is UNPREDICTABLE; we UNDEF */ | ||
285 | +static bool trans_VLDR_S_sg(DisasContext *s, arg_vldst_sg *a) | ||
286 | +{ | ||
287 | + static MVEGenLdStSGFn * const fns[2][4][4] = { { | ||
288 | + { NULL, F(vldrb_sg_sh), F(vldrb_sg_sw), NULL }, | ||
289 | + { NULL, NULL, F(vldrh_sg_sw), NULL }, | ||
290 | + { NULL, NULL, NULL, NULL }, | ||
291 | + { NULL, NULL, NULL, NULL } | ||
292 | + }, { | ||
293 | + { NULL, NULL, NULL, NULL }, | ||
294 | + { NULL, NULL, F(vldrh_sg_os_sw), NULL }, | ||
295 | + { NULL, NULL, NULL, NULL }, | ||
296 | + { NULL, NULL, NULL, NULL } | ||
297 | + } | ||
298 | + }; | ||
299 | + if (a->qd == a->qm) { | ||
300 | + return false; /* UNPREDICTABLE */ | ||
301 | + } | ||
302 | + return do_ldst_sg(s, a, fns[a->os][a->msize][a->size]); | ||
303 | +} | ||
304 | + | ||
305 | +static bool trans_VLDR_U_sg(DisasContext *s, arg_vldst_sg *a) | ||
306 | +{ | ||
307 | + static MVEGenLdStSGFn * const fns[2][4][4] = { { | ||
308 | + { F(vldrb_sg_ub), F(vldrb_sg_uh), F(vldrb_sg_uw), NULL }, | ||
309 | + { NULL, F(vldrh_sg_uh), F(vldrh_sg_uw), NULL }, | ||
310 | + { NULL, NULL, F(vldrw_sg_uw), NULL }, | ||
311 | + { NULL, NULL, NULL, F(vldrd_sg_ud) } | ||
312 | + }, { | ||
313 | + { NULL, NULL, NULL, NULL }, | ||
314 | + { NULL, F(vldrh_sg_os_uh), F(vldrh_sg_os_uw), NULL }, | ||
315 | + { NULL, NULL, F(vldrw_sg_os_uw), NULL }, | ||
316 | + { NULL, NULL, NULL, F(vldrd_sg_os_ud) } | ||
317 | + } | ||
318 | + }; | ||
319 | + if (a->qd == a->qm) { | ||
320 | + return false; /* UNPREDICTABLE */ | ||
321 | + } | ||
322 | + return do_ldst_sg(s, a, fns[a->os][a->msize][a->size]); | ||
323 | +} | ||
324 | + | ||
325 | +static bool trans_VSTR_sg(DisasContext *s, arg_vldst_sg *a) | ||
326 | +{ | ||
327 | + static MVEGenLdStSGFn * const fns[2][4][4] = { { | ||
328 | + { F(vstrb_sg_ub), F(vstrb_sg_uh), F(vstrb_sg_uw), NULL }, | ||
329 | + { NULL, F(vstrh_sg_uh), F(vstrh_sg_uw), NULL }, | ||
330 | + { NULL, NULL, F(vstrw_sg_uw), NULL }, | ||
331 | + { NULL, NULL, NULL, F(vstrd_sg_ud) } | ||
332 | + }, { | ||
333 | + { NULL, NULL, NULL, NULL }, | ||
334 | + { NULL, F(vstrh_sg_os_uh), F(vstrh_sg_os_uw), NULL }, | ||
335 | + { NULL, NULL, F(vstrw_sg_os_uw), NULL }, | ||
336 | + { NULL, NULL, NULL, F(vstrd_sg_os_ud) } | ||
337 | + } | ||
338 | + }; | ||
339 | + return do_ldst_sg(s, a, fns[a->os][a->msize][a->size]); | ||
340 | +} | ||
341 | + | ||
342 | +#undef F | ||
343 | + | ||
344 | static bool trans_VDUP(DisasContext *s, arg_VDUP *a) | ||
345 | { | ||
346 | TCGv_ptr qd; | ||
347 | -- | 100 | -- |
348 | 2.20.1 | 101 | 2.25.1 |
349 | |||
350 | diff view generated by jsdifflib |
1 | From: Guenter Roeck <linux@roeck-us.net> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Instantiate SAI1/2/3 and ASRC as unimplemented devices to avoid random | 3 | Put most of the value writeback to the same place, |
4 | Linux kernel crashes, such as | 4 | and improve the comment that goes with them. |
5 | 5 | ||
6 | Unhandled fault: external abort on non-linefetch (0x808) at 0xd1580010 | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | pgd = (ptrval) | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | [d1580010] *pgd=8231b811, *pte=02034653, *ppte=02034453 | 8 | Message-id: 20220501055028.646596-15-richard.henderson@linaro.org |
9 | Internal error: : 808 [#1] SMP ARM | ||
10 | ... | ||
11 | [<c095e974>] (regmap_mmio_write32le) from [<c095eb48>] (regmap_mmio_write+0x3c/0x54) | ||
12 | [<c095eb48>] (regmap_mmio_write) from [<c09580f4>] (_regmap_write+0x4c/0x1f0) | ||
13 | [<c09580f4>] (_regmap_write) from [<c095837c>] (_regmap_update_bits+0xe4/0xec) | ||
14 | [<c095837c>] (_regmap_update_bits) from [<c09599b4>] (regmap_update_bits_base+0x50/0x74) | ||
15 | [<c09599b4>] (regmap_update_bits_base) from [<c0d3e9e4>] (fsl_asrc_runtime_resume+0x1e4/0x21c) | ||
16 | [<c0d3e9e4>] (fsl_asrc_runtime_resume) from [<c0942464>] (__rpm_callback+0x3c/0x108) | ||
17 | [<c0942464>] (__rpm_callback) from [<c0942590>] (rpm_callback+0x60/0x64) | ||
18 | [<c0942590>] (rpm_callback) from [<c0942b60>] (rpm_resume+0x5cc/0x808) | ||
19 | [<c0942b60>] (rpm_resume) from [<c0942dfc>] (__pm_runtime_resume+0x60/0xa0) | ||
20 | [<c0942dfc>] (__pm_runtime_resume) from [<c0d3ecc4>] (fsl_asrc_probe+0x2a8/0x708) | ||
21 | [<c0d3ecc4>] (fsl_asrc_probe) from [<c0935b08>] (platform_probe+0x58/0xb8) | ||
22 | [<c0935b08>] (platform_probe) from [<c0933264>] (really_probe.part.0+0x9c/0x334) | ||
23 | [<c0933264>] (really_probe.part.0) from [<c093359c>] (__driver_probe_device+0xa0/0x138) | ||
24 | [<c093359c>] (__driver_probe_device) from [<c0933664>] (driver_probe_device+0x30/0xc8) | ||
25 | [<c0933664>] (driver_probe_device) from [<c0933c88>] (__driver_attach+0x90/0x130) | ||
26 | [<c0933c88>] (__driver_attach) from [<c0931060>] (bus_for_each_dev+0x78/0xb8) | ||
27 | [<c0931060>] (bus_for_each_dev) from [<c093254c>] (bus_add_driver+0xf0/0x1d8) | ||
28 | [<c093254c>] (bus_add_driver) from [<c0934a30>] (driver_register+0x88/0x118) | ||
29 | [<c0934a30>] (driver_register) from [<c01022c0>] (do_one_initcall+0x7c/0x3a4) | ||
30 | [<c01022c0>] (do_one_initcall) from [<c1601204>] (kernel_init_freeable+0x198/0x22c) | ||
31 | [<c1601204>] (kernel_init_freeable) from [<c0f5ff2c>] (kernel_init+0x10/0x128) | ||
32 | [<c0f5ff2c>] (kernel_init) from [<c010013c>] (ret_from_fork+0x14/0x38) | ||
33 | |||
34 | or | ||
35 | |||
36 | Unhandled fault: external abort on non-linefetch (0x808) at 0xd19b0000 | ||
37 | pgd = (ptrval) | ||
38 | [d19b0000] *pgd=82711811, *pte=308a0653, *ppte=308a0453 | ||
39 | Internal error: : 808 [#1] SMP ARM | ||
40 | ... | ||
41 | [<c095e974>] (regmap_mmio_write32le) from [<c095eb48>] (regmap_mmio_write+0x3c/0x54) | ||
42 | [<c095eb48>] (regmap_mmio_write) from [<c09580f4>] (_regmap_write+0x4c/0x1f0) | ||
43 | [<c09580f4>] (_regmap_write) from [<c0959b28>] (regmap_write+0x3c/0x60) | ||
44 | [<c0959b28>] (regmap_write) from [<c0d41130>] (fsl_sai_runtime_resume+0x9c/0x1ec) | ||
45 | [<c0d41130>] (fsl_sai_runtime_resume) from [<c0942464>] (__rpm_callback+0x3c/0x108) | ||
46 | [<c0942464>] (__rpm_callback) from [<c0942590>] (rpm_callback+0x60/0x64) | ||
47 | [<c0942590>] (rpm_callback) from [<c0942b60>] (rpm_resume+0x5cc/0x808) | ||
48 | [<c0942b60>] (rpm_resume) from [<c0942dfc>] (__pm_runtime_resume+0x60/0xa0) | ||
49 | [<c0942dfc>] (__pm_runtime_resume) from [<c0d4231c>] (fsl_sai_probe+0x2b8/0x65c) | ||
50 | [<c0d4231c>] (fsl_sai_probe) from [<c0935b08>] (platform_probe+0x58/0xb8) | ||
51 | [<c0935b08>] (platform_probe) from [<c0933264>] (really_probe.part.0+0x9c/0x334) | ||
52 | [<c0933264>] (really_probe.part.0) from [<c093359c>] (__driver_probe_device+0xa0/0x138) | ||
53 | [<c093359c>] (__driver_probe_device) from [<c0933664>] (driver_probe_device+0x30/0xc8) | ||
54 | [<c0933664>] (driver_probe_device) from [<c0933c88>] (__driver_attach+0x90/0x130) | ||
55 | [<c0933c88>] (__driver_attach) from [<c0931060>] (bus_for_each_dev+0x78/0xb8) | ||
56 | [<c0931060>] (bus_for_each_dev) from [<c093254c>] (bus_add_driver+0xf0/0x1d8) | ||
57 | [<c093254c>] (bus_add_driver) from [<c0934a30>] (driver_register+0x88/0x118) | ||
58 | [<c0934a30>] (driver_register) from [<c01022c0>] (do_one_initcall+0x7c/0x3a4) | ||
59 | [<c01022c0>] (do_one_initcall) from [<c1601204>] (kernel_init_freeable+0x198/0x22c) | ||
60 | [<c1601204>] (kernel_init_freeable) from [<c0f5ff2c>] (kernel_init+0x10/0x128) | ||
61 | [<c0f5ff2c>] (kernel_init) from [<c010013c>] (ret_from_fork+0x14/0x38) | ||
62 | |||
63 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
64 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | ||
65 | Message-id: 20210810160318.87376-1-linux@roeck-us.net | ||
66 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
67 | --- | 10 | --- |
68 | hw/arm/fsl-imx6ul.c | 12 ++++++++++++ | 11 | target/arm/helper.c | 28 ++++++++++++---------------- |
69 | 1 file changed, 12 insertions(+) | 12 | 1 file changed, 12 insertions(+), 16 deletions(-) |
70 | 13 | ||
71 | diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c | 14 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
72 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
73 | --- a/hw/arm/fsl-imx6ul.c | 16 | --- a/target/arm/helper.c |
74 | +++ b/hw/arm/fsl-imx6ul.c | 17 | +++ b/target/arm/helper.c |
75 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | 18 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
19 | *r2 = *r; | ||
20 | r2->name = memcpy(r2 + 1, name, name_len); | ||
21 | |||
22 | - /* Reset the secure state to the specific incoming state. This is | ||
23 | - * necessary as the register may have been defined with both states. | ||
24 | + /* | ||
25 | + * Update fields to match the instantiation, overwiting wildcards | ||
26 | + * such as CP_ANY, ARM_CP_STATE_BOTH, or ARM_CP_SECSTATE_BOTH. | ||
76 | */ | 27 | */ |
77 | create_unimplemented_device("sdma", FSL_IMX6UL_SDMA_ADDR, 0x4000); | 28 | + r2->cp = cp; |
78 | 29 | + r2->crm = crm; | |
79 | + /* | 30 | + r2->opc1 = opc1; |
80 | + * SAI (Audio SSI (Synchronous Serial Interface)) | 31 | + r2->opc2 = opc2; |
81 | + */ | 32 | + r2->state = state; |
82 | + create_unimplemented_device("sai1", FSL_IMX6UL_SAI1_ADDR, 0x4000); | 33 | r2->secure = secstate; |
83 | + create_unimplemented_device("sai2", FSL_IMX6UL_SAI2_ADDR, 0x4000); | 34 | + if (opaque) { |
84 | + create_unimplemented_device("sai3", FSL_IMX6UL_SAI3_ADDR, 0x4000); | 35 | + r2->opaque = opaque; |
36 | + } | ||
37 | |||
38 | if (r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1]) { | ||
39 | /* Register is banked (using both entries in array). | ||
40 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
41 | #endif | ||
42 | } | ||
43 | } | ||
44 | - if (opaque) { | ||
45 | - r2->opaque = opaque; | ||
46 | - } | ||
47 | - /* reginfo passed to helpers is correct for the actual access, | ||
48 | - * and is never ARM_CP_STATE_BOTH: | ||
49 | - */ | ||
50 | - r2->state = state; | ||
51 | - /* Make sure reginfo passed to helpers for wildcarded regs | ||
52 | - * has the correct crm/opc1/opc2 for this reg, not CP_ANY: | ||
53 | - */ | ||
54 | - r2->cp = cp; | ||
55 | - r2->crm = crm; | ||
56 | - r2->opc1 = opc1; | ||
57 | - r2->opc2 = opc2; | ||
85 | + | 58 | + |
86 | /* | 59 | /* By convention, for wildcarded registers only the first |
87 | * PWM | 60 | * entry is used for migration; the others are marked as |
88 | */ | 61 | * ALIAS so we don't try to transfer the register |
89 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
90 | create_unimplemented_device("pwm3", FSL_IMX6UL_PWM3_ADDR, 0x4000); | ||
91 | create_unimplemented_device("pwm4", FSL_IMX6UL_PWM4_ADDR, 0x4000); | ||
92 | |||
93 | + /* | ||
94 | + * Audio ASRC (asynchronous sample rate converter) | ||
95 | + */ | ||
96 | + create_unimplemented_device("asrc", FSL_IMX6UL_ASRC_ADDR, 0x4000); | ||
97 | + | ||
98 | /* | ||
99 | * CAN | ||
100 | */ | ||
101 | -- | 62 | -- |
102 | 2.20.1 | 63 | 2.25.1 |
103 | |||
104 | diff view generated by jsdifflib |
1 | From: Sebastian Meyer <meyer@absint.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | With gdb 9.0 and better it is possible to connect to a gdbstub | 3 | Bool is a more appropriate type for these variables. |
4 | over unix sockets, which is better than a TCP socket connection | ||
5 | in some situations. The QEMU command line to set this up is | ||
6 | non-obvious; document it. | ||
7 | 4 | ||
8 | Signed-off-by: Sebastian Meyer <meyer@absint.com> | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 162867284829.27377.4784930719350564918-0@git.sr.ht | ||
10 | [PMM: Tweaked commit message; adjusted wording in a couple of | ||
11 | places; fixed rST formatting issue; moved section up out of | ||
12 | the 'advanced debugging options' subsection] | ||
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 7 | Message-id: 20220501055028.646596-16-richard.henderson@linaro.org |
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 9 | --- |
17 | docs/system/gdb.rst | 26 +++++++++++++++++++++++++- | 10 | target/arm/helper.c | 4 ++-- |
18 | 1 file changed, 25 insertions(+), 1 deletion(-) | 11 | 1 file changed, 2 insertions(+), 2 deletions(-) |
19 | 12 | ||
20 | diff --git a/docs/system/gdb.rst b/docs/system/gdb.rst | 13 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
21 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/docs/system/gdb.rst | 15 | --- a/target/arm/helper.c |
23 | +++ b/docs/system/gdb.rst | 16 | +++ b/target/arm/helper.c |
24 | @@ -XXX,XX +XXX,XX @@ The ``-s`` option will make QEMU listen for an incoming connection | 17 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
25 | from gdb on TCP port 1234, and ``-S`` will make QEMU not start the | 18 | */ |
26 | guest until you tell it to from gdb. (If you want to specify which | 19 | uint32_t key; |
27 | TCP port to use or to use something other than TCP for the gdbstub | 20 | ARMCPRegInfo *r2; |
28 | -connection, use the ``-gdb dev`` option instead of ``-s``.) | 21 | - int is64 = (r->type & ARM_CP_64BIT) ? 1 : 0; |
29 | +connection, use the ``-gdb dev`` option instead of ``-s``. See | 22 | - int ns = (secstate & ARM_CP_SECSTATE_NS) ? 1 : 0; |
30 | +`Using unix sockets`_ for an example.) | 23 | + bool is64 = r->type & ARM_CP_64BIT; |
31 | 24 | + bool ns = secstate & ARM_CP_SECSTATE_NS; | |
32 | .. parsed-literal:: | 25 | int cp = r->cp; |
33 | 26 | size_t name_len; | |
34 | @@ -XXX,XX +XXX,XX @@ not just those in the cluster you are currently working on:: | ||
35 | |||
36 | (gdb) set schedule-multiple on | ||
37 | |||
38 | +Using unix sockets | ||
39 | +================== | ||
40 | + | ||
41 | +An alternate method for connecting gdb to the QEMU gdbstub is to use | ||
42 | +a unix socket (if supported by your operating system). This is useful when | ||
43 | +running several tests in parallel, or if you do not have a known free TCP | ||
44 | +port (e.g. when running automated tests). | ||
45 | + | ||
46 | +First create a chardev with the appropriate options, then | ||
47 | +instruct the gdbserver to use that device: | ||
48 | + | ||
49 | +.. parsed-literal:: | ||
50 | + | ||
51 | + |qemu_system| -chardev socket,path=/tmp/gdb-socket,server=on,wait=off,id=gdb0 -gdb chardev:gdb0 -S ... | ||
52 | + | ||
53 | +Start gdb as before, but this time connect using the path to | ||
54 | +the socket:: | ||
55 | + | ||
56 | + (gdb) target remote /tmp/gdb-socket | ||
57 | + | ||
58 | +Note that to use a unix socket for the connection you will need | ||
59 | +gdb version 9.0 or newer. | ||
60 | + | ||
61 | Advanced debugging options | ||
62 | ========================== | ||
63 | 27 | ||
64 | -- | 28 | -- |
65 | 2.20.1 | 29 | 2.25.1 |
66 | |||
67 | diff view generated by jsdifflib |
1 | In do_sqrshl48_d() and do_uqrshl48_d() we got some of the edge | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | cases wrong and failed to saturate correctly: | ||
3 | 2 | ||
4 | (1) In do_sqrshl48_d() we used the same code that do_shrshl_bhs() | 3 | Computing isbanked only once makes the code |
5 | does to obtain the saturated most-negative and most-positive 48-bit | 4 | a bit easier to read. |
6 | signed values for the large-shift-left case. This gives (1 << 47) | ||
7 | for saturate-to-most-negative, but we weren't sign-extending this | ||
8 | value to the 64-bit output as the pseudocode requires. | ||
9 | 5 | ||
10 | (2) For left shifts by less than 48, we copied the "8/16 bit" code | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
11 | from do_sqrshl_bhs() and do_uqrshl_bhs(). This doesn't do the right | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
12 | thing because it assumes the C type we're working with is at least | 8 | Message-id: 20220501055028.646596-17-richard.henderson@linaro.org |
13 | twice the number of bits we're saturating to (so that a shift left by | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | bits-1 can't shift anything off the top of the value). This isn't | 10 | --- |
15 | true for bits == 48, so we would incorrectly return 0 rather than the | 11 | target/arm/helper.c | 6 ++++-- |
16 | most-positive value for situations like "shift (1 << 44) right by | 12 | 1 file changed, 4 insertions(+), 2 deletions(-) |
17 | 20". Instead check for saturation by doing the shift and signextend | ||
18 | and then testing whether shifting back left again gives the original | ||
19 | value. | ||
20 | 13 | ||
21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
22 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
23 | --- | ||
24 | target/arm/mve_helper.c | 12 +++++------- | ||
25 | 1 file changed, 5 insertions(+), 7 deletions(-) | ||
26 | |||
27 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/target/arm/mve_helper.c | 16 | --- a/target/arm/helper.c |
30 | +++ b/target/arm/mve_helper.c | 17 | +++ b/target/arm/helper.c |
31 | @@ -XXX,XX +XXX,XX @@ static inline int64_t do_sqrshl48_d(int64_t src, int64_t shift, | 18 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
32 | } | 19 | bool is64 = r->type & ARM_CP_64BIT; |
33 | return src >> -shift; | 20 | bool ns = secstate & ARM_CP_SECSTATE_NS; |
34 | } else if (shift < 48) { | 21 | int cp = r->cp; |
35 | - int64_t val = src << shift; | 22 | + bool isbanked; |
36 | - int64_t extval = sextract64(val, 0, 48); | 23 | size_t name_len; |
37 | - if (!sat || val == extval) { | 24 | |
38 | + int64_t extval = sextract64(src << shift, 0, 48); | 25 | switch (state) { |
39 | + if (!sat || src == (extval >> shift)) { | 26 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
40 | return extval; | 27 | r2->opaque = opaque; |
41 | } | ||
42 | } else if (!sat || src == 0) { | ||
43 | @@ -XXX,XX +XXX,XX @@ static inline int64_t do_sqrshl48_d(int64_t src, int64_t shift, | ||
44 | } | 28 | } |
45 | 29 | ||
46 | *sat = 1; | 30 | - if (r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1]) { |
47 | - return (1ULL << 47) - (src >= 0); | 31 | + isbanked = r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1]; |
48 | + return src >= 0 ? MAKE_64BIT_MASK(0, 47) : MAKE_64BIT_MASK(47, 17); | 32 | + if (isbanked) { |
49 | } | 33 | /* Register is banked (using both entries in array). |
50 | 34 | * Overwriting fieldoffset as the array is only used to define | |
51 | /* Operate on 64-bit values, but saturate at 48 bits */ | 35 | * banked registers but later only fieldoffset is used. |
52 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t do_uqrshl48_d(uint64_t src, int64_t shift, | 36 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
53 | return extval; | 37 | } |
54 | } | 38 | |
55 | } else if (shift < 48) { | 39 | if (state == ARM_CP_STATE_AA32) { |
56 | - uint64_t val = src << shift; | 40 | - if (r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1]) { |
57 | - uint64_t extval = extract64(val, 0, 48); | 41 | + if (isbanked) { |
58 | - if (!sat || val == extval) { | 42 | /* If the register is banked then we don't need to migrate or |
59 | + uint64_t extval = extract64(src << shift, 0, 48); | 43 | * reset the 32-bit instance in certain cases: |
60 | + if (!sat || src == (extval >> shift)) { | 44 | * |
61 | return extval; | ||
62 | } | ||
63 | } else if (!sat || src == 0) { | ||
64 | -- | 45 | -- |
65 | 2.20.1 | 46 | 2.25.1 |
66 | |||
67 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | We got an edge case wrong in the 48-bit SQRSHRL implementation: if | ||
2 | the shift is to the right, although it always makes the result | ||
3 | smaller than the input value it might not be within the 48-bit range | ||
4 | the result is supposed to be if the input had some bits in [63..48] | ||
5 | set and the shift didn't bring all of those within the [47..0] range. | ||
6 | 1 | ||
7 | Handle this similarly to the way we already do for this case in | ||
8 | do_uqrshl48_d(): extend the calculated result from 48 bits, | ||
9 | and return that if not saturating or if it doesn't change the | ||
10 | result; otherwise fall through to return a saturated value. | ||
11 | |||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | --- | ||
15 | target/arm/mve_helper.c | 11 +++++++++-- | ||
16 | 1 file changed, 9 insertions(+), 2 deletions(-) | ||
17 | |||
18 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/arm/mve_helper.c | ||
21 | +++ b/target/arm/mve_helper.c | ||
22 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(mve_uqrshll)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
23 | static inline int64_t do_sqrshl48_d(int64_t src, int64_t shift, | ||
24 | bool round, uint32_t *sat) | ||
25 | { | ||
26 | + int64_t val, extval; | ||
27 | + | ||
28 | if (shift <= -48) { | ||
29 | /* Rounding the sign bit always produces 0. */ | ||
30 | if (round) { | ||
31 | @@ -XXX,XX +XXX,XX @@ static inline int64_t do_sqrshl48_d(int64_t src, int64_t shift, | ||
32 | } else if (shift < 0) { | ||
33 | if (round) { | ||
34 | src >>= -shift - 1; | ||
35 | - return (src >> 1) + (src & 1); | ||
36 | + val = (src >> 1) + (src & 1); | ||
37 | + } else { | ||
38 | + val = src >> -shift; | ||
39 | + } | ||
40 | + extval = sextract64(val, 0, 48); | ||
41 | + if (!sat || val == extval) { | ||
42 | + return extval; | ||
43 | } | ||
44 | - return src >> -shift; | ||
45 | } else if (shift < 48) { | ||
46 | int64_t extval = sextract64(src << shift, 0, 48); | ||
47 | if (!sat || src == (extval >> shift)) { | ||
48 | -- | ||
49 | 2.20.1 | ||
50 | |||
51 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | In mve_element_mask(), we calculate a mask for tail predication which | ||
2 | should have a number of 1 bits based on the value of LR. However, | ||
3 | our MAKE_64BIT_MASK() macro has undefined behaviour when passed a | ||
4 | zero length. Special case this to give the all-zeroes mask we | ||
5 | require. | ||
6 | 1 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | --- | ||
10 | target/arm/mve_helper.c | 3 ++- | ||
11 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
12 | |||
13 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/mve_helper.c | ||
16 | +++ b/target/arm/mve_helper.c | ||
17 | @@ -XXX,XX +XXX,XX @@ static uint16_t mve_element_mask(CPUARMState *env) | ||
18 | */ | ||
19 | int masklen = env->regs[14] << env->v7m.ltpsize; | ||
20 | assert(masklen <= 16); | ||
21 | - mask &= MAKE_64BIT_MASK(0, masklen); | ||
22 | + uint16_t ltpmask = masklen ? MAKE_64BIT_MASK(0, masklen) : 0; | ||
23 | + mask &= ltpmask; | ||
24 | } | ||
25 | |||
26 | if ((env->condexec_bits & 0xf) == 0) { | ||
27 | -- | ||
28 | 2.20.1 | ||
29 | |||
30 | diff view generated by jsdifflib |
1 | In some situations we need a mask telling us which parts of the | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | vector correspond to beats that are not being executed because of | ||
3 | ECI, separately from the combined "which bytes are predicated away" | ||
4 | mask. Factor this mask calculation out of mve_element_mask() into | ||
5 | its own function. | ||
6 | 2 | ||
3 | Perform the override check early, so that it is still done | ||
4 | even when we decide to discard an unreachable cpreg. | ||
5 | |||
6 | Use assert not printf+abort. | ||
7 | |||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Message-id: 20220501055028.646596-18-richard.henderson@linaro.org | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | --- | 12 | --- |
10 | target/arm/mve_helper.c | 58 ++++++++++++++++++++++++----------------- | 13 | target/arm/helper.c | 22 ++++++++-------------- |
11 | 1 file changed, 34 insertions(+), 24 deletions(-) | 14 | 1 file changed, 8 insertions(+), 14 deletions(-) |
12 | 15 | ||
13 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | 16 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
14 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/mve_helper.c | 18 | --- a/target/arm/helper.c |
16 | +++ b/target/arm/mve_helper.c | 19 | +++ b/target/arm/helper.c |
17 | @@ -XXX,XX +XXX,XX @@ | 20 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
18 | #include "exec/exec-all.h" | 21 | g_assert_not_reached(); |
19 | #include "tcg/tcg.h" | 22 | } |
20 | 23 | ||
21 | +static uint16_t mve_eci_mask(CPUARMState *env) | 24 | + /* Overriding of an existing definition must be explicitly requested. */ |
22 | +{ | 25 | + if (!(r->type & ARM_CP_OVERRIDE)) { |
23 | + /* | 26 | + const ARMCPRegInfo *oldreg = get_arm_cp_reginfo(cpu->cp_regs, key); |
24 | + * Return the mask of which elements in the MVE vector correspond | 27 | + if (oldreg) { |
25 | + * to beats being executed. The mask has 1 bits for executed lanes | 28 | + assert(oldreg->type & ARM_CP_OVERRIDE); |
26 | + * and 0 bits where ECI says this beat was already executed. | 29 | + } |
27 | + */ | ||
28 | + int eci; | ||
29 | + | ||
30 | + if ((env->condexec_bits & 0xf) != 0) { | ||
31 | + return 0xffff; | ||
32 | + } | 30 | + } |
33 | + | 31 | + |
34 | + eci = env->condexec_bits >> 4; | 32 | /* Combine cpreg and name into one allocation. */ |
35 | + switch (eci) { | 33 | name_len = strlen(name) + 1; |
36 | + case ECI_NONE: | 34 | r2 = g_malloc(sizeof(*r2) + name_len); |
37 | + return 0xffff; | 35 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
38 | + case ECI_A0: | 36 | assert(!raw_accessors_invalid(r2)); |
39 | + return 0xfff0; | ||
40 | + case ECI_A0A1: | ||
41 | + return 0xff00; | ||
42 | + case ECI_A0A1A2: | ||
43 | + case ECI_A0A1A2B0: | ||
44 | + return 0xf000; | ||
45 | + default: | ||
46 | + g_assert_not_reached(); | ||
47 | + } | ||
48 | +} | ||
49 | + | ||
50 | static uint16_t mve_element_mask(CPUARMState *env) | ||
51 | { | ||
52 | /* | ||
53 | @@ -XXX,XX +XXX,XX @@ static uint16_t mve_element_mask(CPUARMState *env) | ||
54 | mask &= ltpmask; | ||
55 | } | 37 | } |
56 | 38 | ||
57 | - if ((env->condexec_bits & 0xf) == 0) { | 39 | - /* Overriding of an existing definition must be explicitly |
58 | - /* | 40 | - * requested. |
59 | - * ECI bits indicate which beats are already executed; | 41 | - */ |
60 | - * we handle this by effectively predicating them out. | 42 | - if (!(r->type & ARM_CP_OVERRIDE)) { |
61 | - */ | 43 | - const ARMCPRegInfo *oldreg = get_arm_cp_reginfo(cpu->cp_regs, key); |
62 | - int eci = env->condexec_bits >> 4; | 44 | - if (oldreg && !(oldreg->type & ARM_CP_OVERRIDE)) { |
63 | - switch (eci) { | 45 | - fprintf(stderr, "Register redefined: cp=%d %d bit " |
64 | - case ECI_NONE: | 46 | - "crn=%d crm=%d opc1=%d opc2=%d, " |
65 | - break; | 47 | - "was %s, now %s\n", r2->cp, 32 + 32 * is64, |
66 | - case ECI_A0: | 48 | - r2->crn, r2->crm, r2->opc1, r2->opc2, |
67 | - mask &= 0xfff0; | 49 | - oldreg->name, r2->name); |
68 | - break; | ||
69 | - case ECI_A0A1: | ||
70 | - mask &= 0xff00; | ||
71 | - break; | ||
72 | - case ECI_A0A1A2: | ||
73 | - case ECI_A0A1A2B0: | ||
74 | - mask &= 0xf000; | ||
75 | - break; | ||
76 | - default: | ||
77 | - g_assert_not_reached(); | 50 | - g_assert_not_reached(); |
78 | - } | 51 | - } |
79 | - } | 52 | - } |
80 | - | 53 | g_hash_table_insert(cpu->cp_regs, (gpointer)(uintptr_t)key, r2); |
81 | + /* | ||
82 | + * ECI bits indicate which beats are already executed; | ||
83 | + * we handle this by effectively predicating them out. | ||
84 | + */ | ||
85 | + mask &= mve_eci_mask(env); | ||
86 | return mask; | ||
87 | } | 54 | } |
88 | 55 | ||
89 | -- | 56 | -- |
90 | 2.20.1 | 57 | 2.25.1 |
91 | |||
92 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | We were not paying attention to the ECI state when advancing the VPT | ||
2 | state. Architecturally, VPT state advance happens for every beat | ||
3 | (see the pseudocode VPTAdvance()), so on every beat the 4 bits of | ||
4 | VPR.P0 corresponding to the current beat are inverted if required, | ||
5 | and at the end of beats 1 and 3 the VPR MASK fields are updated. | ||
6 | This means that if the ECI state says we should not be executing all | ||
7 | 4 beats then we need to skip some of the updating of the VPR that we | ||
8 | currently do in mve_advance_vpt(). | ||
9 | 1 | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | --- | ||
13 | target/arm/mve_helper.c | 24 +++++++++++++++++------- | ||
14 | 1 file changed, 17 insertions(+), 7 deletions(-) | ||
15 | |||
16 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/arm/mve_helper.c | ||
19 | +++ b/target/arm/mve_helper.c | ||
20 | @@ -XXX,XX +XXX,XX @@ static void mve_advance_vpt(CPUARMState *env) | ||
21 | /* Advance the VPT and ECI state if necessary */ | ||
22 | uint32_t vpr = env->v7m.vpr; | ||
23 | unsigned mask01, mask23; | ||
24 | + uint16_t inv_mask; | ||
25 | + uint16_t eci_mask = mve_eci_mask(env); | ||
26 | |||
27 | if ((env->condexec_bits & 0xf) == 0) { | ||
28 | env->condexec_bits = (env->condexec_bits == (ECI_A0A1A2B0 << 4)) ? | ||
29 | @@ -XXX,XX +XXX,XX @@ static void mve_advance_vpt(CPUARMState *env) | ||
30 | return; | ||
31 | } | ||
32 | |||
33 | + /* Invert P0 bits if needed, but only for beats we actually executed */ | ||
34 | mask01 = FIELD_EX32(vpr, V7M_VPR, MASK01); | ||
35 | mask23 = FIELD_EX32(vpr, V7M_VPR, MASK23); | ||
36 | - if (mask01 > 8) { | ||
37 | - /* high bit set, but not 0b1000: invert the relevant half of P0 */ | ||
38 | - vpr ^= 0xff; | ||
39 | + /* Start by assuming we invert all bits corresponding to executed beats */ | ||
40 | + inv_mask = eci_mask; | ||
41 | + if (mask01 <= 8) { | ||
42 | + /* MASK01 says don't invert low half of P0 */ | ||
43 | + inv_mask &= ~0xff; | ||
44 | } | ||
45 | - if (mask23 > 8) { | ||
46 | - /* high bit set, but not 0b1000: invert the relevant half of P0 */ | ||
47 | - vpr ^= 0xff00; | ||
48 | + if (mask23 <= 8) { | ||
49 | + /* MASK23 says don't invert high half of P0 */ | ||
50 | + inv_mask &= ~0xff00; | ||
51 | } | ||
52 | - vpr = FIELD_DP32(vpr, V7M_VPR, MASK01, mask01 << 1); | ||
53 | + vpr ^= inv_mask; | ||
54 | + /* Only update MASK01 if beat 1 executed */ | ||
55 | + if (eci_mask & 0xf0) { | ||
56 | + vpr = FIELD_DP32(vpr, V7M_VPR, MASK01, mask01 << 1); | ||
57 | + } | ||
58 | + /* Beat 3 always executes, so update MASK23 */ | ||
59 | vpr = FIELD_DP32(vpr, V7M_VPR, MASK23, mask23 << 1); | ||
60 | env->v7m.vpr = vpr; | ||
61 | } | ||
62 | -- | ||
63 | 2.20.1 | ||
64 | |||
65 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | For vector loads, predicated elements are zeroed, instead of | ||
2 | retaining their previous values (as happens for most data | ||
3 | processing operations). This means we need to distinguish | ||
4 | "beat not executed due to ECI" (don't touch destination | ||
5 | element) from "beat executed but predicated out" (zero | ||
6 | destination element). | ||
7 | 1 | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | --- | ||
11 | target/arm/mve_helper.c | 8 +++++--- | ||
12 | 1 file changed, 5 insertions(+), 3 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/mve_helper.c | ||
17 | +++ b/target/arm/mve_helper.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static void mve_advance_vpt(CPUARMState *env) | ||
19 | env->v7m.vpr = vpr; | ||
20 | } | ||
21 | |||
22 | - | ||
23 | +/* For loads, predicated lanes are zeroed instead of keeping their old values */ | ||
24 | #define DO_VLDR(OP, MSIZE, LDTYPE, ESIZE, TYPE) \ | ||
25 | void HELPER(mve_##OP)(CPUARMState *env, void *vd, uint32_t addr) \ | ||
26 | { \ | ||
27 | TYPE *d = vd; \ | ||
28 | uint16_t mask = mve_element_mask(env); \ | ||
29 | + uint16_t eci_mask = mve_eci_mask(env); \ | ||
30 | unsigned b, e; \ | ||
31 | /* \ | ||
32 | * R_SXTM allows the dest reg to become UNKNOWN for abandoned \ | ||
33 | @@ -XXX,XX +XXX,XX @@ static void mve_advance_vpt(CPUARMState *env) | ||
34 | * then take an exception. \ | ||
35 | */ \ | ||
36 | for (b = 0, e = 0; b < 16; b += ESIZE, e++) { \ | ||
37 | - if (mask & (1 << b)) { \ | ||
38 | - d[H##ESIZE(e)] = cpu_##LDTYPE##_data_ra(env, addr, GETPC()); \ | ||
39 | + if (eci_mask & (1 << b)) { \ | ||
40 | + d[H##ESIZE(e)] = (mask & (1 << b)) ? \ | ||
41 | + cpu_##LDTYPE##_data_ra(env, addr, GETPC()) : 0; \ | ||
42 | } \ | ||
43 | addr += MSIZE; \ | ||
44 | } \ | ||
45 | -- | ||
46 | 2.20.1 | ||
47 | |||
48 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE VMULL (polynomial) insn. Unlike Neon, this comes | ||
2 | in two flavours: 8x8->16 and a 16x16->32. Also unlike Neon, the | ||
3 | inputs are in either the low or the high half of each double-width | ||
4 | element. | ||
5 | 1 | ||
6 | The assembler for this insn indicates the size with "P8" or "P16", | ||
7 | encoded into bit 28 as size = 0 or 1. We choose to follow the | ||
8 | same encoding as VQDMULL and decode this into a->size as MO_16 | ||
9 | or MO_32 indicating the size of the result elements. This then | ||
10 | carries through to the helper function names where it then | ||
11 | matches up with the existing pmull_h() which does an 8x8->16 | ||
12 | operation and a new pmull_w() which does the 16x16->32. | ||
13 | |||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | --- | ||
17 | target/arm/helper-mve.h | 5 +++++ | ||
18 | target/arm/vec_internal.h | 11 +++++++++++ | ||
19 | target/arm/mve.decode | 14 ++++++++++---- | ||
20 | target/arm/mve_helper.c | 16 ++++++++++++++++ | ||
21 | target/arm/translate-mve.c | 28 ++++++++++++++++++++++++++++ | ||
22 | target/arm/vec_helper.c | 14 +++++++++++++- | ||
23 | 6 files changed, 83 insertions(+), 5 deletions(-) | ||
24 | |||
25 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/target/arm/helper-mve.h | ||
28 | +++ b/target/arm/helper-mve.h | ||
29 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vmulltub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
30 | DEF_HELPER_FLAGS_4(mve_vmulltuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
31 | DEF_HELPER_FLAGS_4(mve_vmulltuw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
32 | |||
33 | +DEF_HELPER_FLAGS_4(mve_vmullpbh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
34 | +DEF_HELPER_FLAGS_4(mve_vmullpth, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
35 | +DEF_HELPER_FLAGS_4(mve_vmullpbw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
36 | +DEF_HELPER_FLAGS_4(mve_vmullptw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
37 | + | ||
38 | DEF_HELPER_FLAGS_4(mve_vqdmulhb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
39 | DEF_HELPER_FLAGS_4(mve_vqdmulhh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
40 | DEF_HELPER_FLAGS_4(mve_vqdmulhw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
41 | diff --git a/target/arm/vec_internal.h b/target/arm/vec_internal.h | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/target/arm/vec_internal.h | ||
44 | +++ b/target/arm/vec_internal.h | ||
45 | @@ -XXX,XX +XXX,XX @@ int16_t do_sqrdmlah_h(int16_t, int16_t, int16_t, bool, bool, uint32_t *); | ||
46 | int32_t do_sqrdmlah_s(int32_t, int32_t, int32_t, bool, bool, uint32_t *); | ||
47 | int64_t do_sqrdmlah_d(int64_t, int64_t, int64_t, bool, bool); | ||
48 | |||
49 | +/* | ||
50 | + * 8 x 8 -> 16 vector polynomial multiply where the inputs are | ||
51 | + * in the low 8 bits of each 16-bit element | ||
52 | +*/ | ||
53 | +uint64_t pmull_h(uint64_t op1, uint64_t op2); | ||
54 | +/* | ||
55 | + * 16 x 16 -> 32 vector polynomial multiply where the inputs are | ||
56 | + * in the low 16 bits of each 32-bit element | ||
57 | + */ | ||
58 | +uint64_t pmull_w(uint64_t op1, uint64_t op2); | ||
59 | + | ||
60 | #endif /* TARGET_ARM_VEC_INTERNALS_H */ | ||
61 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
62 | index XXXXXXX..XXXXXXX 100644 | ||
63 | --- a/target/arm/mve.decode | ||
64 | +++ b/target/arm/mve.decode | ||
65 | @@ -XXX,XX +XXX,XX @@ VHADD_U 111 1 1111 0 . .. ... 0 ... 0 0000 . 1 . 0 ... 0 @2op | ||
66 | VHSUB_S 111 0 1111 0 . .. ... 0 ... 0 0010 . 1 . 0 ... 0 @2op | ||
67 | VHSUB_U 111 1 1111 0 . .. ... 0 ... 0 0010 . 1 . 0 ... 0 @2op | ||
68 | |||
69 | -VMULL_BS 111 0 1110 0 . .. ... 1 ... 0 1110 . 0 . 0 ... 0 @2op | ||
70 | -VMULL_BU 111 1 1110 0 . .. ... 1 ... 0 1110 . 0 . 0 ... 0 @2op | ||
71 | -VMULL_TS 111 0 1110 0 . .. ... 1 ... 1 1110 . 0 . 0 ... 0 @2op | ||
72 | -VMULL_TU 111 1 1110 0 . .. ... 1 ... 1 1110 . 0 . 0 ... 0 @2op | ||
73 | +{ | ||
74 | + VMULLP_B 111 . 1110 0 . 11 ... 1 ... 0 1110 . 0 . 0 ... 0 @2op_sz28 | ||
75 | + VMULL_BS 111 0 1110 0 . .. ... 1 ... 0 1110 . 0 . 0 ... 0 @2op | ||
76 | + VMULL_BU 111 1 1110 0 . .. ... 1 ... 0 1110 . 0 . 0 ... 0 @2op | ||
77 | +} | ||
78 | +{ | ||
79 | + VMULLP_T 111 . 1110 0 . 11 ... 1 ... 1 1110 . 0 . 0 ... 0 @2op_sz28 | ||
80 | + VMULL_TS 111 0 1110 0 . .. ... 1 ... 1 1110 . 0 . 0 ... 0 @2op | ||
81 | + VMULL_TU 111 1 1110 0 . .. ... 1 ... 1 1110 . 0 . 0 ... 0 @2op | ||
82 | +} | ||
83 | |||
84 | VQDMULH 1110 1111 0 . .. ... 0 ... 0 1011 . 1 . 0 ... 0 @2op | ||
85 | VQRDMULH 1111 1111 0 . .. ... 0 ... 0 1011 . 1 . 0 ... 0 @2op | ||
86 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
87 | index XXXXXXX..XXXXXXX 100644 | ||
88 | --- a/target/arm/mve_helper.c | ||
89 | +++ b/target/arm/mve_helper.c | ||
90 | @@ -XXX,XX +XXX,XX @@ DO_2OP_L(vmulltub, 1, 1, uint8_t, 2, uint16_t, DO_MUL) | ||
91 | DO_2OP_L(vmulltuh, 1, 2, uint16_t, 4, uint32_t, DO_MUL) | ||
92 | DO_2OP_L(vmulltuw, 1, 4, uint32_t, 8, uint64_t, DO_MUL) | ||
93 | |||
94 | +/* | ||
95 | + * Polynomial multiply. We can always do this generating 64 bits | ||
96 | + * of the result at a time, so we don't need to use DO_2OP_L. | ||
97 | + */ | ||
98 | +#define VMULLPH_MASK 0x00ff00ff00ff00ffULL | ||
99 | +#define VMULLPW_MASK 0x0000ffff0000ffffULL | ||
100 | +#define DO_VMULLPBH(N, M) pmull_h((N) & VMULLPH_MASK, (M) & VMULLPH_MASK) | ||
101 | +#define DO_VMULLPTH(N, M) DO_VMULLPBH((N) >> 8, (M) >> 8) | ||
102 | +#define DO_VMULLPBW(N, M) pmull_w((N) & VMULLPW_MASK, (M) & VMULLPW_MASK) | ||
103 | +#define DO_VMULLPTW(N, M) DO_VMULLPBW((N) >> 16, (M) >> 16) | ||
104 | + | ||
105 | +DO_2OP(vmullpbh, 8, uint64_t, DO_VMULLPBH) | ||
106 | +DO_2OP(vmullpth, 8, uint64_t, DO_VMULLPTH) | ||
107 | +DO_2OP(vmullpbw, 8, uint64_t, DO_VMULLPBW) | ||
108 | +DO_2OP(vmullptw, 8, uint64_t, DO_VMULLPTW) | ||
109 | + | ||
110 | /* | ||
111 | * Because the computation type is at least twice as large as required, | ||
112 | * these work for both signed and unsigned source types. | ||
113 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
114 | index XXXXXXX..XXXXXXX 100644 | ||
115 | --- a/target/arm/translate-mve.c | ||
116 | +++ b/target/arm/translate-mve.c | ||
117 | @@ -XXX,XX +XXX,XX @@ static bool trans_VQDMULLT(DisasContext *s, arg_2op *a) | ||
118 | return do_2op(s, a, fns[a->size]); | ||
119 | } | ||
120 | |||
121 | +static bool trans_VMULLP_B(DisasContext *s, arg_2op *a) | ||
122 | +{ | ||
123 | + /* | ||
124 | + * Note that a->size indicates the output size, ie VMULL.P8 | ||
125 | + * is the 8x8->16 operation and a->size is MO_16; VMULL.P16 | ||
126 | + * is the 16x16->32 operation and a->size is MO_32. | ||
127 | + */ | ||
128 | + static MVEGenTwoOpFn * const fns[] = { | ||
129 | + NULL, | ||
130 | + gen_helper_mve_vmullpbh, | ||
131 | + gen_helper_mve_vmullpbw, | ||
132 | + NULL, | ||
133 | + }; | ||
134 | + return do_2op(s, a, fns[a->size]); | ||
135 | +} | ||
136 | + | ||
137 | +static bool trans_VMULLP_T(DisasContext *s, arg_2op *a) | ||
138 | +{ | ||
139 | + /* a->size is as for trans_VMULLP_B */ | ||
140 | + static MVEGenTwoOpFn * const fns[] = { | ||
141 | + NULL, | ||
142 | + gen_helper_mve_vmullpth, | ||
143 | + gen_helper_mve_vmullptw, | ||
144 | + NULL, | ||
145 | + }; | ||
146 | + return do_2op(s, a, fns[a->size]); | ||
147 | +} | ||
148 | + | ||
149 | /* | ||
150 | * VADC and VSBC: these perform an add-with-carry or subtract-with-carry | ||
151 | * of the 32-bit elements in each lane of the input vectors, where the | ||
152 | diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c | ||
153 | index XXXXXXX..XXXXXXX 100644 | ||
154 | --- a/target/arm/vec_helper.c | ||
155 | +++ b/target/arm/vec_helper.c | ||
156 | @@ -XXX,XX +XXX,XX @@ static uint64_t expand_byte_to_half(uint64_t x) | ||
157 | | ((x & 0xff000000) << 24); | ||
158 | } | ||
159 | |||
160 | -static uint64_t pmull_h(uint64_t op1, uint64_t op2) | ||
161 | +uint64_t pmull_w(uint64_t op1, uint64_t op2) | ||
162 | { | ||
163 | uint64_t result = 0; | ||
164 | int i; | ||
165 | + for (i = 0; i < 16; ++i) { | ||
166 | + uint64_t mask = (op1 & 0x0000000100000001ull) * 0xffffffff; | ||
167 | + result ^= op2 & mask; | ||
168 | + op1 >>= 1; | ||
169 | + op2 <<= 1; | ||
170 | + } | ||
171 | + return result; | ||
172 | +} | ||
173 | |||
174 | +uint64_t pmull_h(uint64_t op1, uint64_t op2) | ||
175 | +{ | ||
176 | + uint64_t result = 0; | ||
177 | + int i; | ||
178 | for (i = 0; i < 8; ++i) { | ||
179 | uint64_t mask = (op1 & 0x0001000100010001ull) * 0xffff; | ||
180 | result ^= op2 & mask; | ||
181 | -- | ||
182 | 2.20.1 | ||
183 | |||
184 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Factor out the "generate code to update VPR.MASK01/MASK23" part of | ||
2 | trans_VPST(); we are going to want to reuse it for the VPT insns. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | target/arm/translate-mve.c | 31 +++++++++++++++++-------------- | ||
8 | 1 file changed, 17 insertions(+), 14 deletions(-) | ||
9 | |||
10 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/target/arm/translate-mve.c | ||
13 | +++ b/target/arm/translate-mve.c | ||
14 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRMLSLDAVH(DisasContext *s, arg_vmlaldav *a) | ||
15 | return do_long_dual_acc(s, a, fns[a->x]); | ||
16 | } | ||
17 | |||
18 | -static bool trans_VPST(DisasContext *s, arg_VPST *a) | ||
19 | +static void gen_vpst(DisasContext *s, uint32_t mask) | ||
20 | { | ||
21 | - TCGv_i32 vpr; | ||
22 | - | ||
23 | - /* mask == 0 is a "related encoding" */ | ||
24 | - if (!dc_isar_feature(aa32_mve, s) || !a->mask) { | ||
25 | - return false; | ||
26 | - } | ||
27 | - if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
28 | - return true; | ||
29 | - } | ||
30 | /* | ||
31 | * Set the VPR mask fields. We take advantage of MASK01 and MASK23 | ||
32 | * being adjacent fields in the register. | ||
33 | * | ||
34 | - * This insn is not predicated, but it is subject to beat-wise | ||
35 | + * Updating the masks is not predicated, but it is subject to beat-wise | ||
36 | * execution, and the mask is updated on the odd-numbered beats. | ||
37 | * So if PSR.ECI says we should skip beat 1, we mustn't update the | ||
38 | * 01 mask field. | ||
39 | */ | ||
40 | - vpr = load_cpu_field(v7m.vpr); | ||
41 | + TCGv_i32 vpr = load_cpu_field(v7m.vpr); | ||
42 | switch (s->eci) { | ||
43 | case ECI_NONE: | ||
44 | case ECI_A0: | ||
45 | /* Update both 01 and 23 fields */ | ||
46 | tcg_gen_deposit_i32(vpr, vpr, | ||
47 | - tcg_constant_i32(a->mask | (a->mask << 4)), | ||
48 | + tcg_constant_i32(mask | (mask << 4)), | ||
49 | R_V7M_VPR_MASK01_SHIFT, | ||
50 | R_V7M_VPR_MASK01_LENGTH + R_V7M_VPR_MASK23_LENGTH); | ||
51 | break; | ||
52 | @@ -XXX,XX +XXX,XX @@ static bool trans_VPST(DisasContext *s, arg_VPST *a) | ||
53 | case ECI_A0A1A2B0: | ||
54 | /* Update only the 23 mask field */ | ||
55 | tcg_gen_deposit_i32(vpr, vpr, | ||
56 | - tcg_constant_i32(a->mask), | ||
57 | + tcg_constant_i32(mask), | ||
58 | R_V7M_VPR_MASK23_SHIFT, R_V7M_VPR_MASK23_LENGTH); | ||
59 | break; | ||
60 | default: | ||
61 | g_assert_not_reached(); | ||
62 | } | ||
63 | store_cpu_field(vpr, v7m.vpr); | ||
64 | +} | ||
65 | + | ||
66 | +static bool trans_VPST(DisasContext *s, arg_VPST *a) | ||
67 | +{ | ||
68 | + /* mask == 0 is a "related encoding" */ | ||
69 | + if (!dc_isar_feature(aa32_mve, s) || !a->mask) { | ||
70 | + return false; | ||
71 | + } | ||
72 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
73 | + return true; | ||
74 | + } | ||
75 | + gen_vpst(s, a->mask); | ||
76 | mve_update_and_store_eci(s); | ||
77 | return true; | ||
78 | } | ||
79 | -- | ||
80 | 2.20.1 | ||
81 | |||
82 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE integer vector comparison instructions. These are | ||
2 | "VCMP (vector)" encodings T1, T2 and T3, and "VPT (vector)" encodings | ||
3 | T1, T2 and T3. | ||
4 | 1 | ||
5 | These insns compare corresponding elements in each vector, and update | ||
6 | the VPR.P0 predicate bits with the results of the comparison. VPT | ||
7 | also sets the VPR.MASK01 and VPR.MASK23 fields -- it is effectively | ||
8 | "VCMP then VPST". | ||
9 | |||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | --- | ||
13 | target/arm/helper-mve.h | 32 ++++++++++++++++++++++ | ||
14 | target/arm/mve.decode | 18 +++++++++++- | ||
15 | target/arm/mve_helper.c | 56 ++++++++++++++++++++++++++++++++++++++ | ||
16 | target/arm/translate-mve.c | 47 ++++++++++++++++++++++++++++++++ | ||
17 | 4 files changed, 152 insertions(+), 1 deletion(-) | ||
18 | |||
19 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/target/arm/helper-mve.h | ||
22 | +++ b/target/arm/helper-mve.h | ||
23 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_uqshl, TCG_CALL_NO_RWG, i32, env, i32, i32) | ||
24 | DEF_HELPER_FLAGS_3(mve_sqshl, TCG_CALL_NO_RWG, i32, env, i32, i32) | ||
25 | DEF_HELPER_FLAGS_3(mve_uqrshl, TCG_CALL_NO_RWG, i32, env, i32, i32) | ||
26 | DEF_HELPER_FLAGS_3(mve_sqrshr, TCG_CALL_NO_RWG, i32, env, i32, i32) | ||
27 | + | ||
28 | +DEF_HELPER_FLAGS_3(mve_vcmpeqb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
29 | +DEF_HELPER_FLAGS_3(mve_vcmpeqh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
30 | +DEF_HELPER_FLAGS_3(mve_vcmpeqw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
31 | + | ||
32 | +DEF_HELPER_FLAGS_3(mve_vcmpneb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
33 | +DEF_HELPER_FLAGS_3(mve_vcmpneh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
34 | +DEF_HELPER_FLAGS_3(mve_vcmpnew, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
35 | + | ||
36 | +DEF_HELPER_FLAGS_3(mve_vcmpcsb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
37 | +DEF_HELPER_FLAGS_3(mve_vcmpcsh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
38 | +DEF_HELPER_FLAGS_3(mve_vcmpcsw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
39 | + | ||
40 | +DEF_HELPER_FLAGS_3(mve_vcmphib, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
41 | +DEF_HELPER_FLAGS_3(mve_vcmphih, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
42 | +DEF_HELPER_FLAGS_3(mve_vcmphiw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
43 | + | ||
44 | +DEF_HELPER_FLAGS_3(mve_vcmpgeb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
45 | +DEF_HELPER_FLAGS_3(mve_vcmpgeh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
46 | +DEF_HELPER_FLAGS_3(mve_vcmpgew, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
47 | + | ||
48 | +DEF_HELPER_FLAGS_3(mve_vcmpltb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
49 | +DEF_HELPER_FLAGS_3(mve_vcmplth, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
50 | +DEF_HELPER_FLAGS_3(mve_vcmpltw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
51 | + | ||
52 | +DEF_HELPER_FLAGS_3(mve_vcmpgtb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
53 | +DEF_HELPER_FLAGS_3(mve_vcmpgth, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
54 | +DEF_HELPER_FLAGS_3(mve_vcmpgtw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
55 | + | ||
56 | +DEF_HELPER_FLAGS_3(mve_vcmpleb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
57 | +DEF_HELPER_FLAGS_3(mve_vcmpleh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
58 | +DEF_HELPER_FLAGS_3(mve_vcmplew, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
59 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
60 | index XXXXXXX..XXXXXXX 100644 | ||
61 | --- a/target/arm/mve.decode | ||
62 | +++ b/target/arm/mve.decode | ||
63 | @@ -XXX,XX +XXX,XX @@ | ||
64 | &2shift qd qm shift size | ||
65 | &vidup qd rn size imm | ||
66 | &viwdup qd rn rm size imm | ||
67 | +&vcmp qm qn size mask | ||
68 | |||
69 | @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 | ||
70 | # Note that both Rn and Qd are 3 bits only (no D bit) | ||
71 | @@ -XXX,XX +XXX,XX @@ | ||
72 | @2_shr_w .... .... .. 1 ..... .... .... .... .... &2shift qd=%qd qm=%qm \ | ||
73 | size=2 shift=%rshift_i5 | ||
74 | |||
75 | +# Vector comparison; 4-bit Qm but 3-bit Qn | ||
76 | +%mask_22_13 22:1 13:3 | ||
77 | +@vcmp .... .... .. size:2 qn:3 . .... .... .... .... &vcmp qm=%qm mask=%mask_22_13 | ||
78 | + | ||
79 | # Vector loads and stores | ||
80 | |||
81 | # Widening loads and narrowing stores: | ||
82 | @@ -XXX,XX +XXX,XX @@ VQRDMULH_scalar 1111 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
83 | } | ||
84 | |||
85 | # Predicate operations | ||
86 | -%mask_22_13 22:1 13:3 | ||
87 | VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13 | ||
88 | |||
89 | # Logical immediate operations (1 reg and modified-immediate) | ||
90 | @@ -XXX,XX +XXX,XX @@ VQRSHRUNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_b | ||
91 | VQRSHRUNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_h | ||
92 | |||
93 | VSHLC 111 0 1110 1 . 1 imm:5 ... 0 1111 1100 rdm:4 qd=%qd | ||
94 | + | ||
95 | +# Comparisons. We expand out the conditions which are split across | ||
96 | +# encodings T1, T2, T3 and the fc bits. These include VPT, which is | ||
97 | +# effectively "VCMP then VPST". A plain "VCMP" has a mask field of zero. | ||
98 | +VCMPEQ 1111 1110 0 . .. ... 1 ... 0 1111 0 0 . 0 ... 0 @vcmp | ||
99 | +VCMPNE 1111 1110 0 . .. ... 1 ... 0 1111 1 0 . 0 ... 0 @vcmp | ||
100 | +VCMPCS 1111 1110 0 . .. ... 1 ... 0 1111 0 0 . 0 ... 1 @vcmp | ||
101 | +VCMPHI 1111 1110 0 . .. ... 1 ... 0 1111 1 0 . 0 ... 1 @vcmp | ||
102 | +VCMPGE 1111 1110 0 . .. ... 1 ... 1 1111 0 0 . 0 ... 0 @vcmp | ||
103 | +VCMPLT 1111 1110 0 . .. ... 1 ... 1 1111 1 0 . 0 ... 0 @vcmp | ||
104 | +VCMPGT 1111 1110 0 . .. ... 1 ... 1 1111 0 0 . 0 ... 1 @vcmp | ||
105 | +VCMPLE 1111 1110 0 . .. ... 1 ... 1 1111 1 0 . 0 ... 1 @vcmp | ||
106 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
107 | index XXXXXXX..XXXXXXX 100644 | ||
108 | --- a/target/arm/mve_helper.c | ||
109 | +++ b/target/arm/mve_helper.c | ||
110 | @@ -XXX,XX +XXX,XX @@ static uint32_t do_sub_wrap(uint32_t offset, uint32_t wrap, uint32_t imm) | ||
111 | DO_VIDUP_ALL(vidup, DO_ADD) | ||
112 | DO_VIWDUP_ALL(viwdup, do_add_wrap) | ||
113 | DO_VIWDUP_ALL(vdwdup, do_sub_wrap) | ||
114 | + | ||
115 | +/* | ||
116 | + * Vector comparison. | ||
117 | + * P0 bits for non-executed beats (where eci_mask is 0) are unchanged. | ||
118 | + * P0 bits for predicated lanes in executed beats (where mask is 0) are 0. | ||
119 | + * P0 bits otherwise are updated with the results of the comparisons. | ||
120 | + * We must also keep unchanged the MASK fields at the top of v7m.vpr. | ||
121 | + */ | ||
122 | +#define DO_VCMP(OP, ESIZE, TYPE, FN) \ | ||
123 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vn, void *vm) \ | ||
124 | + { \ | ||
125 | + TYPE *n = vn, *m = vm; \ | ||
126 | + uint16_t mask = mve_element_mask(env); \ | ||
127 | + uint16_t eci_mask = mve_eci_mask(env); \ | ||
128 | + uint16_t beatpred = 0; \ | ||
129 | + uint16_t emask = MAKE_64BIT_MASK(0, ESIZE); \ | ||
130 | + unsigned e; \ | ||
131 | + for (e = 0; e < 16 / ESIZE; e++) { \ | ||
132 | + bool r = FN(n[H##ESIZE(e)], m[H##ESIZE(e)]); \ | ||
133 | + /* Comparison sets 0/1 bits for each byte in the element */ \ | ||
134 | + beatpred |= r * emask; \ | ||
135 | + emask <<= ESIZE; \ | ||
136 | + } \ | ||
137 | + beatpred &= mask; \ | ||
138 | + env->v7m.vpr = (env->v7m.vpr & ~(uint32_t)eci_mask) | \ | ||
139 | + (beatpred & eci_mask); \ | ||
140 | + mve_advance_vpt(env); \ | ||
141 | + } | ||
142 | + | ||
143 | +#define DO_VCMP_S(OP, FN) \ | ||
144 | + DO_VCMP(OP##b, 1, int8_t, FN) \ | ||
145 | + DO_VCMP(OP##h, 2, int16_t, FN) \ | ||
146 | + DO_VCMP(OP##w, 4, int32_t, FN) | ||
147 | + | ||
148 | +#define DO_VCMP_U(OP, FN) \ | ||
149 | + DO_VCMP(OP##b, 1, uint8_t, FN) \ | ||
150 | + DO_VCMP(OP##h, 2, uint16_t, FN) \ | ||
151 | + DO_VCMP(OP##w, 4, uint32_t, FN) | ||
152 | + | ||
153 | +#define DO_EQ(N, M) ((N) == (M)) | ||
154 | +#define DO_NE(N, M) ((N) != (M)) | ||
155 | +#define DO_EQ(N, M) ((N) == (M)) | ||
156 | +#define DO_EQ(N, M) ((N) == (M)) | ||
157 | +#define DO_GE(N, M) ((N) >= (M)) | ||
158 | +#define DO_LT(N, M) ((N) < (M)) | ||
159 | +#define DO_GT(N, M) ((N) > (M)) | ||
160 | +#define DO_LE(N, M) ((N) <= (M)) | ||
161 | + | ||
162 | +DO_VCMP_U(vcmpeq, DO_EQ) | ||
163 | +DO_VCMP_U(vcmpne, DO_NE) | ||
164 | +DO_VCMP_U(vcmpcs, DO_GE) | ||
165 | +DO_VCMP_U(vcmphi, DO_GT) | ||
166 | +DO_VCMP_S(vcmpge, DO_GE) | ||
167 | +DO_VCMP_S(vcmplt, DO_LT) | ||
168 | +DO_VCMP_S(vcmpgt, DO_GT) | ||
169 | +DO_VCMP_S(vcmple, DO_LE) | ||
170 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
171 | index XXXXXXX..XXXXXXX 100644 | ||
172 | --- a/target/arm/translate-mve.c | ||
173 | +++ b/target/arm/translate-mve.c | ||
174 | @@ -XXX,XX +XXX,XX @@ typedef void MVEGenVADDVFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
175 | typedef void MVEGenOneOpImmFn(TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
176 | typedef void MVEGenVIDUPFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32, TCGv_i32); | ||
177 | typedef void MVEGenVIWDUPFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32, TCGv_i32, TCGv_i32); | ||
178 | +typedef void MVEGenCmpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
179 | |||
180 | /* Return the offset of a Qn register (same semantics as aa32_vfp_qreg()) */ | ||
181 | static inline long mve_qreg_offset(unsigned reg) | ||
182 | @@ -XXX,XX +XXX,XX @@ static bool trans_VDWDUP(DisasContext *s, arg_viwdup *a) | ||
183 | }; | ||
184 | return do_viwdup(s, a, fns[a->size]); | ||
185 | } | ||
186 | + | ||
187 | +static bool do_vcmp(DisasContext *s, arg_vcmp *a, MVEGenCmpFn *fn) | ||
188 | +{ | ||
189 | + TCGv_ptr qn, qm; | ||
190 | + | ||
191 | + if (!dc_isar_feature(aa32_mve, s) || !mve_check_qreg_bank(s, a->qm) || | ||
192 | + !fn) { | ||
193 | + return false; | ||
194 | + } | ||
195 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
196 | + return true; | ||
197 | + } | ||
198 | + | ||
199 | + qn = mve_qreg_ptr(a->qn); | ||
200 | + qm = mve_qreg_ptr(a->qm); | ||
201 | + fn(cpu_env, qn, qm); | ||
202 | + tcg_temp_free_ptr(qn); | ||
203 | + tcg_temp_free_ptr(qm); | ||
204 | + if (a->mask) { | ||
205 | + /* VPT */ | ||
206 | + gen_vpst(s, a->mask); | ||
207 | + } | ||
208 | + mve_update_eci(s); | ||
209 | + return true; | ||
210 | +} | ||
211 | + | ||
212 | +#define DO_VCMP(INSN, FN) \ | ||
213 | + static bool trans_##INSN(DisasContext *s, arg_vcmp *a) \ | ||
214 | + { \ | ||
215 | + static MVEGenCmpFn * const fns[] = { \ | ||
216 | + gen_helper_mve_##FN##b, \ | ||
217 | + gen_helper_mve_##FN##h, \ | ||
218 | + gen_helper_mve_##FN##w, \ | ||
219 | + NULL, \ | ||
220 | + }; \ | ||
221 | + return do_vcmp(s, a, fns[a->size]); \ | ||
222 | + } | ||
223 | + | ||
224 | +DO_VCMP(VCMPEQ, vcmpeq) | ||
225 | +DO_VCMP(VCMPNE, vcmpne) | ||
226 | +DO_VCMP(VCMPCS, vcmpcs) | ||
227 | +DO_VCMP(VCMPHI, vcmphi) | ||
228 | +DO_VCMP(VCMPGE, vcmpge) | ||
229 | +DO_VCMP(VCMPLT, vcmplt) | ||
230 | +DO_VCMP(VCMPGT, vcmpgt) | ||
231 | +DO_VCMP(VCMPLE, vcmple) | ||
232 | -- | ||
233 | 2.20.1 | ||
234 | |||
235 | diff view generated by jsdifflib |
1 | Implement the MVE integer vector comparison instructions that compare | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | each element against a scalar from a general purpose register. These | ||
3 | are "VCMP (vector)" encodings T4, T5 and T6 and "VPT (vector)" | ||
4 | encodings T4, T5 and T6. | ||
5 | 2 | ||
6 | We have to move the decodetree pattern for VPST, because it | 3 | Put the block comments into the current coding style. |
7 | overlaps with VCMP T4 with size = 0b11. | ||
8 | 4 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Message-id: 20220501055028.646596-19-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | --- | 9 | --- |
12 | target/arm/helper-mve.h | 32 +++++++++++++++++++++++++++ | 10 | target/arm/helper.c | 24 +++++++++++++++--------- |
13 | target/arm/mve.decode | 18 +++++++++++++--- | 11 | 1 file changed, 15 insertions(+), 9 deletions(-) |
14 | target/arm/mve_helper.c | 44 +++++++++++++++++++++++++++++++------- | ||
15 | target/arm/translate-mve.c | 43 +++++++++++++++++++++++++++++++++++++ | ||
16 | 4 files changed, 126 insertions(+), 11 deletions(-) | ||
17 | 12 | ||
18 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 13 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
19 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/helper-mve.h | 15 | --- a/target/arm/helper.c |
21 | +++ b/target/arm/helper-mve.h | 16 | +++ b/target/arm/helper.c |
22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vcmpgtw, TCG_CALL_NO_WG, void, env, ptr, ptr) | 17 | @@ -XXX,XX +XXX,XX @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) |
23 | DEF_HELPER_FLAGS_3(mve_vcmpleb, TCG_CALL_NO_WG, void, env, ptr, ptr) | 18 | return cpu_list; |
24 | DEF_HELPER_FLAGS_3(mve_vcmpleh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
25 | DEF_HELPER_FLAGS_3(mve_vcmplew, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
26 | + | ||
27 | +DEF_HELPER_FLAGS_3(mve_vcmpeq_scalarb, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
28 | +DEF_HELPER_FLAGS_3(mve_vcmpeq_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
29 | +DEF_HELPER_FLAGS_3(mve_vcmpeq_scalarw, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
30 | + | ||
31 | +DEF_HELPER_FLAGS_3(mve_vcmpne_scalarb, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
32 | +DEF_HELPER_FLAGS_3(mve_vcmpne_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
33 | +DEF_HELPER_FLAGS_3(mve_vcmpne_scalarw, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
34 | + | ||
35 | +DEF_HELPER_FLAGS_3(mve_vcmpcs_scalarb, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
36 | +DEF_HELPER_FLAGS_3(mve_vcmpcs_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
37 | +DEF_HELPER_FLAGS_3(mve_vcmpcs_scalarw, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
38 | + | ||
39 | +DEF_HELPER_FLAGS_3(mve_vcmphi_scalarb, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
40 | +DEF_HELPER_FLAGS_3(mve_vcmphi_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
41 | +DEF_HELPER_FLAGS_3(mve_vcmphi_scalarw, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
42 | + | ||
43 | +DEF_HELPER_FLAGS_3(mve_vcmpge_scalarb, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
44 | +DEF_HELPER_FLAGS_3(mve_vcmpge_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
45 | +DEF_HELPER_FLAGS_3(mve_vcmpge_scalarw, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
46 | + | ||
47 | +DEF_HELPER_FLAGS_3(mve_vcmplt_scalarb, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
48 | +DEF_HELPER_FLAGS_3(mve_vcmplt_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
49 | +DEF_HELPER_FLAGS_3(mve_vcmplt_scalarw, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
50 | + | ||
51 | +DEF_HELPER_FLAGS_3(mve_vcmpgt_scalarb, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
52 | +DEF_HELPER_FLAGS_3(mve_vcmpgt_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
53 | +DEF_HELPER_FLAGS_3(mve_vcmpgt_scalarw, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
54 | + | ||
55 | +DEF_HELPER_FLAGS_3(mve_vcmple_scalarb, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
56 | +DEF_HELPER_FLAGS_3(mve_vcmple_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
57 | +DEF_HELPER_FLAGS_3(mve_vcmple_scalarw, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
58 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
59 | index XXXXXXX..XXXXXXX 100644 | ||
60 | --- a/target/arm/mve.decode | ||
61 | +++ b/target/arm/mve.decode | ||
62 | @@ -XXX,XX +XXX,XX @@ | ||
63 | &vidup qd rn size imm | ||
64 | &viwdup qd rn rm size imm | ||
65 | &vcmp qm qn size mask | ||
66 | +&vcmp_scalar qn rm size mask | ||
67 | |||
68 | @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 | ||
69 | # Note that both Rn and Qd are 3 bits only (no D bit) | ||
70 | @@ -XXX,XX +XXX,XX @@ | ||
71 | # Vector comparison; 4-bit Qm but 3-bit Qn | ||
72 | %mask_22_13 22:1 13:3 | ||
73 | @vcmp .... .... .. size:2 qn:3 . .... .... .... .... &vcmp qm=%qm mask=%mask_22_13 | ||
74 | +@vcmp_scalar .... .... .. size:2 qn:3 . .... .... .... rm:4 &vcmp_scalar \ | ||
75 | + mask=%mask_22_13 | ||
76 | |||
77 | # Vector loads and stores | ||
78 | |||
79 | @@ -XXX,XX +XXX,XX @@ VQRDMULH_scalar 1111 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
80 | rdahi=%rdahi rdalo=%rdalo | ||
81 | } | 19 | } |
82 | 20 | ||
83 | -# Predicate operations | 21 | +/* |
84 | -VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13 | 22 | + * Private utility function for define_one_arm_cp_reg_with_opaque(): |
85 | - | 23 | + * add a single reginfo struct to the hash table. |
86 | # Logical immediate operations (1 reg and modified-immediate) | 24 | + */ |
87 | 25 | static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | |
88 | # The cmode/op bits here decode VORR/VBIC/VMOV/VMVN, but | 26 | void *opaque, CPState state, |
89 | @@ -XXX,XX +XXX,XX @@ VCMPGE 1111 1110 0 . .. ... 1 ... 1 1111 0 0 . 0 ... 0 @vcmp | 27 | CPSecureState secstate, |
90 | VCMPLT 1111 1110 0 . .. ... 1 ... 1 1111 1 0 . 0 ... 0 @vcmp | 28 | int crm, int opc1, int opc2, |
91 | VCMPGT 1111 1110 0 . .. ... 1 ... 1 1111 0 0 . 0 ... 1 @vcmp | 29 | const char *name) |
92 | VCMPLE 1111 1110 0 . .. ... 1 ... 1 1111 1 0 . 0 ... 1 @vcmp | 30 | { |
93 | + | 31 | - /* Private utility function for define_one_arm_cp_reg_with_opaque(): |
94 | +{ | 32 | - * add a single reginfo struct to the hash table. |
95 | + VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13 | 33 | - */ |
96 | + VCMPEQ_scalar 1111 1110 0 . .. ... 1 ... 0 1111 0 1 0 0 .... @vcmp_scalar | 34 | uint32_t key; |
97 | +} | 35 | ARMCPRegInfo *r2; |
98 | +VCMPNE_scalar 1111 1110 0 . .. ... 1 ... 0 1111 1 1 0 0 .... @vcmp_scalar | 36 | bool is64 = r->type & ARM_CP_64BIT; |
99 | +VCMPCS_scalar 1111 1110 0 . .. ... 1 ... 0 1111 0 1 1 0 .... @vcmp_scalar | 37 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
100 | +VCMPHI_scalar 1111 1110 0 . .. ... 1 ... 0 1111 1 1 1 0 .... @vcmp_scalar | 38 | |
101 | +VCMPGE_scalar 1111 1110 0 . .. ... 1 ... 1 1111 0 1 0 0 .... @vcmp_scalar | 39 | isbanked = r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1]; |
102 | +VCMPLT_scalar 1111 1110 0 . .. ... 1 ... 1 1111 1 1 0 0 .... @vcmp_scalar | 40 | if (isbanked) { |
103 | +VCMPGT_scalar 1111 1110 0 . .. ... 1 ... 1 1111 0 1 1 0 .... @vcmp_scalar | 41 | - /* Register is banked (using both entries in array). |
104 | +VCMPLE_scalar 1111 1110 0 . .. ... 1 ... 1 1111 1 1 1 0 .... @vcmp_scalar | 42 | + /* |
105 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | 43 | + * Register is banked (using both entries in array). |
106 | index XXXXXXX..XXXXXXX 100644 | 44 | * Overwriting fieldoffset as the array is only used to define |
107 | --- a/target/arm/mve_helper.c | 45 | * banked registers but later only fieldoffset is used. |
108 | +++ b/target/arm/mve_helper.c | 46 | */ |
109 | @@ -XXX,XX +XXX,XX @@ DO_VIWDUP_ALL(vdwdup, do_sub_wrap) | 47 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
110 | mve_advance_vpt(env); \ | 48 | |
49 | if (state == ARM_CP_STATE_AA32) { | ||
50 | if (isbanked) { | ||
51 | - /* If the register is banked then we don't need to migrate or | ||
52 | + /* | ||
53 | + * If the register is banked then we don't need to migrate or | ||
54 | * reset the 32-bit instance in certain cases: | ||
55 | * | ||
56 | * 1) If the register has both 32-bit and 64-bit instances then we | ||
57 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
58 | r2->type |= ARM_CP_ALIAS; | ||
59 | } | ||
60 | } else if ((secstate != r->secure) && !ns) { | ||
61 | - /* The register is not banked so we only want to allow migration of | ||
62 | - * the non-secure instance. | ||
63 | + /* | ||
64 | + * The register is not banked so we only want to allow migration | ||
65 | + * of the non-secure instance. | ||
66 | */ | ||
67 | r2->type |= ARM_CP_ALIAS; | ||
68 | } | ||
69 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
70 | } | ||
111 | } | 71 | } |
112 | 72 | ||
113 | -#define DO_VCMP_S(OP, FN) \ | 73 | - /* By convention, for wildcarded registers only the first |
114 | - DO_VCMP(OP##b, 1, int8_t, FN) \ | 74 | + /* |
115 | - DO_VCMP(OP##h, 2, int16_t, FN) \ | 75 | + * By convention, for wildcarded registers only the first |
116 | - DO_VCMP(OP##w, 4, int32_t, FN) | 76 | * entry is used for migration; the others are marked as |
117 | +#define DO_VCMP_SCALAR(OP, ESIZE, TYPE, FN) \ | 77 | * ALIAS so we don't try to transfer the register |
118 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vn, \ | 78 | * multiple times. Special registers (ie NOP/WFI) are |
119 | + uint32_t rm) \ | 79 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
120 | + { \ | 80 | r2->type |= ARM_CP_ALIAS | ARM_CP_NO_GDB; |
121 | + TYPE *n = vn; \ | ||
122 | + uint16_t mask = mve_element_mask(env); \ | ||
123 | + uint16_t eci_mask = mve_eci_mask(env); \ | ||
124 | + uint16_t beatpred = 0; \ | ||
125 | + uint16_t emask = MAKE_64BIT_MASK(0, ESIZE); \ | ||
126 | + unsigned e; \ | ||
127 | + for (e = 0; e < 16 / ESIZE; e++) { \ | ||
128 | + bool r = FN(n[H##ESIZE(e)], (TYPE)rm); \ | ||
129 | + /* Comparison sets 0/1 bits for each byte in the element */ \ | ||
130 | + beatpred |= r * emask; \ | ||
131 | + emask <<= ESIZE; \ | ||
132 | + } \ | ||
133 | + beatpred &= mask; \ | ||
134 | + env->v7m.vpr = (env->v7m.vpr & ~(uint32_t)eci_mask) | \ | ||
135 | + (beatpred & eci_mask); \ | ||
136 | + mve_advance_vpt(env); \ | ||
137 | + } | ||
138 | |||
139 | -#define DO_VCMP_U(OP, FN) \ | ||
140 | - DO_VCMP(OP##b, 1, uint8_t, FN) \ | ||
141 | - DO_VCMP(OP##h, 2, uint16_t, FN) \ | ||
142 | - DO_VCMP(OP##w, 4, uint32_t, FN) | ||
143 | +#define DO_VCMP_S(OP, FN) \ | ||
144 | + DO_VCMP(OP##b, 1, int8_t, FN) \ | ||
145 | + DO_VCMP(OP##h, 2, int16_t, FN) \ | ||
146 | + DO_VCMP(OP##w, 4, int32_t, FN) \ | ||
147 | + DO_VCMP_SCALAR(OP##_scalarb, 1, int8_t, FN) \ | ||
148 | + DO_VCMP_SCALAR(OP##_scalarh, 2, int16_t, FN) \ | ||
149 | + DO_VCMP_SCALAR(OP##_scalarw, 4, int32_t, FN) | ||
150 | + | ||
151 | +#define DO_VCMP_U(OP, FN) \ | ||
152 | + DO_VCMP(OP##b, 1, uint8_t, FN) \ | ||
153 | + DO_VCMP(OP##h, 2, uint16_t, FN) \ | ||
154 | + DO_VCMP(OP##w, 4, uint32_t, FN) \ | ||
155 | + DO_VCMP_SCALAR(OP##_scalarb, 1, uint8_t, FN) \ | ||
156 | + DO_VCMP_SCALAR(OP##_scalarh, 2, uint16_t, FN) \ | ||
157 | + DO_VCMP_SCALAR(OP##_scalarw, 4, uint32_t, FN) | ||
158 | |||
159 | #define DO_EQ(N, M) ((N) == (M)) | ||
160 | #define DO_NE(N, M) ((N) != (M)) | ||
161 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
162 | index XXXXXXX..XXXXXXX 100644 | ||
163 | --- a/target/arm/translate-mve.c | ||
164 | +++ b/target/arm/translate-mve.c | ||
165 | @@ -XXX,XX +XXX,XX @@ typedef void MVEGenOneOpImmFn(TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
166 | typedef void MVEGenVIDUPFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32, TCGv_i32); | ||
167 | typedef void MVEGenVIWDUPFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32, TCGv_i32, TCGv_i32); | ||
168 | typedef void MVEGenCmpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
169 | +typedef void MVEGenScalarCmpFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
170 | |||
171 | /* Return the offset of a Qn register (same semantics as aa32_vfp_qreg()) */ | ||
172 | static inline long mve_qreg_offset(unsigned reg) | ||
173 | @@ -XXX,XX +XXX,XX @@ static bool do_vcmp(DisasContext *s, arg_vcmp *a, MVEGenCmpFn *fn) | ||
174 | return true; | ||
175 | } | ||
176 | |||
177 | +static bool do_vcmp_scalar(DisasContext *s, arg_vcmp_scalar *a, | ||
178 | + MVEGenScalarCmpFn *fn) | ||
179 | +{ | ||
180 | + TCGv_ptr qn; | ||
181 | + TCGv_i32 rm; | ||
182 | + | ||
183 | + if (!dc_isar_feature(aa32_mve, s) || !fn || a->rm == 13) { | ||
184 | + return false; | ||
185 | + } | ||
186 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
187 | + return true; | ||
188 | + } | ||
189 | + | ||
190 | + qn = mve_qreg_ptr(a->qn); | ||
191 | + if (a->rm == 15) { | ||
192 | + /* Encoding Rm=0b1111 means "constant zero" */ | ||
193 | + rm = tcg_constant_i32(0); | ||
194 | + } else { | ||
195 | + rm = load_reg(s, a->rm); | ||
196 | + } | ||
197 | + fn(cpu_env, qn, rm); | ||
198 | + tcg_temp_free_ptr(qn); | ||
199 | + tcg_temp_free_i32(rm); | ||
200 | + if (a->mask) { | ||
201 | + /* VPT */ | ||
202 | + gen_vpst(s, a->mask); | ||
203 | + } | ||
204 | + mve_update_eci(s); | ||
205 | + return true; | ||
206 | +} | ||
207 | + | ||
208 | #define DO_VCMP(INSN, FN) \ | ||
209 | static bool trans_##INSN(DisasContext *s, arg_vcmp *a) \ | ||
210 | { \ | ||
211 | @@ -XXX,XX +XXX,XX @@ static bool do_vcmp(DisasContext *s, arg_vcmp *a, MVEGenCmpFn *fn) | ||
212 | NULL, \ | ||
213 | }; \ | ||
214 | return do_vcmp(s, a, fns[a->size]); \ | ||
215 | + } \ | ||
216 | + static bool trans_##INSN##_scalar(DisasContext *s, \ | ||
217 | + arg_vcmp_scalar *a) \ | ||
218 | + { \ | ||
219 | + static MVEGenScalarCmpFn * const fns[] = { \ | ||
220 | + gen_helper_mve_##FN##_scalarb, \ | ||
221 | + gen_helper_mve_##FN##_scalarh, \ | ||
222 | + gen_helper_mve_##FN##_scalarw, \ | ||
223 | + NULL, \ | ||
224 | + }; \ | ||
225 | + return do_vcmp_scalar(s, a, fns[a->size]); \ | ||
226 | } | 81 | } |
227 | 82 | ||
228 | DO_VCMP(VCMPEQ, vcmpeq) | 83 | - /* Check that raw accesses are either forbidden or handled. Note that |
84 | + /* | ||
85 | + * Check that raw accesses are either forbidden or handled. Note that | ||
86 | * we can't assert this earlier because the setup of fieldoffset for | ||
87 | * banked registers has to be done first. | ||
88 | */ | ||
229 | -- | 89 | -- |
230 | 2.20.1 | 90 | 2.25.1 |
231 | |||
232 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE VPSEL insn, which sets each byte of the destination | ||
2 | vector Qd to the byte from either Qn or Qm depending on the value of | ||
3 | the corresponding bit in VPR.P0. | ||
4 | 1 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | --- | ||
8 | target/arm/helper-mve.h | 2 ++ | ||
9 | target/arm/mve.decode | 7 +++++-- | ||
10 | target/arm/mve_helper.c | 19 +++++++++++++++++++ | ||
11 | target/arm/translate-mve.c | 2 ++ | ||
12 | 4 files changed, 28 insertions(+), 2 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/helper-mve.h | ||
17 | +++ b/target/arm/helper-mve.h | ||
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vorr, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
19 | DEF_HELPER_FLAGS_4(mve_vorn, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
20 | DEF_HELPER_FLAGS_4(mve_veor, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
21 | |||
22 | +DEF_HELPER_FLAGS_4(mve_vpsel, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
23 | + | ||
24 | DEF_HELPER_FLAGS_4(mve_vaddb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
25 | DEF_HELPER_FLAGS_4(mve_vaddh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
26 | DEF_HELPER_FLAGS_4(mve_vaddw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
27 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/target/arm/mve.decode | ||
30 | +++ b/target/arm/mve.decode | ||
31 | @@ -XXX,XX +XXX,XX @@ VSHLC 111 0 1110 1 . 1 imm:5 ... 0 1111 1100 rdm:4 qd=%qd | ||
32 | # effectively "VCMP then VPST". A plain "VCMP" has a mask field of zero. | ||
33 | VCMPEQ 1111 1110 0 . .. ... 1 ... 0 1111 0 0 . 0 ... 0 @vcmp | ||
34 | VCMPNE 1111 1110 0 . .. ... 1 ... 0 1111 1 0 . 0 ... 0 @vcmp | ||
35 | -VCMPCS 1111 1110 0 . .. ... 1 ... 0 1111 0 0 . 0 ... 1 @vcmp | ||
36 | -VCMPHI 1111 1110 0 . .. ... 1 ... 0 1111 1 0 . 0 ... 1 @vcmp | ||
37 | +{ | ||
38 | + VPSEL 1111 1110 0 . 11 ... 1 ... 0 1111 . 0 . 0 ... 1 @2op_nosz | ||
39 | + VCMPCS 1111 1110 0 . .. ... 1 ... 0 1111 0 0 . 0 ... 1 @vcmp | ||
40 | + VCMPHI 1111 1110 0 . .. ... 1 ... 0 1111 1 0 . 0 ... 1 @vcmp | ||
41 | +} | ||
42 | VCMPGE 1111 1110 0 . .. ... 1 ... 1 1111 0 0 . 0 ... 0 @vcmp | ||
43 | VCMPLT 1111 1110 0 . .. ... 1 ... 1 1111 1 0 . 0 ... 0 @vcmp | ||
44 | VCMPGT 1111 1110 0 . .. ... 1 ... 1 1111 0 0 . 0 ... 1 @vcmp | ||
45 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/target/arm/mve_helper.c | ||
48 | +++ b/target/arm/mve_helper.c | ||
49 | @@ -XXX,XX +XXX,XX @@ DO_VCMP_S(vcmpge, DO_GE) | ||
50 | DO_VCMP_S(vcmplt, DO_LT) | ||
51 | DO_VCMP_S(vcmpgt, DO_GT) | ||
52 | DO_VCMP_S(vcmple, DO_LE) | ||
53 | + | ||
54 | +void HELPER(mve_vpsel)(CPUARMState *env, void *vd, void *vn, void *vm) | ||
55 | +{ | ||
56 | + /* | ||
57 | + * Qd[n] = VPR.P0[n] ? Qn[n] : Qm[n] | ||
58 | + * but note that whether bytes are written to Qd is still subject | ||
59 | + * to (all forms of) predication in the usual way. | ||
60 | + */ | ||
61 | + uint64_t *d = vd, *n = vn, *m = vm; | ||
62 | + uint16_t mask = mve_element_mask(env); | ||
63 | + uint16_t p0 = FIELD_EX32(env->v7m.vpr, V7M_VPR, P0); | ||
64 | + unsigned e; | ||
65 | + for (e = 0; e < 16 / 8; e++, mask >>= 8, p0 >>= 8) { | ||
66 | + uint64_t r = m[H8(e)]; | ||
67 | + mergemask(&r, n[H8(e)], p0); | ||
68 | + mergemask(&d[H8(e)], r, mask); | ||
69 | + } | ||
70 | + mve_advance_vpt(env); | ||
71 | +} | ||
72 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
73 | index XXXXXXX..XXXXXXX 100644 | ||
74 | --- a/target/arm/translate-mve.c | ||
75 | +++ b/target/arm/translate-mve.c | ||
76 | @@ -XXX,XX +XXX,XX @@ DO_LOGIC(VORR, gen_helper_mve_vorr) | ||
77 | DO_LOGIC(VORN, gen_helper_mve_vorn) | ||
78 | DO_LOGIC(VEOR, gen_helper_mve_veor) | ||
79 | |||
80 | +DO_LOGIC(VPSEL, gen_helper_mve_vpsel) | ||
81 | + | ||
82 | #define DO_2OP(INSN, FN) \ | ||
83 | static bool trans_##INSN(DisasContext *s, arg_2op *a) \ | ||
84 | { \ | ||
85 | -- | ||
86 | 2.20.1 | ||
87 | |||
88 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE VMLAS insn, which multiplies a vector by a vector | ||
2 | and adds a scalar. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | target/arm/helper-mve.h | 4 ++++ | ||
8 | target/arm/mve.decode | 3 +++ | ||
9 | target/arm/mve_helper.c | 26 ++++++++++++++++++++++++++ | ||
10 | target/arm/translate-mve.c | 1 + | ||
11 | 4 files changed, 34 insertions(+) | ||
12 | |||
13 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/helper-mve.h | ||
16 | +++ b/target/arm/helper-mve.h | ||
17 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqdmullb_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i3 | ||
18 | DEF_HELPER_FLAGS_4(mve_vqdmullt_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
19 | DEF_HELPER_FLAGS_4(mve_vqdmullt_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
20 | |||
21 | +DEF_HELPER_FLAGS_4(mve_vmlasb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
22 | +DEF_HELPER_FLAGS_4(mve_vmlash, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
23 | +DEF_HELPER_FLAGS_4(mve_vmlasw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
24 | + | ||
25 | DEF_HELPER_FLAGS_4(mve_vmlaldavsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
26 | DEF_HELPER_FLAGS_4(mve_vmlaldavsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
27 | DEF_HELPER_FLAGS_4(mve_vmlaldavxsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
28 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/target/arm/mve.decode | ||
31 | +++ b/target/arm/mve.decode | ||
32 | @@ -XXX,XX +XXX,XX @@ VBRSR 1111 1110 0 . .. ... 1 ... 1 1110 . 110 .... @2scalar | ||
33 | VQDMULH_scalar 1110 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
34 | VQRDMULH_scalar 1111 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
35 | |||
36 | +# The U bit (28) is don't-care because it does not affect the result | ||
37 | +VMLAS 111- 1110 0 . .. ... 1 ... 1 1110 . 100 .... @2scalar | ||
38 | + | ||
39 | # Vector add across vector | ||
40 | { | ||
41 | VADDV 111 u:1 1110 1111 size:2 01 ... 0 1111 0 0 a:1 0 qm:3 0 rda=%rdalo | ||
42 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/target/arm/mve_helper.c | ||
45 | +++ b/target/arm/mve_helper.c | ||
46 | @@ -XXX,XX +XXX,XX @@ DO_VQDMLADH_OP(vqrdmlsdhxw, 4, int32_t, 1, 1, do_vqdmlsdh_w) | ||
47 | mve_advance_vpt(env); \ | ||
48 | } | ||
49 | |||
50 | +/* "accumulating" version where FN takes d as well as n and m */ | ||
51 | +#define DO_2OP_ACC_SCALAR(OP, ESIZE, TYPE, FN) \ | ||
52 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, \ | ||
53 | + uint32_t rm) \ | ||
54 | + { \ | ||
55 | + TYPE *d = vd, *n = vn; \ | ||
56 | + TYPE m = rm; \ | ||
57 | + uint16_t mask = mve_element_mask(env); \ | ||
58 | + unsigned e; \ | ||
59 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
60 | + mergemask(&d[H##ESIZE(e)], \ | ||
61 | + FN(d[H##ESIZE(e)], n[H##ESIZE(e)], m), mask); \ | ||
62 | + } \ | ||
63 | + mve_advance_vpt(env); \ | ||
64 | + } | ||
65 | + | ||
66 | /* provide unsigned 2-op scalar helpers for all sizes */ | ||
67 | #define DO_2OP_SCALAR_U(OP, FN) \ | ||
68 | DO_2OP_SCALAR(OP##b, 1, uint8_t, FN) \ | ||
69 | @@ -XXX,XX +XXX,XX @@ DO_VQDMLADH_OP(vqrdmlsdhxw, 4, int32_t, 1, 1, do_vqdmlsdh_w) | ||
70 | DO_2OP_SCALAR(OP##h, 2, int16_t, FN) \ | ||
71 | DO_2OP_SCALAR(OP##w, 4, int32_t, FN) | ||
72 | |||
73 | +#define DO_2OP_ACC_SCALAR_U(OP, FN) \ | ||
74 | + DO_2OP_ACC_SCALAR(OP##b, 1, uint8_t, FN) \ | ||
75 | + DO_2OP_ACC_SCALAR(OP##h, 2, uint16_t, FN) \ | ||
76 | + DO_2OP_ACC_SCALAR(OP##w, 4, uint32_t, FN) | ||
77 | + | ||
78 | DO_2OP_SCALAR_U(vadd_scalar, DO_ADD) | ||
79 | DO_2OP_SCALAR_U(vsub_scalar, DO_SUB) | ||
80 | DO_2OP_SCALAR_U(vmul_scalar, DO_MUL) | ||
81 | @@ -XXX,XX +XXX,XX @@ DO_2OP_SAT_SCALAR(vqrdmulh_scalarb, 1, int8_t, DO_QRDMULH_B) | ||
82 | DO_2OP_SAT_SCALAR(vqrdmulh_scalarh, 2, int16_t, DO_QRDMULH_H) | ||
83 | DO_2OP_SAT_SCALAR(vqrdmulh_scalarw, 4, int32_t, DO_QRDMULH_W) | ||
84 | |||
85 | +/* Vector by vector plus scalar */ | ||
86 | +#define DO_VMLAS(D, N, M) ((N) * (D) + (M)) | ||
87 | + | ||
88 | +DO_2OP_ACC_SCALAR_U(vmlas, DO_VMLAS) | ||
89 | + | ||
90 | /* | ||
91 | * Long saturating scalar ops. As with DO_2OP_L, TYPE and H are for the | ||
92 | * input (smaller) type and LESIZE, LTYPE, LH for the output (long) type. | ||
93 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
94 | index XXXXXXX..XXXXXXX 100644 | ||
95 | --- a/target/arm/translate-mve.c | ||
96 | +++ b/target/arm/translate-mve.c | ||
97 | @@ -XXX,XX +XXX,XX @@ DO_2OP_SCALAR(VQSUB_U_scalar, vqsubu_scalar) | ||
98 | DO_2OP_SCALAR(VQDMULH_scalar, vqdmulh_scalar) | ||
99 | DO_2OP_SCALAR(VQRDMULH_scalar, vqrdmulh_scalar) | ||
100 | DO_2OP_SCALAR(VBRSR, vbrsr) | ||
101 | +DO_2OP_SCALAR(VMLAS, vmlas) | ||
102 | |||
103 | static bool trans_VQDMULLB_scalar(DisasContext *s, arg_2scalar *a) | ||
104 | { | ||
105 | -- | ||
106 | 2.20.1 | ||
107 | |||
108 | diff view generated by jsdifflib |
1 | We're about to make a code change to the sdiv and udiv helper | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | functions, so first fix their indentation and coding style. | ||
3 | 2 | ||
3 | Since e03b56863d2bc, our host endian indicator is unconditionally | ||
4 | set, which means that we can use a normal C condition. | ||
5 | |||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Message-id: 20220501055028.646596-20-richard.henderson@linaro.org | ||
9 | [PMM: quote correct git hash in commit message] | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20210730151636.17254-2-peter.maydell@linaro.org | ||
7 | --- | 11 | --- |
8 | target/arm/helper.c | 15 +++++++++------ | 12 | target/arm/helper.c | 9 +++------ |
9 | 1 file changed, 9 insertions(+), 6 deletions(-) | 13 | 1 file changed, 3 insertions(+), 6 deletions(-) |
10 | 14 | ||
11 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 15 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
12 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/helper.c | 17 | --- a/target/arm/helper.c |
14 | +++ b/target/arm/helper.c | 18 | +++ b/target/arm/helper.c |
15 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(uxtb16)(uint32_t x) | 19 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
16 | 20 | r2->type |= ARM_CP_ALIAS; | |
17 | int32_t HELPER(sdiv)(int32_t num, int32_t den) | 21 | } |
18 | { | 22 | |
19 | - if (den == 0) | 23 | - if (r->state == ARM_CP_STATE_BOTH) { |
20 | - return 0; | 24 | -#if HOST_BIG_ENDIAN |
21 | - if (num == INT_MIN && den == -1) | 25 | - if (r2->fieldoffset) { |
22 | - return INT_MIN; | 26 | - r2->fieldoffset += sizeof(uint32_t); |
23 | + if (den == 0) { | 27 | - } |
24 | + return 0; | 28 | -#endif |
25 | + } | 29 | + if (HOST_BIG_ENDIAN && |
26 | + if (num == INT_MIN && den == -1) { | 30 | + r->state == ARM_CP_STATE_BOTH && r2->fieldoffset) { |
27 | + return INT_MIN; | 31 | + r2->fieldoffset += sizeof(uint32_t); |
28 | + } | 32 | } |
29 | return num / den; | 33 | } |
30 | } | ||
31 | |||
32 | uint32_t HELPER(udiv)(uint32_t num, uint32_t den) | ||
33 | { | ||
34 | - if (den == 0) | ||
35 | - return 0; | ||
36 | + if (den == 0) { | ||
37 | + return 0; | ||
38 | + } | ||
39 | return num / den; | ||
40 | } | ||
41 | 34 | ||
42 | -- | 35 | -- |
43 | 2.20.1 | 36 | 2.25.1 |
44 | |||
45 | diff view generated by jsdifflib |
1 | Implement the MVE instructions which perform shifts by a scalar. | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | These are VSHL T2, VRSHL T2, VQSHL T1 and VQRSHL T2. They take the | ||
3 | shift amount in a general purpose register and shift every element in | ||
4 | the vector by that amount. | ||
5 | 2 | ||
6 | Mostly we can reuse the helper functions for shift-by-immediate; we | 3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | do need two new helpers for VQRSHL. | 4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
5 | Message-id: 20220501055028.646596-24-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/cpu.h | 15 +++++++++++++++ | ||
9 | 1 file changed, 15 insertions(+) | ||
8 | 10 | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | --- | ||
12 | target/arm/helper-mve.h | 8 +++++++ | ||
13 | target/arm/mve.decode | 23 ++++++++++++++++--- | ||
14 | target/arm/mve_helper.c | 2 ++ | ||
15 | target/arm/translate-mve.c | 46 ++++++++++++++++++++++++++++++++++++++ | ||
16 | 4 files changed, 76 insertions(+), 3 deletions(-) | ||
17 | |||
18 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/helper-mve.h | 13 | --- a/target/arm/cpu.h |
21 | +++ b/target/arm/helper-mve.h | 14 | +++ b/target/arm/cpu.h |
22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vrshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 15 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_ssbs(const ARMISARegisters *id) |
23 | DEF_HELPER_FLAGS_4(mve_vrshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 16 | return FIELD_EX32(id->id_pfr2, ID_PFR2, SSBS) != 0; |
24 | DEF_HELPER_FLAGS_4(mve_vrshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 17 | } |
25 | 18 | ||
26 | +DEF_HELPER_FLAGS_4(mve_vqrshli_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 19 | +static inline bool isar_feature_aa32_debugv8p2(const ARMISARegisters *id) |
27 | +DEF_HELPER_FLAGS_4(mve_vqrshli_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
28 | +DEF_HELPER_FLAGS_4(mve_vqrshli_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
29 | + | ||
30 | +DEF_HELPER_FLAGS_4(mve_vqrshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
31 | +DEF_HELPER_FLAGS_4(mve_vqrshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
32 | +DEF_HELPER_FLAGS_4(mve_vqrshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
33 | + | ||
34 | DEF_HELPER_FLAGS_4(mve_vshllbsb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
35 | DEF_HELPER_FLAGS_4(mve_vshllbsh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
36 | DEF_HELPER_FLAGS_4(mve_vshllbub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
37 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/target/arm/mve.decode | ||
40 | +++ b/target/arm/mve.decode | ||
41 | @@ -XXX,XX +XXX,XX @@ | ||
42 | &viwdup qd rn rm size imm | ||
43 | &vcmp qm qn size mask | ||
44 | &vcmp_scalar qn rm size mask | ||
45 | +&shl_scalar qda rm size | ||
46 | |||
47 | @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 | ||
48 | # Note that both Rn and Qd are 3 bits only (no D bit) | ||
49 | @@ -XXX,XX +XXX,XX @@ | ||
50 | @2_shr_w .... .... .. 1 ..... .... .... .... .... &2shift qd=%qd qm=%qm \ | ||
51 | size=2 shift=%rshift_i5 | ||
52 | |||
53 | +@shl_scalar .... .... .... size:2 .. .... .... .... rm:4 &shl_scalar qda=%qd | ||
54 | + | ||
55 | # Vector comparison; 4-bit Qm but 3-bit Qn | ||
56 | %mask_22_13 22:1 13:3 | ||
57 | @vcmp .... .... .. size:2 qn:3 . .... .... .... .... &vcmp qm=%qm mask=%mask_22_13 | ||
58 | @@ -XXX,XX +XXX,XX @@ VRMLSLDAVH 1111 1110 1 ... ... 0 ... x:1 1110 . 0 a:1 0 ... 1 @vmlaldav_no | ||
59 | |||
60 | VADD_scalar 1110 1110 0 . .. ... 1 ... 0 1111 . 100 .... @2scalar | ||
61 | VSUB_scalar 1110 1110 0 . .. ... 1 ... 1 1111 . 100 .... @2scalar | ||
62 | -VMUL_scalar 1110 1110 0 . .. ... 1 ... 1 1110 . 110 .... @2scalar | ||
63 | + | ||
64 | +{ | 20 | +{ |
65 | + VSHL_S_scalar 1110 1110 0 . 11 .. 01 ... 1 1110 0110 .... @shl_scalar | 21 | + return FIELD_EX32(id->id_dfr0, ID_DFR0, COPDBG) >= 8; |
66 | + VRSHL_S_scalar 1110 1110 0 . 11 .. 11 ... 1 1110 0110 .... @shl_scalar | ||
67 | + VQSHL_S_scalar 1110 1110 0 . 11 .. 01 ... 1 1110 1110 .... @shl_scalar | ||
68 | + VQRSHL_S_scalar 1110 1110 0 . 11 .. 11 ... 1 1110 1110 .... @shl_scalar | ||
69 | + VMUL_scalar 1110 1110 0 . .. ... 1 ... 1 1110 . 110 .... @2scalar | ||
70 | +} | 22 | +} |
71 | + | 23 | + |
24 | /* | ||
25 | * 64-bit feature tests via id registers. | ||
26 | */ | ||
27 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_ssbs(const ARMISARegisters *id) | ||
28 | return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, SSBS) != 0; | ||
29 | } | ||
30 | |||
31 | +static inline bool isar_feature_aa64_debugv8p2(const ARMISARegisters *id) | ||
72 | +{ | 32 | +{ |
73 | + VSHL_U_scalar 1111 1110 0 . 11 .. 01 ... 1 1110 0110 .... @shl_scalar | 33 | + return FIELD_EX64(id->id_aa64dfr0, ID_AA64DFR0, DEBUGVER) >= 8; |
74 | + VRSHL_U_scalar 1111 1110 0 . 11 .. 11 ... 1 1110 0110 .... @shl_scalar | ||
75 | + VQSHL_U_scalar 1111 1110 0 . 11 .. 01 ... 1 1110 1110 .... @shl_scalar | ||
76 | + VQRSHL_U_scalar 1111 1110 0 . 11 .. 11 ... 1 1110 1110 .... @shl_scalar | ||
77 | + VBRSR 1111 1110 0 . .. ... 1 ... 1 1110 . 110 .... @2scalar | ||
78 | +} | 34 | +} |
79 | + | 35 | + |
80 | VHADD_S_scalar 1110 1110 0 . .. ... 0 ... 0 1111 . 100 .... @2scalar | 36 | static inline bool isar_feature_aa64_sve2(const ARMISARegisters *id) |
81 | VHADD_U_scalar 1111 1110 0 . .. ... 0 ... 0 1111 . 100 .... @2scalar | 37 | { |
82 | VHSUB_S_scalar 1110 1110 0 . .. ... 0 ... 1 1111 . 100 .... @2scalar | 38 | return FIELD_EX64(id->id_aa64zfr0, ID_AA64ZFR0, SVEVER) != 0; |
83 | @@ -XXX,XX +XXX,XX @@ VHSUB_U_scalar 1111 1110 0 . .. ... 0 ... 1 1111 . 100 .... @2scalar | 39 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_any_tts2uxn(const ARMISARegisters *id) |
84 | size=%size_28 | 40 | return isar_feature_aa64_tts2uxn(id) || isar_feature_aa32_tts2uxn(id); |
85 | } | 41 | } |
86 | 42 | ||
87 | -VBRSR 1111 1110 0 . .. ... 1 ... 1 1110 . 110 .... @2scalar | 43 | +static inline bool isar_feature_any_debugv8p2(const ARMISARegisters *id) |
88 | - | ||
89 | VQDMULH_scalar 1110 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
90 | VQRDMULH_scalar 1111 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
91 | |||
92 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
93 | index XXXXXXX..XXXXXXX 100644 | ||
94 | --- a/target/arm/mve_helper.c | ||
95 | +++ b/target/arm/mve_helper.c | ||
96 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT_SAT_S(vqshli_s, DO_SQSHL_OP) | ||
97 | DO_2SHIFT_SAT_S(vqshlui_s, DO_SUQSHL_OP) | ||
98 | DO_2SHIFT_U(vrshli_u, DO_VRSHLU) | ||
99 | DO_2SHIFT_S(vrshli_s, DO_VRSHLS) | ||
100 | +DO_2SHIFT_SAT_U(vqrshli_u, DO_UQRSHL_OP) | ||
101 | +DO_2SHIFT_SAT_S(vqrshli_s, DO_SQRSHL_OP) | ||
102 | |||
103 | /* Shift-and-insert; we always work with 64 bits at a time */ | ||
104 | #define DO_2SHIFT_INSERT(OP, ESIZE, SHIFTFN, MASKFN) \ | ||
105 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
106 | index XXXXXXX..XXXXXXX 100644 | ||
107 | --- a/target/arm/translate-mve.c | ||
108 | +++ b/target/arm/translate-mve.c | ||
109 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT(VRSHRI_U, vrshli_u, true) | ||
110 | DO_2SHIFT(VSRI, vsri, false) | ||
111 | DO_2SHIFT(VSLI, vsli, false) | ||
112 | |||
113 | +static bool do_2shift_scalar(DisasContext *s, arg_shl_scalar *a, | ||
114 | + MVEGenTwoOpShiftFn *fn) | ||
115 | +{ | 44 | +{ |
116 | + TCGv_ptr qda; | 45 | + return isar_feature_aa64_debugv8p2(id) || isar_feature_aa32_debugv8p2(id); |
117 | + TCGv_i32 rm; | ||
118 | + | ||
119 | + if (!dc_isar_feature(aa32_mve, s) || | ||
120 | + !mve_check_qreg_bank(s, a->qda) || | ||
121 | + a->rm == 13 || a->rm == 15 || !fn) { | ||
122 | + /* Rm cases are UNPREDICTABLE */ | ||
123 | + return false; | ||
124 | + } | ||
125 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
126 | + return true; | ||
127 | + } | ||
128 | + | ||
129 | + qda = mve_qreg_ptr(a->qda); | ||
130 | + rm = load_reg(s, a->rm); | ||
131 | + fn(cpu_env, qda, qda, rm); | ||
132 | + tcg_temp_free_ptr(qda); | ||
133 | + tcg_temp_free_i32(rm); | ||
134 | + mve_update_eci(s); | ||
135 | + return true; | ||
136 | +} | 46 | +} |
137 | + | 47 | + |
138 | +#define DO_2SHIFT_SCALAR(INSN, FN) \ | 48 | /* |
139 | + static bool trans_##INSN(DisasContext *s, arg_shl_scalar *a) \ | 49 | * Forward to the above feature tests given an ARMCPU pointer. |
140 | + { \ | 50 | */ |
141 | + static MVEGenTwoOpShiftFn * const fns[] = { \ | ||
142 | + gen_helper_mve_##FN##b, \ | ||
143 | + gen_helper_mve_##FN##h, \ | ||
144 | + gen_helper_mve_##FN##w, \ | ||
145 | + NULL, \ | ||
146 | + }; \ | ||
147 | + return do_2shift_scalar(s, a, fns[a->size]); \ | ||
148 | + } | ||
149 | + | ||
150 | +DO_2SHIFT_SCALAR(VSHL_S_scalar, vshli_s) | ||
151 | +DO_2SHIFT_SCALAR(VSHL_U_scalar, vshli_u) | ||
152 | +DO_2SHIFT_SCALAR(VRSHL_S_scalar, vrshli_s) | ||
153 | +DO_2SHIFT_SCALAR(VRSHL_U_scalar, vrshli_u) | ||
154 | +DO_2SHIFT_SCALAR(VQSHL_S_scalar, vqshli_s) | ||
155 | +DO_2SHIFT_SCALAR(VQSHL_U_scalar, vqshli_u) | ||
156 | +DO_2SHIFT_SCALAR(VQRSHL_S_scalar, vqrshli_s) | ||
157 | +DO_2SHIFT_SCALAR(VQRSHL_U_scalar, vqrshli_u) | ||
158 | + | ||
159 | #define DO_VSHLL(INSN, FN) \ | ||
160 | static bool trans_##INSN(DisasContext *s, arg_2shift *a) \ | ||
161 | { \ | ||
162 | -- | 51 | -- |
163 | 2.20.1 | 52 | 2.25.1 |
164 | |||
165 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | All the users of the vmlaldav formats have an 'x bit in bit 12 and an | ||
2 | 'a' bit in bit 5; move these to the format rather than specifying them | ||
3 | in each insn pattern. | ||
4 | 1 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | --- | ||
8 | target/arm/mve.decode | 16 ++++++++-------- | ||
9 | 1 file changed, 8 insertions(+), 8 deletions(-) | ||
10 | |||
11 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/target/arm/mve.decode | ||
14 | +++ b/target/arm/mve.decode | ||
15 | @@ -XXX,XX +XXX,XX @@ VDUP 1110 1110 1 0 10 ... 0 .... 1011 . 0 0 1 0000 @vdup size=2 | ||
16 | |||
17 | &vmlaldav rdahi rdalo size qn qm x a | ||
18 | |||
19 | -@vmlaldav .... .... . ... ... . ... . .... .... qm:3 . \ | ||
20 | +@vmlaldav .... .... . ... ... . ... x:1 .... .. a:1 . qm:3 . \ | ||
21 | qn=%qn rdahi=%rdahi rdalo=%rdalo size=%size_16 &vmlaldav | ||
22 | -@vmlaldav_nosz .... .... . ... ... . ... . .... .... qm:3 . \ | ||
23 | +@vmlaldav_nosz .... .... . ... ... . ... x:1 .... .. a:1 . qm:3 . \ | ||
24 | qn=%qn rdahi=%rdahi rdalo=%rdalo size=0 &vmlaldav | ||
25 | -VMLALDAV_S 1110 1110 1 ... ... . ... x:1 1110 . 0 a:1 0 ... 0 @vmlaldav | ||
26 | -VMLALDAV_U 1111 1110 1 ... ... . ... x:1 1110 . 0 a:1 0 ... 0 @vmlaldav | ||
27 | +VMLALDAV_S 1110 1110 1 ... ... . ... . 1110 . 0 . 0 ... 0 @vmlaldav | ||
28 | +VMLALDAV_U 1111 1110 1 ... ... . ... . 1110 . 0 . 0 ... 0 @vmlaldav | ||
29 | |||
30 | -VMLSLDAV 1110 1110 1 ... ... . ... x:1 1110 . 0 a:1 0 ... 1 @vmlaldav | ||
31 | +VMLSLDAV 1110 1110 1 ... ... . ... . 1110 . 0 . 0 ... 1 @vmlaldav | ||
32 | |||
33 | -VRMLALDAVH_S 1110 1110 1 ... ... 0 ... x:1 1111 . 0 a:1 0 ... 0 @vmlaldav_nosz | ||
34 | -VRMLALDAVH_U 1111 1110 1 ... ... 0 ... x:1 1111 . 0 a:1 0 ... 0 @vmlaldav_nosz | ||
35 | +VRMLALDAVH_S 1110 1110 1 ... ... 0 ... . 1111 . 0 . 0 ... 0 @vmlaldav_nosz | ||
36 | +VRMLALDAVH_U 1111 1110 1 ... ... 0 ... . 1111 . 0 . 0 ... 0 @vmlaldav_nosz | ||
37 | |||
38 | -VRMLSLDAVH 1111 1110 1 ... ... 0 ... x:1 1110 . 0 a:1 0 ... 1 @vmlaldav_nosz | ||
39 | +VRMLSLDAVH 1111 1110 1 ... ... 0 ... . 1110 . 0 . 0 ... 1 @vmlaldav_nosz | ||
40 | |||
41 | # Scalar operations | ||
42 | |||
43 | -- | ||
44 | 2.20.1 | ||
45 | |||
46 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE integer min/max across vector insns | ||
2 | VMAXV, VMINV, VMAXAV and VMINAV, which find the maximum | ||
3 | from the vector elements and a general purpose register, | ||
4 | and store the maximum back into the general purpose | ||
5 | register. | ||
6 | 1 | ||
7 | These insns overlap with VRMLALDAVH (they use what would | ||
8 | be RdaHi=0b110). | ||
9 | |||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | --- | ||
13 | target/arm/helper-mve.h | 20 ++++++++++++ | ||
14 | target/arm/mve.decode | 18 +++++++++-- | ||
15 | target/arm/mve_helper.c | 66 ++++++++++++++++++++++++++++++++++++++ | ||
16 | target/arm/translate-mve.c | 48 +++++++++++++++++++++++++++ | ||
17 | 4 files changed, 150 insertions(+), 2 deletions(-) | ||
18 | |||
19 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/target/arm/helper-mve.h | ||
22 | +++ b/target/arm/helper-mve.h | ||
23 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vaddvuh, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
24 | DEF_HELPER_FLAGS_3(mve_vaddvsw, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
25 | DEF_HELPER_FLAGS_3(mve_vaddvuw, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
26 | |||
27 | +DEF_HELPER_FLAGS_3(mve_vmaxvsb, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
28 | +DEF_HELPER_FLAGS_3(mve_vmaxvsh, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
29 | +DEF_HELPER_FLAGS_3(mve_vmaxvsw, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
30 | +DEF_HELPER_FLAGS_3(mve_vmaxvub, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
31 | +DEF_HELPER_FLAGS_3(mve_vmaxvuh, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
32 | +DEF_HELPER_FLAGS_3(mve_vmaxvuw, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
33 | +DEF_HELPER_FLAGS_3(mve_vmaxavb, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
34 | +DEF_HELPER_FLAGS_3(mve_vmaxavh, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
35 | +DEF_HELPER_FLAGS_3(mve_vmaxavw, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
36 | + | ||
37 | +DEF_HELPER_FLAGS_3(mve_vminvsb, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
38 | +DEF_HELPER_FLAGS_3(mve_vminvsh, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
39 | +DEF_HELPER_FLAGS_3(mve_vminvsw, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
40 | +DEF_HELPER_FLAGS_3(mve_vminvub, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
41 | +DEF_HELPER_FLAGS_3(mve_vminvuh, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
42 | +DEF_HELPER_FLAGS_3(mve_vminvuw, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
43 | +DEF_HELPER_FLAGS_3(mve_vminavb, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
44 | +DEF_HELPER_FLAGS_3(mve_vminavh, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
45 | +DEF_HELPER_FLAGS_3(mve_vminavw, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
46 | + | ||
47 | DEF_HELPER_FLAGS_3(mve_vaddlv_s, TCG_CALL_NO_WG, i64, env, ptr, i64) | ||
48 | DEF_HELPER_FLAGS_3(mve_vaddlv_u, TCG_CALL_NO_WG, i64, env, ptr, i64) | ||
49 | |||
50 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/target/arm/mve.decode | ||
53 | +++ b/target/arm/mve.decode | ||
54 | @@ -XXX,XX +XXX,XX @@ | ||
55 | &vcmp qm qn size mask | ||
56 | &vcmp_scalar qn rm size mask | ||
57 | &shl_scalar qda rm size | ||
58 | +&vmaxv qm rda size | ||
59 | |||
60 | @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 | ||
61 | # Note that both Rn and Qd are 3 bits only (no D bit) | ||
62 | @@ -XXX,XX +XXX,XX @@ | ||
63 | @vcmp_scalar .... .... .. size:2 qn:3 . .... .... .... rm:4 &vcmp_scalar \ | ||
64 | mask=%mask_22_13 | ||
65 | |||
66 | +@vmaxv .... .... .... size:2 .. rda:4 .... .... .... &vmaxv qm=%qm | ||
67 | + | ||
68 | # Vector loads and stores | ||
69 | |||
70 | # Widening loads and narrowing stores: | ||
71 | @@ -XXX,XX +XXX,XX @@ VMLALDAV_U 1111 1110 1 ... ... . ... . 1110 . 0 . 0 ... 0 @vmlaldav | ||
72 | |||
73 | VMLSLDAV 1110 1110 1 ... ... . ... . 1110 . 0 . 0 ... 1 @vmlaldav | ||
74 | |||
75 | -VRMLALDAVH_S 1110 1110 1 ... ... 0 ... . 1111 . 0 . 0 ... 0 @vmlaldav_nosz | ||
76 | -VRMLALDAVH_U 1111 1110 1 ... ... 0 ... . 1111 . 0 . 0 ... 0 @vmlaldav_nosz | ||
77 | +{ | ||
78 | + VMAXV_S 1110 1110 1110 .. 10 .... 1111 0 0 . 0 ... 0 @vmaxv | ||
79 | + VMINV_S 1110 1110 1110 .. 10 .... 1111 1 0 . 0 ... 0 @vmaxv | ||
80 | + VMAXAV 1110 1110 1110 .. 00 .... 1111 0 0 . 0 ... 0 @vmaxv | ||
81 | + VMINAV 1110 1110 1110 .. 00 .... 1111 1 0 . 0 ... 0 @vmaxv | ||
82 | + VRMLALDAVH_S 1110 1110 1 ... ... 0 ... . 1111 . 0 . 0 ... 0 @vmlaldav_nosz | ||
83 | +} | ||
84 | + | ||
85 | +{ | ||
86 | + VMAXV_U 1111 1110 1110 .. 10 .... 1111 0 0 . 0 ... 0 @vmaxv | ||
87 | + VMINV_U 1111 1110 1110 .. 10 .... 1111 1 0 . 0 ... 0 @vmaxv | ||
88 | + VRMLALDAVH_U 1111 1110 1 ... ... 0 ... . 1111 . 0 . 0 ... 0 @vmlaldav_nosz | ||
89 | +} | ||
90 | |||
91 | VRMLSLDAVH 1111 1110 1 ... ... 0 ... . 1110 . 0 . 0 ... 1 @vmlaldav_nosz | ||
92 | |||
93 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
94 | index XXXXXXX..XXXXXXX 100644 | ||
95 | --- a/target/arm/mve_helper.c | ||
96 | +++ b/target/arm/mve_helper.c | ||
97 | @@ -XXX,XX +XXX,XX @@ DO_VADDV(vaddvub, 1, uint8_t) | ||
98 | DO_VADDV(vaddvuh, 2, uint16_t) | ||
99 | DO_VADDV(vaddvuw, 4, uint32_t) | ||
100 | |||
101 | +/* | ||
102 | + * Vector max/min across vector. Unlike VADDV, we must | ||
103 | + * read ra as the element size, not its full width. | ||
104 | + * We work with int64_t internally for simplicity. | ||
105 | + */ | ||
106 | +#define DO_VMAXMINV(OP, ESIZE, TYPE, RATYPE, FN) \ | ||
107 | + uint32_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vm, \ | ||
108 | + uint32_t ra_in) \ | ||
109 | + { \ | ||
110 | + uint16_t mask = mve_element_mask(env); \ | ||
111 | + unsigned e; \ | ||
112 | + TYPE *m = vm; \ | ||
113 | + int64_t ra = (RATYPE)ra_in; \ | ||
114 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
115 | + if (mask & 1) { \ | ||
116 | + ra = FN(ra, m[H##ESIZE(e)]); \ | ||
117 | + } \ | ||
118 | + } \ | ||
119 | + mve_advance_vpt(env); \ | ||
120 | + return ra; \ | ||
121 | + } \ | ||
122 | + | ||
123 | +#define DO_VMAXMINV_U(INSN, FN) \ | ||
124 | + DO_VMAXMINV(INSN##b, 1, uint8_t, uint8_t, FN) \ | ||
125 | + DO_VMAXMINV(INSN##h, 2, uint16_t, uint16_t, FN) \ | ||
126 | + DO_VMAXMINV(INSN##w, 4, uint32_t, uint32_t, FN) | ||
127 | +#define DO_VMAXMINV_S(INSN, FN) \ | ||
128 | + DO_VMAXMINV(INSN##b, 1, int8_t, int8_t, FN) \ | ||
129 | + DO_VMAXMINV(INSN##h, 2, int16_t, int16_t, FN) \ | ||
130 | + DO_VMAXMINV(INSN##w, 4, int32_t, int32_t, FN) | ||
131 | + | ||
132 | +/* | ||
133 | + * Helpers for max and min of absolute values across vector: | ||
134 | + * note that we only take the absolute value of 'm', not 'n' | ||
135 | + */ | ||
136 | +static int64_t do_maxa(int64_t n, int64_t m) | ||
137 | +{ | ||
138 | + if (m < 0) { | ||
139 | + m = -m; | ||
140 | + } | ||
141 | + return MAX(n, m); | ||
142 | +} | ||
143 | + | ||
144 | +static int64_t do_mina(int64_t n, int64_t m) | ||
145 | +{ | ||
146 | + if (m < 0) { | ||
147 | + m = -m; | ||
148 | + } | ||
149 | + return MIN(n, m); | ||
150 | +} | ||
151 | + | ||
152 | +DO_VMAXMINV_S(vmaxvs, DO_MAX) | ||
153 | +DO_VMAXMINV_U(vmaxvu, DO_MAX) | ||
154 | +DO_VMAXMINV_S(vminvs, DO_MIN) | ||
155 | +DO_VMAXMINV_U(vminvu, DO_MIN) | ||
156 | +/* | ||
157 | + * VMAXAV, VMINAV treat the general purpose input as unsigned | ||
158 | + * and the vector elements as signed. | ||
159 | + */ | ||
160 | +DO_VMAXMINV(vmaxavb, 1, int8_t, uint8_t, do_maxa) | ||
161 | +DO_VMAXMINV(vmaxavh, 2, int16_t, uint16_t, do_maxa) | ||
162 | +DO_VMAXMINV(vmaxavw, 4, int32_t, uint32_t, do_maxa) | ||
163 | +DO_VMAXMINV(vminavb, 1, int8_t, uint8_t, do_mina) | ||
164 | +DO_VMAXMINV(vminavh, 2, int16_t, uint16_t, do_mina) | ||
165 | +DO_VMAXMINV(vminavw, 4, int32_t, uint32_t, do_mina) | ||
166 | + | ||
167 | #define DO_VADDLV(OP, TYPE, LTYPE) \ | ||
168 | uint64_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vm, \ | ||
169 | uint64_t ra) \ | ||
170 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
171 | index XXXXXXX..XXXXXXX 100644 | ||
172 | --- a/target/arm/translate-mve.c | ||
173 | +++ b/target/arm/translate-mve.c | ||
174 | @@ -XXX,XX +XXX,XX @@ DO_VCMP(VCMPGE, vcmpge) | ||
175 | DO_VCMP(VCMPLT, vcmplt) | ||
176 | DO_VCMP(VCMPGT, vcmpgt) | ||
177 | DO_VCMP(VCMPLE, vcmple) | ||
178 | + | ||
179 | +static bool do_vmaxv(DisasContext *s, arg_vmaxv *a, MVEGenVADDVFn fn) | ||
180 | +{ | ||
181 | + /* | ||
182 | + * MIN/MAX operations across a vector: compute the min or | ||
183 | + * max of the initial value in a general purpose register | ||
184 | + * and all the elements in the vector, and store it back | ||
185 | + * into the general purpose register. | ||
186 | + */ | ||
187 | + TCGv_ptr qm; | ||
188 | + TCGv_i32 rda; | ||
189 | + | ||
190 | + if (!dc_isar_feature(aa32_mve, s) || !mve_check_qreg_bank(s, a->qm) || | ||
191 | + !fn || a->rda == 13 || a->rda == 15) { | ||
192 | + /* Rda cases are UNPREDICTABLE */ | ||
193 | + return false; | ||
194 | + } | ||
195 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
196 | + return true; | ||
197 | + } | ||
198 | + | ||
199 | + qm = mve_qreg_ptr(a->qm); | ||
200 | + rda = load_reg(s, a->rda); | ||
201 | + fn(rda, cpu_env, qm, rda); | ||
202 | + store_reg(s, a->rda, rda); | ||
203 | + tcg_temp_free_ptr(qm); | ||
204 | + mve_update_eci(s); | ||
205 | + return true; | ||
206 | +} | ||
207 | + | ||
208 | +#define DO_VMAXV(INSN, FN) \ | ||
209 | + static bool trans_##INSN(DisasContext *s, arg_vmaxv *a) \ | ||
210 | + { \ | ||
211 | + static MVEGenVADDVFn * const fns[] = { \ | ||
212 | + gen_helper_mve_##FN##b, \ | ||
213 | + gen_helper_mve_##FN##h, \ | ||
214 | + gen_helper_mve_##FN##w, \ | ||
215 | + NULL, \ | ||
216 | + }; \ | ||
217 | + return do_vmaxv(s, a, fns[a->size]); \ | ||
218 | + } | ||
219 | + | ||
220 | +DO_VMAXV(VMAXV_S, vmaxvs) | ||
221 | +DO_VMAXV(VMAXV_U, vmaxvu) | ||
222 | +DO_VMAXV(VMAXAV, vmaxav) | ||
223 | +DO_VMAXV(VMINV_S, vminvs) | ||
224 | +DO_VMAXV(VMINV_U, vminvu) | ||
225 | +DO_VMAXV(VMINAV, vminav) | ||
226 | -- | ||
227 | 2.20.1 | ||
228 | |||
229 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE VABAV insn, which computes absolute differences | ||
2 | between elements of two vectors and accumulates the result into | ||
3 | a general purpose register. | ||
4 | 1 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | --- | ||
8 | target/arm/helper-mve.h | 7 +++++++ | ||
9 | target/arm/mve.decode | 6 ++++++ | ||
10 | target/arm/mve_helper.c | 26 +++++++++++++++++++++++ | ||
11 | target/arm/translate-mve.c | 43 ++++++++++++++++++++++++++++++++++++++ | ||
12 | 4 files changed, 82 insertions(+) | ||
13 | |||
14 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/helper-mve.h | ||
17 | +++ b/target/arm/helper-mve.h | ||
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vminavw, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
19 | DEF_HELPER_FLAGS_3(mve_vaddlv_s, TCG_CALL_NO_WG, i64, env, ptr, i64) | ||
20 | DEF_HELPER_FLAGS_3(mve_vaddlv_u, TCG_CALL_NO_WG, i64, env, ptr, i64) | ||
21 | |||
22 | +DEF_HELPER_FLAGS_4(mve_vabavsb, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
23 | +DEF_HELPER_FLAGS_4(mve_vabavsh, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
24 | +DEF_HELPER_FLAGS_4(mve_vabavsw, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
25 | +DEF_HELPER_FLAGS_4(mve_vabavub, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
26 | +DEF_HELPER_FLAGS_4(mve_vabavuh, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
27 | +DEF_HELPER_FLAGS_4(mve_vabavuw, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
28 | + | ||
29 | DEF_HELPER_FLAGS_3(mve_vmovi, TCG_CALL_NO_WG, void, env, ptr, i64) | ||
30 | DEF_HELPER_FLAGS_3(mve_vandi, TCG_CALL_NO_WG, void, env, ptr, i64) | ||
31 | DEF_HELPER_FLAGS_3(mve_vorri, TCG_CALL_NO_WG, void, env, ptr, i64) | ||
32 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/target/arm/mve.decode | ||
35 | +++ b/target/arm/mve.decode | ||
36 | @@ -XXX,XX +XXX,XX @@ | ||
37 | &vcmp_scalar qn rm size mask | ||
38 | &shl_scalar qda rm size | ||
39 | &vmaxv qm rda size | ||
40 | +&vabav qn qm rda size | ||
41 | |||
42 | @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 | ||
43 | # Note that both Rn and Qd are 3 bits only (no D bit) | ||
44 | @@ -XXX,XX +XXX,XX @@ VMLAS 111- 1110 0 . .. ... 1 ... 1 1110 . 100 .... @2scalar | ||
45 | rdahi=%rdahi rdalo=%rdalo | ||
46 | } | ||
47 | |||
48 | +@vabav .... .... .. size:2 .... rda:4 .... .... .... &vabav qn=%qn qm=%qm | ||
49 | + | ||
50 | +VABAV_S 111 0 1110 10 .. ... 0 .... 1111 . 0 . 0 ... 1 @vabav | ||
51 | +VABAV_U 111 1 1110 10 .. ... 0 .... 1111 . 0 . 0 ... 1 @vabav | ||
52 | + | ||
53 | # Logical immediate operations (1 reg and modified-immediate) | ||
54 | |||
55 | # The cmode/op bits here decode VORR/VBIC/VMOV/VMVN, but | ||
56 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/target/arm/mve_helper.c | ||
59 | +++ b/target/arm/mve_helper.c | ||
60 | @@ -XXX,XX +XXX,XX @@ DO_VMAXMINV(vminavb, 1, int8_t, uint8_t, do_mina) | ||
61 | DO_VMAXMINV(vminavh, 2, int16_t, uint16_t, do_mina) | ||
62 | DO_VMAXMINV(vminavw, 4, int32_t, uint32_t, do_mina) | ||
63 | |||
64 | +#define DO_VABAV(OP, ESIZE, TYPE) \ | ||
65 | + uint32_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vn, \ | ||
66 | + void *vm, uint32_t ra) \ | ||
67 | + { \ | ||
68 | + uint16_t mask = mve_element_mask(env); \ | ||
69 | + unsigned e; \ | ||
70 | + TYPE *m = vm, *n = vn; \ | ||
71 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
72 | + if (mask & 1) { \ | ||
73 | + int64_t n0 = n[H##ESIZE(e)]; \ | ||
74 | + int64_t m0 = m[H##ESIZE(e)]; \ | ||
75 | + uint32_t r = n0 >= m0 ? (n0 - m0) : (m0 - n0); \ | ||
76 | + ra += r; \ | ||
77 | + } \ | ||
78 | + } \ | ||
79 | + mve_advance_vpt(env); \ | ||
80 | + return ra; \ | ||
81 | + } | ||
82 | + | ||
83 | +DO_VABAV(vabavsb, 1, int8_t) | ||
84 | +DO_VABAV(vabavsh, 2, int16_t) | ||
85 | +DO_VABAV(vabavsw, 4, int32_t) | ||
86 | +DO_VABAV(vabavub, 1, uint8_t) | ||
87 | +DO_VABAV(vabavuh, 2, uint16_t) | ||
88 | +DO_VABAV(vabavuw, 4, uint32_t) | ||
89 | + | ||
90 | #define DO_VADDLV(OP, TYPE, LTYPE) \ | ||
91 | uint64_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vm, \ | ||
92 | uint64_t ra) \ | ||
93 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
94 | index XXXXXXX..XXXXXXX 100644 | ||
95 | --- a/target/arm/translate-mve.c | ||
96 | +++ b/target/arm/translate-mve.c | ||
97 | @@ -XXX,XX +XXX,XX @@ typedef void MVEGenVIDUPFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32, TCGv_i32); | ||
98 | typedef void MVEGenVIWDUPFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32, TCGv_i32, TCGv_i32); | ||
99 | typedef void MVEGenCmpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
100 | typedef void MVEGenScalarCmpFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
101 | +typedef void MVEGenVABAVFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
102 | |||
103 | /* Return the offset of a Qn register (same semantics as aa32_vfp_qreg()) */ | ||
104 | static inline long mve_qreg_offset(unsigned reg) | ||
105 | @@ -XXX,XX +XXX,XX @@ DO_VMAXV(VMAXAV, vmaxav) | ||
106 | DO_VMAXV(VMINV_S, vminvs) | ||
107 | DO_VMAXV(VMINV_U, vminvu) | ||
108 | DO_VMAXV(VMINAV, vminav) | ||
109 | + | ||
110 | +static bool do_vabav(DisasContext *s, arg_vabav *a, MVEGenVABAVFn *fn) | ||
111 | +{ | ||
112 | + /* Absolute difference accumulated across vector */ | ||
113 | + TCGv_ptr qn, qm; | ||
114 | + TCGv_i32 rda; | ||
115 | + | ||
116 | + if (!dc_isar_feature(aa32_mve, s) || | ||
117 | + !mve_check_qreg_bank(s, a->qm | a->qn) || | ||
118 | + !fn || a->rda == 13 || a->rda == 15) { | ||
119 | + /* Rda cases are UNPREDICTABLE */ | ||
120 | + return false; | ||
121 | + } | ||
122 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
123 | + return true; | ||
124 | + } | ||
125 | + | ||
126 | + qm = mve_qreg_ptr(a->qm); | ||
127 | + qn = mve_qreg_ptr(a->qn); | ||
128 | + rda = load_reg(s, a->rda); | ||
129 | + fn(rda, cpu_env, qn, qm, rda); | ||
130 | + store_reg(s, a->rda, rda); | ||
131 | + tcg_temp_free_ptr(qm); | ||
132 | + tcg_temp_free_ptr(qn); | ||
133 | + mve_update_eci(s); | ||
134 | + return true; | ||
135 | +} | ||
136 | + | ||
137 | +#define DO_VABAV(INSN, FN) \ | ||
138 | + static bool trans_##INSN(DisasContext *s, arg_vabav *a) \ | ||
139 | + { \ | ||
140 | + static MVEGenVABAVFn * const fns[] = { \ | ||
141 | + gen_helper_mve_##FN##b, \ | ||
142 | + gen_helper_mve_##FN##h, \ | ||
143 | + gen_helper_mve_##FN##w, \ | ||
144 | + NULL, \ | ||
145 | + }; \ | ||
146 | + return do_vabav(s, a, fns[a->size]); \ | ||
147 | + } | ||
148 | + | ||
149 | +DO_VABAV(VABAV_S, vabavs) | ||
150 | +DO_VABAV(VABAV_U, vabavu) | ||
151 | -- | ||
152 | 2.20.1 | ||
153 | |||
154 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE narrowing move insns VMOVN, VQMOVN and VQMOVUN. | ||
2 | These take a double-width input, narrow it (possibly saturating) and | ||
3 | store the result to either the top or bottom half of the output | ||
4 | element. | ||
5 | 1 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | --- | ||
9 | target/arm/helper-mve.h | 20 ++++++++++ | ||
10 | target/arm/mve.decode | 12 ++++++ | ||
11 | target/arm/mve_helper.c | 78 ++++++++++++++++++++++++++++++++++++++ | ||
12 | target/arm/translate-mve.c | 22 +++++++++++ | ||
13 | 4 files changed, 132 insertions(+) | ||
14 | |||
15 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/helper-mve.h | ||
18 | +++ b/target/arm/helper-mve.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vnegw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
20 | DEF_HELPER_FLAGS_3(mve_vfnegh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
21 | DEF_HELPER_FLAGS_3(mve_vfnegs, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
22 | |||
23 | +DEF_HELPER_FLAGS_3(mve_vmovnbb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
24 | +DEF_HELPER_FLAGS_3(mve_vmovnbh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
25 | +DEF_HELPER_FLAGS_3(mve_vmovntb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
26 | +DEF_HELPER_FLAGS_3(mve_vmovnth, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
27 | + | ||
28 | +DEF_HELPER_FLAGS_3(mve_vqmovunbb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
29 | +DEF_HELPER_FLAGS_3(mve_vqmovunbh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
30 | +DEF_HELPER_FLAGS_3(mve_vqmovuntb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
31 | +DEF_HELPER_FLAGS_3(mve_vqmovunth, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
32 | + | ||
33 | +DEF_HELPER_FLAGS_3(mve_vqmovnbsb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
34 | +DEF_HELPER_FLAGS_3(mve_vqmovnbsh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
35 | +DEF_HELPER_FLAGS_3(mve_vqmovntsb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
36 | +DEF_HELPER_FLAGS_3(mve_vqmovntsh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
37 | + | ||
38 | +DEF_HELPER_FLAGS_3(mve_vqmovnbub, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
39 | +DEF_HELPER_FLAGS_3(mve_vqmovnbuh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
40 | +DEF_HELPER_FLAGS_3(mve_vqmovntub, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
41 | +DEF_HELPER_FLAGS_3(mve_vqmovntuh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
42 | + | ||
43 | DEF_HELPER_FLAGS_4(mve_vand, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
44 | DEF_HELPER_FLAGS_4(mve_vbic, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
45 | DEF_HELPER_FLAGS_4(mve_vorr, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
46 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/target/arm/mve.decode | ||
49 | +++ b/target/arm/mve.decode | ||
50 | @@ -XXX,XX +XXX,XX @@ VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op | ||
51 | VSHLL_BS 111 0 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_b | ||
52 | VSHLL_BS 111 0 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_h | ||
53 | |||
54 | + VQMOVUNB 111 0 1110 0 . 11 .. 01 ... 0 1110 1 0 . 0 ... 1 @1op | ||
55 | + VQMOVN_BS 111 0 1110 0 . 11 .. 11 ... 0 1110 0 0 . 0 ... 1 @1op | ||
56 | + | ||
57 | VMULH_S 111 0 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op | ||
58 | } | ||
59 | |||
60 | @@ -XXX,XX +XXX,XX @@ VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op | ||
61 | VSHLL_BU 111 1 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_b | ||
62 | VSHLL_BU 111 1 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_h | ||
63 | |||
64 | + VMOVNB 111 1 1110 0 . 11 .. 01 ... 0 1110 1 0 . 0 ... 1 @1op | ||
65 | + VQMOVN_BU 111 1 1110 0 . 11 .. 11 ... 0 1110 0 0 . 0 ... 1 @1op | ||
66 | + | ||
67 | VMULH_U 111 1 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op | ||
68 | } | ||
69 | |||
70 | @@ -XXX,XX +XXX,XX @@ VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op | ||
71 | VSHLL_TS 111 0 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_b | ||
72 | VSHLL_TS 111 0 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_h | ||
73 | |||
74 | + VQMOVUNT 111 0 1110 0 . 11 .. 01 ... 1 1110 1 0 . 0 ... 1 @1op | ||
75 | + VQMOVN_TS 111 0 1110 0 . 11 .. 11 ... 1 1110 0 0 . 0 ... 1 @1op | ||
76 | + | ||
77 | VRMULH_S 111 0 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op | ||
78 | } | ||
79 | |||
80 | @@ -XXX,XX +XXX,XX @@ VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op | ||
81 | VSHLL_TU 111 1 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_b | ||
82 | VSHLL_TU 111 1 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_h | ||
83 | |||
84 | + VMOVNT 111 1 1110 0 . 11 .. 01 ... 1 1110 1 0 . 0 ... 1 @1op | ||
85 | + VQMOVN_TU 111 1 1110 0 . 11 .. 11 ... 1 1110 0 0 . 0 ... 1 @1op | ||
86 | + | ||
87 | VRMULH_U 111 1 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op | ||
88 | } | ||
89 | |||
90 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
91 | index XXXXXXX..XXXXXXX 100644 | ||
92 | --- a/target/arm/mve_helper.c | ||
93 | +++ b/target/arm/mve_helper.c | ||
94 | @@ -XXX,XX +XXX,XX @@ DO_VSHRN_SAT_UH(vqrshrnb_uh, vqrshrnt_uh, DO_RSHRN_UH) | ||
95 | DO_VSHRN_SAT_SB(vqrshrunbb, vqrshruntb, DO_RSHRUN_B) | ||
96 | DO_VSHRN_SAT_SH(vqrshrunbh, vqrshrunth, DO_RSHRUN_H) | ||
97 | |||
98 | +#define DO_VMOVN(OP, TOP, ESIZE, TYPE, LESIZE, LTYPE) \ | ||
99 | + void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm) \ | ||
100 | + { \ | ||
101 | + LTYPE *m = vm; \ | ||
102 | + TYPE *d = vd; \ | ||
103 | + uint16_t mask = mve_element_mask(env); \ | ||
104 | + unsigned le; \ | ||
105 | + mask >>= ESIZE * TOP; \ | ||
106 | + for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \ | ||
107 | + mergemask(&d[H##ESIZE(le * 2 + TOP)], \ | ||
108 | + m[H##LESIZE(le)], mask); \ | ||
109 | + } \ | ||
110 | + mve_advance_vpt(env); \ | ||
111 | + } | ||
112 | + | ||
113 | +DO_VMOVN(vmovnbb, false, 1, uint8_t, 2, uint16_t) | ||
114 | +DO_VMOVN(vmovnbh, false, 2, uint16_t, 4, uint32_t) | ||
115 | +DO_VMOVN(vmovntb, true, 1, uint8_t, 2, uint16_t) | ||
116 | +DO_VMOVN(vmovnth, true, 2, uint16_t, 4, uint32_t) | ||
117 | + | ||
118 | +#define DO_VMOVN_SAT(OP, TOP, ESIZE, TYPE, LESIZE, LTYPE, FN) \ | ||
119 | + void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm) \ | ||
120 | + { \ | ||
121 | + LTYPE *m = vm; \ | ||
122 | + TYPE *d = vd; \ | ||
123 | + uint16_t mask = mve_element_mask(env); \ | ||
124 | + bool qc = false; \ | ||
125 | + unsigned le; \ | ||
126 | + mask >>= ESIZE * TOP; \ | ||
127 | + for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \ | ||
128 | + bool sat = false; \ | ||
129 | + TYPE r = FN(m[H##LESIZE(le)], &sat); \ | ||
130 | + mergemask(&d[H##ESIZE(le * 2 + TOP)], r, mask); \ | ||
131 | + qc |= sat & mask & 1; \ | ||
132 | + } \ | ||
133 | + if (qc) { \ | ||
134 | + env->vfp.qc[0] = qc; \ | ||
135 | + } \ | ||
136 | + mve_advance_vpt(env); \ | ||
137 | + } | ||
138 | + | ||
139 | +#define DO_VMOVN_SAT_UB(BOP, TOP, FN) \ | ||
140 | + DO_VMOVN_SAT(BOP, false, 1, uint8_t, 2, uint16_t, FN) \ | ||
141 | + DO_VMOVN_SAT(TOP, true, 1, uint8_t, 2, uint16_t, FN) | ||
142 | + | ||
143 | +#define DO_VMOVN_SAT_UH(BOP, TOP, FN) \ | ||
144 | + DO_VMOVN_SAT(BOP, false, 2, uint16_t, 4, uint32_t, FN) \ | ||
145 | + DO_VMOVN_SAT(TOP, true, 2, uint16_t, 4, uint32_t, FN) | ||
146 | + | ||
147 | +#define DO_VMOVN_SAT_SB(BOP, TOP, FN) \ | ||
148 | + DO_VMOVN_SAT(BOP, false, 1, int8_t, 2, int16_t, FN) \ | ||
149 | + DO_VMOVN_SAT(TOP, true, 1, int8_t, 2, int16_t, FN) | ||
150 | + | ||
151 | +#define DO_VMOVN_SAT_SH(BOP, TOP, FN) \ | ||
152 | + DO_VMOVN_SAT(BOP, false, 2, int16_t, 4, int32_t, FN) \ | ||
153 | + DO_VMOVN_SAT(TOP, true, 2, int16_t, 4, int32_t, FN) | ||
154 | + | ||
155 | +#define DO_VQMOVN_SB(N, SATP) \ | ||
156 | + do_sat_bhs((int64_t)(N), INT8_MIN, INT8_MAX, SATP) | ||
157 | +#define DO_VQMOVN_UB(N, SATP) \ | ||
158 | + do_sat_bhs((uint64_t)(N), 0, UINT8_MAX, SATP) | ||
159 | +#define DO_VQMOVUN_B(N, SATP) \ | ||
160 | + do_sat_bhs((int64_t)(N), 0, UINT8_MAX, SATP) | ||
161 | + | ||
162 | +#define DO_VQMOVN_SH(N, SATP) \ | ||
163 | + do_sat_bhs((int64_t)(N), INT16_MIN, INT16_MAX, SATP) | ||
164 | +#define DO_VQMOVN_UH(N, SATP) \ | ||
165 | + do_sat_bhs((uint64_t)(N), 0, UINT16_MAX, SATP) | ||
166 | +#define DO_VQMOVUN_H(N, SATP) \ | ||
167 | + do_sat_bhs((int64_t)(N), 0, UINT16_MAX, SATP) | ||
168 | + | ||
169 | +DO_VMOVN_SAT_SB(vqmovnbsb, vqmovntsb, DO_VQMOVN_SB) | ||
170 | +DO_VMOVN_SAT_SH(vqmovnbsh, vqmovntsh, DO_VQMOVN_SH) | ||
171 | +DO_VMOVN_SAT_UB(vqmovnbub, vqmovntub, DO_VQMOVN_UB) | ||
172 | +DO_VMOVN_SAT_UH(vqmovnbuh, vqmovntuh, DO_VQMOVN_UH) | ||
173 | +DO_VMOVN_SAT_SB(vqmovunbb, vqmovuntb, DO_VQMOVUN_B) | ||
174 | +DO_VMOVN_SAT_SH(vqmovunbh, vqmovunth, DO_VQMOVUN_H) | ||
175 | + | ||
176 | uint32_t HELPER(mve_vshlc)(CPUARMState *env, void *vd, uint32_t rdm, | ||
177 | uint32_t shift) | ||
178 | { | ||
179 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
180 | index XXXXXXX..XXXXXXX 100644 | ||
181 | --- a/target/arm/translate-mve.c | ||
182 | +++ b/target/arm/translate-mve.c | ||
183 | @@ -XXX,XX +XXX,XX @@ DO_1OP(VCLS, vcls) | ||
184 | DO_1OP(VABS, vabs) | ||
185 | DO_1OP(VNEG, vneg) | ||
186 | |||
187 | +/* Narrowing moves: only size 0 and 1 are valid */ | ||
188 | +#define DO_VMOVN(INSN, FN) \ | ||
189 | + static bool trans_##INSN(DisasContext *s, arg_1op *a) \ | ||
190 | + { \ | ||
191 | + static MVEGenOneOpFn * const fns[] = { \ | ||
192 | + gen_helper_mve_##FN##b, \ | ||
193 | + gen_helper_mve_##FN##h, \ | ||
194 | + NULL, \ | ||
195 | + NULL, \ | ||
196 | + }; \ | ||
197 | + return do_1op(s, a, fns[a->size]); \ | ||
198 | + } | ||
199 | + | ||
200 | +DO_VMOVN(VMOVNB, vmovnb) | ||
201 | +DO_VMOVN(VMOVNT, vmovnt) | ||
202 | +DO_VMOVN(VQMOVUNB, vqmovunb) | ||
203 | +DO_VMOVN(VQMOVUNT, vqmovunt) | ||
204 | +DO_VMOVN(VQMOVN_BS, vqmovnbs) | ||
205 | +DO_VMOVN(VQMOVN_TS, vqmovnts) | ||
206 | +DO_VMOVN(VQMOVN_BU, vqmovnbu) | ||
207 | +DO_VMOVN(VQMOVN_TU, vqmovntu) | ||
208 | + | ||
209 | static bool trans_VREV16(DisasContext *s, arg_1op *a) | ||
210 | { | ||
211 | static MVEGenOneOpFn * const fns[] = { | ||
212 | -- | ||
213 | 2.20.1 | ||
214 | |||
215 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE VMLADAV and VMLSLDAV insns. Like the VMLALDAV and | ||
2 | VMLSLDAV insns already implemented, these accumulate multiplied | ||
3 | vector elements; but they accumulate a 32-bit result rather than a | ||
4 | 64-bit one. | ||
5 | 1 | ||
6 | Note that these encodings overlap with what would be RdaHi=0b111 for | ||
7 | VMLALDAV, VMLSLDAV, VRMLALDAVH and VRMLSLDAVH. | ||
8 | |||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | --- | ||
12 | target/arm/helper-mve.h | 17 ++++++++++ | ||
13 | target/arm/mve.decode | 33 +++++++++++++++++--- | ||
14 | target/arm/mve_helper.c | 41 ++++++++++++++++++++++++ | ||
15 | target/arm/translate-mve.c | 64 ++++++++++++++++++++++++++++++++++++++ | ||
16 | 4 files changed, 150 insertions(+), 5 deletions(-) | ||
17 | |||
18 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/arm/helper-mve.h | ||
21 | +++ b/target/arm/helper-mve.h | ||
22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vrmlaldavhuw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
23 | DEF_HELPER_FLAGS_4(mve_vrmlsldavhsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
24 | DEF_HELPER_FLAGS_4(mve_vrmlsldavhxsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
25 | |||
26 | +DEF_HELPER_FLAGS_4(mve_vmladavsb, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
27 | +DEF_HELPER_FLAGS_4(mve_vmladavsh, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
28 | +DEF_HELPER_FLAGS_4(mve_vmladavsw, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
29 | +DEF_HELPER_FLAGS_4(mve_vmladavub, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
30 | +DEF_HELPER_FLAGS_4(mve_vmladavuh, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
31 | +DEF_HELPER_FLAGS_4(mve_vmladavuw, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
32 | +DEF_HELPER_FLAGS_4(mve_vmlsdavb, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
33 | +DEF_HELPER_FLAGS_4(mve_vmlsdavh, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
34 | +DEF_HELPER_FLAGS_4(mve_vmlsdavw, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
35 | + | ||
36 | +DEF_HELPER_FLAGS_4(mve_vmladavsxb, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
37 | +DEF_HELPER_FLAGS_4(mve_vmladavsxh, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
38 | +DEF_HELPER_FLAGS_4(mve_vmladavsxw, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
39 | +DEF_HELPER_FLAGS_4(mve_vmlsdavxb, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
40 | +DEF_HELPER_FLAGS_4(mve_vmlsdavxh, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
41 | +DEF_HELPER_FLAGS_4(mve_vmlsdavxw, TCG_CALL_NO_WG, i32, env, ptr, ptr, i32) | ||
42 | + | ||
43 | DEF_HELPER_FLAGS_3(mve_vaddvsb, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
44 | DEF_HELPER_FLAGS_3(mve_vaddvub, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
45 | DEF_HELPER_FLAGS_3(mve_vaddvsh, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
46 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/target/arm/mve.decode | ||
49 | +++ b/target/arm/mve.decode | ||
50 | @@ -XXX,XX +XXX,XX @@ VDUP 1110 1110 1 0 10 ... 0 .... 1011 . 0 0 1 0000 @vdup size=2 | ||
51 | %size_16 16:1 !function=plus_1 | ||
52 | |||
53 | &vmlaldav rdahi rdalo size qn qm x a | ||
54 | +&vmladav rda size qn qm x a | ||
55 | |||
56 | @vmlaldav .... .... . ... ... . ... x:1 .... .. a:1 . qm:3 . \ | ||
57 | qn=%qn rdahi=%rdahi rdalo=%rdalo size=%size_16 &vmlaldav | ||
58 | @vmlaldav_nosz .... .... . ... ... . ... x:1 .... .. a:1 . qm:3 . \ | ||
59 | qn=%qn rdahi=%rdahi rdalo=%rdalo size=0 &vmlaldav | ||
60 | -VMLALDAV_S 1110 1110 1 ... ... . ... . 1110 . 0 . 0 ... 0 @vmlaldav | ||
61 | -VMLALDAV_U 1111 1110 1 ... ... . ... . 1110 . 0 . 0 ... 0 @vmlaldav | ||
62 | +@vmladav .... .... .... ... . ... x:1 .... . . a:1 . qm:3 . \ | ||
63 | + qn=%qn rda=%rdalo size=%size_16 &vmladav | ||
64 | +@vmladav_nosz .... .... .... ... . ... x:1 .... . . a:1 . qm:3 . \ | ||
65 | + qn=%qn rda=%rdalo size=0 &vmladav | ||
66 | |||
67 | -VMLSLDAV 1110 1110 1 ... ... . ... . 1110 . 0 . 0 ... 1 @vmlaldav | ||
68 | +{ | ||
69 | + VMLADAV_S 1110 1110 1111 ... . ... . 1110 . 0 . 0 ... 0 @vmladav | ||
70 | + VMLALDAV_S 1110 1110 1 ... ... . ... . 1110 . 0 . 0 ... 0 @vmlaldav | ||
71 | +} | ||
72 | +{ | ||
73 | + VMLADAV_U 1111 1110 1111 ... . ... . 1110 . 0 . 0 ... 0 @vmladav | ||
74 | + VMLALDAV_U 1111 1110 1 ... ... . ... . 1110 . 0 . 0 ... 0 @vmlaldav | ||
75 | +} | ||
76 | + | ||
77 | +{ | ||
78 | + VMLSDAV 1110 1110 1111 ... . ... . 1110 . 0 . 0 ... 1 @vmladav | ||
79 | + VMLSLDAV 1110 1110 1 ... ... . ... . 1110 . 0 . 0 ... 1 @vmlaldav | ||
80 | +} | ||
81 | + | ||
82 | +{ | ||
83 | + VMLSDAV 1111 1110 1111 ... 0 ... . 1110 . 0 . 0 ... 1 @vmladav_nosz | ||
84 | + VRMLSLDAVH 1111 1110 1 ... ... 0 ... . 1110 . 0 . 0 ... 1 @vmlaldav_nosz | ||
85 | +} | ||
86 | + | ||
87 | +VMLADAV_S 1110 1110 1111 ... 0 ... . 1111 . 0 . 0 ... 1 @vmladav_nosz | ||
88 | +VMLADAV_U 1111 1110 1111 ... 0 ... . 1111 . 0 . 0 ... 1 @vmladav_nosz | ||
89 | |||
90 | { | ||
91 | VMAXV_S 1110 1110 1110 .. 10 .... 1111 0 0 . 0 ... 0 @vmaxv | ||
92 | VMINV_S 1110 1110 1110 .. 10 .... 1111 1 0 . 0 ... 0 @vmaxv | ||
93 | VMAXAV 1110 1110 1110 .. 00 .... 1111 0 0 . 0 ... 0 @vmaxv | ||
94 | VMINAV 1110 1110 1110 .. 00 .... 1111 1 0 . 0 ... 0 @vmaxv | ||
95 | + VMLADAV_S 1110 1110 1111 ... 0 ... . 1111 . 0 . 0 ... 0 @vmladav_nosz | ||
96 | VRMLALDAVH_S 1110 1110 1 ... ... 0 ... . 1111 . 0 . 0 ... 0 @vmlaldav_nosz | ||
97 | } | ||
98 | |||
99 | { | ||
100 | VMAXV_U 1111 1110 1110 .. 10 .... 1111 0 0 . 0 ... 0 @vmaxv | ||
101 | VMINV_U 1111 1110 1110 .. 10 .... 1111 1 0 . 0 ... 0 @vmaxv | ||
102 | + VMLADAV_U 1111 1110 1111 ... 0 ... . 1111 . 0 . 0 ... 0 @vmladav_nosz | ||
103 | VRMLALDAVH_U 1111 1110 1 ... ... 0 ... . 1111 . 0 . 0 ... 0 @vmlaldav_nosz | ||
104 | } | ||
105 | |||
106 | -VRMLSLDAVH 1111 1110 1 ... ... 0 ... . 1110 . 0 . 0 ... 1 @vmlaldav_nosz | ||
107 | - | ||
108 | # Scalar operations | ||
109 | |||
110 | VADD_scalar 1110 1110 0 . .. ... 1 ... 0 1111 . 100 .... @2scalar | ||
111 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
112 | index XXXXXXX..XXXXXXX 100644 | ||
113 | --- a/target/arm/mve_helper.c | ||
114 | +++ b/target/arm/mve_helper.c | ||
115 | @@ -XXX,XX +XXX,XX @@ DO_LDAV(vmlsldavxsh, 2, int16_t, true, +=, -=) | ||
116 | DO_LDAV(vmlsldavsw, 4, int32_t, false, +=, -=) | ||
117 | DO_LDAV(vmlsldavxsw, 4, int32_t, true, +=, -=) | ||
118 | |||
119 | +/* | ||
120 | + * Multiply add dual accumulate ops | ||
121 | + */ | ||
122 | +#define DO_DAV(OP, ESIZE, TYPE, XCHG, EVENACC, ODDACC) \ | ||
123 | + uint32_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vn, \ | ||
124 | + void *vm, uint32_t a) \ | ||
125 | + { \ | ||
126 | + uint16_t mask = mve_element_mask(env); \ | ||
127 | + unsigned e; \ | ||
128 | + TYPE *n = vn, *m = vm; \ | ||
129 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
130 | + if (mask & 1) { \ | ||
131 | + if (e & 1) { \ | ||
132 | + a ODDACC \ | ||
133 | + n[H##ESIZE(e - 1 * XCHG)] * m[H##ESIZE(e)]; \ | ||
134 | + } else { \ | ||
135 | + a EVENACC \ | ||
136 | + n[H##ESIZE(e + 1 * XCHG)] * m[H##ESIZE(e)]; \ | ||
137 | + } \ | ||
138 | + } \ | ||
139 | + } \ | ||
140 | + mve_advance_vpt(env); \ | ||
141 | + return a; \ | ||
142 | + } | ||
143 | + | ||
144 | +#define DO_DAV_S(INSN, XCHG, EVENACC, ODDACC) \ | ||
145 | + DO_DAV(INSN##b, 1, int8_t, XCHG, EVENACC, ODDACC) \ | ||
146 | + DO_DAV(INSN##h, 2, int16_t, XCHG, EVENACC, ODDACC) \ | ||
147 | + DO_DAV(INSN##w, 4, int32_t, XCHG, EVENACC, ODDACC) | ||
148 | + | ||
149 | +#define DO_DAV_U(INSN, XCHG, EVENACC, ODDACC) \ | ||
150 | + DO_DAV(INSN##b, 1, uint8_t, XCHG, EVENACC, ODDACC) \ | ||
151 | + DO_DAV(INSN##h, 2, uint16_t, XCHG, EVENACC, ODDACC) \ | ||
152 | + DO_DAV(INSN##w, 4, uint32_t, XCHG, EVENACC, ODDACC) | ||
153 | + | ||
154 | +DO_DAV_S(vmladavs, false, +=, +=) | ||
155 | +DO_DAV_U(vmladavu, false, +=, +=) | ||
156 | +DO_DAV_S(vmlsdav, false, +=, -=) | ||
157 | +DO_DAV_S(vmladavsx, true, +=, +=) | ||
158 | +DO_DAV_S(vmlsdavx, true, +=, -=) | ||
159 | + | ||
160 | /* | ||
161 | * Rounding multiply add long dual accumulate high. In the pseudocode | ||
162 | * this is implemented with a 72-bit internal accumulator value of which | ||
163 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
164 | index XXXXXXX..XXXXXXX 100644 | ||
165 | --- a/target/arm/translate-mve.c | ||
166 | +++ b/target/arm/translate-mve.c | ||
167 | @@ -XXX,XX +XXX,XX @@ typedef void MVEGenVIWDUPFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32, TCGv_i32, TC | ||
168 | typedef void MVEGenCmpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
169 | typedef void MVEGenScalarCmpFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
170 | typedef void MVEGenVABAVFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
171 | +typedef void MVEGenDualAccOpFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
172 | |||
173 | /* Return the offset of a Qn register (same semantics as aa32_vfp_qreg()) */ | ||
174 | static inline long mve_qreg_offset(unsigned reg) | ||
175 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRMLSLDAVH(DisasContext *s, arg_vmlaldav *a) | ||
176 | return do_long_dual_acc(s, a, fns[a->x]); | ||
177 | } | ||
178 | |||
179 | +static bool do_dual_acc(DisasContext *s, arg_vmladav *a, MVEGenDualAccOpFn *fn) | ||
180 | +{ | ||
181 | + TCGv_ptr qn, qm; | ||
182 | + TCGv_i32 rda; | ||
183 | + | ||
184 | + if (!dc_isar_feature(aa32_mve, s) || | ||
185 | + !mve_check_qreg_bank(s, a->qn) || | ||
186 | + !fn) { | ||
187 | + return false; | ||
188 | + } | ||
189 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
190 | + return true; | ||
191 | + } | ||
192 | + | ||
193 | + qn = mve_qreg_ptr(a->qn); | ||
194 | + qm = mve_qreg_ptr(a->qm); | ||
195 | + | ||
196 | + /* | ||
197 | + * This insn is subject to beat-wise execution. Partial execution | ||
198 | + * of an A=0 (no-accumulate) insn which does not execute the first | ||
199 | + * beat must start with the current rda value, not 0. | ||
200 | + */ | ||
201 | + if (a->a || mve_skip_first_beat(s)) { | ||
202 | + rda = load_reg(s, a->rda); | ||
203 | + } else { | ||
204 | + rda = tcg_const_i32(0); | ||
205 | + } | ||
206 | + | ||
207 | + fn(rda, cpu_env, qn, qm, rda); | ||
208 | + store_reg(s, a->rda, rda); | ||
209 | + tcg_temp_free_ptr(qn); | ||
210 | + tcg_temp_free_ptr(qm); | ||
211 | + | ||
212 | + mve_update_eci(s); | ||
213 | + return true; | ||
214 | +} | ||
215 | + | ||
216 | +#define DO_DUAL_ACC(INSN, FN) \ | ||
217 | + static bool trans_##INSN(DisasContext *s, arg_vmladav *a) \ | ||
218 | + { \ | ||
219 | + static MVEGenDualAccOpFn * const fns[4][2] = { \ | ||
220 | + { gen_helper_mve_##FN##b, gen_helper_mve_##FN##xb }, \ | ||
221 | + { gen_helper_mve_##FN##h, gen_helper_mve_##FN##xh }, \ | ||
222 | + { gen_helper_mve_##FN##w, gen_helper_mve_##FN##xw }, \ | ||
223 | + { NULL, NULL }, \ | ||
224 | + }; \ | ||
225 | + return do_dual_acc(s, a, fns[a->size][a->x]); \ | ||
226 | + } | ||
227 | + | ||
228 | +DO_DUAL_ACC(VMLADAV_S, vmladavs) | ||
229 | +DO_DUAL_ACC(VMLSDAV, vmlsdav) | ||
230 | + | ||
231 | +static bool trans_VMLADAV_U(DisasContext *s, arg_vmladav *a) | ||
232 | +{ | ||
233 | + static MVEGenDualAccOpFn * const fns[4][2] = { | ||
234 | + { gen_helper_mve_vmladavub, NULL }, | ||
235 | + { gen_helper_mve_vmladavuh, NULL }, | ||
236 | + { gen_helper_mve_vmladavuw, NULL }, | ||
237 | + { NULL, NULL }, | ||
238 | + }; | ||
239 | + return do_dual_acc(s, a, fns[a->size][a->x]); | ||
240 | +} | ||
241 | + | ||
242 | static void gen_vpst(DisasContext *s, uint32_t mask) | ||
243 | { | ||
244 | /* | ||
245 | -- | ||
246 | 2.20.1 | ||
247 | |||
248 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE VMLA insn, which multiplies a vector by a scalar | ||
2 | and accumulates into another vector. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | target/arm/helper-mve.h | 4 ++++ | ||
8 | target/arm/mve.decode | 1 + | ||
9 | target/arm/mve_helper.c | 5 +++++ | ||
10 | target/arm/translate-mve.c | 1 + | ||
11 | 4 files changed, 11 insertions(+) | ||
12 | |||
13 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/helper-mve.h | ||
16 | +++ b/target/arm/helper-mve.h | ||
17 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqdmullb_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i3 | ||
18 | DEF_HELPER_FLAGS_4(mve_vqdmullt_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
19 | DEF_HELPER_FLAGS_4(mve_vqdmullt_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
20 | |||
21 | +DEF_HELPER_FLAGS_4(mve_vmlab, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
22 | +DEF_HELPER_FLAGS_4(mve_vmlah, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
23 | +DEF_HELPER_FLAGS_4(mve_vmlaw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
24 | + | ||
25 | DEF_HELPER_FLAGS_4(mve_vmlasb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
26 | DEF_HELPER_FLAGS_4(mve_vmlash, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
27 | DEF_HELPER_FLAGS_4(mve_vmlasw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
28 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/target/arm/mve.decode | ||
31 | +++ b/target/arm/mve.decode | ||
32 | @@ -XXX,XX +XXX,XX @@ VQDMULH_scalar 1110 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
33 | VQRDMULH_scalar 1111 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
34 | |||
35 | # The U bit (28) is don't-care because it does not affect the result | ||
36 | +VMLA 111- 1110 0 . .. ... 1 ... 0 1110 . 100 .... @2scalar | ||
37 | VMLAS 111- 1110 0 . .. ... 1 ... 1 1110 . 100 .... @2scalar | ||
38 | |||
39 | # Vector add across vector | ||
40 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/target/arm/mve_helper.c | ||
43 | +++ b/target/arm/mve_helper.c | ||
44 | @@ -XXX,XX +XXX,XX @@ DO_2OP_SAT_SCALAR(vqrdmulh_scalarb, 1, int8_t, DO_QRDMULH_B) | ||
45 | DO_2OP_SAT_SCALAR(vqrdmulh_scalarh, 2, int16_t, DO_QRDMULH_H) | ||
46 | DO_2OP_SAT_SCALAR(vqrdmulh_scalarw, 4, int32_t, DO_QRDMULH_W) | ||
47 | |||
48 | +/* Vector by scalar plus vector */ | ||
49 | +#define DO_VMLA(D, N, M) ((N) * (M) + (D)) | ||
50 | + | ||
51 | +DO_2OP_ACC_SCALAR_U(vmla, DO_VMLA) | ||
52 | + | ||
53 | /* Vector by vector plus scalar */ | ||
54 | #define DO_VMLAS(D, N, M) ((N) * (D) + (M)) | ||
55 | |||
56 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/target/arm/translate-mve.c | ||
59 | +++ b/target/arm/translate-mve.c | ||
60 | @@ -XXX,XX +XXX,XX @@ DO_2OP_SCALAR(VQSUB_U_scalar, vqsubu_scalar) | ||
61 | DO_2OP_SCALAR(VQDMULH_scalar, vqdmulh_scalar) | ||
62 | DO_2OP_SCALAR(VQRDMULH_scalar, vqrdmulh_scalar) | ||
63 | DO_2OP_SCALAR(VBRSR, vbrsr) | ||
64 | +DO_2OP_SCALAR(VMLA, vmla) | ||
65 | DO_2OP_SCALAR(VMLAS, vmlas) | ||
66 | |||
67 | static bool trans_VQDMULLB_scalar(DisasContext *s, arg_2scalar *a) | ||
68 | -- | ||
69 | 2.20.1 | ||
70 | |||
71 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE 1-operand saturating operations VQABS and VQNEG. | ||
2 | 1 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | --- | ||
6 | target/arm/helper-mve.h | 8 ++++++++ | ||
7 | target/arm/mve.decode | 3 +++ | ||
8 | target/arm/mve_helper.c | 37 +++++++++++++++++++++++++++++++++++++ | ||
9 | target/arm/translate-mve.c | 2 ++ | ||
10 | 4 files changed, 50 insertions(+) | ||
11 | |||
12 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/arm/helper-mve.h | ||
15 | +++ b/target/arm/helper-mve.h | ||
16 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vnegw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
17 | DEF_HELPER_FLAGS_3(mve_vfnegh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
18 | DEF_HELPER_FLAGS_3(mve_vfnegs, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
19 | |||
20 | +DEF_HELPER_FLAGS_3(mve_vqabsb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
21 | +DEF_HELPER_FLAGS_3(mve_vqabsh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
22 | +DEF_HELPER_FLAGS_3(mve_vqabsw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
23 | + | ||
24 | +DEF_HELPER_FLAGS_3(mve_vqnegb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
25 | +DEF_HELPER_FLAGS_3(mve_vqnegh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
26 | +DEF_HELPER_FLAGS_3(mve_vqnegw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
27 | + | ||
28 | DEF_HELPER_FLAGS_3(mve_vmovnbb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
29 | DEF_HELPER_FLAGS_3(mve_vmovnbh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
30 | DEF_HELPER_FLAGS_3(mve_vmovntb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
31 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/target/arm/mve.decode | ||
34 | +++ b/target/arm/mve.decode | ||
35 | @@ -XXX,XX +XXX,XX @@ VABS_fp 1111 1111 1 . 11 .. 01 ... 0 0111 01 . 0 ... 0 @1op | ||
36 | VNEG 1111 1111 1 . 11 .. 01 ... 0 0011 11 . 0 ... 0 @1op | ||
37 | VNEG_fp 1111 1111 1 . 11 .. 01 ... 0 0111 11 . 0 ... 0 @1op | ||
38 | |||
39 | +VQABS 1111 1111 1 . 11 .. 00 ... 0 0111 01 . 0 ... 0 @1op | ||
40 | +VQNEG 1111 1111 1 . 11 .. 00 ... 0 0111 11 . 0 ... 0 @1op | ||
41 | + | ||
42 | &vdup qd rt size | ||
43 | # Qd is in the fields usually named Qn | ||
44 | @vdup .... .... . . .. ... . rt:4 .... . . . . .... qd=%qn &vdup | ||
45 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/target/arm/mve_helper.c | ||
48 | +++ b/target/arm/mve_helper.c | ||
49 | @@ -XXX,XX +XXX,XX @@ void HELPER(mve_vpsel)(CPUARMState *env, void *vd, void *vn, void *vm) | ||
50 | } | ||
51 | mve_advance_vpt(env); | ||
52 | } | ||
53 | + | ||
54 | +#define DO_1OP_SAT(OP, ESIZE, TYPE, FN) \ | ||
55 | + void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm) \ | ||
56 | + { \ | ||
57 | + TYPE *d = vd, *m = vm; \ | ||
58 | + uint16_t mask = mve_element_mask(env); \ | ||
59 | + unsigned e; \ | ||
60 | + bool qc = false; \ | ||
61 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
62 | + bool sat = false; \ | ||
63 | + mergemask(&d[H##ESIZE(e)], FN(m[H##ESIZE(e)], &sat), mask); \ | ||
64 | + qc |= sat & mask & 1; \ | ||
65 | + } \ | ||
66 | + if (qc) { \ | ||
67 | + env->vfp.qc[0] = qc; \ | ||
68 | + } \ | ||
69 | + mve_advance_vpt(env); \ | ||
70 | + } | ||
71 | + | ||
72 | +#define DO_VQABS_B(N, SATP) \ | ||
73 | + do_sat_bhs(DO_ABS((int64_t)N), INT8_MIN, INT8_MAX, SATP) | ||
74 | +#define DO_VQABS_H(N, SATP) \ | ||
75 | + do_sat_bhs(DO_ABS((int64_t)N), INT16_MIN, INT16_MAX, SATP) | ||
76 | +#define DO_VQABS_W(N, SATP) \ | ||
77 | + do_sat_bhs(DO_ABS((int64_t)N), INT32_MIN, INT32_MAX, SATP) | ||
78 | + | ||
79 | +#define DO_VQNEG_B(N, SATP) do_sat_bhs(-(int64_t)N, INT8_MIN, INT8_MAX, SATP) | ||
80 | +#define DO_VQNEG_H(N, SATP) do_sat_bhs(-(int64_t)N, INT16_MIN, INT16_MAX, SATP) | ||
81 | +#define DO_VQNEG_W(N, SATP) do_sat_bhs(-(int64_t)N, INT32_MIN, INT32_MAX, SATP) | ||
82 | + | ||
83 | +DO_1OP_SAT(vqabsb, 1, int8_t, DO_VQABS_B) | ||
84 | +DO_1OP_SAT(vqabsh, 2, int16_t, DO_VQABS_H) | ||
85 | +DO_1OP_SAT(vqabsw, 4, int32_t, DO_VQABS_W) | ||
86 | + | ||
87 | +DO_1OP_SAT(vqnegb, 1, int8_t, DO_VQNEG_B) | ||
88 | +DO_1OP_SAT(vqnegh, 2, int16_t, DO_VQNEG_H) | ||
89 | +DO_1OP_SAT(vqnegw, 4, int32_t, DO_VQNEG_W) | ||
90 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
91 | index XXXXXXX..XXXXXXX 100644 | ||
92 | --- a/target/arm/translate-mve.c | ||
93 | +++ b/target/arm/translate-mve.c | ||
94 | @@ -XXX,XX +XXX,XX @@ DO_1OP(VCLZ, vclz) | ||
95 | DO_1OP(VCLS, vcls) | ||
96 | DO_1OP(VABS, vabs) | ||
97 | DO_1OP(VNEG, vneg) | ||
98 | +DO_1OP(VQABS, vqabs) | ||
99 | +DO_1OP(VQNEG, vqneg) | ||
100 | |||
101 | /* Narrowing moves: only size 0 and 1 are valid */ | ||
102 | #define DO_VMOVN(INSN, FN) \ | ||
103 | -- | ||
104 | 2.20.1 | ||
105 | |||
106 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE VMOV forms that move data between 2 general-purpose | ||
2 | registers and 2 32-bit lanes in a vector register. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | target/arm/translate-a32.h | 1 + | ||
8 | target/arm/mve.decode | 4 ++ | ||
9 | target/arm/translate-mve.c | 85 ++++++++++++++++++++++++++++++++++++++ | ||
10 | target/arm/translate-vfp.c | 2 +- | ||
11 | 4 files changed, 91 insertions(+), 1 deletion(-) | ||
12 | |||
13 | diff --git a/target/arm/translate-a32.h b/target/arm/translate-a32.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/translate-a32.h | ||
16 | +++ b/target/arm/translate-a32.h | ||
17 | @@ -XXX,XX +XXX,XX @@ void gen_rev16(TCGv_i32 dest, TCGv_i32 var); | ||
18 | void clear_eci_state(DisasContext *s); | ||
19 | bool mve_eci_check(DisasContext *s); | ||
20 | void mve_update_and_store_eci(DisasContext *s); | ||
21 | +bool mve_skip_vmov(DisasContext *s, int vn, int index, int size); | ||
22 | |||
23 | static inline TCGv_i32 load_cpu_offset(int offset) | ||
24 | { | ||
25 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/target/arm/mve.decode | ||
28 | +++ b/target/arm/mve.decode | ||
29 | @@ -XXX,XX +XXX,XX @@ VLDR_VSTR 1110110 1 a:1 . w:1 . .... ... 111101 ....... @vldr_vstr \ | ||
30 | VLDR_VSTR 1110110 1 a:1 . w:1 . .... ... 111110 ....... @vldr_vstr \ | ||
31 | size=2 p=1 | ||
32 | |||
33 | +# Moves between 2 32-bit vector lanes and 2 general purpose registers | ||
34 | +VMOV_to_2gp 1110 1100 0 . 00 rt2:4 ... 0 1111 000 idx:1 rt:4 qd=%qd | ||
35 | +VMOV_from_2gp 1110 1100 0 . 01 rt2:4 ... 0 1111 000 idx:1 rt:4 qd=%qd | ||
36 | + | ||
37 | # Vector 2-op | ||
38 | VAND 1110 1111 0 . 00 ... 0 ... 0 0001 . 1 . 1 ... 0 @2op_nosz | ||
39 | VBIC 1110 1111 0 . 01 ... 0 ... 0 0001 . 1 . 1 ... 0 @2op_nosz | ||
40 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/target/arm/translate-mve.c | ||
43 | +++ b/target/arm/translate-mve.c | ||
44 | @@ -XXX,XX +XXX,XX @@ static bool do_vabav(DisasContext *s, arg_vabav *a, MVEGenVABAVFn *fn) | ||
45 | |||
46 | DO_VABAV(VABAV_S, vabavs) | ||
47 | DO_VABAV(VABAV_U, vabavu) | ||
48 | + | ||
49 | +static bool trans_VMOV_to_2gp(DisasContext *s, arg_VMOV_to_2gp *a) | ||
50 | +{ | ||
51 | + /* | ||
52 | + * VMOV two 32-bit vector lanes to two general-purpose registers. | ||
53 | + * This insn is not predicated but it is subject to beat-wise | ||
54 | + * execution if it is not in an IT block. For us this means | ||
55 | + * only that if PSR.ECI says we should not be executing the beat | ||
56 | + * corresponding to the lane of the vector register being accessed | ||
57 | + * then we should skip perfoming the move, and that we need to do | ||
58 | + * the usual check for bad ECI state and advance of ECI state. | ||
59 | + * (If PSR.ECI is non-zero then we cannot be in an IT block.) | ||
60 | + */ | ||
61 | + TCGv_i32 tmp; | ||
62 | + int vd; | ||
63 | + | ||
64 | + if (!dc_isar_feature(aa32_mve, s) || !mve_check_qreg_bank(s, a->qd) || | ||
65 | + a->rt == 13 || a->rt == 15 || a->rt2 == 13 || a->rt2 == 15 || | ||
66 | + a->rt == a->rt2) { | ||
67 | + /* Rt/Rt2 cases are UNPREDICTABLE */ | ||
68 | + return false; | ||
69 | + } | ||
70 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
71 | + return true; | ||
72 | + } | ||
73 | + | ||
74 | + /* Convert Qreg index to Dreg for read_neon_element32() etc */ | ||
75 | + vd = a->qd * 2; | ||
76 | + | ||
77 | + if (!mve_skip_vmov(s, vd, a->idx, MO_32)) { | ||
78 | + tmp = tcg_temp_new_i32(); | ||
79 | + read_neon_element32(tmp, vd, a->idx, MO_32); | ||
80 | + store_reg(s, a->rt, tmp); | ||
81 | + } | ||
82 | + if (!mve_skip_vmov(s, vd + 1, a->idx, MO_32)) { | ||
83 | + tmp = tcg_temp_new_i32(); | ||
84 | + read_neon_element32(tmp, vd + 1, a->idx, MO_32); | ||
85 | + store_reg(s, a->rt2, tmp); | ||
86 | + } | ||
87 | + | ||
88 | + mve_update_and_store_eci(s); | ||
89 | + return true; | ||
90 | +} | ||
91 | + | ||
92 | +static bool trans_VMOV_from_2gp(DisasContext *s, arg_VMOV_to_2gp *a) | ||
93 | +{ | ||
94 | + /* | ||
95 | + * VMOV two general-purpose registers to two 32-bit vector lanes. | ||
96 | + * This insn is not predicated but it is subject to beat-wise | ||
97 | + * execution if it is not in an IT block. For us this means | ||
98 | + * only that if PSR.ECI says we should not be executing the beat | ||
99 | + * corresponding to the lane of the vector register being accessed | ||
100 | + * then we should skip perfoming the move, and that we need to do | ||
101 | + * the usual check for bad ECI state and advance of ECI state. | ||
102 | + * (If PSR.ECI is non-zero then we cannot be in an IT block.) | ||
103 | + */ | ||
104 | + TCGv_i32 tmp; | ||
105 | + int vd; | ||
106 | + | ||
107 | + if (!dc_isar_feature(aa32_mve, s) || !mve_check_qreg_bank(s, a->qd) || | ||
108 | + a->rt == 13 || a->rt == 15 || a->rt2 == 13 || a->rt2 == 15) { | ||
109 | + /* Rt/Rt2 cases are UNPREDICTABLE */ | ||
110 | + return false; | ||
111 | + } | ||
112 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
113 | + return true; | ||
114 | + } | ||
115 | + | ||
116 | + /* Convert Qreg idx to Dreg for read_neon_element32() etc */ | ||
117 | + vd = a->qd * 2; | ||
118 | + | ||
119 | + if (!mve_skip_vmov(s, vd, a->idx, MO_32)) { | ||
120 | + tmp = load_reg(s, a->rt); | ||
121 | + write_neon_element32(tmp, vd, a->idx, MO_32); | ||
122 | + tcg_temp_free_i32(tmp); | ||
123 | + } | ||
124 | + if (!mve_skip_vmov(s, vd + 1, a->idx, MO_32)) { | ||
125 | + tmp = load_reg(s, a->rt2); | ||
126 | + write_neon_element32(tmp, vd + 1, a->idx, MO_32); | ||
127 | + tcg_temp_free_i32(tmp); | ||
128 | + } | ||
129 | + | ||
130 | + mve_update_and_store_eci(s); | ||
131 | + return true; | ||
132 | +} | ||
133 | diff --git a/target/arm/translate-vfp.c b/target/arm/translate-vfp.c | ||
134 | index XXXXXXX..XXXXXXX 100644 | ||
135 | --- a/target/arm/translate-vfp.c | ||
136 | +++ b/target/arm/translate-vfp.c | ||
137 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT(DisasContext *s, arg_VCVT *a) | ||
138 | return true; | ||
139 | } | ||
140 | |||
141 | -static bool mve_skip_vmov(DisasContext *s, int vn, int index, int size) | ||
142 | +bool mve_skip_vmov(DisasContext *s, int vn, int index, int size) | ||
143 | { | ||
144 | /* | ||
145 | * In a CPU with MVE, the VMOV (vector lane to general-purpose register) | ||
146 | -- | ||
147 | 2.20.1 | ||
148 | |||
149 | diff view generated by jsdifflib |
1 | Implement the MVE VPNOT insn, which inverts the bits in VPR.P0 | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | (subject to both predication and to beatwise execution). | ||
3 | 2 | ||
3 | Add the aa64 predicate for detecting RAS support from id registers. | ||
4 | We already have the aa32 version from the M-profile work. | ||
5 | Add the 'any' predicate for testing both aa64 and aa32. | ||
6 | |||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20220501055028.646596-34-richard.henderson@linaro.org | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | 11 | --- |
7 | target/arm/helper-mve.h | 1 + | 12 | target/arm/cpu.h | 10 ++++++++++ |
8 | target/arm/mve.decode | 1 + | 13 | 1 file changed, 10 insertions(+) |
9 | target/arm/mve_helper.c | 17 +++++++++++++++++ | ||
10 | target/arm/translate-mve.c | 19 +++++++++++++++++++ | ||
11 | 4 files changed, 38 insertions(+) | ||
12 | 14 | ||
13 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 15 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
14 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/helper-mve.h | 17 | --- a/target/arm/cpu.h |
16 | +++ b/target/arm/helper-mve.h | 18 | +++ b/target/arm/cpu.h |
17 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vorn, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 19 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_aa32_el1(const ARMISARegisters *id) |
18 | DEF_HELPER_FLAGS_4(mve_veor, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 20 | return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, EL1) >= 2; |
19 | |||
20 | DEF_HELPER_FLAGS_4(mve_vpsel, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
21 | +DEF_HELPER_FLAGS_1(mve_vpnot, TCG_CALL_NO_WG, void, env) | ||
22 | |||
23 | DEF_HELPER_FLAGS_4(mve_vaddb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
24 | DEF_HELPER_FLAGS_4(mve_vaddh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
25 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/target/arm/mve.decode | ||
28 | +++ b/target/arm/mve.decode | ||
29 | @@ -XXX,XX +XXX,XX @@ VCMPGT 1111 1110 0 . .. ... 1 ... 1 1111 0 0 . 0 ... 1 @vcmp | ||
30 | VCMPLE 1111 1110 0 . .. ... 1 ... 1 1111 1 0 . 0 ... 1 @vcmp | ||
31 | |||
32 | { | ||
33 | + VPNOT 1111 1110 0 0 11 000 1 000 0 1111 0100 1101 | ||
34 | VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13 | ||
35 | VCMPEQ_scalar 1111 1110 0 . .. ... 1 ... 0 1111 0 1 0 0 .... @vcmp_scalar | ||
36 | } | 21 | } |
37 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | 22 | |
38 | index XXXXXXX..XXXXXXX 100644 | 23 | +static inline bool isar_feature_aa64_ras(const ARMISARegisters *id) |
39 | --- a/target/arm/mve_helper.c | ||
40 | +++ b/target/arm/mve_helper.c | ||
41 | @@ -XXX,XX +XXX,XX @@ void HELPER(mve_vpsel)(CPUARMState *env, void *vd, void *vn, void *vm) | ||
42 | mve_advance_vpt(env); | ||
43 | } | ||
44 | |||
45 | +void HELPER(mve_vpnot)(CPUARMState *env) | ||
46 | +{ | 24 | +{ |
47 | + /* | 25 | + return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, RAS) != 0; |
48 | + * P0 bits for unexecuted beats (where eci_mask is 0) are unchanged. | ||
49 | + * P0 bits for predicated lanes in executed bits (where mask is 0) are 0. | ||
50 | + * P0 bits otherwise are inverted. | ||
51 | + * (This is the same logic as VCMP.) | ||
52 | + * This insn is itself subject to predication and to beat-wise execution, | ||
53 | + * and after it executes VPT state advances in the usual way. | ||
54 | + */ | ||
55 | + uint16_t mask = mve_element_mask(env); | ||
56 | + uint16_t eci_mask = mve_eci_mask(env); | ||
57 | + uint16_t beatpred = ~env->v7m.vpr & mask; | ||
58 | + env->v7m.vpr = (env->v7m.vpr & ~(uint32_t)eci_mask) | (beatpred & eci_mask); | ||
59 | + mve_advance_vpt(env); | ||
60 | +} | 26 | +} |
61 | + | 27 | + |
62 | #define DO_1OP_SAT(OP, ESIZE, TYPE, FN) \ | 28 | static inline bool isar_feature_aa64_sve(const ARMISARegisters *id) |
63 | void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm) \ | 29 | { |
64 | { \ | 30 | return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, SVE) != 0; |
65 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | 31 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_any_debugv8p2(const ARMISARegisters *id) |
66 | index XXXXXXX..XXXXXXX 100644 | 32 | return isar_feature_aa64_debugv8p2(id) || isar_feature_aa32_debugv8p2(id); |
67 | --- a/target/arm/translate-mve.c | ||
68 | +++ b/target/arm/translate-mve.c | ||
69 | @@ -XXX,XX +XXX,XX @@ static bool trans_VPST(DisasContext *s, arg_VPST *a) | ||
70 | return true; | ||
71 | } | 33 | } |
72 | 34 | ||
73 | +static bool trans_VPNOT(DisasContext *s, arg_VPNOT *a) | 35 | +static inline bool isar_feature_any_ras(const ARMISARegisters *id) |
74 | +{ | 36 | +{ |
75 | + /* | 37 | + return isar_feature_aa64_ras(id) || isar_feature_aa32_ras(id); |
76 | + * Invert the predicate in VPR.P0. We have call out to | ||
77 | + * a helper because this insn itself is beatwise and can | ||
78 | + * be predicated. | ||
79 | + */ | ||
80 | + if (!dc_isar_feature(aa32_mve, s)) { | ||
81 | + return false; | ||
82 | + } | ||
83 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
84 | + return true; | ||
85 | + } | ||
86 | + | ||
87 | + gen_helper_mve_vpnot(cpu_env); | ||
88 | + mve_update_eci(s); | ||
89 | + return true; | ||
90 | +} | 38 | +} |
91 | + | 39 | + |
92 | static bool trans_VADDV(DisasContext *s, arg_VADDV *a) | 40 | /* |
93 | { | 41 | * Forward to the above feature tests given an ARMCPU pointer. |
94 | /* VADDV: vector add across vector */ | 42 | */ |
95 | -- | 43 | -- |
96 | 2.20.1 | 44 | 2.25.1 |
97 | |||
98 | diff view generated by jsdifflib |
1 | From: Jan Luebbe <jlu@pengutronix.de> | 1 | From: Alex Zuepke <alex.zuepke@tum.de> |
---|---|---|---|
2 | 2 | ||
3 | Break events are currently only handled by chardev/char-serial.c, so we | 3 | The ARMv8 manual defines that PMUSERENR_EL0.ER enables read-access |
4 | just ignore errors, which results in no behaviour change for other | 4 | to both PMXEVCNTR_EL0 and PMEVCNTR<n>_EL0 registers, however, |
5 | chardevs. | 5 | we only use it for PMXEVCNTR_EL0. Extend to PMEVCNTR<n>_EL0 as well. |
6 | 6 | ||
7 | Signed-off-by: Jan Luebbe <jlu@pengutronix.de> | 7 | Signed-off-by: Alex Zuepke <alex.zuepke@tum.de> |
8 | Message-id: 20210806144700.3751979-1-jlu@pengutronix.de | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Message-id: 20220428132717.84190-1-alex.zuepke@tum.de |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 11 | --- |
12 | hw/char/pl011.c | 6 ++++++ | 12 | target/arm/helper.c | 4 ++-- |
13 | 1 file changed, 6 insertions(+) | 13 | 1 file changed, 2 insertions(+), 2 deletions(-) |
14 | 14 | ||
15 | diff --git a/hw/char/pl011.c b/hw/char/pl011.c | 15 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
16 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/char/pl011.c | 17 | --- a/target/arm/helper.c |
18 | +++ b/hw/char/pl011.c | 18 | +++ b/target/arm/helper.c |
19 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu) |
20 | #include "hw/qdev-properties-system.h" | 20 | .crm = 8 | (3 & (i >> 3)), .opc1 = 0, .opc2 = i & 7, |
21 | #include "migration/vmstate.h" | 21 | .access = PL0_RW, .type = ARM_CP_IO | ARM_CP_ALIAS, |
22 | #include "chardev/char-fe.h" | 22 | .readfn = pmevcntr_readfn, .writefn = pmevcntr_writefn, |
23 | +#include "chardev/char-serial.h" | 23 | - .accessfn = pmreg_access }, |
24 | #include "qemu/log.h" | 24 | + .accessfn = pmreg_access_xevcntr }, |
25 | #include "qemu/module.h" | 25 | { .name = pmevcntr_el0_name, .state = ARM_CP_STATE_AA64, |
26 | #include "trace.h" | 26 | .opc0 = 3, .opc1 = 3, .crn = 14, .crm = 8 | (3 & (i >> 3)), |
27 | @@ -XXX,XX +XXX,XX @@ static void pl011_write(void *opaque, hwaddr offset, | 27 | - .opc2 = i & 7, .access = PL0_RW, .accessfn = pmreg_access, |
28 | s->read_count = 0; | 28 | + .opc2 = i & 7, .access = PL0_RW, .accessfn = pmreg_access_xevcntr, |
29 | s->read_pos = 0; | 29 | .type = ARM_CP_IO, |
30 | } | 30 | .readfn = pmevcntr_readfn, .writefn = pmevcntr_writefn, |
31 | + if ((s->lcr ^ value) & 0x1) { | 31 | .raw_readfn = pmevcntr_rawread, |
32 | + int break_enable = value & 0x1; | ||
33 | + qemu_chr_fe_ioctl(&s->chr, CHR_IOCTL_SERIAL_SET_BREAK, | ||
34 | + &break_enable); | ||
35 | + } | ||
36 | s->lcr = value; | ||
37 | pl011_set_read_trigger(s); | ||
38 | break; | ||
39 | -- | 32 | -- |
40 | 2.20.1 | 33 | 2.25.1 |
41 | |||
42 | diff view generated by jsdifflib |