1 | The following changes since commit 53f306f316549d20c76886903181413d20842423: | 1 | The following changes since commit 003ba52a8b327180e284630b289c6ece5a3e08b9: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/ehabkost-gl/tags/x86-next-pull-request' into staging (2021-06-21 11:26:04 +0100) | 3 | Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (2023-02-16 11:16:39 +0000) |
4 | 4 | ||
5 | are available in the Git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210621 | 7 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230216 |
8 | 8 | ||
9 | for you to fetch changes up to a83f1d9263d281f938a3984cda7104d55affd43a: | 9 | for you to fetch changes up to caf01d6a435d9f4a95aeae2f9fc6cb8b889b1fb8: |
10 | 10 | ||
11 | docs/system: arm: Add nRF boards description (2021-06-21 17:24:33 +0100) | 11 | tests/qtest: Restrict tpm-tis-devices-{swtpm}-test to CONFIG_TCG (2023-02-16 16:28:53 +0000) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | target-arm queue: | 14 | target-arm queue: |
15 | * Don't require 'virt' board to be compiled in for ACPI GHES code | 15 | * Some mostly M-profile-related code cleanups |
16 | * docs: Document which architecture extensions we emulate | 16 | * avocado: Retire the boot_linux.py AArch64 TCG tests |
17 | * Fix bugs in M-profile FPCXT_NS accesses | 17 | * hw/arm/smmuv3: Add GBPA register |
18 | * First slice of MVE patches | 18 | * arm/virt: don't try to spell out the accelerator |
19 | * Implement MTE3 | 19 | * hw/arm: Attach PSPI module to NPCM7XX SoC |
20 | * docs/system: arm: Add nRF boards description | 20 | * Some cleanup/refactoring patches aiming towards |
21 | allowing building Arm targets without CONFIG_TCG | ||
21 | 22 | ||
22 | ---------------------------------------------------------------- | 23 | ---------------------------------------------------------------- |
23 | Alexandre Iooss (1): | 24 | Alex Bennée (1): |
24 | docs/system: arm: Add nRF boards description | 25 | tests/avocado: retire the Aarch64 TCG tests from boot_linux.py |
25 | 26 | ||
26 | Peter Collingbourne (1): | 27 | Claudio Fontana (3): |
27 | target/arm: Implement MTE3 | 28 | target/arm: rename handle_semihosting to tcg_handle_semihosting |
29 | target/arm: wrap psci call with tcg_enabled | ||
30 | target/arm: wrap call to aarch64_sve_change_el in tcg_enabled() | ||
28 | 31 | ||
29 | Peter Maydell (55): | 32 | Cornelia Huck (1): |
30 | hw/acpi: Provide stub version of acpi_ghes_record_errors() | 33 | arm/virt: don't try to spell out the accelerator |
31 | hw/acpi: Provide function acpi_ghes_present() | ||
32 | target/arm: Use acpi_ghes_present() to see if we report ACPI memory errors | ||
33 | docs/system/arm: Document which architecture extensions we emulate | ||
34 | target/arm/translate-vfp.c: Whitespace fixes | ||
35 | target/arm: Handle FPU being disabled in FPCXT_NS accesses | ||
36 | target/arm: Don't NOCP fault for FPCXT_NS accesses | ||
37 | target/arm: Handle writeback in VLDR/VSTR sysreg with no memory access | ||
38 | target/arm: Factor FP context update code out into helper function | ||
39 | target/arm: Split vfp_access_check() into A and M versions | ||
40 | target/arm: Handle FPU check for FPCXT_NS insns via vfp_access_check_m() | ||
41 | target/arm: Implement MVE VLDR/VSTR (non-widening forms) | ||
42 | target/arm: Implement widening/narrowing MVE VLDR/VSTR insns | ||
43 | target/arm: Implement MVE VCLZ | ||
44 | target/arm: Implement MVE VCLS | ||
45 | target/arm: Implement MVE VREV16, VREV32, VREV64 | ||
46 | target/arm: Implement MVE VMVN (register) | ||
47 | target/arm: Implement MVE VABS | ||
48 | target/arm: Implement MVE VNEG | ||
49 | tcg: Make gen_dup_i32/i64() public as tcg_gen_dup_i32/i64 | ||
50 | target/arm: Implement MVE VDUP | ||
51 | target/arm: Implement MVE VAND, VBIC, VORR, VORN, VEOR | ||
52 | target/arm: Implement MVE VADD, VSUB, VMUL | ||
53 | target/arm: Implement MVE VMULH | ||
54 | target/arm: Implement MVE VRMULH | ||
55 | target/arm: Implement MVE VMAX, VMIN | ||
56 | target/arm: Implement MVE VABD | ||
57 | target/arm: Implement MVE VHADD, VHSUB | ||
58 | target/arm: Implement MVE VMULL | ||
59 | target/arm: Implement MVE VMLALDAV | ||
60 | target/arm: Implement MVE VMLSLDAV | ||
61 | target/arm: Implement MVE VRMLALDAVH, VRMLSLDAVH | ||
62 | target/arm: Implement MVE VADD (scalar) | ||
63 | target/arm: Implement MVE VSUB, VMUL (scalar) | ||
64 | target/arm: Implement MVE VHADD, VHSUB (scalar) | ||
65 | target/arm: Implement MVE VBRSR | ||
66 | target/arm: Implement MVE VPST | ||
67 | target/arm: Implement MVE VQADD and VQSUB | ||
68 | target/arm: Implement MVE VQDMULH and VQRDMULH (scalar) | ||
69 | target/arm: Implement MVE VQDMULL scalar | ||
70 | target/arm: Implement MVE VQDMULH, VQRDMULH (vector) | ||
71 | target/arm: Implement MVE VQADD, VQSUB (vector) | ||
72 | target/arm: Implement MVE VQSHL (vector) | ||
73 | target/arm: Implement MVE VQRSHL | ||
74 | target/arm: Implement MVE VSHL insn | ||
75 | target/arm: Implement MVE VRSHL | ||
76 | target/arm: Implement MVE VQDMLADH and VQRDMLADH | ||
77 | target/arm: Implement MVE VQDMLSDH and VQRDMLSDH | ||
78 | target/arm: Implement MVE VQDMULL (vector) | ||
79 | target/arm: Implement MVE VRHADD | ||
80 | target/arm: Implement MVE VADC, VSBC | ||
81 | target/arm: Implement MVE VCADD | ||
82 | target/arm: Implement MVE VHCADD | ||
83 | target/arm: Implement MVE VADDV | ||
84 | target/arm: Make VMOV scalar <-> gpreg beatwise for MVE | ||
85 | 34 | ||
86 | docs/system/arm/emulation.rst | 103 ++++ | 35 | Fabiano Rosas (7): |
87 | docs/system/arm/nrf.rst | 51 ++ | 36 | target/arm: Move PC alignment check |
88 | docs/system/target-arm.rst | 7 + | 37 | target/arm: Move cpregs code out of cpu.h |
89 | include/hw/acpi/ghes.h | 9 + | 38 | tests/avocado: Skip tests that require a missing accelerator |
90 | include/tcg/tcg-op.h | 8 + | 39 | tests/avocado: Tag TCG tests with accel:tcg |
91 | include/tcg/tcg.h | 1 - | 40 | target/arm: Use "max" as default cpu for the virt machine with KVM |
92 | target/arm/helper-mve.h | 357 +++++++++++++ | 41 | tests/qtest: arm-cpu-features: Match tests to required accelerators |
93 | target/arm/helper.h | 2 + | 42 | tests/qtest: Restrict tpm-tis-devices-{swtpm}-test to CONFIG_TCG |
94 | target/arm/internals.h | 11 + | ||
95 | target/arm/translate-a32.h | 3 + | ||
96 | target/arm/translate.h | 10 + | ||
97 | target/arm/m-nocp.decode | 24 + | ||
98 | target/arm/mve.decode | 240 +++++++++ | ||
99 | target/arm/vfp.decode | 14 - | ||
100 | hw/acpi/ghes-stub.c | 22 + | ||
101 | hw/acpi/ghes.c | 17 + | ||
102 | target/arm/cpu64.c | 2 +- | ||
103 | target/arm/kvm64.c | 6 +- | ||
104 | target/arm/mte_helper.c | 82 +-- | ||
105 | target/arm/mve_helper.c | 1160 +++++++++++++++++++++++++++++++++++++++++ | ||
106 | target/arm/translate-m-nocp.c | 550 +++++++++++++++++++ | ||
107 | target/arm/translate-mve.c | 759 +++++++++++++++++++++++++++ | ||
108 | target/arm/translate-vfp.c | 741 +++++++------------------- | ||
109 | tcg/tcg-op-gvec.c | 20 +- | ||
110 | MAINTAINERS | 1 + | ||
111 | hw/acpi/meson.build | 6 +- | ||
112 | target/arm/meson.build | 1 + | ||
113 | 27 files changed, 3578 insertions(+), 629 deletions(-) | ||
114 | create mode 100644 docs/system/arm/emulation.rst | ||
115 | create mode 100644 docs/system/arm/nrf.rst | ||
116 | create mode 100644 target/arm/helper-mve.h | ||
117 | create mode 100644 hw/acpi/ghes-stub.c | ||
118 | create mode 100644 target/arm/mve_helper.c | ||
119 | 43 | ||
44 | Hao Wu (3): | ||
45 | MAINTAINERS: Add myself to maintainers and remove Havard | ||
46 | hw/ssi: Add Nuvoton PSPI Module | ||
47 | hw/arm: Attach PSPI module to NPCM7XX SoC | ||
48 | |||
49 | Jean-Philippe Brucker (2): | ||
50 | hw/arm/smmu-common: Support 64-bit addresses | ||
51 | hw/arm/smmu-common: Fix TTB1 handling | ||
52 | |||
53 | Mostafa Saleh (1): | ||
54 | hw/arm/smmuv3: Add GBPA register | ||
55 | |||
56 | Philippe Mathieu-Daudé (12): | ||
57 | hw/intc/armv7m_nvic: Use OBJECT_DECLARE_SIMPLE_TYPE() macro | ||
58 | target/arm: Simplify arm_v7m_mmu_idx_for_secstate() for user emulation | ||
59 | target/arm: Reduce arm_v7m_mmu_idx_[all/for_secstate_and_priv]() scope | ||
60 | target/arm: Constify ID_PFR1 on user emulation | ||
61 | target/arm: Convert CPUARMState::eabi to boolean | ||
62 | target/arm: Avoid resetting CPUARMState::eabi field | ||
63 | target/arm: Restrict CPUARMState::gicv3state to sysemu | ||
64 | target/arm: Restrict CPUARMState::arm_boot_info to sysemu | ||
65 | target/arm: Restrict CPUARMState::nvic to sysemu | ||
66 | target/arm: Store CPUARMState::nvic as NVICState* | ||
67 | target/arm: Declare CPU <-> NVIC helpers in 'hw/intc/armv7m_nvic.h' | ||
68 | hw/arm: Add missing XLNX_ZYNQMP_ARM -> USB_DWC3 Kconfig dependency | ||
69 | |||
70 | MAINTAINERS | 8 +- | ||
71 | docs/system/arm/nuvoton.rst | 2 +- | ||
72 | hw/arm/smmuv3-internal.h | 7 + | ||
73 | include/hw/arm/npcm7xx.h | 2 + | ||
74 | include/hw/arm/smmu-common.h | 2 - | ||
75 | include/hw/arm/smmuv3.h | 1 + | ||
76 | include/hw/intc/armv7m_nvic.h | 128 +++++++++++++++++- | ||
77 | include/hw/ssi/npcm_pspi.h | 53 ++++++++ | ||
78 | linux-user/user-internals.h | 2 +- | ||
79 | target/arm/cpregs.h | 98 ++++++++++++++ | ||
80 | target/arm/cpu.h | 228 ++------------------------------- | ||
81 | target/arm/internals.h | 14 -- | ||
82 | hw/arm/npcm7xx.c | 25 +++- | ||
83 | hw/arm/smmu-common.c | 4 +- | ||
84 | hw/arm/smmuv3.c | 43 ++++++- | ||
85 | hw/arm/virt.c | 10 +- | ||
86 | hw/intc/armv7m_nvic.c | 38 ++---- | ||
87 | hw/ssi/npcm_pspi.c | 221 ++++++++++++++++++++++++++++++++ | ||
88 | linux-user/arm/cpu_loop.c | 4 +- | ||
89 | target/arm/cpu.c | 5 +- | ||
90 | target/arm/cpu_tcg.c | 3 + | ||
91 | target/arm/helper.c | 31 +++-- | ||
92 | target/arm/m_helper.c | 86 +++++++------ | ||
93 | target/arm/machine.c | 18 +-- | ||
94 | tests/qtest/arm-cpu-features.c | 28 ++-- | ||
95 | hw/arm/Kconfig | 1 + | ||
96 | hw/ssi/meson.build | 2 +- | ||
97 | hw/ssi/trace-events | 5 + | ||
98 | tests/avocado/avocado_qemu/__init__.py | 4 + | ||
99 | tests/avocado/boot_linux.py | 48 ++----- | ||
100 | tests/avocado/boot_linux_console.py | 1 + | ||
101 | tests/avocado/machine_aarch64_virt.py | 63 ++++++++- | ||
102 | tests/avocado/reverse_debugging.py | 8 ++ | ||
103 | tests/qtest/meson.build | 4 +- | ||
104 | 34 files changed, 798 insertions(+), 399 deletions(-) | ||
105 | create mode 100644 include/hw/ssi/npcm_pspi.h | ||
106 | create mode 100644 hw/ssi/npcm_pspi.c | ||
107 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Generic code in target/arm wants to call acpi_ghes_record_errors(); | ||
2 | provide a stub version so that we don't fail to link when | ||
3 | CONFIG_ACPI_APEI is not set. This requires us to add a new | ||
4 | ghes-stub.c file to contain it and the meson.build mechanics | ||
5 | to use it when appropriate. | ||
6 | 1 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Reviewed-by: Dongjiu Geng <gengdongjiu1@gmail.com> | ||
10 | Message-id: 20210603171259.27962-2-peter.maydell@linaro.org | ||
11 | --- | ||
12 | hw/acpi/ghes-stub.c | 17 +++++++++++++++++ | ||
13 | hw/acpi/meson.build | 6 +++--- | ||
14 | 2 files changed, 20 insertions(+), 3 deletions(-) | ||
15 | create mode 100644 hw/acpi/ghes-stub.c | ||
16 | |||
17 | diff --git a/hw/acpi/ghes-stub.c b/hw/acpi/ghes-stub.c | ||
18 | new file mode 100644 | ||
19 | index XXXXXXX..XXXXXXX | ||
20 | --- /dev/null | ||
21 | +++ b/hw/acpi/ghes-stub.c | ||
22 | @@ -XXX,XX +XXX,XX @@ | ||
23 | +/* | ||
24 | + * Support for generating APEI tables and recording CPER for Guests: | ||
25 | + * stub functions. | ||
26 | + * | ||
27 | + * Copyright (c) 2021 Linaro, Ltd | ||
28 | + * | ||
29 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
30 | + * See the COPYING file in the top-level directory. | ||
31 | + */ | ||
32 | + | ||
33 | +#include "qemu/osdep.h" | ||
34 | +#include "hw/acpi/ghes.h" | ||
35 | + | ||
36 | +int acpi_ghes_record_errors(uint8_t source_id, uint64_t physical_address) | ||
37 | +{ | ||
38 | + return -1; | ||
39 | +} | ||
40 | diff --git a/hw/acpi/meson.build b/hw/acpi/meson.build | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/hw/acpi/meson.build | ||
43 | +++ b/hw/acpi/meson.build | ||
44 | @@ -XXX,XX +XXX,XX @@ acpi_ss.add(when: 'CONFIG_ACPI_PCI', if_true: files('pci.c')) | ||
45 | acpi_ss.add(when: 'CONFIG_ACPI_VMGENID', if_true: files('vmgenid.c')) | ||
46 | acpi_ss.add(when: 'CONFIG_ACPI_HW_REDUCED', if_true: files('generic_event_device.c')) | ||
47 | acpi_ss.add(when: 'CONFIG_ACPI_HMAT', if_true: files('hmat.c')) | ||
48 | -acpi_ss.add(when: 'CONFIG_ACPI_APEI', if_true: files('ghes.c')) | ||
49 | +acpi_ss.add(when: 'CONFIG_ACPI_APEI', if_true: files('ghes.c'), if_false: files('ghes-stub.c')) | ||
50 | acpi_ss.add(when: 'CONFIG_ACPI_X86', if_true: files('core.c', 'piix4.c', 'pcihp.c'), if_false: files('acpi-stub.c')) | ||
51 | acpi_ss.add(when: 'CONFIG_ACPI_X86_ICH', if_true: files('ich9.c', 'tco.c')) | ||
52 | acpi_ss.add(when: 'CONFIG_IPMI', if_true: files('ipmi.c'), if_false: files('ipmi-stub.c')) | ||
53 | acpi_ss.add(when: 'CONFIG_PC', if_false: files('acpi-x86-stub.c')) | ||
54 | acpi_ss.add(when: 'CONFIG_TPM', if_true: files('tpm.c')) | ||
55 | -softmmu_ss.add(when: 'CONFIG_ACPI', if_false: files('acpi-stub.c', 'aml-build-stub.c')) | ||
56 | +softmmu_ss.add(when: 'CONFIG_ACPI', if_false: files('acpi-stub.c', 'aml-build-stub.c', 'ghes-stub.c')) | ||
57 | softmmu_ss.add_all(when: 'CONFIG_ACPI', if_true: acpi_ss) | ||
58 | softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('acpi-stub.c', 'aml-build-stub.c', | ||
59 | - 'acpi-x86-stub.c', 'ipmi-stub.c')) | ||
60 | + 'acpi-x86-stub.c', 'ipmi-stub.c', 'ghes-stub.c')) | ||
61 | -- | ||
62 | 2.20.1 | ||
63 | |||
64 | diff view generated by jsdifflib |
1 | Implement the MVE VADDV insn, which performs an addition | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | across vector lanes. | ||
3 | 2 | ||
3 | Manually convert to OBJECT_DECLARE_SIMPLE_TYPE() macro, | ||
4 | similarly to automatic conversion from commit 8063396bf3 | ||
5 | ("Use OBJECT_DECLARE_SIMPLE_TYPE when possible"). | ||
6 | |||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20230206223502.25122-2-philmd@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 | Message-id: 20210617121628.20116-44-peter.maydell@linaro.org | ||
7 | --- | 11 | --- |
8 | target/arm/helper-mve.h | 7 +++++++ | 12 | include/hw/intc/armv7m_nvic.h | 5 +---- |
9 | target/arm/mve.decode | 2 ++ | 13 | 1 file changed, 1 insertion(+), 4 deletions(-) |
10 | target/arm/mve_helper.c | 24 +++++++++++++++++++++ | ||
11 | target/arm/translate-mve.c | 43 ++++++++++++++++++++++++++++++++++++++ | ||
12 | 4 files changed, 76 insertions(+) | ||
13 | 14 | ||
14 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 15 | diff --git a/include/hw/intc/armv7m_nvic.h b/include/hw/intc/armv7m_nvic.h |
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/helper-mve.h | 17 | --- a/include/hw/intc/armv7m_nvic.h |
17 | +++ b/target/arm/helper-mve.h | 18 | +++ b/include/hw/intc/armv7m_nvic.h |
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vrmlaldavhuw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | 19 | @@ -XXX,XX +XXX,XX @@ |
19 | 20 | #include "qom/object.h" | |
20 | DEF_HELPER_FLAGS_4(mve_vrmlsldavhsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | 21 | |
21 | DEF_HELPER_FLAGS_4(mve_vrmlsldavhxsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | 22 | #define TYPE_NVIC "armv7m_nvic" |
22 | + | 23 | - |
23 | +DEF_HELPER_FLAGS_3(mve_vaddvsb, TCG_CALL_NO_WG, i32, env, ptr, i32) | 24 | -typedef struct NVICState NVICState; |
24 | +DEF_HELPER_FLAGS_3(mve_vaddvub, TCG_CALL_NO_WG, i32, env, ptr, i32) | 25 | -DECLARE_INSTANCE_CHECKER(NVICState, NVIC, |
25 | +DEF_HELPER_FLAGS_3(mve_vaddvsh, TCG_CALL_NO_WG, i32, env, ptr, i32) | 26 | - TYPE_NVIC) |
26 | +DEF_HELPER_FLAGS_3(mve_vaddvuh, TCG_CALL_NO_WG, i32, env, ptr, i32) | 27 | +OBJECT_DECLARE_SIMPLE_TYPE(NVICState, NVIC) |
27 | +DEF_HELPER_FLAGS_3(mve_vaddvsw, TCG_CALL_NO_WG, i32, env, ptr, i32) | 28 | |
28 | +DEF_HELPER_FLAGS_3(mve_vaddvuw, TCG_CALL_NO_WG, i32, env, ptr, i32) | 29 | /* Highest permitted number of exceptions (architectural limit) */ |
29 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | 30 | #define NVIC_MAX_VECTORS 512 |
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/target/arm/mve.decode | ||
32 | +++ b/target/arm/mve.decode | ||
33 | @@ -XXX,XX +XXX,XX @@ VBRSR 1111 1110 0 . .. ... 1 ... 1 1110 . 110 .... @2scalar | ||
34 | VQDMULH_scalar 1110 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
35 | VQRDMULH_scalar 1111 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
36 | |||
37 | +# Vector add across vector | ||
38 | +VADDV 111 u:1 1110 1111 size:2 01 ... 0 1111 0 0 a:1 0 qm:3 0 rda=%rdalo | ||
39 | |||
40 | # Predicate operations | ||
41 | %mask_22_13 22:1 13:3 | ||
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_LDAVH(vrmlaldavhuw, 4, uint32_t, false, int128_add, int128_add, int128_make64 | ||
47 | |||
48 | DO_LDAVH(vrmlsldavhsw, 4, int32_t, false, int128_add, int128_sub, int128_makes64) | ||
49 | DO_LDAVH(vrmlsldavhxsw, 4, int32_t, true, int128_add, int128_sub, int128_makes64) | ||
50 | + | ||
51 | +/* Vector add across vector */ | ||
52 | +#define DO_VADDV(OP, ESIZE, TYPE) \ | ||
53 | + uint32_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vm, \ | ||
54 | + uint32_t ra) \ | ||
55 | + { \ | ||
56 | + uint16_t mask = mve_element_mask(env); \ | ||
57 | + unsigned e; \ | ||
58 | + TYPE *m = vm; \ | ||
59 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
60 | + if (mask & 1) { \ | ||
61 | + ra += m[H##ESIZE(e)]; \ | ||
62 | + } \ | ||
63 | + } \ | ||
64 | + mve_advance_vpt(env); \ | ||
65 | + return ra; \ | ||
66 | + } \ | ||
67 | + | ||
68 | +DO_VADDV(vaddvsb, 1, uint8_t) | ||
69 | +DO_VADDV(vaddvsh, 2, uint16_t) | ||
70 | +DO_VADDV(vaddvsw, 4, uint32_t) | ||
71 | +DO_VADDV(vaddvub, 1, uint8_t) | ||
72 | +DO_VADDV(vaddvuh, 2, uint16_t) | ||
73 | +DO_VADDV(vaddvuw, 4, uint32_t) | ||
74 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
75 | index XXXXXXX..XXXXXXX 100644 | ||
76 | --- a/target/arm/translate-mve.c | ||
77 | +++ b/target/arm/translate-mve.c | ||
78 | @@ -XXX,XX +XXX,XX @@ typedef void MVEGenOneOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
79 | typedef void MVEGenTwoOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
80 | typedef void MVEGenTwoOpScalarFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
81 | typedef void MVEGenDualAccOpFn(TCGv_i64, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
82 | +typedef void MVEGenVADDVFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
83 | |||
84 | /* Return the offset of a Qn register (same semantics as aa32_vfp_qreg()) */ | ||
85 | static inline long mve_qreg_offset(unsigned reg) | ||
86 | @@ -XXX,XX +XXX,XX @@ static bool trans_VPST(DisasContext *s, arg_VPST *a) | ||
87 | mve_update_and_store_eci(s); | ||
88 | return true; | ||
89 | } | ||
90 | + | ||
91 | +static bool trans_VADDV(DisasContext *s, arg_VADDV *a) | ||
92 | +{ | ||
93 | + /* VADDV: vector add across vector */ | ||
94 | + static MVEGenVADDVFn * const fns[4][2] = { | ||
95 | + { gen_helper_mve_vaddvsb, gen_helper_mve_vaddvub }, | ||
96 | + { gen_helper_mve_vaddvsh, gen_helper_mve_vaddvuh }, | ||
97 | + { gen_helper_mve_vaddvsw, gen_helper_mve_vaddvuw }, | ||
98 | + { NULL, NULL } | ||
99 | + }; | ||
100 | + TCGv_ptr qm; | ||
101 | + TCGv_i32 rda; | ||
102 | + | ||
103 | + if (!dc_isar_feature(aa32_mve, s) || | ||
104 | + a->size == 3) { | ||
105 | + return false; | ||
106 | + } | ||
107 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
108 | + return true; | ||
109 | + } | ||
110 | + | ||
111 | + /* | ||
112 | + * This insn is subject to beat-wise execution. Partial execution | ||
113 | + * of an A=0 (no-accumulate) insn which does not execute the first | ||
114 | + * beat must start with the current value of Rda, not zero. | ||
115 | + */ | ||
116 | + if (a->a || mve_skip_first_beat(s)) { | ||
117 | + /* Accumulate input from Rda */ | ||
118 | + rda = load_reg(s, a->rda); | ||
119 | + } else { | ||
120 | + /* Accumulate starting at zero */ | ||
121 | + rda = tcg_const_i32(0); | ||
122 | + } | ||
123 | + | ||
124 | + qm = mve_qreg_ptr(a->qm); | ||
125 | + fns[a->size][a->u](rda, cpu_env, qm, rda); | ||
126 | + store_reg(s, a->rda, rda); | ||
127 | + tcg_temp_free_ptr(qm); | ||
128 | + | ||
129 | + mve_update_eci(s); | ||
130 | + return true; | ||
131 | +} | ||
132 | -- | 31 | -- |
133 | 2.20.1 | 32 | 2.34.1 |
134 | 33 | ||
135 | 34 | diff view generated by jsdifflib |
1 | Implement the MVE VPST insn, which sets the predicate mask | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | fields in the VPR to the immediate value encoded in the insn. | ||
3 | 2 | ||
3 | Suggested-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20230206223502.25122-3-philmd@linaro.org | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20210617121628.20116-27-peter.maydell@linaro.org | ||
7 | --- | 8 | --- |
8 | target/arm/mve.decode | 4 +++ | 9 | target/arm/m_helper.c | 11 ++++++++--- |
9 | target/arm/translate-mve.c | 59 ++++++++++++++++++++++++++++++++++++++ | 10 | 1 file changed, 8 insertions(+), 3 deletions(-) |
10 | 2 files changed, 63 insertions(+) | ||
11 | 11 | ||
12 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | 12 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c |
13 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/target/arm/mve.decode | 14 | --- a/target/arm/m_helper.c |
15 | +++ b/target/arm/mve.decode | 15 | +++ b/target/arm/m_helper.c |
16 | @@ -XXX,XX +XXX,XX @@ VHADD_U_scalar 1111 1110 0 . .. ... 0 ... 0 1111 . 100 .... @2scalar | 16 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) |
17 | VHSUB_S_scalar 1110 1110 0 . .. ... 0 ... 1 1111 . 100 .... @2scalar | 17 | return 0; |
18 | VHSUB_U_scalar 1111 1110 0 . .. ... 0 ... 1 1111 . 100 .... @2scalar | ||
19 | VBRSR 1111 1110 0 . .. ... 1 ... 1 1110 . 110 .... @2scalar | ||
20 | + | ||
21 | +# Predicate operations | ||
22 | +%mask_22_13 22:1 13:3 | ||
23 | +VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13 | ||
24 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/target/arm/translate-mve.c | ||
27 | +++ b/target/arm/translate-mve.c | ||
28 | @@ -XXX,XX +XXX,XX @@ static void mve_update_eci(DisasContext *s) | ||
29 | } | ||
30 | } | 18 | } |
31 | 19 | ||
32 | +static void mve_update_and_store_eci(DisasContext *s) | 20 | -#else |
21 | +ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate) | ||
33 | +{ | 22 | +{ |
34 | + /* | 23 | + return ARMMMUIdx_MUser; |
35 | + * For insns which don't call a helper function that will call | ||
36 | + * mve_advance_vpt(), this version updates s->eci and also stores | ||
37 | + * it out to the CPUState field. | ||
38 | + */ | ||
39 | + if (s->eci) { | ||
40 | + mve_update_eci(s); | ||
41 | + store_cpu_field(tcg_constant_i32(s->eci << 4), condexec_bits); | ||
42 | + } | ||
43 | +} | 24 | +} |
44 | + | 25 | + |
45 | static bool mve_skip_first_beat(DisasContext *s) | 26 | +#else /* !CONFIG_USER_ONLY */ |
27 | |||
28 | /* | ||
29 | * What kind of stack write are we doing? This affects how exceptions | ||
30 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) | ||
31 | return tt_resp; | ||
32 | } | ||
33 | |||
34 | -#endif /* !CONFIG_USER_ONLY */ | ||
35 | - | ||
36 | ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env, | ||
37 | bool secstate, bool priv, bool negpri) | ||
46 | { | 38 | { |
47 | /* Return true if PSR.ECI says we must skip the first beat of this insn */ | 39 | @@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate) |
48 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRMLSLDAVH(DisasContext *s, arg_vmlaldav *a) | 40 | |
49 | }; | 41 | return arm_v7m_mmu_idx_for_secstate_and_priv(env, secstate, priv); |
50 | return do_long_dual_acc(s, a, fns[a->x]); | ||
51 | } | 42 | } |
52 | + | 43 | + |
53 | +static bool trans_VPST(DisasContext *s, arg_VPST *a) | 44 | +#endif /* !CONFIG_USER_ONLY */ |
54 | +{ | ||
55 | + TCGv_i32 vpr; | ||
56 | + | ||
57 | + /* mask == 0 is a "related encoding" */ | ||
58 | + if (!dc_isar_feature(aa32_mve, s) || !a->mask) { | ||
59 | + return false; | ||
60 | + } | ||
61 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
62 | + return true; | ||
63 | + } | ||
64 | + /* | ||
65 | + * Set the VPR mask fields. We take advantage of MASK01 and MASK23 | ||
66 | + * being adjacent fields in the register. | ||
67 | + * | ||
68 | + * This insn is not predicated, but it is subject to beat-wise | ||
69 | + * execution, and the mask is updated on the odd-numbered beats. | ||
70 | + * So if PSR.ECI says we should skip beat 1, we mustn't update the | ||
71 | + * 01 mask field. | ||
72 | + */ | ||
73 | + vpr = load_cpu_field(v7m.vpr); | ||
74 | + switch (s->eci) { | ||
75 | + case ECI_NONE: | ||
76 | + case ECI_A0: | ||
77 | + /* Update both 01 and 23 fields */ | ||
78 | + tcg_gen_deposit_i32(vpr, vpr, | ||
79 | + tcg_constant_i32(a->mask | (a->mask << 4)), | ||
80 | + R_V7M_VPR_MASK01_SHIFT, | ||
81 | + R_V7M_VPR_MASK01_LENGTH + R_V7M_VPR_MASK23_LENGTH); | ||
82 | + break; | ||
83 | + case ECI_A0A1: | ||
84 | + case ECI_A0A1A2: | ||
85 | + case ECI_A0A1A2B0: | ||
86 | + /* Update only the 23 mask field */ | ||
87 | + tcg_gen_deposit_i32(vpr, vpr, | ||
88 | + tcg_constant_i32(a->mask), | ||
89 | + R_V7M_VPR_MASK23_SHIFT, R_V7M_VPR_MASK23_LENGTH); | ||
90 | + break; | ||
91 | + default: | ||
92 | + g_assert_not_reached(); | ||
93 | + } | ||
94 | + store_cpu_field(vpr, v7m.vpr); | ||
95 | + mve_update_and_store_eci(s); | ||
96 | + return true; | ||
97 | +} | ||
98 | -- | 45 | -- |
99 | 2.20.1 | 46 | 2.34.1 |
100 | 47 | ||
101 | 48 | diff view generated by jsdifflib |
1 | The M-profile architecture requires that accesses to FPCXT_NS when | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | there is no active FP state must not take a NOCP fault even if the | ||
3 | FPU is disabled. We were not implementing this correctly, because | ||
4 | in our decode we catch the NOCP faults early in m-nocp.decode. | ||
5 | 2 | ||
6 | Fix this bug by moving all the handling of M-profile FP system | 3 | arm_v7m_mmu_idx_all() and arm_v7m_mmu_idx_for_secstate_and_priv() |
7 | register accesses from vfp.decode into m-nocp.decode and putting | 4 | are only used for system emulation in m_helper.c. |
8 | it above the NOCP blocks. This provides the correct behaviour: | 5 | Move the definitions to avoid prototype forward declarations. |
9 | * for accesses other than FPCXT_NS the trans functions call | ||
10 | vfp_access_check(), which will check for FPU disabled and | ||
11 | raise a NOCP exception if necessary | ||
12 | * for FPCXT_NS we have the special case code that doesn't | ||
13 | call vfp_access_check() | ||
14 | * when these trans functions want to raise an UNDEF they return | ||
15 | false, so the decoder will fall through into the NOCP blocks. | ||
16 | This means that NOCP correctly takes precedence over UNDEF | ||
17 | for these insns. (This is a difference from the other insns | ||
18 | handled by m-nocp.decode, where UNDEF takes precedence and | ||
19 | which we implement by having those trans functions call | ||
20 | unallocated_encoding() in the appropriate places.) | ||
21 | 6 | ||
22 | [Note for backport to stable: this commit has a semantic dependency | 7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
23 | on commit 9a486856e9173af, which was not marked as cc-stable because | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
24 | we didn't know we'd need it for a for-stable bugfix.] | 9 | Message-id: 20230206223502.25122-4-philmd@linaro.org |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/internals.h | 14 -------- | ||
13 | target/arm/m_helper.c | 74 +++++++++++++++++++++--------------------- | ||
14 | 2 files changed, 37 insertions(+), 51 deletions(-) | ||
25 | 15 | ||
26 | Cc: qemu-stable@nongnu.org | 16 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
28 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
29 | Message-id: 20210618141019.10671-4-peter.maydell@linaro.org | ||
30 | --- | ||
31 | target/arm/translate-a32.h | 1 + | ||
32 | target/arm/m-nocp.decode | 24 ++ | ||
33 | target/arm/vfp.decode | 14 - | ||
34 | target/arm/translate-m-nocp.c | 514 +++++++++++++++++++++++++++++++++ | ||
35 | target/arm/translate-vfp.c | 517 +--------------------------------- | ||
36 | 5 files changed, 542 insertions(+), 528 deletions(-) | ||
37 | |||
38 | diff --git a/target/arm/translate-a32.h b/target/arm/translate-a32.h | ||
39 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
40 | --- a/target/arm/translate-a32.h | 18 | --- a/target/arm/internals.h |
41 | +++ b/target/arm/translate-a32.h | 19 | +++ b/target/arm/internals.h |
42 | @@ -XXX,XX +XXX,XX @@ bool disas_neon_shared(DisasContext *s, uint32_t insn); | 20 | @@ -XXX,XX +XXX,XX @@ static inline ARMMMUIdx core_to_aa64_mmu_idx(int mmu_idx) |
43 | void load_reg_var(DisasContext *s, TCGv_i32 var, int reg); | 21 | |
44 | void arm_gen_condlabel(DisasContext *s); | 22 | int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx); |
45 | bool vfp_access_check(DisasContext *s); | 23 | |
46 | +void gen_preserve_fp_state(DisasContext *s); | 24 | -/* |
47 | void read_neon_element32(TCGv_i32 dest, int reg, int ele, MemOp memop); | 25 | - * Return the MMU index for a v7M CPU with all relevant information |
48 | void read_neon_element64(TCGv_i64 dest, int reg, int ele, MemOp memop); | 26 | - * manually specified. |
49 | void write_neon_element32(TCGv_i32 src, int reg, int ele, MemOp memop); | 27 | - */ |
50 | diff --git a/target/arm/m-nocp.decode b/target/arm/m-nocp.decode | 28 | -ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env, |
29 | - bool secstate, bool priv, bool negpri); | ||
30 | - | ||
31 | -/* | ||
32 | - * Return the MMU index for a v7M CPU in the specified security and | ||
33 | - * privilege state. | ||
34 | - */ | ||
35 | -ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env, | ||
36 | - bool secstate, bool priv); | ||
37 | - | ||
38 | /* Return the MMU index for a v7M CPU in the specified security state */ | ||
39 | ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate); | ||
40 | |||
41 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | ||
51 | index XXXXXXX..XXXXXXX 100644 | 42 | index XXXXXXX..XXXXXXX 100644 |
52 | --- a/target/arm/m-nocp.decode | 43 | --- a/target/arm/m_helper.c |
53 | +++ b/target/arm/m-nocp.decode | 44 | +++ b/target/arm/m_helper.c |
54 | @@ -XXX,XX +XXX,XX @@ | 45 | @@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate) |
55 | 46 | ||
56 | &nocp cp | 47 | #else /* !CONFIG_USER_ONLY */ |
57 | 48 | ||
58 | +# M-profile VLDR/VSTR to sysreg | 49 | +static ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env, |
59 | +%vldr_sysreg 22:1 13:3 | 50 | + bool secstate, bool priv, bool negpri) |
60 | +%imm7_0x4 0:7 !function=times_4 | 51 | +{ |
52 | + ARMMMUIdx mmu_idx = ARM_MMU_IDX_M; | ||
61 | + | 53 | + |
62 | +&vldr_sysreg rn reg imm a w p | 54 | + if (priv) { |
63 | +@vldr_sysreg .... ... . a:1 . . . rn:4 ... . ... .. ....... \ | 55 | + mmu_idx |= ARM_MMU_IDX_M_PRIV; |
64 | + reg=%vldr_sysreg imm=%imm7_0x4 &vldr_sysreg | ||
65 | + | ||
66 | { | ||
67 | # Special cases which do not take an early NOCP: VLLDM and VLSTM | ||
68 | VLLDM_VLSTM 1110 1100 001 l:1 rn:4 0000 1010 op:1 000 0000 | ||
69 | @@ -XXX,XX +XXX,XX @@ | ||
70 | VSCCLRM 1110 1100 1.01 1111 .... 1011 imm:7 0 vd=%vd_dp size=3 | ||
71 | VSCCLRM 1110 1100 1.01 1111 .... 1010 imm:8 vd=%vd_sp size=2 | ||
72 | |||
73 | + # FP system register accesses: these are a special case because accesses | ||
74 | + # to FPCXT_NS succeed even if the FPU is disabled. We therefore need | ||
75 | + # to handle them before the big NOCP blocks. Note that within these | ||
76 | + # insns NOCP still has higher priority than UNDEFs; this is implemented | ||
77 | + # by their returning 'false' for UNDEF so as to fall through into the | ||
78 | + # NOCP check (in contrast to VLLDM etc, which call unallocated_encoding() | ||
79 | + # for the UNDEFs there that must take precedence over NOCP.) | ||
80 | + | ||
81 | + VMSR_VMRS ---- 1110 111 l:1 reg:4 rt:4 1010 0001 0000 | ||
82 | + | ||
83 | + # P=0 W=0 is SEE "Related encodings", so split into two patterns | ||
84 | + VLDR_sysreg ---- 110 1 . . w:1 1 .... ... 0 111 11 ....... @vldr_sysreg p=1 | ||
85 | + VLDR_sysreg ---- 110 0 . . 1 1 .... ... 0 111 11 ....... @vldr_sysreg p=0 w=1 | ||
86 | + VSTR_sysreg ---- 110 1 . . w:1 0 .... ... 0 111 11 ....... @vldr_sysreg p=1 | ||
87 | + VSTR_sysreg ---- 110 0 . . 1 0 .... ... 0 111 11 ....... @vldr_sysreg p=0 w=1 | ||
88 | + | ||
89 | NOCP 111- 1110 ---- ---- ---- cp:4 ---- ---- &nocp | ||
90 | NOCP 111- 110- ---- ---- ---- cp:4 ---- ---- &nocp | ||
91 | # From v8.1M onwards this range will also NOCP: | ||
92 | diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode | ||
93 | index XXXXXXX..XXXXXXX 100644 | ||
94 | --- a/target/arm/vfp.decode | ||
95 | +++ b/target/arm/vfp.decode | ||
96 | @@ -XXX,XX +XXX,XX @@ VLDR_VSTR_hp ---- 1101 u:1 .0 l:1 rn:4 .... 1001 imm:8 vd=%vd_sp | ||
97 | VLDR_VSTR_sp ---- 1101 u:1 .0 l:1 rn:4 .... 1010 imm:8 vd=%vd_sp | ||
98 | VLDR_VSTR_dp ---- 1101 u:1 .0 l:1 rn:4 .... 1011 imm:8 vd=%vd_dp | ||
99 | |||
100 | -# M-profile VLDR/VSTR to sysreg | ||
101 | -%vldr_sysreg 22:1 13:3 | ||
102 | -%imm7_0x4 0:7 !function=times_4 | ||
103 | - | ||
104 | -&vldr_sysreg rn reg imm a w p | ||
105 | -@vldr_sysreg .... ... . a:1 . . . rn:4 ... . ... .. ....... \ | ||
106 | - reg=%vldr_sysreg imm=%imm7_0x4 &vldr_sysreg | ||
107 | - | ||
108 | -# P=0 W=0 is SEE "Related encodings", so split into two patterns | ||
109 | -VLDR_sysreg ---- 110 1 . . w:1 1 .... ... 0 111 11 ....... @vldr_sysreg p=1 | ||
110 | -VLDR_sysreg ---- 110 0 . . 1 1 .... ... 0 111 11 ....... @vldr_sysreg p=0 w=1 | ||
111 | -VSTR_sysreg ---- 110 1 . . w:1 0 .... ... 0 111 11 ....... @vldr_sysreg p=1 | ||
112 | -VSTR_sysreg ---- 110 0 . . 1 0 .... ... 0 111 11 ....... @vldr_sysreg p=0 w=1 | ||
113 | - | ||
114 | # We split the load/store multiple up into two patterns to avoid | ||
115 | # overlap with other insns in the "Advanced SIMD load/store and 64-bit move" | ||
116 | # grouping: | ||
117 | diff --git a/target/arm/translate-m-nocp.c b/target/arm/translate-m-nocp.c | ||
118 | index XXXXXXX..XXXXXXX 100644 | ||
119 | --- a/target/arm/translate-m-nocp.c | ||
120 | +++ b/target/arm/translate-m-nocp.c | ||
121 | @@ -XXX,XX +XXX,XX @@ | ||
122 | |||
123 | #include "qemu/osdep.h" | ||
124 | #include "tcg/tcg-op.h" | ||
125 | +#include "tcg/tcg-op-gvec.h" | ||
126 | #include "translate.h" | ||
127 | #include "translate-a32.h" | ||
128 | |||
129 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSCCLRM(DisasContext *s, arg_VSCCLRM *a) | ||
130 | return true; | ||
131 | } | ||
132 | |||
133 | +/* | ||
134 | + * M-profile provides two different sets of instructions that can | ||
135 | + * access floating point system registers: VMSR/VMRS (which move | ||
136 | + * to/from a general purpose register) and VLDR/VSTR sysreg (which | ||
137 | + * move directly to/from memory). In some cases there are also side | ||
138 | + * effects which must happen after any write to memory (which could | ||
139 | + * cause an exception). So we implement the common logic for the | ||
140 | + * sysreg access in gen_M_fp_sysreg_write() and gen_M_fp_sysreg_read(), | ||
141 | + * which take pointers to callback functions which will perform the | ||
142 | + * actual "read/write general purpose register" and "read/write | ||
143 | + * memory" operations. | ||
144 | + */ | ||
145 | + | ||
146 | +/* | ||
147 | + * Emit code to store the sysreg to its final destination; frees the | ||
148 | + * TCG temp 'value' it is passed. | ||
149 | + */ | ||
150 | +typedef void fp_sysreg_storefn(DisasContext *s, void *opaque, TCGv_i32 value); | ||
151 | +/* | ||
152 | + * Emit code to load the value to be copied to the sysreg; returns | ||
153 | + * a new TCG temporary | ||
154 | + */ | ||
155 | +typedef TCGv_i32 fp_sysreg_loadfn(DisasContext *s, void *opaque); | ||
156 | + | ||
157 | +/* Common decode/access checks for fp sysreg read/write */ | ||
158 | +typedef enum FPSysRegCheckResult { | ||
159 | + FPSysRegCheckFailed, /* caller should return false */ | ||
160 | + FPSysRegCheckDone, /* caller should return true */ | ||
161 | + FPSysRegCheckContinue, /* caller should continue generating code */ | ||
162 | +} FPSysRegCheckResult; | ||
163 | + | ||
164 | +static FPSysRegCheckResult fp_sysreg_checks(DisasContext *s, int regno) | ||
165 | +{ | ||
166 | + if (!dc_isar_feature(aa32_fpsp_v2, s) && !dc_isar_feature(aa32_mve, s)) { | ||
167 | + return FPSysRegCheckFailed; | ||
168 | + } | 56 | + } |
169 | + | 57 | + |
170 | + switch (regno) { | 58 | + if (negpri) { |
171 | + case ARM_VFP_FPSCR: | 59 | + mmu_idx |= ARM_MMU_IDX_M_NEGPRI; |
172 | + case QEMU_VFP_FPSCR_NZCV: | ||
173 | + break; | ||
174 | + case ARM_VFP_FPSCR_NZCVQC: | ||
175 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { | ||
176 | + return FPSysRegCheckFailed; | ||
177 | + } | ||
178 | + break; | ||
179 | + case ARM_VFP_FPCXT_S: | ||
180 | + case ARM_VFP_FPCXT_NS: | ||
181 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { | ||
182 | + return FPSysRegCheckFailed; | ||
183 | + } | ||
184 | + if (!s->v8m_secure) { | ||
185 | + return FPSysRegCheckFailed; | ||
186 | + } | ||
187 | + break; | ||
188 | + case ARM_VFP_VPR: | ||
189 | + case ARM_VFP_P0: | ||
190 | + if (!dc_isar_feature(aa32_mve, s)) { | ||
191 | + return FPSysRegCheckFailed; | ||
192 | + } | ||
193 | + break; | ||
194 | + default: | ||
195 | + return FPSysRegCheckFailed; | ||
196 | + } | 60 | + } |
197 | + | 61 | + |
198 | + /* | 62 | + if (secstate) { |
199 | + * FPCXT_NS is a special case: it has specific handling for | 63 | + mmu_idx |= ARM_MMU_IDX_M_S; |
200 | + * "current FP state is inactive", and must do the PreserveFPState() | ||
201 | + * but not the usual full set of actions done by ExecuteFPCheck(). | ||
202 | + * So we don't call vfp_access_check() and the callers must handle this. | ||
203 | + */ | ||
204 | + if (regno != ARM_VFP_FPCXT_NS && !vfp_access_check(s)) { | ||
205 | + return FPSysRegCheckDone; | ||
206 | + } | 64 | + } |
207 | + return FPSysRegCheckContinue; | 65 | + |
66 | + return mmu_idx; | ||
208 | +} | 67 | +} |
209 | + | 68 | + |
210 | +static void gen_branch_fpInactive(DisasContext *s, TCGCond cond, | 69 | +static ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env, |
211 | + TCGLabel *label) | 70 | + bool secstate, bool priv) |
212 | +{ | 71 | +{ |
213 | + /* | 72 | + bool negpri = armv7m_nvic_neg_prio_requested(env->nvic, secstate); |
214 | + * FPCXT_NS is a special case: it has specific handling for | ||
215 | + * "current FP state is inactive", and must do the PreserveFPState() | ||
216 | + * but not the usual full set of actions done by ExecuteFPCheck(). | ||
217 | + * We don't have a TB flag that matches the fpInactive check, so we | ||
218 | + * do it at runtime as we don't expect FPCXT_NS accesses to be frequent. | ||
219 | + * | ||
220 | + * Emit code that checks fpInactive and does a conditional | ||
221 | + * branch to label based on it: | ||
222 | + * if cond is TCG_COND_NE then branch if fpInactive != 0 (ie if inactive) | ||
223 | + * if cond is TCG_COND_EQ then branch if fpInactive == 0 (ie if active) | ||
224 | + */ | ||
225 | + assert(cond == TCG_COND_EQ || cond == TCG_COND_NE); | ||
226 | + | 73 | + |
227 | + /* fpInactive = FPCCR_NS.ASPEN == 1 && CONTROL.FPCA == 0 */ | 74 | + return arm_v7m_mmu_idx_all(env, secstate, priv, negpri); |
228 | + TCGv_i32 aspen, fpca; | ||
229 | + aspen = load_cpu_field(v7m.fpccr[M_REG_NS]); | ||
230 | + fpca = load_cpu_field(v7m.control[M_REG_S]); | ||
231 | + tcg_gen_andi_i32(aspen, aspen, R_V7M_FPCCR_ASPEN_MASK); | ||
232 | + tcg_gen_xori_i32(aspen, aspen, R_V7M_FPCCR_ASPEN_MASK); | ||
233 | + tcg_gen_andi_i32(fpca, fpca, R_V7M_CONTROL_FPCA_MASK); | ||
234 | + tcg_gen_or_i32(fpca, fpca, aspen); | ||
235 | + tcg_gen_brcondi_i32(tcg_invert_cond(cond), fpca, 0, label); | ||
236 | + tcg_temp_free_i32(aspen); | ||
237 | + tcg_temp_free_i32(fpca); | ||
238 | +} | 75 | +} |
239 | + | 76 | + |
240 | +static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, | 77 | +/* Return the MMU index for a v7M CPU in the specified security state */ |
241 | + fp_sysreg_loadfn *loadfn, | 78 | +ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate) |
242 | + void *opaque) | ||
243 | +{ | 79 | +{ |
244 | + /* Do a write to an M-profile floating point system register */ | 80 | + bool priv = arm_v7m_is_handler_mode(env) || |
245 | + TCGv_i32 tmp; | 81 | + !(env->v7m.control[secstate] & 1); |
246 | + TCGLabel *lab_end = NULL; | ||
247 | + | 82 | + |
248 | + switch (fp_sysreg_checks(s, regno)) { | 83 | + return arm_v7m_mmu_idx_for_secstate_and_priv(env, secstate, priv); |
249 | + case FPSysRegCheckFailed: | ||
250 | + return false; | ||
251 | + case FPSysRegCheckDone: | ||
252 | + return true; | ||
253 | + case FPSysRegCheckContinue: | ||
254 | + break; | ||
255 | + } | ||
256 | + | ||
257 | + switch (regno) { | ||
258 | + case ARM_VFP_FPSCR: | ||
259 | + tmp = loadfn(s, opaque); | ||
260 | + gen_helper_vfp_set_fpscr(cpu_env, tmp); | ||
261 | + tcg_temp_free_i32(tmp); | ||
262 | + gen_lookup_tb(s); | ||
263 | + break; | ||
264 | + case ARM_VFP_FPSCR_NZCVQC: | ||
265 | + { | ||
266 | + TCGv_i32 fpscr; | ||
267 | + tmp = loadfn(s, opaque); | ||
268 | + if (dc_isar_feature(aa32_mve, s)) { | ||
269 | + /* QC is only present for MVE; otherwise RES0 */ | ||
270 | + TCGv_i32 qc = tcg_temp_new_i32(); | ||
271 | + tcg_gen_andi_i32(qc, tmp, FPCR_QC); | ||
272 | + /* | ||
273 | + * The 4 vfp.qc[] fields need only be "zero" vs "non-zero"; | ||
274 | + * here writing the same value into all elements is simplest. | ||
275 | + */ | ||
276 | + tcg_gen_gvec_dup_i32(MO_32, offsetof(CPUARMState, vfp.qc), | ||
277 | + 16, 16, qc); | ||
278 | + } | ||
279 | + tcg_gen_andi_i32(tmp, tmp, FPCR_NZCV_MASK); | ||
280 | + fpscr = load_cpu_field(vfp.xregs[ARM_VFP_FPSCR]); | ||
281 | + tcg_gen_andi_i32(fpscr, fpscr, ~FPCR_NZCV_MASK); | ||
282 | + tcg_gen_or_i32(fpscr, fpscr, tmp); | ||
283 | + store_cpu_field(fpscr, vfp.xregs[ARM_VFP_FPSCR]); | ||
284 | + tcg_temp_free_i32(tmp); | ||
285 | + break; | ||
286 | + } | ||
287 | + case ARM_VFP_FPCXT_NS: | ||
288 | + lab_end = gen_new_label(); | ||
289 | + /* fpInactive case: write is a NOP, so branch to end */ | ||
290 | + gen_branch_fpInactive(s, TCG_COND_NE, lab_end); | ||
291 | + /* | ||
292 | + * !fpInactive: if FPU disabled, take NOCP exception; | ||
293 | + * otherwise PreserveFPState(), and then FPCXT_NS writes | ||
294 | + * behave the same as FPCXT_S writes. | ||
295 | + */ | ||
296 | + if (s->fp_excp_el) { | ||
297 | + gen_exception_insn(s, s->pc_curr, EXCP_NOCP, | ||
298 | + syn_uncategorized(), s->fp_excp_el); | ||
299 | + /* | ||
300 | + * This was only a conditional exception, so override | ||
301 | + * gen_exception_insn()'s default to DISAS_NORETURN | ||
302 | + */ | ||
303 | + s->base.is_jmp = DISAS_NEXT; | ||
304 | + break; | ||
305 | + } | ||
306 | + gen_preserve_fp_state(s); | ||
307 | + /* fall through */ | ||
308 | + case ARM_VFP_FPCXT_S: | ||
309 | + { | ||
310 | + TCGv_i32 sfpa, control; | ||
311 | + /* | ||
312 | + * Set FPSCR and CONTROL.SFPA from value; the new FPSCR takes | ||
313 | + * bits [27:0] from value and zeroes bits [31:28]. | ||
314 | + */ | ||
315 | + tmp = loadfn(s, opaque); | ||
316 | + sfpa = tcg_temp_new_i32(); | ||
317 | + tcg_gen_shri_i32(sfpa, tmp, 31); | ||
318 | + control = load_cpu_field(v7m.control[M_REG_S]); | ||
319 | + tcg_gen_deposit_i32(control, control, sfpa, | ||
320 | + R_V7M_CONTROL_SFPA_SHIFT, 1); | ||
321 | + store_cpu_field(control, v7m.control[M_REG_S]); | ||
322 | + tcg_gen_andi_i32(tmp, tmp, ~FPCR_NZCV_MASK); | ||
323 | + gen_helper_vfp_set_fpscr(cpu_env, tmp); | ||
324 | + tcg_temp_free_i32(tmp); | ||
325 | + tcg_temp_free_i32(sfpa); | ||
326 | + break; | ||
327 | + } | ||
328 | + case ARM_VFP_VPR: | ||
329 | + /* Behaves as NOP if not privileged */ | ||
330 | + if (IS_USER(s)) { | ||
331 | + break; | ||
332 | + } | ||
333 | + tmp = loadfn(s, opaque); | ||
334 | + store_cpu_field(tmp, v7m.vpr); | ||
335 | + break; | ||
336 | + case ARM_VFP_P0: | ||
337 | + { | ||
338 | + TCGv_i32 vpr; | ||
339 | + tmp = loadfn(s, opaque); | ||
340 | + vpr = load_cpu_field(v7m.vpr); | ||
341 | + tcg_gen_deposit_i32(vpr, vpr, tmp, | ||
342 | + R_V7M_VPR_P0_SHIFT, R_V7M_VPR_P0_LENGTH); | ||
343 | + store_cpu_field(vpr, v7m.vpr); | ||
344 | + tcg_temp_free_i32(tmp); | ||
345 | + break; | ||
346 | + } | ||
347 | + default: | ||
348 | + g_assert_not_reached(); | ||
349 | + } | ||
350 | + if (lab_end) { | ||
351 | + gen_set_label(lab_end); | ||
352 | + } | ||
353 | + return true; | ||
354 | +} | 84 | +} |
355 | + | 85 | + |
356 | +static bool gen_M_fp_sysreg_read(DisasContext *s, int regno, | 86 | /* |
357 | + fp_sysreg_storefn *storefn, | 87 | * What kind of stack write are we doing? This affects how exceptions |
358 | + void *opaque) | 88 | * generated during the stacking are treated. |
359 | +{ | 89 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) |
360 | + /* Do a read from an M-profile floating point system register */ | 90 | return tt_resp; |
361 | + TCGv_i32 tmp; | ||
362 | + TCGLabel *lab_end = NULL; | ||
363 | + bool lookup_tb = false; | ||
364 | + | ||
365 | + switch (fp_sysreg_checks(s, regno)) { | ||
366 | + case FPSysRegCheckFailed: | ||
367 | + return false; | ||
368 | + case FPSysRegCheckDone: | ||
369 | + return true; | ||
370 | + case FPSysRegCheckContinue: | ||
371 | + break; | ||
372 | + } | ||
373 | + | ||
374 | + if (regno == ARM_VFP_FPSCR_NZCVQC && !dc_isar_feature(aa32_mve, s)) { | ||
375 | + /* QC is RES0 without MVE, so NZCVQC simplifies to NZCV */ | ||
376 | + regno = QEMU_VFP_FPSCR_NZCV; | ||
377 | + } | ||
378 | + | ||
379 | + switch (regno) { | ||
380 | + case ARM_VFP_FPSCR: | ||
381 | + tmp = tcg_temp_new_i32(); | ||
382 | + gen_helper_vfp_get_fpscr(tmp, cpu_env); | ||
383 | + storefn(s, opaque, tmp); | ||
384 | + break; | ||
385 | + case ARM_VFP_FPSCR_NZCVQC: | ||
386 | + tmp = tcg_temp_new_i32(); | ||
387 | + gen_helper_vfp_get_fpscr(tmp, cpu_env); | ||
388 | + tcg_gen_andi_i32(tmp, tmp, FPCR_NZCVQC_MASK); | ||
389 | + storefn(s, opaque, tmp); | ||
390 | + break; | ||
391 | + case QEMU_VFP_FPSCR_NZCV: | ||
392 | + /* | ||
393 | + * Read just NZCV; this is a special case to avoid the | ||
394 | + * helper call for the "VMRS to CPSR.NZCV" insn. | ||
395 | + */ | ||
396 | + tmp = load_cpu_field(vfp.xregs[ARM_VFP_FPSCR]); | ||
397 | + tcg_gen_andi_i32(tmp, tmp, FPCR_NZCV_MASK); | ||
398 | + storefn(s, opaque, tmp); | ||
399 | + break; | ||
400 | + case ARM_VFP_FPCXT_S: | ||
401 | + { | ||
402 | + TCGv_i32 control, sfpa, fpscr; | ||
403 | + /* Bits [27:0] from FPSCR, bit [31] from CONTROL.SFPA */ | ||
404 | + tmp = tcg_temp_new_i32(); | ||
405 | + sfpa = tcg_temp_new_i32(); | ||
406 | + gen_helper_vfp_get_fpscr(tmp, cpu_env); | ||
407 | + tcg_gen_andi_i32(tmp, tmp, ~FPCR_NZCV_MASK); | ||
408 | + control = load_cpu_field(v7m.control[M_REG_S]); | ||
409 | + tcg_gen_andi_i32(sfpa, control, R_V7M_CONTROL_SFPA_MASK); | ||
410 | + tcg_gen_shli_i32(sfpa, sfpa, 31 - R_V7M_CONTROL_SFPA_SHIFT); | ||
411 | + tcg_gen_or_i32(tmp, tmp, sfpa); | ||
412 | + tcg_temp_free_i32(sfpa); | ||
413 | + /* | ||
414 | + * Store result before updating FPSCR etc, in case | ||
415 | + * it is a memory write which causes an exception. | ||
416 | + */ | ||
417 | + storefn(s, opaque, tmp); | ||
418 | + /* | ||
419 | + * Now we must reset FPSCR from FPDSCR_NS, and clear | ||
420 | + * CONTROL.SFPA; so we'll end the TB here. | ||
421 | + */ | ||
422 | + tcg_gen_andi_i32(control, control, ~R_V7M_CONTROL_SFPA_MASK); | ||
423 | + store_cpu_field(control, v7m.control[M_REG_S]); | ||
424 | + fpscr = load_cpu_field(v7m.fpdscr[M_REG_NS]); | ||
425 | + gen_helper_vfp_set_fpscr(cpu_env, fpscr); | ||
426 | + tcg_temp_free_i32(fpscr); | ||
427 | + lookup_tb = true; | ||
428 | + break; | ||
429 | + } | ||
430 | + case ARM_VFP_FPCXT_NS: | ||
431 | + { | ||
432 | + TCGv_i32 control, sfpa, fpscr, fpdscr, zero; | ||
433 | + TCGLabel *lab_active = gen_new_label(); | ||
434 | + | ||
435 | + lookup_tb = true; | ||
436 | + | ||
437 | + gen_branch_fpInactive(s, TCG_COND_EQ, lab_active); | ||
438 | + /* fpInactive case: reads as FPDSCR_NS */ | ||
439 | + TCGv_i32 tmp = load_cpu_field(v7m.fpdscr[M_REG_NS]); | ||
440 | + storefn(s, opaque, tmp); | ||
441 | + lab_end = gen_new_label(); | ||
442 | + tcg_gen_br(lab_end); | ||
443 | + | ||
444 | + gen_set_label(lab_active); | ||
445 | + /* | ||
446 | + * !fpInactive: if FPU disabled, take NOCP exception; | ||
447 | + * otherwise PreserveFPState(), and then FPCXT_NS | ||
448 | + * reads the same as FPCXT_S. | ||
449 | + */ | ||
450 | + if (s->fp_excp_el) { | ||
451 | + gen_exception_insn(s, s->pc_curr, EXCP_NOCP, | ||
452 | + syn_uncategorized(), s->fp_excp_el); | ||
453 | + /* | ||
454 | + * This was only a conditional exception, so override | ||
455 | + * gen_exception_insn()'s default to DISAS_NORETURN | ||
456 | + */ | ||
457 | + s->base.is_jmp = DISAS_NEXT; | ||
458 | + break; | ||
459 | + } | ||
460 | + gen_preserve_fp_state(s); | ||
461 | + tmp = tcg_temp_new_i32(); | ||
462 | + sfpa = tcg_temp_new_i32(); | ||
463 | + fpscr = tcg_temp_new_i32(); | ||
464 | + gen_helper_vfp_get_fpscr(fpscr, cpu_env); | ||
465 | + tcg_gen_andi_i32(tmp, fpscr, ~FPCR_NZCV_MASK); | ||
466 | + control = load_cpu_field(v7m.control[M_REG_S]); | ||
467 | + tcg_gen_andi_i32(sfpa, control, R_V7M_CONTROL_SFPA_MASK); | ||
468 | + tcg_gen_shli_i32(sfpa, sfpa, 31 - R_V7M_CONTROL_SFPA_SHIFT); | ||
469 | + tcg_gen_or_i32(tmp, tmp, sfpa); | ||
470 | + tcg_temp_free_i32(control); | ||
471 | + /* Store result before updating FPSCR, in case it faults */ | ||
472 | + storefn(s, opaque, tmp); | ||
473 | + /* If SFPA is zero then set FPSCR from FPDSCR_NS */ | ||
474 | + fpdscr = load_cpu_field(v7m.fpdscr[M_REG_NS]); | ||
475 | + zero = tcg_const_i32(0); | ||
476 | + tcg_gen_movcond_i32(TCG_COND_EQ, fpscr, sfpa, zero, fpdscr, fpscr); | ||
477 | + gen_helper_vfp_set_fpscr(cpu_env, fpscr); | ||
478 | + tcg_temp_free_i32(zero); | ||
479 | + tcg_temp_free_i32(sfpa); | ||
480 | + tcg_temp_free_i32(fpdscr); | ||
481 | + tcg_temp_free_i32(fpscr); | ||
482 | + break; | ||
483 | + } | ||
484 | + case ARM_VFP_VPR: | ||
485 | + /* Behaves as NOP if not privileged */ | ||
486 | + if (IS_USER(s)) { | ||
487 | + break; | ||
488 | + } | ||
489 | + tmp = load_cpu_field(v7m.vpr); | ||
490 | + storefn(s, opaque, tmp); | ||
491 | + break; | ||
492 | + case ARM_VFP_P0: | ||
493 | + tmp = load_cpu_field(v7m.vpr); | ||
494 | + tcg_gen_extract_i32(tmp, tmp, R_V7M_VPR_P0_SHIFT, R_V7M_VPR_P0_LENGTH); | ||
495 | + storefn(s, opaque, tmp); | ||
496 | + break; | ||
497 | + default: | ||
498 | + g_assert_not_reached(); | ||
499 | + } | ||
500 | + | ||
501 | + if (lab_end) { | ||
502 | + gen_set_label(lab_end); | ||
503 | + } | ||
504 | + if (lookup_tb) { | ||
505 | + gen_lookup_tb(s); | ||
506 | + } | ||
507 | + return true; | ||
508 | +} | ||
509 | + | ||
510 | +static void fp_sysreg_to_gpr(DisasContext *s, void *opaque, TCGv_i32 value) | ||
511 | +{ | ||
512 | + arg_VMSR_VMRS *a = opaque; | ||
513 | + | ||
514 | + if (a->rt == 15) { | ||
515 | + /* Set the 4 flag bits in the CPSR */ | ||
516 | + gen_set_nzcv(value); | ||
517 | + tcg_temp_free_i32(value); | ||
518 | + } else { | ||
519 | + store_reg(s, a->rt, value); | ||
520 | + } | ||
521 | +} | ||
522 | + | ||
523 | +static TCGv_i32 gpr_to_fp_sysreg(DisasContext *s, void *opaque) | ||
524 | +{ | ||
525 | + arg_VMSR_VMRS *a = opaque; | ||
526 | + | ||
527 | + return load_reg(s, a->rt); | ||
528 | +} | ||
529 | + | ||
530 | +static bool trans_VMSR_VMRS(DisasContext *s, arg_VMSR_VMRS *a) | ||
531 | +{ | ||
532 | + /* | ||
533 | + * Accesses to R15 are UNPREDICTABLE; we choose to undef. | ||
534 | + * FPSCR -> r15 is a special case which writes to the PSR flags; | ||
535 | + * set a->reg to a special value to tell gen_M_fp_sysreg_read() | ||
536 | + * we only care about the top 4 bits of FPSCR there. | ||
537 | + */ | ||
538 | + if (a->rt == 15) { | ||
539 | + if (a->l && a->reg == ARM_VFP_FPSCR) { | ||
540 | + a->reg = QEMU_VFP_FPSCR_NZCV; | ||
541 | + } else { | ||
542 | + return false; | ||
543 | + } | ||
544 | + } | ||
545 | + | ||
546 | + if (a->l) { | ||
547 | + /* VMRS, move FP system register to gp register */ | ||
548 | + return gen_M_fp_sysreg_read(s, a->reg, fp_sysreg_to_gpr, a); | ||
549 | + } else { | ||
550 | + /* VMSR, move gp register to FP system register */ | ||
551 | + return gen_M_fp_sysreg_write(s, a->reg, gpr_to_fp_sysreg, a); | ||
552 | + } | ||
553 | +} | ||
554 | + | ||
555 | +static void fp_sysreg_to_memory(DisasContext *s, void *opaque, TCGv_i32 value) | ||
556 | +{ | ||
557 | + arg_vldr_sysreg *a = opaque; | ||
558 | + uint32_t offset = a->imm; | ||
559 | + TCGv_i32 addr; | ||
560 | + | ||
561 | + if (!a->a) { | ||
562 | + offset = -offset; | ||
563 | + } | ||
564 | + | ||
565 | + addr = load_reg(s, a->rn); | ||
566 | + if (a->p) { | ||
567 | + tcg_gen_addi_i32(addr, addr, offset); | ||
568 | + } | ||
569 | + | ||
570 | + if (s->v8m_stackcheck && a->rn == 13 && a->w) { | ||
571 | + gen_helper_v8m_stackcheck(cpu_env, addr); | ||
572 | + } | ||
573 | + | ||
574 | + gen_aa32_st_i32(s, value, addr, get_mem_index(s), | ||
575 | + MO_UL | MO_ALIGN | s->be_data); | ||
576 | + tcg_temp_free_i32(value); | ||
577 | + | ||
578 | + if (a->w) { | ||
579 | + /* writeback */ | ||
580 | + if (!a->p) { | ||
581 | + tcg_gen_addi_i32(addr, addr, offset); | ||
582 | + } | ||
583 | + store_reg(s, a->rn, addr); | ||
584 | + } else { | ||
585 | + tcg_temp_free_i32(addr); | ||
586 | + } | ||
587 | +} | ||
588 | + | ||
589 | +static TCGv_i32 memory_to_fp_sysreg(DisasContext *s, void *opaque) | ||
590 | +{ | ||
591 | + arg_vldr_sysreg *a = opaque; | ||
592 | + uint32_t offset = a->imm; | ||
593 | + TCGv_i32 addr; | ||
594 | + TCGv_i32 value = tcg_temp_new_i32(); | ||
595 | + | ||
596 | + if (!a->a) { | ||
597 | + offset = -offset; | ||
598 | + } | ||
599 | + | ||
600 | + addr = load_reg(s, a->rn); | ||
601 | + if (a->p) { | ||
602 | + tcg_gen_addi_i32(addr, addr, offset); | ||
603 | + } | ||
604 | + | ||
605 | + if (s->v8m_stackcheck && a->rn == 13 && a->w) { | ||
606 | + gen_helper_v8m_stackcheck(cpu_env, addr); | ||
607 | + } | ||
608 | + | ||
609 | + gen_aa32_ld_i32(s, value, addr, get_mem_index(s), | ||
610 | + MO_UL | MO_ALIGN | s->be_data); | ||
611 | + | ||
612 | + if (a->w) { | ||
613 | + /* writeback */ | ||
614 | + if (!a->p) { | ||
615 | + tcg_gen_addi_i32(addr, addr, offset); | ||
616 | + } | ||
617 | + store_reg(s, a->rn, addr); | ||
618 | + } else { | ||
619 | + tcg_temp_free_i32(addr); | ||
620 | + } | ||
621 | + return value; | ||
622 | +} | ||
623 | + | ||
624 | +static bool trans_VLDR_sysreg(DisasContext *s, arg_vldr_sysreg *a) | ||
625 | +{ | ||
626 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { | ||
627 | + return false; | ||
628 | + } | ||
629 | + if (a->rn == 15) { | ||
630 | + return false; | ||
631 | + } | ||
632 | + return gen_M_fp_sysreg_write(s, a->reg, memory_to_fp_sysreg, a); | ||
633 | +} | ||
634 | + | ||
635 | +static bool trans_VSTR_sysreg(DisasContext *s, arg_vldr_sysreg *a) | ||
636 | +{ | ||
637 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { | ||
638 | + return false; | ||
639 | + } | ||
640 | + if (a->rn == 15) { | ||
641 | + return false; | ||
642 | + } | ||
643 | + return gen_M_fp_sysreg_read(s, a->reg, fp_sysreg_to_memory, a); | ||
644 | +} | ||
645 | + | ||
646 | static bool trans_NOCP(DisasContext *s, arg_nocp *a) | ||
647 | { | ||
648 | /* | ||
649 | diff --git a/target/arm/translate-vfp.c b/target/arm/translate-vfp.c | ||
650 | index XXXXXXX..XXXXXXX 100644 | ||
651 | --- a/target/arm/translate-vfp.c | ||
652 | +++ b/target/arm/translate-vfp.c | ||
653 | @@ -XXX,XX +XXX,XX @@ static inline long vfp_f16_offset(unsigned reg, bool top) | ||
654 | * Generate code for M-profile lazy FP state preservation if needed; | ||
655 | * this corresponds to the pseudocode PreserveFPState() function. | ||
656 | */ | ||
657 | -static void gen_preserve_fp_state(DisasContext *s) | ||
658 | +void gen_preserve_fp_state(DisasContext *s) | ||
659 | { | ||
660 | if (s->v7m_lspact) { | ||
661 | /* | ||
662 | @@ -XXX,XX +XXX,XX @@ static bool trans_VDUP(DisasContext *s, arg_VDUP *a) | ||
663 | return true; | ||
664 | } | 91 | } |
665 | 92 | ||
666 | -/* | 93 | -ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env, |
667 | - * M-profile provides two different sets of instructions that can | 94 | - bool secstate, bool priv, bool negpri) |
668 | - * access floating point system registers: VMSR/VMRS (which move | 95 | -{ |
669 | - * to/from a general purpose register) and VLDR/VSTR sysreg (which | 96 | - ARMMMUIdx mmu_idx = ARM_MMU_IDX_M; |
670 | - * move directly to/from memory). In some cases there are also side | ||
671 | - * effects which must happen after any write to memory (which could | ||
672 | - * cause an exception). So we implement the common logic for the | ||
673 | - * sysreg access in gen_M_fp_sysreg_write() and gen_M_fp_sysreg_read(), | ||
674 | - * which take pointers to callback functions which will perform the | ||
675 | - * actual "read/write general purpose register" and "read/write | ||
676 | - * memory" operations. | ||
677 | - */ | ||
678 | - | 97 | - |
679 | -/* | 98 | - if (priv) { |
680 | - * Emit code to store the sysreg to its final destination; frees the | 99 | - mmu_idx |= ARM_MMU_IDX_M_PRIV; |
681 | - * TCG temp 'value' it is passed. | ||
682 | - */ | ||
683 | -typedef void fp_sysreg_storefn(DisasContext *s, void *opaque, TCGv_i32 value); | ||
684 | -/* | ||
685 | - * Emit code to load the value to be copied to the sysreg; returns | ||
686 | - * a new TCG temporary | ||
687 | - */ | ||
688 | -typedef TCGv_i32 fp_sysreg_loadfn(DisasContext *s, void *opaque); | ||
689 | - | ||
690 | -/* Common decode/access checks for fp sysreg read/write */ | ||
691 | -typedef enum FPSysRegCheckResult { | ||
692 | - FPSysRegCheckFailed, /* caller should return false */ | ||
693 | - FPSysRegCheckDone, /* caller should return true */ | ||
694 | - FPSysRegCheckContinue, /* caller should continue generating code */ | ||
695 | -} FPSysRegCheckResult; | ||
696 | - | ||
697 | -static FPSysRegCheckResult fp_sysreg_checks(DisasContext *s, int regno) | ||
698 | -{ | ||
699 | - if (!dc_isar_feature(aa32_fpsp_v2, s) && !dc_isar_feature(aa32_mve, s)) { | ||
700 | - return FPSysRegCheckFailed; | ||
701 | - } | 100 | - } |
702 | - | 101 | - |
703 | - switch (regno) { | 102 | - if (negpri) { |
704 | - case ARM_VFP_FPSCR: | 103 | - mmu_idx |= ARM_MMU_IDX_M_NEGPRI; |
705 | - case QEMU_VFP_FPSCR_NZCV: | ||
706 | - break; | ||
707 | - case ARM_VFP_FPSCR_NZCVQC: | ||
708 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { | ||
709 | - return FPSysRegCheckFailed; | ||
710 | - } | ||
711 | - break; | ||
712 | - case ARM_VFP_FPCXT_S: | ||
713 | - case ARM_VFP_FPCXT_NS: | ||
714 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { | ||
715 | - return FPSysRegCheckFailed; | ||
716 | - } | ||
717 | - if (!s->v8m_secure) { | ||
718 | - return FPSysRegCheckFailed; | ||
719 | - } | ||
720 | - break; | ||
721 | - case ARM_VFP_VPR: | ||
722 | - case ARM_VFP_P0: | ||
723 | - if (!dc_isar_feature(aa32_mve, s)) { | ||
724 | - return FPSysRegCheckFailed; | ||
725 | - } | ||
726 | - break; | ||
727 | - default: | ||
728 | - return FPSysRegCheckFailed; | ||
729 | - } | 104 | - } |
730 | - | 105 | - |
731 | - /* | 106 | - if (secstate) { |
732 | - * FPCXT_NS is a special case: it has specific handling for | 107 | - mmu_idx |= ARM_MMU_IDX_M_S; |
733 | - * "current FP state is inactive", and must do the PreserveFPState() | ||
734 | - * but not the usual full set of actions done by ExecuteFPCheck(). | ||
735 | - * So we don't call vfp_access_check() and the callers must handle this. | ||
736 | - */ | ||
737 | - if (regno != ARM_VFP_FPCXT_NS && !vfp_access_check(s)) { | ||
738 | - return FPSysRegCheckDone; | ||
739 | - } | 108 | - } |
740 | - return FPSysRegCheckContinue; | 109 | - |
110 | - return mmu_idx; | ||
741 | -} | 111 | -} |
742 | - | 112 | - |
743 | -static void gen_branch_fpInactive(DisasContext *s, TCGCond cond, | 113 | -ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env, |
744 | - TCGLabel *label) | 114 | - bool secstate, bool priv) |
745 | -{ | 115 | -{ |
746 | - /* | 116 | - bool negpri = armv7m_nvic_neg_prio_requested(env->nvic, secstate); |
747 | - * FPCXT_NS is a special case: it has specific handling for | ||
748 | - * "current FP state is inactive", and must do the PreserveFPState() | ||
749 | - * but not the usual full set of actions done by ExecuteFPCheck(). | ||
750 | - * We don't have a TB flag that matches the fpInactive check, so we | ||
751 | - * do it at runtime as we don't expect FPCXT_NS accesses to be frequent. | ||
752 | - * | ||
753 | - * Emit code that checks fpInactive and does a conditional | ||
754 | - * branch to label based on it: | ||
755 | - * if cond is TCG_COND_NE then branch if fpInactive != 0 (ie if inactive) | ||
756 | - * if cond is TCG_COND_EQ then branch if fpInactive == 0 (ie if active) | ||
757 | - */ | ||
758 | - assert(cond == TCG_COND_EQ || cond == TCG_COND_NE); | ||
759 | - | 117 | - |
760 | - /* fpInactive = FPCCR_NS.ASPEN == 1 && CONTROL.FPCA == 0 */ | 118 | - return arm_v7m_mmu_idx_all(env, secstate, priv, negpri); |
761 | - TCGv_i32 aspen, fpca; | ||
762 | - aspen = load_cpu_field(v7m.fpccr[M_REG_NS]); | ||
763 | - fpca = load_cpu_field(v7m.control[M_REG_S]); | ||
764 | - tcg_gen_andi_i32(aspen, aspen, R_V7M_FPCCR_ASPEN_MASK); | ||
765 | - tcg_gen_xori_i32(aspen, aspen, R_V7M_FPCCR_ASPEN_MASK); | ||
766 | - tcg_gen_andi_i32(fpca, fpca, R_V7M_CONTROL_FPCA_MASK); | ||
767 | - tcg_gen_or_i32(fpca, fpca, aspen); | ||
768 | - tcg_gen_brcondi_i32(tcg_invert_cond(cond), fpca, 0, label); | ||
769 | - tcg_temp_free_i32(aspen); | ||
770 | - tcg_temp_free_i32(fpca); | ||
771 | -} | 119 | -} |
772 | - | 120 | - |
773 | -static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, | 121 | -/* Return the MMU index for a v7M CPU in the specified security state */ |
774 | - fp_sysreg_loadfn *loadfn, | 122 | -ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate) |
775 | - void *opaque) | ||
776 | -{ | 123 | -{ |
777 | - /* Do a write to an M-profile floating point system register */ | 124 | - bool priv = arm_v7m_is_handler_mode(env) || |
778 | - TCGv_i32 tmp; | 125 | - !(env->v7m.control[secstate] & 1); |
779 | - TCGLabel *lab_end = NULL; | ||
780 | - | 126 | - |
781 | - switch (fp_sysreg_checks(s, regno)) { | 127 | - return arm_v7m_mmu_idx_for_secstate_and_priv(env, secstate, priv); |
782 | - case FPSysRegCheckFailed: | ||
783 | - return false; | ||
784 | - case FPSysRegCheckDone: | ||
785 | - return true; | ||
786 | - case FPSysRegCheckContinue: | ||
787 | - break; | ||
788 | - } | ||
789 | - | ||
790 | - switch (regno) { | ||
791 | - case ARM_VFP_FPSCR: | ||
792 | - tmp = loadfn(s, opaque); | ||
793 | - gen_helper_vfp_set_fpscr(cpu_env, tmp); | ||
794 | - tcg_temp_free_i32(tmp); | ||
795 | - gen_lookup_tb(s); | ||
796 | - break; | ||
797 | - case ARM_VFP_FPSCR_NZCVQC: | ||
798 | - { | ||
799 | - TCGv_i32 fpscr; | ||
800 | - tmp = loadfn(s, opaque); | ||
801 | - if (dc_isar_feature(aa32_mve, s)) { | ||
802 | - /* QC is only present for MVE; otherwise RES0 */ | ||
803 | - TCGv_i32 qc = tcg_temp_new_i32(); | ||
804 | - tcg_gen_andi_i32(qc, tmp, FPCR_QC); | ||
805 | - /* | ||
806 | - * The 4 vfp.qc[] fields need only be "zero" vs "non-zero"; | ||
807 | - * here writing the same value into all elements is simplest. | ||
808 | - */ | ||
809 | - tcg_gen_gvec_dup_i32(MO_32, offsetof(CPUARMState, vfp.qc), | ||
810 | - 16, 16, qc); | ||
811 | - } | ||
812 | - tcg_gen_andi_i32(tmp, tmp, FPCR_NZCV_MASK); | ||
813 | - fpscr = load_cpu_field(vfp.xregs[ARM_VFP_FPSCR]); | ||
814 | - tcg_gen_andi_i32(fpscr, fpscr, ~FPCR_NZCV_MASK); | ||
815 | - tcg_gen_or_i32(fpscr, fpscr, tmp); | ||
816 | - store_cpu_field(fpscr, vfp.xregs[ARM_VFP_FPSCR]); | ||
817 | - tcg_temp_free_i32(tmp); | ||
818 | - break; | ||
819 | - } | ||
820 | - case ARM_VFP_FPCXT_NS: | ||
821 | - lab_end = gen_new_label(); | ||
822 | - /* fpInactive case: write is a NOP, so branch to end */ | ||
823 | - gen_branch_fpInactive(s, TCG_COND_NE, lab_end); | ||
824 | - /* | ||
825 | - * !fpInactive: if FPU disabled, take NOCP exception; | ||
826 | - * otherwise PreserveFPState(), and then FPCXT_NS writes | ||
827 | - * behave the same as FPCXT_S writes. | ||
828 | - */ | ||
829 | - if (s->fp_excp_el) { | ||
830 | - gen_exception_insn(s, s->pc_curr, EXCP_NOCP, | ||
831 | - syn_uncategorized(), s->fp_excp_el); | ||
832 | - /* | ||
833 | - * This was only a conditional exception, so override | ||
834 | - * gen_exception_insn()'s default to DISAS_NORETURN | ||
835 | - */ | ||
836 | - s->base.is_jmp = DISAS_NEXT; | ||
837 | - break; | ||
838 | - } | ||
839 | - gen_preserve_fp_state(s); | ||
840 | - /* fall through */ | ||
841 | - case ARM_VFP_FPCXT_S: | ||
842 | - { | ||
843 | - TCGv_i32 sfpa, control; | ||
844 | - /* | ||
845 | - * Set FPSCR and CONTROL.SFPA from value; the new FPSCR takes | ||
846 | - * bits [27:0] from value and zeroes bits [31:28]. | ||
847 | - */ | ||
848 | - tmp = loadfn(s, opaque); | ||
849 | - sfpa = tcg_temp_new_i32(); | ||
850 | - tcg_gen_shri_i32(sfpa, tmp, 31); | ||
851 | - control = load_cpu_field(v7m.control[M_REG_S]); | ||
852 | - tcg_gen_deposit_i32(control, control, sfpa, | ||
853 | - R_V7M_CONTROL_SFPA_SHIFT, 1); | ||
854 | - store_cpu_field(control, v7m.control[M_REG_S]); | ||
855 | - tcg_gen_andi_i32(tmp, tmp, ~FPCR_NZCV_MASK); | ||
856 | - gen_helper_vfp_set_fpscr(cpu_env, tmp); | ||
857 | - tcg_temp_free_i32(tmp); | ||
858 | - tcg_temp_free_i32(sfpa); | ||
859 | - break; | ||
860 | - } | ||
861 | - case ARM_VFP_VPR: | ||
862 | - /* Behaves as NOP if not privileged */ | ||
863 | - if (IS_USER(s)) { | ||
864 | - break; | ||
865 | - } | ||
866 | - tmp = loadfn(s, opaque); | ||
867 | - store_cpu_field(tmp, v7m.vpr); | ||
868 | - break; | ||
869 | - case ARM_VFP_P0: | ||
870 | - { | ||
871 | - TCGv_i32 vpr; | ||
872 | - tmp = loadfn(s, opaque); | ||
873 | - vpr = load_cpu_field(v7m.vpr); | ||
874 | - tcg_gen_deposit_i32(vpr, vpr, tmp, | ||
875 | - R_V7M_VPR_P0_SHIFT, R_V7M_VPR_P0_LENGTH); | ||
876 | - store_cpu_field(vpr, v7m.vpr); | ||
877 | - tcg_temp_free_i32(tmp); | ||
878 | - break; | ||
879 | - } | ||
880 | - default: | ||
881 | - g_assert_not_reached(); | ||
882 | - } | ||
883 | - if (lab_end) { | ||
884 | - gen_set_label(lab_end); | ||
885 | - } | ||
886 | - return true; | ||
887 | -} | 128 | -} |
888 | - | 129 | - |
889 | -static bool gen_M_fp_sysreg_read(DisasContext *s, int regno, | 130 | #endif /* !CONFIG_USER_ONLY */ |
890 | - fp_sysreg_storefn *storefn, | ||
891 | - void *opaque) | ||
892 | -{ | ||
893 | - /* Do a read from an M-profile floating point system register */ | ||
894 | - TCGv_i32 tmp; | ||
895 | - TCGLabel *lab_end = NULL; | ||
896 | - bool lookup_tb = false; | ||
897 | - | ||
898 | - switch (fp_sysreg_checks(s, regno)) { | ||
899 | - case FPSysRegCheckFailed: | ||
900 | - return false; | ||
901 | - case FPSysRegCheckDone: | ||
902 | - return true; | ||
903 | - case FPSysRegCheckContinue: | ||
904 | - break; | ||
905 | - } | ||
906 | - | ||
907 | - if (regno == ARM_VFP_FPSCR_NZCVQC && !dc_isar_feature(aa32_mve, s)) { | ||
908 | - /* QC is RES0 without MVE, so NZCVQC simplifies to NZCV */ | ||
909 | - regno = QEMU_VFP_FPSCR_NZCV; | ||
910 | - } | ||
911 | - | ||
912 | - switch (regno) { | ||
913 | - case ARM_VFP_FPSCR: | ||
914 | - tmp = tcg_temp_new_i32(); | ||
915 | - gen_helper_vfp_get_fpscr(tmp, cpu_env); | ||
916 | - storefn(s, opaque, tmp); | ||
917 | - break; | ||
918 | - case ARM_VFP_FPSCR_NZCVQC: | ||
919 | - tmp = tcg_temp_new_i32(); | ||
920 | - gen_helper_vfp_get_fpscr(tmp, cpu_env); | ||
921 | - tcg_gen_andi_i32(tmp, tmp, FPCR_NZCVQC_MASK); | ||
922 | - storefn(s, opaque, tmp); | ||
923 | - break; | ||
924 | - case QEMU_VFP_FPSCR_NZCV: | ||
925 | - /* | ||
926 | - * Read just NZCV; this is a special case to avoid the | ||
927 | - * helper call for the "VMRS to CPSR.NZCV" insn. | ||
928 | - */ | ||
929 | - tmp = load_cpu_field(vfp.xregs[ARM_VFP_FPSCR]); | ||
930 | - tcg_gen_andi_i32(tmp, tmp, FPCR_NZCV_MASK); | ||
931 | - storefn(s, opaque, tmp); | ||
932 | - break; | ||
933 | - case ARM_VFP_FPCXT_S: | ||
934 | - { | ||
935 | - TCGv_i32 control, sfpa, fpscr; | ||
936 | - /* Bits [27:0] from FPSCR, bit [31] from CONTROL.SFPA */ | ||
937 | - tmp = tcg_temp_new_i32(); | ||
938 | - sfpa = tcg_temp_new_i32(); | ||
939 | - gen_helper_vfp_get_fpscr(tmp, cpu_env); | ||
940 | - tcg_gen_andi_i32(tmp, tmp, ~FPCR_NZCV_MASK); | ||
941 | - control = load_cpu_field(v7m.control[M_REG_S]); | ||
942 | - tcg_gen_andi_i32(sfpa, control, R_V7M_CONTROL_SFPA_MASK); | ||
943 | - tcg_gen_shli_i32(sfpa, sfpa, 31 - R_V7M_CONTROL_SFPA_SHIFT); | ||
944 | - tcg_gen_or_i32(tmp, tmp, sfpa); | ||
945 | - tcg_temp_free_i32(sfpa); | ||
946 | - /* | ||
947 | - * Store result before updating FPSCR etc, in case | ||
948 | - * it is a memory write which causes an exception. | ||
949 | - */ | ||
950 | - storefn(s, opaque, tmp); | ||
951 | - /* | ||
952 | - * Now we must reset FPSCR from FPDSCR_NS, and clear | ||
953 | - * CONTROL.SFPA; so we'll end the TB here. | ||
954 | - */ | ||
955 | - tcg_gen_andi_i32(control, control, ~R_V7M_CONTROL_SFPA_MASK); | ||
956 | - store_cpu_field(control, v7m.control[M_REG_S]); | ||
957 | - fpscr = load_cpu_field(v7m.fpdscr[M_REG_NS]); | ||
958 | - gen_helper_vfp_set_fpscr(cpu_env, fpscr); | ||
959 | - tcg_temp_free_i32(fpscr); | ||
960 | - lookup_tb = true; | ||
961 | - break; | ||
962 | - } | ||
963 | - case ARM_VFP_FPCXT_NS: | ||
964 | - { | ||
965 | - TCGv_i32 control, sfpa, fpscr, fpdscr, zero; | ||
966 | - TCGLabel *lab_active = gen_new_label(); | ||
967 | - | ||
968 | - lookup_tb = true; | ||
969 | - | ||
970 | - gen_branch_fpInactive(s, TCG_COND_EQ, lab_active); | ||
971 | - /* fpInactive case: reads as FPDSCR_NS */ | ||
972 | - TCGv_i32 tmp = load_cpu_field(v7m.fpdscr[M_REG_NS]); | ||
973 | - storefn(s, opaque, tmp); | ||
974 | - lab_end = gen_new_label(); | ||
975 | - tcg_gen_br(lab_end); | ||
976 | - | ||
977 | - gen_set_label(lab_active); | ||
978 | - /* | ||
979 | - * !fpInactive: if FPU disabled, take NOCP exception; | ||
980 | - * otherwise PreserveFPState(), and then FPCXT_NS | ||
981 | - * reads the same as FPCXT_S. | ||
982 | - */ | ||
983 | - if (s->fp_excp_el) { | ||
984 | - gen_exception_insn(s, s->pc_curr, EXCP_NOCP, | ||
985 | - syn_uncategorized(), s->fp_excp_el); | ||
986 | - /* | ||
987 | - * This was only a conditional exception, so override | ||
988 | - * gen_exception_insn()'s default to DISAS_NORETURN | ||
989 | - */ | ||
990 | - s->base.is_jmp = DISAS_NEXT; | ||
991 | - break; | ||
992 | - } | ||
993 | - gen_preserve_fp_state(s); | ||
994 | - tmp = tcg_temp_new_i32(); | ||
995 | - sfpa = tcg_temp_new_i32(); | ||
996 | - fpscr = tcg_temp_new_i32(); | ||
997 | - gen_helper_vfp_get_fpscr(fpscr, cpu_env); | ||
998 | - tcg_gen_andi_i32(tmp, fpscr, ~FPCR_NZCV_MASK); | ||
999 | - control = load_cpu_field(v7m.control[M_REG_S]); | ||
1000 | - tcg_gen_andi_i32(sfpa, control, R_V7M_CONTROL_SFPA_MASK); | ||
1001 | - tcg_gen_shli_i32(sfpa, sfpa, 31 - R_V7M_CONTROL_SFPA_SHIFT); | ||
1002 | - tcg_gen_or_i32(tmp, tmp, sfpa); | ||
1003 | - tcg_temp_free_i32(control); | ||
1004 | - /* Store result before updating FPSCR, in case it faults */ | ||
1005 | - storefn(s, opaque, tmp); | ||
1006 | - /* If SFPA is zero then set FPSCR from FPDSCR_NS */ | ||
1007 | - fpdscr = load_cpu_field(v7m.fpdscr[M_REG_NS]); | ||
1008 | - zero = tcg_const_i32(0); | ||
1009 | - tcg_gen_movcond_i32(TCG_COND_EQ, fpscr, sfpa, zero, fpdscr, fpscr); | ||
1010 | - gen_helper_vfp_set_fpscr(cpu_env, fpscr); | ||
1011 | - tcg_temp_free_i32(zero); | ||
1012 | - tcg_temp_free_i32(sfpa); | ||
1013 | - tcg_temp_free_i32(fpdscr); | ||
1014 | - tcg_temp_free_i32(fpscr); | ||
1015 | - break; | ||
1016 | - } | ||
1017 | - case ARM_VFP_VPR: | ||
1018 | - /* Behaves as NOP if not privileged */ | ||
1019 | - if (IS_USER(s)) { | ||
1020 | - break; | ||
1021 | - } | ||
1022 | - tmp = load_cpu_field(v7m.vpr); | ||
1023 | - storefn(s, opaque, tmp); | ||
1024 | - break; | ||
1025 | - case ARM_VFP_P0: | ||
1026 | - tmp = load_cpu_field(v7m.vpr); | ||
1027 | - tcg_gen_extract_i32(tmp, tmp, R_V7M_VPR_P0_SHIFT, R_V7M_VPR_P0_LENGTH); | ||
1028 | - storefn(s, opaque, tmp); | ||
1029 | - break; | ||
1030 | - default: | ||
1031 | - g_assert_not_reached(); | ||
1032 | - } | ||
1033 | - | ||
1034 | - if (lab_end) { | ||
1035 | - gen_set_label(lab_end); | ||
1036 | - } | ||
1037 | - if (lookup_tb) { | ||
1038 | - gen_lookup_tb(s); | ||
1039 | - } | ||
1040 | - return true; | ||
1041 | -} | ||
1042 | - | ||
1043 | -static void fp_sysreg_to_gpr(DisasContext *s, void *opaque, TCGv_i32 value) | ||
1044 | -{ | ||
1045 | - arg_VMSR_VMRS *a = opaque; | ||
1046 | - | ||
1047 | - if (a->rt == 15) { | ||
1048 | - /* Set the 4 flag bits in the CPSR */ | ||
1049 | - gen_set_nzcv(value); | ||
1050 | - tcg_temp_free_i32(value); | ||
1051 | - } else { | ||
1052 | - store_reg(s, a->rt, value); | ||
1053 | - } | ||
1054 | -} | ||
1055 | - | ||
1056 | -static TCGv_i32 gpr_to_fp_sysreg(DisasContext *s, void *opaque) | ||
1057 | -{ | ||
1058 | - arg_VMSR_VMRS *a = opaque; | ||
1059 | - | ||
1060 | - return load_reg(s, a->rt); | ||
1061 | -} | ||
1062 | - | ||
1063 | -static bool gen_M_VMSR_VMRS(DisasContext *s, arg_VMSR_VMRS *a) | ||
1064 | -{ | ||
1065 | - /* | ||
1066 | - * Accesses to R15 are UNPREDICTABLE; we choose to undef. | ||
1067 | - * FPSCR -> r15 is a special case which writes to the PSR flags; | ||
1068 | - * set a->reg to a special value to tell gen_M_fp_sysreg_read() | ||
1069 | - * we only care about the top 4 bits of FPSCR there. | ||
1070 | - */ | ||
1071 | - if (a->rt == 15) { | ||
1072 | - if (a->l && a->reg == ARM_VFP_FPSCR) { | ||
1073 | - a->reg = QEMU_VFP_FPSCR_NZCV; | ||
1074 | - } else { | ||
1075 | - return false; | ||
1076 | - } | ||
1077 | - } | ||
1078 | - | ||
1079 | - if (a->l) { | ||
1080 | - /* VMRS, move FP system register to gp register */ | ||
1081 | - return gen_M_fp_sysreg_read(s, a->reg, fp_sysreg_to_gpr, a); | ||
1082 | - } else { | ||
1083 | - /* VMSR, move gp register to FP system register */ | ||
1084 | - return gen_M_fp_sysreg_write(s, a->reg, gpr_to_fp_sysreg, a); | ||
1085 | - } | ||
1086 | -} | ||
1087 | - | ||
1088 | static bool trans_VMSR_VMRS(DisasContext *s, arg_VMSR_VMRS *a) | ||
1089 | { | ||
1090 | TCGv_i32 tmp; | ||
1091 | bool ignore_vfp_enabled = false; | ||
1092 | |||
1093 | if (arm_dc_feature(s, ARM_FEATURE_M)) { | ||
1094 | - return gen_M_VMSR_VMRS(s, a); | ||
1095 | + /* M profile version was already handled in m-nocp.decode */ | ||
1096 | + return false; | ||
1097 | } | ||
1098 | |||
1099 | if (!dc_isar_feature(aa32_fpsp_v2, s)) { | ||
1100 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMSR_VMRS(DisasContext *s, arg_VMSR_VMRS *a) | ||
1101 | return true; | ||
1102 | } | ||
1103 | |||
1104 | -static void fp_sysreg_to_memory(DisasContext *s, void *opaque, TCGv_i32 value) | ||
1105 | -{ | ||
1106 | - arg_vldr_sysreg *a = opaque; | ||
1107 | - uint32_t offset = a->imm; | ||
1108 | - TCGv_i32 addr; | ||
1109 | - | ||
1110 | - if (!a->a) { | ||
1111 | - offset = -offset; | ||
1112 | - } | ||
1113 | - | ||
1114 | - addr = load_reg(s, a->rn); | ||
1115 | - if (a->p) { | ||
1116 | - tcg_gen_addi_i32(addr, addr, offset); | ||
1117 | - } | ||
1118 | - | ||
1119 | - if (s->v8m_stackcheck && a->rn == 13 && a->w) { | ||
1120 | - gen_helper_v8m_stackcheck(cpu_env, addr); | ||
1121 | - } | ||
1122 | - | ||
1123 | - gen_aa32_st_i32(s, value, addr, get_mem_index(s), | ||
1124 | - MO_UL | MO_ALIGN | s->be_data); | ||
1125 | - tcg_temp_free_i32(value); | ||
1126 | - | ||
1127 | - if (a->w) { | ||
1128 | - /* writeback */ | ||
1129 | - if (!a->p) { | ||
1130 | - tcg_gen_addi_i32(addr, addr, offset); | ||
1131 | - } | ||
1132 | - store_reg(s, a->rn, addr); | ||
1133 | - } else { | ||
1134 | - tcg_temp_free_i32(addr); | ||
1135 | - } | ||
1136 | -} | ||
1137 | - | ||
1138 | -static TCGv_i32 memory_to_fp_sysreg(DisasContext *s, void *opaque) | ||
1139 | -{ | ||
1140 | - arg_vldr_sysreg *a = opaque; | ||
1141 | - uint32_t offset = a->imm; | ||
1142 | - TCGv_i32 addr; | ||
1143 | - TCGv_i32 value = tcg_temp_new_i32(); | ||
1144 | - | ||
1145 | - if (!a->a) { | ||
1146 | - offset = -offset; | ||
1147 | - } | ||
1148 | - | ||
1149 | - addr = load_reg(s, a->rn); | ||
1150 | - if (a->p) { | ||
1151 | - tcg_gen_addi_i32(addr, addr, offset); | ||
1152 | - } | ||
1153 | - | ||
1154 | - if (s->v8m_stackcheck && a->rn == 13 && a->w) { | ||
1155 | - gen_helper_v8m_stackcheck(cpu_env, addr); | ||
1156 | - } | ||
1157 | - | ||
1158 | - gen_aa32_ld_i32(s, value, addr, get_mem_index(s), | ||
1159 | - MO_UL | MO_ALIGN | s->be_data); | ||
1160 | - | ||
1161 | - if (a->w) { | ||
1162 | - /* writeback */ | ||
1163 | - if (!a->p) { | ||
1164 | - tcg_gen_addi_i32(addr, addr, offset); | ||
1165 | - } | ||
1166 | - store_reg(s, a->rn, addr); | ||
1167 | - } else { | ||
1168 | - tcg_temp_free_i32(addr); | ||
1169 | - } | ||
1170 | - return value; | ||
1171 | -} | ||
1172 | - | ||
1173 | -static bool trans_VLDR_sysreg(DisasContext *s, arg_vldr_sysreg *a) | ||
1174 | -{ | ||
1175 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { | ||
1176 | - return false; | ||
1177 | - } | ||
1178 | - if (a->rn == 15) { | ||
1179 | - return false; | ||
1180 | - } | ||
1181 | - return gen_M_fp_sysreg_write(s, a->reg, memory_to_fp_sysreg, a); | ||
1182 | -} | ||
1183 | - | ||
1184 | -static bool trans_VSTR_sysreg(DisasContext *s, arg_vldr_sysreg *a) | ||
1185 | -{ | ||
1186 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { | ||
1187 | - return false; | ||
1188 | - } | ||
1189 | - if (a->rn == 15) { | ||
1190 | - return false; | ||
1191 | - } | ||
1192 | - return gen_M_fp_sysreg_read(s, a->reg, fp_sysreg_to_memory, a); | ||
1193 | -} | ||
1194 | |||
1195 | static bool trans_VMOV_half(DisasContext *s, arg_VMOV_single *a) | ||
1196 | { | ||
1197 | -- | 131 | -- |
1198 | 2.20.1 | 132 | 2.34.1 |
1199 | 133 | ||
1200 | 134 | diff view generated by jsdifflib |
1 | Implement the MVE VMLALDAV insn, which multiplies pairs of integer | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | elements, accumulating them into a 64-bit result in a pair of | ||
3 | general-purpose registers. | ||
4 | 2 | ||
3 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
5 | Message-id: 20230206223502.25122-5-philmd@linaro.org | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20210617121628.20116-20-peter.maydell@linaro.org | ||
8 | --- | 7 | --- |
9 | target/arm/helper-mve.h | 8 ++++ | 8 | target/arm/helper.c | 12 ++++++++++-- |
10 | target/arm/translate.h | 10 ++++ | 9 | 1 file changed, 10 insertions(+), 2 deletions(-) |
11 | target/arm/mve.decode | 15 ++++++ | ||
12 | target/arm/mve_helper.c | 34 ++++++++++++++ | ||
13 | target/arm/translate-mve.c | 96 ++++++++++++++++++++++++++++++++++++++ | ||
14 | 5 files changed, 163 insertions(+) | ||
15 | 10 | ||
16 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 11 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
17 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/helper-mve.h | 13 | --- a/target/arm/helper.c |
19 | +++ b/target/arm/helper-mve.h | 14 | +++ b/target/arm/helper.c |
20 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vmulltsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 15 | @@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu) |
21 | DEF_HELPER_FLAGS_4(mve_vmulltub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
22 | DEF_HELPER_FLAGS_4(mve_vmulltuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
23 | DEF_HELPER_FLAGS_4(mve_vmulltuw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
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 | +DEF_HELPER_FLAGS_4(mve_vmlaldavxsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
29 | + | ||
30 | +DEF_HELPER_FLAGS_4(mve_vmlaldavuh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
31 | +DEF_HELPER_FLAGS_4(mve_vmlaldavuw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
32 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/target/arm/translate.h | ||
35 | +++ b/target/arm/translate.h | ||
36 | @@ -XXX,XX +XXX,XX @@ static inline int negate(DisasContext *s, int x) | ||
37 | return -x; | ||
38 | } | ||
39 | |||
40 | +static inline int plus_1(DisasContext *s, int x) | ||
41 | +{ | ||
42 | + return x + 1; | ||
43 | +} | ||
44 | + | ||
45 | static inline int plus_2(DisasContext *s, int x) | ||
46 | { | ||
47 | return x + 2; | ||
48 | @@ -XXX,XX +XXX,XX @@ static inline int times_4(DisasContext *s, int x) | ||
49 | return x * 4; | ||
50 | } | ||
51 | |||
52 | +static inline int times_2_plus_1(DisasContext *s, int x) | ||
53 | +{ | ||
54 | + return x * 2 + 1; | ||
55 | +} | ||
56 | + | ||
57 | static inline int arm_dc_feature(DisasContext *dc, int feature) | ||
58 | { | ||
59 | return (dc->features & (1ULL << feature)) != 0; | ||
60 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/target/arm/mve.decode | ||
63 | +++ b/target/arm/mve.decode | ||
64 | @@ -XXX,XX +XXX,XX @@ VNEG_fp 1111 1111 1 . 11 .. 01 ... 0 0111 11 . 0 ... 0 @1op | ||
65 | VDUP 1110 1110 1 1 10 ... 0 .... 1011 . 0 0 1 0000 @vdup size=0 | ||
66 | VDUP 1110 1110 1 0 10 ... 0 .... 1011 . 0 1 1 0000 @vdup size=1 | ||
67 | VDUP 1110 1110 1 0 10 ... 0 .... 1011 . 0 0 1 0000 @vdup size=2 | ||
68 | + | ||
69 | +# multiply-add long dual accumulate | ||
70 | +# rdahi: bits [3:1] from insn, bit 0 is 1 | ||
71 | +# rdalo: bits [3:1] from insn, bit 0 is 0 | ||
72 | +%rdahi 20:3 !function=times_2_plus_1 | ||
73 | +%rdalo 13:3 !function=times_2 | ||
74 | +# size bit is 0 for 16 bit, 1 for 32 bit | ||
75 | +%size_16 16:1 !function=plus_1 | ||
76 | + | ||
77 | +&vmlaldav rdahi rdalo size qn qm x a | ||
78 | + | ||
79 | +@vmlaldav .... .... . ... ... . ... . .... .... qm:3 . \ | ||
80 | + qn=%qn rdahi=%rdahi rdalo=%rdalo size=%size_16 &vmlaldav | ||
81 | +VMLALDAV_S 1110 1110 1 ... ... . ... x:1 1110 . 0 a:1 0 ... 0 @vmlaldav | ||
82 | +VMLALDAV_U 1111 1110 1 ... ... . ... x:1 1110 . 0 a:1 0 ... 0 @vmlaldav | ||
83 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
84 | index XXXXXXX..XXXXXXX 100644 | ||
85 | --- a/target/arm/mve_helper.c | ||
86 | +++ b/target/arm/mve_helper.c | ||
87 | @@ -XXX,XX +XXX,XX @@ DO_2OP_S(vhadds, do_vhadd_s) | ||
88 | DO_2OP_U(vhaddu, do_vhadd_u) | ||
89 | DO_2OP_S(vhsubs, do_vhsub_s) | ||
90 | DO_2OP_U(vhsubu, do_vhsub_u) | ||
91 | + | ||
92 | + | ||
93 | +/* | ||
94 | + * Multiply add long dual accumulate ops. | ||
95 | + */ | ||
96 | +#define DO_LDAV(OP, ESIZE, TYPE, XCHG, EVENACC, ODDACC) \ | ||
97 | + uint64_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vn, \ | ||
98 | + void *vm, uint64_t a) \ | ||
99 | + { \ | ||
100 | + uint16_t mask = mve_element_mask(env); \ | ||
101 | + unsigned e; \ | ||
102 | + TYPE *n = vn, *m = vm; \ | ||
103 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
104 | + if (mask & 1) { \ | ||
105 | + if (e & 1) { \ | ||
106 | + a ODDACC \ | ||
107 | + (int64_t)n[H##ESIZE(e - 1 * XCHG)] * m[H##ESIZE(e)]; \ | ||
108 | + } else { \ | ||
109 | + a EVENACC \ | ||
110 | + (int64_t)n[H##ESIZE(e + 1 * XCHG)] * m[H##ESIZE(e)]; \ | ||
111 | + } \ | ||
112 | + } \ | ||
113 | + } \ | ||
114 | + mve_advance_vpt(env); \ | ||
115 | + return a; \ | ||
116 | + } | ||
117 | + | ||
118 | +DO_LDAV(vmlaldavsh, 2, int16_t, false, +=, +=) | ||
119 | +DO_LDAV(vmlaldavxsh, 2, int16_t, true, +=, +=) | ||
120 | +DO_LDAV(vmlaldavsw, 4, int32_t, false, +=, +=) | ||
121 | +DO_LDAV(vmlaldavxsw, 4, int32_t, true, +=, +=) | ||
122 | + | ||
123 | +DO_LDAV(vmlaldavuh, 2, uint16_t, false, +=, +=) | ||
124 | +DO_LDAV(vmlaldavuw, 4, uint32_t, false, +=, +=) | ||
125 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
126 | index XXXXXXX..XXXXXXX 100644 | ||
127 | --- a/target/arm/translate-mve.c | ||
128 | +++ b/target/arm/translate-mve.c | ||
129 | @@ -XXX,XX +XXX,XX @@ | ||
130 | typedef void MVEGenLdStFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
131 | typedef void MVEGenOneOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
132 | typedef void MVEGenTwoOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
133 | +typedef void MVEGenDualAccOpFn(TCGv_i64, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
134 | |||
135 | /* Return the offset of a Qn register (same semantics as aa32_vfp_qreg()) */ | ||
136 | static inline long mve_qreg_offset(unsigned reg) | ||
137 | @@ -XXX,XX +XXX,XX @@ static void mve_update_eci(DisasContext *s) | ||
138 | } | 16 | } |
139 | } | 17 | } |
140 | 18 | ||
141 | +static bool mve_skip_first_beat(DisasContext *s) | 19 | +#ifndef CONFIG_USER_ONLY |
142 | +{ | 20 | /* |
143 | + /* Return true if PSR.ECI says we must skip the first beat of this insn */ | 21 | * We don't know until after realize whether there's a GICv3 |
144 | + switch (s->eci) { | 22 | * attached, and that is what registers the gicv3 sysregs. |
145 | + case ECI_NONE: | 23 | @@ -XXX,XX +XXX,XX @@ static uint64_t id_pfr1_read(CPUARMState *env, const ARMCPRegInfo *ri) |
146 | + return false; | 24 | return pfr1; |
147 | + case ECI_A0: | 25 | } |
148 | + case ECI_A0A1: | 26 | |
149 | + case ECI_A0A1A2: | 27 | -#ifndef CONFIG_USER_ONLY |
150 | + case ECI_A0A1A2B0: | 28 | static uint64_t id_aa64pfr0_read(CPUARMState *env, const ARMCPRegInfo *ri) |
151 | + return true; | ||
152 | + default: | ||
153 | + g_assert_not_reached(); | ||
154 | + } | ||
155 | +} | ||
156 | + | ||
157 | static bool do_ldst(DisasContext *s, arg_VLDR_VSTR *a, MVEGenLdStFn *fn) | ||
158 | { | 29 | { |
159 | TCGv_i32 addr; | 30 | ARMCPU *cpu = env_archcpu(env); |
160 | @@ -XXX,XX +XXX,XX @@ DO_2OP(VMULL_BS, vmullbs) | 31 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
161 | DO_2OP(VMULL_BU, vmullbu) | 32 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 1, |
162 | DO_2OP(VMULL_TS, vmullts) | 33 | .access = PL1_R, .type = ARM_CP_NO_RAW, |
163 | DO_2OP(VMULL_TU, vmulltu) | 34 | .accessfn = access_aa32_tid3, |
164 | + | 35 | +#ifdef CONFIG_USER_ONLY |
165 | +static bool do_long_dual_acc(DisasContext *s, arg_vmlaldav *a, | 36 | + .type = ARM_CP_CONST, |
166 | + MVEGenDualAccOpFn *fn) | 37 | + .resetvalue = cpu->isar.id_pfr1, |
167 | +{ | 38 | +#else |
168 | + TCGv_ptr qn, qm; | 39 | + .type = ARM_CP_NO_RAW, |
169 | + TCGv_i64 rda; | 40 | + .accessfn = access_aa32_tid3, |
170 | + TCGv_i32 rdalo, rdahi; | 41 | .readfn = id_pfr1_read, |
171 | + | 42 | - .writefn = arm_cp_write_ignore }, |
172 | + if (!dc_isar_feature(aa32_mve, s) || | 43 | + .writefn = arm_cp_write_ignore |
173 | + !mve_check_qreg_bank(s, a->qn | a->qm) || | 44 | +#endif |
174 | + !fn) { | 45 | + }, |
175 | + return false; | 46 | { .name = "ID_DFR0", .state = ARM_CP_STATE_BOTH, |
176 | + } | 47 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 2, |
177 | + /* | 48 | .access = PL1_R, .type = ARM_CP_CONST, |
178 | + * rdahi == 13 is UNPREDICTABLE; rdahi == 15 is a related | ||
179 | + * encoding; rdalo always has bit 0 clear so cannot be 13 or 15. | ||
180 | + */ | ||
181 | + if (a->rdahi == 13 || a->rdahi == 15) { | ||
182 | + return false; | ||
183 | + } | ||
184 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
185 | + return true; | ||
186 | + } | ||
187 | + | ||
188 | + qn = mve_qreg_ptr(a->qn); | ||
189 | + qm = mve_qreg_ptr(a->qm); | ||
190 | + | ||
191 | + /* | ||
192 | + * This insn is subject to beat-wise execution. Partial execution | ||
193 | + * of an A=0 (no-accumulate) insn which does not execute the first | ||
194 | + * beat must start with the current rda value, not 0. | ||
195 | + */ | ||
196 | + if (a->a || mve_skip_first_beat(s)) { | ||
197 | + rda = tcg_temp_new_i64(); | ||
198 | + rdalo = load_reg(s, a->rdalo); | ||
199 | + rdahi = load_reg(s, a->rdahi); | ||
200 | + tcg_gen_concat_i32_i64(rda, rdalo, rdahi); | ||
201 | + tcg_temp_free_i32(rdalo); | ||
202 | + tcg_temp_free_i32(rdahi); | ||
203 | + } else { | ||
204 | + rda = tcg_const_i64(0); | ||
205 | + } | ||
206 | + | ||
207 | + fn(rda, cpu_env, qn, qm, rda); | ||
208 | + tcg_temp_free_ptr(qn); | ||
209 | + tcg_temp_free_ptr(qm); | ||
210 | + | ||
211 | + rdalo = tcg_temp_new_i32(); | ||
212 | + rdahi = tcg_temp_new_i32(); | ||
213 | + tcg_gen_extrl_i64_i32(rdalo, rda); | ||
214 | + tcg_gen_extrh_i64_i32(rdahi, rda); | ||
215 | + store_reg(s, a->rdalo, rdalo); | ||
216 | + store_reg(s, a->rdahi, rdahi); | ||
217 | + tcg_temp_free_i64(rda); | ||
218 | + mve_update_eci(s); | ||
219 | + return true; | ||
220 | +} | ||
221 | + | ||
222 | +static bool trans_VMLALDAV_S(DisasContext *s, arg_vmlaldav *a) | ||
223 | +{ | ||
224 | + static MVEGenDualAccOpFn * const fns[4][2] = { | ||
225 | + { NULL, NULL }, | ||
226 | + { gen_helper_mve_vmlaldavsh, gen_helper_mve_vmlaldavxsh }, | ||
227 | + { gen_helper_mve_vmlaldavsw, gen_helper_mve_vmlaldavxsw }, | ||
228 | + { NULL, NULL }, | ||
229 | + }; | ||
230 | + return do_long_dual_acc(s, a, fns[a->size][a->x]); | ||
231 | +} | ||
232 | + | ||
233 | +static bool trans_VMLALDAV_U(DisasContext *s, arg_vmlaldav *a) | ||
234 | +{ | ||
235 | + static MVEGenDualAccOpFn * const fns[4][2] = { | ||
236 | + { NULL, NULL }, | ||
237 | + { gen_helper_mve_vmlaldavuh, NULL }, | ||
238 | + { gen_helper_mve_vmlaldavuw, NULL }, | ||
239 | + { NULL, NULL }, | ||
240 | + }; | ||
241 | + return do_long_dual_acc(s, a, fns[a->size][a->x]); | ||
242 | +} | ||
243 | -- | 49 | -- |
244 | 2.20.1 | 50 | 2.34.1 |
245 | 51 | ||
246 | 52 | diff view generated by jsdifflib |
1 | The Arm MVE VDUP implementation would like to be able to emit code to | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | duplicate a byte or halfword value into an i32. We have code to do | ||
3 | this already in tcg-op-gvec.c, so all we need to do is make the | ||
4 | functions global. | ||
5 | |||
6 | For consistency with other functions made available to the frontends: | ||
7 | * we rename to tcg_gen_dup_* | ||
8 | * we expose both the _i32 and _i64 forms | ||
9 | * we provide the #define for a _tl form | ||
10 | 2 | ||
11 | Suggested-by: Richard Henderson <richard.henderson@linaro.org> | 3 | Suggested-by: Richard Henderson <richard.henderson@linaro.org> |
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20230206223502.25122-6-philmd@linaro.org | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Message-id: 20210617121628.20116-10-peter.maydell@linaro.org | ||
15 | --- | 8 | --- |
16 | include/tcg/tcg-op.h | 8 ++++++++ | 9 | linux-user/user-internals.h | 2 +- |
17 | include/tcg/tcg.h | 1 - | 10 | target/arm/cpu.h | 2 +- |
18 | tcg/tcg-op-gvec.c | 20 ++++++++++---------- | 11 | linux-user/arm/cpu_loop.c | 4 ++-- |
19 | 3 files changed, 18 insertions(+), 11 deletions(-) | 12 | 3 files changed, 4 insertions(+), 4 deletions(-) |
20 | 13 | ||
21 | diff --git a/include/tcg/tcg-op.h b/include/tcg/tcg-op.h | 14 | diff --git a/linux-user/user-internals.h b/linux-user/user-internals.h |
22 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/include/tcg/tcg-op.h | 16 | --- a/linux-user/user-internals.h |
24 | +++ b/include/tcg/tcg-op.h | 17 | +++ b/linux-user/user-internals.h |
25 | @@ -XXX,XX +XXX,XX @@ void tcg_gen_umin_i32(TCGv_i32, TCGv_i32 arg1, TCGv_i32 arg2); | 18 | @@ -XXX,XX +XXX,XX @@ void print_termios(void *arg); |
26 | void tcg_gen_umax_i32(TCGv_i32, TCGv_i32 arg1, TCGv_i32 arg2); | 19 | #ifdef TARGET_ARM |
27 | void tcg_gen_abs_i32(TCGv_i32, TCGv_i32); | 20 | static inline int regpairs_aligned(CPUArchState *cpu_env, int num) |
28 | |||
29 | +/* Replicate a value of size @vece from @in to all the lanes in @out */ | ||
30 | +void tcg_gen_dup_i32(unsigned vece, TCGv_i32 out, TCGv_i32 in); | ||
31 | + | ||
32 | static inline void tcg_gen_discard_i32(TCGv_i32 arg) | ||
33 | { | 21 | { |
34 | tcg_gen_op1_i32(INDEX_op_discard, arg); | 22 | - return cpu_env->eabi == 1; |
35 | @@ -XXX,XX +XXX,XX @@ void tcg_gen_umin_i64(TCGv_i64, TCGv_i64 arg1, TCGv_i64 arg2); | 23 | + return cpu_env->eabi; |
36 | void tcg_gen_umax_i64(TCGv_i64, TCGv_i64 arg1, TCGv_i64 arg2); | 24 | } |
37 | void tcg_gen_abs_i64(TCGv_i64, TCGv_i64); | 25 | #elif defined(TARGET_MIPS) && defined(TARGET_ABI_MIPSO32) |
38 | 26 | static inline int regpairs_aligned(CPUArchState *cpu_env, int num) { return 1; } | |
39 | +/* Replicate a value of size @vece from @in to all the lanes in @out */ | 27 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
40 | +void tcg_gen_dup_i64(unsigned vece, TCGv_i64 out, TCGv_i64 in); | 28 | index XXXXXXX..XXXXXXX 100644 |
41 | + | 29 | --- a/target/arm/cpu.h |
42 | #if TCG_TARGET_REG_BITS == 64 | 30 | +++ b/target/arm/cpu.h |
43 | static inline void tcg_gen_discard_i64(TCGv_i64 arg) | 31 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { |
44 | { | 32 | |
45 | @@ -XXX,XX +XXX,XX @@ void tcg_gen_stl_vec(TCGv_vec r, TCGv_ptr base, TCGArg offset, TCGType t); | 33 | #if defined(CONFIG_USER_ONLY) |
46 | #define tcg_gen_atomic_smax_fetch_tl tcg_gen_atomic_smax_fetch_i64 | 34 | /* For usermode syscall translation. */ |
47 | #define tcg_gen_atomic_umax_fetch_tl tcg_gen_atomic_umax_fetch_i64 | 35 | - int eabi; |
48 | #define tcg_gen_dup_tl_vec tcg_gen_dup_i64_vec | 36 | + bool eabi; |
49 | +#define tcg_gen_dup_tl tcg_gen_dup_i64 | ||
50 | #else | ||
51 | #define tcg_gen_movi_tl tcg_gen_movi_i32 | ||
52 | #define tcg_gen_mov_tl tcg_gen_mov_i32 | ||
53 | @@ -XXX,XX +XXX,XX @@ void tcg_gen_stl_vec(TCGv_vec r, TCGv_ptr base, TCGArg offset, TCGType t); | ||
54 | #define tcg_gen_atomic_smax_fetch_tl tcg_gen_atomic_smax_fetch_i32 | ||
55 | #define tcg_gen_atomic_umax_fetch_tl tcg_gen_atomic_umax_fetch_i32 | ||
56 | #define tcg_gen_dup_tl_vec tcg_gen_dup_i32_vec | ||
57 | +#define tcg_gen_dup_tl tcg_gen_dup_i32 | ||
58 | #endif | 37 | #endif |
59 | 38 | ||
60 | #if UINTPTR_MAX == UINT32_MAX | 39 | struct CPUBreakpoint *cpu_breakpoint[16]; |
61 | diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h | 40 | diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c |
62 | index XXXXXXX..XXXXXXX 100644 | 41 | index XXXXXXX..XXXXXXX 100644 |
63 | --- a/include/tcg/tcg.h | 42 | --- a/linux-user/arm/cpu_loop.c |
64 | +++ b/include/tcg/tcg.h | 43 | +++ b/linux-user/arm/cpu_loop.c |
65 | @@ -XXX,XX +XXX,XX @@ uint64_t dup_const(unsigned vece, uint64_t c); | 44 | @@ -XXX,XX +XXX,XX @@ void cpu_loop(CPUARMState *env) |
66 | : (qemu_build_not_reached_always(), 0)) \ | 45 | break; |
67 | : dup_const(VECE, C)) | 46 | case EXCP_SWI: |
68 | 47 | { | |
69 | - | 48 | - env->eabi = 1; |
70 | /* | 49 | + env->eabi = true; |
71 | * Memory helpers that will be used by TCG generated code. | 50 | /* system call */ |
72 | */ | 51 | if (env->thumb) { |
73 | diff --git a/tcg/tcg-op-gvec.c b/tcg/tcg-op-gvec.c | 52 | /* Thumb is always EABI style with syscall number in r7 */ |
74 | index XXXXXXX..XXXXXXX 100644 | 53 | @@ -XXX,XX +XXX,XX @@ void cpu_loop(CPUARMState *env) |
75 | --- a/tcg/tcg-op-gvec.c | 54 | * > 0xfffff and are handled below as out-of-range. |
76 | +++ b/tcg/tcg-op-gvec.c | 55 | */ |
77 | @@ -XXX,XX +XXX,XX @@ uint64_t (dup_const)(unsigned vece, uint64_t c) | 56 | n ^= ARM_SYSCALL_BASE; |
78 | } | 57 | - env->eabi = 0; |
79 | 58 | + env->eabi = false; | |
80 | /* Duplicate IN into OUT as per VECE. */ | 59 | } |
81 | -static void gen_dup_i32(unsigned vece, TCGv_i32 out, TCGv_i32 in) | 60 | } |
82 | +void tcg_gen_dup_i32(unsigned vece, TCGv_i32 out, TCGv_i32 in) | 61 | |
83 | { | ||
84 | switch (vece) { | ||
85 | case MO_8: | ||
86 | @@ -XXX,XX +XXX,XX @@ static void gen_dup_i32(unsigned vece, TCGv_i32 out, TCGv_i32 in) | ||
87 | } | ||
88 | } | ||
89 | |||
90 | -static void gen_dup_i64(unsigned vece, TCGv_i64 out, TCGv_i64 in) | ||
91 | +void tcg_gen_dup_i64(unsigned vece, TCGv_i64 out, TCGv_i64 in) | ||
92 | { | ||
93 | switch (vece) { | ||
94 | case MO_8: | ||
95 | @@ -XXX,XX +XXX,XX @@ static void do_dup(unsigned vece, uint32_t dofs, uint32_t oprsz, | ||
96 | && (vece != MO_32 || !check_size_impl(oprsz, 4))) { | ||
97 | t_64 = tcg_temp_new_i64(); | ||
98 | tcg_gen_extu_i32_i64(t_64, in_32); | ||
99 | - gen_dup_i64(vece, t_64, t_64); | ||
100 | + tcg_gen_dup_i64(vece, t_64, t_64); | ||
101 | } else { | ||
102 | t_32 = tcg_temp_new_i32(); | ||
103 | - gen_dup_i32(vece, t_32, in_32); | ||
104 | + tcg_gen_dup_i32(vece, t_32, in_32); | ||
105 | } | ||
106 | } else if (in_64) { | ||
107 | /* We are given a 64-bit variable input. */ | ||
108 | t_64 = tcg_temp_new_i64(); | ||
109 | - gen_dup_i64(vece, t_64, in_64); | ||
110 | + tcg_gen_dup_i64(vece, t_64, in_64); | ||
111 | } else { | ||
112 | /* We are given a constant input. */ | ||
113 | /* For 64-bit hosts, use 64-bit constants for "simple" constants | ||
114 | @@ -XXX,XX +XXX,XX @@ void tcg_gen_gvec_2s(uint32_t dofs, uint32_t aofs, uint32_t oprsz, | ||
115 | } else if (g->fni8 && check_size_impl(oprsz, 8)) { | ||
116 | TCGv_i64 t64 = tcg_temp_new_i64(); | ||
117 | |||
118 | - gen_dup_i64(g->vece, t64, c); | ||
119 | + tcg_gen_dup_i64(g->vece, t64, c); | ||
120 | expand_2s_i64(dofs, aofs, oprsz, t64, g->scalar_first, g->fni8); | ||
121 | tcg_temp_free_i64(t64); | ||
122 | } else if (g->fni4 && check_size_impl(oprsz, 4)) { | ||
123 | TCGv_i32 t32 = tcg_temp_new_i32(); | ||
124 | |||
125 | tcg_gen_extrl_i64_i32(t32, c); | ||
126 | - gen_dup_i32(g->vece, t32, t32); | ||
127 | + tcg_gen_dup_i32(g->vece, t32, t32); | ||
128 | expand_2s_i32(dofs, aofs, oprsz, t32, g->scalar_first, g->fni4); | ||
129 | tcg_temp_free_i32(t32); | ||
130 | } else { | ||
131 | @@ -XXX,XX +XXX,XX @@ void tcg_gen_gvec_ands(unsigned vece, uint32_t dofs, uint32_t aofs, | ||
132 | TCGv_i64 c, uint32_t oprsz, uint32_t maxsz) | ||
133 | { | ||
134 | TCGv_i64 tmp = tcg_temp_new_i64(); | ||
135 | - gen_dup_i64(vece, tmp, c); | ||
136 | + tcg_gen_dup_i64(vece, tmp, c); | ||
137 | tcg_gen_gvec_2s(dofs, aofs, oprsz, maxsz, tmp, &gop_ands); | ||
138 | tcg_temp_free_i64(tmp); | ||
139 | } | ||
140 | @@ -XXX,XX +XXX,XX @@ void tcg_gen_gvec_xors(unsigned vece, uint32_t dofs, uint32_t aofs, | ||
141 | TCGv_i64 c, uint32_t oprsz, uint32_t maxsz) | ||
142 | { | ||
143 | TCGv_i64 tmp = tcg_temp_new_i64(); | ||
144 | - gen_dup_i64(vece, tmp, c); | ||
145 | + tcg_gen_dup_i64(vece, tmp, c); | ||
146 | tcg_gen_gvec_2s(dofs, aofs, oprsz, maxsz, tmp, &gop_xors); | ||
147 | tcg_temp_free_i64(tmp); | ||
148 | } | ||
149 | @@ -XXX,XX +XXX,XX @@ void tcg_gen_gvec_ors(unsigned vece, uint32_t dofs, uint32_t aofs, | ||
150 | TCGv_i64 c, uint32_t oprsz, uint32_t maxsz) | ||
151 | { | ||
152 | TCGv_i64 tmp = tcg_temp_new_i64(); | ||
153 | - gen_dup_i64(vece, tmp, c); | ||
154 | + tcg_gen_dup_i64(vece, tmp, c); | ||
155 | tcg_gen_gvec_2s(dofs, aofs, oprsz, maxsz, tmp, &gop_ors); | ||
156 | tcg_temp_free_i64(tmp); | ||
157 | } | ||
158 | -- | 62 | -- |
159 | 2.20.1 | 63 | 2.34.1 |
160 | 64 | ||
161 | 65 | diff view generated by jsdifflib |
1 | Implement the MVE VHCADD insn, which is similar to VCADD | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | but performs a halving step. This one overlaps with VADC. | ||
3 | 2 | ||
3 | Although the 'eabi' field is only used in user emulation where | ||
4 | CPU reset doesn't occur, it doesn't belong to the area to reset. | ||
5 | Move it after the 'end_reset_fields' for consistency. | ||
6 | |||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
9 | Message-id: 20230206223502.25122-7-philmd@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 | Message-id: 20210617121628.20116-43-peter.maydell@linaro.org | ||
7 | --- | 11 | --- |
8 | target/arm/helper-mve.h | 8 ++++++++ | 12 | target/arm/cpu.h | 9 ++++----- |
9 | target/arm/mve.decode | 8 ++++++-- | 13 | 1 file changed, 4 insertions(+), 5 deletions(-) |
10 | target/arm/mve_helper.c | 2 ++ | ||
11 | target/arm/translate-mve.c | 4 +++- | ||
12 | 4 files changed, 19 insertions(+), 3 deletions(-) | ||
13 | 14 | ||
14 | 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 |
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/helper-mve.h | 17 | --- a/target/arm/cpu.h |
17 | +++ b/target/arm/helper-mve.h | 18 | +++ b/target/arm/cpu.h |
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vcadd270b, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 19 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { |
19 | DEF_HELPER_FLAGS_4(mve_vcadd270h, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 20 | ARMVectorReg zarray[ARM_MAX_VQ * 16]; |
20 | DEF_HELPER_FLAGS_4(mve_vcadd270w, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 21 | #endif |
21 | 22 | ||
22 | +DEF_HELPER_FLAGS_4(mve_vhcadd90b, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 23 | -#if defined(CONFIG_USER_ONLY) |
23 | +DEF_HELPER_FLAGS_4(mve_vhcadd90h, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 24 | - /* For usermode syscall translation. */ |
24 | +DEF_HELPER_FLAGS_4(mve_vhcadd90w, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 25 | - bool eabi; |
25 | + | 26 | -#endif |
26 | +DEF_HELPER_FLAGS_4(mve_vhcadd270b, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 27 | - |
27 | +DEF_HELPER_FLAGS_4(mve_vhcadd270h, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 28 | struct CPUBreakpoint *cpu_breakpoint[16]; |
28 | +DEF_HELPER_FLAGS_4(mve_vhcadd270w, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 29 | struct CPUWatchpoint *cpu_watchpoint[16]; |
29 | + | 30 | |
30 | DEF_HELPER_FLAGS_4(mve_vadd_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 31 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { |
31 | DEF_HELPER_FLAGS_4(mve_vadd_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 32 | const struct arm_boot_info *boot_info; |
32 | DEF_HELPER_FLAGS_4(mve_vadd_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 33 | /* Store GICv3CPUState to access from this struct */ |
33 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | 34 | void *gicv3state; |
34 | index XXXXXXX..XXXXXXX 100644 | 35 | +#if defined(CONFIG_USER_ONLY) |
35 | --- a/target/arm/mve.decode | 36 | + /* For usermode syscall translation. */ |
36 | +++ b/target/arm/mve.decode | 37 | + bool eabi; |
37 | @@ -XXX,XX +XXX,XX @@ VQDMULLT 111 . 1110 0 . 11 ... 0 ... 1 1111 . 0 . 0 ... 1 @2op_sz28 | 38 | +#endif /* CONFIG_USER_ONLY */ |
38 | VRHADD_S 111 0 1111 0 . .. ... 0 ... 0 0001 . 1 . 0 ... 0 @2op | 39 | |
39 | VRHADD_U 111 1 1111 0 . .. ... 0 ... 0 0001 . 1 . 0 ... 0 @2op | 40 | #ifdef TARGET_TAGGED_ADDRESSES |
40 | 41 | /* Linux syscall tagged address support */ | |
41 | -VADC 1110 1110 0 . 11 ... 0 ... 0 1111 . 0 . 0 ... 0 @2op_nosz | ||
42 | -VADCI 1110 1110 0 . 11 ... 0 ... 1 1111 . 0 . 0 ... 0 @2op_nosz | ||
43 | +{ | ||
44 | + VADC 1110 1110 0 . 11 ... 0 ... 0 1111 . 0 . 0 ... 0 @2op_nosz | ||
45 | + VADCI 1110 1110 0 . 11 ... 0 ... 1 1111 . 0 . 0 ... 0 @2op_nosz | ||
46 | + VHCADD90 1110 1110 0 . .. ... 0 ... 0 1111 . 0 . 0 ... 0 @2op | ||
47 | + VHCADD270 1110 1110 0 . .. ... 0 ... 1 1111 . 0 . 0 ... 0 @2op | ||
48 | +} | ||
49 | |||
50 | { | ||
51 | VSBC 1111 1110 0 . 11 ... 0 ... 0 1111 . 0 . 0 ... 0 @2op_nosz | ||
52 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | --- a/target/arm/mve_helper.c | ||
55 | +++ b/target/arm/mve_helper.c | ||
56 | @@ -XXX,XX +XXX,XX @@ void HELPER(mve_vsbci)(CPUARMState *env, void *vd, void *vn, void *vm) | ||
57 | |||
58 | DO_VCADD_ALL(vcadd90, DO_SUB, DO_ADD) | ||
59 | DO_VCADD_ALL(vcadd270, DO_ADD, DO_SUB) | ||
60 | +DO_VCADD_ALL(vhcadd90, do_vhsub_s, do_vhadd_s) | ||
61 | +DO_VCADD_ALL(vhcadd270, do_vhadd_s, do_vhsub_s) | ||
62 | |||
63 | static inline int32_t do_sat_bhw(int64_t val, int64_t min, int64_t max, bool *s) | ||
64 | { | ||
65 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
66 | index XXXXXXX..XXXXXXX 100644 | ||
67 | --- a/target/arm/translate-mve.c | ||
68 | +++ b/target/arm/translate-mve.c | ||
69 | @@ -XXX,XX +XXX,XX @@ DO_2OP(VRHADD_U, vrhaddu) | ||
70 | /* | ||
71 | * VCADD Qd == Qm at size MO_32 is UNPREDICTABLE; we choose not to diagnose | ||
72 | * so we can reuse the DO_2OP macro. (Our implementation calculates the | ||
73 | - * "expected" results in this case.) | ||
74 | + * "expected" results in this case.) Similarly for VHCADD. | ||
75 | */ | ||
76 | DO_2OP(VCADD90, vcadd90) | ||
77 | DO_2OP(VCADD270, vcadd270) | ||
78 | +DO_2OP(VHCADD90, vhcadd90) | ||
79 | +DO_2OP(VHCADD270, vhcadd270) | ||
80 | |||
81 | static bool trans_VQDMULLB(DisasContext *s, arg_2op *a) | ||
82 | { | ||
83 | -- | 42 | -- |
84 | 2.20.1 | 43 | 2.34.1 |
85 | 44 | ||
86 | 45 | diff view generated by jsdifflib |
1 | Implement the MVE VCADD insn, which performs a complex add with | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | rotate. Note that the size=0b11 encoding is VSBC. | ||
3 | 2 | ||
4 | The architecture grants some leeway for the "destination and Vm | 3 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | source overlap" case for the size MO_32 case, but we choose not to | 4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
6 | make use of it, instead always calculating all 16 bytes worth of | 5 | Message-id: 20230206223502.25122-8-philmd@linaro.org |
7 | results before setting the destination register. | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | ||
8 | target/arm/cpu.h | 3 ++- | ||
9 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
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 | Message-id: 20210617121628.20116-42-peter.maydell@linaro.org | ||
12 | --- | ||
13 | target/arm/helper-mve.h | 8 ++++++++ | ||
14 | target/arm/mve.decode | 9 +++++++-- | ||
15 | target/arm/mve_helper.c | 29 +++++++++++++++++++++++++++++ | ||
16 | target/arm/translate-mve.c | 7 +++++++ | ||
17 | 4 files changed, 51 insertions(+), 2 deletions(-) | ||
18 | |||
19 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
20 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/helper-mve.h | 13 | --- a/target/arm/cpu.h |
22 | +++ b/target/arm/helper-mve.h | 14 | +++ b/target/arm/cpu.h |
23 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vadci, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 15 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { |
24 | DEF_HELPER_FLAGS_4(mve_vsbc, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 16 | |
25 | DEF_HELPER_FLAGS_4(mve_vsbci, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 17 | void *nvic; |
26 | 18 | const struct arm_boot_info *boot_info; | |
27 | +DEF_HELPER_FLAGS_4(mve_vcadd90b, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 19 | +#if !defined(CONFIG_USER_ONLY) |
28 | +DEF_HELPER_FLAGS_4(mve_vcadd90h, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 20 | /* Store GICv3CPUState to access from this struct */ |
29 | +DEF_HELPER_FLAGS_4(mve_vcadd90w, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 21 | void *gicv3state; |
30 | + | 22 | -#if defined(CONFIG_USER_ONLY) |
31 | +DEF_HELPER_FLAGS_4(mve_vcadd270b, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 23 | +#else /* CONFIG_USER_ONLY */ |
32 | +DEF_HELPER_FLAGS_4(mve_vcadd270h, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 24 | /* For usermode syscall translation. */ |
33 | +DEF_HELPER_FLAGS_4(mve_vcadd270w, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 25 | bool eabi; |
34 | + | 26 | #endif /* CONFIG_USER_ONLY */ |
35 | DEF_HELPER_FLAGS_4(mve_vadd_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
36 | DEF_HELPER_FLAGS_4(mve_vadd_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
37 | DEF_HELPER_FLAGS_4(mve_vadd_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
38 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/target/arm/mve.decode | ||
41 | +++ b/target/arm/mve.decode | ||
42 | @@ -XXX,XX +XXX,XX @@ VRHADD_S 111 0 1111 0 . .. ... 0 ... 0 0001 . 1 . 0 ... 0 @2op | ||
43 | VRHADD_U 111 1 1111 0 . .. ... 0 ... 0 0001 . 1 . 0 ... 0 @2op | ||
44 | |||
45 | VADC 1110 1110 0 . 11 ... 0 ... 0 1111 . 0 . 0 ... 0 @2op_nosz | ||
46 | -VSBC 1111 1110 0 . 11 ... 0 ... 0 1111 . 0 . 0 ... 0 @2op_nosz | ||
47 | VADCI 1110 1110 0 . 11 ... 0 ... 1 1111 . 0 . 0 ... 0 @2op_nosz | ||
48 | -VSBCI 1111 1110 0 . 11 ... 0 ... 1 1111 . 0 . 0 ... 0 @2op_nosz | ||
49 | + | ||
50 | +{ | ||
51 | + VSBC 1111 1110 0 . 11 ... 0 ... 0 1111 . 0 . 0 ... 0 @2op_nosz | ||
52 | + VSBCI 1111 1110 0 . 11 ... 0 ... 1 1111 . 0 . 0 ... 0 @2op_nosz | ||
53 | + VCADD90 1111 1110 0 . .. ... 0 ... 0 1111 . 0 . 0 ... 0 @2op | ||
54 | + VCADD270 1111 1110 0 . .. ... 0 ... 1 1111 . 0 . 0 ... 0 @2op | ||
55 | +} | ||
56 | |||
57 | # Vector miscellaneous | ||
58 | |||
59 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
60 | index XXXXXXX..XXXXXXX 100644 | ||
61 | --- a/target/arm/mve_helper.c | ||
62 | +++ b/target/arm/mve_helper.c | ||
63 | @@ -XXX,XX +XXX,XX @@ void HELPER(mve_vsbci)(CPUARMState *env, void *vd, void *vn, void *vm) | ||
64 | do_vadc(env, vd, vn, vm, -1, 1, true); | ||
65 | } | ||
66 | |||
67 | +#define DO_VCADD(OP, ESIZE, TYPE, FN0, FN1) \ | ||
68 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, void *vm) \ | ||
69 | + { \ | ||
70 | + TYPE *d = vd, *n = vn, *m = vm; \ | ||
71 | + uint16_t mask = mve_element_mask(env); \ | ||
72 | + unsigned e; \ | ||
73 | + TYPE r[16 / ESIZE]; \ | ||
74 | + /* Calculate all results first to avoid overwriting inputs */ \ | ||
75 | + for (e = 0; e < 16 / ESIZE; e++) { \ | ||
76 | + if (!(e & 1)) { \ | ||
77 | + r[e] = FN0(n[H##ESIZE(e)], m[H##ESIZE(e + 1)]); \ | ||
78 | + } else { \ | ||
79 | + r[e] = FN1(n[H##ESIZE(e)], m[H##ESIZE(e - 1)]); \ | ||
80 | + } \ | ||
81 | + } \ | ||
82 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
83 | + mergemask(&d[H##ESIZE(e)], r[e], mask); \ | ||
84 | + } \ | ||
85 | + mve_advance_vpt(env); \ | ||
86 | + } | ||
87 | + | ||
88 | +#define DO_VCADD_ALL(OP, FN0, FN1) \ | ||
89 | + DO_VCADD(OP##b, 1, int8_t, FN0, FN1) \ | ||
90 | + DO_VCADD(OP##h, 2, int16_t, FN0, FN1) \ | ||
91 | + DO_VCADD(OP##w, 4, int32_t, FN0, FN1) | ||
92 | + | ||
93 | +DO_VCADD_ALL(vcadd90, DO_SUB, DO_ADD) | ||
94 | +DO_VCADD_ALL(vcadd270, DO_ADD, DO_SUB) | ||
95 | + | ||
96 | static inline int32_t do_sat_bhw(int64_t val, int64_t min, int64_t max, bool *s) | ||
97 | { | ||
98 | if (val > max) { | ||
99 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
100 | index XXXXXXX..XXXXXXX 100644 | ||
101 | --- a/target/arm/translate-mve.c | ||
102 | +++ b/target/arm/translate-mve.c | ||
103 | @@ -XXX,XX +XXX,XX @@ DO_2OP(VQRDMLSDH, vqrdmlsdh) | ||
104 | DO_2OP(VQRDMLSDHX, vqrdmlsdhx) | ||
105 | DO_2OP(VRHADD_S, vrhadds) | ||
106 | DO_2OP(VRHADD_U, vrhaddu) | ||
107 | +/* | ||
108 | + * VCADD Qd == Qm at size MO_32 is UNPREDICTABLE; we choose not to diagnose | ||
109 | + * so we can reuse the DO_2OP macro. (Our implementation calculates the | ||
110 | + * "expected" results in this case.) | ||
111 | + */ | ||
112 | +DO_2OP(VCADD90, vcadd90) | ||
113 | +DO_2OP(VCADD270, vcadd270) | ||
114 | |||
115 | static bool trans_VQDMULLB(DisasContext *s, arg_2op *a) | ||
116 | { | ||
117 | -- | 27 | -- |
118 | 2.20.1 | 28 | 2.34.1 |
119 | 29 | ||
120 | 30 | diff view generated by jsdifflib |
1 | Implement the MVE VADC and VSBC insns. These perform an | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | add-with-carry or subtract-with-carry of the 32-bit elements in each | ||
3 | lane of the input vectors, where the carry-out of each add is the | ||
4 | carry-in of the next. The initial carry input is either 1 or is from | ||
5 | FPSCR.C; the carry out at the end is written back to FPSCR.C. | ||
6 | 2 | ||
3 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
5 | Message-id: 20230206223502.25122-9-philmd@linaro.org | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20210617121628.20116-41-peter.maydell@linaro.org | ||
10 | --- | 7 | --- |
11 | target/arm/helper-mve.h | 5 ++++ | 8 | target/arm/cpu.h | 2 +- |
12 | target/arm/mve.decode | 5 ++++ | 9 | 1 file changed, 1 insertion(+), 1 deletion(-) |
13 | target/arm/mve_helper.c | 52 ++++++++++++++++++++++++++++++++++++++ | ||
14 | target/arm/translate-mve.c | 37 +++++++++++++++++++++++++++ | ||
15 | 4 files changed, 99 insertions(+) | ||
16 | 10 | ||
17 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 11 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
18 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/helper-mve.h | 13 | --- a/target/arm/cpu.h |
20 | +++ b/target/arm/helper-mve.h | 14 | +++ b/target/arm/cpu.h |
21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vrhaddub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 15 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { |
22 | DEF_HELPER_FLAGS_4(mve_vrhadduh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 16 | } sau; |
23 | DEF_HELPER_FLAGS_4(mve_vrhadduw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 17 | |
24 | 18 | void *nvic; | |
25 | +DEF_HELPER_FLAGS_4(mve_vadc, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 19 | - const struct arm_boot_info *boot_info; |
26 | +DEF_HELPER_FLAGS_4(mve_vadci, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 20 | #if !defined(CONFIG_USER_ONLY) |
27 | +DEF_HELPER_FLAGS_4(mve_vsbc, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 21 | + const struct arm_boot_info *boot_info; |
28 | +DEF_HELPER_FLAGS_4(mve_vsbci, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 22 | /* Store GICv3CPUState to access from this struct */ |
29 | + | 23 | void *gicv3state; |
30 | DEF_HELPER_FLAGS_4(mve_vadd_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 24 | #else /* CONFIG_USER_ONLY */ |
31 | DEF_HELPER_FLAGS_4(mve_vadd_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
32 | DEF_HELPER_FLAGS_4(mve_vadd_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
33 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/target/arm/mve.decode | ||
36 | +++ b/target/arm/mve.decode | ||
37 | @@ -XXX,XX +XXX,XX @@ VQDMULLT 111 . 1110 0 . 11 ... 0 ... 1 1111 . 0 . 0 ... 1 @2op_sz28 | ||
38 | VRHADD_S 111 0 1111 0 . .. ... 0 ... 0 0001 . 1 . 0 ... 0 @2op | ||
39 | VRHADD_U 111 1 1111 0 . .. ... 0 ... 0 0001 . 1 . 0 ... 0 @2op | ||
40 | |||
41 | +VADC 1110 1110 0 . 11 ... 0 ... 0 1111 . 0 . 0 ... 0 @2op_nosz | ||
42 | +VSBC 1111 1110 0 . 11 ... 0 ... 0 1111 . 0 . 0 ... 0 @2op_nosz | ||
43 | +VADCI 1110 1110 0 . 11 ... 0 ... 1 1111 . 0 . 0 ... 0 @2op_nosz | ||
44 | +VSBCI 1111 1110 0 . 11 ... 0 ... 1 1111 . 0 . 0 ... 0 @2op_nosz | ||
45 | + | ||
46 | # Vector miscellaneous | ||
47 | |||
48 | VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op | ||
49 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
50 | index XXXXXXX..XXXXXXX 100644 | ||
51 | --- a/target/arm/mve_helper.c | ||
52 | +++ b/target/arm/mve_helper.c | ||
53 | @@ -XXX,XX +XXX,XX @@ DO_2OP_U(vrshlu, DO_VRSHLU) | ||
54 | DO_2OP_S(vrhadds, DO_RHADD_S) | ||
55 | DO_2OP_U(vrhaddu, DO_RHADD_U) | ||
56 | |||
57 | +static void do_vadc(CPUARMState *env, uint32_t *d, uint32_t *n, uint32_t *m, | ||
58 | + uint32_t inv, uint32_t carry_in, bool update_flags) | ||
59 | +{ | ||
60 | + uint16_t mask = mve_element_mask(env); | ||
61 | + unsigned e; | ||
62 | + | ||
63 | + /* If any additions trigger, we will update flags. */ | ||
64 | + if (mask & 0x1111) { | ||
65 | + update_flags = true; | ||
66 | + } | ||
67 | + | ||
68 | + for (e = 0; e < 16 / 4; e++, mask >>= 4) { | ||
69 | + uint64_t r = carry_in; | ||
70 | + r += n[H4(e)]; | ||
71 | + r += m[H4(e)] ^ inv; | ||
72 | + if (mask & 1) { | ||
73 | + carry_in = r >> 32; | ||
74 | + } | ||
75 | + mergemask(&d[H4(e)], r, mask); | ||
76 | + } | ||
77 | + | ||
78 | + if (update_flags) { | ||
79 | + /* Store C, clear NZV. */ | ||
80 | + env->vfp.xregs[ARM_VFP_FPSCR] &= ~FPCR_NZCV_MASK; | ||
81 | + env->vfp.xregs[ARM_VFP_FPSCR] |= carry_in * FPCR_C; | ||
82 | + } | ||
83 | + mve_advance_vpt(env); | ||
84 | +} | ||
85 | + | ||
86 | +void HELPER(mve_vadc)(CPUARMState *env, void *vd, void *vn, void *vm) | ||
87 | +{ | ||
88 | + bool carry_in = env->vfp.xregs[ARM_VFP_FPSCR] & FPCR_C; | ||
89 | + do_vadc(env, vd, vn, vm, 0, carry_in, false); | ||
90 | +} | ||
91 | + | ||
92 | +void HELPER(mve_vsbc)(CPUARMState *env, void *vd, void *vn, void *vm) | ||
93 | +{ | ||
94 | + bool carry_in = env->vfp.xregs[ARM_VFP_FPSCR] & FPCR_C; | ||
95 | + do_vadc(env, vd, vn, vm, -1, carry_in, false); | ||
96 | +} | ||
97 | + | ||
98 | + | ||
99 | +void HELPER(mve_vadci)(CPUARMState *env, void *vd, void *vn, void *vm) | ||
100 | +{ | ||
101 | + do_vadc(env, vd, vn, vm, 0, 0, true); | ||
102 | +} | ||
103 | + | ||
104 | +void HELPER(mve_vsbci)(CPUARMState *env, void *vd, void *vn, void *vm) | ||
105 | +{ | ||
106 | + do_vadc(env, vd, vn, vm, -1, 1, true); | ||
107 | +} | ||
108 | + | ||
109 | static inline int32_t do_sat_bhw(int64_t val, int64_t min, int64_t max, bool *s) | ||
110 | { | ||
111 | if (val > max) { | ||
112 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
113 | index XXXXXXX..XXXXXXX 100644 | ||
114 | --- a/target/arm/translate-mve.c | ||
115 | +++ b/target/arm/translate-mve.c | ||
116 | @@ -XXX,XX +XXX,XX @@ static bool trans_VQDMULLT(DisasContext *s, arg_2op *a) | ||
117 | return do_2op(s, a, fns[a->size]); | ||
118 | } | ||
119 | |||
120 | +/* | ||
121 | + * VADC and VSBC: these perform an add-with-carry or subtract-with-carry | ||
122 | + * of the 32-bit elements in each lane of the input vectors, where the | ||
123 | + * carry-out of each add is the carry-in of the next. The initial carry | ||
124 | + * input is either fixed (0 for VADCI, 1 for VSBCI) or is from FPSCR.C | ||
125 | + * (for VADC and VSBC); the carry out at the end is written back to FPSCR.C. | ||
126 | + * These insns are subject to beat-wise execution. Partial execution | ||
127 | + * of an I=1 (initial carry input fixed) insn which does not | ||
128 | + * execute the first beat must start with the current FPSCR.NZCV | ||
129 | + * value, not the fixed constant input. | ||
130 | + */ | ||
131 | +static bool trans_VADC(DisasContext *s, arg_2op *a) | ||
132 | +{ | ||
133 | + return do_2op(s, a, gen_helper_mve_vadc); | ||
134 | +} | ||
135 | + | ||
136 | +static bool trans_VADCI(DisasContext *s, arg_2op *a) | ||
137 | +{ | ||
138 | + if (mve_skip_first_beat(s)) { | ||
139 | + return trans_VADC(s, a); | ||
140 | + } | ||
141 | + return do_2op(s, a, gen_helper_mve_vadci); | ||
142 | +} | ||
143 | + | ||
144 | +static bool trans_VSBC(DisasContext *s, arg_2op *a) | ||
145 | +{ | ||
146 | + return do_2op(s, a, gen_helper_mve_vsbc); | ||
147 | +} | ||
148 | + | ||
149 | +static bool trans_VSBCI(DisasContext *s, arg_2op *a) | ||
150 | +{ | ||
151 | + if (mve_skip_first_beat(s)) { | ||
152 | + return trans_VSBC(s, a); | ||
153 | + } | ||
154 | + return do_2op(s, a, gen_helper_mve_vsbci); | ||
155 | +} | ||
156 | + | ||
157 | static bool do_2op_scalar(DisasContext *s, arg_2scalar *a, | ||
158 | MVEGenTwoOpScalarFn fn) | ||
159 | { | ||
160 | -- | 25 | -- |
161 | 2.20.1 | 26 | 2.34.1 |
162 | 27 | ||
163 | 28 | diff view generated by jsdifflib |
1 | From: Peter Collingbourne <pcc@google.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | MTE3 introduces an asymmetric tag checking mode, in which loads are | 3 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
4 | checked synchronously and stores are checked asynchronously. Add | ||
5 | support for it. | ||
6 | |||
7 | Signed-off-by: Peter Collingbourne <pcc@google.com> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20210616195614.11785-1-pcc@google.com | 5 | Message-id: 20230206223502.25122-10-philmd@linaro.org |
10 | [PMM: Add line to emulation.rst] | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 7 | --- |
13 | docs/system/arm/emulation.rst | 1 + | 8 | target/arm/cpu.h | 2 +- |
14 | target/arm/cpu64.c | 2 +- | 9 | 1 file changed, 1 insertion(+), 1 deletion(-) |
15 | target/arm/mte_helper.c | 82 ++++++++++++++++++++++------------- | ||
16 | 3 files changed, 53 insertions(+), 32 deletions(-) | ||
17 | 10 | ||
18 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst | 11 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
19 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/docs/system/arm/emulation.rst | 13 | --- a/target/arm/cpu.h |
21 | +++ b/docs/system/arm/emulation.rst | 14 | +++ b/target/arm/cpu.h |
22 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: | 15 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { |
23 | - FEAT_LSE (Large System Extensions) | 16 | uint32_t ctrl; |
24 | - FEAT_MTE (Memory Tagging Extension) | 17 | } sau; |
25 | - FEAT_MTE2 (Memory Tagging Extension) | 18 | |
26 | +- FEAT_MTE3 (MTE Asymmetric Fault Handling) | 19 | - void *nvic; |
27 | - FEAT_PAN (Privileged access never) | 20 | #if !defined(CONFIG_USER_ONLY) |
28 | - FEAT_PAN2 (AT S1E1R and AT S1E1W instruction variants affected by PSTATE.PAN) | 21 | + void *nvic; |
29 | - FEAT_PAuth (Pointer authentication) | 22 | const struct arm_boot_info *boot_info; |
30 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 23 | /* Store GICv3CPUState to access from this struct */ |
31 | index XXXXXXX..XXXXXXX 100644 | 24 | void *gicv3state; |
32 | --- a/target/arm/cpu64.c | ||
33 | +++ b/target/arm/cpu64.c | ||
34 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
35 | * during realize if the board provides no tag memory, much like | ||
36 | * we do for EL2 with the virtualization=on property. | ||
37 | */ | ||
38 | - t = FIELD_DP64(t, ID_AA64PFR1, MTE, 2); | ||
39 | + t = FIELD_DP64(t, ID_AA64PFR1, MTE, 3); | ||
40 | cpu->isar.id_aa64pfr1 = t; | ||
41 | |||
42 | t = cpu->isar.id_aa64mmfr0; | ||
43 | diff --git a/target/arm/mte_helper.c b/target/arm/mte_helper.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/target/arm/mte_helper.c | ||
46 | +++ b/target/arm/mte_helper.c | ||
47 | @@ -XXX,XX +XXX,XX @@ void HELPER(stzgm_tags)(CPUARMState *env, uint64_t ptr, uint64_t val) | ||
48 | } | ||
49 | } | ||
50 | |||
51 | +static void mte_sync_check_fail(CPUARMState *env, uint32_t desc, | ||
52 | + uint64_t dirty_ptr, uintptr_t ra) | ||
53 | +{ | ||
54 | + int is_write, syn; | ||
55 | + | ||
56 | + env->exception.vaddress = dirty_ptr; | ||
57 | + | ||
58 | + is_write = FIELD_EX32(desc, MTEDESC, WRITE); | ||
59 | + syn = syn_data_abort_no_iss(arm_current_el(env) != 0, 0, 0, 0, 0, is_write, | ||
60 | + 0x11); | ||
61 | + raise_exception_ra(env, EXCP_DATA_ABORT, syn, exception_target_el(env), ra); | ||
62 | + g_assert_not_reached(); | ||
63 | +} | ||
64 | + | ||
65 | +static void mte_async_check_fail(CPUARMState *env, uint64_t dirty_ptr, | ||
66 | + uintptr_t ra, ARMMMUIdx arm_mmu_idx, int el) | ||
67 | +{ | ||
68 | + int select; | ||
69 | + | ||
70 | + if (regime_has_2_ranges(arm_mmu_idx)) { | ||
71 | + select = extract64(dirty_ptr, 55, 1); | ||
72 | + } else { | ||
73 | + select = 0; | ||
74 | + } | ||
75 | + env->cp15.tfsr_el[el] |= 1 << select; | ||
76 | +#ifdef CONFIG_USER_ONLY | ||
77 | + /* | ||
78 | + * Stand in for a timer irq, setting _TIF_MTE_ASYNC_FAULT, | ||
79 | + * which then sends a SIGSEGV when the thread is next scheduled. | ||
80 | + * This cpu will return to the main loop at the end of the TB, | ||
81 | + * which is rather sooner than "normal". But the alternative | ||
82 | + * is waiting until the next syscall. | ||
83 | + */ | ||
84 | + qemu_cpu_kick(env_cpu(env)); | ||
85 | +#endif | ||
86 | +} | ||
87 | + | ||
88 | /* Record a tag check failure. */ | ||
89 | static void mte_check_fail(CPUARMState *env, uint32_t desc, | ||
90 | uint64_t dirty_ptr, uintptr_t ra) | ||
91 | { | ||
92 | int mmu_idx = FIELD_EX32(desc, MTEDESC, MIDX); | ||
93 | ARMMMUIdx arm_mmu_idx = core_to_aa64_mmu_idx(mmu_idx); | ||
94 | - int el, reg_el, tcf, select, is_write, syn; | ||
95 | + int el, reg_el, tcf; | ||
96 | uint64_t sctlr; | ||
97 | |||
98 | reg_el = regime_el(env, arm_mmu_idx); | ||
99 | @@ -XXX,XX +XXX,XX @@ static void mte_check_fail(CPUARMState *env, uint32_t desc, | ||
100 | switch (tcf) { | ||
101 | case 1: | ||
102 | /* Tag check fail causes a synchronous exception. */ | ||
103 | - env->exception.vaddress = dirty_ptr; | ||
104 | - | ||
105 | - is_write = FIELD_EX32(desc, MTEDESC, WRITE); | ||
106 | - syn = syn_data_abort_no_iss(arm_current_el(env) != 0, 0, 0, 0, 0, | ||
107 | - is_write, 0x11); | ||
108 | - raise_exception_ra(env, EXCP_DATA_ABORT, syn, | ||
109 | - exception_target_el(env), ra); | ||
110 | - /* noreturn, but fall through to the assert anyway */ | ||
111 | + mte_sync_check_fail(env, desc, dirty_ptr, ra); | ||
112 | + break; | ||
113 | |||
114 | case 0: | ||
115 | /* | ||
116 | @@ -XXX,XX +XXX,XX @@ static void mte_check_fail(CPUARMState *env, uint32_t desc, | ||
117 | |||
118 | case 2: | ||
119 | /* Tag check fail causes asynchronous flag set. */ | ||
120 | - if (regime_has_2_ranges(arm_mmu_idx)) { | ||
121 | - select = extract64(dirty_ptr, 55, 1); | ||
122 | - } else { | ||
123 | - select = 0; | ||
124 | - } | ||
125 | - env->cp15.tfsr_el[el] |= 1 << select; | ||
126 | -#ifdef CONFIG_USER_ONLY | ||
127 | - /* | ||
128 | - * Stand in for a timer irq, setting _TIF_MTE_ASYNC_FAULT, | ||
129 | - * which then sends a SIGSEGV when the thread is next scheduled. | ||
130 | - * This cpu will return to the main loop at the end of the TB, | ||
131 | - * which is rather sooner than "normal". But the alternative | ||
132 | - * is waiting until the next syscall. | ||
133 | - */ | ||
134 | - qemu_cpu_kick(env_cpu(env)); | ||
135 | -#endif | ||
136 | + mte_async_check_fail(env, dirty_ptr, ra, arm_mmu_idx, el); | ||
137 | break; | ||
138 | |||
139 | - default: | ||
140 | - /* Case 3: Reserved. */ | ||
141 | - qemu_log_mask(LOG_GUEST_ERROR, | ||
142 | - "Tag check failure with SCTLR_EL%d.TCF%s " | ||
143 | - "set to reserved value %d\n", | ||
144 | - reg_el, el ? "" : "0", tcf); | ||
145 | + case 3: | ||
146 | + /* | ||
147 | + * Tag check fail causes asynchronous flag set for stores, or | ||
148 | + * a synchronous exception for loads. | ||
149 | + */ | ||
150 | + if (FIELD_EX32(desc, MTEDESC, WRITE)) { | ||
151 | + mte_async_check_fail(env, dirty_ptr, ra, arm_mmu_idx, el); | ||
152 | + } else { | ||
153 | + mte_sync_check_fail(env, desc, dirty_ptr, ra); | ||
154 | + } | ||
155 | break; | ||
156 | } | ||
157 | } | ||
158 | -- | 25 | -- |
159 | 2.20.1 | 26 | 2.34.1 |
160 | 27 | ||
161 | 28 | diff view generated by jsdifflib |
1 | A few subcases of VLDR/VSTR sysreg succeed but do not perform a | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | memory access: | 2 | |
3 | * VSTR of VPR when unprivileged | 3 | There is no point in using a void pointer to access the NVIC. |
4 | * VLDR to VPR when unprivileged | 4 | Use the real type to avoid casting it while debugging. |
5 | * VLDR to FPCXT_NS when fpInactive | 5 | |
6 | 6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | |
7 | In these cases, even though we don't do the memory access we should | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | still update the base register and perform the stack limit check if | 8 | Message-id: 20230206223502.25122-11-philmd@linaro.org |
9 | the insn's addressing mode specifies writeback. Our implementation | ||
10 | failed to do this, because we handle these side-effects inside the | ||
11 | memory_to_fp_sysreg() and fp_sysreg_to_memory() callback functions, | ||
12 | which are only called if there's something to load or store. | ||
13 | |||
14 | Fix this by adding an extra argument to the callbacks which is set to | ||
15 | true to actually perform the access and false to only do side effects | ||
16 | like writeback, and calling the callback with do_access = false | ||
17 | for the three cases listed above. | ||
18 | |||
19 | This produces slightly suboptimal code for the case of a write | ||
20 | to FPCXT_NS when the FPU is inactive and the insn didn't have | ||
21 | side effects (ie no writeback, or via VMSR), in which case we'll | ||
22 | generate a conditional branch over an unconditional branch. | ||
23 | But this doesn't seem to be important enough to merit requiring | ||
24 | the callback to report back whether it generated any code or not. | ||
25 | |||
26 | Cc: qemu-stable@nongnu.org | ||
27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
28 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
29 | Message-id: 20210618141019.10671-5-peter.maydell@linaro.org | ||
30 | --- | 10 | --- |
31 | target/arm/translate-m-nocp.c | 102 ++++++++++++++++++++++++---------- | 11 | target/arm/cpu.h | 46 ++++++++++++++++++++++--------------------- |
32 | 1 file changed, 72 insertions(+), 30 deletions(-) | 12 | hw/intc/armv7m_nvic.c | 38 ++++++++++++----------------------- |
33 | 13 | target/arm/cpu.c | 1 + | |
34 | diff --git a/target/arm/translate-m-nocp.c b/target/arm/translate-m-nocp.c | 14 | target/arm/m_helper.c | 2 +- |
15 | 4 files changed, 39 insertions(+), 48 deletions(-) | ||
16 | |||
17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
35 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
36 | --- a/target/arm/translate-m-nocp.c | 19 | --- a/target/arm/cpu.h |
37 | +++ b/target/arm/translate-m-nocp.c | 20 | +++ b/target/arm/cpu.h |
38 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSCCLRM(DisasContext *s, arg_VSCCLRM *a) | 21 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUARMTBFlags { |
39 | 22 | ||
40 | /* | 23 | typedef struct ARMMMUFaultInfo ARMMMUFaultInfo; |
41 | * Emit code to store the sysreg to its final destination; frees the | 24 | |
42 | - * TCG temp 'value' it is passed. | 25 | +typedef struct NVICState NVICState; |
43 | + * TCG temp 'value' it is passed. do_access is true to do the store, | 26 | + |
44 | + * and false to skip it and only perform side-effects like base | 27 | typedef struct CPUArchState { |
45 | + * register writeback. | 28 | /* Regs for current mode. */ |
46 | */ | 29 | uint32_t regs[16]; |
47 | -typedef void fp_sysreg_storefn(DisasContext *s, void *opaque, TCGv_i32 value); | 30 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { |
48 | +typedef void fp_sysreg_storefn(DisasContext *s, void *opaque, TCGv_i32 value, | 31 | } sau; |
49 | + bool do_access); | 32 | |
50 | /* | 33 | #if !defined(CONFIG_USER_ONLY) |
51 | * Emit code to load the value to be copied to the sysreg; returns | 34 | - void *nvic; |
52 | - * a new TCG temporary | 35 | + NVICState *nvic; |
53 | + * a new TCG temporary. do_access is true to do the store, | 36 | const struct arm_boot_info *boot_info; |
54 | + * and false to skip it and only perform side-effects like base | 37 | /* Store GICv3CPUState to access from this struct */ |
55 | + * register writeback. | 38 | void *gicv3state; |
56 | */ | 39 | @@ -XXX,XX +XXX,XX @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx, |
57 | -typedef TCGv_i32 fp_sysreg_loadfn(DisasContext *s, void *opaque); | 40 | |
58 | +typedef TCGv_i32 fp_sysreg_loadfn(DisasContext *s, void *opaque, | 41 | /* Interface between CPU and Interrupt controller. */ |
59 | + bool do_access); | 42 | #ifndef CONFIG_USER_ONLY |
60 | 43 | -bool armv7m_nvic_can_take_pending_exception(void *opaque); | |
61 | /* Common decode/access checks for fp sysreg read/write */ | 44 | +bool armv7m_nvic_can_take_pending_exception(NVICState *s); |
62 | typedef enum FPSysRegCheckResult { | 45 | #else |
63 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, | 46 | -static inline bool armv7m_nvic_can_take_pending_exception(void *opaque) |
64 | 47 | +static inline bool armv7m_nvic_can_take_pending_exception(NVICState *s) | |
65 | switch (regno) { | 48 | { |
66 | case ARM_VFP_FPSCR: | 49 | return true; |
67 | - tmp = loadfn(s, opaque); | 50 | } |
68 | + tmp = loadfn(s, opaque, true); | 51 | #endif |
69 | gen_helper_vfp_set_fpscr(cpu_env, tmp); | 52 | /** |
70 | tcg_temp_free_i32(tmp); | 53 | * armv7m_nvic_set_pending: mark the specified exception as pending |
71 | gen_lookup_tb(s); | 54 | - * @opaque: the NVIC |
72 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, | 55 | + * @s: the NVIC |
73 | case ARM_VFP_FPSCR_NZCVQC: | 56 | * @irq: the exception number to mark pending |
74 | { | 57 | * @secure: false for non-banked exceptions or for the nonsecure |
75 | TCGv_i32 fpscr; | 58 | * version of a banked exception, true for the secure version of a banked |
76 | - tmp = loadfn(s, opaque); | 59 | @@ -XXX,XX +XXX,XX @@ static inline bool armv7m_nvic_can_take_pending_exception(void *opaque) |
77 | + tmp = loadfn(s, opaque, true); | 60 | * if @secure is true and @irq does not specify one of the fixed set |
78 | if (dc_isar_feature(aa32_mve, s)) { | 61 | * of architecturally banked exceptions. |
79 | /* QC is only present for MVE; otherwise RES0 */ | 62 | */ |
80 | TCGv_i32 qc = tcg_temp_new_i32(); | 63 | -void armv7m_nvic_set_pending(void *opaque, int irq, bool secure); |
81 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, | 64 | +void armv7m_nvic_set_pending(NVICState *s, int irq, bool secure); |
82 | break; | 65 | /** |
66 | * armv7m_nvic_set_pending_derived: mark this derived exception as pending | ||
67 | - * @opaque: the NVIC | ||
68 | + * @s: the NVIC | ||
69 | * @irq: the exception number to mark pending | ||
70 | * @secure: false for non-banked exceptions or for the nonsecure | ||
71 | * version of a banked exception, true for the secure version of a banked | ||
72 | @@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending(void *opaque, int irq, bool secure); | ||
73 | * exceptions (exceptions generated in the course of trying to take | ||
74 | * a different exception). | ||
75 | */ | ||
76 | -void armv7m_nvic_set_pending_derived(void *opaque, int irq, bool secure); | ||
77 | +void armv7m_nvic_set_pending_derived(NVICState *s, int irq, bool secure); | ||
78 | /** | ||
79 | * armv7m_nvic_set_pending_lazyfp: mark this lazy FP exception as pending | ||
80 | - * @opaque: the NVIC | ||
81 | + * @s: the NVIC | ||
82 | * @irq: the exception number to mark pending | ||
83 | * @secure: false for non-banked exceptions or for the nonsecure | ||
84 | * version of a banked exception, true for the secure version of a banked | ||
85 | @@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending_derived(void *opaque, int irq, bool secure); | ||
86 | * Similar to armv7m_nvic_set_pending(), but specifically for exceptions | ||
87 | * generated in the course of lazy stacking of FP registers. | ||
88 | */ | ||
89 | -void armv7m_nvic_set_pending_lazyfp(void *opaque, int irq, bool secure); | ||
90 | +void armv7m_nvic_set_pending_lazyfp(NVICState *s, int irq, bool secure); | ||
91 | /** | ||
92 | * armv7m_nvic_get_pending_irq_info: return highest priority pending | ||
93 | * exception, and whether it targets Secure state | ||
94 | - * @opaque: the NVIC | ||
95 | + * @s: the NVIC | ||
96 | * @pirq: set to pending exception number | ||
97 | * @ptargets_secure: set to whether pending exception targets Secure | ||
98 | * | ||
99 | @@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending_lazyfp(void *opaque, int irq, bool secure); | ||
100 | * to true if the current highest priority pending exception should | ||
101 | * be taken to Secure state, false for NS. | ||
102 | */ | ||
103 | -void armv7m_nvic_get_pending_irq_info(void *opaque, int *pirq, | ||
104 | +void armv7m_nvic_get_pending_irq_info(NVICState *s, int *pirq, | ||
105 | bool *ptargets_secure); | ||
106 | /** | ||
107 | * armv7m_nvic_acknowledge_irq: make highest priority pending exception active | ||
108 | - * @opaque: the NVIC | ||
109 | + * @s: the NVIC | ||
110 | * | ||
111 | * Move the current highest priority pending exception from the pending | ||
112 | * state to the active state, and update v7m.exception to indicate that | ||
113 | * it is the exception currently being handled. | ||
114 | */ | ||
115 | -void armv7m_nvic_acknowledge_irq(void *opaque); | ||
116 | +void armv7m_nvic_acknowledge_irq(NVICState *s); | ||
117 | /** | ||
118 | * armv7m_nvic_complete_irq: complete specified interrupt or exception | ||
119 | - * @opaque: the NVIC | ||
120 | + * @s: the NVIC | ||
121 | * @irq: the exception number to complete | ||
122 | * @secure: true if this exception was secure | ||
123 | * | ||
124 | @@ -XXX,XX +XXX,XX @@ void armv7m_nvic_acknowledge_irq(void *opaque); | ||
125 | * 0 if there is still an irq active after this one was completed | ||
126 | * (Ignoring -1, this is the same as the RETTOBASE value before completion.) | ||
127 | */ | ||
128 | -int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure); | ||
129 | +int armv7m_nvic_complete_irq(NVICState *s, int irq, bool secure); | ||
130 | /** | ||
131 | * armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure) | ||
132 | - * @opaque: the NVIC | ||
133 | + * @s: the NVIC | ||
134 | * @irq: the exception number to mark pending | ||
135 | * @secure: false for non-banked exceptions or for the nonsecure | ||
136 | * version of a banked exception, true for the secure version of a banked | ||
137 | @@ -XXX,XX +XXX,XX @@ int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure); | ||
138 | * interrupt the current execution priority. This controls whether the | ||
139 | * RDY bit for it in the FPCCR is set. | ||
140 | */ | ||
141 | -bool armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure); | ||
142 | +bool armv7m_nvic_get_ready_status(NVICState *s, int irq, bool secure); | ||
143 | /** | ||
144 | * armv7m_nvic_raw_execution_priority: return the raw execution priority | ||
145 | - * @opaque: the NVIC | ||
146 | + * @s: the NVIC | ||
147 | * | ||
148 | * Returns: the raw execution priority as defined by the v8M architecture. | ||
149 | * This is the execution priority minus the effects of AIRCR.PRIS, | ||
150 | * and minus any PRIMASK/FAULTMASK/BASEPRI priority boosting. | ||
151 | * (v8M ARM ARM I_PKLD.) | ||
152 | */ | ||
153 | -int armv7m_nvic_raw_execution_priority(void *opaque); | ||
154 | +int armv7m_nvic_raw_execution_priority(NVICState *s); | ||
155 | /** | ||
156 | * armv7m_nvic_neg_prio_requested: return true if the requested execution | ||
157 | * priority is negative for the specified security state. | ||
158 | - * @opaque: the NVIC | ||
159 | + * @s: the NVIC | ||
160 | * @secure: the security state to test | ||
161 | * This corresponds to the pseudocode IsReqExecPriNeg(). | ||
162 | */ | ||
163 | #ifndef CONFIG_USER_ONLY | ||
164 | -bool armv7m_nvic_neg_prio_requested(void *opaque, bool secure); | ||
165 | +bool armv7m_nvic_neg_prio_requested(NVICState *s, bool secure); | ||
166 | #else | ||
167 | -static inline bool armv7m_nvic_neg_prio_requested(void *opaque, bool secure) | ||
168 | +static inline bool armv7m_nvic_neg_prio_requested(NVICState *s, bool secure) | ||
169 | { | ||
170 | return false; | ||
171 | } | ||
172 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | ||
173 | index XXXXXXX..XXXXXXX 100644 | ||
174 | --- a/hw/intc/armv7m_nvic.c | ||
175 | +++ b/hw/intc/armv7m_nvic.c | ||
176 | @@ -XXX,XX +XXX,XX @@ static inline int nvic_exec_prio(NVICState *s) | ||
177 | return MIN(running, s->exception_prio); | ||
178 | } | ||
179 | |||
180 | -bool armv7m_nvic_neg_prio_requested(void *opaque, bool secure) | ||
181 | +bool armv7m_nvic_neg_prio_requested(NVICState *s, bool secure) | ||
182 | { | ||
183 | /* Return true if the requested execution priority is negative | ||
184 | * for the specified security state, ie that security state | ||
185 | @@ -XXX,XX +XXX,XX @@ bool armv7m_nvic_neg_prio_requested(void *opaque, bool secure) | ||
186 | * mean we don't allow FAULTMASK_NS to actually make the execution | ||
187 | * priority negative). Compare pseudocode IsReqExcPriNeg(). | ||
188 | */ | ||
189 | - NVICState *s = opaque; | ||
190 | - | ||
191 | if (s->cpu->env.v7m.faultmask[secure]) { | ||
192 | return true; | ||
83 | } | 193 | } |
84 | case ARM_VFP_FPCXT_NS: | 194 | @@ -XXX,XX +XXX,XX @@ bool armv7m_nvic_neg_prio_requested(void *opaque, bool secure) |
85 | + { | 195 | return false; |
86 | + TCGLabel *lab_active = gen_new_label(); | 196 | } |
87 | + | 197 | |
88 | lab_end = gen_new_label(); | 198 | -bool armv7m_nvic_can_take_pending_exception(void *opaque) |
89 | - /* fpInactive case: write is a NOP, so branch to end */ | 199 | +bool armv7m_nvic_can_take_pending_exception(NVICState *s) |
90 | - gen_branch_fpInactive(s, TCG_COND_NE, lab_end); | 200 | { |
91 | + gen_branch_fpInactive(s, TCG_COND_EQ, lab_active); | 201 | - NVICState *s = opaque; |
92 | + /* | 202 | - |
93 | + * fpInactive case: write is a NOP, so only do side effects | 203 | return nvic_exec_prio(s) > nvic_pending_prio(s); |
94 | + * like register writeback before we branch to end | 204 | } |
95 | + */ | 205 | |
96 | + loadfn(s, opaque, false); | 206 | -int armv7m_nvic_raw_execution_priority(void *opaque) |
97 | + tcg_gen_br(lab_end); | 207 | +int armv7m_nvic_raw_execution_priority(NVICState *s) |
98 | + | 208 | { |
99 | + gen_set_label(lab_active); | 209 | - NVICState *s = opaque; |
100 | /* | 210 | - |
101 | * !fpInactive: if FPU disabled, take NOCP exception; | 211 | return s->exception_prio; |
102 | * otherwise PreserveFPState(), and then FPCXT_NS writes | 212 | } |
103 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, | 213 | |
104 | break; | 214 | @@ -XXX,XX +XXX,XX @@ static void nvic_irq_update(NVICState *s) |
105 | } | 215 | * if @secure is true and @irq does not specify one of the fixed set |
106 | gen_preserve_fp_state(s); | 216 | * of architecturally banked exceptions. |
107 | - /* fall through */ | 217 | */ |
108 | + } | 218 | -static void armv7m_nvic_clear_pending(void *opaque, int irq, bool secure) |
109 | + /* fall through */ | 219 | +static void armv7m_nvic_clear_pending(NVICState *s, int irq, bool secure) |
110 | case ARM_VFP_FPCXT_S: | 220 | { |
111 | { | 221 | - NVICState *s = (NVICState *)opaque; |
112 | TCGv_i32 sfpa, control; | 222 | VecInfo *vec; |
113 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, | 223 | |
114 | * Set FPSCR and CONTROL.SFPA from value; the new FPSCR takes | 224 | assert(irq > ARMV7M_EXCP_RESET && irq < s->num_irq); |
115 | * bits [27:0] from value and zeroes bits [31:28]. | 225 | @@ -XXX,XX +XXX,XX @@ static void do_armv7m_nvic_set_pending(void *opaque, int irq, bool secure, |
116 | */ | ||
117 | - tmp = loadfn(s, opaque); | ||
118 | + tmp = loadfn(s, opaque, true); | ||
119 | sfpa = tcg_temp_new_i32(); | ||
120 | tcg_gen_shri_i32(sfpa, tmp, 31); | ||
121 | control = load_cpu_field(v7m.control[M_REG_S]); | ||
122 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, | ||
123 | case ARM_VFP_VPR: | ||
124 | /* Behaves as NOP if not privileged */ | ||
125 | if (IS_USER(s)) { | ||
126 | + loadfn(s, opaque, false); | ||
127 | break; | ||
128 | } | ||
129 | - tmp = loadfn(s, opaque); | ||
130 | + tmp = loadfn(s, opaque, true); | ||
131 | store_cpu_field(tmp, v7m.vpr); | ||
132 | break; | ||
133 | case ARM_VFP_P0: | ||
134 | { | ||
135 | TCGv_i32 vpr; | ||
136 | - tmp = loadfn(s, opaque); | ||
137 | + tmp = loadfn(s, opaque, true); | ||
138 | vpr = load_cpu_field(v7m.vpr); | ||
139 | tcg_gen_deposit_i32(vpr, vpr, tmp, | ||
140 | R_V7M_VPR_P0_SHIFT, R_V7M_VPR_P0_LENGTH); | ||
141 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno, | ||
142 | case ARM_VFP_FPSCR: | ||
143 | tmp = tcg_temp_new_i32(); | ||
144 | gen_helper_vfp_get_fpscr(tmp, cpu_env); | ||
145 | - storefn(s, opaque, tmp); | ||
146 | + storefn(s, opaque, tmp, true); | ||
147 | break; | ||
148 | case ARM_VFP_FPSCR_NZCVQC: | ||
149 | tmp = tcg_temp_new_i32(); | ||
150 | gen_helper_vfp_get_fpscr(tmp, cpu_env); | ||
151 | tcg_gen_andi_i32(tmp, tmp, FPCR_NZCVQC_MASK); | ||
152 | - storefn(s, opaque, tmp); | ||
153 | + storefn(s, opaque, tmp, true); | ||
154 | break; | ||
155 | case QEMU_VFP_FPSCR_NZCV: | ||
156 | /* | ||
157 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno, | ||
158 | */ | ||
159 | tmp = load_cpu_field(vfp.xregs[ARM_VFP_FPSCR]); | ||
160 | tcg_gen_andi_i32(tmp, tmp, FPCR_NZCV_MASK); | ||
161 | - storefn(s, opaque, tmp); | ||
162 | + storefn(s, opaque, tmp, true); | ||
163 | break; | ||
164 | case ARM_VFP_FPCXT_S: | ||
165 | { | ||
166 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno, | ||
167 | * Store result before updating FPSCR etc, in case | ||
168 | * it is a memory write which causes an exception. | ||
169 | */ | ||
170 | - storefn(s, opaque, tmp); | ||
171 | + storefn(s, opaque, tmp, true); | ||
172 | /* | ||
173 | * Now we must reset FPSCR from FPDSCR_NS, and clear | ||
174 | * CONTROL.SFPA; so we'll end the TB here. | ||
175 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno, | ||
176 | gen_branch_fpInactive(s, TCG_COND_EQ, lab_active); | ||
177 | /* fpInactive case: reads as FPDSCR_NS */ | ||
178 | TCGv_i32 tmp = load_cpu_field(v7m.fpdscr[M_REG_NS]); | ||
179 | - storefn(s, opaque, tmp); | ||
180 | + storefn(s, opaque, tmp, true); | ||
181 | lab_end = gen_new_label(); | ||
182 | tcg_gen_br(lab_end); | ||
183 | |||
184 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno, | ||
185 | tcg_gen_or_i32(tmp, tmp, sfpa); | ||
186 | tcg_temp_free_i32(control); | ||
187 | /* Store result before updating FPSCR, in case it faults */ | ||
188 | - storefn(s, opaque, tmp); | ||
189 | + storefn(s, opaque, tmp, true); | ||
190 | /* If SFPA is zero then set FPSCR from FPDSCR_NS */ | ||
191 | fpdscr = load_cpu_field(v7m.fpdscr[M_REG_NS]); | ||
192 | zero = tcg_const_i32(0); | ||
193 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno, | ||
194 | case ARM_VFP_VPR: | ||
195 | /* Behaves as NOP if not privileged */ | ||
196 | if (IS_USER(s)) { | ||
197 | + storefn(s, opaque, NULL, false); | ||
198 | break; | ||
199 | } | ||
200 | tmp = load_cpu_field(v7m.vpr); | ||
201 | - storefn(s, opaque, tmp); | ||
202 | + storefn(s, opaque, tmp, true); | ||
203 | break; | ||
204 | case ARM_VFP_P0: | ||
205 | tmp = load_cpu_field(v7m.vpr); | ||
206 | tcg_gen_extract_i32(tmp, tmp, R_V7M_VPR_P0_SHIFT, R_V7M_VPR_P0_LENGTH); | ||
207 | - storefn(s, opaque, tmp); | ||
208 | + storefn(s, opaque, tmp, true); | ||
209 | break; | ||
210 | default: | ||
211 | g_assert_not_reached(); | ||
212 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno, | ||
213 | return true; | ||
214 | } | ||
215 | |||
216 | -static void fp_sysreg_to_gpr(DisasContext *s, void *opaque, TCGv_i32 value) | ||
217 | +static void fp_sysreg_to_gpr(DisasContext *s, void *opaque, TCGv_i32 value, | ||
218 | + bool do_access) | ||
219 | { | ||
220 | arg_VMSR_VMRS *a = opaque; | ||
221 | |||
222 | + if (!do_access) { | ||
223 | + return; | ||
224 | + } | ||
225 | + | ||
226 | if (a->rt == 15) { | ||
227 | /* Set the 4 flag bits in the CPSR */ | ||
228 | gen_set_nzcv(value); | ||
229 | @@ -XXX,XX +XXX,XX @@ static void fp_sysreg_to_gpr(DisasContext *s, void *opaque, TCGv_i32 value) | ||
230 | } | 226 | } |
231 | } | 227 | } |
232 | 228 | ||
233 | -static TCGv_i32 gpr_to_fp_sysreg(DisasContext *s, void *opaque) | 229 | -void armv7m_nvic_set_pending(void *opaque, int irq, bool secure) |
234 | +static TCGv_i32 gpr_to_fp_sysreg(DisasContext *s, void *opaque, bool do_access) | 230 | +void armv7m_nvic_set_pending(NVICState *s, int irq, bool secure) |
235 | { | 231 | { |
236 | arg_VMSR_VMRS *a = opaque; | 232 | - do_armv7m_nvic_set_pending(opaque, irq, secure, false); |
237 | 233 | + do_armv7m_nvic_set_pending(s, irq, secure, false); | |
238 | + if (!do_access) { | 234 | } |
239 | + return NULL; | 235 | |
240 | + } | 236 | -void armv7m_nvic_set_pending_derived(void *opaque, int irq, bool secure) |
241 | return load_reg(s, a->rt); | 237 | +void armv7m_nvic_set_pending_derived(NVICState *s, int irq, bool secure) |
242 | } | 238 | { |
243 | 239 | - do_armv7m_nvic_set_pending(opaque, irq, secure, true); | |
244 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMSR_VMRS(DisasContext *s, arg_VMSR_VMRS *a) | 240 | + do_armv7m_nvic_set_pending(s, irq, secure, true); |
245 | } | 241 | } |
246 | } | 242 | |
247 | 243 | -void armv7m_nvic_set_pending_lazyfp(void *opaque, int irq, bool secure) | |
248 | -static void fp_sysreg_to_memory(DisasContext *s, void *opaque, TCGv_i32 value) | 244 | +void armv7m_nvic_set_pending_lazyfp(NVICState *s, int irq, bool secure) |
249 | +static void fp_sysreg_to_memory(DisasContext *s, void *opaque, TCGv_i32 value, | 245 | { |
250 | + bool do_access) | 246 | /* |
251 | { | 247 | * Pend an exception during lazy FP stacking. This differs |
252 | arg_vldr_sysreg *a = opaque; | 248 | @@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending_lazyfp(void *opaque, int irq, bool secure) |
253 | uint32_t offset = a->imm; | 249 | * whether we should escalate depends on the saved context |
254 | @@ -XXX,XX +XXX,XX @@ static void fp_sysreg_to_memory(DisasContext *s, void *opaque, TCGv_i32 value) | 250 | * in the FPCCR register, not on the current state of the CPU/NVIC. |
255 | offset = -offset; | 251 | */ |
256 | } | 252 | - NVICState *s = (NVICState *)opaque; |
257 | 253 | bool banked = exc_is_banked(irq); | |
258 | + if (!do_access && !a->w) { | 254 | VecInfo *vec; |
259 | + return; | 255 | bool targets_secure; |
260 | + } | 256 | @@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending_lazyfp(void *opaque, int irq, bool secure) |
261 | + | 257 | } |
262 | addr = load_reg(s, a->rn); | 258 | |
263 | if (a->p) { | 259 | /* Make pending IRQ active. */ |
264 | tcg_gen_addi_i32(addr, addr, offset); | 260 | -void armv7m_nvic_acknowledge_irq(void *opaque) |
265 | @@ -XXX,XX +XXX,XX @@ static void fp_sysreg_to_memory(DisasContext *s, void *opaque, TCGv_i32 value) | 261 | +void armv7m_nvic_acknowledge_irq(NVICState *s) |
266 | gen_helper_v8m_stackcheck(cpu_env, addr); | 262 | { |
267 | } | 263 | - NVICState *s = (NVICState *)opaque; |
268 | 264 | CPUARMState *env = &s->cpu->env; | |
269 | - gen_aa32_st_i32(s, value, addr, get_mem_index(s), | 265 | const int pending = s->vectpending; |
270 | - MO_UL | MO_ALIGN | s->be_data); | 266 | const int running = nvic_exec_prio(s); |
271 | - tcg_temp_free_i32(value); | 267 | @@ -XXX,XX +XXX,XX @@ static bool vectpending_targets_secure(NVICState *s) |
272 | + if (do_access) { | 268 | exc_targets_secure(s, s->vectpending); |
273 | + gen_aa32_st_i32(s, value, addr, get_mem_index(s), | 269 | } |
274 | + MO_UL | MO_ALIGN | s->be_data); | 270 | |
275 | + tcg_temp_free_i32(value); | 271 | -void armv7m_nvic_get_pending_irq_info(void *opaque, |
276 | + } | 272 | +void armv7m_nvic_get_pending_irq_info(NVICState *s, |
277 | 273 | int *pirq, bool *ptargets_secure) | |
278 | if (a->w) { | 274 | { |
279 | /* writeback */ | 275 | - NVICState *s = (NVICState *)opaque; |
280 | @@ -XXX,XX +XXX,XX @@ static void fp_sysreg_to_memory(DisasContext *s, void *opaque, TCGv_i32 value) | 276 | const int pending = s->vectpending; |
281 | } | 277 | bool targets_secure; |
282 | } | 278 | |
283 | 279 | @@ -XXX,XX +XXX,XX @@ void armv7m_nvic_get_pending_irq_info(void *opaque, | |
284 | -static TCGv_i32 memory_to_fp_sysreg(DisasContext *s, void *opaque) | 280 | *pirq = pending; |
285 | +static TCGv_i32 memory_to_fp_sysreg(DisasContext *s, void *opaque, | 281 | } |
286 | + bool do_access) | 282 | |
287 | { | 283 | -int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure) |
288 | arg_vldr_sysreg *a = opaque; | 284 | +int armv7m_nvic_complete_irq(NVICState *s, int irq, bool secure) |
289 | uint32_t offset = a->imm; | 285 | { |
290 | TCGv_i32 addr; | 286 | - NVICState *s = (NVICState *)opaque; |
291 | - TCGv_i32 value = tcg_temp_new_i32(); | 287 | VecInfo *vec = NULL; |
292 | + TCGv_i32 value = NULL; | 288 | int ret = 0; |
293 | 289 | ||
294 | if (!a->a) { | 290 | @@ -XXX,XX +XXX,XX @@ int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure) |
295 | offset = -offset; | 291 | return ret; |
296 | } | 292 | } |
297 | 293 | ||
298 | + if (!do_access && !a->w) { | 294 | -bool armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure) |
299 | + return NULL; | 295 | +bool armv7m_nvic_get_ready_status(NVICState *s, int irq, bool secure) |
300 | + } | 296 | { |
301 | + | 297 | /* |
302 | addr = load_reg(s, a->rn); | 298 | * Return whether an exception is "ready", i.e. it is enabled and is |
303 | if (a->p) { | 299 | @@ -XXX,XX +XXX,XX @@ bool armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure) |
304 | tcg_gen_addi_i32(addr, addr, offset); | 300 | * for non-banked exceptions secure is always false; for banked exceptions |
305 | @@ -XXX,XX +XXX,XX @@ static TCGv_i32 memory_to_fp_sysreg(DisasContext *s, void *opaque) | 301 | * it indicates which of the exceptions is required. |
306 | gen_helper_v8m_stackcheck(cpu_env, addr); | 302 | */ |
307 | } | 303 | - NVICState *s = (NVICState *)opaque; |
308 | 304 | bool banked = exc_is_banked(irq); | |
309 | - gen_aa32_ld_i32(s, value, addr, get_mem_index(s), | 305 | VecInfo *vec; |
310 | - MO_UL | MO_ALIGN | s->be_data); | 306 | int running = nvic_exec_prio(s); |
311 | + if (do_access) { | 307 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
312 | + value = tcg_temp_new_i32(); | 308 | index XXXXXXX..XXXXXXX 100644 |
313 | + gen_aa32_ld_i32(s, value, addr, get_mem_index(s), | 309 | --- a/target/arm/cpu.c |
314 | + MO_UL | MO_ALIGN | s->be_data); | 310 | +++ b/target/arm/cpu.c |
315 | + } | 311 | @@ -XXX,XX +XXX,XX @@ |
316 | 312 | #if !defined(CONFIG_USER_ONLY) | |
317 | if (a->w) { | 313 | #include "hw/loader.h" |
318 | /* writeback */ | 314 | #include "hw/boards.h" |
315 | +#include "hw/intc/armv7m_nvic.h" | ||
316 | #endif | ||
317 | #include "sysemu/tcg.h" | ||
318 | #include "sysemu/qtest.h" | ||
319 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | ||
320 | index XXXXXXX..XXXXXXX 100644 | ||
321 | --- a/target/arm/m_helper.c | ||
322 | +++ b/target/arm/m_helper.c | ||
323 | @@ -XXX,XX +XXX,XX @@ static void v7m_update_fpccr(CPUARMState *env, uint32_t frameptr, | ||
324 | * that we will need later in order to do lazy FP reg stacking. | ||
325 | */ | ||
326 | bool is_secure = env->v7m.secure; | ||
327 | - void *nvic = env->nvic; | ||
328 | + NVICState *nvic = env->nvic; | ||
329 | /* | ||
330 | * Some bits are unbanked and live always in fpccr[M_REG_S]; some bits | ||
331 | * are banked and we want to update the bit in the bank for the | ||
319 | -- | 332 | -- |
320 | 2.20.1 | 333 | 2.34.1 |
321 | 334 | ||
322 | 335 | diff view generated by jsdifflib |
1 | Allow code elsewhere in the system to check whether the ACPI GHES | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | table is present, so it can determine whether it is OK to try to | 2 | |
3 | record an error by calling acpi_ghes_record_errors(). | 3 | While dozens of files include "cpu.h", only 3 files require |
4 | 4 | these NVIC helper declarations. | |
5 | (We don't need to migrate the new 'present' field in AcpiGhesState, | 5 | |
6 | because it is set once at system initialization and doesn't change.) | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | 7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | |
8 | Message-id: 20230206223502.25122-12-philmd@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 | Reviewed-by: Dongjiu Geng <gengdongjiu1@gmail.com> | ||
11 | Message-id: 20210603171259.27962-3-peter.maydell@linaro.org | ||
12 | --- | 10 | --- |
13 | include/hw/acpi/ghes.h | 9 +++++++++ | 11 | include/hw/intc/armv7m_nvic.h | 123 ++++++++++++++++++++++++++++++++++ |
14 | hw/acpi/ghes-stub.c | 5 +++++ | 12 | target/arm/cpu.h | 123 ---------------------------------- |
15 | hw/acpi/ghes.c | 17 +++++++++++++++++ | 13 | target/arm/cpu.c | 4 +- |
16 | 3 files changed, 31 insertions(+) | 14 | target/arm/cpu_tcg.c | 3 + |
17 | 15 | target/arm/m_helper.c | 3 + | |
18 | diff --git a/include/hw/acpi/ghes.h b/include/hw/acpi/ghes.h | 16 | 5 files changed, 132 insertions(+), 124 deletions(-) |
19 | index XXXXXXX..XXXXXXX 100644 | 17 | |
20 | --- a/include/hw/acpi/ghes.h | 18 | diff --git a/include/hw/intc/armv7m_nvic.h b/include/hw/intc/armv7m_nvic.h |
21 | +++ b/include/hw/acpi/ghes.h | 19 | index XXXXXXX..XXXXXXX 100644 |
22 | @@ -XXX,XX +XXX,XX @@ enum { | 20 | --- a/include/hw/intc/armv7m_nvic.h |
23 | 21 | +++ b/include/hw/intc/armv7m_nvic.h | |
24 | typedef struct AcpiGhesState { | 22 | @@ -XXX,XX +XXX,XX @@ struct NVICState { |
25 | uint64_t ghes_addr_le; | 23 | qemu_irq sysresetreq; |
26 | + bool present; /* True if GHES is present at all on this board */ | 24 | }; |
27 | } AcpiGhesState; | 25 | |
28 | 26 | +/* Interface between CPU and Interrupt controller. */ | |
29 | void build_ghes_error_table(GArray *hardware_errors, BIOSLinker *linker); | 27 | +/** |
30 | @@ -XXX,XX +XXX,XX @@ void acpi_build_hest(GArray *table_data, BIOSLinker *linker, | 28 | + * armv7m_nvic_set_pending: mark the specified exception as pending |
31 | void acpi_ghes_add_fw_cfg(AcpiGhesState *vms, FWCfgState *s, | 29 | + * @s: the NVIC |
32 | GArray *hardware_errors); | 30 | + * @irq: the exception number to mark pending |
33 | int acpi_ghes_record_errors(uint8_t notify, uint64_t error_physical_addr); | 31 | + * @secure: false for non-banked exceptions or for the nonsecure |
34 | + | 32 | + * version of a banked exception, true for the secure version of a banked |
35 | +/** | 33 | + * exception. |
36 | + * acpi_ghes_present: Report whether ACPI GHES table is present | 34 | + * |
37 | + * | 35 | + * Marks the specified exception as pending. Note that we will assert() |
38 | + * Returns: true if the system has an ACPI GHES table and it is | 36 | + * if @secure is true and @irq does not specify one of the fixed set |
39 | + * safe to call acpi_ghes_record_errors() to record a memory error. | 37 | + * of architecturally banked exceptions. |
40 | + */ | 38 | + */ |
41 | +bool acpi_ghes_present(void); | 39 | +void armv7m_nvic_set_pending(NVICState *s, int irq, bool secure); |
42 | #endif | 40 | +/** |
43 | diff --git a/hw/acpi/ghes-stub.c b/hw/acpi/ghes-stub.c | 41 | + * armv7m_nvic_set_pending_derived: mark this derived exception as pending |
44 | index XXXXXXX..XXXXXXX 100644 | 42 | + * @s: the NVIC |
45 | --- a/hw/acpi/ghes-stub.c | 43 | + * @irq: the exception number to mark pending |
46 | +++ b/hw/acpi/ghes-stub.c | 44 | + * @secure: false for non-banked exceptions or for the nonsecure |
47 | @@ -XXX,XX +XXX,XX @@ int acpi_ghes_record_errors(uint8_t source_id, uint64_t physical_address) | 45 | + * version of a banked exception, true for the secure version of a banked |
48 | { | 46 | + * exception. |
49 | return -1; | 47 | + * |
50 | } | 48 | + * Similar to armv7m_nvic_set_pending(), but specifically for derived |
51 | + | 49 | + * exceptions (exceptions generated in the course of trying to take |
52 | +bool acpi_ghes_present(void) | 50 | + * a different exception). |
51 | + */ | ||
52 | +void armv7m_nvic_set_pending_derived(NVICState *s, int irq, bool secure); | ||
53 | +/** | ||
54 | + * armv7m_nvic_set_pending_lazyfp: mark this lazy FP exception as pending | ||
55 | + * @s: the NVIC | ||
56 | + * @irq: the exception number to mark pending | ||
57 | + * @secure: false for non-banked exceptions or for the nonsecure | ||
58 | + * version of a banked exception, true for the secure version of a banked | ||
59 | + * exception. | ||
60 | + * | ||
61 | + * Similar to armv7m_nvic_set_pending(), but specifically for exceptions | ||
62 | + * generated in the course of lazy stacking of FP registers. | ||
63 | + */ | ||
64 | +void armv7m_nvic_set_pending_lazyfp(NVICState *s, int irq, bool secure); | ||
65 | +/** | ||
66 | + * armv7m_nvic_get_pending_irq_info: return highest priority pending | ||
67 | + * exception, and whether it targets Secure state | ||
68 | + * @s: the NVIC | ||
69 | + * @pirq: set to pending exception number | ||
70 | + * @ptargets_secure: set to whether pending exception targets Secure | ||
71 | + * | ||
72 | + * This function writes the number of the highest priority pending | ||
73 | + * exception (the one which would be made active by | ||
74 | + * armv7m_nvic_acknowledge_irq()) to @pirq, and sets @ptargets_secure | ||
75 | + * to true if the current highest priority pending exception should | ||
76 | + * be taken to Secure state, false for NS. | ||
77 | + */ | ||
78 | +void armv7m_nvic_get_pending_irq_info(NVICState *s, int *pirq, | ||
79 | + bool *ptargets_secure); | ||
80 | +/** | ||
81 | + * armv7m_nvic_acknowledge_irq: make highest priority pending exception active | ||
82 | + * @s: the NVIC | ||
83 | + * | ||
84 | + * Move the current highest priority pending exception from the pending | ||
85 | + * state to the active state, and update v7m.exception to indicate that | ||
86 | + * it is the exception currently being handled. | ||
87 | + */ | ||
88 | +void armv7m_nvic_acknowledge_irq(NVICState *s); | ||
89 | +/** | ||
90 | + * armv7m_nvic_complete_irq: complete specified interrupt or exception | ||
91 | + * @s: the NVIC | ||
92 | + * @irq: the exception number to complete | ||
93 | + * @secure: true if this exception was secure | ||
94 | + * | ||
95 | + * Returns: -1 if the irq was not active | ||
96 | + * 1 if completing this irq brought us back to base (no active irqs) | ||
97 | + * 0 if there is still an irq active after this one was completed | ||
98 | + * (Ignoring -1, this is the same as the RETTOBASE value before completion.) | ||
99 | + */ | ||
100 | +int armv7m_nvic_complete_irq(NVICState *s, int irq, bool secure); | ||
101 | +/** | ||
102 | + * armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure) | ||
103 | + * @s: the NVIC | ||
104 | + * @irq: the exception number to mark pending | ||
105 | + * @secure: false for non-banked exceptions or for the nonsecure | ||
106 | + * version of a banked exception, true for the secure version of a banked | ||
107 | + * exception. | ||
108 | + * | ||
109 | + * Return whether an exception is "ready", i.e. whether the exception is | ||
110 | + * enabled and is configured at a priority which would allow it to | ||
111 | + * interrupt the current execution priority. This controls whether the | ||
112 | + * RDY bit for it in the FPCCR is set. | ||
113 | + */ | ||
114 | +bool armv7m_nvic_get_ready_status(NVICState *s, int irq, bool secure); | ||
115 | +/** | ||
116 | + * armv7m_nvic_raw_execution_priority: return the raw execution priority | ||
117 | + * @s: the NVIC | ||
118 | + * | ||
119 | + * Returns: the raw execution priority as defined by the v8M architecture. | ||
120 | + * This is the execution priority minus the effects of AIRCR.PRIS, | ||
121 | + * and minus any PRIMASK/FAULTMASK/BASEPRI priority boosting. | ||
122 | + * (v8M ARM ARM I_PKLD.) | ||
123 | + */ | ||
124 | +int armv7m_nvic_raw_execution_priority(NVICState *s); | ||
125 | +/** | ||
126 | + * armv7m_nvic_neg_prio_requested: return true if the requested execution | ||
127 | + * priority is negative for the specified security state. | ||
128 | + * @s: the NVIC | ||
129 | + * @secure: the security state to test | ||
130 | + * This corresponds to the pseudocode IsReqExecPriNeg(). | ||
131 | + */ | ||
132 | +#ifndef CONFIG_USER_ONLY | ||
133 | +bool armv7m_nvic_neg_prio_requested(NVICState *s, bool secure); | ||
134 | +#else | ||
135 | +static inline bool armv7m_nvic_neg_prio_requested(NVICState *s, bool secure) | ||
53 | +{ | 136 | +{ |
54 | + return false; | 137 | + return false; |
55 | +} | 138 | +} |
56 | diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c | 139 | +#endif |
57 | index XXXXXXX..XXXXXXX 100644 | 140 | +#ifndef CONFIG_USER_ONLY |
58 | --- a/hw/acpi/ghes.c | 141 | +bool armv7m_nvic_can_take_pending_exception(NVICState *s); |
59 | +++ b/hw/acpi/ghes.c | 142 | +#else |
60 | @@ -XXX,XX +XXX,XX @@ void acpi_ghes_add_fw_cfg(AcpiGhesState *ags, FWCfgState *s, | 143 | +static inline bool armv7m_nvic_can_take_pending_exception(NVICState *s) |
61 | /* Create a read-write fw_cfg file for Address */ | 144 | +{ |
62 | fw_cfg_add_file_callback(s, ACPI_GHES_DATA_ADDR_FW_CFG_FILE, NULL, NULL, | 145 | + return true; |
63 | NULL, &(ags->ghes_addr_le), sizeof(ags->ghes_addr_le), false); | 146 | +} |
147 | +#endif | ||
64 | + | 148 | + |
65 | + ags->present = true; | 149 | #endif |
66 | } | 150 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
67 | 151 | index XXXXXXX..XXXXXXX 100644 | |
68 | int acpi_ghes_record_errors(uint8_t source_id, uint64_t physical_address) | 152 | --- a/target/arm/cpu.h |
69 | @@ -XXX,XX +XXX,XX @@ int acpi_ghes_record_errors(uint8_t source_id, uint64_t physical_address) | 153 | +++ b/target/arm/cpu.h |
70 | 154 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_list(void); | |
71 | return ret; | 155 | uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx, |
72 | } | 156 | uint32_t cur_el, bool secure); |
73 | + | 157 | |
74 | +bool acpi_ghes_present(void) | 158 | -/* Interface between CPU and Interrupt controller. */ |
75 | +{ | 159 | -#ifndef CONFIG_USER_ONLY |
76 | + AcpiGedState *acpi_ged_state; | 160 | -bool armv7m_nvic_can_take_pending_exception(NVICState *s); |
77 | + AcpiGhesState *ags; | 161 | -#else |
78 | + | 162 | -static inline bool armv7m_nvic_can_take_pending_exception(NVICState *s) |
79 | + acpi_ged_state = ACPI_GED(object_resolve_path_type("", TYPE_ACPI_GED, | 163 | -{ |
80 | + NULL)); | 164 | - return true; |
81 | + | 165 | -} |
82 | + if (!acpi_ged_state) { | 166 | -#endif |
83 | + return false; | 167 | -/** |
84 | + } | 168 | - * armv7m_nvic_set_pending: mark the specified exception as pending |
85 | + ags = &acpi_ged_state->ghes_state; | 169 | - * @s: the NVIC |
86 | + return ags->present; | 170 | - * @irq: the exception number to mark pending |
87 | +} | 171 | - * @secure: false for non-banked exceptions or for the nonsecure |
172 | - * version of a banked exception, true for the secure version of a banked | ||
173 | - * exception. | ||
174 | - * | ||
175 | - * Marks the specified exception as pending. Note that we will assert() | ||
176 | - * if @secure is true and @irq does not specify one of the fixed set | ||
177 | - * of architecturally banked exceptions. | ||
178 | - */ | ||
179 | -void armv7m_nvic_set_pending(NVICState *s, int irq, bool secure); | ||
180 | -/** | ||
181 | - * armv7m_nvic_set_pending_derived: mark this derived exception as pending | ||
182 | - * @s: the NVIC | ||
183 | - * @irq: the exception number to mark pending | ||
184 | - * @secure: false for non-banked exceptions or for the nonsecure | ||
185 | - * version of a banked exception, true for the secure version of a banked | ||
186 | - * exception. | ||
187 | - * | ||
188 | - * Similar to armv7m_nvic_set_pending(), but specifically for derived | ||
189 | - * exceptions (exceptions generated in the course of trying to take | ||
190 | - * a different exception). | ||
191 | - */ | ||
192 | -void armv7m_nvic_set_pending_derived(NVICState *s, int irq, bool secure); | ||
193 | -/** | ||
194 | - * armv7m_nvic_set_pending_lazyfp: mark this lazy FP exception as pending | ||
195 | - * @s: the NVIC | ||
196 | - * @irq: the exception number to mark pending | ||
197 | - * @secure: false for non-banked exceptions or for the nonsecure | ||
198 | - * version of a banked exception, true for the secure version of a banked | ||
199 | - * exception. | ||
200 | - * | ||
201 | - * Similar to armv7m_nvic_set_pending(), but specifically for exceptions | ||
202 | - * generated in the course of lazy stacking of FP registers. | ||
203 | - */ | ||
204 | -void armv7m_nvic_set_pending_lazyfp(NVICState *s, int irq, bool secure); | ||
205 | -/** | ||
206 | - * armv7m_nvic_get_pending_irq_info: return highest priority pending | ||
207 | - * exception, and whether it targets Secure state | ||
208 | - * @s: the NVIC | ||
209 | - * @pirq: set to pending exception number | ||
210 | - * @ptargets_secure: set to whether pending exception targets Secure | ||
211 | - * | ||
212 | - * This function writes the number of the highest priority pending | ||
213 | - * exception (the one which would be made active by | ||
214 | - * armv7m_nvic_acknowledge_irq()) to @pirq, and sets @ptargets_secure | ||
215 | - * to true if the current highest priority pending exception should | ||
216 | - * be taken to Secure state, false for NS. | ||
217 | - */ | ||
218 | -void armv7m_nvic_get_pending_irq_info(NVICState *s, int *pirq, | ||
219 | - bool *ptargets_secure); | ||
220 | -/** | ||
221 | - * armv7m_nvic_acknowledge_irq: make highest priority pending exception active | ||
222 | - * @s: the NVIC | ||
223 | - * | ||
224 | - * Move the current highest priority pending exception from the pending | ||
225 | - * state to the active state, and update v7m.exception to indicate that | ||
226 | - * it is the exception currently being handled. | ||
227 | - */ | ||
228 | -void armv7m_nvic_acknowledge_irq(NVICState *s); | ||
229 | -/** | ||
230 | - * armv7m_nvic_complete_irq: complete specified interrupt or exception | ||
231 | - * @s: the NVIC | ||
232 | - * @irq: the exception number to complete | ||
233 | - * @secure: true if this exception was secure | ||
234 | - * | ||
235 | - * Returns: -1 if the irq was not active | ||
236 | - * 1 if completing this irq brought us back to base (no active irqs) | ||
237 | - * 0 if there is still an irq active after this one was completed | ||
238 | - * (Ignoring -1, this is the same as the RETTOBASE value before completion.) | ||
239 | - */ | ||
240 | -int armv7m_nvic_complete_irq(NVICState *s, int irq, bool secure); | ||
241 | -/** | ||
242 | - * armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure) | ||
243 | - * @s: the NVIC | ||
244 | - * @irq: the exception number to mark pending | ||
245 | - * @secure: false for non-banked exceptions or for the nonsecure | ||
246 | - * version of a banked exception, true for the secure version of a banked | ||
247 | - * exception. | ||
248 | - * | ||
249 | - * Return whether an exception is "ready", i.e. whether the exception is | ||
250 | - * enabled and is configured at a priority which would allow it to | ||
251 | - * interrupt the current execution priority. This controls whether the | ||
252 | - * RDY bit for it in the FPCCR is set. | ||
253 | - */ | ||
254 | -bool armv7m_nvic_get_ready_status(NVICState *s, int irq, bool secure); | ||
255 | -/** | ||
256 | - * armv7m_nvic_raw_execution_priority: return the raw execution priority | ||
257 | - * @s: the NVIC | ||
258 | - * | ||
259 | - * Returns: the raw execution priority as defined by the v8M architecture. | ||
260 | - * This is the execution priority minus the effects of AIRCR.PRIS, | ||
261 | - * and minus any PRIMASK/FAULTMASK/BASEPRI priority boosting. | ||
262 | - * (v8M ARM ARM I_PKLD.) | ||
263 | - */ | ||
264 | -int armv7m_nvic_raw_execution_priority(NVICState *s); | ||
265 | -/** | ||
266 | - * armv7m_nvic_neg_prio_requested: return true if the requested execution | ||
267 | - * priority is negative for the specified security state. | ||
268 | - * @s: the NVIC | ||
269 | - * @secure: the security state to test | ||
270 | - * This corresponds to the pseudocode IsReqExecPriNeg(). | ||
271 | - */ | ||
272 | -#ifndef CONFIG_USER_ONLY | ||
273 | -bool armv7m_nvic_neg_prio_requested(NVICState *s, bool secure); | ||
274 | -#else | ||
275 | -static inline bool armv7m_nvic_neg_prio_requested(NVICState *s, bool secure) | ||
276 | -{ | ||
277 | - return false; | ||
278 | -} | ||
279 | -#endif | ||
280 | - | ||
281 | /* Interface for defining coprocessor registers. | ||
282 | * Registers are defined in tables of arm_cp_reginfo structs | ||
283 | * which are passed to define_arm_cp_regs(). | ||
284 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
285 | index XXXXXXX..XXXXXXX 100644 | ||
286 | --- a/target/arm/cpu.c | ||
287 | +++ b/target/arm/cpu.c | ||
288 | @@ -XXX,XX +XXX,XX @@ | ||
289 | #if !defined(CONFIG_USER_ONLY) | ||
290 | #include "hw/loader.h" | ||
291 | #include "hw/boards.h" | ||
292 | +#ifdef CONFIG_TCG | ||
293 | #include "hw/intc/armv7m_nvic.h" | ||
294 | -#endif | ||
295 | +#endif /* CONFIG_TCG */ | ||
296 | +#endif /* !CONFIG_USER_ONLY */ | ||
297 | #include "sysemu/tcg.h" | ||
298 | #include "sysemu/qtest.h" | ||
299 | #include "sysemu/hw_accel.h" | ||
300 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | ||
301 | index XXXXXXX..XXXXXXX 100644 | ||
302 | --- a/target/arm/cpu_tcg.c | ||
303 | +++ b/target/arm/cpu_tcg.c | ||
304 | @@ -XXX,XX +XXX,XX @@ | ||
305 | #include "hw/boards.h" | ||
306 | #endif | ||
307 | #include "cpregs.h" | ||
308 | +#if !defined(CONFIG_USER_ONLY) && defined(CONFIG_TCG) | ||
309 | +#include "hw/intc/armv7m_nvic.h" | ||
310 | +#endif | ||
311 | |||
312 | |||
313 | /* Share AArch32 -cpu max features with AArch64. */ | ||
314 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | ||
315 | index XXXXXXX..XXXXXXX 100644 | ||
316 | --- a/target/arm/m_helper.c | ||
317 | +++ b/target/arm/m_helper.c | ||
318 | @@ -XXX,XX +XXX,XX @@ | ||
319 | #include "exec/cpu_ldst.h" | ||
320 | #include "semihosting/common-semi.h" | ||
321 | #endif | ||
322 | +#if !defined(CONFIG_USER_ONLY) | ||
323 | +#include "hw/intc/armv7m_nvic.h" | ||
324 | +#endif | ||
325 | |||
326 | static void v7m_msr_xpsr(CPUARMState *env, uint32_t mask, | ||
327 | uint32_t reg, uint32_t val) | ||
88 | -- | 328 | -- |
89 | 2.20.1 | 329 | 2.34.1 |
90 | 330 | ||
91 | 331 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The virt_is_acpi_enabled() function is specific to the virt board, as | ||
2 | is the check for its 'ras' property. Use the new acpi_ghes_present() | ||
3 | function to check whether we should report memory errors via | ||
4 | acpi_ghes_record_errors(). | ||
5 | 1 | ||
6 | This avoids a link error if QEMU was built without support for the | ||
7 | virt board, and provides a mechanism that can be used by any future | ||
8 | board models that want to add ACPI memory error reporting support | ||
9 | (they only need to call acpi_ghes_add_fw_cfg()). | ||
10 | |||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Reviewed-by: Dongjiu Geng <gengdongjiu1@gmail.com> | ||
14 | Message-id: 20210603171259.27962-4-peter.maydell@linaro.org | ||
15 | --- | ||
16 | target/arm/kvm64.c | 6 +----- | ||
17 | 1 file changed, 1 insertion(+), 5 deletions(-) | ||
18 | |||
19 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/target/arm/kvm64.c | ||
22 | +++ b/target/arm/kvm64.c | ||
23 | @@ -XXX,XX +XXX,XX @@ void kvm_arch_on_sigbus_vcpu(CPUState *c, int code, void *addr) | ||
24 | { | ||
25 | ram_addr_t ram_addr; | ||
26 | hwaddr paddr; | ||
27 | - Object *obj = qdev_get_machine(); | ||
28 | - VirtMachineState *vms = VIRT_MACHINE(obj); | ||
29 | - bool acpi_enabled = virt_is_acpi_enabled(vms); | ||
30 | |||
31 | assert(code == BUS_MCEERR_AR || code == BUS_MCEERR_AO); | ||
32 | |||
33 | - if (acpi_enabled && addr && | ||
34 | - object_property_get_bool(obj, "ras", NULL)) { | ||
35 | + if (acpi_ghes_present() && addr) { | ||
36 | ram_addr = qemu_ram_addr_from_host(addr); | ||
37 | if (ram_addr != RAM_ADDR_INVALID && | ||
38 | kvm_physical_memory_addr_from_host(c->kvm_state, addr, &paddr)) { | ||
39 | -- | ||
40 | 2.20.1 | ||
41 | |||
42 | diff view generated by jsdifflib |
1 | Implement the MVE VADD, VSUB and VMUL insns. | 1 | From: Alex Bennée <alex.bennee@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The two TCG tests for GICv2 and GICv3 are very heavy weight distros | ||
4 | that take a long time to boot up, especially for an --enable-debug | ||
5 | build. The total code coverage they give is: | ||
6 | |||
7 | Overall coverage rate: | ||
8 | lines......: 11.2% (59584 of 530123 lines) | ||
9 | functions..: 15.0% (7436 of 49443 functions) | ||
10 | branches...: 6.3% (19273 of 303933 branches) | ||
11 | |||
12 | We already get pretty close to that with the machine_aarch64_virt | ||
13 | tests which only does one full boot (~120s vs ~600s) of alpine. We | ||
14 | expand the kernel+initrd boot (~8s) to test both GICs and also add an | ||
15 | RNG device and a block device to generate a few IRQs and exercise the | ||
16 | storage layer. With that we get to a coverage of: | ||
17 | |||
18 | Overall coverage rate: | ||
19 | lines......: 11.0% (58121 of 530123 lines) | ||
20 | functions..: 14.9% (7343 of 49443 functions) | ||
21 | branches...: 6.0% (18269 of 303933 branches) | ||
22 | |||
23 | which I feel is close enough given the massive time saving. If we want | ||
24 | to target any more sub-systems we can use lighter weight more directed | ||
25 | tests. | ||
26 | |||
27 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | ||
28 | Reviewed-by: Fabiano Rosas <farosas@suse.de> | ||
29 | Acked-by: Richard Henderson <richard.henderson@linaro.org> | ||
30 | Message-id: 20230203181632.2919715-1-alex.bennee@linaro.org | ||
31 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 32 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20210617121628.20116-13-peter.maydell@linaro.org | ||
6 | --- | 33 | --- |
7 | target/arm/helper-mve.h | 12 ++++++++++++ | 34 | tests/avocado/boot_linux.py | 48 ++++---------------- |
8 | target/arm/mve.decode | 5 +++++ | 35 | tests/avocado/machine_aarch64_virt.py | 63 ++++++++++++++++++++++++--- |
9 | target/arm/mve_helper.c | 14 ++++++++++++++ | 36 | 2 files changed, 65 insertions(+), 46 deletions(-) |
10 | target/arm/translate-mve.c | 16 ++++++++++++++++ | 37 | |
11 | 4 files changed, 47 insertions(+) | 38 | diff --git a/tests/avocado/boot_linux.py b/tests/avocado/boot_linux.py |
12 | |||
13 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | 39 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/helper-mve.h | 40 | --- a/tests/avocado/boot_linux.py |
16 | +++ b/target/arm/helper-mve.h | 41 | +++ b/tests/avocado/boot_linux.py |
17 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vbic, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 42 | @@ -XXX,XX +XXX,XX @@ def test_pc_q35_kvm(self): |
18 | DEF_HELPER_FLAGS_4(mve_vorr, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 43 | self.launch_and_wait(set_up_ssh_connection=False) |
19 | DEF_HELPER_FLAGS_4(mve_vorn, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 44 | |
20 | DEF_HELPER_FLAGS_4(mve_veor, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 45 | |
21 | + | 46 | -# For Aarch64 we only boot KVM tests in CI as the TCG tests are very |
22 | +DEF_HELPER_FLAGS_4(mve_vaddb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 47 | -# heavyweight. There are lighter weight distros which we use in the |
23 | +DEF_HELPER_FLAGS_4(mve_vaddh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 48 | -# machine_aarch64_virt.py tests. |
24 | +DEF_HELPER_FLAGS_4(mve_vaddw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 49 | +# For Aarch64 we only boot KVM tests in CI as booting the current |
25 | + | 50 | +# Fedora OS in TCG tests is very heavyweight. There are lighter weight |
26 | +DEF_HELPER_FLAGS_4(mve_vsubb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 51 | +# distros which we use in the machine_aarch64_virt.py tests. |
27 | +DEF_HELPER_FLAGS_4(mve_vsubh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 52 | class BootLinuxAarch64(LinuxTest): |
28 | +DEF_HELPER_FLAGS_4(mve_vsubw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 53 | """ |
29 | + | 54 | :avocado: tags=arch:aarch64 |
30 | +DEF_HELPER_FLAGS_4(mve_vmulb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 55 | :avocado: tags=machine:virt |
31 | +DEF_HELPER_FLAGS_4(mve_vmulh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 56 | - :avocado: tags=machine:gic-version=2 |
32 | +DEF_HELPER_FLAGS_4(mve_vmulw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 57 | """ |
33 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | 58 | timeout = 720 |
59 | |||
60 | - def add_common_args(self): | ||
61 | - self.vm.add_args('-bios', | ||
62 | - os.path.join(BUILD_DIR, 'pc-bios', | ||
63 | - 'edk2-aarch64-code.fd')) | ||
64 | - self.vm.add_args('-device', 'virtio-rng-pci,rng=rng0') | ||
65 | - self.vm.add_args('-object', 'rng-random,id=rng0,filename=/dev/urandom') | ||
66 | - | ||
67 | - @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab') | ||
68 | - def test_fedora_cloud_tcg_gicv2(self): | ||
69 | - """ | ||
70 | - :avocado: tags=accel:tcg | ||
71 | - :avocado: tags=cpu:max | ||
72 | - :avocado: tags=device:gicv2 | ||
73 | - """ | ||
74 | - self.require_accelerator("tcg") | ||
75 | - self.vm.add_args("-accel", "tcg") | ||
76 | - self.vm.add_args("-cpu", "max,lpa2=off") | ||
77 | - self.vm.add_args("-machine", "virt,gic-version=2") | ||
78 | - self.add_common_args() | ||
79 | - self.launch_and_wait(set_up_ssh_connection=False) | ||
80 | - | ||
81 | - @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab') | ||
82 | - def test_fedora_cloud_tcg_gicv3(self): | ||
83 | - """ | ||
84 | - :avocado: tags=accel:tcg | ||
85 | - :avocado: tags=cpu:max | ||
86 | - :avocado: tags=device:gicv3 | ||
87 | - """ | ||
88 | - self.require_accelerator("tcg") | ||
89 | - self.vm.add_args("-accel", "tcg") | ||
90 | - self.vm.add_args("-cpu", "max,lpa2=off") | ||
91 | - self.vm.add_args("-machine", "virt,gic-version=3") | ||
92 | - self.add_common_args() | ||
93 | - self.launch_and_wait(set_up_ssh_connection=False) | ||
94 | - | ||
95 | def test_virt_kvm(self): | ||
96 | """ | ||
97 | :avocado: tags=accel:kvm | ||
98 | @@ -XXX,XX +XXX,XX @@ def test_virt_kvm(self): | ||
99 | self.require_accelerator("kvm") | ||
100 | self.vm.add_args("-accel", "kvm") | ||
101 | self.vm.add_args("-machine", "virt,gic-version=host") | ||
102 | - self.add_common_args() | ||
103 | + self.vm.add_args('-bios', | ||
104 | + os.path.join(BUILD_DIR, 'pc-bios', | ||
105 | + 'edk2-aarch64-code.fd')) | ||
106 | + self.vm.add_args('-device', 'virtio-rng-pci,rng=rng0') | ||
107 | + self.vm.add_args('-object', 'rng-random,id=rng0,filename=/dev/urandom') | ||
108 | self.launch_and_wait(set_up_ssh_connection=False) | ||
109 | |||
110 | |||
111 | diff --git a/tests/avocado/machine_aarch64_virt.py b/tests/avocado/machine_aarch64_virt.py | ||
34 | index XXXXXXX..XXXXXXX 100644 | 112 | index XXXXXXX..XXXXXXX 100644 |
35 | --- a/target/arm/mve.decode | 113 | --- a/tests/avocado/machine_aarch64_virt.py |
36 | +++ b/target/arm/mve.decode | 114 | +++ b/tests/avocado/machine_aarch64_virt.py |
37 | @@ -XXX,XX +XXX,XX @@ | 115 | @@ -XXX,XX +XXX,XX @@ |
38 | 116 | ||
39 | @1op .... .... .... size:2 .. .... .... .... .... &1op qd=%qd qm=%qm | 117 | import time |
40 | @1op_nosz .... .... .... .... .... .... .... .... &1op qd=%qd qm=%qm size=0 | 118 | import os |
41 | +@2op .... .... .. size:2 .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn | 119 | +import logging |
42 | @2op_nosz .... .... .... .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn size=0 | 120 | |
43 | 121 | from avocado_qemu import QemuSystemTest | |
44 | # Vector loads and stores | 122 | from avocado_qemu import wait_for_console_pattern |
45 | @@ -XXX,XX +XXX,XX @@ VORR 1110 1111 0 . 10 ... 0 ... 0 0001 . 1 . 1 ... 0 @2op_nosz | 123 | from avocado_qemu import exec_command |
46 | VORN 1110 1111 0 . 11 ... 0 ... 0 0001 . 1 . 1 ... 0 @2op_nosz | 124 | from avocado_qemu import BUILD_DIR |
47 | VEOR 1111 1111 0 . 00 ... 0 ... 0 0001 . 1 . 1 ... 0 @2op_nosz | 125 | +from avocado.utils import process |
48 | 126 | +from avocado.utils.path import find_command | |
49 | +VADD 1110 1111 0 . .. ... 0 ... 0 1000 . 1 . 0 ... 0 @2op | 127 | |
50 | +VSUB 1111 1111 0 . .. ... 0 ... 0 1000 . 1 . 0 ... 0 @2op | 128 | class Aarch64VirtMachine(QemuSystemTest): |
51 | +VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op | 129 | KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 ' |
52 | + | 130 | @@ -XXX,XX +XXX,XX @@ def test_alpine_virt_tcg_gic_max(self): |
53 | # Vector miscellaneous | 131 | self.wait_for_console_pattern('Welcome to Alpine Linux 3.16') |
54 | 132 | ||
55 | VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op | 133 | |
56 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | 134 | - def test_aarch64_virt(self): |
57 | index XXXXXXX..XXXXXXX 100644 | 135 | + def common_aarch64_virt(self, machine): |
58 | --- a/target/arm/mve_helper.c | 136 | """ |
59 | +++ b/target/arm/mve_helper.c | 137 | - :avocado: tags=arch:aarch64 |
60 | @@ -XXX,XX +XXX,XX @@ DO_1OP(vfnegs, 8, uint64_t, DO_FNEGS) | 138 | - :avocado: tags=machine:virt |
61 | mve_advance_vpt(env); \ | 139 | - :avocado: tags=accel:tcg |
62 | } | 140 | - :avocado: tags=cpu:max |
63 | 141 | + Common code to launch basic virt machine with kernel+initrd | |
64 | +/* provide unsigned 2-op helpers for all sizes */ | 142 | + and a scratch disk. |
65 | +#define DO_2OP_U(OP, FN) \ | 143 | """ |
66 | + DO_2OP(OP##b, 1, uint8_t, FN) \ | 144 | + logger = logging.getLogger('aarch64_virt') |
67 | + DO_2OP(OP##h, 2, uint16_t, FN) \ | 145 | + |
68 | + DO_2OP(OP##w, 4, uint32_t, FN) | 146 | kernel_url = ('https://fileserver.linaro.org/s/' |
69 | + | 147 | 'z6B2ARM7DQT3HWN/download') |
70 | #define DO_AND(N, M) ((N) & (M)) | 148 | - |
71 | #define DO_BIC(N, M) ((N) & ~(M)) | 149 | kernel_hash = 'ed11daab50c151dde0e1e9c9cb8b2d9bd3215347' |
72 | #define DO_ORR(N, M) ((N) | (M)) | 150 | kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) |
73 | @@ -XXX,XX +XXX,XX @@ DO_2OP(vbic, 8, uint64_t, DO_BIC) | 151 | |
74 | DO_2OP(vorr, 8, uint64_t, DO_ORR) | 152 | @@ -XXX,XX +XXX,XX @@ def test_aarch64_virt(self): |
75 | DO_2OP(vorn, 8, uint64_t, DO_ORN) | 153 | 'console=ttyAMA0') |
76 | DO_2OP(veor, 8, uint64_t, DO_EOR) | 154 | self.require_accelerator("tcg") |
77 | + | 155 | self.vm.add_args('-cpu', 'max,pauth-impdef=on', |
78 | +#define DO_ADD(N, M) ((N) + (M)) | 156 | + '-machine', machine, |
79 | +#define DO_SUB(N, M) ((N) - (M)) | 157 | '-accel', 'tcg', |
80 | +#define DO_MUL(N, M) ((N) * (M)) | 158 | '-kernel', kernel_path, |
81 | + | 159 | '-append', kernel_command_line) |
82 | +DO_2OP_U(vadd, DO_ADD) | 160 | + |
83 | +DO_2OP_U(vsub, DO_SUB) | 161 | + # A RNG offers an easy way to generate a few IRQs |
84 | +DO_2OP_U(vmul, DO_MUL) | 162 | + self.vm.add_args('-device', 'virtio-rng-pci,rng=rng0') |
85 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | 163 | + self.vm.add_args('-object', |
86 | index XXXXXXX..XXXXXXX 100644 | 164 | + 'rng-random,id=rng0,filename=/dev/urandom') |
87 | --- a/target/arm/translate-mve.c | 165 | + |
88 | +++ b/target/arm/translate-mve.c | 166 | + # Also add a scratch block device |
89 | @@ -XXX,XX +XXX,XX @@ DO_LOGIC(VBIC, gen_helper_mve_vbic) | 167 | + logger.info('creating scratch qcow2 image') |
90 | DO_LOGIC(VORR, gen_helper_mve_vorr) | 168 | + image_path = os.path.join(self.workdir, 'scratch.qcow2') |
91 | DO_LOGIC(VORN, gen_helper_mve_vorn) | 169 | + qemu_img = os.path.join(BUILD_DIR, 'qemu-img') |
92 | DO_LOGIC(VEOR, gen_helper_mve_veor) | 170 | + if not os.path.exists(qemu_img): |
93 | + | 171 | + qemu_img = find_command('qemu-img', False) |
94 | +#define DO_2OP(INSN, FN) \ | 172 | + if qemu_img is False: |
95 | + static bool trans_##INSN(DisasContext *s, arg_2op *a) \ | 173 | + self.cancel('Could not find "qemu-img", which is required to ' |
96 | + { \ | 174 | + 'create the temporary qcow2 image') |
97 | + static MVEGenTwoOpFn * const fns[] = { \ | 175 | + cmd = '%s create -f qcow2 %s 8M' % (qemu_img, image_path) |
98 | + gen_helper_mve_##FN##b, \ | 176 | + process.run(cmd) |
99 | + gen_helper_mve_##FN##h, \ | 177 | + |
100 | + gen_helper_mve_##FN##w, \ | 178 | + # Add the device |
101 | + NULL, \ | 179 | + self.vm.add_args('-blockdev', |
102 | + }; \ | 180 | + f"driver=qcow2,file.driver=file,file.filename={image_path},node-name=scratch") |
103 | + return do_2op(s, a, fns[a->size]); \ | 181 | + self.vm.add_args('-device', |
104 | + } | 182 | + 'virtio-blk-device,drive=scratch') |
105 | + | 183 | + |
106 | +DO_2OP(VADD, vadd) | 184 | self.vm.launch() |
107 | +DO_2OP(VSUB, vsub) | 185 | self.wait_for_console_pattern('Welcome to Buildroot') |
108 | +DO_2OP(VMUL, vmul) | 186 | time.sleep(0.1) |
187 | exec_command(self, 'root') | ||
188 | time.sleep(0.1) | ||
189 | + exec_command(self, 'dd if=/dev/hwrng of=/dev/vda bs=512 count=4') | ||
190 | + time.sleep(0.1) | ||
191 | + exec_command(self, 'md5sum /dev/vda') | ||
192 | + time.sleep(0.1) | ||
193 | + exec_command(self, 'cat /proc/interrupts') | ||
194 | + time.sleep(0.1) | ||
195 | exec_command(self, 'cat /proc/self/maps') | ||
196 | time.sleep(0.1) | ||
197 | + | ||
198 | + def test_aarch64_virt_gicv3(self): | ||
199 | + """ | ||
200 | + :avocado: tags=arch:aarch64 | ||
201 | + :avocado: tags=machine:virt | ||
202 | + :avocado: tags=accel:tcg | ||
203 | + :avocado: tags=cpu:max | ||
204 | + """ | ||
205 | + self.common_aarch64_virt("virt,gic_version=3") | ||
206 | + | ||
207 | + def test_aarch64_virt_gicv2(self): | ||
208 | + """ | ||
209 | + :avocado: tags=arch:aarch64 | ||
210 | + :avocado: tags=machine:virt | ||
211 | + :avocado: tags=accel:tcg | ||
212 | + :avocado: tags=cpu:max | ||
213 | + """ | ||
214 | + self.common_aarch64_virt("virt,gic-version=2") | ||
109 | -- | 215 | -- |
110 | 2.20.1 | 216 | 2.34.1 |
111 | 217 | ||
112 | 218 | diff view generated by jsdifflib |
1 | vfp_access_check and its helper routine full_vfp_access_check() has | 1 | From: Mostafa Saleh <smostafa@google.com> |
---|---|---|---|
2 | gradually grown and is now an awkward mix of A-profile only and | ||
3 | M-profile only pieces. Refactor it into an A-profile only and an | ||
4 | M-profile only version, taking advantage of the fact that now the | ||
5 | only direct call to full_vfp_access_check() is in A-profile-only | ||
6 | code. | ||
7 | 2 | ||
3 | GBPA register can be used to globally abort all | ||
4 | transactions. | ||
5 | |||
6 | It is described in the SMMU manual in "6.3.14 SMMU_GBPA". | ||
7 | ABORT reset value is IMPLEMENTATION DEFINED, it is chosen to | ||
8 | be zero(Do not abort incoming transactions). | ||
9 | |||
10 | Other fields have default values of Use Incoming. | ||
11 | |||
12 | If UPDATE is not set, the write is ignored. This is the only permitted | ||
13 | behavior in SMMUv3.2 and later.(6.3.14.1 Update procedure) | ||
14 | |||
15 | As this patch adds a new state to the SMMU (GBPA), it is added | ||
16 | in a new subsection for forward migration compatibility. | ||
17 | GBPA is only migrated if its value is different from the reset value. | ||
18 | It does this to be backward migration compatible if SW didn't write | ||
19 | the register. | ||
20 | |||
21 | Signed-off-by: Mostafa Saleh <smostafa@google.com> | ||
22 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
23 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
24 | Message-id: 20230214094009.2445653-1-smostafa@google.com | ||
25 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 26 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20210618141019.10671-7-peter.maydell@linaro.org | ||
11 | --- | 27 | --- |
12 | target/arm/translate-vfp.c | 79 +++++++++++++++++++++++--------------- | 28 | hw/arm/smmuv3-internal.h | 7 +++++++ |
13 | 1 file changed, 48 insertions(+), 31 deletions(-) | 29 | include/hw/arm/smmuv3.h | 1 + |
30 | hw/arm/smmuv3.c | 43 +++++++++++++++++++++++++++++++++++++++- | ||
31 | 3 files changed, 50 insertions(+), 1 deletion(-) | ||
14 | 32 | ||
15 | diff --git a/target/arm/translate-vfp.c b/target/arm/translate-vfp.c | 33 | diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h |
16 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate-vfp.c | 35 | --- a/hw/arm/smmuv3-internal.h |
18 | +++ b/target/arm/translate-vfp.c | 36 | +++ b/hw/arm/smmuv3-internal.h |
19 | @@ -XXX,XX +XXX,XX @@ static void gen_update_fp_context(DisasContext *s) | 37 | @@ -XXX,XX +XXX,XX @@ REG32(CR0ACK, 0x24) |
38 | REG32(CR1, 0x28) | ||
39 | REG32(CR2, 0x2c) | ||
40 | REG32(STATUSR, 0x40) | ||
41 | +REG32(GBPA, 0x44) | ||
42 | + FIELD(GBPA, ABORT, 20, 1) | ||
43 | + FIELD(GBPA, UPDATE, 31, 1) | ||
44 | + | ||
45 | +/* Use incoming. */ | ||
46 | +#define SMMU_GBPA_RESET_VAL 0x1000 | ||
47 | + | ||
48 | REG32(IRQ_CTRL, 0x50) | ||
49 | FIELD(IRQ_CTRL, GERROR_IRQEN, 0, 1) | ||
50 | FIELD(IRQ_CTRL, PRI_IRQEN, 1, 1) | ||
51 | diff --git a/include/hw/arm/smmuv3.h b/include/hw/arm/smmuv3.h | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/include/hw/arm/smmuv3.h | ||
54 | +++ b/include/hw/arm/smmuv3.h | ||
55 | @@ -XXX,XX +XXX,XX @@ struct SMMUv3State { | ||
56 | uint32_t cr[3]; | ||
57 | uint32_t cr0ack; | ||
58 | uint32_t statusr; | ||
59 | + uint32_t gbpa; | ||
60 | uint32_t irq_ctrl; | ||
61 | uint32_t gerror; | ||
62 | uint32_t gerrorn; | ||
63 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c | ||
64 | index XXXXXXX..XXXXXXX 100644 | ||
65 | --- a/hw/arm/smmuv3.c | ||
66 | +++ b/hw/arm/smmuv3.c | ||
67 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_init_regs(SMMUv3State *s) | ||
68 | s->gerror = 0; | ||
69 | s->gerrorn = 0; | ||
70 | s->statusr = 0; | ||
71 | + s->gbpa = SMMU_GBPA_RESET_VAL; | ||
20 | } | 72 | } |
21 | 73 | ||
22 | /* | 74 | static int smmu_get_ste(SMMUv3State *s, dma_addr_t addr, STE *buf, |
23 | - * Check that VFP access is enabled. If it is, do the necessary | 75 | @@ -XXX,XX +XXX,XX @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr, |
24 | - * M-profile lazy-FP handling and then return true. | 76 | qemu_mutex_lock(&s->mutex); |
25 | - * If not, emit code to generate an appropriate exception and | 77 | |
26 | - * return false. | 78 | if (!smmu_enabled(s)) { |
27 | + * Check that VFP access is enabled, A-profile specific version. | 79 | - status = SMMU_TRANS_DISABLE; |
28 | + * | 80 | + if (FIELD_EX32(s->gbpa, GBPA, ABORT)) { |
29 | + * If VFP is enabled, return true. If not, emit code to generate an | 81 | + status = SMMU_TRANS_ABORT; |
30 | + * appropriate exception and return false. | 82 | + } else { |
31 | * The ignore_vfp_enabled argument specifies that we should ignore | 83 | + status = SMMU_TRANS_DISABLE; |
32 | - * whether VFP is enabled via FPEXC[EN]: this should be true for FMXR/FMRX | 84 | + } |
33 | + * whether VFP is enabled via FPEXC.EN: this should be true for FMXR/FMRX | 85 | goto epilogue; |
34 | * accesses to FPSID, FPEXC, MVFR0, MVFR1, MVFR2, and false for all other insns. | ||
35 | */ | ||
36 | -static bool full_vfp_access_check(DisasContext *s, bool ignore_vfp_enabled) | ||
37 | +static bool vfp_access_check_a(DisasContext *s, bool ignore_vfp_enabled) | ||
38 | { | ||
39 | if (s->fp_excp_el) { | ||
40 | - if (arm_dc_feature(s, ARM_FEATURE_M)) { | ||
41 | - /* | ||
42 | - * M-profile mostly catches the "FPU disabled" case early, in | ||
43 | - * disas_m_nocp(), but a few insns (eg LCTP, WLSTP, DLSTP) | ||
44 | - * which do coprocessor-checks are outside the large ranges of | ||
45 | - * the encoding space handled by the patterns in m-nocp.decode, | ||
46 | - * and for them we may need to raise NOCP here. | ||
47 | - */ | ||
48 | - gen_exception_insn(s, s->pc_curr, EXCP_NOCP, | ||
49 | - syn_uncategorized(), s->fp_excp_el); | ||
50 | - } else { | ||
51 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
52 | - syn_fp_access_trap(1, 0xe, false), | ||
53 | - s->fp_excp_el); | ||
54 | - } | ||
55 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
56 | + syn_fp_access_trap(1, 0xe, false), s->fp_excp_el); | ||
57 | return false; | ||
58 | } | 86 | } |
59 | 87 | ||
60 | @@ -XXX,XX +XXX,XX @@ static bool full_vfp_access_check(DisasContext *s, bool ignore_vfp_enabled) | 88 | @@ -XXX,XX +XXX,XX @@ static MemTxResult smmu_writel(SMMUv3State *s, hwaddr offset, |
61 | unallocated_encoding(s); | 89 | case A_GERROR_IRQ_CFG2: |
62 | return false; | 90 | s->gerror_irq_cfg2 = data; |
63 | } | 91 | return MEMTX_OK; |
64 | + return true; | 92 | + case A_GBPA: |
93 | + /* | ||
94 | + * If UPDATE is not set, the write is ignored. This is the only | ||
95 | + * permitted behavior in SMMUv3.2 and later. | ||
96 | + */ | ||
97 | + if (data & R_GBPA_UPDATE_MASK) { | ||
98 | + /* Ignore update bit as write is synchronous. */ | ||
99 | + s->gbpa = data & ~R_GBPA_UPDATE_MASK; | ||
100 | + } | ||
101 | + return MEMTX_OK; | ||
102 | case A_STRTAB_BASE: /* 64b */ | ||
103 | s->strtab_base = deposit64(s->strtab_base, 0, 32, data); | ||
104 | return MEMTX_OK; | ||
105 | @@ -XXX,XX +XXX,XX @@ static MemTxResult smmu_readl(SMMUv3State *s, hwaddr offset, | ||
106 | case A_STATUSR: | ||
107 | *data = s->statusr; | ||
108 | return MEMTX_OK; | ||
109 | + case A_GBPA: | ||
110 | + *data = s->gbpa; | ||
111 | + return MEMTX_OK; | ||
112 | case A_IRQ_CTRL: | ||
113 | case A_IRQ_CTRL_ACK: | ||
114 | *data = s->irq_ctrl; | ||
115 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_smmuv3_queue = { | ||
116 | }, | ||
117 | }; | ||
118 | |||
119 | +static bool smmuv3_gbpa_needed(void *opaque) | ||
120 | +{ | ||
121 | + SMMUv3State *s = opaque; | ||
122 | + | ||
123 | + /* Only migrate GBPA if it has different reset value. */ | ||
124 | + return s->gbpa != SMMU_GBPA_RESET_VAL; | ||
65 | +} | 125 | +} |
66 | |||
67 | - if (arm_dc_feature(s, ARM_FEATURE_M)) { | ||
68 | - /* Handle M-profile lazy FP state mechanics */ | ||
69 | - | ||
70 | - /* Trigger lazy-state preservation if necessary */ | ||
71 | - gen_preserve_fp_state(s); | ||
72 | - | ||
73 | - /* Update ownership of FP context and create new FP context if needed */ | ||
74 | - gen_update_fp_context(s); | ||
75 | +/* | ||
76 | + * Check that VFP access is enabled, M-profile specific version. | ||
77 | + * | ||
78 | + * If VFP is enabled, do the necessary M-profile lazy-FP handling and then | ||
79 | + * return true. If not, emit code to generate an appropriate exception and | ||
80 | + * return false. | ||
81 | + */ | ||
82 | +static bool vfp_access_check_m(DisasContext *s) | ||
83 | +{ | ||
84 | + if (s->fp_excp_el) { | ||
85 | + /* | ||
86 | + * M-profile mostly catches the "FPU disabled" case early, in | ||
87 | + * disas_m_nocp(), but a few insns (eg LCTP, WLSTP, DLSTP) | ||
88 | + * which do coprocessor-checks are outside the large ranges of | ||
89 | + * the encoding space handled by the patterns in m-nocp.decode, | ||
90 | + * and for them we may need to raise NOCP here. | ||
91 | + */ | ||
92 | + gen_exception_insn(s, s->pc_curr, EXCP_NOCP, | ||
93 | + syn_uncategorized(), s->fp_excp_el); | ||
94 | + return false; | ||
95 | } | ||
96 | |||
97 | + /* Handle M-profile lazy FP state mechanics */ | ||
98 | + | 126 | + |
99 | + /* Trigger lazy-state preservation if necessary */ | 127 | +static const VMStateDescription vmstate_gbpa = { |
100 | + gen_preserve_fp_state(s); | 128 | + .name = "smmuv3/gbpa", |
129 | + .version_id = 1, | ||
130 | + .minimum_version_id = 1, | ||
131 | + .needed = smmuv3_gbpa_needed, | ||
132 | + .fields = (VMStateField[]) { | ||
133 | + VMSTATE_UINT32(gbpa, SMMUv3State), | ||
134 | + VMSTATE_END_OF_LIST() | ||
135 | + } | ||
136 | +}; | ||
101 | + | 137 | + |
102 | + /* Update ownership of FP context and create new FP context if needed */ | 138 | static const VMStateDescription vmstate_smmuv3 = { |
103 | + gen_update_fp_context(s); | 139 | .name = "smmuv3", |
104 | + | 140 | .version_id = 1, |
105 | return true; | 141 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_smmuv3 = { |
106 | } | 142 | |
107 | 143 | VMSTATE_END_OF_LIST(), | |
108 | @@ -XXX,XX +XXX,XX @@ static bool full_vfp_access_check(DisasContext *s, bool ignore_vfp_enabled) | 144 | }, |
109 | */ | 145 | + .subsections = (const VMStateDescription * []) { |
110 | bool vfp_access_check(DisasContext *s) | 146 | + &vmstate_gbpa, |
111 | { | 147 | + NULL |
112 | - return full_vfp_access_check(s, false); | ||
113 | + if (arm_dc_feature(s, ARM_FEATURE_M)) { | ||
114 | + return vfp_access_check_m(s); | ||
115 | + } else { | ||
116 | + return vfp_access_check_a(s, false); | ||
117 | + } | 148 | + } |
118 | } | 149 | }; |
119 | 150 | ||
120 | static bool trans_VSEL(DisasContext *s, arg_VSEL *a) | 151 | static void smmuv3_instance_init(Object *obj) |
121 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMSR_VMRS(DisasContext *s, arg_VMSR_VMRS *a) | ||
122 | return false; | ||
123 | } | ||
124 | |||
125 | - if (!full_vfp_access_check(s, ignore_vfp_enabled)) { | ||
126 | + /* | ||
127 | + * Call vfp_access_check_a() directly, because we need to tell | ||
128 | + * it to ignore FPEXC.EN for some register accesses. | ||
129 | + */ | ||
130 | + if (!vfp_access_check_a(s, ignore_vfp_enabled)) { | ||
131 | return true; | ||
132 | } | ||
133 | |||
134 | -- | 152 | -- |
135 | 2.20.1 | 153 | 2.34.1 |
136 | |||
137 | diff view generated by jsdifflib |
1 | Implement the MVE VRHADD insn, which performs a rounded halving | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | addition. | ||
3 | 2 | ||
3 | Since commit acc0b8b05a when running the ZynqMP ZCU102 board with | ||
4 | a QEMU configured using --without-default-devices, we get: | ||
5 | |||
6 | $ qemu-system-aarch64 -M xlnx-zcu102 | ||
7 | qemu-system-aarch64: missing object type 'usb_dwc3' | ||
8 | Abort trap: 6 | ||
9 | |||
10 | Fix by adding the missing Kconfig dependency. | ||
11 | |||
12 | Fixes: acc0b8b05a ("hw/arm/xlnx-zynqmp: Connect ZynqMP's USB controllers") | ||
13 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
14 | Message-id: 20230216092327.2203-1-philmd@linaro.org | ||
15 | Reviewed-by: Francisco Iglesias <francisco.iglesias@amd.com> | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20210617121628.20116-40-peter.maydell@linaro.org | ||
7 | --- | 17 | --- |
8 | target/arm/helper-mve.h | 8 ++++++++ | 18 | hw/arm/Kconfig | 1 + |
9 | target/arm/mve.decode | 3 +++ | 19 | 1 file changed, 1 insertion(+) |
10 | target/arm/mve_helper.c | 6 ++++++ | ||
11 | target/arm/translate-mve.c | 2 ++ | ||
12 | 4 files changed, 19 insertions(+) | ||
13 | 20 | ||
14 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 21 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig |
15 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/helper-mve.h | 23 | --- a/hw/arm/Kconfig |
17 | +++ b/target/arm/helper-mve.h | 24 | +++ b/hw/arm/Kconfig |
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqdmullbw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 25 | @@ -XXX,XX +XXX,XX @@ config XLNX_ZYNQMP_ARM |
19 | DEF_HELPER_FLAGS_4(mve_vqdmullth, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 26 | select XLNX_CSU_DMA |
20 | DEF_HELPER_FLAGS_4(mve_vqdmulltw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 27 | select XLNX_ZYNQMP |
21 | 28 | select XLNX_ZDMA | |
22 | +DEF_HELPER_FLAGS_4(mve_vrhaddsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 29 | + select USB_DWC3 |
23 | +DEF_HELPER_FLAGS_4(mve_vrhaddsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 30 | |
24 | +DEF_HELPER_FLAGS_4(mve_vrhaddsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 31 | config XLNX_VERSAL |
25 | + | 32 | bool |
26 | +DEF_HELPER_FLAGS_4(mve_vrhaddub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
27 | +DEF_HELPER_FLAGS_4(mve_vrhadduh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
28 | +DEF_HELPER_FLAGS_4(mve_vrhadduw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
29 | + | ||
30 | DEF_HELPER_FLAGS_4(mve_vadd_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
31 | DEF_HELPER_FLAGS_4(mve_vadd_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
32 | DEF_HELPER_FLAGS_4(mve_vadd_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
33 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/target/arm/mve.decode | ||
36 | +++ b/target/arm/mve.decode | ||
37 | @@ -XXX,XX +XXX,XX @@ VQRDMLSDHX 1111 1110 0 . .. ... 0 ... 1 1110 . 0 . 0 ... 1 @2op | ||
38 | VQDMULLB 111 . 1110 0 . 11 ... 0 ... 0 1111 . 0 . 0 ... 1 @2op_sz28 | ||
39 | VQDMULLT 111 . 1110 0 . 11 ... 0 ... 1 1111 . 0 . 0 ... 1 @2op_sz28 | ||
40 | |||
41 | +VRHADD_S 111 0 1111 0 . .. ... 0 ... 0 0001 . 1 . 0 ... 0 @2op | ||
42 | +VRHADD_U 111 1 1111 0 . .. ... 0 ... 0 0001 . 1 . 0 ... 0 @2op | ||
43 | + | ||
44 | # Vector miscellaneous | ||
45 | |||
46 | VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op | ||
47 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/target/arm/mve_helper.c | ||
50 | +++ b/target/arm/mve_helper.c | ||
51 | @@ -XXX,XX +XXX,XX @@ DO_2OP_U(vshlu, DO_VSHLU) | ||
52 | DO_2OP_S(vrshls, DO_VRSHLS) | ||
53 | DO_2OP_U(vrshlu, DO_VRSHLU) | ||
54 | |||
55 | +#define DO_RHADD_S(N, M) (((int64_t)(N) + (M) + 1) >> 1) | ||
56 | +#define DO_RHADD_U(N, M) (((uint64_t)(N) + (M) + 1) >> 1) | ||
57 | + | ||
58 | +DO_2OP_S(vrhadds, DO_RHADD_S) | ||
59 | +DO_2OP_U(vrhaddu, DO_RHADD_U) | ||
60 | + | ||
61 | static inline int32_t do_sat_bhw(int64_t val, int64_t min, int64_t max, bool *s) | ||
62 | { | ||
63 | if (val > max) { | ||
64 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
65 | index XXXXXXX..XXXXXXX 100644 | ||
66 | --- a/target/arm/translate-mve.c | ||
67 | +++ b/target/arm/translate-mve.c | ||
68 | @@ -XXX,XX +XXX,XX @@ DO_2OP(VQDMLSDH, vqdmlsdh) | ||
69 | DO_2OP(VQDMLSDHX, vqdmlsdhx) | ||
70 | DO_2OP(VQRDMLSDH, vqrdmlsdh) | ||
71 | DO_2OP(VQRDMLSDHX, vqrdmlsdhx) | ||
72 | +DO_2OP(VRHADD_S, vrhadds) | ||
73 | +DO_2OP(VRHADD_U, vrhaddu) | ||
74 | |||
75 | static bool trans_VQDMULLB(DisasContext *s, arg_2op *a) | ||
76 | { | ||
77 | -- | 33 | -- |
78 | 2.20.1 | 34 | 2.34.1 |
79 | 35 | ||
80 | 36 | diff view generated by jsdifflib |
1 | In the code for handling VFP system register accesses there is some | 1 | From: Cornelia Huck <cohuck@redhat.com> |
---|---|---|---|
2 | stray whitespace after a unary '-' operator, and also some incorrect | ||
3 | indent in a couple of function prototypes. We're about to move this | ||
4 | code to another file, so fix the code style issues first so | ||
5 | checkpatch doesn't complain about the code-movement patch. | ||
6 | 2 | ||
7 | Cc: qemu-stable@nongnu.org | 3 | Just use current_accel_name() directly. |
4 | |||
5 | Signed-off-by: Cornelia Huck <cohuck@redhat.com> | ||
6 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20210618141019.10671-2-peter.maydell@linaro.org | ||
11 | --- | 9 | --- |
12 | target/arm/translate-vfp.c | 11 +++++------ | 10 | hw/arm/virt.c | 6 +++--- |
13 | 1 file changed, 5 insertions(+), 6 deletions(-) | 11 | 1 file changed, 3 insertions(+), 3 deletions(-) |
14 | 12 | ||
15 | diff --git a/target/arm/translate-vfp.c b/target/arm/translate-vfp.c | 13 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c |
16 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate-vfp.c | 15 | --- a/hw/arm/virt.c |
18 | +++ b/target/arm/translate-vfp.c | 16 | +++ b/hw/arm/virt.c |
19 | @@ -XXX,XX +XXX,XX @@ static void gen_branch_fpInactive(DisasContext *s, TCGCond cond, | 17 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) |
20 | } | 18 | if (vms->secure && (kvm_enabled() || hvf_enabled())) { |
21 | 19 | error_report("mach-virt: %s does not support providing " | |
22 | static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, | 20 | "Security extensions (TrustZone) to the guest CPU", |
23 | - | 21 | - kvm_enabled() ? "KVM" : "HVF"); |
24 | fp_sysreg_loadfn *loadfn, | 22 | + current_accel_name()); |
25 | - void *opaque) | 23 | exit(1); |
26 | + void *opaque) | ||
27 | { | ||
28 | /* Do a write to an M-profile floating point system register */ | ||
29 | TCGv_i32 tmp; | ||
30 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, | ||
31 | } | ||
32 | |||
33 | static bool gen_M_fp_sysreg_read(DisasContext *s, int regno, | ||
34 | - fp_sysreg_storefn *storefn, | ||
35 | - void *opaque) | ||
36 | + fp_sysreg_storefn *storefn, | ||
37 | + void *opaque) | ||
38 | { | ||
39 | /* Do a read from an M-profile floating point system register */ | ||
40 | TCGv_i32 tmp; | ||
41 | @@ -XXX,XX +XXX,XX @@ static void fp_sysreg_to_memory(DisasContext *s, void *opaque, TCGv_i32 value) | ||
42 | TCGv_i32 addr; | ||
43 | |||
44 | if (!a->a) { | ||
45 | - offset = - offset; | ||
46 | + offset = -offset; | ||
47 | } | 24 | } |
48 | 25 | ||
49 | addr = load_reg(s, a->rn); | 26 | if (vms->virt && (kvm_enabled() || hvf_enabled())) { |
50 | @@ -XXX,XX +XXX,XX @@ static TCGv_i32 memory_to_fp_sysreg(DisasContext *s, void *opaque) | 27 | error_report("mach-virt: %s does not support providing " |
51 | TCGv_i32 value = tcg_temp_new_i32(); | 28 | "Virtualization extensions to the guest CPU", |
52 | 29 | - kvm_enabled() ? "KVM" : "HVF"); | |
53 | if (!a->a) { | 30 | + current_accel_name()); |
54 | - offset = - offset; | 31 | exit(1); |
55 | + offset = -offset; | ||
56 | } | 32 | } |
57 | 33 | ||
58 | addr = load_reg(s, a->rn); | 34 | if (vms->mte && (kvm_enabled() || hvf_enabled())) { |
35 | error_report("mach-virt: %s does not support providing " | ||
36 | "MTE to the guest CPU", | ||
37 | - kvm_enabled() ? "KVM" : "HVF"); | ||
38 | + current_accel_name()); | ||
39 | exit(1); | ||
40 | } | ||
41 | |||
59 | -- | 42 | -- |
60 | 2.20.1 | 43 | 2.34.1 |
61 | |||
62 | diff view generated by jsdifflib |
1 | From: Alexandre Iooss <erdnaxe@crans.org> | 1 | From: Hao Wu <wuhaotsh@google.com> |
---|---|---|---|
2 | 2 | ||
3 | This adds the target guide for BBC Micro:bit. | 3 | Havard is no longer working on the Nuvoton systems for a while |
4 | and won't be able to do any work on it in the future. So I'll | ||
5 | take over maintaining the Nuvoton system from him. | ||
4 | 6 | ||
5 | Information is taken from https://wiki.qemu.org/Features/MicroBit | 7 | Signed-off-by: Hao Wu <wuhaotsh@google.com> |
6 | and from hw/arm/nrf51_soc.c. | 8 | Acked-by: Havard Skinnemoen <hskinnemoen@google.com> |
7 | 9 | Reviewed-by: Philippe Mathieu-Daude <philmd@linaro.org> | |
8 | Signed-off-by: Alexandre Iooss <erdnaxe@crans.org> | 10 | Message-id: 20230208235433.3989937-2-wuhaotsh@google.com |
9 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
10 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
11 | Message-id: 20210621075625.540471-1-erdnaxe@crans.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 12 | --- |
14 | docs/system/arm/nrf.rst | 51 ++++++++++++++++++++++++++++++++++++++ | 13 | MAINTAINERS | 2 +- |
15 | docs/system/target-arm.rst | 1 + | 14 | 1 file changed, 1 insertion(+), 1 deletion(-) |
16 | MAINTAINERS | 1 + | ||
17 | 3 files changed, 53 insertions(+) | ||
18 | create mode 100644 docs/system/arm/nrf.rst | ||
19 | 15 | ||
20 | diff --git a/docs/system/arm/nrf.rst b/docs/system/arm/nrf.rst | ||
21 | new file mode 100644 | ||
22 | index XXXXXXX..XXXXXXX | ||
23 | --- /dev/null | ||
24 | +++ b/docs/system/arm/nrf.rst | ||
25 | @@ -XXX,XX +XXX,XX @@ | ||
26 | +Nordic nRF boards (``microbit``) | ||
27 | +================================ | ||
28 | + | ||
29 | +The `Nordic nRF`_ chips are a family of ARM-based System-on-Chip that | ||
30 | +are designed to be used for low-power and short-range wireless solutions. | ||
31 | + | ||
32 | +.. _Nordic nRF: https://www.nordicsemi.com/Products | ||
33 | + | ||
34 | +The nRF51 series is the first series for short range wireless applications. | ||
35 | +It is superseded by the nRF52 series. | ||
36 | +The following machines are based on this chip : | ||
37 | + | ||
38 | +- ``microbit`` BBC micro:bit board with nRF51822 SoC | ||
39 | + | ||
40 | +There are other series such as nRF52, nRF53 and nRF91 which are currently not | ||
41 | +supported by QEMU. | ||
42 | + | ||
43 | +Supported devices | ||
44 | +----------------- | ||
45 | + | ||
46 | + * ARM Cortex-M0 (ARMv6-M) | ||
47 | + * Serial ports (UART) | ||
48 | + * Clock controller | ||
49 | + * Timers | ||
50 | + * Random Number Generator (RNG) | ||
51 | + * GPIO controller | ||
52 | + * NVMC | ||
53 | + * SWI | ||
54 | + | ||
55 | +Missing devices | ||
56 | +--------------- | ||
57 | + | ||
58 | + * Watchdog | ||
59 | + * Real-Time Clock (RTC) controller | ||
60 | + * TWI (i2c) | ||
61 | + * SPI controller | ||
62 | + * Analog to Digital Converter (ADC) | ||
63 | + * Quadrature decoder | ||
64 | + * Radio | ||
65 | + | ||
66 | +Boot options | ||
67 | +------------ | ||
68 | + | ||
69 | +The Micro:bit machine can be started using the ``-device`` option to load a | ||
70 | +firmware in `ihex format`_. Example: | ||
71 | + | ||
72 | +.. _ihex format: https://en.wikipedia.org/wiki/Intel_HEX | ||
73 | + | ||
74 | +.. code-block:: bash | ||
75 | + | ||
76 | + $ qemu-system-arm -M microbit -device loader,file=test.hex | ||
77 | diff --git a/docs/system/target-arm.rst b/docs/system/target-arm.rst | ||
78 | index XXXXXXX..XXXXXXX 100644 | ||
79 | --- a/docs/system/target-arm.rst | ||
80 | +++ b/docs/system/target-arm.rst | ||
81 | @@ -XXX,XX +XXX,XX @@ undocumented; you can get a complete list by running | ||
82 | arm/digic | ||
83 | arm/musicpal | ||
84 | arm/gumstix | ||
85 | + arm/nrf | ||
86 | arm/nseries | ||
87 | arm/nuvoton | ||
88 | arm/orangepi | ||
89 | diff --git a/MAINTAINERS b/MAINTAINERS | 16 | diff --git a/MAINTAINERS b/MAINTAINERS |
90 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
91 | --- a/MAINTAINERS | 18 | --- a/MAINTAINERS |
92 | +++ b/MAINTAINERS | 19 | +++ b/MAINTAINERS |
93 | @@ -XXX,XX +XXX,XX @@ F: hw/*/microbit*.c | 20 | @@ -XXX,XX +XXX,XX @@ F: include/hw/net/mv88w8618_eth.h |
94 | F: include/hw/*/nrf51*.h | 21 | F: docs/system/arm/musicpal.rst |
95 | F: include/hw/*/microbit*.h | 22 | |
96 | F: tests/qtest/microbit-test.c | 23 | Nuvoton NPCM7xx |
97 | +F: docs/system/arm/nrf.rst | 24 | -M: Havard Skinnemoen <hskinnemoen@google.com> |
98 | 25 | M: Tyrone Ting <kfting@nuvoton.com> | |
99 | AVR Machines | 26 | +M: Hao Wu <wuhaotsh@google.com> |
100 | ------------- | 27 | L: qemu-arm@nongnu.org |
28 | S: Supported | ||
29 | F: hw/*/npcm7xx* | ||
101 | -- | 30 | -- |
102 | 2.20.1 | 31 | 2.34.1 |
103 | |||
104 | diff view generated by jsdifflib |
1 | Implement the forms of the MVE VLDR and VSTR insns which perform | 1 | From: Hao Wu <wuhaotsh@google.com> |
---|---|---|---|
2 | non-widening loads of bytes, halfwords or words from memory into | ||
3 | vector elements of the same width (encodings T5, T6, T7). | ||
4 | 2 | ||
5 | (At the moment we know for MVE and M-profile in general that | 3 | Nuvoton's PSPI is a general purpose SPI module which enables |
6 | vfp_access_check() can never return false, but we include the | 4 | connections to SPI-based peripheral devices. |
7 | conventional return-true-on-failure check for consistency | ||
8 | with non-M-profile translation code.) | ||
9 | 5 | ||
6 | Signed-off-by: Hao Wu <wuhaotsh@google.com> | ||
7 | Reviewed-by: Chris Rauer <crauer@google.com> | ||
8 | Reviewed-by: Philippe Mathieu-Daude <philmd@linaro.org> | ||
9 | Message-id: 20230208235433.3989937-3-wuhaotsh@google.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-id: 20210617121628.20116-2-peter.maydell@linaro.org | ||
13 | --- | 11 | --- |
14 | target/arm/{translate-mve.c => helper-mve.h} | 19 +- | 12 | MAINTAINERS | 6 +- |
15 | target/arm/helper.h | 2 + | 13 | include/hw/ssi/npcm_pspi.h | 53 +++++++++ |
16 | target/arm/internals.h | 11 ++ | 14 | hw/ssi/npcm_pspi.c | 221 +++++++++++++++++++++++++++++++++++++ |
17 | target/arm/mve.decode | 22 +++ | 15 | hw/ssi/meson.build | 2 +- |
18 | target/arm/mve_helper.c | 172 +++++++++++++++++++ | 16 | hw/ssi/trace-events | 5 + |
19 | target/arm/translate-mve.c | 119 +++++++++++++ | 17 | 5 files changed, 283 insertions(+), 4 deletions(-) |
20 | target/arm/meson.build | 1 + | 18 | create mode 100644 include/hw/ssi/npcm_pspi.h |
21 | 7 files changed, 334 insertions(+), 12 deletions(-) | 19 | create mode 100644 hw/ssi/npcm_pspi.c |
22 | copy target/arm/{translate-mve.c => helper-mve.h} (61%) | ||
23 | create mode 100644 target/arm/mve_helper.c | ||
24 | 20 | ||
25 | diff --git a/target/arm/translate-mve.c b/target/arm/helper-mve.h | 21 | diff --git a/MAINTAINERS b/MAINTAINERS |
26 | similarity index 61% | ||
27 | copy from target/arm/translate-mve.c | ||
28 | copy to target/arm/helper-mve.h | ||
29 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/target/arm/translate-mve.c | 23 | --- a/MAINTAINERS |
31 | +++ b/target/arm/helper-mve.h | 24 | +++ b/MAINTAINERS |
32 | @@ -XXX,XX +XXX,XX @@ | 25 | @@ -XXX,XX +XXX,XX @@ M: Tyrone Ting <kfting@nuvoton.com> |
33 | /* | 26 | M: Hao Wu <wuhaotsh@google.com> |
34 | - * ARM translation: M-profile MVE instructions | 27 | L: qemu-arm@nongnu.org |
35 | + * M-profile MVE specific helper definitions | 28 | S: Supported |
36 | * | 29 | -F: hw/*/npcm7xx* |
37 | * Copyright (c) 2021 Linaro, Ltd. | 30 | -F: include/hw/*/npcm7xx* |
38 | * | 31 | -F: tests/qtest/npcm7xx* |
39 | @@ -XXX,XX +XXX,XX @@ | 32 | +F: hw/*/npcm* |
40 | * You should have received a copy of the GNU Lesser General Public | 33 | +F: include/hw/*/npcm* |
41 | * License along with this library; if not, see <http://www.gnu.org/licenses/>. | 34 | +F: tests/qtest/npcm* |
42 | */ | 35 | F: pc-bios/npcm7xx_bootrom.bin |
43 | - | 36 | F: roms/vbootrom |
44 | -#include "qemu/osdep.h" | 37 | F: docs/system/arm/nuvoton.rst |
45 | -#include "tcg/tcg-op.h" | 38 | diff --git a/include/hw/ssi/npcm_pspi.h b/include/hw/ssi/npcm_pspi.h |
46 | -#include "tcg/tcg-op-gvec.h" | ||
47 | -#include "exec/exec-all.h" | ||
48 | -#include "exec/gen-icount.h" | ||
49 | -#include "translate.h" | ||
50 | -#include "translate-a32.h" | ||
51 | - | ||
52 | -/* Include the generated decoder */ | ||
53 | -#include "decode-mve.c.inc" | ||
54 | +DEF_HELPER_FLAGS_3(mve_vldrb, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
55 | +DEF_HELPER_FLAGS_3(mve_vldrh, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
56 | +DEF_HELPER_FLAGS_3(mve_vldrw, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
57 | +DEF_HELPER_FLAGS_3(mve_vstrb, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
58 | +DEF_HELPER_FLAGS_3(mve_vstrh, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
59 | +DEF_HELPER_FLAGS_3(mve_vstrw, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
60 | diff --git a/target/arm/helper.h b/target/arm/helper.h | ||
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/target/arm/helper.h | ||
63 | +++ b/target/arm/helper.h | ||
64 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_6(gvec_bfmlal_idx, TCG_CALL_NO_RWG, | ||
65 | #include "helper-a64.h" | ||
66 | #include "helper-sve.h" | ||
67 | #endif | ||
68 | + | ||
69 | +#include "helper-mve.h" | ||
70 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
71 | index XXXXXXX..XXXXXXX 100644 | ||
72 | --- a/target/arm/internals.h | ||
73 | +++ b/target/arm/internals.h | ||
74 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t useronly_maybe_clean_ptr(uint32_t desc, uint64_t ptr) | ||
75 | return ptr; | ||
76 | } | ||
77 | |||
78 | +/* Values for M-profile PSR.ECI for MVE insns */ | ||
79 | +enum MVEECIState { | ||
80 | + ECI_NONE = 0, /* No completed beats */ | ||
81 | + ECI_A0 = 1, /* Completed: A0 */ | ||
82 | + ECI_A0A1 = 2, /* Completed: A0, A1 */ | ||
83 | + /* 3 is reserved */ | ||
84 | + ECI_A0A1A2 = 4, /* Completed: A0, A1, A2 */ | ||
85 | + ECI_A0A1A2B0 = 5, /* Completed: A0, A1, A2, B0 */ | ||
86 | + /* All other values reserved */ | ||
87 | +}; | ||
88 | + | ||
89 | #endif | ||
90 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
91 | index XXXXXXX..XXXXXXX 100644 | ||
92 | --- a/target/arm/mve.decode | ||
93 | +++ b/target/arm/mve.decode | ||
94 | @@ -XXX,XX +XXX,XX @@ | ||
95 | # | ||
96 | # This file is processed by scripts/decodetree.py | ||
97 | # | ||
98 | + | ||
99 | +%qd 22:1 13:3 | ||
100 | + | ||
101 | +&vldr_vstr rn qd imm p a w size l | ||
102 | + | ||
103 | +@vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd | ||
104 | + | ||
105 | +# Vector loads and stores | ||
106 | + | ||
107 | +# Non-widening loads/stores (P=0 W=0 is 'related encoding') | ||
108 | +VLDR_VSTR 1110110 0 a:1 . 1 . .... ... 111100 ....... @vldr_vstr \ | ||
109 | + size=0 p=0 w=1 | ||
110 | +VLDR_VSTR 1110110 0 a:1 . 1 . .... ... 111101 ....... @vldr_vstr \ | ||
111 | + size=1 p=0 w=1 | ||
112 | +VLDR_VSTR 1110110 0 a:1 . 1 . .... ... 111110 ....... @vldr_vstr \ | ||
113 | + size=2 p=0 w=1 | ||
114 | +VLDR_VSTR 1110110 1 a:1 . w:1 . .... ... 111100 ....... @vldr_vstr \ | ||
115 | + size=0 p=1 | ||
116 | +VLDR_VSTR 1110110 1 a:1 . w:1 . .... ... 111101 ....... @vldr_vstr \ | ||
117 | + size=1 p=1 | ||
118 | +VLDR_VSTR 1110110 1 a:1 . w:1 . .... ... 111110 ....... @vldr_vstr \ | ||
119 | + size=2 p=1 | ||
120 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
121 | new file mode 100644 | 39 | new file mode 100644 |
122 | index XXXXXXX..XXXXXXX | 40 | index XXXXXXX..XXXXXXX |
123 | --- /dev/null | 41 | --- /dev/null |
124 | +++ b/target/arm/mve_helper.c | 42 | +++ b/include/hw/ssi/npcm_pspi.h |
125 | @@ -XXX,XX +XXX,XX @@ | 43 | @@ -XXX,XX +XXX,XX @@ |
126 | +/* | 44 | +/* |
127 | + * M-profile MVE Operations | 45 | + * Nuvoton Peripheral SPI Module |
128 | + * | 46 | + * |
129 | + * Copyright (c) 2021 Linaro, Ltd. | 47 | + * Copyright 2023 Google LLC |
130 | + * | 48 | + * |
131 | + * This library is free software; you can redistribute it and/or | 49 | + * This program is free software; you can redistribute it and/or modify it |
132 | + * modify it under the terms of the GNU Lesser General Public | 50 | + * under the terms of the GNU General Public License as published by the |
133 | + * License as published by the Free Software Foundation; either | 51 | + * Free Software Foundation; either version 2 of the License, or |
134 | + * version 2.1 of the License, or (at your option) any later version. | 52 | + * (at your option) any later version. |
135 | + * | 53 | + * |
136 | + * This library is distributed in the hope that it will be useful, | 54 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
137 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | 55 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
138 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 56 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
139 | + * Lesser General Public License for more details. | 57 | + * for more details. |
140 | + * | ||
141 | + * You should have received a copy of the GNU Lesser General Public | ||
142 | + * License along with this library; if not, see <http://www.gnu.org/licenses/>. | ||
143 | + */ | 58 | + */ |
59 | +#ifndef NPCM_PSPI_H | ||
60 | +#define NPCM_PSPI_H | ||
61 | + | ||
62 | +#include "hw/ssi/ssi.h" | ||
63 | +#include "hw/sysbus.h" | ||
64 | + | ||
65 | +/* | ||
66 | + * Number of registers in our device state structure. Don't change this without | ||
67 | + * incrementing the version_id in the vmstate. | ||
68 | + */ | ||
69 | +#define NPCM_PSPI_NR_REGS 3 | ||
70 | + | ||
71 | +/** | ||
72 | + * NPCMPSPIState - Device state for one Flash Interface Unit. | ||
73 | + * @parent: System bus device. | ||
74 | + * @mmio: Memory region for register access. | ||
75 | + * @spi: The SPI bus mastered by this controller. | ||
76 | + * @regs: Register contents. | ||
77 | + * @irq: The interrupt request queue for this module. | ||
78 | + * | ||
79 | + * Each PSPI has a shared bank of registers, and controls up to four chip | ||
80 | + * selects. Each chip select has a dedicated memory region which may be used to | ||
81 | + * read and write the flash connected to that chip select as if it were memory. | ||
82 | + */ | ||
83 | +typedef struct NPCMPSPIState { | ||
84 | + SysBusDevice parent; | ||
85 | + | ||
86 | + MemoryRegion mmio; | ||
87 | + | ||
88 | + SSIBus *spi; | ||
89 | + uint16_t regs[NPCM_PSPI_NR_REGS]; | ||
90 | + qemu_irq irq; | ||
91 | +} NPCMPSPIState; | ||
92 | + | ||
93 | +#define TYPE_NPCM_PSPI "npcm-pspi" | ||
94 | +OBJECT_DECLARE_SIMPLE_TYPE(NPCMPSPIState, NPCM_PSPI) | ||
95 | + | ||
96 | +#endif /* NPCM_PSPI_H */ | ||
97 | diff --git a/hw/ssi/npcm_pspi.c b/hw/ssi/npcm_pspi.c | ||
98 | new file mode 100644 | ||
99 | index XXXXXXX..XXXXXXX | ||
100 | --- /dev/null | ||
101 | +++ b/hw/ssi/npcm_pspi.c | ||
102 | @@ -XXX,XX +XXX,XX @@ | ||
103 | +/* | ||
104 | + * Nuvoton NPCM Peripheral SPI Module (PSPI) | ||
105 | + * | ||
106 | + * Copyright 2023 Google LLC | ||
107 | + * | ||
108 | + * This program is free software; you can redistribute it and/or modify it | ||
109 | + * under the terms of the GNU General Public License as published by the | ||
110 | + * Free Software Foundation; either version 2 of the License, or | ||
111 | + * (at your option) any later version. | ||
112 | + * | ||
113 | + * This program is distributed in the hope that it will be useful, but WITHOUT | ||
114 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
115 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
116 | + * for more details. | ||
117 | + */ | ||
144 | + | 118 | + |
145 | +#include "qemu/osdep.h" | 119 | +#include "qemu/osdep.h" |
146 | +#include "cpu.h" | 120 | + |
147 | +#include "internals.h" | 121 | +#include "hw/irq.h" |
148 | +#include "vec_internal.h" | 122 | +#include "hw/registerfields.h" |
149 | +#include "exec/helper-proto.h" | 123 | +#include "hw/ssi/npcm_pspi.h" |
150 | +#include "exec/cpu_ldst.h" | 124 | +#include "migration/vmstate.h" |
151 | +#include "exec/exec-all.h" | 125 | +#include "qapi/error.h" |
152 | + | 126 | +#include "qemu/error-report.h" |
153 | +static uint16_t mve_element_mask(CPUARMState *env) | 127 | +#include "qemu/log.h" |
154 | +{ | 128 | +#include "qemu/module.h" |
155 | + /* | 129 | +#include "qemu/units.h" |
156 | + * Return the mask of which elements in the MVE vector should be | 130 | + |
157 | + * updated. This is a combination of multiple things: | 131 | +#include "trace.h" |
158 | + * (1) by default, we update every lane in the vector | 132 | + |
159 | + * (2) VPT predication stores its state in the VPR register; | 133 | +REG16(PSPI_DATA, 0x0) |
160 | + * (3) low-overhead-branch tail predication will mask out part | 134 | +REG16(PSPI_CTL1, 0x2) |
161 | + * the vector on the final iteration of the loop | 135 | + FIELD(PSPI_CTL1, SPIEN, 0, 1) |
162 | + * (4) if EPSR.ECI is set then we must execute only some beats | 136 | + FIELD(PSPI_CTL1, MOD, 2, 1) |
163 | + * of the insn | 137 | + FIELD(PSPI_CTL1, EIR, 5, 1) |
164 | + * We combine all these into a 16-bit result with the same semantics | 138 | + FIELD(PSPI_CTL1, EIW, 6, 1) |
165 | + * as VPR.P0: 0 to mask the lane, 1 if it is active. | 139 | + FIELD(PSPI_CTL1, SCM, 7, 1) |
166 | + * 8-bit vector ops will look at all bits of the result; | 140 | + FIELD(PSPI_CTL1, SCIDL, 8, 1) |
167 | + * 16-bit ops will look at bits 0, 2, 4, ...; | 141 | + FIELD(PSPI_CTL1, SCDV, 9, 7) |
168 | + * 32-bit ops will look at bits 0, 4, 8 and 12. | 142 | +REG16(PSPI_STAT, 0x4) |
169 | + * Compare pseudocode GetCurInstrBeat(), though that only returns | 143 | + FIELD(PSPI_STAT, BSY, 0, 1) |
170 | + * the 4-bit slice of the mask corresponding to a single beat. | 144 | + FIELD(PSPI_STAT, RBF, 1, 1) |
171 | + */ | 145 | + |
172 | + uint16_t mask = FIELD_EX32(env->v7m.vpr, V7M_VPR, P0); | 146 | +static void npcm_pspi_update_irq(NPCMPSPIState *s) |
173 | + | 147 | +{ |
174 | + if (!(env->v7m.vpr & R_V7M_VPR_MASK01_MASK)) { | 148 | + int level = 0; |
175 | + mask |= 0xff; | 149 | + |
176 | + } | 150 | + /* Only fire IRQ when the module is enabled. */ |
177 | + if (!(env->v7m.vpr & R_V7M_VPR_MASK23_MASK)) { | 151 | + if (FIELD_EX16(s->regs[R_PSPI_CTL1], PSPI_CTL1, SPIEN)) { |
178 | + mask |= 0xff00; | 152 | + /* Update interrupt as BSY is cleared. */ |
179 | + } | 153 | + if ((!FIELD_EX16(s->regs[R_PSPI_STAT], PSPI_STAT, BSY)) && |
180 | + | 154 | + FIELD_EX16(s->regs[R_PSPI_CTL1], PSPI_CTL1, EIW)) { |
181 | + if (env->v7m.ltpsize < 4 && | 155 | + level = 1; |
182 | + env->regs[14] <= (1 << (4 - env->v7m.ltpsize))) { | 156 | + } |
183 | + /* | 157 | + |
184 | + * Tail predication active, and this is the last loop iteration. | 158 | + /* Update interrupt as RBF is set. */ |
185 | + * The element size is (1 << ltpsize), and we only want to process | 159 | + if (FIELD_EX16(s->regs[R_PSPI_STAT], PSPI_STAT, RBF) && |
186 | + * loopcount elements, so we want to retain the least significant | 160 | + FIELD_EX16(s->regs[R_PSPI_CTL1], PSPI_CTL1, EIR)) { |
187 | + * (loopcount * esize) predicate bits and zero out bits above that. | 161 | + level = 1; |
188 | + */ | ||
189 | + int masklen = env->regs[14] << env->v7m.ltpsize; | ||
190 | + assert(masklen <= 16); | ||
191 | + mask &= MAKE_64BIT_MASK(0, masklen); | ||
192 | + } | ||
193 | + | ||
194 | + if ((env->condexec_bits & 0xf) == 0) { | ||
195 | + /* | ||
196 | + * ECI bits indicate which beats are already executed; | ||
197 | + * we handle this by effectively predicating them out. | ||
198 | + */ | ||
199 | + int eci = env->condexec_bits >> 4; | ||
200 | + switch (eci) { | ||
201 | + case ECI_NONE: | ||
202 | + break; | ||
203 | + case ECI_A0: | ||
204 | + mask &= 0xfff0; | ||
205 | + break; | ||
206 | + case ECI_A0A1: | ||
207 | + mask &= 0xff00; | ||
208 | + break; | ||
209 | + case ECI_A0A1A2: | ||
210 | + case ECI_A0A1A2B0: | ||
211 | + mask &= 0xf000; | ||
212 | + break; | ||
213 | + default: | ||
214 | + g_assert_not_reached(); | ||
215 | + } | 162 | + } |
216 | + } | 163 | + } |
217 | + | 164 | + qemu_set_irq(s->irq, level); |
218 | + return mask; | 165 | +} |
219 | +} | 166 | + |
220 | + | 167 | +static uint16_t npcm_pspi_read_data(NPCMPSPIState *s) |
221 | +static void mve_advance_vpt(CPUARMState *env) | 168 | +{ |
222 | +{ | 169 | + uint16_t value = s->regs[R_PSPI_DATA]; |
223 | + /* Advance the VPT and ECI state if necessary */ | 170 | + |
224 | + uint32_t vpr = env->v7m.vpr; | 171 | + /* Clear stat bits as the value are read out. */ |
225 | + unsigned mask01, mask23; | 172 | + s->regs[R_PSPI_STAT] = 0; |
226 | + | 173 | + |
227 | + if ((env->condexec_bits & 0xf) == 0) { | 174 | + return value; |
228 | + env->condexec_bits = (env->condexec_bits == (ECI_A0A1A2B0 << 4)) ? | 175 | +} |
229 | + (ECI_A0 << 4) : (ECI_NONE << 4); | 176 | + |
177 | +static void npcm_pspi_write_data(NPCMPSPIState *s, uint16_t data) | ||
178 | +{ | ||
179 | + uint16_t value = 0; | ||
180 | + | ||
181 | + if (FIELD_EX16(s->regs[R_PSPI_CTL1], PSPI_CTL1, MOD)) { | ||
182 | + value = ssi_transfer(s->spi, extract16(data, 8, 8)) << 8; | ||
230 | + } | 183 | + } |
231 | + | 184 | + value |= ssi_transfer(s->spi, extract16(data, 0, 8)); |
232 | + if (!(vpr & (R_V7M_VPR_MASK01_MASK | R_V7M_VPR_MASK23_MASK))) { | 185 | + s->regs[R_PSPI_DATA] = value; |
233 | + /* VPT not enabled, nothing to do */ | 186 | + |
187 | + /* Mark data as available */ | ||
188 | + s->regs[R_PSPI_STAT] = R_PSPI_STAT_BSY_MASK | R_PSPI_STAT_RBF_MASK; | ||
189 | +} | ||
190 | + | ||
191 | +/* Control register read handler. */ | ||
192 | +static uint64_t npcm_pspi_ctrl_read(void *opaque, hwaddr addr, | ||
193 | + unsigned int size) | ||
194 | +{ | ||
195 | + NPCMPSPIState *s = opaque; | ||
196 | + uint16_t value; | ||
197 | + | ||
198 | + switch (addr) { | ||
199 | + case A_PSPI_DATA: | ||
200 | + value = npcm_pspi_read_data(s); | ||
201 | + break; | ||
202 | + | ||
203 | + case A_PSPI_CTL1: | ||
204 | + value = s->regs[R_PSPI_CTL1]; | ||
205 | + break; | ||
206 | + | ||
207 | + case A_PSPI_STAT: | ||
208 | + value = s->regs[R_PSPI_STAT]; | ||
209 | + break; | ||
210 | + | ||
211 | + default: | ||
212 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
213 | + "%s: write to invalid offset 0x%" PRIx64 "\n", | ||
214 | + DEVICE(s)->canonical_path, addr); | ||
215 | + return 0; | ||
216 | + } | ||
217 | + trace_npcm_pspi_ctrl_read(DEVICE(s)->canonical_path, addr, value); | ||
218 | + npcm_pspi_update_irq(s); | ||
219 | + | ||
220 | + return value; | ||
221 | +} | ||
222 | + | ||
223 | +/* Control register write handler. */ | ||
224 | +static void npcm_pspi_ctrl_write(void *opaque, hwaddr addr, uint64_t v, | ||
225 | + unsigned int size) | ||
226 | +{ | ||
227 | + NPCMPSPIState *s = opaque; | ||
228 | + uint16_t value = v; | ||
229 | + | ||
230 | + trace_npcm_pspi_ctrl_write(DEVICE(s)->canonical_path, addr, value); | ||
231 | + | ||
232 | + switch (addr) { | ||
233 | + case A_PSPI_DATA: | ||
234 | + npcm_pspi_write_data(s, value); | ||
235 | + break; | ||
236 | + | ||
237 | + case A_PSPI_CTL1: | ||
238 | + s->regs[R_PSPI_CTL1] = value; | ||
239 | + break; | ||
240 | + | ||
241 | + case A_PSPI_STAT: | ||
242 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
243 | + "%s: write to read-only register PSPI_STAT: 0x%08" | ||
244 | + PRIx64 "\n", DEVICE(s)->canonical_path, v); | ||
245 | + break; | ||
246 | + | ||
247 | + default: | ||
248 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
249 | + "%s: write to invalid offset 0x%" PRIx64 "\n", | ||
250 | + DEVICE(s)->canonical_path, addr); | ||
234 | + return; | 251 | + return; |
235 | + } | 252 | + } |
236 | + | 253 | + npcm_pspi_update_irq(s); |
237 | + mask01 = FIELD_EX32(vpr, V7M_VPR, MASK01); | 254 | +} |
238 | + mask23 = FIELD_EX32(vpr, V7M_VPR, MASK23); | 255 | + |
239 | + if (mask01 > 8) { | 256 | +static const MemoryRegionOps npcm_pspi_ctrl_ops = { |
240 | + /* high bit set, but not 0b1000: invert the relevant half of P0 */ | 257 | + .read = npcm_pspi_ctrl_read, |
241 | + vpr ^= 0xff; | 258 | + .write = npcm_pspi_ctrl_write, |
242 | + } | 259 | + .endianness = DEVICE_LITTLE_ENDIAN, |
243 | + if (mask23 > 8) { | 260 | + .valid = { |
244 | + /* high bit set, but not 0b1000: invert the relevant half of P0 */ | 261 | + .min_access_size = 1, |
245 | + vpr ^= 0xff00; | 262 | + .max_access_size = 2, |
246 | + } | 263 | + .unaligned = false, |
247 | + vpr = FIELD_DP32(vpr, V7M_VPR, MASK01, mask01 << 1); | 264 | + }, |
248 | + vpr = FIELD_DP32(vpr, V7M_VPR, MASK23, mask23 << 1); | 265 | + .impl = { |
249 | + env->v7m.vpr = vpr; | 266 | + .min_access_size = 2, |
250 | +} | 267 | + .max_access_size = 2, |
251 | + | 268 | + .unaligned = false, |
252 | + | 269 | + }, |
253 | +#define DO_VLDR(OP, MSIZE, LDTYPE, ESIZE, TYPE) \ | 270 | +}; |
254 | + void HELPER(mve_##OP)(CPUARMState *env, void *vd, uint32_t addr) \ | 271 | + |
255 | + { \ | 272 | +static void npcm_pspi_enter_reset(Object *obj, ResetType type) |
256 | + TYPE *d = vd; \ | 273 | +{ |
257 | + uint16_t mask = mve_element_mask(env); \ | 274 | + NPCMPSPIState *s = NPCM_PSPI(obj); |
258 | + unsigned b, e; \ | 275 | + |
259 | + /* \ | 276 | + trace_npcm_pspi_enter_reset(DEVICE(obj)->canonical_path, type); |
260 | + * R_SXTM allows the dest reg to become UNKNOWN for abandoned \ | 277 | + memset(s->regs, 0, sizeof(s->regs)); |
261 | + * beats so we don't care if we update part of the dest and \ | 278 | +} |
262 | + * then take an exception. \ | 279 | + |
263 | + */ \ | 280 | +static void npcm_pspi_realize(DeviceState *dev, Error **errp) |
264 | + for (b = 0, e = 0; b < 16; b += ESIZE, e++) { \ | 281 | +{ |
265 | + if (mask & (1 << b)) { \ | 282 | + NPCMPSPIState *s = NPCM_PSPI(dev); |
266 | + d[H##ESIZE(e)] = cpu_##LDTYPE##_data_ra(env, addr, GETPC()); \ | 283 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); |
267 | + } \ | 284 | + Object *obj = OBJECT(dev); |
268 | + addr += MSIZE; \ | 285 | + |
269 | + } \ | 286 | + s->spi = ssi_create_bus(dev, "pspi"); |
270 | + mve_advance_vpt(env); \ | 287 | + memory_region_init_io(&s->mmio, obj, &npcm_pspi_ctrl_ops, s, |
271 | + } | 288 | + "mmio", 4 * KiB); |
272 | + | 289 | + sysbus_init_mmio(sbd, &s->mmio); |
273 | +#define DO_VSTR(OP, MSIZE, STTYPE, ESIZE, TYPE) \ | 290 | + sysbus_init_irq(sbd, &s->irq); |
274 | + void HELPER(mve_##OP)(CPUARMState *env, void *vd, uint32_t addr) \ | 291 | +} |
275 | + { \ | 292 | + |
276 | + TYPE *d = vd; \ | 293 | +static const VMStateDescription vmstate_npcm_pspi = { |
277 | + uint16_t mask = mve_element_mask(env); \ | 294 | + .name = "npcm-pspi", |
278 | + unsigned b, e; \ | 295 | + .version_id = 0, |
279 | + for (b = 0, e = 0; b < 16; b += ESIZE, e++) { \ | 296 | + .minimum_version_id = 0, |
280 | + if (mask & (1 << b)) { \ | 297 | + .fields = (VMStateField[]) { |
281 | + cpu_##STTYPE##_data_ra(env, addr, d[H##ESIZE(e)], GETPC()); \ | 298 | + VMSTATE_UINT16_ARRAY(regs, NPCMPSPIState, NPCM_PSPI_NR_REGS), |
282 | + } \ | 299 | + VMSTATE_END_OF_LIST(), |
283 | + addr += MSIZE; \ | 300 | + }, |
284 | + } \ | 301 | +}; |
285 | + mve_advance_vpt(env); \ | 302 | + |
286 | + } | 303 | + |
287 | + | 304 | +static void npcm_pspi_class_init(ObjectClass *klass, void *data) |
288 | +DO_VLDR(vldrb, 1, ldub, 1, uint8_t) | 305 | +{ |
289 | +DO_VLDR(vldrh, 2, lduw, 2, uint16_t) | 306 | + ResettableClass *rc = RESETTABLE_CLASS(klass); |
290 | +DO_VLDR(vldrw, 4, ldl, 4, uint32_t) | 307 | + DeviceClass *dc = DEVICE_CLASS(klass); |
291 | + | 308 | + |
292 | +DO_VSTR(vstrb, 1, stb, 1, uint8_t) | 309 | + dc->desc = "NPCM Peripheral SPI Module"; |
293 | +DO_VSTR(vstrh, 2, stw, 2, uint16_t) | 310 | + dc->realize = npcm_pspi_realize; |
294 | +DO_VSTR(vstrw, 4, stl, 4, uint32_t) | 311 | + dc->vmsd = &vmstate_npcm_pspi; |
295 | + | 312 | + rc->phases.enter = npcm_pspi_enter_reset; |
296 | +#undef DO_VLDR | 313 | +} |
297 | +#undef DO_VSTR | 314 | + |
298 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | 315 | +static const TypeInfo npcm_pspi_types[] = { |
316 | + { | ||
317 | + .name = TYPE_NPCM_PSPI, | ||
318 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
319 | + .instance_size = sizeof(NPCMPSPIState), | ||
320 | + .class_init = npcm_pspi_class_init, | ||
321 | + }, | ||
322 | +}; | ||
323 | +DEFINE_TYPES(npcm_pspi_types); | ||
324 | diff --git a/hw/ssi/meson.build b/hw/ssi/meson.build | ||
299 | index XXXXXXX..XXXXXXX 100644 | 325 | index XXXXXXX..XXXXXXX 100644 |
300 | --- a/target/arm/translate-mve.c | 326 | --- a/hw/ssi/meson.build |
301 | +++ b/target/arm/translate-mve.c | 327 | +++ b/hw/ssi/meson.build |
302 | @@ -XXX,XX +XXX,XX @@ | 328 | @@ -XXX,XX +XXX,XX @@ |
303 | 329 | softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_smc.c')) | |
304 | /* Include the generated decoder */ | 330 | softmmu_ss.add(when: 'CONFIG_MSF2', if_true: files('mss-spi.c')) |
305 | #include "decode-mve.c.inc" | 331 | -softmmu_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_fiu.c')) |
306 | + | 332 | +softmmu_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_fiu.c', 'npcm_pspi.c')) |
307 | +typedef void MVEGenLdStFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | 333 | softmmu_ss.add(when: 'CONFIG_PL022', if_true: files('pl022.c')) |
308 | + | 334 | softmmu_ss.add(when: 'CONFIG_SIFIVE_SPI', if_true: files('sifive_spi.c')) |
309 | +/* Return the offset of a Qn register (same semantics as aa32_vfp_qreg()) */ | 335 | softmmu_ss.add(when: 'CONFIG_SSI', if_true: files('ssi.c')) |
310 | +static inline long mve_qreg_offset(unsigned reg) | 336 | diff --git a/hw/ssi/trace-events b/hw/ssi/trace-events |
311 | +{ | ||
312 | + return offsetof(CPUARMState, vfp.zregs[reg].d[0]); | ||
313 | +} | ||
314 | + | ||
315 | +static TCGv_ptr mve_qreg_ptr(unsigned reg) | ||
316 | +{ | ||
317 | + TCGv_ptr ret = tcg_temp_new_ptr(); | ||
318 | + tcg_gen_addi_ptr(ret, cpu_env, mve_qreg_offset(reg)); | ||
319 | + return ret; | ||
320 | +} | ||
321 | + | ||
322 | +static bool mve_check_qreg_bank(DisasContext *s, int qmask) | ||
323 | +{ | ||
324 | + /* | ||
325 | + * Check whether Qregs are in range. For v8.1M only Q0..Q7 | ||
326 | + * are supported, see VFPSmallRegisterBank(). | ||
327 | + */ | ||
328 | + return qmask < 8; | ||
329 | +} | ||
330 | + | ||
331 | +static bool mve_eci_check(DisasContext *s) | ||
332 | +{ | ||
333 | + /* | ||
334 | + * This is a beatwise insn: check that ECI is valid (not a | ||
335 | + * reserved value) and note that we are handling it. | ||
336 | + * Return true if OK, false if we generated an exception. | ||
337 | + */ | ||
338 | + s->eci_handled = true; | ||
339 | + switch (s->eci) { | ||
340 | + case ECI_NONE: | ||
341 | + case ECI_A0: | ||
342 | + case ECI_A0A1: | ||
343 | + case ECI_A0A1A2: | ||
344 | + case ECI_A0A1A2B0: | ||
345 | + return true; | ||
346 | + default: | ||
347 | + /* Reserved value: INVSTATE UsageFault */ | ||
348 | + gen_exception_insn(s, s->pc_curr, EXCP_INVSTATE, syn_uncategorized(), | ||
349 | + default_exception_el(s)); | ||
350 | + return false; | ||
351 | + } | ||
352 | +} | ||
353 | + | ||
354 | +static void mve_update_eci(DisasContext *s) | ||
355 | +{ | ||
356 | + /* | ||
357 | + * The helper function will always update the CPUState field, | ||
358 | + * so we only need to update the DisasContext field. | ||
359 | + */ | ||
360 | + if (s->eci) { | ||
361 | + s->eci = (s->eci == ECI_A0A1A2B0) ? ECI_A0 : ECI_NONE; | ||
362 | + } | ||
363 | +} | ||
364 | + | ||
365 | +static bool do_ldst(DisasContext *s, arg_VLDR_VSTR *a, MVEGenLdStFn *fn) | ||
366 | +{ | ||
367 | + TCGv_i32 addr; | ||
368 | + uint32_t offset; | ||
369 | + TCGv_ptr qreg; | ||
370 | + | ||
371 | + if (!dc_isar_feature(aa32_mve, s) || | ||
372 | + !mve_check_qreg_bank(s, a->qd) || | ||
373 | + !fn) { | ||
374 | + return false; | ||
375 | + } | ||
376 | + | ||
377 | + /* CONSTRAINED UNPREDICTABLE: we choose to UNDEF */ | ||
378 | + if (a->rn == 15 || (a->rn == 13 && a->w)) { | ||
379 | + return false; | ||
380 | + } | ||
381 | + | ||
382 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
383 | + return true; | ||
384 | + } | ||
385 | + | ||
386 | + offset = a->imm << a->size; | ||
387 | + if (!a->a) { | ||
388 | + offset = -offset; | ||
389 | + } | ||
390 | + addr = load_reg(s, a->rn); | ||
391 | + if (a->p) { | ||
392 | + tcg_gen_addi_i32(addr, addr, offset); | ||
393 | + } | ||
394 | + | ||
395 | + qreg = mve_qreg_ptr(a->qd); | ||
396 | + fn(cpu_env, qreg, addr); | ||
397 | + tcg_temp_free_ptr(qreg); | ||
398 | + | ||
399 | + /* | ||
400 | + * Writeback always happens after the last beat of the insn, | ||
401 | + * regardless of predication | ||
402 | + */ | ||
403 | + if (a->w) { | ||
404 | + if (!a->p) { | ||
405 | + tcg_gen_addi_i32(addr, addr, offset); | ||
406 | + } | ||
407 | + store_reg(s, a->rn, addr); | ||
408 | + } else { | ||
409 | + tcg_temp_free_i32(addr); | ||
410 | + } | ||
411 | + mve_update_eci(s); | ||
412 | + return true; | ||
413 | +} | ||
414 | + | ||
415 | +static bool trans_VLDR_VSTR(DisasContext *s, arg_VLDR_VSTR *a) | ||
416 | +{ | ||
417 | + static MVEGenLdStFn * const ldstfns[4][2] = { | ||
418 | + { gen_helper_mve_vstrb, gen_helper_mve_vldrb }, | ||
419 | + { gen_helper_mve_vstrh, gen_helper_mve_vldrh }, | ||
420 | + { gen_helper_mve_vstrw, gen_helper_mve_vldrw }, | ||
421 | + { NULL, NULL } | ||
422 | + }; | ||
423 | + return do_ldst(s, a, ldstfns[a->size][a->l]); | ||
424 | +} | ||
425 | diff --git a/target/arm/meson.build b/target/arm/meson.build | ||
426 | index XXXXXXX..XXXXXXX 100644 | 337 | index XXXXXXX..XXXXXXX 100644 |
427 | --- a/target/arm/meson.build | 338 | --- a/hw/ssi/trace-events |
428 | +++ b/target/arm/meson.build | 339 | +++ b/hw/ssi/trace-events |
429 | @@ -XXX,XX +XXX,XX @@ arm_ss.add(files( | 340 | @@ -XXX,XX +XXX,XX @@ npcm7xx_fiu_ctrl_write(const char *id, uint64_t addr, uint32_t data) "%s offset: |
430 | 'helper.c', | 341 | npcm7xx_fiu_flash_read(const char *id, int cs, uint64_t addr, unsigned int size, uint64_t value) "%s[%d] offset: 0x%08" PRIx64 " size: %u value: 0x%" PRIx64 |
431 | 'iwmmxt_helper.c', | 342 | npcm7xx_fiu_flash_write(const char *id, unsigned cs, uint64_t addr, unsigned int size, uint64_t value) "%s[%d] offset: 0x%08" PRIx64 " size: %u value: 0x%" PRIx64 |
432 | 'm_helper.c', | 343 | |
433 | + 'mve_helper.c', | 344 | +# npcm_pspi.c |
434 | 'neon_helper.c', | 345 | +npcm_pspi_enter_reset(const char *id, int reset_type) "%s reset type: %d" |
435 | 'op_helper.c', | 346 | +npcm_pspi_ctrl_read(const char *id, uint64_t addr, uint16_t data) "%s offset: 0x%03" PRIx64 " value: 0x%04" PRIx16 |
436 | 'tlb_helper.c', | 347 | +npcm_pspi_ctrl_write(const char *id, uint64_t addr, uint16_t data) "%s offset: 0x%03" PRIx64 " value: 0x%04" PRIx16 |
348 | + | ||
349 | # ibex_spi_host.c | ||
350 | |||
351 | ibex_spi_host_reset(const char *msg) "%s" | ||
437 | -- | 352 | -- |
438 | 2.20.1 | 353 | 2.34.1 |
439 | |||
440 | diff view generated by jsdifflib |
1 | Implement the MVE VQADD and VQSUB insns, which perform saturating | 1 | From: Hao Wu <wuhaotsh@google.com> |
---|---|---|---|
2 | addition of a scalar to each element. Note that individual bytes of | ||
3 | each result element are used or discarded according to the predicate | ||
4 | mask, but FPSCR.QC is only set if the predicate mask for the lowest | ||
5 | byte of the element is set. | ||
6 | 2 | ||
3 | Signed-off-by: Hao Wu <wuhaotsh@google.com> | ||
4 | Reviewed-by: Titus Rwantare <titusr@google.com> | ||
5 | Reviewed-by: Philippe Mathieu-Daude <philmd@linaro.org> | ||
6 | Message-id: 20230208235433.3989937-4-wuhaotsh@google.com | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20210617121628.20116-28-peter.maydell@linaro.org | ||
10 | --- | 8 | --- |
11 | target/arm/helper-mve.h | 16 ++++++++++ | 9 | docs/system/arm/nuvoton.rst | 2 +- |
12 | target/arm/mve.decode | 5 +++ | 10 | include/hw/arm/npcm7xx.h | 2 ++ |
13 | target/arm/mve_helper.c | 62 ++++++++++++++++++++++++++++++++++++++ | 11 | hw/arm/npcm7xx.c | 25 +++++++++++++++++++++++-- |
14 | target/arm/translate-mve.c | 4 +++ | 12 | 3 files changed, 26 insertions(+), 3 deletions(-) |
15 | 4 files changed, 87 insertions(+) | ||
16 | 13 | ||
17 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 14 | diff --git a/docs/system/arm/nuvoton.rst b/docs/system/arm/nuvoton.rst |
18 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/helper-mve.h | 16 | --- a/docs/system/arm/nuvoton.rst |
20 | +++ b/target/arm/helper-mve.h | 17 | +++ b/docs/system/arm/nuvoton.rst |
21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vhsubu_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 18 | @@ -XXX,XX +XXX,XX @@ Supported devices |
22 | DEF_HELPER_FLAGS_4(mve_vhsubu_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 19 | * SMBus controller (SMBF) |
23 | DEF_HELPER_FLAGS_4(mve_vhsubu_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 20 | * Ethernet controller (EMC) |
24 | 21 | * Tachometer | |
25 | +DEF_HELPER_FLAGS_4(mve_vqadds_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 22 | + * Peripheral SPI controller (PSPI) |
26 | +DEF_HELPER_FLAGS_4(mve_vqadds_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 23 | |
27 | +DEF_HELPER_FLAGS_4(mve_vqadds_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 24 | Missing devices |
25 | --------------- | ||
26 | @@ -XXX,XX +XXX,XX @@ Missing devices | ||
27 | |||
28 | * Ethernet controller (GMAC) | ||
29 | * USB device (USBD) | ||
30 | - * Peripheral SPI controller (PSPI) | ||
31 | * SD/MMC host | ||
32 | * PECI interface | ||
33 | * PCI and PCIe root complex and bridges | ||
34 | diff --git a/include/hw/arm/npcm7xx.h b/include/hw/arm/npcm7xx.h | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/include/hw/arm/npcm7xx.h | ||
37 | +++ b/include/hw/arm/npcm7xx.h | ||
38 | @@ -XXX,XX +XXX,XX @@ | ||
39 | #include "hw/nvram/npcm7xx_otp.h" | ||
40 | #include "hw/timer/npcm7xx_timer.h" | ||
41 | #include "hw/ssi/npcm7xx_fiu.h" | ||
42 | +#include "hw/ssi/npcm_pspi.h" | ||
43 | #include "hw/usb/hcd-ehci.h" | ||
44 | #include "hw/usb/hcd-ohci.h" | ||
45 | #include "target/arm/cpu.h" | ||
46 | @@ -XXX,XX +XXX,XX @@ struct NPCM7xxState { | ||
47 | NPCM7xxFIUState fiu[2]; | ||
48 | NPCM7xxEMCState emc[2]; | ||
49 | NPCM7xxSDHCIState mmc; | ||
50 | + NPCMPSPIState pspi[2]; | ||
51 | }; | ||
52 | |||
53 | #define TYPE_NPCM7XX "npcm7xx" | ||
54 | diff --git a/hw/arm/npcm7xx.c b/hw/arm/npcm7xx.c | ||
55 | index XXXXXXX..XXXXXXX 100644 | ||
56 | --- a/hw/arm/npcm7xx.c | ||
57 | +++ b/hw/arm/npcm7xx.c | ||
58 | @@ -XXX,XX +XXX,XX @@ enum NPCM7xxInterrupt { | ||
59 | NPCM7XX_EMC1RX_IRQ = 15, | ||
60 | NPCM7XX_EMC1TX_IRQ, | ||
61 | NPCM7XX_MMC_IRQ = 26, | ||
62 | + NPCM7XX_PSPI2_IRQ = 28, | ||
63 | + NPCM7XX_PSPI1_IRQ = 31, | ||
64 | NPCM7XX_TIMER0_IRQ = 32, /* Timer Module 0 */ | ||
65 | NPCM7XX_TIMER1_IRQ, | ||
66 | NPCM7XX_TIMER2_IRQ, | ||
67 | @@ -XXX,XX +XXX,XX @@ static const hwaddr npcm7xx_emc_addr[] = { | ||
68 | 0xf0826000, | ||
69 | }; | ||
70 | |||
71 | +/* Register base address for each PSPI Module */ | ||
72 | +static const hwaddr npcm7xx_pspi_addr[] = { | ||
73 | + 0xf0200000, | ||
74 | + 0xf0201000, | ||
75 | +}; | ||
28 | + | 76 | + |
29 | +DEF_HELPER_FLAGS_4(mve_vqaddu_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 77 | static const struct { |
30 | +DEF_HELPER_FLAGS_4(mve_vqaddu_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 78 | hwaddr regs_addr; |
31 | +DEF_HELPER_FLAGS_4(mve_vqaddu_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 79 | uint32_t unconnected_pins; |
32 | + | 80 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_init(Object *obj) |
33 | +DEF_HELPER_FLAGS_4(mve_vqsubs_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 81 | object_initialize_child(obj, "emc[*]", &s->emc[i], TYPE_NPCM7XX_EMC); |
34 | +DEF_HELPER_FLAGS_4(mve_vqsubs_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
35 | +DEF_HELPER_FLAGS_4(mve_vqsubs_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
36 | + | ||
37 | +DEF_HELPER_FLAGS_4(mve_vqsubu_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
38 | +DEF_HELPER_FLAGS_4(mve_vqsubu_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
39 | +DEF_HELPER_FLAGS_4(mve_vqsubu_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
40 | + | ||
41 | DEF_HELPER_FLAGS_4(mve_vbrsrb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
42 | DEF_HELPER_FLAGS_4(mve_vbrsrh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
43 | DEF_HELPER_FLAGS_4(mve_vbrsrw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
44 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/target/arm/mve.decode | ||
47 | +++ b/target/arm/mve.decode | ||
48 | @@ -XXX,XX +XXX,XX @@ VHADD_S_scalar 1110 1110 0 . .. ... 0 ... 0 1111 . 100 .... @2scalar | ||
49 | VHADD_U_scalar 1111 1110 0 . .. ... 0 ... 0 1111 . 100 .... @2scalar | ||
50 | VHSUB_S_scalar 1110 1110 0 . .. ... 0 ... 1 1111 . 100 .... @2scalar | ||
51 | VHSUB_U_scalar 1111 1110 0 . .. ... 0 ... 1 1111 . 100 .... @2scalar | ||
52 | + | ||
53 | +VQADD_S_scalar 1110 1110 0 . .. ... 0 ... 0 1111 . 110 .... @2scalar | ||
54 | +VQADD_U_scalar 1111 1110 0 . .. ... 0 ... 0 1111 . 110 .... @2scalar | ||
55 | +VQSUB_S_scalar 1110 1110 0 . .. ... 0 ... 1 1111 . 110 .... @2scalar | ||
56 | +VQSUB_U_scalar 1111 1110 0 . .. ... 0 ... 1 1111 . 110 .... @2scalar | ||
57 | VBRSR 1111 1110 0 . .. ... 1 ... 1 1110 . 110 .... @2scalar | ||
58 | |||
59 | # Predicate operations | ||
60 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/target/arm/mve_helper.c | ||
63 | +++ b/target/arm/mve_helper.c | ||
64 | @@ -XXX,XX +XXX,XX @@ DO_2OP_U(vhaddu, do_vhadd_u) | ||
65 | DO_2OP_S(vhsubs, do_vhsub_s) | ||
66 | DO_2OP_U(vhsubu, do_vhsub_u) | ||
67 | |||
68 | +static inline int32_t do_sat_bhw(int64_t val, int64_t min, int64_t max, bool *s) | ||
69 | +{ | ||
70 | + if (val > max) { | ||
71 | + *s = true; | ||
72 | + return max; | ||
73 | + } else if (val < min) { | ||
74 | + *s = true; | ||
75 | + return min; | ||
76 | + } | ||
77 | + return val; | ||
78 | +} | ||
79 | + | ||
80 | +#define DO_SQADD_B(n, m, s) do_sat_bhw((int64_t)n + m, INT8_MIN, INT8_MAX, s) | ||
81 | +#define DO_SQADD_H(n, m, s) do_sat_bhw((int64_t)n + m, INT16_MIN, INT16_MAX, s) | ||
82 | +#define DO_SQADD_W(n, m, s) do_sat_bhw((int64_t)n + m, INT32_MIN, INT32_MAX, s) | ||
83 | + | ||
84 | +#define DO_UQADD_B(n, m, s) do_sat_bhw((int64_t)n + m, 0, UINT8_MAX, s) | ||
85 | +#define DO_UQADD_H(n, m, s) do_sat_bhw((int64_t)n + m, 0, UINT16_MAX, s) | ||
86 | +#define DO_UQADD_W(n, m, s) do_sat_bhw((int64_t)n + m, 0, UINT32_MAX, s) | ||
87 | + | ||
88 | +#define DO_SQSUB_B(n, m, s) do_sat_bhw((int64_t)n - m, INT8_MIN, INT8_MAX, s) | ||
89 | +#define DO_SQSUB_H(n, m, s) do_sat_bhw((int64_t)n - m, INT16_MIN, INT16_MAX, s) | ||
90 | +#define DO_SQSUB_W(n, m, s) do_sat_bhw((int64_t)n - m, INT32_MIN, INT32_MAX, s) | ||
91 | + | ||
92 | +#define DO_UQSUB_B(n, m, s) do_sat_bhw((int64_t)n - m, 0, UINT8_MAX, s) | ||
93 | +#define DO_UQSUB_H(n, m, s) do_sat_bhw((int64_t)n - m, 0, UINT16_MAX, s) | ||
94 | +#define DO_UQSUB_W(n, m, s) do_sat_bhw((int64_t)n - m, 0, UINT32_MAX, s) | ||
95 | |||
96 | #define DO_2OP_SCALAR(OP, ESIZE, TYPE, FN) \ | ||
97 | void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, \ | ||
98 | @@ -XXX,XX +XXX,XX @@ DO_2OP_U(vhsubu, do_vhsub_u) | ||
99 | mve_advance_vpt(env); \ | ||
100 | } | 82 | } |
101 | 83 | ||
102 | +#define DO_2OP_SAT_SCALAR(OP, ESIZE, TYPE, FN) \ | 84 | + for (i = 0; i < ARRAY_SIZE(s->pspi); i++) { |
103 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, \ | 85 | + object_initialize_child(obj, "pspi[*]", &s->pspi[i], TYPE_NPCM_PSPI); |
104 | + uint32_t rm) \ | ||
105 | + { \ | ||
106 | + TYPE *d = vd, *n = vn; \ | ||
107 | + TYPE m = rm; \ | ||
108 | + uint16_t mask = mve_element_mask(env); \ | ||
109 | + unsigned e; \ | ||
110 | + bool qc = false; \ | ||
111 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
112 | + bool sat = false; \ | ||
113 | + mergemask(&d[H##ESIZE(e)], FN(n[H##ESIZE(e)], m, &sat), \ | ||
114 | + mask); \ | ||
115 | + qc |= sat & mask & 1; \ | ||
116 | + } \ | ||
117 | + if (qc) { \ | ||
118 | + env->vfp.qc[0] = qc; \ | ||
119 | + } \ | ||
120 | + mve_advance_vpt(env); \ | ||
121 | + } | 86 | + } |
122 | + | 87 | + |
123 | /* provide unsigned 2-op scalar helpers for all sizes */ | 88 | object_initialize_child(obj, "mmc", &s->mmc, TYPE_NPCM7XX_SDHCI); |
124 | #define DO_2OP_SCALAR_U(OP, FN) \ | 89 | } |
125 | DO_2OP_SCALAR(OP##b, 1, uint8_t, FN) \ | 90 | |
126 | @@ -XXX,XX +XXX,XX @@ DO_2OP_SCALAR_U(vhaddu_scalar, do_vhadd_u) | 91 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_realize(DeviceState *dev, Error **errp) |
127 | DO_2OP_SCALAR_S(vhsubs_scalar, do_vhsub_s) | 92 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->mmc), 0, |
128 | DO_2OP_SCALAR_U(vhsubu_scalar, do_vhsub_u) | 93 | npcm7xx_irq(s, NPCM7XX_MMC_IRQ)); |
129 | 94 | ||
130 | +DO_2OP_SAT_SCALAR(vqaddu_scalarb, 1, uint8_t, DO_UQADD_B) | 95 | + /* PSPI */ |
131 | +DO_2OP_SAT_SCALAR(vqaddu_scalarh, 2, uint16_t, DO_UQADD_H) | 96 | + QEMU_BUILD_BUG_ON(ARRAY_SIZE(npcm7xx_pspi_addr) != ARRAY_SIZE(s->pspi)); |
132 | +DO_2OP_SAT_SCALAR(vqaddu_scalarw, 4, uint32_t, DO_UQADD_W) | 97 | + for (i = 0; i < ARRAY_SIZE(s->pspi); i++) { |
133 | +DO_2OP_SAT_SCALAR(vqadds_scalarb, 1, int8_t, DO_SQADD_B) | 98 | + SysBusDevice *sbd = SYS_BUS_DEVICE(&s->pspi[i]); |
134 | +DO_2OP_SAT_SCALAR(vqadds_scalarh, 2, int16_t, DO_SQADD_H) | 99 | + int irq = (i == 0) ? NPCM7XX_PSPI1_IRQ : NPCM7XX_PSPI2_IRQ; |
135 | +DO_2OP_SAT_SCALAR(vqadds_scalarw, 4, int32_t, DO_SQADD_W) | ||
136 | + | 100 | + |
137 | +DO_2OP_SAT_SCALAR(vqsubu_scalarb, 1, uint8_t, DO_UQSUB_B) | 101 | + sysbus_realize(sbd, &error_abort); |
138 | +DO_2OP_SAT_SCALAR(vqsubu_scalarh, 2, uint16_t, DO_UQSUB_H) | 102 | + sysbus_mmio_map(sbd, 0, npcm7xx_pspi_addr[i]); |
139 | +DO_2OP_SAT_SCALAR(vqsubu_scalarw, 4, uint32_t, DO_UQSUB_W) | 103 | + sysbus_connect_irq(sbd, 0, npcm7xx_irq(s, irq)); |
140 | +DO_2OP_SAT_SCALAR(vqsubs_scalarb, 1, int8_t, DO_SQSUB_B) | 104 | + } |
141 | +DO_2OP_SAT_SCALAR(vqsubs_scalarh, 2, int16_t, DO_SQSUB_H) | ||
142 | +DO_2OP_SAT_SCALAR(vqsubs_scalarw, 4, int32_t, DO_SQSUB_W) | ||
143 | + | 105 | + |
144 | static inline uint32_t do_vbrsrb(uint32_t n, uint32_t m) | 106 | create_unimplemented_device("npcm7xx.shm", 0xc0001000, 4 * KiB); |
145 | { | 107 | create_unimplemented_device("npcm7xx.vdmx", 0xe0800000, 4 * KiB); |
146 | m &= 0xff; | 108 | create_unimplemented_device("npcm7xx.pcierc", 0xe1000000, 64 * KiB); |
147 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | 109 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_realize(DeviceState *dev, Error **errp) |
148 | index XXXXXXX..XXXXXXX 100644 | 110 | create_unimplemented_device("npcm7xx.peci", 0xf0100000, 4 * KiB); |
149 | --- a/target/arm/translate-mve.c | 111 | create_unimplemented_device("npcm7xx.siox[1]", 0xf0101000, 4 * KiB); |
150 | +++ b/target/arm/translate-mve.c | 112 | create_unimplemented_device("npcm7xx.siox[2]", 0xf0102000, 4 * KiB); |
151 | @@ -XXX,XX +XXX,XX @@ DO_2OP_SCALAR(VHADD_S_scalar, vhadds_scalar) | 113 | - create_unimplemented_device("npcm7xx.pspi1", 0xf0200000, 4 * KiB); |
152 | DO_2OP_SCALAR(VHADD_U_scalar, vhaddu_scalar) | 114 | - create_unimplemented_device("npcm7xx.pspi2", 0xf0201000, 4 * KiB); |
153 | DO_2OP_SCALAR(VHSUB_S_scalar, vhsubs_scalar) | 115 | create_unimplemented_device("npcm7xx.ahbpci", 0xf0400000, 1 * MiB); |
154 | DO_2OP_SCALAR(VHSUB_U_scalar, vhsubu_scalar) | 116 | create_unimplemented_device("npcm7xx.mcphy", 0xf05f0000, 64 * KiB); |
155 | +DO_2OP_SCALAR(VQADD_S_scalar, vqadds_scalar) | 117 | create_unimplemented_device("npcm7xx.gmac1", 0xf0802000, 8 * KiB); |
156 | +DO_2OP_SCALAR(VQADD_U_scalar, vqaddu_scalar) | ||
157 | +DO_2OP_SCALAR(VQSUB_S_scalar, vqsubs_scalar) | ||
158 | +DO_2OP_SCALAR(VQSUB_U_scalar, vqsubu_scalar) | ||
159 | DO_2OP_SCALAR(VBRSR, vbrsr) | ||
160 | |||
161 | static bool do_long_dual_acc(DisasContext *s, arg_vmlaldav *a, | ||
162 | -- | 118 | -- |
163 | 2.20.1 | 119 | 2.34.1 |
164 | |||
165 | diff view generated by jsdifflib |
1 | Implement the vector form of the MVE VQDMULL insn. | 1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Addresses targeting the second translation table (TTB1) in the SMMU have | ||
4 | all upper bits set. Ensure the IOMMU region covers all 64 bits. | ||
5 | |||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> | ||
8 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
9 | Message-id: 20230214171921.1917916-2-jean-philippe@linaro.org | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20210617121628.20116-39-peter.maydell@linaro.org | ||
6 | --- | 11 | --- |
7 | target/arm/helper-mve.h | 5 +++++ | 12 | include/hw/arm/smmu-common.h | 2 -- |
8 | target/arm/mve.decode | 5 +++++ | 13 | hw/arm/smmu-common.c | 2 +- |
9 | target/arm/mve_helper.c | 30 ++++++++++++++++++++++++++++++ | 14 | 2 files changed, 1 insertion(+), 3 deletions(-) |
10 | target/arm/translate-mve.c | 30 ++++++++++++++++++++++++++++++ | ||
11 | 4 files changed, 70 insertions(+) | ||
12 | 15 | ||
13 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 16 | diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h |
14 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/helper-mve.h | 18 | --- a/include/hw/arm/smmu-common.h |
16 | +++ b/target/arm/helper-mve.h | 19 | +++ b/include/hw/arm/smmu-common.h |
17 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqrdmlsdhxb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 20 | @@ -XXX,XX +XXX,XX @@ |
18 | DEF_HELPER_FLAGS_4(mve_vqrdmlsdhxh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 21 | #define SMMU_PCI_DEVFN_MAX 256 |
19 | DEF_HELPER_FLAGS_4(mve_vqrdmlsdhxw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 22 | #define SMMU_PCI_DEVFN(sid) (sid & 0xFF) |
20 | 23 | ||
21 | +DEF_HELPER_FLAGS_4(mve_vqdmullbh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 24 | -#define SMMU_MAX_VA_BITS 48 |
22 | +DEF_HELPER_FLAGS_4(mve_vqdmullbw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 25 | - |
23 | +DEF_HELPER_FLAGS_4(mve_vqdmullth, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 26 | /* |
24 | +DEF_HELPER_FLAGS_4(mve_vqdmulltw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 27 | * Page table walk error types |
25 | + | 28 | */ |
26 | DEF_HELPER_FLAGS_4(mve_vadd_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 29 | diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c |
27 | DEF_HELPER_FLAGS_4(mve_vadd_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
28 | DEF_HELPER_FLAGS_4(mve_vadd_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
29 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
30 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
31 | --- a/target/arm/mve.decode | 31 | --- a/hw/arm/smmu-common.c |
32 | +++ b/target/arm/mve.decode | 32 | +++ b/hw/arm/smmu-common.c |
33 | @@ -XXX,XX +XXX,XX @@ | 33 | @@ -XXX,XX +XXX,XX @@ static AddressSpace *smmu_find_add_as(PCIBus *bus, void *opaque, int devfn) |
34 | @1op_nosz .... .... .... .... .... .... .... .... &1op qd=%qd qm=%qm size=0 | 34 | |
35 | @2op .... .... .. size:2 .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn | 35 | memory_region_init_iommu(&sdev->iommu, sizeof(sdev->iommu), |
36 | @2op_nosz .... .... .... .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn size=0 | 36 | s->mrtypename, |
37 | +@2op_sz28 .... .... .... .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn \ | 37 | - OBJECT(s), name, 1ULL << SMMU_MAX_VA_BITS); |
38 | + size=%size_28 | 38 | + OBJECT(s), name, UINT64_MAX); |
39 | 39 | address_space_init(&sdev->as, | |
40 | # The _rev suffix indicates that Vn and Vm are reversed. This is | 40 | MEMORY_REGION(&sdev->iommu), name); |
41 | # the case for shifts. In the Arm ARM these insns are documented | 41 | trace_smmu_add_mr(name); |
42 | @@ -XXX,XX +XXX,XX @@ VQDMLSDHX 1111 1110 0 . .. ... 0 ... 1 1110 . 0 . 0 ... 0 @2op | ||
43 | VQRDMLSDH 1111 1110 0 . .. ... 0 ... 0 1110 . 0 . 0 ... 1 @2op | ||
44 | VQRDMLSDHX 1111 1110 0 . .. ... 0 ... 1 1110 . 0 . 0 ... 1 @2op | ||
45 | |||
46 | +VQDMULLB 111 . 1110 0 . 11 ... 0 ... 0 1111 . 0 . 0 ... 1 @2op_sz28 | ||
47 | +VQDMULLT 111 . 1110 0 . 11 ... 0 ... 1 1111 . 0 . 0 ... 1 @2op_sz28 | ||
48 | + | ||
49 | # Vector miscellaneous | ||
50 | |||
51 | VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op | ||
52 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | --- a/target/arm/mve_helper.c | ||
55 | +++ b/target/arm/mve_helper.c | ||
56 | @@ -XXX,XX +XXX,XX @@ DO_2OP_SAT_SCALAR_L(vqdmullt_scalarh, 1, 2, int16_t, 4, int32_t, \ | ||
57 | DO_2OP_SAT_SCALAR_L(vqdmullt_scalarw, 1, 4, int32_t, 8, int64_t, \ | ||
58 | do_qdmullw, SATMASK32) | ||
59 | |||
60 | +/* | ||
61 | + * Long saturating ops | ||
62 | + */ | ||
63 | +#define DO_2OP_SAT_L(OP, TOP, ESIZE, TYPE, LESIZE, LTYPE, FN, SATMASK) \ | ||
64 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, \ | ||
65 | + void *vm) \ | ||
66 | + { \ | ||
67 | + LTYPE *d = vd; \ | ||
68 | + TYPE *n = vn, *m = vm; \ | ||
69 | + uint16_t mask = mve_element_mask(env); \ | ||
70 | + unsigned le; \ | ||
71 | + bool qc = false; \ | ||
72 | + for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \ | ||
73 | + bool sat = false; \ | ||
74 | + LTYPE op1 = n[H##ESIZE(le * 2 + TOP)]; \ | ||
75 | + LTYPE op2 = m[H##ESIZE(le * 2 + TOP)]; \ | ||
76 | + mergemask(&d[H##LESIZE(le)], FN(op1, op2, &sat), mask); \ | ||
77 | + qc |= sat && (mask & SATMASK); \ | ||
78 | + } \ | ||
79 | + if (qc) { \ | ||
80 | + env->vfp.qc[0] = qc; \ | ||
81 | + } \ | ||
82 | + mve_advance_vpt(env); \ | ||
83 | + } | ||
84 | + | ||
85 | +DO_2OP_SAT_L(vqdmullbh, 0, 2, int16_t, 4, int32_t, do_qdmullh, SATMASK16B) | ||
86 | +DO_2OP_SAT_L(vqdmullbw, 0, 4, int32_t, 8, int64_t, do_qdmullw, SATMASK32) | ||
87 | +DO_2OP_SAT_L(vqdmullth, 1, 2, int16_t, 4, int32_t, do_qdmullh, SATMASK16T) | ||
88 | +DO_2OP_SAT_L(vqdmulltw, 1, 4, int32_t, 8, int64_t, do_qdmullw, SATMASK32) | ||
89 | + | ||
90 | static inline uint32_t do_vbrsrb(uint32_t n, uint32_t m) | ||
91 | { | ||
92 | m &= 0xff; | ||
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(VQDMLSDHX, vqdmlsdhx) | ||
98 | DO_2OP(VQRDMLSDH, vqrdmlsdh) | ||
99 | DO_2OP(VQRDMLSDHX, vqrdmlsdhx) | ||
100 | |||
101 | +static bool trans_VQDMULLB(DisasContext *s, arg_2op *a) | ||
102 | +{ | ||
103 | + static MVEGenTwoOpFn * const fns[] = { | ||
104 | + NULL, | ||
105 | + gen_helper_mve_vqdmullbh, | ||
106 | + gen_helper_mve_vqdmullbw, | ||
107 | + NULL, | ||
108 | + }; | ||
109 | + if (a->size == MO_32 && (a->qd == a->qm || a->qd == a->qn)) { | ||
110 | + /* UNPREDICTABLE; we choose to undef */ | ||
111 | + return false; | ||
112 | + } | ||
113 | + return do_2op(s, a, fns[a->size]); | ||
114 | +} | ||
115 | + | ||
116 | +static bool trans_VQDMULLT(DisasContext *s, arg_2op *a) | ||
117 | +{ | ||
118 | + static MVEGenTwoOpFn * const fns[] = { | ||
119 | + NULL, | ||
120 | + gen_helper_mve_vqdmullth, | ||
121 | + gen_helper_mve_vqdmulltw, | ||
122 | + NULL, | ||
123 | + }; | ||
124 | + if (a->size == MO_32 && (a->qd == a->qm || a->qd == a->qn)) { | ||
125 | + /* UNPREDICTABLE; we choose to undef */ | ||
126 | + return false; | ||
127 | + } | ||
128 | + return do_2op(s, a, fns[a->size]); | ||
129 | +} | ||
130 | + | ||
131 | static bool do_2op_scalar(DisasContext *s, arg_2scalar *a, | ||
132 | MVEGenTwoOpScalarFn fn) | ||
133 | { | ||
134 | -- | 42 | -- |
135 | 2.20.1 | 43 | 2.34.1 |
136 | |||
137 | diff view generated by jsdifflib |
1 | Implement the MVE VQDMLSDH and VQRDMLSDH insns, which are | 1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> |
---|---|---|---|
2 | like VQDMLADH and VQRDMLADH except that products are subtracted | ||
3 | rather than added. | ||
4 | 2 | ||
3 | Addresses targeting the second translation table (TTB1) in the SMMU have | ||
4 | all upper bits set (except for the top byte when TBI is enabled). Fix | ||
5 | the TTB1 check. | ||
6 | |||
7 | Reported-by: Ola Hugosson <ola.hugosson@arm.com> | ||
8 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> | ||
11 | Message-id: 20230214171921.1917916-3-jean-philippe@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 | Message-id: 20210617121628.20116-38-peter.maydell@linaro.org | ||
8 | --- | 13 | --- |
9 | target/arm/helper-mve.h | 16 ++++++++++++++ | 14 | hw/arm/smmu-common.c | 2 +- |
10 | target/arm/mve.decode | 5 +++++ | 15 | 1 file changed, 1 insertion(+), 1 deletion(-) |
11 | target/arm/mve_helper.c | 44 ++++++++++++++++++++++++++++++++++++++ | ||
12 | target/arm/translate-mve.c | 4 ++++ | ||
13 | 4 files changed, 69 insertions(+) | ||
14 | 16 | ||
15 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 17 | diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c |
16 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/helper-mve.h | 19 | --- a/hw/arm/smmu-common.c |
18 | +++ b/target/arm/helper-mve.h | 20 | +++ b/hw/arm/smmu-common.c |
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqrdmladhxb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 21 | @@ -XXX,XX +XXX,XX @@ SMMUTransTableInfo *select_tt(SMMUTransCfg *cfg, dma_addr_t iova) |
20 | DEF_HELPER_FLAGS_4(mve_vqrdmladhxh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 22 | /* there is a ttbr0 region and we are in it (high bits all zero) */ |
21 | DEF_HELPER_FLAGS_4(mve_vqrdmladhxw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 23 | return &cfg->tt[0]; |
22 | 24 | } else if (cfg->tt[1].tsz && | |
23 | +DEF_HELPER_FLAGS_4(mve_vqdmlsdhb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 25 | - !extract64(iova, 64 - cfg->tt[1].tsz, cfg->tt[1].tsz - tbi_byte)) { |
24 | +DEF_HELPER_FLAGS_4(mve_vqdmlsdhh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 26 | + sextract64(iova, 64 - cfg->tt[1].tsz, cfg->tt[1].tsz - tbi_byte) == -1) { |
25 | +DEF_HELPER_FLAGS_4(mve_vqdmlsdhw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 27 | /* there is a ttbr1 region and we are in it (high bits all one) */ |
26 | + | 28 | return &cfg->tt[1]; |
27 | +DEF_HELPER_FLAGS_4(mve_vqdmlsdhxb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 29 | } else if (!cfg->tt[0].tsz) { |
28 | +DEF_HELPER_FLAGS_4(mve_vqdmlsdhxh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
29 | +DEF_HELPER_FLAGS_4(mve_vqdmlsdhxw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
30 | + | ||
31 | +DEF_HELPER_FLAGS_4(mve_vqrdmlsdhb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
32 | +DEF_HELPER_FLAGS_4(mve_vqrdmlsdhh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
33 | +DEF_HELPER_FLAGS_4(mve_vqrdmlsdhw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
34 | + | ||
35 | +DEF_HELPER_FLAGS_4(mve_vqrdmlsdhxb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
36 | +DEF_HELPER_FLAGS_4(mve_vqrdmlsdhxh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
37 | +DEF_HELPER_FLAGS_4(mve_vqrdmlsdhxw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
38 | + | ||
39 | DEF_HELPER_FLAGS_4(mve_vadd_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
40 | DEF_HELPER_FLAGS_4(mve_vadd_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
41 | DEF_HELPER_FLAGS_4(mve_vadd_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
42 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/target/arm/mve.decode | ||
45 | +++ b/target/arm/mve.decode | ||
46 | @@ -XXX,XX +XXX,XX @@ VQDMLADHX 1110 1110 0 . .. ... 0 ... 1 1110 . 0 . 0 ... 0 @2op | ||
47 | VQRDMLADH 1110 1110 0 . .. ... 0 ... 0 1110 . 0 . 0 ... 1 @2op | ||
48 | VQRDMLADHX 1110 1110 0 . .. ... 0 ... 1 1110 . 0 . 0 ... 1 @2op | ||
49 | |||
50 | +VQDMLSDH 1111 1110 0 . .. ... 0 ... 0 1110 . 0 . 0 ... 0 @2op | ||
51 | +VQDMLSDHX 1111 1110 0 . .. ... 0 ... 1 1110 . 0 . 0 ... 0 @2op | ||
52 | +VQRDMLSDH 1111 1110 0 . .. ... 0 ... 0 1110 . 0 . 0 ... 1 @2op | ||
53 | +VQRDMLSDHX 1111 1110 0 . .. ... 0 ... 1 1110 . 0 . 0 ... 1 @2op | ||
54 | + | ||
55 | # Vector miscellaneous | ||
56 | |||
57 | VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op | ||
58 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
59 | index XXXXXXX..XXXXXXX 100644 | ||
60 | --- a/target/arm/mve_helper.c | ||
61 | +++ b/target/arm/mve_helper.c | ||
62 | @@ -XXX,XX +XXX,XX @@ static int32_t do_vqdmladh_w(int32_t a, int32_t b, int32_t c, int32_t d, | ||
63 | return r >> 32; | ||
64 | } | ||
65 | |||
66 | +static int8_t do_vqdmlsdh_b(int8_t a, int8_t b, int8_t c, int8_t d, | ||
67 | + int round, bool *sat) | ||
68 | +{ | ||
69 | + int64_t r = ((int64_t)a * b - (int64_t)c * d) * 2 + (round << 7); | ||
70 | + return do_sat_bhw(r, INT16_MIN, INT16_MAX, sat) >> 8; | ||
71 | +} | ||
72 | + | ||
73 | +static int16_t do_vqdmlsdh_h(int16_t a, int16_t b, int16_t c, int16_t d, | ||
74 | + int round, bool *sat) | ||
75 | +{ | ||
76 | + int64_t r = ((int64_t)a * b - (int64_t)c * d) * 2 + (round << 15); | ||
77 | + return do_sat_bhw(r, INT32_MIN, INT32_MAX, sat) >> 16; | ||
78 | +} | ||
79 | + | ||
80 | +static int32_t do_vqdmlsdh_w(int32_t a, int32_t b, int32_t c, int32_t d, | ||
81 | + int round, bool *sat) | ||
82 | +{ | ||
83 | + int64_t m1 = (int64_t)a * b; | ||
84 | + int64_t m2 = (int64_t)c * d; | ||
85 | + int64_t r; | ||
86 | + /* The same ordering issue as in do_vqdmladh_w applies here too */ | ||
87 | + if (ssub64_overflow(m1, m2, &r) || | ||
88 | + sadd64_overflow(r, (round << 30), &r) || | ||
89 | + sadd64_overflow(r, r, &r)) { | ||
90 | + *sat = true; | ||
91 | + return r < 0 ? INT32_MAX : INT32_MIN; | ||
92 | + } | ||
93 | + return r >> 32; | ||
94 | +} | ||
95 | + | ||
96 | DO_VQDMLADH_OP(vqdmladhb, 1, int8_t, 0, 0, do_vqdmladh_b) | ||
97 | DO_VQDMLADH_OP(vqdmladhh, 2, int16_t, 0, 0, do_vqdmladh_h) | ||
98 | DO_VQDMLADH_OP(vqdmladhw, 4, int32_t, 0, 0, do_vqdmladh_w) | ||
99 | @@ -XXX,XX +XXX,XX @@ DO_VQDMLADH_OP(vqrdmladhxb, 1, int8_t, 1, 1, do_vqdmladh_b) | ||
100 | DO_VQDMLADH_OP(vqrdmladhxh, 2, int16_t, 1, 1, do_vqdmladh_h) | ||
101 | DO_VQDMLADH_OP(vqrdmladhxw, 4, int32_t, 1, 1, do_vqdmladh_w) | ||
102 | |||
103 | +DO_VQDMLADH_OP(vqdmlsdhb, 1, int8_t, 0, 0, do_vqdmlsdh_b) | ||
104 | +DO_VQDMLADH_OP(vqdmlsdhh, 2, int16_t, 0, 0, do_vqdmlsdh_h) | ||
105 | +DO_VQDMLADH_OP(vqdmlsdhw, 4, int32_t, 0, 0, do_vqdmlsdh_w) | ||
106 | +DO_VQDMLADH_OP(vqdmlsdhxb, 1, int8_t, 1, 0, do_vqdmlsdh_b) | ||
107 | +DO_VQDMLADH_OP(vqdmlsdhxh, 2, int16_t, 1, 0, do_vqdmlsdh_h) | ||
108 | +DO_VQDMLADH_OP(vqdmlsdhxw, 4, int32_t, 1, 0, do_vqdmlsdh_w) | ||
109 | + | ||
110 | +DO_VQDMLADH_OP(vqrdmlsdhb, 1, int8_t, 0, 1, do_vqdmlsdh_b) | ||
111 | +DO_VQDMLADH_OP(vqrdmlsdhh, 2, int16_t, 0, 1, do_vqdmlsdh_h) | ||
112 | +DO_VQDMLADH_OP(vqrdmlsdhw, 4, int32_t, 0, 1, do_vqdmlsdh_w) | ||
113 | +DO_VQDMLADH_OP(vqrdmlsdhxb, 1, int8_t, 1, 1, do_vqdmlsdh_b) | ||
114 | +DO_VQDMLADH_OP(vqrdmlsdhxh, 2, int16_t, 1, 1, do_vqdmlsdh_h) | ||
115 | +DO_VQDMLADH_OP(vqrdmlsdhxw, 4, int32_t, 1, 1, do_vqdmlsdh_w) | ||
116 | + | ||
117 | #define DO_2OP_SCALAR(OP, ESIZE, TYPE, FN) \ | ||
118 | void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, \ | ||
119 | uint32_t rm) \ | ||
120 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
121 | index XXXXXXX..XXXXXXX 100644 | ||
122 | --- a/target/arm/translate-mve.c | ||
123 | +++ b/target/arm/translate-mve.c | ||
124 | @@ -XXX,XX +XXX,XX @@ DO_2OP(VQDMLADH, vqdmladh) | ||
125 | DO_2OP(VQDMLADHX, vqdmladhx) | ||
126 | DO_2OP(VQRDMLADH, vqrdmladh) | ||
127 | DO_2OP(VQRDMLADHX, vqrdmladhx) | ||
128 | +DO_2OP(VQDMLSDH, vqdmlsdh) | ||
129 | +DO_2OP(VQDMLSDHX, vqdmlsdhx) | ||
130 | +DO_2OP(VQRDMLSDH, vqrdmlsdh) | ||
131 | +DO_2OP(VQRDMLSDHX, vqrdmlsdhx) | ||
132 | |||
133 | static bool do_2op_scalar(DisasContext *s, arg_2scalar *a, | ||
134 | MVEGenTwoOpScalarFn fn) | ||
135 | -- | 30 | -- |
136 | 2.20.1 | 31 | 2.34.1 |
137 | |||
138 | diff view generated by jsdifflib |
1 | Implement the MVE VQDMLADH and VQRDMLADH insns. These multiply | 1 | From: Claudio Fontana <cfontana@suse.de> |
---|---|---|---|
2 | elements, and then add pairs of products, double, possibly round, | ||
3 | saturate and return the high half of the result. | ||
4 | 2 | ||
3 | make it clearer from the name that this is a tcg-only function. | ||
4 | |||
5 | Signed-off-by: Claudio Fontana <cfontana@suse.de> | ||
6 | Signed-off-by: Fabiano Rosas <farosas@suse.de> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
9 | Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20210617121628.20116-37-peter.maydell@linaro.org | ||
8 | --- | 11 | --- |
9 | target/arm/helper-mve.h | 16 +++++++ | 12 | target/arm/helper.c | 4 ++-- |
10 | target/arm/mve.decode | 5 +++ | 13 | 1 file changed, 2 insertions(+), 2 deletions(-) |
11 | target/arm/mve_helper.c | 89 ++++++++++++++++++++++++++++++++++++++ | ||
12 | target/arm/translate-mve.c | 4 ++ | ||
13 | 4 files changed, 114 insertions(+) | ||
14 | 14 | ||
15 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 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/target/arm/helper-mve.h | 17 | --- a/target/arm/helper.c |
18 | +++ b/target/arm/helper-mve.h | 18 | +++ b/target/arm/helper.c |
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqrshlub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 19 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) |
20 | DEF_HELPER_FLAGS_4(mve_vqrshluh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 20 | * trapped to the hypervisor in KVM. |
21 | DEF_HELPER_FLAGS_4(mve_vqrshluw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 21 | */ |
22 | 22 | #ifdef CONFIG_TCG | |
23 | +DEF_HELPER_FLAGS_4(mve_vqdmladhb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 23 | -static void handle_semihosting(CPUState *cs) |
24 | +DEF_HELPER_FLAGS_4(mve_vqdmladhh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 24 | +static void tcg_handle_semihosting(CPUState *cs) |
25 | +DEF_HELPER_FLAGS_4(mve_vqdmladhw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 25 | { |
26 | + | 26 | ARMCPU *cpu = ARM_CPU(cs); |
27 | +DEF_HELPER_FLAGS_4(mve_vqdmladhxb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 27 | CPUARMState *env = &cpu->env; |
28 | +DEF_HELPER_FLAGS_4(mve_vqdmladhxh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 28 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_do_interrupt(CPUState *cs) |
29 | +DEF_HELPER_FLAGS_4(mve_vqdmladhxw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 29 | */ |
30 | + | 30 | #ifdef CONFIG_TCG |
31 | +DEF_HELPER_FLAGS_4(mve_vqrdmladhb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 31 | if (cs->exception_index == EXCP_SEMIHOST) { |
32 | +DEF_HELPER_FLAGS_4(mve_vqrdmladhh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 32 | - handle_semihosting(cs); |
33 | +DEF_HELPER_FLAGS_4(mve_vqrdmladhw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 33 | + tcg_handle_semihosting(cs); |
34 | + | 34 | return; |
35 | +DEF_HELPER_FLAGS_4(mve_vqrdmladhxb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 35 | } |
36 | +DEF_HELPER_FLAGS_4(mve_vqrdmladhxh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 36 | #endif |
37 | +DEF_HELPER_FLAGS_4(mve_vqrdmladhxw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
38 | + | ||
39 | DEF_HELPER_FLAGS_4(mve_vadd_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
40 | DEF_HELPER_FLAGS_4(mve_vadd_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
41 | DEF_HELPER_FLAGS_4(mve_vadd_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
42 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/target/arm/mve.decode | ||
45 | +++ b/target/arm/mve.decode | ||
46 | @@ -XXX,XX +XXX,XX @@ VQSHL_U 111 1 1111 0 . .. ... 0 ... 0 0100 . 1 . 1 ... 0 @2op_rev | ||
47 | VQRSHL_S 111 0 1111 0 . .. ... 0 ... 0 0101 . 1 . 1 ... 0 @2op_rev | ||
48 | VQRSHL_U 111 1 1111 0 . .. ... 0 ... 0 0101 . 1 . 1 ... 0 @2op_rev | ||
49 | |||
50 | +VQDMLADH 1110 1110 0 . .. ... 0 ... 0 1110 . 0 . 0 ... 0 @2op | ||
51 | +VQDMLADHX 1110 1110 0 . .. ... 0 ... 1 1110 . 0 . 0 ... 0 @2op | ||
52 | +VQRDMLADH 1110 1110 0 . .. ... 0 ... 0 1110 . 0 . 0 ... 1 @2op | ||
53 | +VQRDMLADHX 1110 1110 0 . .. ... 0 ... 1 1110 . 0 . 0 ... 1 @2op | ||
54 | + | ||
55 | # Vector miscellaneous | ||
56 | |||
57 | VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op | ||
58 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
59 | index XXXXXXX..XXXXXXX 100644 | ||
60 | --- a/target/arm/mve_helper.c | ||
61 | +++ b/target/arm/mve_helper.c | ||
62 | @@ -XXX,XX +XXX,XX @@ DO_2OP_SAT_U(vqshlu, DO_UQSHL_OP) | ||
63 | DO_2OP_SAT_S(vqrshls, DO_SQRSHL_OP) | ||
64 | DO_2OP_SAT_U(vqrshlu, DO_UQRSHL_OP) | ||
65 | |||
66 | +/* | ||
67 | + * Multiply add dual returning high half | ||
68 | + * The 'FN' here takes four inputs A, B, C, D, a 0/1 indicator of | ||
69 | + * whether to add the rounding constant, and the pointer to the | ||
70 | + * saturation flag, and should do "(A * B + C * D) * 2 + rounding constant", | ||
71 | + * saturate to twice the input size and return the high half; or | ||
72 | + * (A * B - C * D) etc for VQDMLSDH. | ||
73 | + */ | ||
74 | +#define DO_VQDMLADH_OP(OP, ESIZE, TYPE, XCHG, ROUND, FN) \ | ||
75 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, \ | ||
76 | + void *vm) \ | ||
77 | + { \ | ||
78 | + TYPE *d = vd, *n = vn, *m = vm; \ | ||
79 | + uint16_t mask = mve_element_mask(env); \ | ||
80 | + unsigned e; \ | ||
81 | + bool qc = false; \ | ||
82 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
83 | + bool sat = false; \ | ||
84 | + if ((e & 1) == XCHG) { \ | ||
85 | + TYPE r = FN(n[H##ESIZE(e)], \ | ||
86 | + m[H##ESIZE(e - XCHG)], \ | ||
87 | + n[H##ESIZE(e + (1 - 2 * XCHG))], \ | ||
88 | + m[H##ESIZE(e + (1 - XCHG))], \ | ||
89 | + ROUND, &sat); \ | ||
90 | + mergemask(&d[H##ESIZE(e)], r, mask); \ | ||
91 | + qc |= sat & mask & 1; \ | ||
92 | + } \ | ||
93 | + } \ | ||
94 | + if (qc) { \ | ||
95 | + env->vfp.qc[0] = qc; \ | ||
96 | + } \ | ||
97 | + mve_advance_vpt(env); \ | ||
98 | + } | ||
99 | + | ||
100 | +static int8_t do_vqdmladh_b(int8_t a, int8_t b, int8_t c, int8_t d, | ||
101 | + int round, bool *sat) | ||
102 | +{ | ||
103 | + int64_t r = ((int64_t)a * b + (int64_t)c * d) * 2 + (round << 7); | ||
104 | + return do_sat_bhw(r, INT16_MIN, INT16_MAX, sat) >> 8; | ||
105 | +} | ||
106 | + | ||
107 | +static int16_t do_vqdmladh_h(int16_t a, int16_t b, int16_t c, int16_t d, | ||
108 | + int round, bool *sat) | ||
109 | +{ | ||
110 | + int64_t r = ((int64_t)a * b + (int64_t)c * d) * 2 + (round << 15); | ||
111 | + return do_sat_bhw(r, INT32_MIN, INT32_MAX, sat) >> 16; | ||
112 | +} | ||
113 | + | ||
114 | +static int32_t do_vqdmladh_w(int32_t a, int32_t b, int32_t c, int32_t d, | ||
115 | + int round, bool *sat) | ||
116 | +{ | ||
117 | + int64_t m1 = (int64_t)a * b; | ||
118 | + int64_t m2 = (int64_t)c * d; | ||
119 | + int64_t r; | ||
120 | + /* | ||
121 | + * Architecturally we should do the entire add, double, round | ||
122 | + * and then check for saturation. We do three saturating adds, | ||
123 | + * but we need to be careful about the order. If the first | ||
124 | + * m1 + m2 saturates then it's impossible for the *2+rc to | ||
125 | + * bring it back into the non-saturated range. However, if | ||
126 | + * m1 + m2 is negative then it's possible that doing the doubling | ||
127 | + * would take the intermediate result below INT64_MAX and the | ||
128 | + * addition of the rounding constant then brings it back in range. | ||
129 | + * So we add half the rounding constant before doubling rather | ||
130 | + * than adding the rounding constant after the doubling. | ||
131 | + */ | ||
132 | + if (sadd64_overflow(m1, m2, &r) || | ||
133 | + sadd64_overflow(r, (round << 30), &r) || | ||
134 | + sadd64_overflow(r, r, &r)) { | ||
135 | + *sat = true; | ||
136 | + return r < 0 ? INT32_MAX : INT32_MIN; | ||
137 | + } | ||
138 | + return r >> 32; | ||
139 | +} | ||
140 | + | ||
141 | +DO_VQDMLADH_OP(vqdmladhb, 1, int8_t, 0, 0, do_vqdmladh_b) | ||
142 | +DO_VQDMLADH_OP(vqdmladhh, 2, int16_t, 0, 0, do_vqdmladh_h) | ||
143 | +DO_VQDMLADH_OP(vqdmladhw, 4, int32_t, 0, 0, do_vqdmladh_w) | ||
144 | +DO_VQDMLADH_OP(vqdmladhxb, 1, int8_t, 1, 0, do_vqdmladh_b) | ||
145 | +DO_VQDMLADH_OP(vqdmladhxh, 2, int16_t, 1, 0, do_vqdmladh_h) | ||
146 | +DO_VQDMLADH_OP(vqdmladhxw, 4, int32_t, 1, 0, do_vqdmladh_w) | ||
147 | + | ||
148 | +DO_VQDMLADH_OP(vqrdmladhb, 1, int8_t, 0, 1, do_vqdmladh_b) | ||
149 | +DO_VQDMLADH_OP(vqrdmladhh, 2, int16_t, 0, 1, do_vqdmladh_h) | ||
150 | +DO_VQDMLADH_OP(vqrdmladhw, 4, int32_t, 0, 1, do_vqdmladh_w) | ||
151 | +DO_VQDMLADH_OP(vqrdmladhxb, 1, int8_t, 1, 1, do_vqdmladh_b) | ||
152 | +DO_VQDMLADH_OP(vqrdmladhxh, 2, int16_t, 1, 1, do_vqdmladh_h) | ||
153 | +DO_VQDMLADH_OP(vqrdmladhxw, 4, int32_t, 1, 1, do_vqdmladh_w) | ||
154 | + | ||
155 | #define DO_2OP_SCALAR(OP, ESIZE, TYPE, FN) \ | ||
156 | void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, \ | ||
157 | uint32_t rm) \ | ||
158 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
159 | index XXXXXXX..XXXXXXX 100644 | ||
160 | --- a/target/arm/translate-mve.c | ||
161 | +++ b/target/arm/translate-mve.c | ||
162 | @@ -XXX,XX +XXX,XX @@ DO_2OP(VQSHL_S, vqshls) | ||
163 | DO_2OP(VQSHL_U, vqshlu) | ||
164 | DO_2OP(VQRSHL_S, vqrshls) | ||
165 | DO_2OP(VQRSHL_U, vqrshlu) | ||
166 | +DO_2OP(VQDMLADH, vqdmladh) | ||
167 | +DO_2OP(VQDMLADHX, vqdmladhx) | ||
168 | +DO_2OP(VQRDMLADH, vqrdmladh) | ||
169 | +DO_2OP(VQRDMLADHX, vqrdmladhx) | ||
170 | |||
171 | static bool do_2op_scalar(DisasContext *s, arg_2scalar *a, | ||
172 | MVEGenTwoOpScalarFn fn) | ||
173 | -- | 37 | -- |
174 | 2.20.1 | 38 | 2.34.1 |
175 | 39 | ||
176 | 40 | diff view generated by jsdifflib |
1 | Implement the MVE VQSHL insn (encoding T4, which is the | 1 | From: Claudio Fontana <cfontana@suse.de> |
---|---|---|---|
2 | vector-shift-by-vector version). | ||
3 | 2 | ||
4 | The DO_SQSHL_OP and DO_UQSHL_OP macros here are derived from | 3 | for "all" builds (tcg + kvm), we want to avoid doing |
5 | the neon_helper.c code for qshl_u{8,16,32} and qshl_s{8,16,32}. | 4 | the psci check if tcg is built-in, but not enabled. |
6 | 5 | ||
6 | Signed-off-by: Claudio Fontana <cfontana@suse.de> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Signed-off-by: Fabiano Rosas <farosas@suse.de> | ||
9 | Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20210617121628.20116-33-peter.maydell@linaro.org | ||
10 | --- | 11 | --- |
11 | target/arm/helper-mve.h | 8 ++++++++ | 12 | target/arm/helper.c | 3 ++- |
12 | target/arm/mve.decode | 12 ++++++++++++ | 13 | 1 file changed, 2 insertions(+), 1 deletion(-) |
13 | target/arm/mve_helper.c | 34 ++++++++++++++++++++++++++++++++++ | ||
14 | target/arm/translate-mve.c | 2 ++ | ||
15 | 4 files changed, 56 insertions(+) | ||
16 | 14 | ||
17 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 15 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
18 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/helper-mve.h | 17 | --- a/target/arm/helper.c |
20 | +++ b/target/arm/helper-mve.h | 18 | +++ b/target/arm/helper.c |
21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqsubub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
22 | DEF_HELPER_FLAGS_4(mve_vqsubuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
23 | DEF_HELPER_FLAGS_4(mve_vqsubuw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
24 | |||
25 | +DEF_HELPER_FLAGS_4(mve_vqshlsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
26 | +DEF_HELPER_FLAGS_4(mve_vqshlsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
27 | +DEF_HELPER_FLAGS_4(mve_vqshlsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
28 | + | ||
29 | +DEF_HELPER_FLAGS_4(mve_vqshlub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
30 | +DEF_HELPER_FLAGS_4(mve_vqshluh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
31 | +DEF_HELPER_FLAGS_4(mve_vqshluw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
32 | + | ||
33 | DEF_HELPER_FLAGS_4(mve_vadd_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
34 | DEF_HELPER_FLAGS_4(mve_vadd_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
35 | DEF_HELPER_FLAGS_4(mve_vadd_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
36 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/target/arm/mve.decode | ||
39 | +++ b/target/arm/mve.decode | ||
40 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ |
41 | @2op .... .... .. size:2 .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn | 20 | #include "hw/irq.h" |
42 | @2op_nosz .... .... .... .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn size=0 | 21 | #include "sysemu/cpu-timers.h" |
43 | 22 | #include "sysemu/kvm.h" | |
44 | +# The _rev suffix indicates that Vn and Vm are reversed. This is | 23 | +#include "sysemu/tcg.h" |
45 | +# the case for shifts. In the Arm ARM these insns are documented | 24 | #include "qapi/qapi-commands-machine-target.h" |
46 | +# with the Vm and Vn fields in their usual places, but in the | 25 | #include "qapi/error.h" |
47 | +# assembly the operands are listed "backwards", ie in the order | 26 | #include "qemu/guest-random.h" |
48 | +# Qd, Qm, Qn where other insns use Qd, Qn, Qm. For QEMU we choose | 27 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_do_interrupt(CPUState *cs) |
49 | +# to consider Vm and Vn as being in different fields in the insn. | 28 | env->exception.syndrome); |
50 | +# This gives us consistency with A64 and Neon. | ||
51 | +@2op_rev .... .... .. size:2 .... .... .... .... .... &2op qd=%qd qm=%qn qn=%qm | ||
52 | + | ||
53 | @2scalar .... .... .. size:2 .... .... .... .... rm:4 &2scalar qd=%qd qn=%qn | ||
54 | @2scalar_nosz .... .... .... .... .... .... .... rm:4 &2scalar qd=%qd qn=%qn | ||
55 | |||
56 | @@ -XXX,XX +XXX,XX @@ VQADD_U 111 1 1111 0 . .. ... 0 ... 0 0000 . 1 . 1 ... 0 @2op | ||
57 | VQSUB_S 111 0 1111 0 . .. ... 0 ... 0 0010 . 1 . 1 ... 0 @2op | ||
58 | VQSUB_U 111 1 1111 0 . .. ... 0 ... 0 0010 . 1 . 1 ... 0 @2op | ||
59 | |||
60 | +VQSHL_S 111 0 1111 0 . .. ... 0 ... 0 0100 . 1 . 1 ... 0 @2op_rev | ||
61 | +VQSHL_U 111 1 1111 0 . .. ... 0 ... 0 0100 . 1 . 1 ... 0 @2op_rev | ||
62 | + | ||
63 | # Vector miscellaneous | ||
64 | |||
65 | VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op | ||
66 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/target/arm/mve_helper.c | ||
69 | +++ b/target/arm/mve_helper.c | ||
70 | @@ -XXX,XX +XXX,XX @@ DO_1OP(vfnegs, 8, uint64_t, DO_FNEGS) | ||
71 | mve_advance_vpt(env); \ | ||
72 | } | 29 | } |
73 | 30 | ||
74 | +/* provide unsigned 2-op helpers for all sizes */ | 31 | - if (arm_is_psci_call(cpu, cs->exception_index)) { |
75 | +#define DO_2OP_SAT_U(OP, FN) \ | 32 | + if (tcg_enabled() && arm_is_psci_call(cpu, cs->exception_index)) { |
76 | + DO_2OP_SAT(OP##b, 1, uint8_t, FN) \ | 33 | arm_handle_psci_call(cpu); |
77 | + DO_2OP_SAT(OP##h, 2, uint16_t, FN) \ | 34 | qemu_log_mask(CPU_LOG_INT, "...handled as PSCI call\n"); |
78 | + DO_2OP_SAT(OP##w, 4, uint32_t, FN) | 35 | return; |
79 | + | ||
80 | +/* provide signed 2-op helpers for all sizes */ | ||
81 | +#define DO_2OP_SAT_S(OP, FN) \ | ||
82 | + DO_2OP_SAT(OP##b, 1, int8_t, FN) \ | ||
83 | + DO_2OP_SAT(OP##h, 2, int16_t, FN) \ | ||
84 | + DO_2OP_SAT(OP##w, 4, int32_t, FN) | ||
85 | + | ||
86 | #define DO_AND(N, M) ((N) & (M)) | ||
87 | #define DO_BIC(N, M) ((N) & ~(M)) | ||
88 | #define DO_ORR(N, M) ((N) | (M)) | ||
89 | @@ -XXX,XX +XXX,XX @@ DO_2OP_SAT(vqsubsb, 1, int8_t, DO_SQSUB_B) | ||
90 | DO_2OP_SAT(vqsubsh, 2, int16_t, DO_SQSUB_H) | ||
91 | DO_2OP_SAT(vqsubsw, 4, int32_t, DO_SQSUB_W) | ||
92 | |||
93 | +/* | ||
94 | + * This wrapper fixes up the impedance mismatch between do_sqrshl_bhs() | ||
95 | + * and friends wanting a uint32_t* sat and our needing a bool*. | ||
96 | + */ | ||
97 | +#define WRAP_QRSHL_HELPER(FN, N, M, ROUND, satp) \ | ||
98 | + ({ \ | ||
99 | + uint32_t su32 = 0; \ | ||
100 | + typeof(N) r = FN(N, (int8_t)(M), sizeof(N) * 8, ROUND, &su32); \ | ||
101 | + if (su32) { \ | ||
102 | + *satp = true; \ | ||
103 | + } \ | ||
104 | + r; \ | ||
105 | + }) | ||
106 | + | ||
107 | +#define DO_SQSHL_OP(N, M, satp) \ | ||
108 | + WRAP_QRSHL_HELPER(do_sqrshl_bhs, N, M, false, satp) | ||
109 | +#define DO_UQSHL_OP(N, M, satp) \ | ||
110 | + WRAP_QRSHL_HELPER(do_uqrshl_bhs, N, M, false, satp) | ||
111 | + | ||
112 | +DO_2OP_SAT_S(vqshls, DO_SQSHL_OP) | ||
113 | +DO_2OP_SAT_U(vqshlu, DO_UQSHL_OP) | ||
114 | + | ||
115 | #define DO_2OP_SCALAR(OP, ESIZE, TYPE, FN) \ | ||
116 | void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, \ | ||
117 | uint32_t rm) \ | ||
118 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
119 | index XXXXXXX..XXXXXXX 100644 | ||
120 | --- a/target/arm/translate-mve.c | ||
121 | +++ b/target/arm/translate-mve.c | ||
122 | @@ -XXX,XX +XXX,XX @@ DO_2OP(VQADD_S, vqadds) | ||
123 | DO_2OP(VQADD_U, vqaddu) | ||
124 | DO_2OP(VQSUB_S, vqsubs) | ||
125 | DO_2OP(VQSUB_U, vqsubu) | ||
126 | +DO_2OP(VQSHL_S, vqshls) | ||
127 | +DO_2OP(VQSHL_U, vqshlu) | ||
128 | |||
129 | static bool do_2op_scalar(DisasContext *s, arg_2scalar *a, | ||
130 | MVEGenTwoOpScalarFn fn) | ||
131 | -- | 36 | -- |
132 | 2.20.1 | 37 | 2.34.1 |
133 | 38 | ||
134 | 39 | diff view generated by jsdifflib |
1 | Implement the MVE VRSHL insn (vector form). | 1 | From: Claudio Fontana <cfontana@suse.de> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Claudio Fontana <cfontana@suse.de> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Signed-off-by: Fabiano Rosas <farosas@suse.de> | ||
6 | Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20210617121628.20116-36-peter.maydell@linaro.org | ||
6 | --- | 8 | --- |
7 | target/arm/helper-mve.h | 8 ++++++++ | 9 | target/arm/helper.c | 12 +++++++----- |
8 | target/arm/mve.decode | 3 +++ | 10 | 1 file changed, 7 insertions(+), 5 deletions(-) |
9 | target/arm/mve_helper.c | 4 ++++ | ||
10 | target/arm/translate-mve.c | 2 ++ | ||
11 | 4 files changed, 17 insertions(+) | ||
12 | 11 | ||
13 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 12 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
14 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/helper-mve.h | 14 | --- a/target/arm/helper.c |
16 | +++ b/target/arm/helper-mve.h | 15 | +++ b/target/arm/helper.c |
17 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vshlub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 16 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) |
18 | DEF_HELPER_FLAGS_4(mve_vshluh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 17 | unsigned int cur_el = arm_current_el(env); |
19 | DEF_HELPER_FLAGS_4(mve_vshluw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 18 | int rt; |
20 | 19 | ||
21 | +DEF_HELPER_FLAGS_4(mve_vrshlsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 20 | - /* |
22 | +DEF_HELPER_FLAGS_4(mve_vrshlsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 21 | - * Note that new_el can never be 0. If cur_el is 0, then |
23 | +DEF_HELPER_FLAGS_4(mve_vrshlsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 22 | - * el0_a64 is is_a64(), else el0_a64 is ignored. |
24 | + | 23 | - */ |
25 | +DEF_HELPER_FLAGS_4(mve_vrshlub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 24 | - aarch64_sve_change_el(env, cur_el, new_el, is_a64(env)); |
26 | +DEF_HELPER_FLAGS_4(mve_vrshluh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 25 | + if (tcg_enabled()) { |
27 | +DEF_HELPER_FLAGS_4(mve_vrshluw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 26 | + /* |
28 | + | 27 | + * Note that new_el can never be 0. If cur_el is 0, then |
29 | DEF_HELPER_FLAGS_4(mve_vqshlsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 28 | + * el0_a64 is is_a64(), else el0_a64 is ignored. |
30 | DEF_HELPER_FLAGS_4(mve_vqshlsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 29 | + */ |
31 | DEF_HELPER_FLAGS_4(mve_vqshlsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 30 | + aarch64_sve_change_el(env, cur_el, new_el, is_a64(env)); |
32 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | 31 | + } |
33 | index XXXXXXX..XXXXXXX 100644 | 32 | |
34 | --- a/target/arm/mve.decode | 33 | if (cur_el < new_el) { |
35 | +++ b/target/arm/mve.decode | 34 | /* |
36 | @@ -XXX,XX +XXX,XX @@ VQSUB_U 111 1 1111 0 . .. ... 0 ... 0 0010 . 1 . 1 ... 0 @2op | ||
37 | VSHL_S 111 0 1111 0 . .. ... 0 ... 0 0100 . 1 . 0 ... 0 @2op_rev | ||
38 | VSHL_U 111 1 1111 0 . .. ... 0 ... 0 0100 . 1 . 0 ... 0 @2op_rev | ||
39 | |||
40 | +VRSHL_S 111 0 1111 0 . .. ... 0 ... 0 0101 . 1 . 0 ... 0 @2op_rev | ||
41 | +VRSHL_U 111 1 1111 0 . .. ... 0 ... 0 0101 . 1 . 0 ... 0 @2op_rev | ||
42 | + | ||
43 | VQSHL_S 111 0 1111 0 . .. ... 0 ... 0 0100 . 1 . 1 ... 0 @2op_rev | ||
44 | VQSHL_U 111 1 1111 0 . .. ... 0 ... 0 0100 . 1 . 1 ... 0 @2op_rev | ||
45 | |||
46 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/target/arm/mve_helper.c | ||
49 | +++ b/target/arm/mve_helper.c | ||
50 | @@ -XXX,XX +XXX,XX @@ DO_2OP_U(vhsubu, do_vhsub_u) | ||
51 | |||
52 | #define DO_VSHLS(N, M) do_sqrshl_bhs(N, (int8_t)(M), sizeof(N) * 8, false, NULL) | ||
53 | #define DO_VSHLU(N, M) do_uqrshl_bhs(N, (int8_t)(M), sizeof(N) * 8, false, NULL) | ||
54 | +#define DO_VRSHLS(N, M) do_sqrshl_bhs(N, (int8_t)(M), sizeof(N) * 8, true, NULL) | ||
55 | +#define DO_VRSHLU(N, M) do_uqrshl_bhs(N, (int8_t)(M), sizeof(N) * 8, true, NULL) | ||
56 | |||
57 | DO_2OP_S(vshls, DO_VSHLS) | ||
58 | DO_2OP_U(vshlu, DO_VSHLU) | ||
59 | +DO_2OP_S(vrshls, DO_VRSHLS) | ||
60 | +DO_2OP_U(vrshlu, DO_VRSHLU) | ||
61 | |||
62 | static inline int32_t do_sat_bhw(int64_t val, int64_t min, int64_t max, bool *s) | ||
63 | { | ||
64 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
65 | index XXXXXXX..XXXXXXX 100644 | ||
66 | --- a/target/arm/translate-mve.c | ||
67 | +++ b/target/arm/translate-mve.c | ||
68 | @@ -XXX,XX +XXX,XX @@ DO_2OP(VQSUB_S, vqsubs) | ||
69 | DO_2OP(VQSUB_U, vqsubu) | ||
70 | DO_2OP(VSHL_S, vshls) | ||
71 | DO_2OP(VSHL_U, vshlu) | ||
72 | +DO_2OP(VRSHL_S, vrshls) | ||
73 | +DO_2OP(VRSHL_U, vrshlu) | ||
74 | DO_2OP(VQSHL_S, vqshls) | ||
75 | DO_2OP(VQSHL_U, vqshlu) | ||
76 | DO_2OP(VQRSHL_S, vqrshls) | ||
77 | -- | 35 | -- |
78 | 2.20.1 | 36 | 2.34.1 |
79 | 37 | ||
80 | 38 | diff view generated by jsdifflib |
1 | Implement the vector forms of the MVE VQDMULH and VQRDMULH insns. | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | 2 | ||
3 | Move this earlier to make the next patch diff cleaner. While here | ||
4 | update the comment slightly to not give the impression that the | ||
5 | misalignment affects only TCG. | ||
6 | |||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
9 | Signed-off-by: Fabiano Rosas <farosas@suse.de> | ||
10 | Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20210617121628.20116-31-peter.maydell@linaro.org | ||
6 | --- | 12 | --- |
7 | target/arm/helper-mve.h | 8 ++++++++ | 13 | target/arm/machine.c | 18 +++++++++--------- |
8 | target/arm/mve.decode | 3 +++ | 14 | 1 file changed, 9 insertions(+), 9 deletions(-) |
9 | target/arm/mve_helper.c | 27 +++++++++++++++++++++++++++ | ||
10 | target/arm/translate-mve.c | 2 ++ | ||
11 | 4 files changed, 40 insertions(+) | ||
12 | 15 | ||
13 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 16 | diff --git a/target/arm/machine.c b/target/arm/machine.c |
14 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/helper-mve.h | 18 | --- a/target/arm/machine.c |
16 | +++ b/target/arm/helper-mve.h | 19 | +++ b/target/arm/machine.c |
17 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vmulltub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 20 | @@ -XXX,XX +XXX,XX @@ static int cpu_post_load(void *opaque, int version_id) |
18 | DEF_HELPER_FLAGS_4(mve_vmulltuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 21 | } |
19 | DEF_HELPER_FLAGS_4(mve_vmulltuw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
20 | |||
21 | +DEF_HELPER_FLAGS_4(mve_vqdmulhb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
22 | +DEF_HELPER_FLAGS_4(mve_vqdmulhh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
23 | +DEF_HELPER_FLAGS_4(mve_vqdmulhw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
24 | + | ||
25 | +DEF_HELPER_FLAGS_4(mve_vqrdmulhb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
26 | +DEF_HELPER_FLAGS_4(mve_vqrdmulhh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
27 | +DEF_HELPER_FLAGS_4(mve_vqrdmulhw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
28 | + | ||
29 | DEF_HELPER_FLAGS_4(mve_vadd_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
30 | DEF_HELPER_FLAGS_4(mve_vadd_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
31 | DEF_HELPER_FLAGS_4(mve_vadd_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
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 @@ VMULL_BU 111 1 1110 0 . .. ... 1 ... 0 1110 . 0 . 0 ... 0 @2op | ||
37 | VMULL_TS 111 0 1110 0 . .. ... 1 ... 1 1110 . 0 . 0 ... 0 @2op | ||
38 | VMULL_TU 111 1 1110 0 . .. ... 1 ... 1 1110 . 0 . 0 ... 0 @2op | ||
39 | |||
40 | +VQDMULH 1110 1111 0 . .. ... 0 ... 0 1011 . 1 . 0 ... 0 @2op | ||
41 | +VQRDMULH 1111 1111 0 . .. ... 0 ... 0 1011 . 1 . 0 ... 0 @2op | ||
42 | + | ||
43 | # Vector miscellaneous | ||
44 | |||
45 | VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op | ||
46 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/target/arm/mve_helper.c | ||
49 | +++ b/target/arm/mve_helper.c | ||
50 | @@ -XXX,XX +XXX,XX @@ DO_1OP(vfnegs, 8, uint64_t, DO_FNEGS) | ||
51 | mve_advance_vpt(env); \ | ||
52 | } | 22 | } |
53 | 23 | ||
54 | +#define DO_2OP_SAT(OP, ESIZE, TYPE, FN) \ | 24 | + /* |
55 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, void *vm) \ | 25 | + * Misaligned thumb pc is architecturally impossible. Fail the |
56 | + { \ | 26 | + * incoming migration. For TCG it would trigger the assert in |
57 | + TYPE *d = vd, *n = vn, *m = vm; \ | 27 | + * thumb_tr_translate_insn(). |
58 | + uint16_t mask = mve_element_mask(env); \ | 28 | + */ |
59 | + unsigned e; \ | 29 | + if (!is_a64(env) && env->thumb && (env->regs[15] & 1)) { |
60 | + bool qc = false; \ | 30 | + return -1; |
61 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
62 | + bool sat = false; \ | ||
63 | + TYPE r = FN(n[H##ESIZE(e)], m[H##ESIZE(e)], &sat); \ | ||
64 | + mergemask(&d[H##ESIZE(e)], r, mask); \ | ||
65 | + qc |= sat & mask & 1; \ | ||
66 | + } \ | ||
67 | + if (qc) { \ | ||
68 | + env->vfp.qc[0] = qc; \ | ||
69 | + } \ | ||
70 | + mve_advance_vpt(env); \ | ||
71 | + } | 31 | + } |
72 | + | 32 | + |
73 | #define DO_AND(N, M) ((N) & (M)) | 33 | hw_breakpoint_update_all(cpu); |
74 | #define DO_BIC(N, M) ((N) & ~(M)) | 34 | hw_watchpoint_update_all(cpu); |
75 | #define DO_ORR(N, M) ((N) | (M)) | 35 | |
76 | @@ -XXX,XX +XXX,XX @@ static inline int32_t do_sat_bhw(int64_t val, int64_t min, int64_t max, bool *s) | 36 | @@ -XXX,XX +XXX,XX @@ static int cpu_post_load(void *opaque, int version_id) |
77 | #define DO_QRDMULH_W(n, m, s) do_sat_bhw(((int64_t)n * m + (1 << 30)) >> 31, \ | 37 | } |
78 | INT32_MIN, INT32_MAX, s) | 38 | } |
79 | 39 | ||
80 | +DO_2OP_SAT(vqdmulhb, 1, int8_t, DO_QDMULH_B) | 40 | - /* |
81 | +DO_2OP_SAT(vqdmulhh, 2, int16_t, DO_QDMULH_H) | 41 | - * Misaligned thumb pc is architecturally impossible. |
82 | +DO_2OP_SAT(vqdmulhw, 4, int32_t, DO_QDMULH_W) | 42 | - * We have an assert in thumb_tr_translate_insn to verify this. |
83 | + | 43 | - * Fail an incoming migrate to avoid this assert. |
84 | +DO_2OP_SAT(vqrdmulhb, 1, int8_t, DO_QRDMULH_B) | 44 | - */ |
85 | +DO_2OP_SAT(vqrdmulhh, 2, int16_t, DO_QRDMULH_H) | 45 | - if (!is_a64(env) && env->thumb && (env->regs[15] & 1)) { |
86 | +DO_2OP_SAT(vqrdmulhw, 4, int32_t, DO_QRDMULH_W) | 46 | - return -1; |
87 | + | 47 | - } |
88 | #define DO_2OP_SCALAR(OP, ESIZE, TYPE, FN) \ | 48 | - |
89 | void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, \ | 49 | if (!kvm_enabled()) { |
90 | uint32_t rm) \ | 50 | pmu_op_finish(&cpu->env); |
91 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | 51 | } |
92 | index XXXXXXX..XXXXXXX 100644 | ||
93 | --- a/target/arm/translate-mve.c | ||
94 | +++ b/target/arm/translate-mve.c | ||
95 | @@ -XXX,XX +XXX,XX @@ DO_2OP(VMULL_BS, vmullbs) | ||
96 | DO_2OP(VMULL_BU, vmullbu) | ||
97 | DO_2OP(VMULL_TS, vmullts) | ||
98 | DO_2OP(VMULL_TU, vmulltu) | ||
99 | +DO_2OP(VQDMULH, vqdmulh) | ||
100 | +DO_2OP(VQRDMULH, vqrdmulh) | ||
101 | |||
102 | static bool do_2op_scalar(DisasContext *s, arg_2scalar *a, | ||
103 | MVEGenTwoOpScalarFn fn) | ||
104 | -- | 52 | -- |
105 | 2.20.1 | 53 | 2.34.1 |
106 | 54 | ||
107 | 55 | diff view generated by jsdifflib |
1 | Factor the code in full_vfp_access_check() which updates the | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | ownership of the FP context and creates a new FP context | 2 | |
3 | out into its own function. | 3 | Since commit cf7c6d1004 ("target/arm: Split out cpregs.h") we now have |
4 | 4 | a cpregs.h header which is more suitable for this code. | |
5 | |||
6 | Code moved verbatim. | ||
7 | |||
8 | Signed-off-by: Fabiano Rosas <farosas@suse.de> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
11 | Tested-by: Philippe Mathieu-Daudé <philmd@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 | Message-id: 20210618141019.10671-6-peter.maydell@linaro.org | ||
8 | --- | 13 | --- |
9 | target/arm/translate-vfp.c | 104 +++++++++++++++++++++---------------- | 14 | target/arm/cpregs.h | 98 +++++++++++++++++++++++++++++++++++++++++++++ |
10 | 1 file changed, 58 insertions(+), 46 deletions(-) | 15 | target/arm/cpu.h | 91 ----------------------------------------- |
11 | 16 | 2 files changed, 98 insertions(+), 91 deletions(-) | |
12 | diff --git a/target/arm/translate-vfp.c b/target/arm/translate-vfp.c | 17 | |
18 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h | ||
13 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/target/arm/translate-vfp.c | 20 | --- a/target/arm/cpregs.h |
15 | +++ b/target/arm/translate-vfp.c | 21 | +++ b/target/arm/cpregs.h |
16 | @@ -XXX,XX +XXX,XX @@ void gen_preserve_fp_state(DisasContext *s) | 22 | @@ -XXX,XX +XXX,XX @@ enum { |
17 | } | 23 | ARM_CP_SME = 1 << 19, |
18 | } | 24 | }; |
19 | 25 | ||
20 | +/* | 26 | +/* |
21 | + * Generate code for M-profile FP context handling: update the | 27 | + * Interface for defining coprocessor registers. |
22 | + * ownership of the FP context, and create a new context if | 28 | + * Registers are defined in tables of arm_cp_reginfo structs |
23 | + * necessary. This corresponds to the parts of the pseudocode | 29 | + * which are passed to define_arm_cp_regs(). |
24 | + * ExecuteFPCheck() after the inital PreserveFPState() call. | 30 | + */ |
25 | + */ | 31 | + |
26 | +static void gen_update_fp_context(DisasContext *s) | 32 | +/* |
33 | + * When looking up a coprocessor register we look for it | ||
34 | + * via an integer which encodes all of: | ||
35 | + * coprocessor number | ||
36 | + * Crn, Crm, opc1, opc2 fields | ||
37 | + * 32 or 64 bit register (ie is it accessed via MRC/MCR | ||
38 | + * or via MRRC/MCRR?) | ||
39 | + * non-secure/secure bank (AArch32 only) | ||
40 | + * We allow 4 bits for opc1 because MRRC/MCRR have a 4 bit field. | ||
41 | + * (In this case crn and opc2 should be zero.) | ||
42 | + * For AArch64, there is no 32/64 bit size distinction; | ||
43 | + * instead all registers have a 2 bit op0, 3 bit op1 and op2, | ||
44 | + * and 4 bit CRn and CRm. The encoding patterns are chosen | ||
45 | + * to be easy to convert to and from the KVM encodings, and also | ||
46 | + * so that the hashtable can contain both AArch32 and AArch64 | ||
47 | + * registers (to allow for interprocessing where we might run | ||
48 | + * 32 bit code on a 64 bit core). | ||
49 | + */ | ||
50 | +/* | ||
51 | + * This bit is private to our hashtable cpreg; in KVM register | ||
52 | + * IDs the AArch64/32 distinction is the KVM_REG_ARM/ARM64 | ||
53 | + * in the upper bits of the 64 bit ID. | ||
54 | + */ | ||
55 | +#define CP_REG_AA64_SHIFT 28 | ||
56 | +#define CP_REG_AA64_MASK (1 << CP_REG_AA64_SHIFT) | ||
57 | + | ||
58 | +/* | ||
59 | + * To enable banking of coprocessor registers depending on ns-bit we | ||
60 | + * add a bit to distinguish between secure and non-secure cpregs in the | ||
61 | + * hashtable. | ||
62 | + */ | ||
63 | +#define CP_REG_NS_SHIFT 29 | ||
64 | +#define CP_REG_NS_MASK (1 << CP_REG_NS_SHIFT) | ||
65 | + | ||
66 | +#define ENCODE_CP_REG(cp, is64, ns, crn, crm, opc1, opc2) \ | ||
67 | + ((ns) << CP_REG_NS_SHIFT | ((cp) << 16) | ((is64) << 15) | \ | ||
68 | + ((crn) << 11) | ((crm) << 7) | ((opc1) << 3) | (opc2)) | ||
69 | + | ||
70 | +#define ENCODE_AA64_CP_REG(cp, crn, crm, op0, op1, op2) \ | ||
71 | + (CP_REG_AA64_MASK | \ | ||
72 | + ((cp) << CP_REG_ARM_COPROC_SHIFT) | \ | ||
73 | + ((op0) << CP_REG_ARM64_SYSREG_OP0_SHIFT) | \ | ||
74 | + ((op1) << CP_REG_ARM64_SYSREG_OP1_SHIFT) | \ | ||
75 | + ((crn) << CP_REG_ARM64_SYSREG_CRN_SHIFT) | \ | ||
76 | + ((crm) << CP_REG_ARM64_SYSREG_CRM_SHIFT) | \ | ||
77 | + ((op2) << CP_REG_ARM64_SYSREG_OP2_SHIFT)) | ||
78 | + | ||
79 | +/* | ||
80 | + * Convert a full 64 bit KVM register ID to the truncated 32 bit | ||
81 | + * version used as a key for the coprocessor register hashtable | ||
82 | + */ | ||
83 | +static inline uint32_t kvm_to_cpreg_id(uint64_t kvmid) | ||
27 | +{ | 84 | +{ |
28 | + /* Update ownership of FP context: set FPCCR.S to match current state */ | 85 | + uint32_t cpregid = kvmid; |
29 | + if (s->v8m_fpccr_s_wrong) { | 86 | + if ((kvmid & CP_REG_ARCH_MASK) == CP_REG_ARM64) { |
30 | + TCGv_i32 tmp; | 87 | + cpregid |= CP_REG_AA64_MASK; |
31 | + | 88 | + } else { |
32 | + tmp = load_cpu_field(v7m.fpccr[M_REG_S]); | 89 | + if ((kvmid & CP_REG_SIZE_MASK) == CP_REG_SIZE_U64) { |
33 | + if (s->v8m_secure) { | 90 | + cpregid |= (1 << 15); |
34 | + tcg_gen_ori_i32(tmp, tmp, R_V7M_FPCCR_S_MASK); | 91 | + } |
92 | + | ||
93 | + /* | ||
94 | + * KVM is always non-secure so add the NS flag on AArch32 register | ||
95 | + * entries. | ||
96 | + */ | ||
97 | + cpregid |= 1 << CP_REG_NS_SHIFT; | ||
98 | + } | ||
99 | + return cpregid; | ||
100 | +} | ||
101 | + | ||
102 | +/* | ||
103 | + * Convert a truncated 32 bit hashtable key into the full | ||
104 | + * 64 bit KVM register ID. | ||
105 | + */ | ||
106 | +static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid) | ||
107 | +{ | ||
108 | + uint64_t kvmid; | ||
109 | + | ||
110 | + if (cpregid & CP_REG_AA64_MASK) { | ||
111 | + kvmid = cpregid & ~CP_REG_AA64_MASK; | ||
112 | + kvmid |= CP_REG_SIZE_U64 | CP_REG_ARM64; | ||
113 | + } else { | ||
114 | + kvmid = cpregid & ~(1 << 15); | ||
115 | + if (cpregid & (1 << 15)) { | ||
116 | + kvmid |= CP_REG_SIZE_U64 | CP_REG_ARM; | ||
35 | + } else { | 117 | + } else { |
36 | + tcg_gen_andi_i32(tmp, tmp, ~R_V7M_FPCCR_S_MASK); | 118 | + kvmid |= CP_REG_SIZE_U32 | CP_REG_ARM; |
37 | + } | 119 | + } |
38 | + store_cpu_field(tmp, v7m.fpccr[M_REG_S]); | ||
39 | + /* Don't need to do this for any further FP insns in this TB */ | ||
40 | + s->v8m_fpccr_s_wrong = false; | ||
41 | + } | 120 | + } |
42 | + | 121 | + return kvmid; |
43 | + if (s->v7m_new_fp_ctxt_needed) { | ||
44 | + /* | ||
45 | + * Create new FP context by updating CONTROL.FPCA, CONTROL.SFPA, | ||
46 | + * the FPSCR, and VPR. | ||
47 | + */ | ||
48 | + TCGv_i32 control, fpscr; | ||
49 | + uint32_t bits = R_V7M_CONTROL_FPCA_MASK; | ||
50 | + | ||
51 | + fpscr = load_cpu_field(v7m.fpdscr[s->v8m_secure]); | ||
52 | + gen_helper_vfp_set_fpscr(cpu_env, fpscr); | ||
53 | + tcg_temp_free_i32(fpscr); | ||
54 | + if (dc_isar_feature(aa32_mve, s)) { | ||
55 | + TCGv_i32 z32 = tcg_const_i32(0); | ||
56 | + store_cpu_field(z32, v7m.vpr); | ||
57 | + } | ||
58 | + | ||
59 | + /* | ||
60 | + * We don't need to arrange to end the TB, because the only | ||
61 | + * parts of FPSCR which we cache in the TB flags are the VECLEN | ||
62 | + * and VECSTRIDE, and those don't exist for M-profile. | ||
63 | + */ | ||
64 | + | ||
65 | + if (s->v8m_secure) { | ||
66 | + bits |= R_V7M_CONTROL_SFPA_MASK; | ||
67 | + } | ||
68 | + control = load_cpu_field(v7m.control[M_REG_S]); | ||
69 | + tcg_gen_ori_i32(control, control, bits); | ||
70 | + store_cpu_field(control, v7m.control[M_REG_S]); | ||
71 | + /* Don't need to do this for any further FP insns in this TB */ | ||
72 | + s->v7m_new_fp_ctxt_needed = false; | ||
73 | + } | ||
74 | +} | 122 | +} |
75 | + | 123 | + |
76 | /* | 124 | /* |
77 | * Check that VFP access is enabled. If it is, do the necessary | 125 | * Valid values for ARMCPRegInfo state field, indicating which of |
78 | * M-profile lazy-FP handling and then return true. | 126 | * the AArch32 and AArch64 execution states this register is visible in. |
79 | @@ -XXX,XX +XXX,XX @@ static bool full_vfp_access_check(DisasContext *s, bool ignore_vfp_enabled) | 127 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
80 | /* Trigger lazy-state preservation if necessary */ | 128 | index XXXXXXX..XXXXXXX 100644 |
81 | gen_preserve_fp_state(s); | 129 | --- a/target/arm/cpu.h |
82 | 130 | +++ b/target/arm/cpu.h | |
83 | - /* Update ownership of FP context: set FPCCR.S to match current state */ | 131 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_list(void); |
84 | - if (s->v8m_fpccr_s_wrong) { | 132 | uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx, |
85 | - TCGv_i32 tmp; | 133 | uint32_t cur_el, bool secure); |
86 | - | 134 | |
87 | - tmp = load_cpu_field(v7m.fpccr[M_REG_S]); | 135 | -/* Interface for defining coprocessor registers. |
88 | - if (s->v8m_secure) { | 136 | - * Registers are defined in tables of arm_cp_reginfo structs |
89 | - tcg_gen_ori_i32(tmp, tmp, R_V7M_FPCCR_S_MASK); | 137 | - * which are passed to define_arm_cp_regs(). |
90 | - } else { | 138 | - */ |
91 | - tcg_gen_andi_i32(tmp, tmp, ~R_V7M_FPCCR_S_MASK); | 139 | - |
92 | - } | 140 | -/* When looking up a coprocessor register we look for it |
93 | - store_cpu_field(tmp, v7m.fpccr[M_REG_S]); | 141 | - * via an integer which encodes all of: |
94 | - /* Don't need to do this for any further FP insns in this TB */ | 142 | - * coprocessor number |
95 | - s->v8m_fpccr_s_wrong = false; | 143 | - * Crn, Crm, opc1, opc2 fields |
144 | - * 32 or 64 bit register (ie is it accessed via MRC/MCR | ||
145 | - * or via MRRC/MCRR?) | ||
146 | - * non-secure/secure bank (AArch32 only) | ||
147 | - * We allow 4 bits for opc1 because MRRC/MCRR have a 4 bit field. | ||
148 | - * (In this case crn and opc2 should be zero.) | ||
149 | - * For AArch64, there is no 32/64 bit size distinction; | ||
150 | - * instead all registers have a 2 bit op0, 3 bit op1 and op2, | ||
151 | - * and 4 bit CRn and CRm. The encoding patterns are chosen | ||
152 | - * to be easy to convert to and from the KVM encodings, and also | ||
153 | - * so that the hashtable can contain both AArch32 and AArch64 | ||
154 | - * registers (to allow for interprocessing where we might run | ||
155 | - * 32 bit code on a 64 bit core). | ||
156 | - */ | ||
157 | -/* This bit is private to our hashtable cpreg; in KVM register | ||
158 | - * IDs the AArch64/32 distinction is the KVM_REG_ARM/ARM64 | ||
159 | - * in the upper bits of the 64 bit ID. | ||
160 | - */ | ||
161 | -#define CP_REG_AA64_SHIFT 28 | ||
162 | -#define CP_REG_AA64_MASK (1 << CP_REG_AA64_SHIFT) | ||
163 | - | ||
164 | -/* To enable banking of coprocessor registers depending on ns-bit we | ||
165 | - * add a bit to distinguish between secure and non-secure cpregs in the | ||
166 | - * hashtable. | ||
167 | - */ | ||
168 | -#define CP_REG_NS_SHIFT 29 | ||
169 | -#define CP_REG_NS_MASK (1 << CP_REG_NS_SHIFT) | ||
170 | - | ||
171 | -#define ENCODE_CP_REG(cp, is64, ns, crn, crm, opc1, opc2) \ | ||
172 | - ((ns) << CP_REG_NS_SHIFT | ((cp) << 16) | ((is64) << 15) | \ | ||
173 | - ((crn) << 11) | ((crm) << 7) | ((opc1) << 3) | (opc2)) | ||
174 | - | ||
175 | -#define ENCODE_AA64_CP_REG(cp, crn, crm, op0, op1, op2) \ | ||
176 | - (CP_REG_AA64_MASK | \ | ||
177 | - ((cp) << CP_REG_ARM_COPROC_SHIFT) | \ | ||
178 | - ((op0) << CP_REG_ARM64_SYSREG_OP0_SHIFT) | \ | ||
179 | - ((op1) << CP_REG_ARM64_SYSREG_OP1_SHIFT) | \ | ||
180 | - ((crn) << CP_REG_ARM64_SYSREG_CRN_SHIFT) | \ | ||
181 | - ((crm) << CP_REG_ARM64_SYSREG_CRM_SHIFT) | \ | ||
182 | - ((op2) << CP_REG_ARM64_SYSREG_OP2_SHIFT)) | ||
183 | - | ||
184 | -/* Convert a full 64 bit KVM register ID to the truncated 32 bit | ||
185 | - * version used as a key for the coprocessor register hashtable | ||
186 | - */ | ||
187 | -static inline uint32_t kvm_to_cpreg_id(uint64_t kvmid) | ||
188 | -{ | ||
189 | - uint32_t cpregid = kvmid; | ||
190 | - if ((kvmid & CP_REG_ARCH_MASK) == CP_REG_ARM64) { | ||
191 | - cpregid |= CP_REG_AA64_MASK; | ||
192 | - } else { | ||
193 | - if ((kvmid & CP_REG_SIZE_MASK) == CP_REG_SIZE_U64) { | ||
194 | - cpregid |= (1 << 15); | ||
96 | - } | 195 | - } |
97 | - | 196 | - |
98 | - if (s->v7m_new_fp_ctxt_needed) { | 197 | - /* KVM is always non-secure so add the NS flag on AArch32 register |
99 | - /* | 198 | - * entries. |
100 | - * Create new FP context by updating CONTROL.FPCA, CONTROL.SFPA, | 199 | - */ |
101 | - * the FPSCR, and VPR. | 200 | - cpregid |= 1 << CP_REG_NS_SHIFT; |
102 | - */ | 201 | - } |
103 | - TCGv_i32 control, fpscr; | 202 | - return cpregid; |
104 | - uint32_t bits = R_V7M_CONTROL_FPCA_MASK; | 203 | -} |
105 | - | 204 | - |
106 | - fpscr = load_cpu_field(v7m.fpdscr[s->v8m_secure]); | 205 | -/* Convert a truncated 32 bit hashtable key into the full |
107 | - gen_helper_vfp_set_fpscr(cpu_env, fpscr); | 206 | - * 64 bit KVM register ID. |
108 | - tcg_temp_free_i32(fpscr); | 207 | - */ |
109 | - if (dc_isar_feature(aa32_mve, s)) { | 208 | -static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid) |
110 | - TCGv_i32 z32 = tcg_const_i32(0); | 209 | -{ |
111 | - store_cpu_field(z32, v7m.vpr); | 210 | - uint64_t kvmid; |
112 | - } | 211 | - |
113 | - | 212 | - if (cpregid & CP_REG_AA64_MASK) { |
114 | - /* | 213 | - kvmid = cpregid & ~CP_REG_AA64_MASK; |
115 | - * We don't need to arrange to end the TB, because the only | 214 | - kvmid |= CP_REG_SIZE_U64 | CP_REG_ARM64; |
116 | - * parts of FPSCR which we cache in the TB flags are the VECLEN | 215 | - } else { |
117 | - * and VECSTRIDE, and those don't exist for M-profile. | 216 | - kvmid = cpregid & ~(1 << 15); |
118 | - */ | 217 | - if (cpregid & (1 << 15)) { |
119 | - | 218 | - kvmid |= CP_REG_SIZE_U64 | CP_REG_ARM; |
120 | - if (s->v8m_secure) { | 219 | - } else { |
121 | - bits |= R_V7M_CONTROL_SFPA_MASK; | 220 | - kvmid |= CP_REG_SIZE_U32 | CP_REG_ARM; |
122 | - } | ||
123 | - control = load_cpu_field(v7m.control[M_REG_S]); | ||
124 | - tcg_gen_ori_i32(control, control, bits); | ||
125 | - store_cpu_field(control, v7m.control[M_REG_S]); | ||
126 | - /* Don't need to do this for any further FP insns in this TB */ | ||
127 | - s->v7m_new_fp_ctxt_needed = false; | ||
128 | - } | 221 | - } |
129 | + /* Update ownership of FP context and create new FP context if needed */ | 222 | - } |
130 | + gen_update_fp_context(s); | 223 | - return kvmid; |
131 | } | 224 | -} |
132 | 225 | - | |
133 | return true; | 226 | /* Return the highest implemented Exception Level */ |
227 | static inline int arm_highest_el(CPUARMState *env) | ||
228 | { | ||
134 | -- | 229 | -- |
135 | 2.20.1 | 230 | 2.34.1 |
136 | 231 | ||
137 | 232 | diff view generated by jsdifflib |
1 | These days the Arm architecture has a wide range of fine-grained | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | optional extra architectural features. We implement quite a lot | ||
3 | of these but by no means all of them. Document what we do implement, | ||
4 | so that users can find out without having to dig through back-issues | ||
5 | of our Changelog on the wiki. | ||
6 | 2 | ||
3 | If a test was tagged with the "accel" tag and the specified | ||
4 | accelerator it not present in the qemu binary, cancel the test. | ||
5 | |||
6 | We can now write tests without explicit calls to require_accelerator, | ||
7 | just the tag is enough. | ||
8 | |||
9 | Signed-off-by: Fabiano Rosas <farosas@suse.de> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
9 | Message-id: 20210617140328.28622-1-peter.maydell@linaro.org | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | --- | 13 | --- |
12 | docs/system/arm/emulation.rst | 102 ++++++++++++++++++++++++++++++++++ | 14 | tests/avocado/avocado_qemu/__init__.py | 4 ++++ |
13 | docs/system/target-arm.rst | 6 ++ | 15 | 1 file changed, 4 insertions(+) |
14 | 2 files changed, 108 insertions(+) | ||
15 | create mode 100644 docs/system/arm/emulation.rst | ||
16 | 16 | ||
17 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst | 17 | diff --git a/tests/avocado/avocado_qemu/__init__.py b/tests/avocado/avocado_qemu/__init__.py |
18 | new file mode 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
19 | index XXXXXXX..XXXXXXX | 19 | --- a/tests/avocado/avocado_qemu/__init__.py |
20 | --- /dev/null | 20 | +++ b/tests/avocado/avocado_qemu/__init__.py |
21 | +++ b/docs/system/arm/emulation.rst | 21 | @@ -XXX,XX +XXX,XX @@ def setUp(self): |
22 | @@ -XXX,XX +XXX,XX @@ | 22 | |
23 | +A-profile CPU architecture support | 23 | super().setUp('qemu-system-') |
24 | +================================== | 24 | |
25 | + accel_required = self._get_unique_tag_val('accel') | ||
26 | + if accel_required: | ||
27 | + self.require_accelerator(accel_required) | ||
25 | + | 28 | + |
26 | +QEMU's TCG emulation includes support for the Armv5, Armv6, Armv7 and | 29 | self.machine = self.params.get('machine', |
27 | +Armv8 versions of the A-profile architecture. It also has support for | 30 | default=self._get_unique_tag_val('machine')) |
28 | +the following architecture extensions: | ||
29 | + | ||
30 | +- FEAT_AA32BF16 (AArch32 BFloat16 instructions) | ||
31 | +- FEAT_AA32HPD (AArch32 hierarchical permission disables) | ||
32 | +- FEAT_AA32I8MM (AArch32 Int8 matrix multiplication instructions) | ||
33 | +- FEAT_AES (AESD and AESE instructions) | ||
34 | +- FEAT_BF16 (AArch64 BFloat16 instructions) | ||
35 | +- FEAT_BTI (Branch Target Identification) | ||
36 | +- FEAT_DIT (Data Independent Timing instructions) | ||
37 | +- FEAT_DPB (DC CVAP instruction) | ||
38 | +- FEAT_DotProd (Advanced SIMD dot product instructions) | ||
39 | +- FEAT_FCMA (Floating-point complex number instructions) | ||
40 | +- FEAT_FHM (Floating-point half-precision multiplication instructions) | ||
41 | +- FEAT_FP16 (Half-precision floating-point data processing) | ||
42 | +- FEAT_FRINTTS (Floating-point to integer instructions) | ||
43 | +- FEAT_FlagM (Flag manipulation instructions v2) | ||
44 | +- FEAT_FlagM2 (Enhancements to flag manipulation instructions) | ||
45 | +- FEAT_HPDS (Hierarchical permission disables) | ||
46 | +- FEAT_I8MM (AArch64 Int8 matrix multiplication instructions) | ||
47 | +- FEAT_JSCVT (JavaScript conversion instructions) | ||
48 | +- FEAT_LOR (Limited ordering regions) | ||
49 | +- FEAT_LRCPC (Load-acquire RCpc instructions) | ||
50 | +- FEAT_LRCPC2 (Load-acquire RCpc instructions v2) | ||
51 | +- FEAT_LSE (Large System Extensions) | ||
52 | +- FEAT_MTE (Memory Tagging Extension) | ||
53 | +- FEAT_MTE2 (Memory Tagging Extension) | ||
54 | +- FEAT_PAN (Privileged access never) | ||
55 | +- FEAT_PAN2 (AT S1E1R and AT S1E1W instruction variants affected by PSTATE.PAN) | ||
56 | +- FEAT_PAuth (Pointer authentication) | ||
57 | +- FEAT_PMULL (PMULL, PMULL2 instructions) | ||
58 | +- FEAT_PMUv3p1 (PMU Extensions v3.1) | ||
59 | +- FEAT_PMUv3p4 (PMU Extensions v3.4) | ||
60 | +- FEAT_RDM (Advanced SIMD rounding double multiply accumulate instructions) | ||
61 | +- FEAT_RNG (Random number generator) | ||
62 | +- FEAT_SB (Speculation Barrier) | ||
63 | +- FEAT_SEL2 (Secure EL2) | ||
64 | +- FEAT_SHA1 (SHA1 instructions) | ||
65 | +- FEAT_SHA256 (SHA256 instructions) | ||
66 | +- FEAT_SHA3 (Advanced SIMD SHA3 instructions) | ||
67 | +- FEAT_SHA512 (Advanced SIMD SHA512 instructions) | ||
68 | +- FEAT_SM3 (Advanced SIMD SM3 instructions) | ||
69 | +- FEAT_SM4 (Advanced SIMD SM4 instructions) | ||
70 | +- FEAT_SPECRES (Speculation restriction instructions) | ||
71 | +- FEAT_SSBS (Speculative Store Bypass Safe) | ||
72 | +- FEAT_TLBIOS (TLB invalidate instructions in Outer Shareable domain) | ||
73 | +- FEAT_TLBIRANGE (TLB invalidate range instructions) | ||
74 | +- FEAT_TTCNP (Translation table Common not private translations) | ||
75 | +- FEAT_TTST (Small translation tables) | ||
76 | +- FEAT_UAO (Unprivileged Access Override control) | ||
77 | +- FEAT_VHE (Virtualization Host Extensions) | ||
78 | +- FEAT_VMID16 (16-bit VMID) | ||
79 | +- FEAT_XNX (Translation table stage 2 Unprivileged Execute-never) | ||
80 | +- SVE (The Scalable Vector Extension) | ||
81 | +- SVE2 (The Scalable Vector Extension v2) | ||
82 | + | ||
83 | +For information on the specifics of these extensions, please refer | ||
84 | +to the `Armv8-A Arm Architecture Reference Manual | ||
85 | +<https://developer.arm.com/documentation/ddi0487/latest>`_. | ||
86 | + | ||
87 | +When a specific named CPU is being emulated, only those features which | ||
88 | +are present in hardware for that CPU are emulated. (If a feature is | ||
89 | +not in the list above then it is not supported, even if the real | ||
90 | +hardware should have it.) The ``max`` CPU enables all features. | ||
91 | + | ||
92 | +R-profile CPU architecture support | ||
93 | +================================== | ||
94 | + | ||
95 | +QEMU's TCG emulation support for R-profile CPUs is currently limited. | ||
96 | +We emulate only the Cortex-R5 and Cortex-R5F CPUs. | ||
97 | + | ||
98 | +M-profile CPU architecture support | ||
99 | +================================== | ||
100 | + | ||
101 | +QEMU's TCG emulation includes support for Armv6-M, Armv7-M, Armv8-M, and | ||
102 | +Armv8.1-M versions of the M-profile architucture. It also has support | ||
103 | +for the following architecture extensions: | ||
104 | + | ||
105 | +- FP (Floating-point Extension) | ||
106 | +- FPCXT (FPCXT access instructions) | ||
107 | +- HP (Half-precision floating-point instructions) | ||
108 | +- LOB (Low Overhead loops and Branch future) | ||
109 | +- M (Main Extension) | ||
110 | +- MPU (Memory Protection Unit Extension) | ||
111 | +- PXN (Privileged Execute Never) | ||
112 | +- RAS (Reliability, Serviceability and Availability): "minimum RAS Extension" only | ||
113 | +- S (Security Extension) | ||
114 | +- ST (System Timer Extension) | ||
115 | + | ||
116 | +For information on the specifics of these extensions, please refer | ||
117 | +to the `Armv8-M Arm Architecture Reference Manual | ||
118 | +<https://developer.arm.com/documentation/ddi0553/latest>`_. | ||
119 | + | ||
120 | +When a specific named CPU is being emulated, only those features which | ||
121 | +are present in hardware for that CPU are emulated. (If a feature is | ||
122 | +not in the list above then it is not supported, even if the real | ||
123 | +hardware should have it.) There is no equivalent of the ``max`` CPU for | ||
124 | +M-profile. | ||
125 | diff --git a/docs/system/target-arm.rst b/docs/system/target-arm.rst | ||
126 | index XXXXXXX..XXXXXXX 100644 | ||
127 | --- a/docs/system/target-arm.rst | ||
128 | +++ b/docs/system/target-arm.rst | ||
129 | @@ -XXX,XX +XXX,XX @@ undocumented; you can get a complete list by running | ||
130 | arm/virt | ||
131 | arm/xlnx-versal-virt | ||
132 | |||
133 | +Emulated CPU architecture support | ||
134 | +================================= | ||
135 | + | ||
136 | +.. toctree:: | ||
137 | + arm/emulation | ||
138 | + | ||
139 | Arm CPU features | ||
140 | ================ | ||
141 | 31 | ||
142 | -- | 32 | -- |
143 | 2.20.1 | 33 | 2.34.1 |
144 | 34 | ||
145 | 35 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | If the guest makes an FPCXT_NS access when the FPU is disabled, | ||
2 | one of two things happens: | ||
3 | * if there is no active FP context, then the insn behaves the | ||
4 | same way as if the FPU was enabled: writes ignored, reads | ||
5 | same value as FPDSCR_NS | ||
6 | * if there is an active FP context, then we take a NOCP | ||
7 | exception | ||
8 | 1 | ||
9 | Add code to the sysreg read/write functions which emits | ||
10 | code to take the NOCP exception in the latter case. | ||
11 | |||
12 | At the moment this will never be used, because the NOCP checks in | ||
13 | m-nocp.decode happen first, and so the trans functions are never | ||
14 | called when the FPU is disabled. The code will be needed when we | ||
15 | move the sysreg access insns to before the NOCP patterns in the | ||
16 | following commit. | ||
17 | |||
18 | Cc: qemu-stable@nongnu.org | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
20 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
21 | Message-id: 20210618141019.10671-3-peter.maydell@linaro.org | ||
22 | --- | ||
23 | target/arm/translate-vfp.c | 32 ++++++++++++++++++++++++++++++-- | ||
24 | 1 file changed, 30 insertions(+), 2 deletions(-) | ||
25 | |||
26 | diff --git a/target/arm/translate-vfp.c b/target/arm/translate-vfp.c | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/target/arm/translate-vfp.c | ||
29 | +++ b/target/arm/translate-vfp.c | ||
30 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, | ||
31 | lab_end = gen_new_label(); | ||
32 | /* fpInactive case: write is a NOP, so branch to end */ | ||
33 | gen_branch_fpInactive(s, TCG_COND_NE, lab_end); | ||
34 | - /* !fpInactive: PreserveFPState(), and reads same as FPCXT_S */ | ||
35 | + /* | ||
36 | + * !fpInactive: if FPU disabled, take NOCP exception; | ||
37 | + * otherwise PreserveFPState(), and then FPCXT_NS writes | ||
38 | + * behave the same as FPCXT_S writes. | ||
39 | + */ | ||
40 | + if (s->fp_excp_el) { | ||
41 | + gen_exception_insn(s, s->pc_curr, EXCP_NOCP, | ||
42 | + syn_uncategorized(), s->fp_excp_el); | ||
43 | + /* | ||
44 | + * This was only a conditional exception, so override | ||
45 | + * gen_exception_insn()'s default to DISAS_NORETURN | ||
46 | + */ | ||
47 | + s->base.is_jmp = DISAS_NEXT; | ||
48 | + break; | ||
49 | + } | ||
50 | gen_preserve_fp_state(s); | ||
51 | /* fall through */ | ||
52 | case ARM_VFP_FPCXT_S: | ||
53 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno, | ||
54 | tcg_gen_br(lab_end); | ||
55 | |||
56 | gen_set_label(lab_active); | ||
57 | - /* !fpInactive: Reads the same as FPCXT_S, but side effects differ */ | ||
58 | + /* | ||
59 | + * !fpInactive: if FPU disabled, take NOCP exception; | ||
60 | + * otherwise PreserveFPState(), and then FPCXT_NS | ||
61 | + * reads the same as FPCXT_S. | ||
62 | + */ | ||
63 | + if (s->fp_excp_el) { | ||
64 | + gen_exception_insn(s, s->pc_curr, EXCP_NOCP, | ||
65 | + syn_uncategorized(), s->fp_excp_el); | ||
66 | + /* | ||
67 | + * This was only a conditional exception, so override | ||
68 | + * gen_exception_insn()'s default to DISAS_NORETURN | ||
69 | + */ | ||
70 | + s->base.is_jmp = DISAS_NEXT; | ||
71 | + break; | ||
72 | + } | ||
73 | gen_preserve_fp_state(s); | ||
74 | tmp = tcg_temp_new_i32(); | ||
75 | sfpa = tcg_temp_new_i32(); | ||
76 | -- | ||
77 | 2.20.1 | ||
78 | |||
79 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Instead of open-coding the "take NOCP exception if FPU disabled, | ||
2 | otherwise call gen_preserve_fp_state()" code in the accessors for | ||
3 | FPCXT_NS, add an argument to vfp_access_check_m() which tells it to | ||
4 | skip the gen_update_fp_context() call, so we can use it for the | ||
5 | FPCXT_NS case. | ||
6 | 1 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20210618141019.10671-8-peter.maydell@linaro.org | ||
10 | --- | ||
11 | target/arm/translate-a32.h | 2 +- | ||
12 | target/arm/translate-m-nocp.c | 10 ++-------- | ||
13 | target/arm/translate-vfp.c | 13 ++++++++----- | ||
14 | 3 files changed, 11 insertions(+), 14 deletions(-) | ||
15 | |||
16 | diff --git a/target/arm/translate-a32.h b/target/arm/translate-a32.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/arm/translate-a32.h | ||
19 | +++ b/target/arm/translate-a32.h | ||
20 | @@ -XXX,XX +XXX,XX @@ bool disas_neon_shared(DisasContext *s, uint32_t insn); | ||
21 | void load_reg_var(DisasContext *s, TCGv_i32 var, int reg); | ||
22 | void arm_gen_condlabel(DisasContext *s); | ||
23 | bool vfp_access_check(DisasContext *s); | ||
24 | -void gen_preserve_fp_state(DisasContext *s); | ||
25 | +bool vfp_access_check_m(DisasContext *s, bool skip_context_update); | ||
26 | void read_neon_element32(TCGv_i32 dest, int reg, int ele, MemOp memop); | ||
27 | void read_neon_element64(TCGv_i64 dest, int reg, int ele, MemOp memop); | ||
28 | void write_neon_element32(TCGv_i32 src, int reg, int ele, MemOp memop); | ||
29 | diff --git a/target/arm/translate-m-nocp.c b/target/arm/translate-m-nocp.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/target/arm/translate-m-nocp.c | ||
32 | +++ b/target/arm/translate-m-nocp.c | ||
33 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, | ||
34 | * otherwise PreserveFPState(), and then FPCXT_NS writes | ||
35 | * behave the same as FPCXT_S writes. | ||
36 | */ | ||
37 | - if (s->fp_excp_el) { | ||
38 | - gen_exception_insn(s, s->pc_curr, EXCP_NOCP, | ||
39 | - syn_uncategorized(), s->fp_excp_el); | ||
40 | + if (!vfp_access_check_m(s, true)) { | ||
41 | /* | ||
42 | * This was only a conditional exception, so override | ||
43 | * gen_exception_insn()'s default to DISAS_NORETURN | ||
44 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, | ||
45 | s->base.is_jmp = DISAS_NEXT; | ||
46 | break; | ||
47 | } | ||
48 | - gen_preserve_fp_state(s); | ||
49 | } | ||
50 | /* fall through */ | ||
51 | case ARM_VFP_FPCXT_S: | ||
52 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno, | ||
53 | * otherwise PreserveFPState(), and then FPCXT_NS | ||
54 | * reads the same as FPCXT_S. | ||
55 | */ | ||
56 | - if (s->fp_excp_el) { | ||
57 | - gen_exception_insn(s, s->pc_curr, EXCP_NOCP, | ||
58 | - syn_uncategorized(), s->fp_excp_el); | ||
59 | + if (!vfp_access_check_m(s, true)) { | ||
60 | /* | ||
61 | * This was only a conditional exception, so override | ||
62 | * gen_exception_insn()'s default to DISAS_NORETURN | ||
63 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno, | ||
64 | s->base.is_jmp = DISAS_NEXT; | ||
65 | break; | ||
66 | } | ||
67 | - gen_preserve_fp_state(s); | ||
68 | tmp = tcg_temp_new_i32(); | ||
69 | sfpa = tcg_temp_new_i32(); | ||
70 | fpscr = tcg_temp_new_i32(); | ||
71 | diff --git a/target/arm/translate-vfp.c b/target/arm/translate-vfp.c | ||
72 | index XXXXXXX..XXXXXXX 100644 | ||
73 | --- a/target/arm/translate-vfp.c | ||
74 | +++ b/target/arm/translate-vfp.c | ||
75 | @@ -XXX,XX +XXX,XX @@ static inline long vfp_f16_offset(unsigned reg, bool top) | ||
76 | * Generate code for M-profile lazy FP state preservation if needed; | ||
77 | * this corresponds to the pseudocode PreserveFPState() function. | ||
78 | */ | ||
79 | -void gen_preserve_fp_state(DisasContext *s) | ||
80 | +static void gen_preserve_fp_state(DisasContext *s) | ||
81 | { | ||
82 | if (s->v7m_lspact) { | ||
83 | /* | ||
84 | @@ -XXX,XX +XXX,XX @@ static bool vfp_access_check_a(DisasContext *s, bool ignore_vfp_enabled) | ||
85 | * If VFP is enabled, do the necessary M-profile lazy-FP handling and then | ||
86 | * return true. If not, emit code to generate an appropriate exception and | ||
87 | * return false. | ||
88 | + * skip_context_update is true to skip the "update FP context" part of this. | ||
89 | */ | ||
90 | -static bool vfp_access_check_m(DisasContext *s) | ||
91 | +bool vfp_access_check_m(DisasContext *s, bool skip_context_update) | ||
92 | { | ||
93 | if (s->fp_excp_el) { | ||
94 | /* | ||
95 | @@ -XXX,XX +XXX,XX @@ static bool vfp_access_check_m(DisasContext *s) | ||
96 | /* Trigger lazy-state preservation if necessary */ | ||
97 | gen_preserve_fp_state(s); | ||
98 | |||
99 | - /* Update ownership of FP context and create new FP context if needed */ | ||
100 | - gen_update_fp_context(s); | ||
101 | + if (!skip_context_update) { | ||
102 | + /* Update ownership of FP context and create new FP context if needed */ | ||
103 | + gen_update_fp_context(s); | ||
104 | + } | ||
105 | |||
106 | return true; | ||
107 | } | ||
108 | @@ -XXX,XX +XXX,XX @@ static bool vfp_access_check_m(DisasContext *s) | ||
109 | bool vfp_access_check(DisasContext *s) | ||
110 | { | ||
111 | if (arm_dc_feature(s, ARM_FEATURE_M)) { | ||
112 | - return vfp_access_check_m(s); | ||
113 | + return vfp_access_check_m(s, false); | ||
114 | } else { | ||
115 | return vfp_access_check_a(s, false); | ||
116 | } | ||
117 | -- | ||
118 | 2.20.1 | ||
119 | |||
120 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the variants of MVE VLDR (encodings T1, T2) which perform | ||
2 | "widening" loads where bytes or halfwords are loaded from memory and | ||
3 | zero or sign-extended into halfword or word length vector elements, | ||
4 | and the narrowing MVE VSTR (encodings T1, T2) where bytes or | ||
5 | halfwords are stored from halfword or word elements. | ||
6 | 1 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20210617121628.20116-3-peter.maydell@linaro.org | ||
10 | --- | ||
11 | target/arm/helper-mve.h | 10 ++++++++++ | ||
12 | target/arm/mve.decode | 25 +++++++++++++++++++++++-- | ||
13 | target/arm/mve_helper.c | 11 +++++++++++ | ||
14 | target/arm/translate-mve.c | 14 ++++++++++++++ | ||
15 | 4 files changed, 58 insertions(+), 2 deletions(-) | ||
16 | |||
17 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/helper-mve.h | ||
20 | +++ b/target/arm/helper-mve.h | ||
21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vldrw, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
22 | DEF_HELPER_FLAGS_3(mve_vstrb, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
23 | DEF_HELPER_FLAGS_3(mve_vstrh, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
24 | DEF_HELPER_FLAGS_3(mve_vstrw, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
25 | + | ||
26 | +DEF_HELPER_FLAGS_3(mve_vldrb_sh, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
27 | +DEF_HELPER_FLAGS_3(mve_vldrb_sw, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
28 | +DEF_HELPER_FLAGS_3(mve_vldrb_uh, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
29 | +DEF_HELPER_FLAGS_3(mve_vldrb_uw, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
30 | +DEF_HELPER_FLAGS_3(mve_vldrh_sw, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
31 | +DEF_HELPER_FLAGS_3(mve_vldrh_uw, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
32 | +DEF_HELPER_FLAGS_3(mve_vstrb_h, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
33 | +DEF_HELPER_FLAGS_3(mve_vstrb_w, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
34 | +DEF_HELPER_FLAGS_3(mve_vstrh_w, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
35 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/target/arm/mve.decode | ||
38 | +++ b/target/arm/mve.decode | ||
39 | @@ -XXX,XX +XXX,XX @@ | ||
40 | |||
41 | %qd 22:1 13:3 | ||
42 | |||
43 | -&vldr_vstr rn qd imm p a w size l | ||
44 | +&vldr_vstr rn qd imm p a w size l u | ||
45 | |||
46 | -@vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd | ||
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 | +@vldst_wn ... u:1 ... . . . . l:1 . rn:3 qd:3 . ... .. imm:7 &vldr_vstr | ||
50 | |||
51 | # Vector loads and stores | ||
52 | |||
53 | +# Widening loads and narrowing stores: | ||
54 | +# for these P=0 W=0 is 'related encoding'; sz=11 is 'related encoding' | ||
55 | +# This means we need to expand out to multiple patterns for P, W, SZ. | ||
56 | +# For stores the U bit must be 0 but we catch that in the trans_ function. | ||
57 | +# The naming scheme here is "VLDSTB_H == in-memory byte load/store to/from | ||
58 | +# signed halfword element in register", etc. | ||
59 | +VLDSTB_H 111 . 110 0 a:1 0 1 . 0 ... ... 0 111 01 ....... @vldst_wn \ | ||
60 | + p=0 w=1 size=1 | ||
61 | +VLDSTB_H 111 . 110 1 a:1 0 w:1 . 0 ... ... 0 111 01 ....... @vldst_wn \ | ||
62 | + p=1 size=1 | ||
63 | +VLDSTB_W 111 . 110 0 a:1 0 1 . 0 ... ... 0 111 10 ....... @vldst_wn \ | ||
64 | + p=0 w=1 size=2 | ||
65 | +VLDSTB_W 111 . 110 1 a:1 0 w:1 . 0 ... ... 0 111 10 ....... @vldst_wn \ | ||
66 | + p=1 size=2 | ||
67 | +VLDSTH_W 111 . 110 0 a:1 0 1 . 1 ... ... 0 111 10 ....... @vldst_wn \ | ||
68 | + p=0 w=1 size=2 | ||
69 | +VLDSTH_W 111 . 110 1 a:1 0 w:1 . 1 ... ... 0 111 10 ....... @vldst_wn \ | ||
70 | + p=1 size=2 | ||
71 | + | ||
72 | # Non-widening loads/stores (P=0 W=0 is 'related encoding') | ||
73 | VLDR_VSTR 1110110 0 a:1 . 1 . .... ... 111100 ....... @vldr_vstr \ | ||
74 | size=0 p=0 w=1 | ||
75 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
76 | index XXXXXXX..XXXXXXX 100644 | ||
77 | --- a/target/arm/mve_helper.c | ||
78 | +++ b/target/arm/mve_helper.c | ||
79 | @@ -XXX,XX +XXX,XX @@ DO_VSTR(vstrb, 1, stb, 1, uint8_t) | ||
80 | DO_VSTR(vstrh, 2, stw, 2, uint16_t) | ||
81 | DO_VSTR(vstrw, 4, stl, 4, uint32_t) | ||
82 | |||
83 | +DO_VLDR(vldrb_sh, 1, ldsb, 2, int16_t) | ||
84 | +DO_VLDR(vldrb_sw, 1, ldsb, 4, int32_t) | ||
85 | +DO_VLDR(vldrb_uh, 1, ldub, 2, uint16_t) | ||
86 | +DO_VLDR(vldrb_uw, 1, ldub, 4, uint32_t) | ||
87 | +DO_VLDR(vldrh_sw, 2, ldsw, 4, int32_t) | ||
88 | +DO_VLDR(vldrh_uw, 2, lduw, 4, uint32_t) | ||
89 | + | ||
90 | +DO_VSTR(vstrb_h, 1, stb, 2, int16_t) | ||
91 | +DO_VSTR(vstrb_w, 1, stb, 4, int32_t) | ||
92 | +DO_VSTR(vstrh_w, 2, stw, 4, int32_t) | ||
93 | + | ||
94 | #undef DO_VLDR | ||
95 | #undef DO_VSTR | ||
96 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
97 | index XXXXXXX..XXXXXXX 100644 | ||
98 | --- a/target/arm/translate-mve.c | ||
99 | +++ b/target/arm/translate-mve.c | ||
100 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR(DisasContext *s, arg_VLDR_VSTR *a) | ||
101 | }; | ||
102 | return do_ldst(s, a, ldstfns[a->size][a->l]); | ||
103 | } | ||
104 | + | ||
105 | +#define DO_VLDST_WIDE_NARROW(OP, SLD, ULD, ST) \ | ||
106 | + static bool trans_##OP(DisasContext *s, arg_VLDR_VSTR *a) \ | ||
107 | + { \ | ||
108 | + static MVEGenLdStFn * const ldstfns[2][2] = { \ | ||
109 | + { gen_helper_mve_##ST, gen_helper_mve_##SLD }, \ | ||
110 | + { NULL, gen_helper_mve_##ULD }, \ | ||
111 | + }; \ | ||
112 | + return do_ldst(s, a, ldstfns[a->u][a->l]); \ | ||
113 | + } | ||
114 | + | ||
115 | +DO_VLDST_WIDE_NARROW(VLDSTB_H, vldrb_sh, vldrb_uh, vstrb_h) | ||
116 | +DO_VLDST_WIDE_NARROW(VLDSTB_W, vldrb_sw, vldrb_uw, vstrb_w) | ||
117 | +DO_VLDST_WIDE_NARROW(VLDSTH_W, vldrh_sw, vldrh_uw, vstrh_w) | ||
118 | -- | ||
119 | 2.20.1 | ||
120 | |||
121 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE VCLZ insn (and the necessary machinery | ||
2 | for MVE 1-input vector ops). | ||
3 | 1 | ||
4 | Note that for non-load instructions predication is always performed | ||
5 | at a byte level granularity regardless of element size (R_ZLSJ), | ||
6 | and so the masking logic here differs from that used in the VLDR | ||
7 | and VSTR helpers. | ||
8 | |||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20210617121628.20116-4-peter.maydell@linaro.org | ||
12 | --- | ||
13 | target/arm/helper-mve.h | 4 ++ | ||
14 | target/arm/mve.decode | 8 ++++ | ||
15 | target/arm/mve_helper.c | 82 ++++++++++++++++++++++++++++++++++++++ | ||
16 | target/arm/translate-mve.c | 38 ++++++++++++++++++ | ||
17 | 4 files changed, 132 insertions(+) | ||
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_vldrh_uw, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
24 | DEF_HELPER_FLAGS_3(mve_vstrb_h, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
25 | DEF_HELPER_FLAGS_3(mve_vstrb_w, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
26 | DEF_HELPER_FLAGS_3(mve_vstrh_w, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
27 | + | ||
28 | +DEF_HELPER_FLAGS_3(mve_vclzb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
29 | +DEF_HELPER_FLAGS_3(mve_vclzh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
30 | +DEF_HELPER_FLAGS_3(mve_vclzw, 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 @@ | ||
36 | # | ||
37 | |||
38 | %qd 22:1 13:3 | ||
39 | +%qm 5:1 1:3 | ||
40 | |||
41 | &vldr_vstr rn qd imm p a w size l u | ||
42 | +&1op qd qm size | ||
43 | |||
44 | @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 | ||
45 | # Note that both Rn and Qd are 3 bits only (no D bit) | ||
46 | @vldst_wn ... u:1 ... . . . . l:1 . rn:3 qd:3 . ... .. imm:7 &vldr_vstr | ||
47 | |||
48 | +@1op .... .... .... size:2 .. .... .... .... .... &1op qd=%qd qm=%qm | ||
49 | + | ||
50 | # Vector loads and stores | ||
51 | |||
52 | # Widening loads and narrowing stores: | ||
53 | @@ -XXX,XX +XXX,XX @@ VLDR_VSTR 1110110 1 a:1 . w:1 . .... ... 111101 ....... @vldr_vstr \ | ||
54 | size=1 p=1 | ||
55 | VLDR_VSTR 1110110 1 a:1 . w:1 . .... ... 111110 ....... @vldr_vstr \ | ||
56 | size=2 p=1 | ||
57 | + | ||
58 | +# Vector miscellaneous | ||
59 | + | ||
60 | +VCLZ 1111 1111 1 . 11 .. 00 ... 0 0100 11 . 0 ... 0 @1op | ||
61 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
62 | index XXXXXXX..XXXXXXX 100644 | ||
63 | --- a/target/arm/mve_helper.c | ||
64 | +++ b/target/arm/mve_helper.c | ||
65 | @@ -XXX,XX +XXX,XX @@ DO_VSTR(vstrh_w, 2, stw, 4, int32_t) | ||
66 | |||
67 | #undef DO_VLDR | ||
68 | #undef DO_VSTR | ||
69 | + | ||
70 | +/* | ||
71 | + * The mergemask(D, R, M) macro performs the operation "*D = R" but | ||
72 | + * storing only the bytes which correspond to 1 bits in M, | ||
73 | + * leaving other bytes in *D unchanged. We use _Generic | ||
74 | + * to select the correct implementation based on the type of D. | ||
75 | + */ | ||
76 | + | ||
77 | +static void mergemask_ub(uint8_t *d, uint8_t r, uint16_t mask) | ||
78 | +{ | ||
79 | + if (mask & 1) { | ||
80 | + *d = r; | ||
81 | + } | ||
82 | +} | ||
83 | + | ||
84 | +static void mergemask_sb(int8_t *d, int8_t r, uint16_t mask) | ||
85 | +{ | ||
86 | + mergemask_ub((uint8_t *)d, r, mask); | ||
87 | +} | ||
88 | + | ||
89 | +static void mergemask_uh(uint16_t *d, uint16_t r, uint16_t mask) | ||
90 | +{ | ||
91 | + uint16_t bmask = expand_pred_b_data[mask & 3]; | ||
92 | + *d = (*d & ~bmask) | (r & bmask); | ||
93 | +} | ||
94 | + | ||
95 | +static void mergemask_sh(int16_t *d, int16_t r, uint16_t mask) | ||
96 | +{ | ||
97 | + mergemask_uh((uint16_t *)d, r, mask); | ||
98 | +} | ||
99 | + | ||
100 | +static void mergemask_uw(uint32_t *d, uint32_t r, uint16_t mask) | ||
101 | +{ | ||
102 | + uint32_t bmask = expand_pred_b_data[mask & 0xf]; | ||
103 | + *d = (*d & ~bmask) | (r & bmask); | ||
104 | +} | ||
105 | + | ||
106 | +static void mergemask_sw(int32_t *d, int32_t r, uint16_t mask) | ||
107 | +{ | ||
108 | + mergemask_uw((uint32_t *)d, r, mask); | ||
109 | +} | ||
110 | + | ||
111 | +static void mergemask_uq(uint64_t *d, uint64_t r, uint16_t mask) | ||
112 | +{ | ||
113 | + uint64_t bmask = expand_pred_b_data[mask & 0xff]; | ||
114 | + *d = (*d & ~bmask) | (r & bmask); | ||
115 | +} | ||
116 | + | ||
117 | +static void mergemask_sq(int64_t *d, int64_t r, uint16_t mask) | ||
118 | +{ | ||
119 | + mergemask_uq((uint64_t *)d, r, mask); | ||
120 | +} | ||
121 | + | ||
122 | +#define mergemask(D, R, M) \ | ||
123 | + _Generic(D, \ | ||
124 | + uint8_t *: mergemask_ub, \ | ||
125 | + int8_t *: mergemask_sb, \ | ||
126 | + uint16_t *: mergemask_uh, \ | ||
127 | + int16_t *: mergemask_sh, \ | ||
128 | + uint32_t *: mergemask_uw, \ | ||
129 | + int32_t *: mergemask_sw, \ | ||
130 | + uint64_t *: mergemask_uq, \ | ||
131 | + int64_t *: mergemask_sq)(D, R, M) | ||
132 | + | ||
133 | +#define DO_1OP(OP, ESIZE, TYPE, FN) \ | ||
134 | + void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm) \ | ||
135 | + { \ | ||
136 | + TYPE *d = vd, *m = vm; \ | ||
137 | + uint16_t mask = mve_element_mask(env); \ | ||
138 | + unsigned e; \ | ||
139 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
140 | + mergemask(&d[H##ESIZE(e)], FN(m[H##ESIZE(e)]), mask); \ | ||
141 | + } \ | ||
142 | + mve_advance_vpt(env); \ | ||
143 | + } | ||
144 | + | ||
145 | +#define DO_CLZ_B(N) (clz32(N) - 24) | ||
146 | +#define DO_CLZ_H(N) (clz32(N) - 16) | ||
147 | + | ||
148 | +DO_1OP(vclzb, 1, uint8_t, DO_CLZ_B) | ||
149 | +DO_1OP(vclzh, 2, uint16_t, DO_CLZ_H) | ||
150 | +DO_1OP(vclzw, 4, uint32_t, clz32) | ||
151 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
152 | index XXXXXXX..XXXXXXX 100644 | ||
153 | --- a/target/arm/translate-mve.c | ||
154 | +++ b/target/arm/translate-mve.c | ||
155 | @@ -XXX,XX +XXX,XX @@ | ||
156 | #include "decode-mve.c.inc" | ||
157 | |||
158 | typedef void MVEGenLdStFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
159 | +typedef void MVEGenOneOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
160 | |||
161 | /* Return the offset of a Qn register (same semantics as aa32_vfp_qreg()) */ | ||
162 | static inline long mve_qreg_offset(unsigned reg) | ||
163 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR(DisasContext *s, arg_VLDR_VSTR *a) | ||
164 | DO_VLDST_WIDE_NARROW(VLDSTB_H, vldrb_sh, vldrb_uh, vstrb_h) | ||
165 | DO_VLDST_WIDE_NARROW(VLDSTB_W, vldrb_sw, vldrb_uw, vstrb_w) | ||
166 | DO_VLDST_WIDE_NARROW(VLDSTH_W, vldrh_sw, vldrh_uw, vstrh_w) | ||
167 | + | ||
168 | +static bool do_1op(DisasContext *s, arg_1op *a, MVEGenOneOpFn fn) | ||
169 | +{ | ||
170 | + TCGv_ptr qd, qm; | ||
171 | + | ||
172 | + if (!dc_isar_feature(aa32_mve, s) || | ||
173 | + !mve_check_qreg_bank(s, a->qd | a->qm) || | ||
174 | + !fn) { | ||
175 | + return false; | ||
176 | + } | ||
177 | + | ||
178 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
179 | + return true; | ||
180 | + } | ||
181 | + | ||
182 | + qd = mve_qreg_ptr(a->qd); | ||
183 | + qm = mve_qreg_ptr(a->qm); | ||
184 | + fn(cpu_env, qd, qm); | ||
185 | + tcg_temp_free_ptr(qd); | ||
186 | + tcg_temp_free_ptr(qm); | ||
187 | + mve_update_eci(s); | ||
188 | + return true; | ||
189 | +} | ||
190 | + | ||
191 | +#define DO_1OP(INSN, FN) \ | ||
192 | + static bool trans_##INSN(DisasContext *s, arg_1op *a) \ | ||
193 | + { \ | ||
194 | + static MVEGenOneOpFn * const fns[] = { \ | ||
195 | + gen_helper_mve_##FN##b, \ | ||
196 | + gen_helper_mve_##FN##h, \ | ||
197 | + gen_helper_mve_##FN##w, \ | ||
198 | + NULL, \ | ||
199 | + }; \ | ||
200 | + return do_1op(s, a, fns[a->size]); \ | ||
201 | + } | ||
202 | + | ||
203 | +DO_1OP(VCLZ, vclz) | ||
204 | -- | ||
205 | 2.20.1 | ||
206 | |||
207 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE VCLS insn. | ||
2 | 1 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20210617121628.20116-5-peter.maydell@linaro.org | ||
6 | --- | ||
7 | target/arm/helper-mve.h | 4 ++++ | ||
8 | target/arm/mve.decode | 1 + | ||
9 | target/arm/mve_helper.c | 7 +++++++ | ||
10 | target/arm/translate-mve.c | 1 + | ||
11 | 4 files changed, 13 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_3(mve_vstrb_h, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
18 | DEF_HELPER_FLAGS_3(mve_vstrb_w, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
19 | DEF_HELPER_FLAGS_3(mve_vstrh_w, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
20 | |||
21 | +DEF_HELPER_FLAGS_3(mve_vclsb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
22 | +DEF_HELPER_FLAGS_3(mve_vclsh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
23 | +DEF_HELPER_FLAGS_3(mve_vclsw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
24 | + | ||
25 | DEF_HELPER_FLAGS_3(mve_vclzb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
26 | DEF_HELPER_FLAGS_3(mve_vclzh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
27 | DEF_HELPER_FLAGS_3(mve_vclzw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
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 @@ VLDR_VSTR 1110110 1 a:1 . w:1 . .... ... 111110 ....... @vldr_vstr \ | ||
33 | |||
34 | # Vector miscellaneous | ||
35 | |||
36 | +VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op | ||
37 | VCLZ 1111 1111 1 . 11 .. 00 ... 0 0100 11 . 0 ... 0 @1op | ||
38 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/target/arm/mve_helper.c | ||
41 | +++ b/target/arm/mve_helper.c | ||
42 | @@ -XXX,XX +XXX,XX @@ static void mergemask_sq(int64_t *d, int64_t r, uint16_t mask) | ||
43 | mve_advance_vpt(env); \ | ||
44 | } | ||
45 | |||
46 | +#define DO_CLS_B(N) (clrsb32(N) - 24) | ||
47 | +#define DO_CLS_H(N) (clrsb32(N) - 16) | ||
48 | + | ||
49 | +DO_1OP(vclsb, 1, int8_t, DO_CLS_B) | ||
50 | +DO_1OP(vclsh, 2, int16_t, DO_CLS_H) | ||
51 | +DO_1OP(vclsw, 4, int32_t, clrsb32) | ||
52 | + | ||
53 | #define DO_CLZ_B(N) (clz32(N) - 24) | ||
54 | #define DO_CLZ_H(N) (clz32(N) - 16) | ||
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 @@ static bool do_1op(DisasContext *s, arg_1op *a, MVEGenOneOpFn fn) | ||
61 | } | ||
62 | |||
63 | DO_1OP(VCLZ, vclz) | ||
64 | +DO_1OP(VCLS, vcls) | ||
65 | -- | ||
66 | 2.20.1 | ||
67 | |||
68 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE instructions VREV16, VREV32 and VREV64. | ||
2 | 1 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20210617121628.20116-6-peter.maydell@linaro.org | ||
6 | --- | ||
7 | target/arm/helper-mve.h | 7 +++++++ | ||
8 | target/arm/mve.decode | 4 ++++ | ||
9 | target/arm/mve_helper.c | 7 +++++++ | ||
10 | target/arm/translate-mve.c | 33 +++++++++++++++++++++++++++++++++ | ||
11 | 4 files changed, 51 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_3(mve_vclsw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
18 | DEF_HELPER_FLAGS_3(mve_vclzb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
19 | DEF_HELPER_FLAGS_3(mve_vclzh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
20 | DEF_HELPER_FLAGS_3(mve_vclzw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
21 | + | ||
22 | +DEF_HELPER_FLAGS_3(mve_vrev16b, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
23 | +DEF_HELPER_FLAGS_3(mve_vrev32b, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
24 | +DEF_HELPER_FLAGS_3(mve_vrev32h, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
25 | +DEF_HELPER_FLAGS_3(mve_vrev64b, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
26 | +DEF_HELPER_FLAGS_3(mve_vrev64h, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
27 | +DEF_HELPER_FLAGS_3(mve_vrev64w, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
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 @@ VLDR_VSTR 1110110 1 a:1 . w:1 . .... ... 111110 ....... @vldr_vstr \ | ||
33 | |||
34 | VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op | ||
35 | VCLZ 1111 1111 1 . 11 .. 00 ... 0 0100 11 . 0 ... 0 @1op | ||
36 | + | ||
37 | +VREV16 1111 1111 1 . 11 .. 00 ... 0 0001 01 . 0 ... 0 @1op | ||
38 | +VREV32 1111 1111 1 . 11 .. 00 ... 0 0000 11 . 0 ... 0 @1op | ||
39 | +VREV64 1111 1111 1 . 11 .. 00 ... 0 0000 01 . 0 ... 0 @1op | ||
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_1OP(vclsw, 4, int32_t, clrsb32) | ||
45 | DO_1OP(vclzb, 1, uint8_t, DO_CLZ_B) | ||
46 | DO_1OP(vclzh, 2, uint16_t, DO_CLZ_H) | ||
47 | DO_1OP(vclzw, 4, uint32_t, clz32) | ||
48 | + | ||
49 | +DO_1OP(vrev16b, 2, uint16_t, bswap16) | ||
50 | +DO_1OP(vrev32b, 4, uint32_t, bswap32) | ||
51 | +DO_1OP(vrev32h, 4, uint32_t, hswap32) | ||
52 | +DO_1OP(vrev64b, 8, uint64_t, bswap64) | ||
53 | +DO_1OP(vrev64h, 8, uint64_t, hswap64) | ||
54 | +DO_1OP(vrev64w, 8, uint64_t, wswap64) | ||
55 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/target/arm/translate-mve.c | ||
58 | +++ b/target/arm/translate-mve.c | ||
59 | @@ -XXX,XX +XXX,XX @@ static bool do_1op(DisasContext *s, arg_1op *a, MVEGenOneOpFn fn) | ||
60 | |||
61 | DO_1OP(VCLZ, vclz) | ||
62 | DO_1OP(VCLS, vcls) | ||
63 | + | ||
64 | +static bool trans_VREV16(DisasContext *s, arg_1op *a) | ||
65 | +{ | ||
66 | + static MVEGenOneOpFn * const fns[] = { | ||
67 | + gen_helper_mve_vrev16b, | ||
68 | + NULL, | ||
69 | + NULL, | ||
70 | + NULL, | ||
71 | + }; | ||
72 | + return do_1op(s, a, fns[a->size]); | ||
73 | +} | ||
74 | + | ||
75 | +static bool trans_VREV32(DisasContext *s, arg_1op *a) | ||
76 | +{ | ||
77 | + static MVEGenOneOpFn * const fns[] = { | ||
78 | + gen_helper_mve_vrev32b, | ||
79 | + gen_helper_mve_vrev32h, | ||
80 | + NULL, | ||
81 | + NULL, | ||
82 | + }; | ||
83 | + return do_1op(s, a, fns[a->size]); | ||
84 | +} | ||
85 | + | ||
86 | +static bool trans_VREV64(DisasContext *s, arg_1op *a) | ||
87 | +{ | ||
88 | + static MVEGenOneOpFn * const fns[] = { | ||
89 | + gen_helper_mve_vrev64b, | ||
90 | + gen_helper_mve_vrev64h, | ||
91 | + gen_helper_mve_vrev64w, | ||
92 | + NULL, | ||
93 | + }; | ||
94 | + return do_1op(s, a, fns[a->size]); | ||
95 | +} | ||
96 | -- | ||
97 | 2.20.1 | ||
98 | |||
99 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE VMVN(register) operation. Note that for | ||
2 | predication this operation is byte-by-byte. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20210617121628.20116-7-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/arm/helper-mve.h | 2 ++ | ||
9 | target/arm/mve.decode | 3 +++ | ||
10 | target/arm/mve_helper.c | 4 ++++ | ||
11 | target/arm/translate-mve.c | 5 +++++ | ||
12 | 4 files changed, 14 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_vrev32h, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
19 | DEF_HELPER_FLAGS_3(mve_vrev64b, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
20 | DEF_HELPER_FLAGS_3(mve_vrev64h, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
21 | DEF_HELPER_FLAGS_3(mve_vrev64w, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
22 | + | ||
23 | +DEF_HELPER_FLAGS_3(mve_vmvn, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
24 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/target/arm/mve.decode | ||
27 | +++ b/target/arm/mve.decode | ||
28 | @@ -XXX,XX +XXX,XX @@ | ||
29 | @vldst_wn ... u:1 ... . . . . l:1 . rn:3 qd:3 . ... .. imm:7 &vldr_vstr | ||
30 | |||
31 | @1op .... .... .... size:2 .. .... .... .... .... &1op qd=%qd qm=%qm | ||
32 | +@1op_nosz .... .... .... .... .... .... .... .... &1op qd=%qd qm=%qm size=0 | ||
33 | |||
34 | # Vector loads and stores | ||
35 | |||
36 | @@ -XXX,XX +XXX,XX @@ VCLZ 1111 1111 1 . 11 .. 00 ... 0 0100 11 . 0 ... 0 @1op | ||
37 | VREV16 1111 1111 1 . 11 .. 00 ... 0 0001 01 . 0 ... 0 @1op | ||
38 | VREV32 1111 1111 1 . 11 .. 00 ... 0 0000 11 . 0 ... 0 @1op | ||
39 | VREV64 1111 1111 1 . 11 .. 00 ... 0 0000 01 . 0 ... 0 @1op | ||
40 | + | ||
41 | +VMVN 1111 1111 1 . 11 00 00 ... 0 0101 11 . 0 ... 0 @1op_nosz | ||
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_1OP(vrev32h, 4, uint32_t, hswap32) | ||
47 | DO_1OP(vrev64b, 8, uint64_t, bswap64) | ||
48 | DO_1OP(vrev64h, 8, uint64_t, hswap64) | ||
49 | DO_1OP(vrev64w, 8, uint64_t, wswap64) | ||
50 | + | ||
51 | +#define DO_NOT(N) (~(N)) | ||
52 | + | ||
53 | +DO_1OP(vmvn, 8, uint64_t, DO_NOT) | ||
54 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
55 | index XXXXXXX..XXXXXXX 100644 | ||
56 | --- a/target/arm/translate-mve.c | ||
57 | +++ b/target/arm/translate-mve.c | ||
58 | @@ -XXX,XX +XXX,XX @@ static bool trans_VREV64(DisasContext *s, arg_1op *a) | ||
59 | }; | ||
60 | return do_1op(s, a, fns[a->size]); | ||
61 | } | ||
62 | + | ||
63 | +static bool trans_VMVN(DisasContext *s, arg_1op *a) | ||
64 | +{ | ||
65 | + return do_1op(s, a, gen_helper_mve_vmvn); | ||
66 | +} | ||
67 | -- | ||
68 | 2.20.1 | ||
69 | |||
70 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE VABS functions (both integer and floating point). | ||
2 | 1 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20210617121628.20116-8-peter.maydell@linaro.org | ||
6 | --- | ||
7 | target/arm/helper-mve.h | 6 ++++++ | ||
8 | target/arm/mve.decode | 3 +++ | ||
9 | target/arm/mve_helper.c | 13 +++++++++++++ | ||
10 | target/arm/translate-mve.c | 15 +++++++++++++++ | ||
11 | 4 files changed, 37 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_3(mve_vrev64h, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
18 | DEF_HELPER_FLAGS_3(mve_vrev64w, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
19 | |||
20 | DEF_HELPER_FLAGS_3(mve_vmvn, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
21 | + | ||
22 | +DEF_HELPER_FLAGS_3(mve_vabsb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
23 | +DEF_HELPER_FLAGS_3(mve_vabsh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
24 | +DEF_HELPER_FLAGS_3(mve_vabsw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
25 | +DEF_HELPER_FLAGS_3(mve_vfabsh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
26 | +DEF_HELPER_FLAGS_3(mve_vfabss, TCG_CALL_NO_WG, void, env, 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 @@ VREV32 1111 1111 1 . 11 .. 00 ... 0 0000 11 . 0 ... 0 @1op | ||
32 | VREV64 1111 1111 1 . 11 .. 00 ... 0 0000 01 . 0 ... 0 @1op | ||
33 | |||
34 | VMVN 1111 1111 1 . 11 00 00 ... 0 0101 11 . 0 ... 0 @1op_nosz | ||
35 | + | ||
36 | +VABS 1111 1111 1 . 11 .. 01 ... 0 0011 01 . 0 ... 0 @1op | ||
37 | +VABS_fp 1111 1111 1 . 11 .. 01 ... 0 0111 01 . 0 ... 0 @1op | ||
38 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/target/arm/mve_helper.c | ||
41 | +++ b/target/arm/mve_helper.c | ||
42 | @@ -XXX,XX +XXX,XX @@ | ||
43 | #include "exec/helper-proto.h" | ||
44 | #include "exec/cpu_ldst.h" | ||
45 | #include "exec/exec-all.h" | ||
46 | +#include "tcg/tcg.h" | ||
47 | |||
48 | static uint16_t mve_element_mask(CPUARMState *env) | ||
49 | { | ||
50 | @@ -XXX,XX +XXX,XX @@ DO_1OP(vrev64w, 8, uint64_t, wswap64) | ||
51 | #define DO_NOT(N) (~(N)) | ||
52 | |||
53 | DO_1OP(vmvn, 8, uint64_t, DO_NOT) | ||
54 | + | ||
55 | +#define DO_ABS(N) ((N) < 0 ? -(N) : (N)) | ||
56 | +#define DO_FABSH(N) ((N) & dup_const(MO_16, 0x7fff)) | ||
57 | +#define DO_FABSS(N) ((N) & dup_const(MO_32, 0x7fffffff)) | ||
58 | + | ||
59 | +DO_1OP(vabsb, 1, int8_t, DO_ABS) | ||
60 | +DO_1OP(vabsh, 2, int16_t, DO_ABS) | ||
61 | +DO_1OP(vabsw, 4, int32_t, DO_ABS) | ||
62 | + | ||
63 | +/* We can do these 64 bits at a time */ | ||
64 | +DO_1OP(vfabsh, 8, uint64_t, DO_FABSH) | ||
65 | +DO_1OP(vfabss, 8, uint64_t, DO_FABSS) | ||
66 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/target/arm/translate-mve.c | ||
69 | +++ b/target/arm/translate-mve.c | ||
70 | @@ -XXX,XX +XXX,XX @@ static bool do_1op(DisasContext *s, arg_1op *a, MVEGenOneOpFn fn) | ||
71 | |||
72 | DO_1OP(VCLZ, vclz) | ||
73 | DO_1OP(VCLS, vcls) | ||
74 | +DO_1OP(VABS, vabs) | ||
75 | |||
76 | static bool trans_VREV16(DisasContext *s, arg_1op *a) | ||
77 | { | ||
78 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMVN(DisasContext *s, arg_1op *a) | ||
79 | { | ||
80 | return do_1op(s, a, gen_helper_mve_vmvn); | ||
81 | } | ||
82 | + | ||
83 | +static bool trans_VABS_fp(DisasContext *s, arg_1op *a) | ||
84 | +{ | ||
85 | + static MVEGenOneOpFn * const fns[] = { | ||
86 | + NULL, | ||
87 | + gen_helper_mve_vfabsh, | ||
88 | + gen_helper_mve_vfabss, | ||
89 | + NULL, | ||
90 | + }; | ||
91 | + if (!dc_isar_feature(aa32_mve_fp, s)) { | ||
92 | + return false; | ||
93 | + } | ||
94 | + return do_1op(s, a, fns[a->size]); | ||
95 | +} | ||
96 | -- | ||
97 | 2.20.1 | ||
98 | |||
99 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE VNEG insn (both integer and floating point forms). | ||
2 | 1 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20210617121628.20116-9-peter.maydell@linaro.org | ||
6 | --- | ||
7 | target/arm/helper-mve.h | 6 ++++++ | ||
8 | target/arm/mve.decode | 2 ++ | ||
9 | target/arm/mve_helper.c | 12 ++++++++++++ | ||
10 | target/arm/translate-mve.c | 15 +++++++++++++++ | ||
11 | 4 files changed, 35 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_3(mve_vabsh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
18 | DEF_HELPER_FLAGS_3(mve_vabsw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
19 | DEF_HELPER_FLAGS_3(mve_vfabsh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
20 | DEF_HELPER_FLAGS_3(mve_vfabss, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
21 | + | ||
22 | +DEF_HELPER_FLAGS_3(mve_vnegb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
23 | +DEF_HELPER_FLAGS_3(mve_vnegh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
24 | +DEF_HELPER_FLAGS_3(mve_vnegw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
25 | +DEF_HELPER_FLAGS_3(mve_vfnegh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
26 | +DEF_HELPER_FLAGS_3(mve_vfnegs, TCG_CALL_NO_WG, void, env, 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 @@ VMVN 1111 1111 1 . 11 00 00 ... 0 0101 11 . 0 ... 0 @1op_nosz | ||
32 | |||
33 | VABS 1111 1111 1 . 11 .. 01 ... 0 0011 01 . 0 ... 0 @1op | ||
34 | VABS_fp 1111 1111 1 . 11 .. 01 ... 0 0111 01 . 0 ... 0 @1op | ||
35 | +VNEG 1111 1111 1 . 11 .. 01 ... 0 0011 11 . 0 ... 0 @1op | ||
36 | +VNEG_fp 1111 1111 1 . 11 .. 01 ... 0 0111 11 . 0 ... 0 @1op | ||
37 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/target/arm/mve_helper.c | ||
40 | +++ b/target/arm/mve_helper.c | ||
41 | @@ -XXX,XX +XXX,XX @@ DO_1OP(vabsw, 4, int32_t, DO_ABS) | ||
42 | /* We can do these 64 bits at a time */ | ||
43 | DO_1OP(vfabsh, 8, uint64_t, DO_FABSH) | ||
44 | DO_1OP(vfabss, 8, uint64_t, DO_FABSS) | ||
45 | + | ||
46 | +#define DO_NEG(N) (-(N)) | ||
47 | +#define DO_FNEGH(N) ((N) ^ dup_const(MO_16, 0x8000)) | ||
48 | +#define DO_FNEGS(N) ((N) ^ dup_const(MO_32, 0x80000000)) | ||
49 | + | ||
50 | +DO_1OP(vnegb, 1, int8_t, DO_NEG) | ||
51 | +DO_1OP(vnegh, 2, int16_t, DO_NEG) | ||
52 | +DO_1OP(vnegw, 4, int32_t, DO_NEG) | ||
53 | + | ||
54 | +/* We can do these 64 bits at a time */ | ||
55 | +DO_1OP(vfnegh, 8, uint64_t, DO_FNEGH) | ||
56 | +DO_1OP(vfnegs, 8, uint64_t, DO_FNEGS) | ||
57 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
58 | index XXXXXXX..XXXXXXX 100644 | ||
59 | --- a/target/arm/translate-mve.c | ||
60 | +++ b/target/arm/translate-mve.c | ||
61 | @@ -XXX,XX +XXX,XX @@ static bool do_1op(DisasContext *s, arg_1op *a, MVEGenOneOpFn fn) | ||
62 | DO_1OP(VCLZ, vclz) | ||
63 | DO_1OP(VCLS, vcls) | ||
64 | DO_1OP(VABS, vabs) | ||
65 | +DO_1OP(VNEG, vneg) | ||
66 | |||
67 | static bool trans_VREV16(DisasContext *s, arg_1op *a) | ||
68 | { | ||
69 | @@ -XXX,XX +XXX,XX @@ static bool trans_VABS_fp(DisasContext *s, arg_1op *a) | ||
70 | } | ||
71 | return do_1op(s, a, fns[a->size]); | ||
72 | } | ||
73 | + | ||
74 | +static bool trans_VNEG_fp(DisasContext *s, arg_1op *a) | ||
75 | +{ | ||
76 | + static MVEGenOneOpFn * const fns[] = { | ||
77 | + NULL, | ||
78 | + gen_helper_mve_vfnegh, | ||
79 | + gen_helper_mve_vfnegs, | ||
80 | + NULL, | ||
81 | + }; | ||
82 | + if (!dc_isar_feature(aa32_mve_fp, s)) { | ||
83 | + return false; | ||
84 | + } | ||
85 | + return do_1op(s, a, fns[a->size]); | ||
86 | +} | ||
87 | -- | ||
88 | 2.20.1 | ||
89 | |||
90 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE VDUP insn, which duplicates a value from | ||
2 | a general-purpose register into every lane of a vector | ||
3 | register (subject to predication). | ||
4 | 1 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20210617121628.20116-11-peter.maydell@linaro.org | ||
8 | --- | ||
9 | target/arm/helper-mve.h | 2 ++ | ||
10 | target/arm/mve.decode | 10 ++++++++++ | ||
11 | target/arm/mve_helper.c | 16 ++++++++++++++++ | ||
12 | target/arm/translate-mve.c | 27 +++++++++++++++++++++++++++ | ||
13 | 4 files changed, 55 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_vstrb_h, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
20 | DEF_HELPER_FLAGS_3(mve_vstrb_w, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
21 | DEF_HELPER_FLAGS_3(mve_vstrh_w, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
22 | |||
23 | +DEF_HELPER_FLAGS_3(mve_vdup, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
24 | + | ||
25 | DEF_HELPER_FLAGS_3(mve_vclsb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
26 | DEF_HELPER_FLAGS_3(mve_vclsh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
27 | DEF_HELPER_FLAGS_3(mve_vclsw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
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 @@ | ||
33 | |||
34 | %qd 22:1 13:3 | ||
35 | %qm 5:1 1:3 | ||
36 | +%qn 7:1 17:3 | ||
37 | |||
38 | &vldr_vstr rn qd imm p a w size l u | ||
39 | &1op qd qm size | ||
40 | @@ -XXX,XX +XXX,XX @@ VABS 1111 1111 1 . 11 .. 01 ... 0 0011 01 . 0 ... 0 @1op | ||
41 | VABS_fp 1111 1111 1 . 11 .. 01 ... 0 0111 01 . 0 ... 0 @1op | ||
42 | VNEG 1111 1111 1 . 11 .. 01 ... 0 0011 11 . 0 ... 0 @1op | ||
43 | VNEG_fp 1111 1111 1 . 11 .. 01 ... 0 0111 11 . 0 ... 0 @1op | ||
44 | + | ||
45 | +&vdup qd rt size | ||
46 | +# Qd is in the fields usually named Qn | ||
47 | +@vdup .... .... . . .. ... . rt:4 .... . . . . .... qd=%qn &vdup | ||
48 | + | ||
49 | +# B and E bits encode size, which we decode here to the usual size values | ||
50 | +VDUP 1110 1110 1 1 10 ... 0 .... 1011 . 0 0 1 0000 @vdup size=0 | ||
51 | +VDUP 1110 1110 1 0 10 ... 0 .... 1011 . 0 1 1 0000 @vdup size=1 | ||
52 | +VDUP 1110 1110 1 0 10 ... 0 .... 1011 . 0 0 1 0000 @vdup size=2 | ||
53 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/target/arm/mve_helper.c | ||
56 | +++ b/target/arm/mve_helper.c | ||
57 | @@ -XXX,XX +XXX,XX @@ static void mergemask_sq(int64_t *d, int64_t r, uint16_t mask) | ||
58 | uint64_t *: mergemask_uq, \ | ||
59 | int64_t *: mergemask_sq)(D, R, M) | ||
60 | |||
61 | +void HELPER(mve_vdup)(CPUARMState *env, void *vd, uint32_t val) | ||
62 | +{ | ||
63 | + /* | ||
64 | + * The generated code already replicated an 8 or 16 bit constant | ||
65 | + * into the 32-bit value, so we only need to write the 32-bit | ||
66 | + * value to all elements of the Qreg, allowing for predication. | ||
67 | + */ | ||
68 | + uint32_t *d = vd; | ||
69 | + uint16_t mask = mve_element_mask(env); | ||
70 | + unsigned e; | ||
71 | + for (e = 0; e < 16 / 4; e++, mask >>= 4) { | ||
72 | + mergemask(&d[H4(e)], val, mask); | ||
73 | + } | ||
74 | + mve_advance_vpt(env); | ||
75 | +} | ||
76 | + | ||
77 | #define DO_1OP(OP, ESIZE, TYPE, FN) \ | ||
78 | void HELPER(mve_##OP)(CPUARMState *env, void *vd, void *vm) \ | ||
79 | { \ | ||
80 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
81 | index XXXXXXX..XXXXXXX 100644 | ||
82 | --- a/target/arm/translate-mve.c | ||
83 | +++ b/target/arm/translate-mve.c | ||
84 | @@ -XXX,XX +XXX,XX @@ DO_VLDST_WIDE_NARROW(VLDSTB_H, vldrb_sh, vldrb_uh, vstrb_h) | ||
85 | DO_VLDST_WIDE_NARROW(VLDSTB_W, vldrb_sw, vldrb_uw, vstrb_w) | ||
86 | DO_VLDST_WIDE_NARROW(VLDSTH_W, vldrh_sw, vldrh_uw, vstrh_w) | ||
87 | |||
88 | +static bool trans_VDUP(DisasContext *s, arg_VDUP *a) | ||
89 | +{ | ||
90 | + TCGv_ptr qd; | ||
91 | + TCGv_i32 rt; | ||
92 | + | ||
93 | + if (!dc_isar_feature(aa32_mve, s) || | ||
94 | + !mve_check_qreg_bank(s, a->qd)) { | ||
95 | + return false; | ||
96 | + } | ||
97 | + if (a->rt == 13 || a->rt == 15) { | ||
98 | + /* UNPREDICTABLE; we choose to UNDEF */ | ||
99 | + return false; | ||
100 | + } | ||
101 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
102 | + return true; | ||
103 | + } | ||
104 | + | ||
105 | + qd = mve_qreg_ptr(a->qd); | ||
106 | + rt = load_reg(s, a->rt); | ||
107 | + tcg_gen_dup_i32(a->size, rt, rt); | ||
108 | + gen_helper_mve_vdup(cpu_env, qd, rt); | ||
109 | + tcg_temp_free_ptr(qd); | ||
110 | + tcg_temp_free_i32(rt); | ||
111 | + mve_update_eci(s); | ||
112 | + return true; | ||
113 | +} | ||
114 | + | ||
115 | static bool do_1op(DisasContext *s, arg_1op *a, MVEGenOneOpFn fn) | ||
116 | { | ||
117 | TCGv_ptr qd, qm; | ||
118 | -- | ||
119 | 2.20.1 | ||
120 | |||
121 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE vector logical operations operating | ||
2 | on two registers. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20210617121628.20116-12-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/arm/helper-mve.h | 6 ++++++ | ||
9 | target/arm/mve.decode | 9 +++++++++ | ||
10 | target/arm/mve_helper.c | 26 ++++++++++++++++++++++++++ | ||
11 | target/arm/translate-mve.c | 37 +++++++++++++++++++++++++++++++++++++ | ||
12 | 4 files changed, 78 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_vnegh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
19 | 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_4(mve_vand, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
24 | +DEF_HELPER_FLAGS_4(mve_vbic, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
25 | +DEF_HELPER_FLAGS_4(mve_vorr, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
26 | +DEF_HELPER_FLAGS_4(mve_vorn, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
27 | +DEF_HELPER_FLAGS_4(mve_veor, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
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 @@ | ||
33 | |||
34 | &vldr_vstr rn qd imm p a w size l u | ||
35 | &1op qd qm size | ||
36 | +&2op qd qm qn size | ||
37 | |||
38 | @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 | ||
39 | # Note that both Rn and Qd are 3 bits only (no D bit) | ||
40 | @@ -XXX,XX +XXX,XX @@ | ||
41 | |||
42 | @1op .... .... .... size:2 .. .... .... .... .... &1op qd=%qd qm=%qm | ||
43 | @1op_nosz .... .... .... .... .... .... .... .... &1op qd=%qd qm=%qm size=0 | ||
44 | +@2op_nosz .... .... .... .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn size=0 | ||
45 | |||
46 | # Vector loads and stores | ||
47 | |||
48 | @@ -XXX,XX +XXX,XX @@ VLDR_VSTR 1110110 1 a:1 . w:1 . .... ... 111101 ....... @vldr_vstr \ | ||
49 | VLDR_VSTR 1110110 1 a:1 . w:1 . .... ... 111110 ....... @vldr_vstr \ | ||
50 | size=2 p=1 | ||
51 | |||
52 | +# Vector 2-op | ||
53 | +VAND 1110 1111 0 . 00 ... 0 ... 0 0001 . 1 . 1 ... 0 @2op_nosz | ||
54 | +VBIC 1110 1111 0 . 01 ... 0 ... 0 0001 . 1 . 1 ... 0 @2op_nosz | ||
55 | +VORR 1110 1111 0 . 10 ... 0 ... 0 0001 . 1 . 1 ... 0 @2op_nosz | ||
56 | +VORN 1110 1111 0 . 11 ... 0 ... 0 0001 . 1 . 1 ... 0 @2op_nosz | ||
57 | +VEOR 1111 1111 0 . 00 ... 0 ... 0 0001 . 1 . 1 ... 0 @2op_nosz | ||
58 | + | ||
59 | # Vector miscellaneous | ||
60 | |||
61 | VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op | ||
62 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
63 | index XXXXXXX..XXXXXXX 100644 | ||
64 | --- a/target/arm/mve_helper.c | ||
65 | +++ b/target/arm/mve_helper.c | ||
66 | @@ -XXX,XX +XXX,XX @@ DO_1OP(vnegw, 4, int32_t, DO_NEG) | ||
67 | /* We can do these 64 bits at a time */ | ||
68 | DO_1OP(vfnegh, 8, uint64_t, DO_FNEGH) | ||
69 | DO_1OP(vfnegs, 8, uint64_t, DO_FNEGS) | ||
70 | + | ||
71 | +#define DO_2OP(OP, ESIZE, TYPE, FN) \ | ||
72 | + void HELPER(glue(mve_, OP))(CPUARMState *env, \ | ||
73 | + void *vd, void *vn, void *vm) \ | ||
74 | + { \ | ||
75 | + TYPE *d = vd, *n = vn, *m = vm; \ | ||
76 | + uint16_t mask = mve_element_mask(env); \ | ||
77 | + unsigned e; \ | ||
78 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
79 | + mergemask(&d[H##ESIZE(e)], \ | ||
80 | + FN(n[H##ESIZE(e)], m[H##ESIZE(e)]), mask); \ | ||
81 | + } \ | ||
82 | + mve_advance_vpt(env); \ | ||
83 | + } | ||
84 | + | ||
85 | +#define DO_AND(N, M) ((N) & (M)) | ||
86 | +#define DO_BIC(N, M) ((N) & ~(M)) | ||
87 | +#define DO_ORR(N, M) ((N) | (M)) | ||
88 | +#define DO_ORN(N, M) ((N) | ~(M)) | ||
89 | +#define DO_EOR(N, M) ((N) ^ (M)) | ||
90 | + | ||
91 | +DO_2OP(vand, 8, uint64_t, DO_AND) | ||
92 | +DO_2OP(vbic, 8, uint64_t, DO_BIC) | ||
93 | +DO_2OP(vorr, 8, uint64_t, DO_ORR) | ||
94 | +DO_2OP(vorn, 8, uint64_t, DO_ORN) | ||
95 | +DO_2OP(veor, 8, uint64_t, DO_EOR) | ||
96 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
97 | index XXXXXXX..XXXXXXX 100644 | ||
98 | --- a/target/arm/translate-mve.c | ||
99 | +++ b/target/arm/translate-mve.c | ||
100 | @@ -XXX,XX +XXX,XX @@ | ||
101 | |||
102 | typedef void MVEGenLdStFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
103 | typedef void MVEGenOneOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
104 | +typedef void MVEGenTwoOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
105 | |||
106 | /* Return the offset of a Qn register (same semantics as aa32_vfp_qreg()) */ | ||
107 | static inline long mve_qreg_offset(unsigned reg) | ||
108 | @@ -XXX,XX +XXX,XX @@ static bool trans_VNEG_fp(DisasContext *s, arg_1op *a) | ||
109 | } | ||
110 | return do_1op(s, a, fns[a->size]); | ||
111 | } | ||
112 | + | ||
113 | +static bool do_2op(DisasContext *s, arg_2op *a, MVEGenTwoOpFn fn) | ||
114 | +{ | ||
115 | + TCGv_ptr qd, qn, qm; | ||
116 | + | ||
117 | + if (!dc_isar_feature(aa32_mve, s) || | ||
118 | + !mve_check_qreg_bank(s, a->qd | a->qn | a->qm) || | ||
119 | + !fn) { | ||
120 | + return false; | ||
121 | + } | ||
122 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
123 | + return true; | ||
124 | + } | ||
125 | + | ||
126 | + qd = mve_qreg_ptr(a->qd); | ||
127 | + qn = mve_qreg_ptr(a->qn); | ||
128 | + qm = mve_qreg_ptr(a->qm); | ||
129 | + fn(cpu_env, qd, qn, qm); | ||
130 | + tcg_temp_free_ptr(qd); | ||
131 | + tcg_temp_free_ptr(qn); | ||
132 | + tcg_temp_free_ptr(qm); | ||
133 | + mve_update_eci(s); | ||
134 | + return true; | ||
135 | +} | ||
136 | + | ||
137 | +#define DO_LOGIC(INSN, HELPER) \ | ||
138 | + static bool trans_##INSN(DisasContext *s, arg_2op *a) \ | ||
139 | + { \ | ||
140 | + return do_2op(s, a, HELPER); \ | ||
141 | + } | ||
142 | + | ||
143 | +DO_LOGIC(VAND, gen_helper_mve_vand) | ||
144 | +DO_LOGIC(VBIC, gen_helper_mve_vbic) | ||
145 | +DO_LOGIC(VORR, gen_helper_mve_vorr) | ||
146 | +DO_LOGIC(VORN, gen_helper_mve_vorn) | ||
147 | +DO_LOGIC(VEOR, gen_helper_mve_veor) | ||
148 | -- | ||
149 | 2.20.1 | ||
150 | |||
151 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE VMULH insn, which performs a vector | ||
2 | multiply and returns the high half of the result. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20210617121628.20116-14-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/arm/helper-mve.h | 7 +++++++ | ||
9 | target/arm/mve.decode | 3 +++ | ||
10 | target/arm/mve_helper.c | 26 ++++++++++++++++++++++++++ | ||
11 | target/arm/translate-mve.c | 2 ++ | ||
12 | 4 files changed, 38 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_4(mve_vsubw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
19 | DEF_HELPER_FLAGS_4(mve_vmulb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
20 | DEF_HELPER_FLAGS_4(mve_vmulh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
21 | DEF_HELPER_FLAGS_4(mve_vmulw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
22 | + | ||
23 | +DEF_HELPER_FLAGS_4(mve_vmulhsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
24 | +DEF_HELPER_FLAGS_4(mve_vmulhsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
25 | +DEF_HELPER_FLAGS_4(mve_vmulhsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
26 | +DEF_HELPER_FLAGS_4(mve_vmulhub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
27 | +DEF_HELPER_FLAGS_4(mve_vmulhuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
28 | +DEF_HELPER_FLAGS_4(mve_vmulhuw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
29 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/target/arm/mve.decode | ||
32 | +++ b/target/arm/mve.decode | ||
33 | @@ -XXX,XX +XXX,XX @@ VADD 1110 1111 0 . .. ... 0 ... 0 1000 . 1 . 0 ... 0 @2op | ||
34 | VSUB 1111 1111 0 . .. ... 0 ... 0 1000 . 1 . 0 ... 0 @2op | ||
35 | VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op | ||
36 | |||
37 | +VMULH_S 111 0 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op | ||
38 | +VMULH_U 111 1 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op | ||
39 | + | ||
40 | # Vector miscellaneous | ||
41 | |||
42 | VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op | ||
43 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/target/arm/mve_helper.c | ||
46 | +++ b/target/arm/mve_helper.c | ||
47 | @@ -XXX,XX +XXX,XX @@ DO_2OP(veor, 8, uint64_t, DO_EOR) | ||
48 | DO_2OP_U(vadd, DO_ADD) | ||
49 | DO_2OP_U(vsub, DO_SUB) | ||
50 | DO_2OP_U(vmul, DO_MUL) | ||
51 | + | ||
52 | +/* | ||
53 | + * Because the computation type is at least twice as large as required, | ||
54 | + * these work for both signed and unsigned source types. | ||
55 | + */ | ||
56 | +static inline uint8_t do_mulh_b(int32_t n, int32_t m) | ||
57 | +{ | ||
58 | + return (n * m) >> 8; | ||
59 | +} | ||
60 | + | ||
61 | +static inline uint16_t do_mulh_h(int32_t n, int32_t m) | ||
62 | +{ | ||
63 | + return (n * m) >> 16; | ||
64 | +} | ||
65 | + | ||
66 | +static inline uint32_t do_mulh_w(int64_t n, int64_t m) | ||
67 | +{ | ||
68 | + return (n * m) >> 32; | ||
69 | +} | ||
70 | + | ||
71 | +DO_2OP(vmulhsb, 1, int8_t, do_mulh_b) | ||
72 | +DO_2OP(vmulhsh, 2, int16_t, do_mulh_h) | ||
73 | +DO_2OP(vmulhsw, 4, int32_t, do_mulh_w) | ||
74 | +DO_2OP(vmulhub, 1, uint8_t, do_mulh_b) | ||
75 | +DO_2OP(vmulhuh, 2, uint16_t, do_mulh_h) | ||
76 | +DO_2OP(vmulhuw, 4, uint32_t, do_mulh_w) | ||
77 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
78 | index XXXXXXX..XXXXXXX 100644 | ||
79 | --- a/target/arm/translate-mve.c | ||
80 | +++ b/target/arm/translate-mve.c | ||
81 | @@ -XXX,XX +XXX,XX @@ DO_LOGIC(VEOR, gen_helper_mve_veor) | ||
82 | DO_2OP(VADD, vadd) | ||
83 | DO_2OP(VSUB, vsub) | ||
84 | DO_2OP(VMUL, vmul) | ||
85 | +DO_2OP(VMULH_S, vmulhs) | ||
86 | +DO_2OP(VMULH_U, vmulhu) | ||
87 | -- | ||
88 | 2.20.1 | ||
89 | |||
90 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE VRMULH insn, which performs a rounding multiply | ||
2 | and then returns the high half. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20210617121628.20116-15-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/arm/helper-mve.h | 7 +++++++ | ||
9 | target/arm/mve.decode | 3 +++ | ||
10 | target/arm/mve_helper.c | 22 ++++++++++++++++++++++ | ||
11 | target/arm/translate-mve.c | 2 ++ | ||
12 | 4 files changed, 34 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_4(mve_vmulhsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
19 | DEF_HELPER_FLAGS_4(mve_vmulhub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
20 | DEF_HELPER_FLAGS_4(mve_vmulhuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
21 | DEF_HELPER_FLAGS_4(mve_vmulhuw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
22 | + | ||
23 | +DEF_HELPER_FLAGS_4(mve_vrmulhsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
24 | +DEF_HELPER_FLAGS_4(mve_vrmulhsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
25 | +DEF_HELPER_FLAGS_4(mve_vrmulhsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
26 | +DEF_HELPER_FLAGS_4(mve_vrmulhub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
27 | +DEF_HELPER_FLAGS_4(mve_vrmulhuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
28 | +DEF_HELPER_FLAGS_4(mve_vrmulhuw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
29 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/target/arm/mve.decode | ||
32 | +++ b/target/arm/mve.decode | ||
33 | @@ -XXX,XX +XXX,XX @@ VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op | ||
34 | VMULH_S 111 0 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op | ||
35 | VMULH_U 111 1 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op | ||
36 | |||
37 | +VRMULH_S 111 0 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op | ||
38 | +VRMULH_U 111 1 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op | ||
39 | + | ||
40 | # Vector miscellaneous | ||
41 | |||
42 | VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op | ||
43 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/target/arm/mve_helper.c | ||
46 | +++ b/target/arm/mve_helper.c | ||
47 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t do_mulh_w(int64_t n, int64_t m) | ||
48 | return (n * m) >> 32; | ||
49 | } | ||
50 | |||
51 | +static inline uint8_t do_rmulh_b(int32_t n, int32_t m) | ||
52 | +{ | ||
53 | + return (n * m + (1U << 7)) >> 8; | ||
54 | +} | ||
55 | + | ||
56 | +static inline uint16_t do_rmulh_h(int32_t n, int32_t m) | ||
57 | +{ | ||
58 | + return (n * m + (1U << 15)) >> 16; | ||
59 | +} | ||
60 | + | ||
61 | +static inline uint32_t do_rmulh_w(int64_t n, int64_t m) | ||
62 | +{ | ||
63 | + return (n * m + (1U << 31)) >> 32; | ||
64 | +} | ||
65 | + | ||
66 | DO_2OP(vmulhsb, 1, int8_t, do_mulh_b) | ||
67 | DO_2OP(vmulhsh, 2, int16_t, do_mulh_h) | ||
68 | DO_2OP(vmulhsw, 4, int32_t, do_mulh_w) | ||
69 | DO_2OP(vmulhub, 1, uint8_t, do_mulh_b) | ||
70 | DO_2OP(vmulhuh, 2, uint16_t, do_mulh_h) | ||
71 | DO_2OP(vmulhuw, 4, uint32_t, do_mulh_w) | ||
72 | + | ||
73 | +DO_2OP(vrmulhsb, 1, int8_t, do_rmulh_b) | ||
74 | +DO_2OP(vrmulhsh, 2, int16_t, do_rmulh_h) | ||
75 | +DO_2OP(vrmulhsw, 4, int32_t, do_rmulh_w) | ||
76 | +DO_2OP(vrmulhub, 1, uint8_t, do_rmulh_b) | ||
77 | +DO_2OP(vrmulhuh, 2, uint16_t, do_rmulh_h) | ||
78 | +DO_2OP(vrmulhuw, 4, uint32_t, do_rmulh_w) | ||
79 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
80 | index XXXXXXX..XXXXXXX 100644 | ||
81 | --- a/target/arm/translate-mve.c | ||
82 | +++ b/target/arm/translate-mve.c | ||
83 | @@ -XXX,XX +XXX,XX @@ DO_2OP(VSUB, vsub) | ||
84 | DO_2OP(VMUL, vmul) | ||
85 | DO_2OP(VMULH_S, vmulhs) | ||
86 | DO_2OP(VMULH_U, vmulhu) | ||
87 | +DO_2OP(VRMULH_S, vrmulhs) | ||
88 | +DO_2OP(VRMULH_U, vrmulhu) | ||
89 | -- | ||
90 | 2.20.1 | ||
91 | |||
92 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE VMAX and VMIN insns. | ||
2 | 1 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20210617121628.20116-16-peter.maydell@linaro.org | ||
6 | --- | ||
7 | target/arm/helper-mve.h | 14 ++++++++++++++ | ||
8 | target/arm/mve.decode | 5 +++++ | ||
9 | target/arm/mve_helper.c | 14 ++++++++++++++ | ||
10 | target/arm/translate-mve.c | 4 ++++ | ||
11 | 4 files changed, 37 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_vrmulhsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
18 | DEF_HELPER_FLAGS_4(mve_vrmulhub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
19 | DEF_HELPER_FLAGS_4(mve_vrmulhuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
20 | DEF_HELPER_FLAGS_4(mve_vrmulhuw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
21 | + | ||
22 | +DEF_HELPER_FLAGS_4(mve_vmaxsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
23 | +DEF_HELPER_FLAGS_4(mve_vmaxsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
24 | +DEF_HELPER_FLAGS_4(mve_vmaxsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
25 | +DEF_HELPER_FLAGS_4(mve_vmaxub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
26 | +DEF_HELPER_FLAGS_4(mve_vmaxuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
27 | +DEF_HELPER_FLAGS_4(mve_vmaxuw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
28 | + | ||
29 | +DEF_HELPER_FLAGS_4(mve_vminsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
30 | +DEF_HELPER_FLAGS_4(mve_vminsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
31 | +DEF_HELPER_FLAGS_4(mve_vminsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
32 | +DEF_HELPER_FLAGS_4(mve_vminub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
33 | +DEF_HELPER_FLAGS_4(mve_vminuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
34 | +DEF_HELPER_FLAGS_4(mve_vminuw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
35 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/target/arm/mve.decode | ||
38 | +++ b/target/arm/mve.decode | ||
39 | @@ -XXX,XX +XXX,XX @@ VMULH_U 111 1 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op | ||
40 | VRMULH_S 111 0 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op | ||
41 | VRMULH_U 111 1 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op | ||
42 | |||
43 | +VMAX_S 111 0 1111 0 . .. ... 0 ... 0 0110 . 1 . 0 ... 0 @2op | ||
44 | +VMAX_U 111 1 1111 0 . .. ... 0 ... 0 0110 . 1 . 0 ... 0 @2op | ||
45 | +VMIN_S 111 0 1111 0 . .. ... 0 ... 0 0110 . 1 . 1 ... 0 @2op | ||
46 | +VMIN_U 111 1 1111 0 . .. ... 0 ... 0 0110 . 1 . 1 ... 0 @2op | ||
47 | + | ||
48 | # Vector miscellaneous | ||
49 | |||
50 | VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op | ||
51 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/target/arm/mve_helper.c | ||
54 | +++ b/target/arm/mve_helper.c | ||
55 | @@ -XXX,XX +XXX,XX @@ DO_1OP(vfnegs, 8, uint64_t, DO_FNEGS) | ||
56 | DO_2OP(OP##h, 2, uint16_t, FN) \ | ||
57 | DO_2OP(OP##w, 4, uint32_t, FN) | ||
58 | |||
59 | +/* provide signed 2-op helpers for all sizes */ | ||
60 | +#define DO_2OP_S(OP, FN) \ | ||
61 | + DO_2OP(OP##b, 1, int8_t, FN) \ | ||
62 | + DO_2OP(OP##h, 2, int16_t, FN) \ | ||
63 | + DO_2OP(OP##w, 4, int32_t, FN) | ||
64 | + | ||
65 | #define DO_AND(N, M) ((N) & (M)) | ||
66 | #define DO_BIC(N, M) ((N) & ~(M)) | ||
67 | #define DO_ORR(N, M) ((N) | (M)) | ||
68 | @@ -XXX,XX +XXX,XX @@ DO_2OP(vrmulhsw, 4, int32_t, do_rmulh_w) | ||
69 | DO_2OP(vrmulhub, 1, uint8_t, do_rmulh_b) | ||
70 | DO_2OP(vrmulhuh, 2, uint16_t, do_rmulh_h) | ||
71 | DO_2OP(vrmulhuw, 4, uint32_t, do_rmulh_w) | ||
72 | + | ||
73 | +#define DO_MAX(N, M) ((N) >= (M) ? (N) : (M)) | ||
74 | +#define DO_MIN(N, M) ((N) >= (M) ? (M) : (N)) | ||
75 | + | ||
76 | +DO_2OP_S(vmaxs, DO_MAX) | ||
77 | +DO_2OP_U(vmaxu, DO_MAX) | ||
78 | +DO_2OP_S(vmins, DO_MIN) | ||
79 | +DO_2OP_U(vminu, DO_MIN) | ||
80 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
81 | index XXXXXXX..XXXXXXX 100644 | ||
82 | --- a/target/arm/translate-mve.c | ||
83 | +++ b/target/arm/translate-mve.c | ||
84 | @@ -XXX,XX +XXX,XX @@ DO_2OP(VMULH_S, vmulhs) | ||
85 | DO_2OP(VMULH_U, vmulhu) | ||
86 | DO_2OP(VRMULH_S, vrmulhs) | ||
87 | DO_2OP(VRMULH_U, vrmulhu) | ||
88 | +DO_2OP(VMAX_S, vmaxs) | ||
89 | +DO_2OP(VMAX_U, vmaxu) | ||
90 | +DO_2OP(VMIN_S, vmins) | ||
91 | +DO_2OP(VMIN_U, vminu) | ||
92 | -- | ||
93 | 2.20.1 | ||
94 | |||
95 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE VABD insn. | ||
2 | 1 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20210617121628.20116-17-peter.maydell@linaro.org | ||
6 | --- | ||
7 | target/arm/helper-mve.h | 7 +++++++ | ||
8 | target/arm/mve.decode | 3 +++ | ||
9 | target/arm/mve_helper.c | 5 +++++ | ||
10 | target/arm/translate-mve.c | 2 ++ | ||
11 | 4 files changed, 17 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_vminsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
18 | DEF_HELPER_FLAGS_4(mve_vminub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
19 | DEF_HELPER_FLAGS_4(mve_vminuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
20 | DEF_HELPER_FLAGS_4(mve_vminuw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
21 | + | ||
22 | +DEF_HELPER_FLAGS_4(mve_vabdsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
23 | +DEF_HELPER_FLAGS_4(mve_vabdsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
24 | +DEF_HELPER_FLAGS_4(mve_vabdsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
25 | +DEF_HELPER_FLAGS_4(mve_vabdub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
26 | +DEF_HELPER_FLAGS_4(mve_vabduh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
27 | +DEF_HELPER_FLAGS_4(mve_vabduw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
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 @@ VMAX_U 111 1 1111 0 . .. ... 0 ... 0 0110 . 1 . 0 ... 0 @2op | ||
33 | VMIN_S 111 0 1111 0 . .. ... 0 ... 0 0110 . 1 . 1 ... 0 @2op | ||
34 | VMIN_U 111 1 1111 0 . .. ... 0 ... 0 0110 . 1 . 1 ... 0 @2op | ||
35 | |||
36 | +VABD_S 111 0 1111 0 . .. ... 0 ... 0 0111 . 1 . 0 ... 0 @2op | ||
37 | +VABD_U 111 1 1111 0 . .. ... 0 ... 0 0111 . 1 . 0 ... 0 @2op | ||
38 | + | ||
39 | # Vector miscellaneous | ||
40 | |||
41 | VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op | ||
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_2OP_S(vmaxs, DO_MAX) | ||
47 | DO_2OP_U(vmaxu, DO_MAX) | ||
48 | DO_2OP_S(vmins, DO_MIN) | ||
49 | DO_2OP_U(vminu, DO_MIN) | ||
50 | + | ||
51 | +#define DO_ABD(N, M) ((N) >= (M) ? (N) - (M) : (M) - (N)) | ||
52 | + | ||
53 | +DO_2OP_S(vabds, DO_ABD) | ||
54 | +DO_2OP_U(vabdu, DO_ABD) | ||
55 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/target/arm/translate-mve.c | ||
58 | +++ b/target/arm/translate-mve.c | ||
59 | @@ -XXX,XX +XXX,XX @@ DO_2OP(VMAX_S, vmaxs) | ||
60 | DO_2OP(VMAX_U, vmaxu) | ||
61 | DO_2OP(VMIN_S, vmins) | ||
62 | DO_2OP(VMIN_U, vminu) | ||
63 | +DO_2OP(VABD_S, vabds) | ||
64 | +DO_2OP(VABD_U, vabdu) | ||
65 | -- | ||
66 | 2.20.1 | ||
67 | |||
68 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement MVE VHADD and VHSUB insns, which perform an addition | ||
2 | or subtraction and then halve the result. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20210617121628.20116-18-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/arm/helper-mve.h | 14 ++++++++++++++ | ||
9 | target/arm/mve.decode | 5 +++++ | ||
10 | target/arm/mve_helper.c | 25 +++++++++++++++++++++++++ | ||
11 | target/arm/translate-mve.c | 4 ++++ | ||
12 | 4 files changed, 48 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_4(mve_vabdsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
19 | DEF_HELPER_FLAGS_4(mve_vabdub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
20 | DEF_HELPER_FLAGS_4(mve_vabduh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
21 | DEF_HELPER_FLAGS_4(mve_vabduw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
22 | + | ||
23 | +DEF_HELPER_FLAGS_4(mve_vhaddsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
24 | +DEF_HELPER_FLAGS_4(mve_vhaddsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
25 | +DEF_HELPER_FLAGS_4(mve_vhaddsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
26 | +DEF_HELPER_FLAGS_4(mve_vhaddub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
27 | +DEF_HELPER_FLAGS_4(mve_vhadduh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
28 | +DEF_HELPER_FLAGS_4(mve_vhadduw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
29 | + | ||
30 | +DEF_HELPER_FLAGS_4(mve_vhsubsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
31 | +DEF_HELPER_FLAGS_4(mve_vhsubsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
32 | +DEF_HELPER_FLAGS_4(mve_vhsubsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
33 | +DEF_HELPER_FLAGS_4(mve_vhsubub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
34 | +DEF_HELPER_FLAGS_4(mve_vhsubuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
35 | +DEF_HELPER_FLAGS_4(mve_vhsubuw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
36 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/target/arm/mve.decode | ||
39 | +++ b/target/arm/mve.decode | ||
40 | @@ -XXX,XX +XXX,XX @@ VMIN_U 111 1 1111 0 . .. ... 0 ... 0 0110 . 1 . 1 ... 0 @2op | ||
41 | VABD_S 111 0 1111 0 . .. ... 0 ... 0 0111 . 1 . 0 ... 0 @2op | ||
42 | VABD_U 111 1 1111 0 . .. ... 0 ... 0 0111 . 1 . 0 ... 0 @2op | ||
43 | |||
44 | +VHADD_S 111 0 1111 0 . .. ... 0 ... 0 0000 . 1 . 0 ... 0 @2op | ||
45 | +VHADD_U 111 1 1111 0 . .. ... 0 ... 0 0000 . 1 . 0 ... 0 @2op | ||
46 | +VHSUB_S 111 0 1111 0 . .. ... 0 ... 0 0010 . 1 . 0 ... 0 @2op | ||
47 | +VHSUB_U 111 1 1111 0 . .. ... 0 ... 0 0010 . 1 . 0 ... 0 @2op | ||
48 | + | ||
49 | # Vector miscellaneous | ||
50 | |||
51 | VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op | ||
52 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | --- a/target/arm/mve_helper.c | ||
55 | +++ b/target/arm/mve_helper.c | ||
56 | @@ -XXX,XX +XXX,XX @@ DO_2OP_U(vminu, DO_MIN) | ||
57 | |||
58 | DO_2OP_S(vabds, DO_ABD) | ||
59 | DO_2OP_U(vabdu, DO_ABD) | ||
60 | + | ||
61 | +static inline uint32_t do_vhadd_u(uint32_t n, uint32_t m) | ||
62 | +{ | ||
63 | + return ((uint64_t)n + m) >> 1; | ||
64 | +} | ||
65 | + | ||
66 | +static inline int32_t do_vhadd_s(int32_t n, int32_t m) | ||
67 | +{ | ||
68 | + return ((int64_t)n + m) >> 1; | ||
69 | +} | ||
70 | + | ||
71 | +static inline uint32_t do_vhsub_u(uint32_t n, uint32_t m) | ||
72 | +{ | ||
73 | + return ((uint64_t)n - m) >> 1; | ||
74 | +} | ||
75 | + | ||
76 | +static inline int32_t do_vhsub_s(int32_t n, int32_t m) | ||
77 | +{ | ||
78 | + return ((int64_t)n - m) >> 1; | ||
79 | +} | ||
80 | + | ||
81 | +DO_2OP_S(vhadds, do_vhadd_s) | ||
82 | +DO_2OP_U(vhaddu, do_vhadd_u) | ||
83 | +DO_2OP_S(vhsubs, do_vhsub_s) | ||
84 | +DO_2OP_U(vhsubu, do_vhsub_u) | ||
85 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
86 | index XXXXXXX..XXXXXXX 100644 | ||
87 | --- a/target/arm/translate-mve.c | ||
88 | +++ b/target/arm/translate-mve.c | ||
89 | @@ -XXX,XX +XXX,XX @@ DO_2OP(VMIN_S, vmins) | ||
90 | DO_2OP(VMIN_U, vminu) | ||
91 | DO_2OP(VABD_S, vabds) | ||
92 | DO_2OP(VABD_U, vabdu) | ||
93 | +DO_2OP(VHADD_S, vhadds) | ||
94 | +DO_2OP(VHADD_U, vhaddu) | ||
95 | +DO_2OP(VHSUB_S, vhsubs) | ||
96 | +DO_2OP(VHSUB_U, vhsubu) | ||
97 | -- | ||
98 | 2.20.1 | ||
99 | |||
100 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE VMULL insn, which multiplies two single | ||
2 | width integer elements to produce a double width result. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20210617121628.20116-19-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/arm/helper-mve.h | 14 ++++++++++++++ | ||
9 | target/arm/mve.decode | 5 +++++ | ||
10 | target/arm/mve_helper.c | 34 ++++++++++++++++++++++++++++++++++ | ||
11 | target/arm/translate-mve.c | 4 ++++ | ||
12 | 4 files changed, 57 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_4(mve_vhsubsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
19 | DEF_HELPER_FLAGS_4(mve_vhsubub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
20 | DEF_HELPER_FLAGS_4(mve_vhsubuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
21 | DEF_HELPER_FLAGS_4(mve_vhsubuw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
22 | + | ||
23 | +DEF_HELPER_FLAGS_4(mve_vmullbsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
24 | +DEF_HELPER_FLAGS_4(mve_vmullbsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
25 | +DEF_HELPER_FLAGS_4(mve_vmullbsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
26 | +DEF_HELPER_FLAGS_4(mve_vmullbub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
27 | +DEF_HELPER_FLAGS_4(mve_vmullbuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
28 | +DEF_HELPER_FLAGS_4(mve_vmullbuw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
29 | + | ||
30 | +DEF_HELPER_FLAGS_4(mve_vmulltsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
31 | +DEF_HELPER_FLAGS_4(mve_vmulltsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
32 | +DEF_HELPER_FLAGS_4(mve_vmulltsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
33 | +DEF_HELPER_FLAGS_4(mve_vmulltub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
34 | +DEF_HELPER_FLAGS_4(mve_vmulltuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
35 | +DEF_HELPER_FLAGS_4(mve_vmulltuw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
36 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/target/arm/mve.decode | ||
39 | +++ b/target/arm/mve.decode | ||
40 | @@ -XXX,XX +XXX,XX @@ VHADD_U 111 1 1111 0 . .. ... 0 ... 0 0000 . 1 . 0 ... 0 @2op | ||
41 | VHSUB_S 111 0 1111 0 . .. ... 0 ... 0 0010 . 1 . 0 ... 0 @2op | ||
42 | VHSUB_U 111 1 1111 0 . .. ... 0 ... 0 0010 . 1 . 0 ... 0 @2op | ||
43 | |||
44 | +VMULL_BS 111 0 1110 0 . .. ... 1 ... 0 1110 . 0 . 0 ... 0 @2op | ||
45 | +VMULL_BU 111 1 1110 0 . .. ... 1 ... 0 1110 . 0 . 0 ... 0 @2op | ||
46 | +VMULL_TS 111 0 1110 0 . .. ... 1 ... 1 1110 . 0 . 0 ... 0 @2op | ||
47 | +VMULL_TU 111 1 1110 0 . .. ... 1 ... 1 1110 . 0 . 0 ... 0 @2op | ||
48 | + | ||
49 | # Vector miscellaneous | ||
50 | |||
51 | VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op | ||
52 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | --- a/target/arm/mve_helper.c | ||
55 | +++ b/target/arm/mve_helper.c | ||
56 | @@ -XXX,XX +XXX,XX @@ DO_1OP(vfnegs, 8, uint64_t, DO_FNEGS) | ||
57 | DO_2OP(OP##h, 2, int16_t, FN) \ | ||
58 | DO_2OP(OP##w, 4, int32_t, FN) | ||
59 | |||
60 | +/* | ||
61 | + * "Long" operations where two half-sized inputs (taken from either the | ||
62 | + * top or the bottom of the input vector) produce a double-width result. | ||
63 | + * Here ESIZE, TYPE are for the input, and LESIZE, LTYPE for the output. | ||
64 | + */ | ||
65 | +#define DO_2OP_L(OP, TOP, ESIZE, TYPE, LESIZE, LTYPE, FN) \ | ||
66 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, void *vm) \ | ||
67 | + { \ | ||
68 | + LTYPE *d = vd; \ | ||
69 | + TYPE *n = vn, *m = vm; \ | ||
70 | + uint16_t mask = mve_element_mask(env); \ | ||
71 | + unsigned le; \ | ||
72 | + for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \ | ||
73 | + LTYPE r = FN((LTYPE)n[H##ESIZE(le * 2 + TOP)], \ | ||
74 | + m[H##ESIZE(le * 2 + TOP)]); \ | ||
75 | + mergemask(&d[H##LESIZE(le)], r, mask); \ | ||
76 | + } \ | ||
77 | + mve_advance_vpt(env); \ | ||
78 | + } | ||
79 | + | ||
80 | #define DO_AND(N, M) ((N) & (M)) | ||
81 | #define DO_BIC(N, M) ((N) & ~(M)) | ||
82 | #define DO_ORR(N, M) ((N) | (M)) | ||
83 | @@ -XXX,XX +XXX,XX @@ DO_2OP_U(vadd, DO_ADD) | ||
84 | DO_2OP_U(vsub, DO_SUB) | ||
85 | DO_2OP_U(vmul, DO_MUL) | ||
86 | |||
87 | +DO_2OP_L(vmullbsb, 0, 1, int8_t, 2, int16_t, DO_MUL) | ||
88 | +DO_2OP_L(vmullbsh, 0, 2, int16_t, 4, int32_t, DO_MUL) | ||
89 | +DO_2OP_L(vmullbsw, 0, 4, int32_t, 8, int64_t, DO_MUL) | ||
90 | +DO_2OP_L(vmullbub, 0, 1, uint8_t, 2, uint16_t, DO_MUL) | ||
91 | +DO_2OP_L(vmullbuh, 0, 2, uint16_t, 4, uint32_t, DO_MUL) | ||
92 | +DO_2OP_L(vmullbuw, 0, 4, uint32_t, 8, uint64_t, DO_MUL) | ||
93 | + | ||
94 | +DO_2OP_L(vmulltsb, 1, 1, int8_t, 2, int16_t, DO_MUL) | ||
95 | +DO_2OP_L(vmulltsh, 1, 2, int16_t, 4, int32_t, DO_MUL) | ||
96 | +DO_2OP_L(vmulltsw, 1, 4, int32_t, 8, int64_t, DO_MUL) | ||
97 | +DO_2OP_L(vmulltub, 1, 1, uint8_t, 2, uint16_t, DO_MUL) | ||
98 | +DO_2OP_L(vmulltuh, 1, 2, uint16_t, 4, uint32_t, DO_MUL) | ||
99 | +DO_2OP_L(vmulltuw, 1, 4, uint32_t, 8, uint64_t, DO_MUL) | ||
100 | + | ||
101 | /* | ||
102 | * Because the computation type is at least twice as large as required, | ||
103 | * these work for both signed and unsigned source types. | ||
104 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
105 | index XXXXXXX..XXXXXXX 100644 | ||
106 | --- a/target/arm/translate-mve.c | ||
107 | +++ b/target/arm/translate-mve.c | ||
108 | @@ -XXX,XX +XXX,XX @@ DO_2OP(VHADD_S, vhadds) | ||
109 | DO_2OP(VHADD_U, vhaddu) | ||
110 | DO_2OP(VHSUB_S, vhsubs) | ||
111 | DO_2OP(VHSUB_U, vhsubu) | ||
112 | +DO_2OP(VMULL_BS, vmullbs) | ||
113 | +DO_2OP(VMULL_BU, vmullbu) | ||
114 | +DO_2OP(VMULL_TS, vmullts) | ||
115 | +DO_2OP(VMULL_TU, vmulltu) | ||
116 | -- | ||
117 | 2.20.1 | ||
118 | |||
119 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE insn VMLSLDAV, which multiplies source elements, | ||
2 | alternately adding and subtracting them, and accumulates into a | ||
3 | 64-bit result in a pair of general purpose registers. | ||
4 | 1 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20210617121628.20116-21-peter.maydell@linaro.org | ||
8 | --- | ||
9 | target/arm/helper-mve.h | 5 +++++ | ||
10 | target/arm/mve.decode | 2 ++ | ||
11 | target/arm/mve_helper.c | 5 +++++ | ||
12 | target/arm/translate-mve.c | 11 +++++++++++ | ||
13 | 4 files changed, 23 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_4(mve_vmlaldavxsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
20 | |||
21 | DEF_HELPER_FLAGS_4(mve_vmlaldavuh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
22 | DEF_HELPER_FLAGS_4(mve_vmlaldavuw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
23 | + | ||
24 | +DEF_HELPER_FLAGS_4(mve_vmlsldavsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
25 | +DEF_HELPER_FLAGS_4(mve_vmlsldavsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
26 | +DEF_HELPER_FLAGS_4(mve_vmlsldavxsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
27 | +DEF_HELPER_FLAGS_4(mve_vmlsldavxsw, 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 @@ VDUP 1110 1110 1 0 10 ... 0 .... 1011 . 0 0 1 0000 @vdup size=2 | ||
33 | qn=%qn rdahi=%rdahi rdalo=%rdalo size=%size_16 &vmlaldav | ||
34 | VMLALDAV_S 1110 1110 1 ... ... . ... x:1 1110 . 0 a:1 0 ... 0 @vmlaldav | ||
35 | VMLALDAV_U 1111 1110 1 ... ... . ... x:1 1110 . 0 a:1 0 ... 0 @vmlaldav | ||
36 | + | ||
37 | +VMLSLDAV 1110 1110 1 ... ... . ... x:1 1110 . 0 a:1 0 ... 1 @vmlaldav | ||
38 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/target/arm/mve_helper.c | ||
41 | +++ b/target/arm/mve_helper.c | ||
42 | @@ -XXX,XX +XXX,XX @@ DO_LDAV(vmlaldavxsw, 4, int32_t, true, +=, +=) | ||
43 | |||
44 | DO_LDAV(vmlaldavuh, 2, uint16_t, false, +=, +=) | ||
45 | DO_LDAV(vmlaldavuw, 4, uint32_t, false, +=, +=) | ||
46 | + | ||
47 | +DO_LDAV(vmlsldavsh, 2, int16_t, false, +=, -=) | ||
48 | +DO_LDAV(vmlsldavxsh, 2, int16_t, true, +=, -=) | ||
49 | +DO_LDAV(vmlsldavsw, 4, int32_t, false, +=, -=) | ||
50 | +DO_LDAV(vmlsldavxsw, 4, int32_t, true, +=, -=) | ||
51 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/target/arm/translate-mve.c | ||
54 | +++ b/target/arm/translate-mve.c | ||
55 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMLALDAV_U(DisasContext *s, arg_vmlaldav *a) | ||
56 | }; | ||
57 | return do_long_dual_acc(s, a, fns[a->size][a->x]); | ||
58 | } | ||
59 | + | ||
60 | +static bool trans_VMLSLDAV(DisasContext *s, arg_vmlaldav *a) | ||
61 | +{ | ||
62 | + static MVEGenDualAccOpFn * const fns[4][2] = { | ||
63 | + { NULL, NULL }, | ||
64 | + { gen_helper_mve_vmlsldavsh, gen_helper_mve_vmlsldavxsh }, | ||
65 | + { gen_helper_mve_vmlsldavsw, gen_helper_mve_vmlsldavxsw }, | ||
66 | + { NULL, NULL }, | ||
67 | + }; | ||
68 | + return do_long_dual_acc(s, a, fns[a->size][a->x]); | ||
69 | +} | ||
70 | -- | ||
71 | 2.20.1 | ||
72 | |||
73 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE VRMLALDAVH and VRMLSLDAVH insns, which accumulate | ||
2 | the results of a rounded multiply of pairs of elements into a 72-bit | ||
3 | accumulator, returning the top 64 bits in a pair of general purpose | ||
4 | registers. | ||
5 | 1 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210617121628.20116-22-peter.maydell@linaro.org | ||
9 | --- | ||
10 | target/arm/helper-mve.h | 8 ++++++++ | ||
11 | target/arm/mve.decode | 7 +++++++ | ||
12 | target/arm/mve_helper.c | 37 +++++++++++++++++++++++++++++++++++++ | ||
13 | target/arm/translate-mve.c | 24 ++++++++++++++++++++++++ | ||
14 | 4 files changed, 76 insertions(+) | ||
15 | |||
16 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/arm/helper-mve.h | ||
19 | +++ b/target/arm/helper-mve.h | ||
20 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vmlsldavsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
21 | DEF_HELPER_FLAGS_4(mve_vmlsldavsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
22 | DEF_HELPER_FLAGS_4(mve_vmlsldavxsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
23 | DEF_HELPER_FLAGS_4(mve_vmlsldavxsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
24 | + | ||
25 | +DEF_HELPER_FLAGS_4(mve_vrmlaldavhsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
26 | +DEF_HELPER_FLAGS_4(mve_vrmlaldavhxsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
27 | + | ||
28 | +DEF_HELPER_FLAGS_4(mve_vrmlaldavhuw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
29 | + | ||
30 | +DEF_HELPER_FLAGS_4(mve_vrmlsldavhsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
31 | +DEF_HELPER_FLAGS_4(mve_vrmlsldavhxsw, TCG_CALL_NO_WG, i64, env, ptr, 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 @@ VDUP 1110 1110 1 0 10 ... 0 .... 1011 . 0 0 1 0000 @vdup size=2 | ||
37 | |||
38 | @vmlaldav .... .... . ... ... . ... . .... .... qm:3 . \ | ||
39 | qn=%qn rdahi=%rdahi rdalo=%rdalo size=%size_16 &vmlaldav | ||
40 | +@vmlaldav_nosz .... .... . ... ... . ... . .... .... qm:3 . \ | ||
41 | + qn=%qn rdahi=%rdahi rdalo=%rdalo size=0 &vmlaldav | ||
42 | VMLALDAV_S 1110 1110 1 ... ... . ... x:1 1110 . 0 a:1 0 ... 0 @vmlaldav | ||
43 | VMLALDAV_U 1111 1110 1 ... ... . ... x:1 1110 . 0 a:1 0 ... 0 @vmlaldav | ||
44 | |||
45 | VMLSLDAV 1110 1110 1 ... ... . ... x:1 1110 . 0 a:1 0 ... 1 @vmlaldav | ||
46 | + | ||
47 | +VRMLALDAVH_S 1110 1110 1 ... ... 0 ... x:1 1111 . 0 a:1 0 ... 0 @vmlaldav_nosz | ||
48 | +VRMLALDAVH_U 1111 1110 1 ... ... 0 ... x:1 1111 . 0 a:1 0 ... 0 @vmlaldav_nosz | ||
49 | + | ||
50 | +VRMLSLDAVH 1111 1110 1 ... ... 0 ... x:1 1110 . 0 a:1 0 ... 1 @vmlaldav_nosz | ||
51 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/target/arm/mve_helper.c | ||
54 | +++ b/target/arm/mve_helper.c | ||
55 | @@ -XXX,XX +XXX,XX @@ | ||
56 | */ | ||
57 | |||
58 | #include "qemu/osdep.h" | ||
59 | +#include "qemu/int128.h" | ||
60 | #include "cpu.h" | ||
61 | #include "internals.h" | ||
62 | #include "vec_internal.h" | ||
63 | @@ -XXX,XX +XXX,XX @@ DO_LDAV(vmlsldavsh, 2, int16_t, false, +=, -=) | ||
64 | DO_LDAV(vmlsldavxsh, 2, int16_t, true, +=, -=) | ||
65 | DO_LDAV(vmlsldavsw, 4, int32_t, false, +=, -=) | ||
66 | DO_LDAV(vmlsldavxsw, 4, int32_t, true, +=, -=) | ||
67 | + | ||
68 | +/* | ||
69 | + * Rounding multiply add long dual accumulate high: we must keep | ||
70 | + * a 72-bit internal accumulator value and return the top 64 bits. | ||
71 | + */ | ||
72 | +#define DO_LDAVH(OP, ESIZE, TYPE, XCHG, EVENACC, ODDACC, TO128) \ | ||
73 | + uint64_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vn, \ | ||
74 | + void *vm, uint64_t a) \ | ||
75 | + { \ | ||
76 | + uint16_t mask = mve_element_mask(env); \ | ||
77 | + unsigned e; \ | ||
78 | + TYPE *n = vn, *m = vm; \ | ||
79 | + Int128 acc = int128_lshift(TO128(a), 8); \ | ||
80 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
81 | + if (mask & 1) { \ | ||
82 | + if (e & 1) { \ | ||
83 | + acc = ODDACC(acc, TO128(n[H##ESIZE(e - 1 * XCHG)] * \ | ||
84 | + m[H##ESIZE(e)])); \ | ||
85 | + } else { \ | ||
86 | + acc = EVENACC(acc, TO128(n[H##ESIZE(e + 1 * XCHG)] * \ | ||
87 | + m[H##ESIZE(e)])); \ | ||
88 | + } \ | ||
89 | + acc = int128_add(acc, 1 << 7); \ | ||
90 | + } \ | ||
91 | + } \ | ||
92 | + mve_advance_vpt(env); \ | ||
93 | + return int128_getlo(int128_rshift(acc, 8)); \ | ||
94 | + } | ||
95 | + | ||
96 | +DO_LDAVH(vrmlaldavhsw, 4, int32_t, false, int128_add, int128_add, int128_makes64) | ||
97 | +DO_LDAVH(vrmlaldavhxsw, 4, int32_t, true, int128_add, int128_add, int128_makes64) | ||
98 | + | ||
99 | +DO_LDAVH(vrmlaldavhuw, 4, uint32_t, false, int128_add, int128_add, int128_make64) | ||
100 | + | ||
101 | +DO_LDAVH(vrmlsldavhsw, 4, int32_t, false, int128_add, int128_sub, int128_makes64) | ||
102 | +DO_LDAVH(vrmlsldavhxsw, 4, int32_t, true, int128_add, int128_sub, int128_makes64) | ||
103 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
104 | index XXXXXXX..XXXXXXX 100644 | ||
105 | --- a/target/arm/translate-mve.c | ||
106 | +++ b/target/arm/translate-mve.c | ||
107 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMLSLDAV(DisasContext *s, arg_vmlaldav *a) | ||
108 | }; | ||
109 | return do_long_dual_acc(s, a, fns[a->size][a->x]); | ||
110 | } | ||
111 | + | ||
112 | +static bool trans_VRMLALDAVH_S(DisasContext *s, arg_vmlaldav *a) | ||
113 | +{ | ||
114 | + static MVEGenDualAccOpFn * const fns[] = { | ||
115 | + gen_helper_mve_vrmlaldavhsw, gen_helper_mve_vrmlaldavhxsw, | ||
116 | + }; | ||
117 | + return do_long_dual_acc(s, a, fns[a->x]); | ||
118 | +} | ||
119 | + | ||
120 | +static bool trans_VRMLALDAVH_U(DisasContext *s, arg_vmlaldav *a) | ||
121 | +{ | ||
122 | + static MVEGenDualAccOpFn * const fns[] = { | ||
123 | + gen_helper_mve_vrmlaldavhuw, NULL, | ||
124 | + }; | ||
125 | + return do_long_dual_acc(s, a, fns[a->x]); | ||
126 | +} | ||
127 | + | ||
128 | +static bool trans_VRMLSLDAVH(DisasContext *s, arg_vmlaldav *a) | ||
129 | +{ | ||
130 | + static MVEGenDualAccOpFn * const fns[] = { | ||
131 | + gen_helper_mve_vrmlsldavhsw, gen_helper_mve_vrmlsldavhxsw, | ||
132 | + }; | ||
133 | + return do_long_dual_acc(s, a, fns[a->x]); | ||
134 | +} | ||
135 | -- | ||
136 | 2.20.1 | ||
137 | |||
138 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the scalar form of the MVE VADD insn. This takes the | ||
2 | scalar operand from a general purpose register. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20210617121628.20116-23-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/arm/helper-mve.h | 4 ++++ | ||
9 | target/arm/mve.decode | 7 ++++++ | ||
10 | target/arm/mve_helper.c | 22 +++++++++++++++++++ | ||
11 | target/arm/translate-mve.c | 45 ++++++++++++++++++++++++++++++++++++++ | ||
12 | 4 files changed, 78 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_4(mve_vmulltub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
19 | DEF_HELPER_FLAGS_4(mve_vmulltuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
20 | DEF_HELPER_FLAGS_4(mve_vmulltuw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
21 | |||
22 | +DEF_HELPER_FLAGS_4(mve_vadd_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
23 | +DEF_HELPER_FLAGS_4(mve_vadd_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
24 | +DEF_HELPER_FLAGS_4(mve_vadd_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
25 | + | ||
26 | DEF_HELPER_FLAGS_4(mve_vmlaldavsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
27 | DEF_HELPER_FLAGS_4(mve_vmlaldavsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
28 | DEF_HELPER_FLAGS_4(mve_vmlaldavxsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
29 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/target/arm/mve.decode | ||
32 | +++ b/target/arm/mve.decode | ||
33 | @@ -XXX,XX +XXX,XX @@ | ||
34 | &vldr_vstr rn qd imm p a w size l u | ||
35 | &1op qd qm size | ||
36 | &2op qd qm qn size | ||
37 | +&2scalar qd qn rm size | ||
38 | |||
39 | @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 | ||
40 | # Note that both Rn and Qd are 3 bits only (no D bit) | ||
41 | @@ -XXX,XX +XXX,XX @@ | ||
42 | @2op .... .... .. size:2 .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn | ||
43 | @2op_nosz .... .... .... .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn size=0 | ||
44 | |||
45 | +@2scalar .... .... .. size:2 .... .... .... .... rm:4 &2scalar qd=%qd qn=%qn | ||
46 | + | ||
47 | # Vector loads and stores | ||
48 | |||
49 | # Widening loads and narrowing stores: | ||
50 | @@ -XXX,XX +XXX,XX @@ VRMLALDAVH_S 1110 1110 1 ... ... 0 ... x:1 1111 . 0 a:1 0 ... 0 @vmlaldav_no | ||
51 | VRMLALDAVH_U 1111 1110 1 ... ... 0 ... x:1 1111 . 0 a:1 0 ... 0 @vmlaldav_nosz | ||
52 | |||
53 | VRMLSLDAVH 1111 1110 1 ... ... 0 ... x:1 1110 . 0 a:1 0 ... 1 @vmlaldav_nosz | ||
54 | + | ||
55 | +# Scalar operations | ||
56 | + | ||
57 | +VADD_scalar 1110 1110 0 . .. ... 1 ... 0 1111 . 100 .... @2scalar | ||
58 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
59 | index XXXXXXX..XXXXXXX 100644 | ||
60 | --- a/target/arm/mve_helper.c | ||
61 | +++ b/target/arm/mve_helper.c | ||
62 | @@ -XXX,XX +XXX,XX @@ DO_2OP_S(vhsubs, do_vhsub_s) | ||
63 | DO_2OP_U(vhsubu, do_vhsub_u) | ||
64 | |||
65 | |||
66 | +#define DO_2OP_SCALAR(OP, ESIZE, TYPE, FN) \ | ||
67 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, \ | ||
68 | + uint32_t rm) \ | ||
69 | + { \ | ||
70 | + TYPE *d = vd, *n = vn; \ | ||
71 | + TYPE m = rm; \ | ||
72 | + uint16_t mask = mve_element_mask(env); \ | ||
73 | + unsigned e; \ | ||
74 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
75 | + mergemask(&d[H##ESIZE(e)], FN(n[H##ESIZE(e)], m), mask); \ | ||
76 | + } \ | ||
77 | + mve_advance_vpt(env); \ | ||
78 | + } | ||
79 | + | ||
80 | +/* provide unsigned 2-op scalar helpers for all sizes */ | ||
81 | +#define DO_2OP_SCALAR_U(OP, FN) \ | ||
82 | + DO_2OP_SCALAR(OP##b, 1, uint8_t, FN) \ | ||
83 | + DO_2OP_SCALAR(OP##h, 2, uint16_t, FN) \ | ||
84 | + DO_2OP_SCALAR(OP##w, 4, uint32_t, FN) | ||
85 | + | ||
86 | +DO_2OP_SCALAR_U(vadd_scalar, DO_ADD) | ||
87 | + | ||
88 | /* | ||
89 | * Multiply add long dual accumulate ops. | ||
90 | */ | ||
91 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
92 | index XXXXXXX..XXXXXXX 100644 | ||
93 | --- a/target/arm/translate-mve.c | ||
94 | +++ b/target/arm/translate-mve.c | ||
95 | @@ -XXX,XX +XXX,XX @@ | ||
96 | typedef void MVEGenLdStFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
97 | typedef void MVEGenOneOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
98 | typedef void MVEGenTwoOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
99 | +typedef void MVEGenTwoOpScalarFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
100 | typedef void MVEGenDualAccOpFn(TCGv_i64, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
101 | |||
102 | /* Return the offset of a Qn register (same semantics as aa32_vfp_qreg()) */ | ||
103 | @@ -XXX,XX +XXX,XX @@ DO_2OP(VMULL_BU, vmullbu) | ||
104 | DO_2OP(VMULL_TS, vmullts) | ||
105 | DO_2OP(VMULL_TU, vmulltu) | ||
106 | |||
107 | +static bool do_2op_scalar(DisasContext *s, arg_2scalar *a, | ||
108 | + MVEGenTwoOpScalarFn fn) | ||
109 | +{ | ||
110 | + TCGv_ptr qd, qn; | ||
111 | + TCGv_i32 rm; | ||
112 | + | ||
113 | + if (!dc_isar_feature(aa32_mve, s) || | ||
114 | + !mve_check_qreg_bank(s, a->qd | a->qn) || | ||
115 | + !fn) { | ||
116 | + return false; | ||
117 | + } | ||
118 | + if (a->rm == 13 || a->rm == 15) { | ||
119 | + /* UNPREDICTABLE */ | ||
120 | + return false; | ||
121 | + } | ||
122 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
123 | + return true; | ||
124 | + } | ||
125 | + | ||
126 | + qd = mve_qreg_ptr(a->qd); | ||
127 | + qn = mve_qreg_ptr(a->qn); | ||
128 | + rm = load_reg(s, a->rm); | ||
129 | + fn(cpu_env, qd, qn, rm); | ||
130 | + tcg_temp_free_i32(rm); | ||
131 | + tcg_temp_free_ptr(qd); | ||
132 | + tcg_temp_free_ptr(qn); | ||
133 | + mve_update_eci(s); | ||
134 | + return true; | ||
135 | +} | ||
136 | + | ||
137 | +#define DO_2OP_SCALAR(INSN, FN) \ | ||
138 | + static bool trans_##INSN(DisasContext *s, arg_2scalar *a) \ | ||
139 | + { \ | ||
140 | + static MVEGenTwoOpScalarFn * 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_2op_scalar(s, a, fns[a->size]); \ | ||
147 | + } | ||
148 | + | ||
149 | +DO_2OP_SCALAR(VADD_scalar, vadd_scalar) | ||
150 | + | ||
151 | static bool do_long_dual_acc(DisasContext *s, arg_vmlaldav *a, | ||
152 | MVEGenDualAccOpFn *fn) | ||
153 | { | ||
154 | -- | ||
155 | 2.20.1 | ||
156 | |||
157 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the scalar forms of the MVE VSUB and VMUL insns. | ||
2 | 1 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20210617121628.20116-24-peter.maydell@linaro.org | ||
6 | --- | ||
7 | target/arm/helper-mve.h | 8 ++++++++ | ||
8 | target/arm/mve.decode | 2 ++ | ||
9 | target/arm/mve_helper.c | 2 ++ | ||
10 | target/arm/translate-mve.c | 2 ++ | ||
11 | 4 files changed, 14 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_vadd_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
18 | DEF_HELPER_FLAGS_4(mve_vadd_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
19 | DEF_HELPER_FLAGS_4(mve_vadd_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
20 | |||
21 | +DEF_HELPER_FLAGS_4(mve_vsub_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
22 | +DEF_HELPER_FLAGS_4(mve_vsub_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
23 | +DEF_HELPER_FLAGS_4(mve_vsub_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
24 | + | ||
25 | +DEF_HELPER_FLAGS_4(mve_vmul_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
26 | +DEF_HELPER_FLAGS_4(mve_vmul_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
27 | +DEF_HELPER_FLAGS_4(mve_vmul_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
28 | + | ||
29 | DEF_HELPER_FLAGS_4(mve_vmlaldavsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
30 | DEF_HELPER_FLAGS_4(mve_vmlaldavsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
31 | DEF_HELPER_FLAGS_4(mve_vmlaldavxsh, TCG_CALL_NO_WG, i64, env, ptr, 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 @@ VRMLSLDAVH 1111 1110 1 ... ... 0 ... x:1 1110 . 0 a:1 0 ... 1 @vmlaldav_no | ||
37 | # Scalar operations | ||
38 | |||
39 | VADD_scalar 1110 1110 0 . .. ... 1 ... 0 1111 . 100 .... @2scalar | ||
40 | +VSUB_scalar 1110 1110 0 . .. ... 1 ... 1 1111 . 100 .... @2scalar | ||
41 | +VMUL_scalar 1110 1110 0 . .. ... 1 ... 1 1110 . 110 .... @2scalar | ||
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_2OP_U(vhsubu, do_vhsub_u) | ||
47 | DO_2OP_SCALAR(OP##w, 4, uint32_t, FN) | ||
48 | |||
49 | DO_2OP_SCALAR_U(vadd_scalar, DO_ADD) | ||
50 | +DO_2OP_SCALAR_U(vsub_scalar, DO_SUB) | ||
51 | +DO_2OP_SCALAR_U(vmul_scalar, DO_MUL) | ||
52 | |||
53 | /* | ||
54 | * Multiply add long dual accumulate ops. | ||
55 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/target/arm/translate-mve.c | ||
58 | +++ b/target/arm/translate-mve.c | ||
59 | @@ -XXX,XX +XXX,XX @@ static bool do_2op_scalar(DisasContext *s, arg_2scalar *a, | ||
60 | } | ||
61 | |||
62 | DO_2OP_SCALAR(VADD_scalar, vadd_scalar) | ||
63 | +DO_2OP_SCALAR(VSUB_scalar, vsub_scalar) | ||
64 | +DO_2OP_SCALAR(VMUL_scalar, vmul_scalar) | ||
65 | |||
66 | static bool do_long_dual_acc(DisasContext *s, arg_vmlaldav *a, | ||
67 | MVEGenDualAccOpFn *fn) | ||
68 | -- | ||
69 | 2.20.1 | ||
70 | |||
71 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the scalar variants of the MVE VHADD and VHSUB insns. | ||
2 | 1 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20210617121628.20116-25-peter.maydell@linaro.org | ||
6 | --- | ||
7 | target/arm/helper-mve.h | 16 ++++++++++++++++ | ||
8 | target/arm/mve.decode | 4 ++++ | ||
9 | target/arm/mve_helper.c | 8 ++++++++ | ||
10 | target/arm/translate-mve.c | 4 ++++ | ||
11 | 4 files changed, 32 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_vmul_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
18 | DEF_HELPER_FLAGS_4(mve_vmul_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
19 | DEF_HELPER_FLAGS_4(mve_vmul_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
20 | |||
21 | +DEF_HELPER_FLAGS_4(mve_vhadds_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
22 | +DEF_HELPER_FLAGS_4(mve_vhadds_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
23 | +DEF_HELPER_FLAGS_4(mve_vhadds_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
24 | + | ||
25 | +DEF_HELPER_FLAGS_4(mve_vhaddu_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
26 | +DEF_HELPER_FLAGS_4(mve_vhaddu_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
27 | +DEF_HELPER_FLAGS_4(mve_vhaddu_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
28 | + | ||
29 | +DEF_HELPER_FLAGS_4(mve_vhsubs_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
30 | +DEF_HELPER_FLAGS_4(mve_vhsubs_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
31 | +DEF_HELPER_FLAGS_4(mve_vhsubs_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
32 | + | ||
33 | +DEF_HELPER_FLAGS_4(mve_vhsubu_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
34 | +DEF_HELPER_FLAGS_4(mve_vhsubu_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
35 | +DEF_HELPER_FLAGS_4(mve_vhsubu_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
36 | + | ||
37 | DEF_HELPER_FLAGS_4(mve_vmlaldavsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
38 | DEF_HELPER_FLAGS_4(mve_vmlaldavsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
39 | DEF_HELPER_FLAGS_4(mve_vmlaldavxsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
40 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/target/arm/mve.decode | ||
43 | +++ b/target/arm/mve.decode | ||
44 | @@ -XXX,XX +XXX,XX @@ VRMLSLDAVH 1111 1110 1 ... ... 0 ... x:1 1110 . 0 a:1 0 ... 1 @vmlaldav_no | ||
45 | VADD_scalar 1110 1110 0 . .. ... 1 ... 0 1111 . 100 .... @2scalar | ||
46 | VSUB_scalar 1110 1110 0 . .. ... 1 ... 1 1111 . 100 .... @2scalar | ||
47 | VMUL_scalar 1110 1110 0 . .. ... 1 ... 1 1110 . 110 .... @2scalar | ||
48 | +VHADD_S_scalar 1110 1110 0 . .. ... 0 ... 0 1111 . 100 .... @2scalar | ||
49 | +VHADD_U_scalar 1111 1110 0 . .. ... 0 ... 0 1111 . 100 .... @2scalar | ||
50 | +VHSUB_S_scalar 1110 1110 0 . .. ... 0 ... 1 1111 . 100 .... @2scalar | ||
51 | +VHSUB_U_scalar 1111 1110 0 . .. ... 0 ... 1 1111 . 100 .... @2scalar | ||
52 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | --- a/target/arm/mve_helper.c | ||
55 | +++ b/target/arm/mve_helper.c | ||
56 | @@ -XXX,XX +XXX,XX @@ DO_2OP_U(vhsubu, do_vhsub_u) | ||
57 | DO_2OP_SCALAR(OP##b, 1, uint8_t, FN) \ | ||
58 | DO_2OP_SCALAR(OP##h, 2, uint16_t, FN) \ | ||
59 | DO_2OP_SCALAR(OP##w, 4, uint32_t, FN) | ||
60 | +#define DO_2OP_SCALAR_S(OP, FN) \ | ||
61 | + DO_2OP_SCALAR(OP##b, 1, int8_t, FN) \ | ||
62 | + DO_2OP_SCALAR(OP##h, 2, int16_t, FN) \ | ||
63 | + DO_2OP_SCALAR(OP##w, 4, int32_t, FN) | ||
64 | |||
65 | DO_2OP_SCALAR_U(vadd_scalar, DO_ADD) | ||
66 | DO_2OP_SCALAR_U(vsub_scalar, DO_SUB) | ||
67 | DO_2OP_SCALAR_U(vmul_scalar, DO_MUL) | ||
68 | +DO_2OP_SCALAR_S(vhadds_scalar, do_vhadd_s) | ||
69 | +DO_2OP_SCALAR_U(vhaddu_scalar, do_vhadd_u) | ||
70 | +DO_2OP_SCALAR_S(vhsubs_scalar, do_vhsub_s) | ||
71 | +DO_2OP_SCALAR_U(vhsubu_scalar, do_vhsub_u) | ||
72 | |||
73 | /* | ||
74 | * Multiply add long dual accumulate ops. | ||
75 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
76 | index XXXXXXX..XXXXXXX 100644 | ||
77 | --- a/target/arm/translate-mve.c | ||
78 | +++ b/target/arm/translate-mve.c | ||
79 | @@ -XXX,XX +XXX,XX @@ static bool do_2op_scalar(DisasContext *s, arg_2scalar *a, | ||
80 | DO_2OP_SCALAR(VADD_scalar, vadd_scalar) | ||
81 | DO_2OP_SCALAR(VSUB_scalar, vsub_scalar) | ||
82 | DO_2OP_SCALAR(VMUL_scalar, vmul_scalar) | ||
83 | +DO_2OP_SCALAR(VHADD_S_scalar, vhadds_scalar) | ||
84 | +DO_2OP_SCALAR(VHADD_U_scalar, vhaddu_scalar) | ||
85 | +DO_2OP_SCALAR(VHSUB_S_scalar, vhsubs_scalar) | ||
86 | +DO_2OP_SCALAR(VHSUB_U_scalar, vhsubu_scalar) | ||
87 | |||
88 | static bool do_long_dual_acc(DisasContext *s, arg_vmlaldav *a, | ||
89 | MVEGenDualAccOpFn *fn) | ||
90 | -- | ||
91 | 2.20.1 | ||
92 | |||
93 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE VBRSR insn, which reverses a specified | ||
2 | number of bits in each element, setting the rest to zero. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20210617121628.20116-26-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/arm/helper-mve.h | 4 ++++ | ||
9 | target/arm/mve.decode | 1 + | ||
10 | target/arm/mve_helper.c | 43 ++++++++++++++++++++++++++++++++++++++ | ||
11 | target/arm/translate-mve.c | 1 + | ||
12 | 4 files changed, 49 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_4(mve_vhsubu_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
19 | DEF_HELPER_FLAGS_4(mve_vhsubu_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
20 | DEF_HELPER_FLAGS_4(mve_vhsubu_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
21 | |||
22 | +DEF_HELPER_FLAGS_4(mve_vbrsrb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
23 | +DEF_HELPER_FLAGS_4(mve_vbrsrh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
24 | +DEF_HELPER_FLAGS_4(mve_vbrsrw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
25 | + | ||
26 | DEF_HELPER_FLAGS_4(mve_vmlaldavsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
27 | DEF_HELPER_FLAGS_4(mve_vmlaldavsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
28 | DEF_HELPER_FLAGS_4(mve_vmlaldavxsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
29 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/target/arm/mve.decode | ||
32 | +++ b/target/arm/mve.decode | ||
33 | @@ -XXX,XX +XXX,XX @@ VHADD_S_scalar 1110 1110 0 . .. ... 0 ... 0 1111 . 100 .... @2scalar | ||
34 | VHADD_U_scalar 1111 1110 0 . .. ... 0 ... 0 1111 . 100 .... @2scalar | ||
35 | VHSUB_S_scalar 1110 1110 0 . .. ... 0 ... 1 1111 . 100 .... @2scalar | ||
36 | VHSUB_U_scalar 1111 1110 0 . .. ... 0 ... 1 1111 . 100 .... @2scalar | ||
37 | +VBRSR 1111 1110 0 . .. ... 1 ... 1 1110 . 110 .... @2scalar | ||
38 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/target/arm/mve_helper.c | ||
41 | +++ b/target/arm/mve_helper.c | ||
42 | @@ -XXX,XX +XXX,XX @@ DO_2OP_SCALAR_U(vhaddu_scalar, do_vhadd_u) | ||
43 | DO_2OP_SCALAR_S(vhsubs_scalar, do_vhsub_s) | ||
44 | DO_2OP_SCALAR_U(vhsubu_scalar, do_vhsub_u) | ||
45 | |||
46 | +static inline uint32_t do_vbrsrb(uint32_t n, uint32_t m) | ||
47 | +{ | ||
48 | + m &= 0xff; | ||
49 | + if (m == 0) { | ||
50 | + return 0; | ||
51 | + } | ||
52 | + n = revbit8(n); | ||
53 | + if (m < 8) { | ||
54 | + n >>= 8 - m; | ||
55 | + } | ||
56 | + return n; | ||
57 | +} | ||
58 | + | ||
59 | +static inline uint32_t do_vbrsrh(uint32_t n, uint32_t m) | ||
60 | +{ | ||
61 | + m &= 0xff; | ||
62 | + if (m == 0) { | ||
63 | + return 0; | ||
64 | + } | ||
65 | + n = revbit16(n); | ||
66 | + if (m < 16) { | ||
67 | + n >>= 16 - m; | ||
68 | + } | ||
69 | + return n; | ||
70 | +} | ||
71 | + | ||
72 | +static inline uint32_t do_vbrsrw(uint32_t n, uint32_t m) | ||
73 | +{ | ||
74 | + m &= 0xff; | ||
75 | + if (m == 0) { | ||
76 | + return 0; | ||
77 | + } | ||
78 | + n = revbit32(n); | ||
79 | + if (m < 32) { | ||
80 | + n >>= 32 - m; | ||
81 | + } | ||
82 | + return n; | ||
83 | +} | ||
84 | + | ||
85 | +DO_2OP_SCALAR(vbrsrb, 1, uint8_t, do_vbrsrb) | ||
86 | +DO_2OP_SCALAR(vbrsrh, 2, uint16_t, do_vbrsrh) | ||
87 | +DO_2OP_SCALAR(vbrsrw, 4, uint32_t, do_vbrsrw) | ||
88 | + | ||
89 | /* | ||
90 | * Multiply add long dual accumulate ops. | ||
91 | */ | ||
92 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
93 | index XXXXXXX..XXXXXXX 100644 | ||
94 | --- a/target/arm/translate-mve.c | ||
95 | +++ b/target/arm/translate-mve.c | ||
96 | @@ -XXX,XX +XXX,XX @@ DO_2OP_SCALAR(VHADD_S_scalar, vhadds_scalar) | ||
97 | DO_2OP_SCALAR(VHADD_U_scalar, vhaddu_scalar) | ||
98 | DO_2OP_SCALAR(VHSUB_S_scalar, vhsubs_scalar) | ||
99 | DO_2OP_SCALAR(VHSUB_U_scalar, vhsubu_scalar) | ||
100 | +DO_2OP_SCALAR(VBRSR, vbrsr) | ||
101 | |||
102 | static bool do_long_dual_acc(DisasContext *s, arg_vmlaldav *a, | ||
103 | MVEGenDualAccOpFn *fn) | ||
104 | -- | ||
105 | 2.20.1 | ||
106 | |||
107 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE VQDMULH and VQRDMULH scalar insns, which multiply | ||
2 | elements by the scalar, double, possibly round, take the high half | ||
3 | and saturate. | ||
4 | 1 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20210617121628.20116-29-peter.maydell@linaro.org | ||
8 | --- | ||
9 | target/arm/helper-mve.h | 8 ++++++++ | ||
10 | target/arm/mve.decode | 3 +++ | ||
11 | target/arm/mve_helper.c | 25 +++++++++++++++++++++++++ | ||
12 | target/arm/translate-mve.c | 2 ++ | ||
13 | 4 files changed, 38 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_4(mve_vqsubu_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
20 | DEF_HELPER_FLAGS_4(mve_vqsubu_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
21 | DEF_HELPER_FLAGS_4(mve_vqsubu_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
22 | |||
23 | +DEF_HELPER_FLAGS_4(mve_vqdmulh_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
24 | +DEF_HELPER_FLAGS_4(mve_vqdmulh_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
25 | +DEF_HELPER_FLAGS_4(mve_vqdmulh_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
26 | + | ||
27 | +DEF_HELPER_FLAGS_4(mve_vqrdmulh_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
28 | +DEF_HELPER_FLAGS_4(mve_vqrdmulh_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
29 | +DEF_HELPER_FLAGS_4(mve_vqrdmulh_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
30 | + | ||
31 | DEF_HELPER_FLAGS_4(mve_vbrsrb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
32 | DEF_HELPER_FLAGS_4(mve_vbrsrh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
33 | DEF_HELPER_FLAGS_4(mve_vbrsrw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
34 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/target/arm/mve.decode | ||
37 | +++ b/target/arm/mve.decode | ||
38 | @@ -XXX,XX +XXX,XX @@ VQSUB_S_scalar 1110 1110 0 . .. ... 0 ... 1 1111 . 110 .... @2scalar | ||
39 | VQSUB_U_scalar 1111 1110 0 . .. ... 0 ... 1 1111 . 110 .... @2scalar | ||
40 | VBRSR 1111 1110 0 . .. ... 1 ... 1 1110 . 110 .... @2scalar | ||
41 | |||
42 | +VQDMULH_scalar 1110 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
43 | +VQRDMULH_scalar 1111 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
44 | + | ||
45 | # Predicate operations | ||
46 | %mask_22_13 22:1 13:3 | ||
47 | VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13 | ||
48 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/target/arm/mve_helper.c | ||
51 | +++ b/target/arm/mve_helper.c | ||
52 | @@ -XXX,XX +XXX,XX @@ static inline int32_t do_sat_bhw(int64_t val, int64_t min, int64_t max, bool *s) | ||
53 | #define DO_UQSUB_H(n, m, s) do_sat_bhw((int64_t)n - m, 0, UINT16_MAX, s) | ||
54 | #define DO_UQSUB_W(n, m, s) do_sat_bhw((int64_t)n - m, 0, UINT32_MAX, s) | ||
55 | |||
56 | +/* | ||
57 | + * For QDMULH and QRDMULH we simplify "double and shift by esize" into | ||
58 | + * "shift by esize-1", adjusting the QRDMULH rounding constant to match. | ||
59 | + */ | ||
60 | +#define DO_QDMULH_B(n, m, s) do_sat_bhw(((int64_t)n * m) >> 7, \ | ||
61 | + INT8_MIN, INT8_MAX, s) | ||
62 | +#define DO_QDMULH_H(n, m, s) do_sat_bhw(((int64_t)n * m) >> 15, \ | ||
63 | + INT16_MIN, INT16_MAX, s) | ||
64 | +#define DO_QDMULH_W(n, m, s) do_sat_bhw(((int64_t)n * m) >> 31, \ | ||
65 | + INT32_MIN, INT32_MAX, s) | ||
66 | + | ||
67 | +#define DO_QRDMULH_B(n, m, s) do_sat_bhw(((int64_t)n * m + (1 << 6)) >> 7, \ | ||
68 | + INT8_MIN, INT8_MAX, s) | ||
69 | +#define DO_QRDMULH_H(n, m, s) do_sat_bhw(((int64_t)n * m + (1 << 14)) >> 15, \ | ||
70 | + INT16_MIN, INT16_MAX, s) | ||
71 | +#define DO_QRDMULH_W(n, m, s) do_sat_bhw(((int64_t)n * m + (1 << 30)) >> 31, \ | ||
72 | + INT32_MIN, INT32_MAX, s) | ||
73 | + | ||
74 | #define DO_2OP_SCALAR(OP, ESIZE, TYPE, FN) \ | ||
75 | void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, \ | ||
76 | uint32_t rm) \ | ||
77 | @@ -XXX,XX +XXX,XX @@ DO_2OP_SAT_SCALAR(vqsubs_scalarb, 1, int8_t, DO_SQSUB_B) | ||
78 | DO_2OP_SAT_SCALAR(vqsubs_scalarh, 2, int16_t, DO_SQSUB_H) | ||
79 | DO_2OP_SAT_SCALAR(vqsubs_scalarw, 4, int32_t, DO_SQSUB_W) | ||
80 | |||
81 | +DO_2OP_SAT_SCALAR(vqdmulh_scalarb, 1, int8_t, DO_QDMULH_B) | ||
82 | +DO_2OP_SAT_SCALAR(vqdmulh_scalarh, 2, int16_t, DO_QDMULH_H) | ||
83 | +DO_2OP_SAT_SCALAR(vqdmulh_scalarw, 4, int32_t, DO_QDMULH_W) | ||
84 | +DO_2OP_SAT_SCALAR(vqrdmulh_scalarb, 1, int8_t, DO_QRDMULH_B) | ||
85 | +DO_2OP_SAT_SCALAR(vqrdmulh_scalarh, 2, int16_t, DO_QRDMULH_H) | ||
86 | +DO_2OP_SAT_SCALAR(vqrdmulh_scalarw, 4, int32_t, DO_QRDMULH_W) | ||
87 | + | ||
88 | static inline uint32_t do_vbrsrb(uint32_t n, uint32_t m) | ||
89 | { | ||
90 | m &= 0xff; | ||
91 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
92 | index XXXXXXX..XXXXXXX 100644 | ||
93 | --- a/target/arm/translate-mve.c | ||
94 | +++ b/target/arm/translate-mve.c | ||
95 | @@ -XXX,XX +XXX,XX @@ DO_2OP_SCALAR(VQADD_S_scalar, vqadds_scalar) | ||
96 | DO_2OP_SCALAR(VQADD_U_scalar, vqaddu_scalar) | ||
97 | DO_2OP_SCALAR(VQSUB_S_scalar, vqsubs_scalar) | ||
98 | DO_2OP_SCALAR(VQSUB_U_scalar, vqsubu_scalar) | ||
99 | +DO_2OP_SCALAR(VQDMULH_scalar, vqdmulh_scalar) | ||
100 | +DO_2OP_SCALAR(VQRDMULH_scalar, vqrdmulh_scalar) | ||
101 | DO_2OP_SCALAR(VBRSR, vbrsr) | ||
102 | |||
103 | static bool do_long_dual_acc(DisasContext *s, arg_vmlaldav *a, | ||
104 | -- | ||
105 | 2.20.1 | ||
106 | |||
107 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE VQDMULL scalar insn. This multiplies the top or | ||
2 | bottom half of each element by the scalar, doubles and saturates | ||
3 | to a double-width result. | ||
4 | 1 | ||
5 | Note that this encoding overlaps with VQADD and VQSUB; it uses | ||
6 | what in VQADD and VQSUB would be the 'size=0b11' encoding. | ||
7 | |||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20210617121628.20116-30-peter.maydell@linaro.org | ||
11 | --- | ||
12 | target/arm/helper-mve.h | 5 +++ | ||
13 | target/arm/mve.decode | 23 +++++++++++--- | ||
14 | target/arm/mve_helper.c | 65 ++++++++++++++++++++++++++++++++++++++ | ||
15 | target/arm/translate-mve.c | 30 ++++++++++++++++++ | ||
16 | 4 files changed, 119 insertions(+), 4 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_vbrsrb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
23 | DEF_HELPER_FLAGS_4(mve_vbrsrh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
24 | DEF_HELPER_FLAGS_4(mve_vbrsrw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
25 | |||
26 | +DEF_HELPER_FLAGS_4(mve_vqdmullb_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
27 | +DEF_HELPER_FLAGS_4(mve_vqdmullb_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
28 | +DEF_HELPER_FLAGS_4(mve_vqdmullt_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
29 | +DEF_HELPER_FLAGS_4(mve_vqdmullt_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
30 | + | ||
31 | DEF_HELPER_FLAGS_4(mve_vmlaldavsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
32 | DEF_HELPER_FLAGS_4(mve_vmlaldavsw, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
33 | DEF_HELPER_FLAGS_4(mve_vmlaldavxsh, TCG_CALL_NO_WG, i64, env, ptr, ptr, i64) | ||
34 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/target/arm/mve.decode | ||
37 | +++ b/target/arm/mve.decode | ||
38 | @@ -XXX,XX +XXX,XX @@ | ||
39 | %qm 5:1 1:3 | ||
40 | %qn 7:1 17:3 | ||
41 | |||
42 | +# VQDMULL has size in bit 28: 0 for 16 bit, 1 for 32 bit | ||
43 | +%size_28 28:1 !function=plus_1 | ||
44 | + | ||
45 | &vldr_vstr rn qd imm p a w size l u | ||
46 | &1op qd qm size | ||
47 | &2op qd qm qn size | ||
48 | @@ -XXX,XX +XXX,XX @@ | ||
49 | @2op_nosz .... .... .... .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn size=0 | ||
50 | |||
51 | @2scalar .... .... .. size:2 .... .... .... .... rm:4 &2scalar qd=%qd qn=%qn | ||
52 | +@2scalar_nosz .... .... .... .... .... .... .... rm:4 &2scalar qd=%qd qn=%qn | ||
53 | |||
54 | # Vector loads and stores | ||
55 | |||
56 | @@ -XXX,XX +XXX,XX @@ VHADD_U_scalar 1111 1110 0 . .. ... 0 ... 0 1111 . 100 .... @2scalar | ||
57 | VHSUB_S_scalar 1110 1110 0 . .. ... 0 ... 1 1111 . 100 .... @2scalar | ||
58 | VHSUB_U_scalar 1111 1110 0 . .. ... 0 ... 1 1111 . 100 .... @2scalar | ||
59 | |||
60 | -VQADD_S_scalar 1110 1110 0 . .. ... 0 ... 0 1111 . 110 .... @2scalar | ||
61 | -VQADD_U_scalar 1111 1110 0 . .. ... 0 ... 0 1111 . 110 .... @2scalar | ||
62 | -VQSUB_S_scalar 1110 1110 0 . .. ... 0 ... 1 1111 . 110 .... @2scalar | ||
63 | -VQSUB_U_scalar 1111 1110 0 . .. ... 0 ... 1 1111 . 110 .... @2scalar | ||
64 | +{ | ||
65 | + VQADD_S_scalar 1110 1110 0 . .. ... 0 ... 0 1111 . 110 .... @2scalar | ||
66 | + VQADD_U_scalar 1111 1110 0 . .. ... 0 ... 0 1111 . 110 .... @2scalar | ||
67 | + VQDMULLB_scalar 111 . 1110 0 . 11 ... 0 ... 0 1111 . 110 .... @2scalar_nosz \ | ||
68 | + size=%size_28 | ||
69 | +} | ||
70 | + | ||
71 | +{ | ||
72 | + VQSUB_S_scalar 1110 1110 0 . .. ... 0 ... 1 1111 . 110 .... @2scalar | ||
73 | + VQSUB_U_scalar 1111 1110 0 . .. ... 0 ... 1 1111 . 110 .... @2scalar | ||
74 | + VQDMULLT_scalar 111 . 1110 0 . 11 ... 0 ... 1 1111 . 110 .... @2scalar_nosz \ | ||
75 | + size=%size_28 | ||
76 | +} | ||
77 | + | ||
78 | VBRSR 1111 1110 0 . .. ... 1 ... 1 1110 . 110 .... @2scalar | ||
79 | |||
80 | VQDMULH_scalar 1110 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
81 | VQRDMULH_scalar 1111 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
82 | |||
83 | + | ||
84 | # Predicate operations | ||
85 | %mask_22_13 22:1 13:3 | ||
86 | VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13 | ||
87 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
88 | index XXXXXXX..XXXXXXX 100644 | ||
89 | --- a/target/arm/mve_helper.c | ||
90 | +++ b/target/arm/mve_helper.c | ||
91 | @@ -XXX,XX +XXX,XX @@ DO_2OP_SAT_SCALAR(vqrdmulh_scalarb, 1, int8_t, DO_QRDMULH_B) | ||
92 | DO_2OP_SAT_SCALAR(vqrdmulh_scalarh, 2, int16_t, DO_QRDMULH_H) | ||
93 | DO_2OP_SAT_SCALAR(vqrdmulh_scalarw, 4, int32_t, DO_QRDMULH_W) | ||
94 | |||
95 | +/* | ||
96 | + * Long saturating scalar ops. As with DO_2OP_L, TYPE and H are for the | ||
97 | + * input (smaller) type and LESIZE, LTYPE, LH for the output (long) type. | ||
98 | + * SATMASK specifies which bits of the predicate mask matter for determining | ||
99 | + * whether to propagate a saturation indication into FPSCR.QC -- for | ||
100 | + * the 16x16->32 case we must check only the bit corresponding to the T or B | ||
101 | + * half that we used, but for the 32x32->64 case we propagate if the mask | ||
102 | + * bit is set for either half. | ||
103 | + */ | ||
104 | +#define DO_2OP_SAT_SCALAR_L(OP, TOP, ESIZE, TYPE, LESIZE, LTYPE, FN, SATMASK) \ | ||
105 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, \ | ||
106 | + uint32_t rm) \ | ||
107 | + { \ | ||
108 | + LTYPE *d = vd; \ | ||
109 | + TYPE *n = vn; \ | ||
110 | + TYPE m = rm; \ | ||
111 | + uint16_t mask = mve_element_mask(env); \ | ||
112 | + unsigned le; \ | ||
113 | + bool qc = false; \ | ||
114 | + for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \ | ||
115 | + bool sat = false; \ | ||
116 | + LTYPE r = FN((LTYPE)n[H##ESIZE(le * 2 + TOP)], m, &sat); \ | ||
117 | + mergemask(&d[H##LESIZE(le)], r, mask); \ | ||
118 | + qc |= sat && (mask & SATMASK); \ | ||
119 | + } \ | ||
120 | + if (qc) { \ | ||
121 | + env->vfp.qc[0] = qc; \ | ||
122 | + } \ | ||
123 | + mve_advance_vpt(env); \ | ||
124 | + } | ||
125 | + | ||
126 | +static inline int32_t do_qdmullh(int16_t n, int16_t m, bool *sat) | ||
127 | +{ | ||
128 | + int64_t r = ((int64_t)n * m) * 2; | ||
129 | + return do_sat_bhw(r, INT32_MIN, INT32_MAX, sat); | ||
130 | +} | ||
131 | + | ||
132 | +static inline int64_t do_qdmullw(int32_t n, int32_t m, bool *sat) | ||
133 | +{ | ||
134 | + /* The multiply can't overflow, but the doubling might */ | ||
135 | + int64_t r = (int64_t)n * m; | ||
136 | + if (r > INT64_MAX / 2) { | ||
137 | + *sat = true; | ||
138 | + return INT64_MAX; | ||
139 | + } else if (r < INT64_MIN / 2) { | ||
140 | + *sat = true; | ||
141 | + return INT64_MIN; | ||
142 | + } else { | ||
143 | + return r * 2; | ||
144 | + } | ||
145 | +} | ||
146 | + | ||
147 | +#define SATMASK16B 1 | ||
148 | +#define SATMASK16T (1 << 2) | ||
149 | +#define SATMASK32 ((1 << 4) | 1) | ||
150 | + | ||
151 | +DO_2OP_SAT_SCALAR_L(vqdmullb_scalarh, 0, 2, int16_t, 4, int32_t, \ | ||
152 | + do_qdmullh, SATMASK16B) | ||
153 | +DO_2OP_SAT_SCALAR_L(vqdmullb_scalarw, 0, 4, int32_t, 8, int64_t, \ | ||
154 | + do_qdmullw, SATMASK32) | ||
155 | +DO_2OP_SAT_SCALAR_L(vqdmullt_scalarh, 1, 2, int16_t, 4, int32_t, \ | ||
156 | + do_qdmullh, SATMASK16T) | ||
157 | +DO_2OP_SAT_SCALAR_L(vqdmullt_scalarw, 1, 4, int32_t, 8, int64_t, \ | ||
158 | + do_qdmullw, SATMASK32) | ||
159 | + | ||
160 | static inline uint32_t do_vbrsrb(uint32_t n, uint32_t m) | ||
161 | { | ||
162 | m &= 0xff; | ||
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 @@ DO_2OP_SCALAR(VQDMULH_scalar, vqdmulh_scalar) | ||
168 | DO_2OP_SCALAR(VQRDMULH_scalar, vqrdmulh_scalar) | ||
169 | DO_2OP_SCALAR(VBRSR, vbrsr) | ||
170 | |||
171 | +static bool trans_VQDMULLB_scalar(DisasContext *s, arg_2scalar *a) | ||
172 | +{ | ||
173 | + static MVEGenTwoOpScalarFn * const fns[] = { | ||
174 | + NULL, | ||
175 | + gen_helper_mve_vqdmullb_scalarh, | ||
176 | + gen_helper_mve_vqdmullb_scalarw, | ||
177 | + NULL, | ||
178 | + }; | ||
179 | + if (a->qd == a->qn && a->size == MO_32) { | ||
180 | + /* UNPREDICTABLE; we choose to undef */ | ||
181 | + return false; | ||
182 | + } | ||
183 | + return do_2op_scalar(s, a, fns[a->size]); | ||
184 | +} | ||
185 | + | ||
186 | +static bool trans_VQDMULLT_scalar(DisasContext *s, arg_2scalar *a) | ||
187 | +{ | ||
188 | + static MVEGenTwoOpScalarFn * const fns[] = { | ||
189 | + NULL, | ||
190 | + gen_helper_mve_vqdmullt_scalarh, | ||
191 | + gen_helper_mve_vqdmullt_scalarw, | ||
192 | + NULL, | ||
193 | + }; | ||
194 | + if (a->qd == a->qn && a->size == MO_32) { | ||
195 | + /* UNPREDICTABLE; we choose to undef */ | ||
196 | + return false; | ||
197 | + } | ||
198 | + return do_2op_scalar(s, a, fns[a->size]); | ||
199 | +} | ||
200 | + | ||
201 | static bool do_long_dual_acc(DisasContext *s, arg_vmlaldav *a, | ||
202 | MVEGenDualAccOpFn *fn) | ||
203 | { | ||
204 | -- | ||
205 | 2.20.1 | ||
206 | |||
207 | diff view generated by jsdifflib |
1 | Implement the MVE VSHL insn (vector form). | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | 2 | ||
3 | This allows the test to be skipped when TCG is not present in the QEMU | ||
4 | binary. | ||
5 | |||
6 | Signed-off-by: Fabiano Rosas <farosas@suse.de> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20210617121628.20116-35-peter.maydell@linaro.org | ||
6 | --- | 10 | --- |
7 | target/arm/helper-mve.h | 8 ++++++++ | 11 | tests/avocado/boot_linux_console.py | 1 + |
8 | target/arm/mve.decode | 3 +++ | 12 | tests/avocado/reverse_debugging.py | 8 ++++++++ |
9 | target/arm/mve_helper.c | 6 ++++++ | 13 | 2 files changed, 9 insertions(+) |
10 | target/arm/translate-mve.c | 2 ++ | ||
11 | 4 files changed, 19 insertions(+) | ||
12 | 14 | ||
13 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 15 | diff --git a/tests/avocado/boot_linux_console.py b/tests/avocado/boot_linux_console.py |
14 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/helper-mve.h | 17 | --- a/tests/avocado/boot_linux_console.py |
16 | +++ b/target/arm/helper-mve.h | 18 | +++ b/tests/avocado/boot_linux_console.py |
17 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqsubub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 19 | @@ -XXX,XX +XXX,XX @@ def test_arm_orangepi_uboot_netbsd9(self): |
18 | DEF_HELPER_FLAGS_4(mve_vqsubuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 20 | |
19 | DEF_HELPER_FLAGS_4(mve_vqsubuw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 21 | def test_aarch64_raspi3_atf(self): |
20 | 22 | """ | |
21 | +DEF_HELPER_FLAGS_4(mve_vshlsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 23 | + :avocado: tags=accel:tcg |
22 | +DEF_HELPER_FLAGS_4(mve_vshlsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 24 | :avocado: tags=arch:aarch64 |
23 | +DEF_HELPER_FLAGS_4(mve_vshlsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 25 | :avocado: tags=machine:raspi3b |
26 | :avocado: tags=cpu:cortex-a53 | ||
27 | diff --git a/tests/avocado/reverse_debugging.py b/tests/avocado/reverse_debugging.py | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/tests/avocado/reverse_debugging.py | ||
30 | +++ b/tests/avocado/reverse_debugging.py | ||
31 | @@ -XXX,XX +XXX,XX @@ def reverse_debugging(self, shift=7, args=None): | ||
32 | vm.shutdown() | ||
33 | |||
34 | class ReverseDebugging_X86_64(ReverseDebugging): | ||
35 | + """ | ||
36 | + :avocado: tags=accel:tcg | ||
37 | + """ | ||
24 | + | 38 | + |
25 | +DEF_HELPER_FLAGS_4(mve_vshlub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 39 | REG_PC = 0x10 |
26 | +DEF_HELPER_FLAGS_4(mve_vshluh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 40 | REG_CS = 0x12 |
27 | +DEF_HELPER_FLAGS_4(mve_vshluw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 41 | def get_pc(self, g): |
42 | @@ -XXX,XX +XXX,XX @@ def test_x86_64_pc(self): | ||
43 | self.reverse_debugging() | ||
44 | |||
45 | class ReverseDebugging_AArch64(ReverseDebugging): | ||
46 | + """ | ||
47 | + :avocado: tags=accel:tcg | ||
48 | + """ | ||
28 | + | 49 | + |
29 | DEF_HELPER_FLAGS_4(mve_vqshlsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 50 | REG_PC = 32 |
30 | DEF_HELPER_FLAGS_4(mve_vqshlsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 51 | |
31 | DEF_HELPER_FLAGS_4(mve_vqshlsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 52 | # unidentified gitlab timeout problem |
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 @@ VQADD_U 111 1 1111 0 . .. ... 0 ... 0 0000 . 1 . 1 ... 0 @2op | ||
37 | VQSUB_S 111 0 1111 0 . .. ... 0 ... 0 0010 . 1 . 1 ... 0 @2op | ||
38 | VQSUB_U 111 1 1111 0 . .. ... 0 ... 0 0010 . 1 . 1 ... 0 @2op | ||
39 | |||
40 | +VSHL_S 111 0 1111 0 . .. ... 0 ... 0 0100 . 1 . 0 ... 0 @2op_rev | ||
41 | +VSHL_U 111 1 1111 0 . .. ... 0 ... 0 0100 . 1 . 0 ... 0 @2op_rev | ||
42 | + | ||
43 | VQSHL_S 111 0 1111 0 . .. ... 0 ... 0 0100 . 1 . 1 ... 0 @2op_rev | ||
44 | VQSHL_U 111 1 1111 0 . .. ... 0 ... 0 0100 . 1 . 1 ... 0 @2op_rev | ||
45 | |||
46 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/target/arm/mve_helper.c | ||
49 | +++ b/target/arm/mve_helper.c | ||
50 | @@ -XXX,XX +XXX,XX @@ DO_2OP_U(vhaddu, do_vhadd_u) | ||
51 | DO_2OP_S(vhsubs, do_vhsub_s) | ||
52 | DO_2OP_U(vhsubu, do_vhsub_u) | ||
53 | |||
54 | +#define DO_VSHLS(N, M) do_sqrshl_bhs(N, (int8_t)(M), sizeof(N) * 8, false, NULL) | ||
55 | +#define DO_VSHLU(N, M) do_uqrshl_bhs(N, (int8_t)(M), sizeof(N) * 8, false, NULL) | ||
56 | + | ||
57 | +DO_2OP_S(vshls, DO_VSHLS) | ||
58 | +DO_2OP_U(vshlu, DO_VSHLU) | ||
59 | + | ||
60 | static inline int32_t do_sat_bhw(int64_t val, int64_t min, int64_t max, bool *s) | ||
61 | { | ||
62 | if (val > max) { | ||
63 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
64 | index XXXXXXX..XXXXXXX 100644 | ||
65 | --- a/target/arm/translate-mve.c | ||
66 | +++ b/target/arm/translate-mve.c | ||
67 | @@ -XXX,XX +XXX,XX @@ DO_2OP(VQADD_S, vqadds) | ||
68 | DO_2OP(VQADD_U, vqaddu) | ||
69 | DO_2OP(VQSUB_S, vqsubs) | ||
70 | DO_2OP(VQSUB_U, vqsubu) | ||
71 | +DO_2OP(VSHL_S, vshls) | ||
72 | +DO_2OP(VSHL_U, vshlu) | ||
73 | DO_2OP(VQSHL_S, vqshls) | ||
74 | DO_2OP(VQSHL_U, vqshlu) | ||
75 | DO_2OP(VQRSHL_S, vqrshls) | ||
76 | -- | 53 | -- |
77 | 2.20.1 | 54 | 2.34.1 |
78 | 55 | ||
79 | 56 | diff view generated by jsdifflib |
1 | Implement the MV VQRSHL (vector) insn. Again, the code to perform | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | the actual shifts is borrowed from neon_helper.c. | ||
3 | 2 | ||
3 | Now that the cortex-a15 is under CONFIG_TCG, use as default CPU for a | ||
4 | KVM-only build the 'max' cpu. | ||
5 | |||
6 | Note that we cannot use 'host' here because the qtests can run without | ||
7 | any other accelerator (than qtest) and 'host' depends on KVM being | ||
8 | enabled. | ||
9 | |||
10 | Signed-off-by: Fabiano Rosas <farosas@suse.de> | ||
11 | Acked-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20210617121628.20116-34-peter.maydell@linaro.org | ||
7 | --- | 14 | --- |
8 | target/arm/helper-mve.h | 8 ++++++++ | 15 | hw/arm/virt.c | 4 ++++ |
9 | target/arm/mve.decode | 3 +++ | 16 | 1 file changed, 4 insertions(+) |
10 | target/arm/mve_helper.c | 6 ++++++ | ||
11 | target/arm/translate-mve.c | 2 ++ | ||
12 | 4 files changed, 19 insertions(+) | ||
13 | 17 | ||
14 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 18 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c |
15 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/helper-mve.h | 20 | --- a/hw/arm/virt.c |
17 | +++ b/target/arm/helper-mve.h | 21 | +++ b/hw/arm/virt.c |
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqshlub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 22 | @@ -XXX,XX +XXX,XX @@ static void virt_machine_class_init(ObjectClass *oc, void *data) |
19 | DEF_HELPER_FLAGS_4(mve_vqshluh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 23 | mc->minimum_page_bits = 12; |
20 | DEF_HELPER_FLAGS_4(mve_vqshluw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 24 | mc->possible_cpu_arch_ids = virt_possible_cpu_arch_ids; |
21 | 25 | mc->cpu_index_to_instance_props = virt_cpu_index_to_props; | |
22 | +DEF_HELPER_FLAGS_4(mve_vqrshlsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 26 | +#ifdef CONFIG_TCG |
23 | +DEF_HELPER_FLAGS_4(mve_vqrshlsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 27 | mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15"); |
24 | +DEF_HELPER_FLAGS_4(mve_vqrshlsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 28 | +#else |
25 | + | 29 | + mc->default_cpu_type = ARM_CPU_TYPE_NAME("max"); |
26 | +DEF_HELPER_FLAGS_4(mve_vqrshlub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 30 | +#endif |
27 | +DEF_HELPER_FLAGS_4(mve_vqrshluh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 31 | mc->get_default_cpu_node_id = virt_get_default_cpu_node_id; |
28 | +DEF_HELPER_FLAGS_4(mve_vqrshluw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 32 | mc->kvm_type = virt_kvm_type; |
29 | + | 33 | assert(!mc->get_hotplug_handler); |
30 | DEF_HELPER_FLAGS_4(mve_vadd_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
31 | DEF_HELPER_FLAGS_4(mve_vadd_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
32 | DEF_HELPER_FLAGS_4(mve_vadd_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
33 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/target/arm/mve.decode | ||
36 | +++ b/target/arm/mve.decode | ||
37 | @@ -XXX,XX +XXX,XX @@ VQSUB_U 111 1 1111 0 . .. ... 0 ... 0 0010 . 1 . 1 ... 0 @2op | ||
38 | VQSHL_S 111 0 1111 0 . .. ... 0 ... 0 0100 . 1 . 1 ... 0 @2op_rev | ||
39 | VQSHL_U 111 1 1111 0 . .. ... 0 ... 0 0100 . 1 . 1 ... 0 @2op_rev | ||
40 | |||
41 | +VQRSHL_S 111 0 1111 0 . .. ... 0 ... 0 0101 . 1 . 1 ... 0 @2op_rev | ||
42 | +VQRSHL_U 111 1 1111 0 . .. ... 0 ... 0 0101 . 1 . 1 ... 0 @2op_rev | ||
43 | + | ||
44 | # Vector miscellaneous | ||
45 | |||
46 | VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op | ||
47 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/target/arm/mve_helper.c | ||
50 | +++ b/target/arm/mve_helper.c | ||
51 | @@ -XXX,XX +XXX,XX @@ DO_2OP_SAT(vqsubsw, 4, int32_t, DO_SQSUB_W) | ||
52 | WRAP_QRSHL_HELPER(do_sqrshl_bhs, N, M, false, satp) | ||
53 | #define DO_UQSHL_OP(N, M, satp) \ | ||
54 | WRAP_QRSHL_HELPER(do_uqrshl_bhs, N, M, false, satp) | ||
55 | +#define DO_SQRSHL_OP(N, M, satp) \ | ||
56 | + WRAP_QRSHL_HELPER(do_sqrshl_bhs, N, M, true, satp) | ||
57 | +#define DO_UQRSHL_OP(N, M, satp) \ | ||
58 | + WRAP_QRSHL_HELPER(do_uqrshl_bhs, N, M, true, satp) | ||
59 | |||
60 | DO_2OP_SAT_S(vqshls, DO_SQSHL_OP) | ||
61 | DO_2OP_SAT_U(vqshlu, DO_UQSHL_OP) | ||
62 | +DO_2OP_SAT_S(vqrshls, DO_SQRSHL_OP) | ||
63 | +DO_2OP_SAT_U(vqrshlu, DO_UQRSHL_OP) | ||
64 | |||
65 | #define DO_2OP_SCALAR(OP, ESIZE, TYPE, FN) \ | ||
66 | void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, \ | ||
67 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
68 | index XXXXXXX..XXXXXXX 100644 | ||
69 | --- a/target/arm/translate-mve.c | ||
70 | +++ b/target/arm/translate-mve.c | ||
71 | @@ -XXX,XX +XXX,XX @@ DO_2OP(VQSUB_S, vqsubs) | ||
72 | DO_2OP(VQSUB_U, vqsubu) | ||
73 | DO_2OP(VQSHL_S, vqshls) | ||
74 | DO_2OP(VQSHL_U, vqshlu) | ||
75 | +DO_2OP(VQRSHL_S, vqrshls) | ||
76 | +DO_2OP(VQRSHL_U, vqrshlu) | ||
77 | |||
78 | static bool do_2op_scalar(DisasContext *s, arg_2scalar *a, | ||
79 | MVEGenTwoOpScalarFn fn) | ||
80 | -- | 34 | -- |
81 | 2.20.1 | 35 | 2.34.1 |
82 | |||
83 | diff view generated by jsdifflib |
1 | In a CPU with MVE, the VMOV (vector lane to general-purpose register) | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | and VMOV (general-purpose register to vector lane) insns are not | ||
3 | predicated, but they are subject to beatwise execution if they | ||
4 | are not in an IT block. | ||
5 | 2 | ||
6 | Since our implementation always executes all 4 beats in one tick, | 3 | Signed-off-by: Fabiano Rosas <farosas@suse.de> |
7 | this means only that we need to handle PSR.ECI: | 4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | * we must do the usual check for bad ECI state | 5 | Acked-by: Thomas Huth <thuth@redhat.com> |
9 | * we must advance ECI state if the insn succeeds | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | * if ECI says we should not be executing the beat corresponding | 7 | --- |
11 | to the lane of the vector register being accessed then we | 8 | tests/qtest/arm-cpu-features.c | 28 ++++++++++++++++++---------- |
12 | should skip performing the move | 9 | 1 file changed, 18 insertions(+), 10 deletions(-) |
13 | 10 | ||
14 | Note that if PSR.ECI is non-zero then we cannot be in an IT block. | 11 | diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c |
15 | |||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
18 | Message-id: 20210617121628.20116-45-peter.maydell@linaro.org | ||
19 | --- | ||
20 | target/arm/translate-a32.h | 2 + | ||
21 | target/arm/translate-mve.c | 4 +- | ||
22 | target/arm/translate-vfp.c | 77 +++++++++++++++++++++++++++++++++++--- | ||
23 | 3 files changed, 75 insertions(+), 8 deletions(-) | ||
24 | |||
25 | diff --git a/target/arm/translate-a32.h b/target/arm/translate-a32.h | ||
26 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/target/arm/translate-a32.h | 13 | --- a/tests/qtest/arm-cpu-features.c |
28 | +++ b/target/arm/translate-a32.h | 14 | +++ b/tests/qtest/arm-cpu-features.c |
29 | @@ -XXX,XX +XXX,XX @@ long neon_full_reg_offset(unsigned reg); | 15 | @@ -XXX,XX +XXX,XX @@ |
30 | long neon_element_offset(int reg, int element, MemOp memop); | 16 | #define SVE_MAX_VQ 16 |
31 | void gen_rev16(TCGv_i32 dest, TCGv_i32 var); | 17 | |
32 | void clear_eci_state(DisasContext *s); | 18 | #define MACHINE "-machine virt,gic-version=max -accel tcg " |
33 | +bool mve_eci_check(DisasContext *s); | 19 | -#define MACHINE_KVM "-machine virt,gic-version=max -accel kvm -accel tcg " |
34 | +void mve_update_and_store_eci(DisasContext *s); | 20 | +#define MACHINE_KVM "-machine virt,gic-version=max -accel kvm " |
35 | 21 | #define QUERY_HEAD "{ 'execute': 'query-cpu-model-expansion', " \ | |
36 | static inline TCGv_i32 load_cpu_offset(int offset) | 22 | " 'arguments': { 'type': 'full', " |
23 | #define QUERY_TAIL "}}" | ||
24 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv) | ||
37 | { | 25 | { |
38 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | 26 | g_test_init(&argc, &argv, NULL); |
39 | index XXXXXXX..XXXXXXX 100644 | 27 | |
40 | --- a/target/arm/translate-mve.c | 28 | - qtest_add_data_func("/arm/query-cpu-model-expansion", |
41 | +++ b/target/arm/translate-mve.c | 29 | - NULL, test_query_cpu_model_expansion); |
42 | @@ -XXX,XX +XXX,XX @@ static bool mve_check_qreg_bank(DisasContext *s, int qmask) | 30 | + if (qtest_has_accel("tcg")) { |
43 | return qmask < 8; | 31 | + qtest_add_data_func("/arm/query-cpu-model-expansion", |
44 | } | 32 | + NULL, test_query_cpu_model_expansion); |
45 | |||
46 | -static bool mve_eci_check(DisasContext *s) | ||
47 | +bool mve_eci_check(DisasContext *s) | ||
48 | { | ||
49 | /* | ||
50 | * This is a beatwise insn: check that ECI is valid (not a | ||
51 | @@ -XXX,XX +XXX,XX @@ static void mve_update_eci(DisasContext *s) | ||
52 | } | ||
53 | } | ||
54 | |||
55 | -static void mve_update_and_store_eci(DisasContext *s) | ||
56 | +void mve_update_and_store_eci(DisasContext *s) | ||
57 | { | ||
58 | /* | ||
59 | * For insns which don't call a helper function that will call | ||
60 | diff --git a/target/arm/translate-vfp.c b/target/arm/translate-vfp.c | ||
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/target/arm/translate-vfp.c | ||
63 | +++ b/target/arm/translate-vfp.c | ||
64 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT(DisasContext *s, arg_VCVT *a) | ||
65 | return true; | ||
66 | } | ||
67 | |||
68 | +static bool mve_skip_vmov(DisasContext *s, int vn, int index, int size) | ||
69 | +{ | ||
70 | + /* | ||
71 | + * In a CPU with MVE, the VMOV (vector lane to general-purpose register) | ||
72 | + * and VMOV (general-purpose register to vector lane) insns are not | ||
73 | + * predicated, but they are subject to beatwise execution if they are | ||
74 | + * not in an IT block. | ||
75 | + * | ||
76 | + * Since our implementation always executes all 4 beats in one tick, | ||
77 | + * this means only that if PSR.ECI says we should not be executing | ||
78 | + * the beat corresponding to the lane of the vector register being | ||
79 | + * accessed then we should skip performing the move, and that we need | ||
80 | + * to do the usual check for bad ECI state and advance of ECI state. | ||
81 | + * | ||
82 | + * Note that if PSR.ECI is non-zero then we cannot be in an IT block. | ||
83 | + * | ||
84 | + * Return true if this VMOV scalar <-> gpreg should be skipped because | ||
85 | + * the MVE PSR.ECI state says we skip the beat where the store happens. | ||
86 | + */ | ||
87 | + | ||
88 | + /* Calculate the byte offset into Qn which we're going to access */ | ||
89 | + int ofs = (index << size) + ((vn & 1) * 8); | ||
90 | + | ||
91 | + if (!dc_isar_feature(aa32_mve, s)) { | ||
92 | + return false; | ||
93 | + } | 33 | + } |
94 | + | 34 | + |
95 | + switch (s->eci) { | 35 | + if (!g_str_equal(qtest_get_arch(), "aarch64")) { |
96 | + case ECI_NONE: | 36 | + goto out; |
97 | + return false; | ||
98 | + case ECI_A0: | ||
99 | + return ofs < 4; | ||
100 | + case ECI_A0A1: | ||
101 | + return ofs < 8; | ||
102 | + case ECI_A0A1A2: | ||
103 | + case ECI_A0A1A2B0: | ||
104 | + return ofs < 12; | ||
105 | + default: | ||
106 | + g_assert_not_reached(); | ||
107 | + } | 37 | + } |
108 | +} | 38 | |
109 | + | 39 | /* |
110 | static bool trans_VMOV_to_gp(DisasContext *s, arg_VMOV_to_gp *a) | 40 | * For now we only run KVM specific tests with AArch64 QEMU in |
111 | { | 41 | * order avoid attempting to run an AArch32 QEMU with KVM on |
112 | /* VMOV scalar to general purpose register */ | 42 | * AArch64 hosts. That won't work and isn't easy to detect. |
113 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_to_gp(DisasContext *s, arg_VMOV_to_gp *a) | 43 | */ |
114 | return false; | 44 | - if (g_str_equal(qtest_get_arch(), "aarch64") && qtest_has_accel("kvm")) { |
45 | + if (qtest_has_accel("kvm")) { | ||
46 | /* | ||
47 | * This tests target the 'host' CPU type, so register it only if | ||
48 | * KVM is available. | ||
49 | */ | ||
50 | qtest_add_data_func("/arm/kvm/query-cpu-model-expansion", | ||
51 | NULL, test_query_cpu_model_expansion_kvm); | ||
52 | - } | ||
53 | |||
54 | - if (g_str_equal(qtest_get_arch(), "aarch64")) { | ||
55 | - qtest_add_data_func("/arm/max/query-cpu-model-expansion/sve-max-vq-8", | ||
56 | - NULL, sve_tests_sve_max_vq_8); | ||
57 | - qtest_add_data_func("/arm/max/query-cpu-model-expansion/sve-off", | ||
58 | - NULL, sve_tests_sve_off); | ||
59 | qtest_add_data_func("/arm/kvm/query-cpu-model-expansion/sve-off", | ||
60 | NULL, sve_tests_sve_off_kvm); | ||
115 | } | 61 | } |
116 | 62 | ||
117 | + if (dc_isar_feature(aa32_mve, s)) { | 63 | + if (qtest_has_accel("tcg")) { |
118 | + if (!mve_eci_check(s)) { | 64 | + qtest_add_data_func("/arm/max/query-cpu-model-expansion/sve-max-vq-8", |
119 | + return true; | 65 | + NULL, sve_tests_sve_max_vq_8); |
120 | + } | 66 | + qtest_add_data_func("/arm/max/query-cpu-model-expansion/sve-off", |
67 | + NULL, sve_tests_sve_off); | ||
121 | + } | 68 | + } |
122 | + | 69 | + |
123 | if (!vfp_access_check(s)) { | 70 | +out: |
124 | return true; | 71 | return g_test_run(); |
125 | } | ||
126 | |||
127 | - tmp = tcg_temp_new_i32(); | ||
128 | - read_neon_element32(tmp, a->vn, a->index, a->size | (a->u ? 0 : MO_SIGN)); | ||
129 | - store_reg(s, a->rt, tmp); | ||
130 | + if (!mve_skip_vmov(s, a->vn, a->index, a->size)) { | ||
131 | + tmp = tcg_temp_new_i32(); | ||
132 | + read_neon_element32(tmp, a->vn, a->index, | ||
133 | + a->size | (a->u ? 0 : MO_SIGN)); | ||
134 | + store_reg(s, a->rt, tmp); | ||
135 | + } | ||
136 | |||
137 | + if (dc_isar_feature(aa32_mve, s)) { | ||
138 | + mve_update_and_store_eci(s); | ||
139 | + } | ||
140 | return true; | ||
141 | } | 72 | } |
142 | |||
143 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_from_gp(DisasContext *s, arg_VMOV_from_gp *a) | ||
144 | return false; | ||
145 | } | ||
146 | |||
147 | + if (dc_isar_feature(aa32_mve, s)) { | ||
148 | + if (!mve_eci_check(s)) { | ||
149 | + return true; | ||
150 | + } | ||
151 | + } | ||
152 | + | ||
153 | if (!vfp_access_check(s)) { | ||
154 | return true; | ||
155 | } | ||
156 | |||
157 | - tmp = load_reg(s, a->rt); | ||
158 | - write_neon_element32(tmp, a->vn, a->index, a->size); | ||
159 | - tcg_temp_free_i32(tmp); | ||
160 | + if (!mve_skip_vmov(s, a->vn, a->index, a->size)) { | ||
161 | + tmp = load_reg(s, a->rt); | ||
162 | + write_neon_element32(tmp, a->vn, a->index, a->size); | ||
163 | + tcg_temp_free_i32(tmp); | ||
164 | + } | ||
165 | |||
166 | + if (dc_isar_feature(aa32_mve, s)) { | ||
167 | + mve_update_and_store_eci(s); | ||
168 | + } | ||
169 | return true; | ||
170 | } | ||
171 | |||
172 | -- | 73 | -- |
173 | 2.20.1 | 74 | 2.34.1 |
174 | |||
175 | diff view generated by jsdifflib |
1 | Implement the vector forms of the MVE VQADD and VQSUB insns. | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | 2 | ||
3 | These tests set -accel tcg, so restrict them to when TCG is present. | ||
4 | |||
5 | Signed-off-by: Fabiano Rosas <farosas@suse.de> | ||
6 | Acked-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20210617121628.20116-32-peter.maydell@linaro.org | ||
6 | --- | 9 | --- |
7 | target/arm/helper-mve.h | 16 ++++++++++++++++ | 10 | tests/qtest/meson.build | 4 ++-- |
8 | target/arm/mve.decode | 5 +++++ | 11 | 1 file changed, 2 insertions(+), 2 deletions(-) |
9 | target/arm/mve_helper.c | 14 ++++++++++++++ | ||
10 | target/arm/translate-mve.c | 4 ++++ | ||
11 | 4 files changed, 39 insertions(+) | ||
12 | 12 | ||
13 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 13 | diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build |
14 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/helper-mve.h | 15 | --- a/tests/qtest/meson.build |
16 | +++ b/target/arm/helper-mve.h | 16 | +++ b/tests/qtest/meson.build |
17 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqrdmulhb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 17 | @@ -XXX,XX +XXX,XX @@ qtests_arm = \ |
18 | DEF_HELPER_FLAGS_4(mve_vqrdmulhh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 18 | # TODO: once aarch64 TCG is fixed on ARM 32 bit host, make bios-tables-test unconditional |
19 | DEF_HELPER_FLAGS_4(mve_vqrdmulhw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 19 | qtests_aarch64 = \ |
20 | 20 | (cpu != 'arm' and unpack_edk2_blobs ? ['bios-tables-test'] : []) + \ | |
21 | +DEF_HELPER_FLAGS_4(mve_vqaddsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 21 | - (config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? ['tpm-tis-device-test'] : []) + \ |
22 | +DEF_HELPER_FLAGS_4(mve_vqaddsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 22 | - (config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? ['tpm-tis-device-swtpm-test'] : []) + \ |
23 | +DEF_HELPER_FLAGS_4(mve_vqaddsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 23 | + (config_all.has_key('CONFIG_TCG') and config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? \ |
24 | + | 24 | + ['tpm-tis-device-test', 'tpm-tis-device-swtpm-test'] : []) + \ |
25 | +DEF_HELPER_FLAGS_4(mve_vqaddub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 25 | (config_all_devices.has_key('CONFIG_XLNX_ZYNQMP_ARM') ? ['xlnx-can-test', 'fuzz-xlnx-dp-test'] : []) + \ |
26 | +DEF_HELPER_FLAGS_4(mve_vqadduh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 26 | (config_all_devices.has_key('CONFIG_RASPI') ? ['bcm2835-dma-test'] : []) + \ |
27 | +DEF_HELPER_FLAGS_4(mve_vqadduw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 27 | ['arm-cpu-features', |
28 | + | ||
29 | +DEF_HELPER_FLAGS_4(mve_vqsubsb, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
30 | +DEF_HELPER_FLAGS_4(mve_vqsubsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
31 | +DEF_HELPER_FLAGS_4(mve_vqsubsw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
32 | + | ||
33 | +DEF_HELPER_FLAGS_4(mve_vqsubub, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
34 | +DEF_HELPER_FLAGS_4(mve_vqsubuh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
35 | +DEF_HELPER_FLAGS_4(mve_vqsubuw, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
36 | + | ||
37 | DEF_HELPER_FLAGS_4(mve_vadd_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
38 | DEF_HELPER_FLAGS_4(mve_vadd_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
39 | DEF_HELPER_FLAGS_4(mve_vadd_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
40 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/target/arm/mve.decode | ||
43 | +++ b/target/arm/mve.decode | ||
44 | @@ -XXX,XX +XXX,XX @@ VMULL_TU 111 1 1110 0 . .. ... 1 ... 1 1110 . 0 . 0 ... 0 @2op | ||
45 | VQDMULH 1110 1111 0 . .. ... 0 ... 0 1011 . 1 . 0 ... 0 @2op | ||
46 | VQRDMULH 1111 1111 0 . .. ... 0 ... 0 1011 . 1 . 0 ... 0 @2op | ||
47 | |||
48 | +VQADD_S 111 0 1111 0 . .. ... 0 ... 0 0000 . 1 . 1 ... 0 @2op | ||
49 | +VQADD_U 111 1 1111 0 . .. ... 0 ... 0 0000 . 1 . 1 ... 0 @2op | ||
50 | +VQSUB_S 111 0 1111 0 . .. ... 0 ... 0 0010 . 1 . 1 ... 0 @2op | ||
51 | +VQSUB_U 111 1 1111 0 . .. ... 0 ... 0 0010 . 1 . 1 ... 0 @2op | ||
52 | + | ||
53 | # Vector miscellaneous | ||
54 | |||
55 | VCLS 1111 1111 1 . 11 .. 00 ... 0 0100 01 . 0 ... 0 @1op | ||
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_2OP_SAT(vqrdmulhb, 1, int8_t, DO_QRDMULH_B) | ||
61 | DO_2OP_SAT(vqrdmulhh, 2, int16_t, DO_QRDMULH_H) | ||
62 | DO_2OP_SAT(vqrdmulhw, 4, int32_t, DO_QRDMULH_W) | ||
63 | |||
64 | +DO_2OP_SAT(vqaddub, 1, uint8_t, DO_UQADD_B) | ||
65 | +DO_2OP_SAT(vqadduh, 2, uint16_t, DO_UQADD_H) | ||
66 | +DO_2OP_SAT(vqadduw, 4, uint32_t, DO_UQADD_W) | ||
67 | +DO_2OP_SAT(vqaddsb, 1, int8_t, DO_SQADD_B) | ||
68 | +DO_2OP_SAT(vqaddsh, 2, int16_t, DO_SQADD_H) | ||
69 | +DO_2OP_SAT(vqaddsw, 4, int32_t, DO_SQADD_W) | ||
70 | + | ||
71 | +DO_2OP_SAT(vqsubub, 1, uint8_t, DO_UQSUB_B) | ||
72 | +DO_2OP_SAT(vqsubuh, 2, uint16_t, DO_UQSUB_H) | ||
73 | +DO_2OP_SAT(vqsubuw, 4, uint32_t, DO_UQSUB_W) | ||
74 | +DO_2OP_SAT(vqsubsb, 1, int8_t, DO_SQSUB_B) | ||
75 | +DO_2OP_SAT(vqsubsh, 2, int16_t, DO_SQSUB_H) | ||
76 | +DO_2OP_SAT(vqsubsw, 4, int32_t, DO_SQSUB_W) | ||
77 | + | ||
78 | #define DO_2OP_SCALAR(OP, ESIZE, TYPE, FN) \ | ||
79 | void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vn, \ | ||
80 | uint32_t rm) \ | ||
81 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
82 | index XXXXXXX..XXXXXXX 100644 | ||
83 | --- a/target/arm/translate-mve.c | ||
84 | +++ b/target/arm/translate-mve.c | ||
85 | @@ -XXX,XX +XXX,XX @@ DO_2OP(VMULL_TS, vmullts) | ||
86 | DO_2OP(VMULL_TU, vmulltu) | ||
87 | DO_2OP(VQDMULH, vqdmulh) | ||
88 | DO_2OP(VQRDMULH, vqrdmulh) | ||
89 | +DO_2OP(VQADD_S, vqadds) | ||
90 | +DO_2OP(VQADD_U, vqaddu) | ||
91 | +DO_2OP(VQSUB_S, vqsubs) | ||
92 | +DO_2OP(VQSUB_U, vqsubu) | ||
93 | |||
94 | static bool do_2op_scalar(DisasContext *s, arg_2scalar *a, | ||
95 | MVEGenTwoOpScalarFn fn) | ||
96 | -- | 28 | -- |
97 | 2.20.1 | 29 | 2.34.1 |
98 | |||
99 | diff view generated by jsdifflib |