1 | The following changes since commit 5a67d7735d4162630769ef495cf813244fc850df: | 1 | I don't have anything else queued up at the moment, so this is just |
---|---|---|---|
2 | Richard's SME patches. | ||
2 | 3 | ||
3 | Merge remote-tracking branch 'remotes/berrange-gitlab/tags/tls-deps-pull-request' into staging (2021-07-02 08:22:39 +0100) | 4 | -- PMM |
5 | |||
6 | The following changes since commit 63b38f6c85acd312c2cab68554abf33adf4ee2b3: | ||
7 | |||
8 | Merge tag 'pull-target-arm-20220707' of https://git.linaro.org/people/pmaydell/qemu-arm into staging (2022-07-08 06:17:11 +0530) | ||
4 | 9 | ||
5 | are available in the Git repository at: | 10 | are available in the Git repository at: |
6 | 11 | ||
7 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210702 | 12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220711 |
8 | 13 | ||
9 | for you to fetch changes up to 04ea4d3cfd0a21b248ece8eb7a9436a3d9898dd8: | 14 | for you to fetch changes up to f9982ceaf26df27d15547a3a7990a95019e9e3a8: |
10 | 15 | ||
11 | target/arm: Implement MVE shifts by register (2021-07-02 11:48:38 +0100) | 16 | linux-user/aarch64: Add SME related hwcap entries (2022-07-11 13:43:52 +0100) |
12 | 17 | ||
13 | ---------------------------------------------------------------- | 18 | ---------------------------------------------------------------- |
14 | target-arm queue: | 19 | target-arm: |
15 | * more MVE instructions | 20 | * Implement SME emulation, for both system and linux-user |
16 | * hw/gpio/gpio_pwr: use shutdown function for reboot | ||
17 | * target/arm: Check NaN mode before silencing NaN | ||
18 | * tests: Boot and halt a Linux guest on the Raspberry Pi 2 machine | ||
19 | * hw/arm: Add basic power management to raspi. | ||
20 | * docs/system/arm: Add quanta-gbs-bmc, quanta-q7l1-bmc | ||
21 | 21 | ||
22 | ---------------------------------------------------------------- | 22 | ---------------------------------------------------------------- |
23 | Joe Komlodi (1): | 23 | Richard Henderson (45): |
24 | target/arm: Check NaN mode before silencing NaN | 24 | target/arm: Handle SME in aarch64_cpu_dump_state |
25 | target/arm: Add infrastructure for disas_sme | ||
26 | target/arm: Trap non-streaming usage when Streaming SVE is active | ||
27 | target/arm: Mark ADR as non-streaming | ||
28 | target/arm: Mark RDFFR, WRFFR, SETFFR as non-streaming | ||
29 | target/arm: Mark BDEP, BEXT, BGRP, COMPACT, FEXPA, FTSSEL as non-streaming | ||
30 | target/arm: Mark PMULL, FMMLA as non-streaming | ||
31 | target/arm: Mark FTSMUL, FTMAD, FADDA as non-streaming | ||
32 | target/arm: Mark SMMLA, UMMLA, USMMLA as non-streaming | ||
33 | target/arm: Mark string/histo/crypto as non-streaming | ||
34 | target/arm: Mark gather/scatter load/store as non-streaming | ||
35 | target/arm: Mark gather prefetch as non-streaming | ||
36 | target/arm: Mark LDFF1 and LDNF1 as non-streaming | ||
37 | target/arm: Mark LD1RO as non-streaming | ||
38 | target/arm: Add SME enablement checks | ||
39 | target/arm: Handle SME in sve_access_check | ||
40 | target/arm: Implement SME RDSVL, ADDSVL, ADDSPL | ||
41 | target/arm: Implement SME ZERO | ||
42 | target/arm: Implement SME MOVA | ||
43 | target/arm: Implement SME LD1, ST1 | ||
44 | target/arm: Export unpredicated ld/st from translate-sve.c | ||
45 | target/arm: Implement SME LDR, STR | ||
46 | target/arm: Implement SME ADDHA, ADDVA | ||
47 | target/arm: Implement FMOPA, FMOPS (non-widening) | ||
48 | target/arm: Implement BFMOPA, BFMOPS | ||
49 | target/arm: Implement FMOPA, FMOPS (widening) | ||
50 | target/arm: Implement SME integer outer product | ||
51 | target/arm: Implement PSEL | ||
52 | target/arm: Implement REVD | ||
53 | target/arm: Implement SCLAMP, UCLAMP | ||
54 | target/arm: Reset streaming sve state on exception boundaries | ||
55 | target/arm: Enable SME for -cpu max | ||
56 | linux-user/aarch64: Clear tpidr2_el0 if CLONE_SETTLS | ||
57 | linux-user/aarch64: Reset PSTATE.SM on syscalls | ||
58 | linux-user/aarch64: Add SM bit to SVE signal context | ||
59 | linux-user/aarch64: Tidy target_restore_sigframe error return | ||
60 | linux-user/aarch64: Do not allow duplicate or short sve records | ||
61 | linux-user/aarch64: Verify extra record lock succeeded | ||
62 | linux-user/aarch64: Move sve record checks into restore | ||
63 | linux-user/aarch64: Implement SME signal handling | ||
64 | linux-user: Rename sve prctls | ||
65 | linux-user/aarch64: Implement PR_SME_GET_VL, PR_SME_SET_VL | ||
66 | target/arm: Only set ZEN in reset if SVE present | ||
67 | target/arm: Enable SME for user-only | ||
68 | linux-user/aarch64: Add SME related hwcap entries | ||
25 | 69 | ||
26 | Maxim Uvarov (1): | 70 | docs/system/arm/emulation.rst | 4 + |
27 | hw/gpio/gpio_pwr: use shutdown function for reboot | 71 | linux-user/aarch64/target_cpu.h | 5 +- |
28 | 72 | linux-user/aarch64/target_prctl.h | 62 +- | |
29 | Nolan Leake (1): | 73 | target/arm/cpu.h | 7 + |
30 | hw/arm: Add basic power management to raspi. | 74 | target/arm/helper-sme.h | 126 ++++ |
31 | 75 | target/arm/helper-sve.h | 4 + | |
32 | Patrick Venture (2): | 76 | target/arm/helper.h | 18 + |
33 | docs/system/arm: Add quanta-q7l1-bmc reference | 77 | target/arm/translate-a64.h | 45 ++ |
34 | docs/system/arm: Add quanta-gbs-bmc reference | 78 | target/arm/translate.h | 16 + |
35 | 79 | target/arm/sme-fa64.decode | 60 ++ | |
36 | Peter Maydell (18): | 80 | target/arm/sme.decode | 88 +++ |
37 | target/arm: Fix MVE widening/narrowing VLDR/VSTR offset calculation | 81 | target/arm/sve.decode | 41 +- |
38 | target/arm: Fix bugs in MVE VRMLALDAVH, VRMLSLDAVH | 82 | linux-user/aarch64/cpu_loop.c | 9 + |
39 | target/arm: Make asimd_imm_const() public | 83 | linux-user/aarch64/signal.c | 243 ++++++-- |
40 | target/arm: Use asimd_imm_const for A64 decode | 84 | linux-user/elfload.c | 20 + |
41 | target/arm: Use dup_const() instead of bitfield_replicate() | 85 | linux-user/syscall.c | 28 +- |
42 | target/arm: Implement MVE logical immediate insns | 86 | target/arm/cpu.c | 35 +- |
43 | target/arm: Implement MVE vector shift left by immediate insns | 87 | target/arm/cpu64.c | 11 + |
44 | target/arm: Implement MVE vector shift right by immediate insns | 88 | target/arm/helper.c | 56 +- |
45 | target/arm: Implement MVE VSHLL | 89 | target/arm/sme_helper.c | 1140 +++++++++++++++++++++++++++++++++++++ |
46 | target/arm: Implement MVE VSRI, VSLI | 90 | target/arm/sve_helper.c | 28 + |
47 | target/arm: Implement MVE VSHRN, VRSHRN | 91 | target/arm/translate-a64.c | 103 +++- |
48 | target/arm: Implement MVE saturating narrowing shifts | 92 | target/arm/translate-sme.c | 373 ++++++++++++ |
49 | target/arm: Implement MVE VSHLC | 93 | target/arm/translate-sve.c | 393 ++++++++++--- |
50 | target/arm: Implement MVE VADDLV | 94 | target/arm/translate-vfp.c | 12 + |
51 | target/arm: Implement MVE long shifts by immediate | 95 | target/arm/translate.c | 2 + |
52 | target/arm: Implement MVE long shifts by register | 96 | target/arm/vec_helper.c | 24 + |
53 | target/arm: Implement MVE shifts by immediate | 97 | target/arm/meson.build | 3 + |
54 | target/arm: Implement MVE shifts by register | 98 | 28 files changed, 2821 insertions(+), 135 deletions(-) |
55 | 99 | create mode 100644 target/arm/sme-fa64.decode | |
56 | Philippe Mathieu-Daudé (1): | 100 | create mode 100644 target/arm/sme.decode |
57 | tests: Boot and halt a Linux guest on the Raspberry Pi 2 machine | 101 | create mode 100644 target/arm/translate-sme.c |
58 | |||
59 | docs/system/arm/aspeed.rst | 1 + | ||
60 | docs/system/arm/nuvoton.rst | 5 +- | ||
61 | include/hw/arm/bcm2835_peripherals.h | 3 +- | ||
62 | include/hw/misc/bcm2835_powermgt.h | 29 ++ | ||
63 | target/arm/helper-mve.h | 108 +++++++ | ||
64 | target/arm/translate.h | 41 +++ | ||
65 | target/arm/mve.decode | 177 ++++++++++- | ||
66 | target/arm/t32.decode | 71 ++++- | ||
67 | hw/arm/bcm2835_peripherals.c | 13 +- | ||
68 | hw/gpio/gpio_pwr.c | 2 +- | ||
69 | hw/misc/bcm2835_powermgt.c | 160 ++++++++++ | ||
70 | target/arm/helper-a64.c | 12 +- | ||
71 | target/arm/mve_helper.c | 524 +++++++++++++++++++++++++++++++-- | ||
72 | target/arm/translate-a64.c | 86 +----- | ||
73 | target/arm/translate-mve.c | 261 +++++++++++++++- | ||
74 | target/arm/translate-neon.c | 81 ----- | ||
75 | target/arm/translate.c | 327 +++++++++++++++++++- | ||
76 | target/arm/vfp_helper.c | 24 +- | ||
77 | hw/misc/meson.build | 1 + | ||
78 | tests/acceptance/boot_linux_console.py | 43 +++ | ||
79 | 20 files changed, 1760 insertions(+), 209 deletions(-) | ||
80 | create mode 100644 include/hw/misc/bcm2835_powermgt.h | ||
81 | create mode 100644 hw/misc/bcm2835_powermgt.c | ||
82 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Dump SVCR, plus use the correct access check for Streaming Mode. | ||
4 | |||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20220708151540.18136-2-richard.henderson@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | target/arm/cpu.c | 17 ++++++++++++++++- | ||
11 | 1 file changed, 16 insertions(+), 1 deletion(-) | ||
12 | |||
13 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/cpu.c | ||
16 | +++ b/target/arm/cpu.c | ||
17 | @@ -XXX,XX +XXX,XX @@ static void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags) | ||
18 | int i; | ||
19 | int el = arm_current_el(env); | ||
20 | const char *ns_status; | ||
21 | + bool sve; | ||
22 | |||
23 | qemu_fprintf(f, " PC=%016" PRIx64 " ", env->pc); | ||
24 | for (i = 0; i < 32; i++) { | ||
25 | @@ -XXX,XX +XXX,XX @@ static void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags) | ||
26 | el, | ||
27 | psr & PSTATE_SP ? 'h' : 't'); | ||
28 | |||
29 | + if (cpu_isar_feature(aa64_sme, cpu)) { | ||
30 | + qemu_fprintf(f, " SVCR=%08" PRIx64 " %c%c", | ||
31 | + env->svcr, | ||
32 | + (FIELD_EX64(env->svcr, SVCR, ZA) ? 'Z' : '-'), | ||
33 | + (FIELD_EX64(env->svcr, SVCR, SM) ? 'S' : '-')); | ||
34 | + } | ||
35 | if (cpu_isar_feature(aa64_bti, cpu)) { | ||
36 | qemu_fprintf(f, " BTYPE=%d", (psr & PSTATE_BTYPE) >> 10); | ||
37 | } | ||
38 | @@ -XXX,XX +XXX,XX @@ static void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags) | ||
39 | qemu_fprintf(f, " FPCR=%08x FPSR=%08x\n", | ||
40 | vfp_get_fpcr(env), vfp_get_fpsr(env)); | ||
41 | |||
42 | - if (cpu_isar_feature(aa64_sve, cpu) && sve_exception_el(env, el) == 0) { | ||
43 | + if (cpu_isar_feature(aa64_sme, cpu) && FIELD_EX64(env->svcr, SVCR, SM)) { | ||
44 | + sve = sme_exception_el(env, el) == 0; | ||
45 | + } else if (cpu_isar_feature(aa64_sve, cpu)) { | ||
46 | + sve = sve_exception_el(env, el) == 0; | ||
47 | + } else { | ||
48 | + sve = false; | ||
49 | + } | ||
50 | + | ||
51 | + if (sve) { | ||
52 | int j, zcr_len = sve_vqm1_for_el(env, el); | ||
53 | |||
54 | for (i = 0; i <= FFR_PRED_NUM; i++) { | ||
55 | -- | ||
56 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Nolan Leake <nolan@sigbus.net> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This is just enough to make reboot and poweroff work. Works for | 3 | This includes the build rules for the decoder, and the |
4 | linux, u-boot, and the arm trusted firmware. Not tested, but should | 4 | new file for translation, but excludes any instructions. |
5 | work for plan9, and bare-metal/hobby OSes, since they seem to generally | ||
6 | do what linux does for reset. | ||
7 | 5 | ||
8 | The watchdog timer functionality is not yet implemented. | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | |
10 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/64 | 8 | Message-id: 20220708151540.18136-3-richard.henderson@linaro.org |
11 | Signed-off-by: Nolan Leake <nolan@sigbus.net> | ||
12 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
13 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
14 | Message-id: 20210625210209.1870217-1-nolan@sigbus.net | ||
15 | [PMM: tweaked commit title; fixed region size to 0x200; | ||
16 | moved header file to include/] | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | --- | 10 | --- |
19 | include/hw/arm/bcm2835_peripherals.h | 3 +- | 11 | target/arm/translate-a64.h | 1 + |
20 | include/hw/misc/bcm2835_powermgt.h | 29 +++++ | 12 | target/arm/sme.decode | 20 ++++++++++++++++++++ |
21 | hw/arm/bcm2835_peripherals.c | 13 ++- | 13 | target/arm/translate-a64.c | 7 ++++++- |
22 | hw/misc/bcm2835_powermgt.c | 160 +++++++++++++++++++++++++++ | 14 | target/arm/translate-sme.c | 35 +++++++++++++++++++++++++++++++++++ |
23 | hw/misc/meson.build | 1 + | 15 | target/arm/meson.build | 2 ++ |
24 | 5 files changed, 204 insertions(+), 2 deletions(-) | 16 | 5 files changed, 64 insertions(+), 1 deletion(-) |
25 | create mode 100644 include/hw/misc/bcm2835_powermgt.h | 17 | create mode 100644 target/arm/sme.decode |
26 | create mode 100644 hw/misc/bcm2835_powermgt.c | 18 | create mode 100644 target/arm/translate-sme.c |
27 | 19 | ||
28 | diff --git a/include/hw/arm/bcm2835_peripherals.h b/include/hw/arm/bcm2835_peripherals.h | 20 | diff --git a/target/arm/translate-a64.h b/target/arm/translate-a64.h |
29 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/include/hw/arm/bcm2835_peripherals.h | 22 | --- a/target/arm/translate-a64.h |
31 | +++ b/include/hw/arm/bcm2835_peripherals.h | 23 | +++ b/target/arm/translate-a64.h |
32 | @@ -XXX,XX +XXX,XX @@ | 24 | @@ -XXX,XX +XXX,XX @@ static inline int pred_gvec_reg_size(DisasContext *s) |
33 | #include "hw/misc/bcm2835_mphi.h" | 25 | } |
34 | #include "hw/misc/bcm2835_thermal.h" | 26 | |
35 | #include "hw/misc/bcm2835_cprman.h" | 27 | bool disas_sve(DisasContext *, uint32_t); |
36 | +#include "hw/misc/bcm2835_powermgt.h" | 28 | +bool disas_sme(DisasContext *, uint32_t); |
37 | #include "hw/sd/sdhci.h" | 29 | |
38 | #include "hw/sd/bcm2835_sdhost.h" | 30 | void gen_gvec_rax1(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs, |
39 | #include "hw/gpio/bcm2835_gpio.h" | 31 | uint32_t rm_ofs, uint32_t opr_sz, uint32_t max_sz); |
40 | @@ -XXX,XX +XXX,XX @@ struct BCM2835PeripheralState { | 32 | diff --git a/target/arm/sme.decode b/target/arm/sme.decode |
41 | BCM2835MphiState mphi; | ||
42 | UnimplementedDeviceState txp; | ||
43 | UnimplementedDeviceState armtmr; | ||
44 | - UnimplementedDeviceState powermgt; | ||
45 | + BCM2835PowerMgtState powermgt; | ||
46 | BCM2835CprmanState cprman; | ||
47 | PL011State uart0; | ||
48 | BCM2835AuxState aux; | ||
49 | diff --git a/include/hw/misc/bcm2835_powermgt.h b/include/hw/misc/bcm2835_powermgt.h | ||
50 | new file mode 100644 | 33 | new file mode 100644 |
51 | index XXXXXXX..XXXXXXX | 34 | index XXXXXXX..XXXXXXX |
52 | --- /dev/null | 35 | --- /dev/null |
53 | +++ b/include/hw/misc/bcm2835_powermgt.h | 36 | +++ b/target/arm/sme.decode |
54 | @@ -XXX,XX +XXX,XX @@ | 37 | @@ -XXX,XX +XXX,XX @@ |
55 | +/* | 38 | +# AArch64 SME instruction descriptions |
56 | + * BCM2835 Power Management emulation | 39 | +# |
57 | + * | 40 | +# Copyright (c) 2022 Linaro, Ltd |
58 | + * Copyright (C) 2017 Marcin Chojnacki <marcinch7@gmail.com> | 41 | +# |
59 | + * Copyright (C) 2021 Nolan Leake <nolan@sigbus.net> | 42 | +# This library is free software; you can redistribute it and/or |
60 | + * | 43 | +# modify it under the terms of the GNU Lesser General Public |
61 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | 44 | +# License as published by the Free Software Foundation; either |
62 | + * See the COPYING file in the top-level directory. | 45 | +# version 2.1 of the License, or (at your option) any later version. |
63 | + */ | 46 | +# |
47 | +# This library is distributed in the hope that it will be useful, | ||
48 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
49 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
50 | +# Lesser General Public License for more details. | ||
51 | +# | ||
52 | +# You should have received a copy of the GNU Lesser General Public | ||
53 | +# License along with this library; if not, see <http://www.gnu.org/licenses/>. | ||
64 | + | 54 | + |
65 | +#ifndef BCM2835_POWERMGT_H | 55 | +# |
66 | +#define BCM2835_POWERMGT_H | 56 | +# This file is processed by scripts/decodetree.py |
67 | + | 57 | +# |
68 | +#include "hw/sysbus.h" | 58 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
69 | +#include "qom/object.h" | ||
70 | + | ||
71 | +#define TYPE_BCM2835_POWERMGT "bcm2835-powermgt" | ||
72 | +OBJECT_DECLARE_SIMPLE_TYPE(BCM2835PowerMgtState, BCM2835_POWERMGT) | ||
73 | + | ||
74 | +struct BCM2835PowerMgtState { | ||
75 | + SysBusDevice busdev; | ||
76 | + MemoryRegion iomem; | ||
77 | + | ||
78 | + uint32_t rstc; | ||
79 | + uint32_t rsts; | ||
80 | + uint32_t wdog; | ||
81 | +}; | ||
82 | + | ||
83 | +#endif | ||
84 | diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c | ||
85 | index XXXXXXX..XXXXXXX 100644 | 59 | index XXXXXXX..XXXXXXX 100644 |
86 | --- a/hw/arm/bcm2835_peripherals.c | 60 | --- a/target/arm/translate-a64.c |
87 | +++ b/hw/arm/bcm2835_peripherals.c | 61 | +++ b/target/arm/translate-a64.c |
88 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_init(Object *obj) | 62 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) |
89 | 63 | } | |
90 | object_property_add_const_link(OBJECT(&s->dwc2), "dma-mr", | 64 | |
91 | OBJECT(&s->gpu_bus_mr)); | 65 | switch (extract32(insn, 25, 4)) { |
92 | + | 66 | - case 0x0: case 0x1: case 0x3: /* UNALLOCATED */ |
93 | + /* Power Management */ | 67 | + case 0x0: |
94 | + object_initialize_child(obj, "powermgt", &s->powermgt, | 68 | + if (!extract32(insn, 31, 1) || !disas_sme(s, insn)) { |
95 | + TYPE_BCM2835_POWERMGT); | 69 | + unallocated_encoding(s); |
96 | } | 70 | + } |
97 | 71 | + break; | |
98 | static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) | 72 | + case 0x1: case 0x3: /* UNALLOCATED */ |
99 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) | 73 | unallocated_encoding(s); |
100 | qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ, | 74 | break; |
101 | INTERRUPT_USB)); | 75 | case 0x2: |
102 | 76 | diff --git a/target/arm/translate-sme.c b/target/arm/translate-sme.c | |
103 | + /* Power Management */ | ||
104 | + if (!sysbus_realize(SYS_BUS_DEVICE(&s->powermgt), errp)) { | ||
105 | + return; | ||
106 | + } | ||
107 | + | ||
108 | + memory_region_add_subregion(&s->peri_mr, PM_OFFSET, | ||
109 | + sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->powermgt), 0)); | ||
110 | + | ||
111 | create_unimp(s, &s->txp, "bcm2835-txp", TXP_OFFSET, 0x1000); | ||
112 | create_unimp(s, &s->armtmr, "bcm2835-sp804", ARMCTRL_TIMER0_1_OFFSET, 0x40); | ||
113 | - create_unimp(s, &s->powermgt, "bcm2835-powermgt", PM_OFFSET, 0x114); | ||
114 | create_unimp(s, &s->i2s, "bcm2835-i2s", I2S_OFFSET, 0x100); | ||
115 | create_unimp(s, &s->smi, "bcm2835-smi", SMI_OFFSET, 0x100); | ||
116 | create_unimp(s, &s->spi[0], "bcm2835-spi0", SPI0_OFFSET, 0x20); | ||
117 | diff --git a/hw/misc/bcm2835_powermgt.c b/hw/misc/bcm2835_powermgt.c | ||
118 | new file mode 100644 | 77 | new file mode 100644 |
119 | index XXXXXXX..XXXXXXX | 78 | index XXXXXXX..XXXXXXX |
120 | --- /dev/null | 79 | --- /dev/null |
121 | +++ b/hw/misc/bcm2835_powermgt.c | 80 | +++ b/target/arm/translate-sme.c |
122 | @@ -XXX,XX +XXX,XX @@ | 81 | @@ -XXX,XX +XXX,XX @@ |
123 | +/* | 82 | +/* |
124 | + * BCM2835 Power Management emulation | 83 | + * AArch64 SME translation |
125 | + * | 84 | + * |
126 | + * Copyright (C) 2017 Marcin Chojnacki <marcinch7@gmail.com> | 85 | + * Copyright (c) 2022 Linaro, Ltd |
127 | + * Copyright (C) 2021 Nolan Leake <nolan@sigbus.net> | ||
128 | + * | 86 | + * |
129 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | 87 | + * This library is free software; you can redistribute it and/or |
130 | + * See the COPYING file in the top-level directory. | 88 | + * modify it under the terms of the GNU Lesser General Public |
89 | + * License as published by the Free Software Foundation; either | ||
90 | + * version 2.1 of the License, or (at your option) any later version. | ||
91 | + * | ||
92 | + * This library is distributed in the hope that it will be useful, | ||
93 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
94 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
95 | + * Lesser General Public License for more details. | ||
96 | + * | ||
97 | + * You should have received a copy of the GNU Lesser General Public | ||
98 | + * License along with this library; if not, see <http://www.gnu.org/licenses/>. | ||
131 | + */ | 99 | + */ |
132 | + | 100 | + |
133 | +#include "qemu/osdep.h" | 101 | +#include "qemu/osdep.h" |
134 | +#include "qemu/log.h" | 102 | +#include "cpu.h" |
135 | +#include "qemu/module.h" | 103 | +#include "tcg/tcg-op.h" |
136 | +#include "hw/misc/bcm2835_powermgt.h" | 104 | +#include "tcg/tcg-op-gvec.h" |
137 | +#include "migration/vmstate.h" | 105 | +#include "tcg/tcg-gvec-desc.h" |
138 | +#include "sysemu/runstate.h" | 106 | +#include "translate.h" |
107 | +#include "exec/helper-gen.h" | ||
108 | +#include "translate-a64.h" | ||
109 | +#include "fpu/softfloat.h" | ||
139 | + | 110 | + |
140 | +#define PASSWORD 0x5a000000 | ||
141 | +#define PASSWORD_MASK 0xff000000 | ||
142 | + | 111 | + |
143 | +#define R_RSTC 0x1c | 112 | +/* |
144 | +#define V_RSTC_RESET 0x20 | 113 | + * Include the generated decoder. |
145 | +#define R_RSTS 0x20 | 114 | + */ |
146 | +#define V_RSTS_POWEROFF 0x555 /* Linux uses partition 63 to indicate halt. */ | ||
147 | +#define R_WDOG 0x24 | ||
148 | + | 115 | + |
149 | +static uint64_t bcm2835_powermgt_read(void *opaque, hwaddr offset, | 116 | +#include "decode-sme.c.inc" |
150 | + unsigned size) | 117 | diff --git a/target/arm/meson.build b/target/arm/meson.build |
151 | +{ | ||
152 | + BCM2835PowerMgtState *s = (BCM2835PowerMgtState *)opaque; | ||
153 | + uint32_t res = 0; | ||
154 | + | ||
155 | + switch (offset) { | ||
156 | + case R_RSTC: | ||
157 | + res = s->rstc; | ||
158 | + break; | ||
159 | + case R_RSTS: | ||
160 | + res = s->rsts; | ||
161 | + break; | ||
162 | + case R_WDOG: | ||
163 | + res = s->wdog; | ||
164 | + break; | ||
165 | + | ||
166 | + default: | ||
167 | + qemu_log_mask(LOG_UNIMP, | ||
168 | + "bcm2835_powermgt_read: Unknown offset 0x%08"HWADDR_PRIx | ||
169 | + "\n", offset); | ||
170 | + res = 0; | ||
171 | + break; | ||
172 | + } | ||
173 | + | ||
174 | + return res; | ||
175 | +} | ||
176 | + | ||
177 | +static void bcm2835_powermgt_write(void *opaque, hwaddr offset, | ||
178 | + uint64_t value, unsigned size) | ||
179 | +{ | ||
180 | + BCM2835PowerMgtState *s = (BCM2835PowerMgtState *)opaque; | ||
181 | + | ||
182 | + if ((value & PASSWORD_MASK) != PASSWORD) { | ||
183 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
184 | + "bcm2835_powermgt_write: Bad password 0x%"PRIx64 | ||
185 | + " at offset 0x%08"HWADDR_PRIx"\n", | ||
186 | + value, offset); | ||
187 | + return; | ||
188 | + } | ||
189 | + | ||
190 | + value = value & ~PASSWORD_MASK; | ||
191 | + | ||
192 | + switch (offset) { | ||
193 | + case R_RSTC: | ||
194 | + s->rstc = value; | ||
195 | + if (value & V_RSTC_RESET) { | ||
196 | + if ((s->rsts & 0xfff) == V_RSTS_POWEROFF) { | ||
197 | + qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); | ||
198 | + } else { | ||
199 | + qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); | ||
200 | + } | ||
201 | + } | ||
202 | + break; | ||
203 | + case R_RSTS: | ||
204 | + qemu_log_mask(LOG_UNIMP, | ||
205 | + "bcm2835_powermgt_write: RSTS\n"); | ||
206 | + s->rsts = value; | ||
207 | + break; | ||
208 | + case R_WDOG: | ||
209 | + qemu_log_mask(LOG_UNIMP, | ||
210 | + "bcm2835_powermgt_write: WDOG\n"); | ||
211 | + s->wdog = value; | ||
212 | + break; | ||
213 | + | ||
214 | + default: | ||
215 | + qemu_log_mask(LOG_UNIMP, | ||
216 | + "bcm2835_powermgt_write: Unknown offset 0x%08"HWADDR_PRIx | ||
217 | + "\n", offset); | ||
218 | + break; | ||
219 | + } | ||
220 | +} | ||
221 | + | ||
222 | +static const MemoryRegionOps bcm2835_powermgt_ops = { | ||
223 | + .read = bcm2835_powermgt_read, | ||
224 | + .write = bcm2835_powermgt_write, | ||
225 | + .endianness = DEVICE_NATIVE_ENDIAN, | ||
226 | + .impl.min_access_size = 4, | ||
227 | + .impl.max_access_size = 4, | ||
228 | +}; | ||
229 | + | ||
230 | +static const VMStateDescription vmstate_bcm2835_powermgt = { | ||
231 | + .name = TYPE_BCM2835_POWERMGT, | ||
232 | + .version_id = 1, | ||
233 | + .minimum_version_id = 1, | ||
234 | + .fields = (VMStateField[]) { | ||
235 | + VMSTATE_UINT32(rstc, BCM2835PowerMgtState), | ||
236 | + VMSTATE_UINT32(rsts, BCM2835PowerMgtState), | ||
237 | + VMSTATE_UINT32(wdog, BCM2835PowerMgtState), | ||
238 | + VMSTATE_END_OF_LIST() | ||
239 | + } | ||
240 | +}; | ||
241 | + | ||
242 | +static void bcm2835_powermgt_init(Object *obj) | ||
243 | +{ | ||
244 | + BCM2835PowerMgtState *s = BCM2835_POWERMGT(obj); | ||
245 | + | ||
246 | + memory_region_init_io(&s->iomem, obj, &bcm2835_powermgt_ops, s, | ||
247 | + TYPE_BCM2835_POWERMGT, 0x200); | ||
248 | + sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem); | ||
249 | +} | ||
250 | + | ||
251 | +static void bcm2835_powermgt_reset(DeviceState *dev) | ||
252 | +{ | ||
253 | + BCM2835PowerMgtState *s = BCM2835_POWERMGT(dev); | ||
254 | + | ||
255 | + /* https://elinux.org/BCM2835_registers#PM */ | ||
256 | + s->rstc = 0x00000102; | ||
257 | + s->rsts = 0x00001000; | ||
258 | + s->wdog = 0x00000000; | ||
259 | +} | ||
260 | + | ||
261 | +static void bcm2835_powermgt_class_init(ObjectClass *klass, void *data) | ||
262 | +{ | ||
263 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
264 | + | ||
265 | + dc->reset = bcm2835_powermgt_reset; | ||
266 | + dc->vmsd = &vmstate_bcm2835_powermgt; | ||
267 | +} | ||
268 | + | ||
269 | +static TypeInfo bcm2835_powermgt_info = { | ||
270 | + .name = TYPE_BCM2835_POWERMGT, | ||
271 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
272 | + .instance_size = sizeof(BCM2835PowerMgtState), | ||
273 | + .class_init = bcm2835_powermgt_class_init, | ||
274 | + .instance_init = bcm2835_powermgt_init, | ||
275 | +}; | ||
276 | + | ||
277 | +static void bcm2835_powermgt_register_types(void) | ||
278 | +{ | ||
279 | + type_register_static(&bcm2835_powermgt_info); | ||
280 | +} | ||
281 | + | ||
282 | +type_init(bcm2835_powermgt_register_types) | ||
283 | diff --git a/hw/misc/meson.build b/hw/misc/meson.build | ||
284 | index XXXXXXX..XXXXXXX 100644 | 118 | index XXXXXXX..XXXXXXX 100644 |
285 | --- a/hw/misc/meson.build | 119 | --- a/target/arm/meson.build |
286 | +++ b/hw/misc/meson.build | 120 | +++ b/target/arm/meson.build |
287 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_RASPI', if_true: files( | 121 | @@ -XXX,XX +XXX,XX @@ |
288 | 'bcm2835_rng.c', | 122 | gen = [ |
289 | 'bcm2835_thermal.c', | 123 | decodetree.process('sve.decode', extra_args: '--decode=disas_sve'), |
290 | 'bcm2835_cprman.c', | 124 | + decodetree.process('sme.decode', extra_args: '--decode=disas_sme'), |
291 | + 'bcm2835_powermgt.c', | 125 | decodetree.process('neon-shared.decode', extra_args: '--decode=disas_neon_shared'), |
126 | decodetree.process('neon-dp.decode', extra_args: '--decode=disas_neon_dp'), | ||
127 | decodetree.process('neon-ls.decode', extra_args: '--decode=disas_neon_ls'), | ||
128 | @@ -XXX,XX +XXX,XX @@ arm_ss.add(when: 'TARGET_AARCH64', if_true: files( | ||
129 | 'sme_helper.c', | ||
130 | 'translate-a64.c', | ||
131 | 'translate-sve.c', | ||
132 | + 'translate-sme.c', | ||
292 | )) | 133 | )) |
293 | softmmu_ss.add(when: 'CONFIG_SLAVIO', if_true: files('slavio_misc.c')) | 134 | |
294 | softmmu_ss.add(when: 'CONFIG_ZYNQ', if_true: files('zynq_slcr.c', 'zynq-xadc.c')) | 135 | arm_softmmu_ss = ss.source_set() |
295 | -- | 136 | -- |
296 | 2.20.1 | 137 | 2.25.1 |
297 | |||
298 | diff view generated by jsdifflib |
1 | The A64 AdvSIMD modified-immediate grouping uses almost the same | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | constant encoding that A32 Neon does; reuse asimd_imm_const() (to | 2 | |
3 | which we add the AArch64-specific case for cmode 15 op 1) instead of | 3 | This new behaviour is in the ARM pseudocode function |
4 | reimplementing it all. | 4 | AArch64.CheckFPAdvSIMDEnabled, which applies to AArch32 |
5 | 5 | via AArch32.CheckAdvSIMDOrFPEnabled when the EL to which | |
6 | the trap would be delivered is in AArch64 mode. | ||
7 | |||
8 | Given that ARMv9 drops support for AArch32 outside EL0, the trap EL | ||
9 | detection ought to be trivially true, but the pseudocode still contains | ||
10 | a number of conditions, and QEMU has not yet committed to dropping A32 | ||
11 | support for EL[12] when v9 features are present. | ||
12 | |||
13 | Since the computation of SME_TRAP_NONSTREAMING is necessarily different | ||
14 | for the two modes, we might as well preserve bits within TBFLAG_ANY and | ||
15 | allocate separate bits within TBFLAG_A32 and TBFLAG_A64 instead. | ||
16 | |||
17 | Note that DDI0616A.a has typos for bits [22:21] of LD1RO in the table | ||
18 | of instructions illegal in streaming mode. | ||
19 | |||
20 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
21 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
22 | Message-id: 20220708151540.18136-4-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 23 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210628135835.6690-5-peter.maydell@linaro.org | ||
9 | --- | 24 | --- |
10 | target/arm/translate.h | 3 +- | 25 | target/arm/cpu.h | 7 +++ |
11 | target/arm/translate-a64.c | 86 ++++---------------------------------- | 26 | target/arm/translate.h | 4 ++ |
12 | target/arm/translate.c | 17 +++++++- | 27 | target/arm/sme-fa64.decode | 90 ++++++++++++++++++++++++++++++++++++++ |
13 | 3 files changed, 24 insertions(+), 82 deletions(-) | 28 | target/arm/helper.c | 41 +++++++++++++++++ |
14 | 29 | target/arm/translate-a64.c | 40 ++++++++++++++++- | |
30 | target/arm/translate-vfp.c | 12 +++++ | ||
31 | target/arm/translate.c | 2 + | ||
32 | target/arm/meson.build | 1 + | ||
33 | 8 files changed, 195 insertions(+), 2 deletions(-) | ||
34 | create mode 100644 target/arm/sme-fa64.decode | ||
35 | |||
36 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/target/arm/cpu.h | ||
39 | +++ b/target/arm/cpu.h | ||
40 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, HSTR_ACTIVE, 9, 1) | ||
41 | * the same thing as the current security state of the processor! | ||
42 | */ | ||
43 | FIELD(TBFLAG_A32, NS, 10, 1) | ||
44 | +/* | ||
45 | + * Indicates that SME Streaming mode is active, and SMCR_ELx.FA64 is not. | ||
46 | + * This requires an SME trap from AArch32 mode when using NEON. | ||
47 | + */ | ||
48 | +FIELD(TBFLAG_A32, SME_TRAP_NONSTREAMING, 11, 1) | ||
49 | |||
50 | /* | ||
51 | * Bit usage when in AArch32 state, for M-profile only. | ||
52 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A64, SMEEXC_EL, 20, 2) | ||
53 | FIELD(TBFLAG_A64, PSTATE_SM, 22, 1) | ||
54 | FIELD(TBFLAG_A64, PSTATE_ZA, 23, 1) | ||
55 | FIELD(TBFLAG_A64, SVL, 24, 4) | ||
56 | +/* Indicates that SME Streaming mode is active, and SMCR_ELx.FA64 is not. */ | ||
57 | +FIELD(TBFLAG_A64, SME_TRAP_NONSTREAMING, 28, 1) | ||
58 | |||
59 | /* | ||
60 | * Helpers for using the above. | ||
15 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 61 | diff --git a/target/arm/translate.h b/target/arm/translate.h |
16 | index XXXXXXX..XXXXXXX 100644 | 62 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate.h | 63 | --- a/target/arm/translate.h |
18 | +++ b/target/arm/translate.h | 64 | +++ b/target/arm/translate.h |
19 | @@ -XXX,XX +XXX,XX @@ static inline MemOp finalize_memop(DisasContext *s, MemOp opc) | 65 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { |
20 | * VMVN and VBIC (when cmode < 14 && op == 1). | 66 | bool pstate_sm; |
21 | * | 67 | /* True if PSTATE.ZA is set. */ |
22 | * The combination cmode == 15 op == 1 is a reserved encoding for AArch32; | 68 | bool pstate_za; |
23 | - * callers must catch this. | 69 | + /* True if non-streaming insns should raise an SME Streaming exception. */ |
24 | + * callers must catch this; we return the 64-bit constant value defined | 70 | + bool sme_trap_nonstreaming; |
25 | + * for AArch64. | 71 | + /* True if the current instruction is non-streaming. */ |
26 | * | 72 | + bool is_nonstreaming; |
27 | * cmode = 2,3,4,5,6,7,10,11,12,13 imm=0 was UNPREDICTABLE in v7A but | 73 | /* True if MVE insns are definitely not predicated by VPR or LTPSIZE */ |
28 | * is either not unpredictable or merely CONSTRAINED UNPREDICTABLE in v8A; | 74 | bool mve_no_pred; |
75 | /* | ||
76 | diff --git a/target/arm/sme-fa64.decode b/target/arm/sme-fa64.decode | ||
77 | new file mode 100644 | ||
78 | index XXXXXXX..XXXXXXX | ||
79 | --- /dev/null | ||
80 | +++ b/target/arm/sme-fa64.decode | ||
81 | @@ -XXX,XX +XXX,XX @@ | ||
82 | +# AArch64 SME allowed instruction decoding | ||
83 | +# | ||
84 | +# Copyright (c) 2022 Linaro, Ltd | ||
85 | +# | ||
86 | +# This library is free software; you can redistribute it and/or | ||
87 | +# modify it under the terms of the GNU Lesser General Public | ||
88 | +# License as published by the Free Software Foundation; either | ||
89 | +# version 2.1 of the License, or (at your option) any later version. | ||
90 | +# | ||
91 | +# This library is distributed in the hope that it will be useful, | ||
92 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
93 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
94 | +# Lesser General Public License for more details. | ||
95 | +# | ||
96 | +# You should have received a copy of the GNU Lesser General Public | ||
97 | +# License along with this library; if not, see <http://www.gnu.org/licenses/>. | ||
98 | + | ||
99 | +# | ||
100 | +# This file is processed by scripts/decodetree.py | ||
101 | +# | ||
102 | + | ||
103 | +# These patterns are taken from Appendix E1.1 of DDI0616 A.a, | ||
104 | +# Arm Architecture Reference Manual Supplement, | ||
105 | +# The Scalable Matrix Extension (SME), for Armv9-A | ||
106 | + | ||
107 | +{ | ||
108 | + [ | ||
109 | + OK 0-00 1110 0000 0001 0010 11-- ---- ---- # SMOV W|Xd,Vn.B[0] | ||
110 | + OK 0-00 1110 0000 0010 0010 11-- ---- ---- # SMOV W|Xd,Vn.H[0] | ||
111 | + OK 0100 1110 0000 0100 0010 11-- ---- ---- # SMOV Xd,Vn.S[0] | ||
112 | + OK 0000 1110 0000 0001 0011 11-- ---- ---- # UMOV Wd,Vn.B[0] | ||
113 | + OK 0000 1110 0000 0010 0011 11-- ---- ---- # UMOV Wd,Vn.H[0] | ||
114 | + OK 0000 1110 0000 0100 0011 11-- ---- ---- # UMOV Wd,Vn.S[0] | ||
115 | + OK 0100 1110 0000 1000 0011 11-- ---- ---- # UMOV Xd,Vn.D[0] | ||
116 | + ] | ||
117 | + FAIL 0--0 111- ---- ---- ---- ---- ---- ---- # Advanced SIMD vector operations | ||
118 | +} | ||
119 | + | ||
120 | +{ | ||
121 | + [ | ||
122 | + OK 0101 1110 --1- ---- 11-1 11-- ---- ---- # FMULX/FRECPS/FRSQRTS (scalar) | ||
123 | + OK 0101 1110 -10- ---- 00-1 11-- ---- ---- # FMULX/FRECPS/FRSQRTS (scalar, FP16) | ||
124 | + OK 01-1 1110 1-10 0001 11-1 10-- ---- ---- # FRECPE/FRSQRTE/FRECPX (scalar) | ||
125 | + OK 01-1 1110 1111 1001 11-1 10-- ---- ---- # FRECPE/FRSQRTE/FRECPX (scalar, FP16) | ||
126 | + ] | ||
127 | + FAIL 01-1 111- ---- ---- ---- ---- ---- ---- # Advanced SIMD single-element operations | ||
128 | +} | ||
129 | + | ||
130 | +FAIL 0-00 110- ---- ---- ---- ---- ---- ---- # Advanced SIMD structure load/store | ||
131 | +FAIL 1100 1110 ---- ---- ---- ---- ---- ---- # Advanced SIMD cryptography extensions | ||
132 | +FAIL 0001 1110 0111 1110 0000 00-- ---- ---- # FJCVTZS | ||
133 | + | ||
134 | +# These are the "avoidance of doubt" final table of Illegal Advanced SIMD instructions | ||
135 | +# We don't actually need to include these, as the default is OK. | ||
136 | +# -001 111- ---- ---- ---- ---- ---- ---- # Scalar floating-point operations | ||
137 | +# --10 110- ---- ---- ---- ---- ---- ---- # Load/store pair of FP registers | ||
138 | +# --01 1100 ---- ---- ---- ---- ---- ---- # Load FP register (PC-relative literal) | ||
139 | +# --11 1100 --0- ---- ---- ---- ---- ---- # Load/store FP register (unscaled imm) | ||
140 | +# --11 1100 --1- ---- ---- ---- ---- --10 # Load/store FP register (register offset) | ||
141 | +# --11 1101 ---- ---- ---- ---- ---- ---- # Load/store FP register (scaled imm) | ||
142 | + | ||
143 | +FAIL 0000 0100 --1- ---- 1010 ---- ---- ---- # ADR | ||
144 | +FAIL 0000 0100 --1- ---- 1011 -0-- ---- ---- # FTSSEL, FEXPA | ||
145 | +FAIL 0000 0101 --10 0001 100- ---- ---- ---- # COMPACT | ||
146 | +FAIL 0010 0101 --01 100- 1111 000- ---0 ---- # RDFFR, RDFFRS | ||
147 | +FAIL 0010 0101 --10 1--- 1001 ---- ---- ---- # WRFFR, SETFFR | ||
148 | +FAIL 0100 0101 --0- ---- 1011 ---- ---- ---- # BDEP, BEXT, BGRP | ||
149 | +FAIL 0100 0101 000- ---- 0110 1--- ---- ---- # PMULLB, PMULLT (128b result) | ||
150 | +FAIL 0110 0100 --1- ---- 1110 01-- ---- ---- # FMMLA, BFMMLA | ||
151 | +FAIL 0110 0101 --0- ---- 0000 11-- ---- ---- # FTSMUL | ||
152 | +FAIL 0110 0101 --01 0--- 100- ---- ---- ---- # FTMAD | ||
153 | +FAIL 0110 0101 --01 1--- 001- ---- ---- ---- # FADDA | ||
154 | +FAIL 0100 0101 --0- ---- 1001 10-- ---- ---- # SMMLA, UMMLA, USMMLA | ||
155 | +FAIL 0100 0101 --1- ---- 1--- ---- ---- ---- # SVE2 string/histo/crypto instructions | ||
156 | +FAIL 1000 010- -00- ---- 10-- ---- ---- ---- # SVE2 32-bit gather NT load (vector+scalar) | ||
157 | +FAIL 1000 010- -00- ---- 111- ---- ---- ---- # SVE 32-bit gather prefetch (vector+imm) | ||
158 | +FAIL 1000 0100 0-1- ---- 0--- ---- ---- ---- # SVE 32-bit gather prefetch (scalar+vector) | ||
159 | +FAIL 1000 010- -01- ---- 1--- ---- ---- ---- # SVE 32-bit gather load (vector+imm) | ||
160 | +FAIL 1000 0100 0-0- ---- 0--- ---- ---- ---- # SVE 32-bit gather load byte (scalar+vector) | ||
161 | +FAIL 1000 0100 1--- ---- 0--- ---- ---- ---- # SVE 32-bit gather load half (scalar+vector) | ||
162 | +FAIL 1000 0101 0--- ---- 0--- ---- ---- ---- # SVE 32-bit gather load word (scalar+vector) | ||
163 | +FAIL 1010 010- ---- ---- 011- ---- ---- ---- # SVE contiguous FF load (scalar+scalar) | ||
164 | +FAIL 1010 010- ---1 ---- 101- ---- ---- ---- # SVE contiguous NF load (scalar+imm) | ||
165 | +FAIL 1010 010- -01- ---- 000- ---- ---- ---- # SVE load & replicate 32 bytes (scalar+scalar) | ||
166 | +FAIL 1010 010- -010 ---- 001- ---- ---- ---- # SVE load & replicate 32 bytes (scalar+imm) | ||
167 | +FAIL 1100 010- ---- ---- ---- ---- ---- ---- # SVE 64-bit gather load/prefetch | ||
168 | +FAIL 1110 010- -00- ---- 001- ---- ---- ---- # SVE2 64-bit scatter NT store (vector+scalar) | ||
169 | +FAIL 1110 010- -10- ---- 001- ---- ---- ---- # SVE2 32-bit scatter NT store (vector+scalar) | ||
170 | +FAIL 1110 010- ---- ---- 1-0- ---- ---- ---- # SVE scatter store (scalar+32-bit vector) | ||
171 | +FAIL 1110 010- ---- ---- 101- ---- ---- ---- # SVE scatter store (misc) | ||
172 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
173 | index XXXXXXX..XXXXXXX 100644 | ||
174 | --- a/target/arm/helper.c | ||
175 | +++ b/target/arm/helper.c | ||
176 | @@ -XXX,XX +XXX,XX @@ int sme_exception_el(CPUARMState *env, int el) | ||
177 | return 0; | ||
178 | } | ||
179 | |||
180 | +/* This corresponds to the ARM pseudocode function IsFullA64Enabled(). */ | ||
181 | +static bool sme_fa64(CPUARMState *env, int el) | ||
182 | +{ | ||
183 | + if (!cpu_isar_feature(aa64_sme_fa64, env_archcpu(env))) { | ||
184 | + return false; | ||
185 | + } | ||
186 | + | ||
187 | + if (el <= 1 && !el_is_in_host(env, el)) { | ||
188 | + if (!FIELD_EX64(env->vfp.smcr_el[1], SMCR, FA64)) { | ||
189 | + return false; | ||
190 | + } | ||
191 | + } | ||
192 | + if (el <= 2 && arm_is_el2_enabled(env)) { | ||
193 | + if (!FIELD_EX64(env->vfp.smcr_el[2], SMCR, FA64)) { | ||
194 | + return false; | ||
195 | + } | ||
196 | + } | ||
197 | + if (arm_feature(env, ARM_FEATURE_EL3)) { | ||
198 | + if (!FIELD_EX64(env->vfp.smcr_el[3], SMCR, FA64)) { | ||
199 | + return false; | ||
200 | + } | ||
201 | + } | ||
202 | + | ||
203 | + return true; | ||
204 | +} | ||
205 | + | ||
206 | /* | ||
207 | * Given that SVE is enabled, return the vector length for EL. | ||
208 | */ | ||
209 | @@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_a32(CPUARMState *env, int fp_el, | ||
210 | DP_TBFLAG_ANY(flags, PSTATE__IL, 1); | ||
211 | } | ||
212 | |||
213 | + /* | ||
214 | + * The SME exception we are testing for is raised via | ||
215 | + * AArch64.CheckFPAdvSIMDEnabled(), as called from | ||
216 | + * AArch32.CheckAdvSIMDOrFPEnabled(). | ||
217 | + */ | ||
218 | + if (el == 0 | ||
219 | + && FIELD_EX64(env->svcr, SVCR, SM) | ||
220 | + && (!arm_is_el2_enabled(env) | ||
221 | + || (arm_el_is_aa64(env, 2) && !(env->cp15.hcr_el2 & HCR_TGE))) | ||
222 | + && arm_el_is_aa64(env, 1) | ||
223 | + && !sme_fa64(env, el)) { | ||
224 | + DP_TBFLAG_A32(flags, SME_TRAP_NONSTREAMING, 1); | ||
225 | + } | ||
226 | + | ||
227 | return rebuild_hflags_common_32(env, fp_el, mmu_idx, flags); | ||
228 | } | ||
229 | |||
230 | @@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | ||
231 | } | ||
232 | if (FIELD_EX64(env->svcr, SVCR, SM)) { | ||
233 | DP_TBFLAG_A64(flags, PSTATE_SM, 1); | ||
234 | + DP_TBFLAG_A64(flags, SME_TRAP_NONSTREAMING, !sme_fa64(env, el)); | ||
235 | } | ||
236 | DP_TBFLAG_A64(flags, PSTATE_ZA, FIELD_EX64(env->svcr, SVCR, ZA)); | ||
237 | } | ||
29 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 238 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
30 | index XXXXXXX..XXXXXXX 100644 | 239 | index XXXXXXX..XXXXXXX 100644 |
31 | --- a/target/arm/translate-a64.c | 240 | --- a/target/arm/translate-a64.c |
32 | +++ b/target/arm/translate-a64.c | 241 | +++ b/target/arm/translate-a64.c |
33 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_mod_imm(DisasContext *s, uint32_t insn) | 242 | @@ -XXX,XX +XXX,XX @@ static void do_vec_ld(DisasContext *s, int destidx, int element, |
243 | * unallocated-encoding checks (otherwise the syndrome information | ||
244 | * for the resulting exception will be incorrect). | ||
245 | */ | ||
246 | -static bool fp_access_check(DisasContext *s) | ||
247 | +static bool fp_access_check_only(DisasContext *s) | ||
34 | { | 248 | { |
35 | int rd = extract32(insn, 0, 5); | 249 | if (s->fp_excp_el) { |
36 | int cmode = extract32(insn, 12, 4); | 250 | assert(!s->fp_access_checked); |
37 | - int cmode_3_1 = extract32(cmode, 1, 3); | 251 | @@ -XXX,XX +XXX,XX @@ static bool fp_access_check(DisasContext *s) |
38 | - int cmode_0 = extract32(cmode, 0, 1); | 252 | return true; |
39 | int o2 = extract32(insn, 11, 1); | 253 | } |
40 | uint64_t abcdefgh = extract32(insn, 5, 5) | (extract32(insn, 16, 3) << 5); | 254 | |
41 | bool is_neg = extract32(insn, 29, 1); | 255 | +static bool fp_access_check(DisasContext *s) |
42 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_mod_imm(DisasContext *s, uint32_t insn) | 256 | +{ |
257 | + if (!fp_access_check_only(s)) { | ||
258 | + return false; | ||
259 | + } | ||
260 | + if (s->sme_trap_nonstreaming && s->is_nonstreaming) { | ||
261 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
262 | + syn_smetrap(SME_ET_Streaming, false)); | ||
263 | + return false; | ||
264 | + } | ||
265 | + return true; | ||
266 | +} | ||
267 | + | ||
268 | /* Check that SVE access is enabled. If it is, return true. | ||
269 | * If not, emit code to generate an appropriate exception and return false. | ||
270 | */ | ||
271 | @@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, | ||
272 | default: | ||
273 | g_assert_not_reached(); | ||
274 | } | ||
275 | - if ((ri->type & ARM_CP_FPU) && !fp_access_check(s)) { | ||
276 | + if ((ri->type & ARM_CP_FPU) && !fp_access_check_only(s)) { | ||
43 | return; | 277 | return; |
44 | } | 278 | } else if ((ri->type & ARM_CP_SVE) && !sve_access_check(s)) { |
45 | 279 | return; | |
46 | - /* See AdvSIMDExpandImm() in ARM ARM */ | 280 | @@ -XXX,XX +XXX,XX @@ static void disas_data_proc_simd_fp(DisasContext *s, uint32_t insn) |
47 | - switch (cmode_3_1) { | 281 | } |
48 | - case 0: /* Replicate(Zeros(24):imm8, 2) */ | 282 | } |
49 | - case 1: /* Replicate(Zeros(16):imm8:Zeros(8), 2) */ | 283 | |
50 | - case 2: /* Replicate(Zeros(8):imm8:Zeros(16), 2) */ | 284 | +/* |
51 | - case 3: /* Replicate(imm8:Zeros(24), 2) */ | 285 | + * Include the generated SME FA64 decoder. |
52 | - { | 286 | + */ |
53 | - int shift = cmode_3_1 * 8; | 287 | + |
54 | - imm = bitfield_replicate(abcdefgh << shift, 32); | 288 | +#include "decode-sme-fa64.c.inc" |
55 | - break; | 289 | + |
56 | - } | 290 | +static bool trans_OK(DisasContext *s, arg_OK *a) |
57 | - case 4: /* Replicate(Zeros(8):imm8, 4) */ | 291 | +{ |
58 | - case 5: /* Replicate(imm8:Zeros(8), 4) */ | 292 | + return true; |
59 | - { | 293 | +} |
60 | - int shift = (cmode_3_1 & 0x1) * 8; | 294 | + |
61 | - imm = bitfield_replicate(abcdefgh << shift, 16); | 295 | +static bool trans_FAIL(DisasContext *s, arg_OK *a) |
62 | - break; | 296 | +{ |
63 | - } | 297 | + s->is_nonstreaming = true; |
64 | - case 6: | 298 | + return true; |
65 | - if (cmode_0) { | 299 | +} |
66 | - /* Replicate(Zeros(8):imm8:Ones(16), 2) */ | 300 | + |
67 | - imm = (abcdefgh << 16) | 0xffff; | 301 | /** |
68 | - } else { | 302 | * is_guarded_page: |
69 | - /* Replicate(Zeros(16):imm8:Ones(8), 2) */ | 303 | * @env: The cpu environment |
70 | - imm = (abcdefgh << 8) | 0xff; | 304 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, |
71 | - } | 305 | dc->mte_active[1] = EX_TBFLAG_A64(tb_flags, MTE0_ACTIVE); |
72 | - imm = bitfield_replicate(imm, 32); | 306 | dc->pstate_sm = EX_TBFLAG_A64(tb_flags, PSTATE_SM); |
73 | - break; | 307 | dc->pstate_za = EX_TBFLAG_A64(tb_flags, PSTATE_ZA); |
74 | - case 7: | 308 | + dc->sme_trap_nonstreaming = EX_TBFLAG_A64(tb_flags, SME_TRAP_NONSTREAMING); |
75 | - if (!cmode_0 && !is_neg) { | 309 | dc->vec_len = 0; |
76 | - imm = bitfield_replicate(abcdefgh, 8); | 310 | dc->vec_stride = 0; |
77 | - } else if (!cmode_0 && is_neg) { | 311 | dc->cp_regs = arm_cpu->cp_regs; |
78 | - int i; | 312 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) |
79 | - imm = 0; | 313 | } |
80 | - for (i = 0; i < 8; i++) { | 314 | } |
81 | - if ((abcdefgh) & (1 << i)) { | 315 | |
82 | - imm |= 0xffULL << (i * 8); | 316 | + s->is_nonstreaming = false; |
83 | - } | 317 | + if (s->sme_trap_nonstreaming) { |
84 | - } | 318 | + disas_sme_fa64(s, insn); |
85 | - } else if (cmode_0) { | 319 | + } |
86 | - if (is_neg) { | 320 | + |
87 | - imm = (abcdefgh & 0x3f) << 48; | 321 | switch (extract32(insn, 25, 4)) { |
88 | - if (abcdefgh & 0x80) { | 322 | case 0x0: |
89 | - imm |= 0x8000000000000000ULL; | 323 | if (!extract32(insn, 31, 1) || !disas_sme(s, insn)) { |
90 | - } | 324 | diff --git a/target/arm/translate-vfp.c b/target/arm/translate-vfp.c |
91 | - if (abcdefgh & 0x40) { | 325 | index XXXXXXX..XXXXXXX 100644 |
92 | - imm |= 0x3fc0000000000000ULL; | 326 | --- a/target/arm/translate-vfp.c |
93 | - } else { | 327 | +++ b/target/arm/translate-vfp.c |
94 | - imm |= 0x4000000000000000ULL; | 328 | @@ -XXX,XX +XXX,XX @@ static bool vfp_access_check_a(DisasContext *s, bool ignore_vfp_enabled) |
95 | - } | 329 | return false; |
96 | - } else { | 330 | } |
97 | - if (o2) { | 331 | |
98 | - /* FMOV (vector, immediate) - half-precision */ | 332 | + /* |
99 | - imm = vfp_expand_imm(MO_16, abcdefgh); | 333 | + * Note that rebuild_hflags_a32 has already accounted for being in EL0 |
100 | - /* now duplicate across the lanes */ | 334 | + * and the higher EL in A64 mode, etc. Unlike A64 mode, there do not |
101 | - imm = bitfield_replicate(imm, 16); | 335 | + * appear to be any insns which touch VFP which are allowed. |
102 | - } else { | 336 | + */ |
103 | - imm = (abcdefgh & 0x3f) << 19; | 337 | + if (s->sme_trap_nonstreaming) { |
104 | - if (abcdefgh & 0x80) { | 338 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, |
105 | - imm |= 0x80000000; | 339 | + syn_smetrap(SME_ET_Streaming, |
106 | - } | 340 | + s->base.pc_next - s->pc_curr == 2)); |
107 | - if (abcdefgh & 0x40) { | 341 | + return false; |
108 | - imm |= 0x3e000000; | 342 | + } |
109 | - } else { | 343 | + |
110 | - imm |= 0x40000000; | 344 | if (!s->vfp_enabled && !ignore_vfp_enabled) { |
111 | - } | 345 | assert(!arm_dc_feature(s, ARM_FEATURE_M)); |
112 | - imm |= (imm << 32); | 346 | unallocated_encoding(s); |
113 | - } | ||
114 | - } | ||
115 | - } | ||
116 | - break; | ||
117 | - default: | ||
118 | - g_assert_not_reached(); | ||
119 | - } | ||
120 | - | ||
121 | - if (cmode_3_1 != 7 && is_neg) { | ||
122 | - imm = ~imm; | ||
123 | + if (cmode == 15 && o2 && !is_neg) { | ||
124 | + /* FMOV (vector, immediate) - half-precision */ | ||
125 | + imm = vfp_expand_imm(MO_16, abcdefgh); | ||
126 | + /* now duplicate across the lanes */ | ||
127 | + imm = bitfield_replicate(imm, 16); | ||
128 | + } else { | ||
129 | + imm = asimd_imm_const(abcdefgh, cmode, is_neg); | ||
130 | } | ||
131 | |||
132 | if (!((cmode & 0x9) == 0x1 || (cmode & 0xd) == 0x9)) { | ||
133 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 347 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
134 | index XXXXXXX..XXXXXXX 100644 | 348 | index XXXXXXX..XXXXXXX 100644 |
135 | --- a/target/arm/translate.c | 349 | --- a/target/arm/translate.c |
136 | +++ b/target/arm/translate.c | 350 | +++ b/target/arm/translate.c |
137 | @@ -XXX,XX +XXX,XX @@ uint64_t asimd_imm_const(uint32_t imm, int cmode, int op) | 351 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) |
138 | case 14: | 352 | dc->vec_len = EX_TBFLAG_A32(tb_flags, VECLEN); |
139 | if (op) { | 353 | dc->vec_stride = EX_TBFLAG_A32(tb_flags, VECSTRIDE); |
140 | /* | 354 | } |
141 | - * This is the only case where the top and bottom 32 bits | 355 | + dc->sme_trap_nonstreaming = |
142 | - * of the encoded constant differ. | 356 | + EX_TBFLAG_A32(tb_flags, SME_TRAP_NONSTREAMING); |
143 | + * This and cmode == 15 op == 1 are the only cases where | 357 | } |
144 | + * the top and bottom 32 bits of the encoded constant differ. | 358 | dc->cp_regs = cpu->cp_regs; |
145 | */ | 359 | dc->features = env->features; |
146 | uint64_t imm64 = 0; | 360 | diff --git a/target/arm/meson.build b/target/arm/meson.build |
147 | int n; | 361 | index XXXXXXX..XXXXXXX 100644 |
148 | @@ -XXX,XX +XXX,XX @@ uint64_t asimd_imm_const(uint32_t imm, int cmode, int op) | 362 | --- a/target/arm/meson.build |
149 | imm |= (imm << 8) | (imm << 16) | (imm << 24); | 363 | +++ b/target/arm/meson.build |
150 | break; | 364 | @@ -XXX,XX +XXX,XX @@ |
151 | case 15: | 365 | gen = [ |
152 | + if (op) { | 366 | decodetree.process('sve.decode', extra_args: '--decode=disas_sve'), |
153 | + /* Reserved encoding for AArch32; valid for AArch64 */ | 367 | decodetree.process('sme.decode', extra_args: '--decode=disas_sme'), |
154 | + uint64_t imm64 = (uint64_t)(imm & 0x3f) << 48; | 368 | + decodetree.process('sme-fa64.decode', extra_args: '--static-decode=disas_sme_fa64'), |
155 | + if (imm & 0x80) { | 369 | decodetree.process('neon-shared.decode', extra_args: '--decode=disas_neon_shared'), |
156 | + imm64 |= 0x8000000000000000ULL; | 370 | decodetree.process('neon-dp.decode', extra_args: '--decode=disas_neon_dp'), |
157 | + } | 371 | decodetree.process('neon-ls.decode', extra_args: '--decode=disas_neon_ls'), |
158 | + if (imm & 0x40) { | ||
159 | + imm64 |= 0x3fc0000000000000ULL; | ||
160 | + } else { | ||
161 | + imm64 |= 0x4000000000000000ULL; | ||
162 | + } | ||
163 | + return imm64; | ||
164 | + } | ||
165 | imm = ((imm & 0x80) << 24) | ((imm & 0x3f) << 19) | ||
166 | | ((imm & 0x40) ? (0x1f << 25) : (1 << 30)); | ||
167 | break; | ||
168 | -- | 372 | -- |
169 | 2.20.1 | 373 | 2.25.1 |
170 | |||
171 | diff view generated by jsdifflib |
1 | The function asimd_imm_const() in translate-neon.c is an | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | implementation of the pseudocode AdvSIMDExpandImm(), which we will | ||
3 | also want for MVE. Move the implementation to translate.c, with a | ||
4 | prototype in translate.h. | ||
5 | 2 | ||
3 | Mark ADR as a non-streaming instruction, which should trap | ||
4 | if full a64 support is not enabled in streaming mode. | ||
5 | |||
6 | Removing entries from sme-fa64.decode is an easy way to see | ||
7 | what remains to be done. | ||
8 | |||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20220708151540.18136-5-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210628135835.6690-4-peter.maydell@linaro.org | ||
9 | --- | 13 | --- |
10 | target/arm/translate.h | 16 ++++++++++ | 14 | target/arm/translate.h | 7 +++++++ |
11 | target/arm/translate-neon.c | 63 ------------------------------------- | 15 | target/arm/sme-fa64.decode | 1 - |
12 | target/arm/translate.c | 57 +++++++++++++++++++++++++++++++++ | 16 | target/arm/translate-sve.c | 8 ++++---- |
13 | 3 files changed, 73 insertions(+), 63 deletions(-) | 17 | 3 files changed, 11 insertions(+), 5 deletions(-) |
14 | 18 | ||
15 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 19 | diff --git a/target/arm/translate.h b/target/arm/translate.h |
16 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate.h | 21 | --- a/target/arm/translate.h |
18 | +++ b/target/arm/translate.h | 22 | +++ b/target/arm/translate.h |
19 | @@ -XXX,XX +XXX,XX @@ static inline MemOp finalize_memop(DisasContext *s, MemOp opc) | 23 | @@ -XXX,XX +XXX,XX @@ uint64_t asimd_imm_const(uint32_t imm, int cmode, int op); |
20 | return opc | s->be_data; | 24 | static bool trans_##NAME(DisasContext *s, arg_##NAME *a) \ |
21 | } | 25 | { return dc_isar_feature(FEAT, s) && FUNC(s, __VA_ARGS__); } |
22 | 26 | ||
23 | +/** | 27 | +#define TRANS_FEAT_NONSTREAMING(NAME, FEAT, FUNC, ...) \ |
24 | + * asimd_imm_const: Expand an encoded SIMD constant value | 28 | + static bool trans_##NAME(DisasContext *s, arg_##NAME *a) \ |
25 | + * | 29 | + { \ |
26 | + * Expand a SIMD constant value. This is essentially the pseudocode | 30 | + s->is_nonstreaming = true; \ |
27 | + * AdvSIMDExpandImm, except that we also perform the boolean NOT needed for | 31 | + return dc_isar_feature(FEAT, s) && FUNC(s, __VA_ARGS__); \ |
28 | + * VMVN and VBIC (when cmode < 14 && op == 1). | 32 | + } |
29 | + * | ||
30 | + * The combination cmode == 15 op == 1 is a reserved encoding for AArch32; | ||
31 | + * callers must catch this. | ||
32 | + * | ||
33 | + * cmode = 2,3,4,5,6,7,10,11,12,13 imm=0 was UNPREDICTABLE in v7A but | ||
34 | + * is either not unpredictable or merely CONSTRAINED UNPREDICTABLE in v8A; | ||
35 | + * we produce an immediate constant value of 0 in these cases. | ||
36 | + */ | ||
37 | +uint64_t asimd_imm_const(uint32_t imm, int cmode, int op); | ||
38 | + | 33 | + |
39 | #endif /* TARGET_ARM_TRANSLATE_H */ | 34 | #endif /* TARGET_ARM_TRANSLATE_H */ |
40 | diff --git a/target/arm/translate-neon.c b/target/arm/translate-neon.c | 35 | diff --git a/target/arm/sme-fa64.decode b/target/arm/sme-fa64.decode |
41 | index XXXXXXX..XXXXXXX 100644 | 36 | index XXXXXXX..XXXXXXX 100644 |
42 | --- a/target/arm/translate-neon.c | 37 | --- a/target/arm/sme-fa64.decode |
43 | +++ b/target/arm/translate-neon.c | 38 | +++ b/target/arm/sme-fa64.decode |
44 | @@ -XXX,XX +XXX,XX @@ DO_FP_2SH(VCVT_UH, gen_helper_gvec_vcvt_uh) | 39 | @@ -XXX,XX +XXX,XX @@ FAIL 0001 1110 0111 1110 0000 00-- ---- ---- # FJCVTZS |
45 | DO_FP_2SH(VCVT_HS, gen_helper_gvec_vcvt_hs) | 40 | # --11 1100 --1- ---- ---- ---- ---- --10 # Load/store FP register (register offset) |
46 | DO_FP_2SH(VCVT_HU, gen_helper_gvec_vcvt_hu) | 41 | # --11 1101 ---- ---- ---- ---- ---- ---- # Load/store FP register (scaled imm) |
47 | 42 | ||
48 | -static uint64_t asimd_imm_const(uint32_t imm, int cmode, int op) | 43 | -FAIL 0000 0100 --1- ---- 1010 ---- ---- ---- # ADR |
49 | -{ | 44 | FAIL 0000 0100 --1- ---- 1011 -0-- ---- ---- # FTSSEL, FEXPA |
50 | - /* | 45 | FAIL 0000 0101 --10 0001 100- ---- ---- ---- # COMPACT |
51 | - * Expand the encoded constant. | 46 | FAIL 0010 0101 --01 100- 1111 000- ---0 ---- # RDFFR, RDFFRS |
52 | - * Note that cmode = 2,3,4,5,6,7,10,11,12,13 imm=0 is UNPREDICTABLE. | 47 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c |
53 | - * We choose to not special-case this and will behave as if a | ||
54 | - * valid constant encoding of 0 had been given. | ||
55 | - * cmode = 15 op = 1 must UNDEF; we assume decode has handled that. | ||
56 | - */ | ||
57 | - switch (cmode) { | ||
58 | - case 0: case 1: | ||
59 | - /* no-op */ | ||
60 | - break; | ||
61 | - case 2: case 3: | ||
62 | - imm <<= 8; | ||
63 | - break; | ||
64 | - case 4: case 5: | ||
65 | - imm <<= 16; | ||
66 | - break; | ||
67 | - case 6: case 7: | ||
68 | - imm <<= 24; | ||
69 | - break; | ||
70 | - case 8: case 9: | ||
71 | - imm |= imm << 16; | ||
72 | - break; | ||
73 | - case 10: case 11: | ||
74 | - imm = (imm << 8) | (imm << 24); | ||
75 | - break; | ||
76 | - case 12: | ||
77 | - imm = (imm << 8) | 0xff; | ||
78 | - break; | ||
79 | - case 13: | ||
80 | - imm = (imm << 16) | 0xffff; | ||
81 | - break; | ||
82 | - case 14: | ||
83 | - if (op) { | ||
84 | - /* | ||
85 | - * This is the only case where the top and bottom 32 bits | ||
86 | - * of the encoded constant differ. | ||
87 | - */ | ||
88 | - uint64_t imm64 = 0; | ||
89 | - int n; | ||
90 | - | ||
91 | - for (n = 0; n < 8; n++) { | ||
92 | - if (imm & (1 << n)) { | ||
93 | - imm64 |= (0xffULL << (n * 8)); | ||
94 | - } | ||
95 | - } | ||
96 | - return imm64; | ||
97 | - } | ||
98 | - imm |= (imm << 8) | (imm << 16) | (imm << 24); | ||
99 | - break; | ||
100 | - case 15: | ||
101 | - imm = ((imm & 0x80) << 24) | ((imm & 0x3f) << 19) | ||
102 | - | ((imm & 0x40) ? (0x1f << 25) : (1 << 30)); | ||
103 | - break; | ||
104 | - } | ||
105 | - if (op) { | ||
106 | - imm = ~imm; | ||
107 | - } | ||
108 | - return dup_const(MO_32, imm); | ||
109 | -} | ||
110 | - | ||
111 | static bool do_1reg_imm(DisasContext *s, arg_1reg_imm *a, | ||
112 | GVecGen2iFn *fn) | ||
113 | { | ||
114 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
115 | index XXXXXXX..XXXXXXX 100644 | 48 | index XXXXXXX..XXXXXXX 100644 |
116 | --- a/target/arm/translate.c | 49 | --- a/target/arm/translate-sve.c |
117 | +++ b/target/arm/translate.c | 50 | +++ b/target/arm/translate-sve.c |
118 | @@ -XXX,XX +XXX,XX @@ void arm_translate_init(void) | 51 | @@ -XXX,XX +XXX,XX @@ static bool do_adr(DisasContext *s, arg_rrri *a, gen_helper_gvec_3 *fn) |
119 | a64_translate_init(); | 52 | return gen_gvec_ool_zzz(s, fn, a->rd, a->rn, a->rm, a->imm); |
120 | } | 53 | } |
121 | 54 | ||
122 | +uint64_t asimd_imm_const(uint32_t imm, int cmode, int op) | 55 | -TRANS_FEAT(ADR_p32, aa64_sve, do_adr, a, gen_helper_sve_adr_p32) |
123 | +{ | 56 | -TRANS_FEAT(ADR_p64, aa64_sve, do_adr, a, gen_helper_sve_adr_p64) |
124 | + /* Expand the encoded constant as per AdvSIMDExpandImm pseudocode */ | 57 | -TRANS_FEAT(ADR_s32, aa64_sve, do_adr, a, gen_helper_sve_adr_s32) |
125 | + switch (cmode) { | 58 | -TRANS_FEAT(ADR_u32, aa64_sve, do_adr, a, gen_helper_sve_adr_u32) |
126 | + case 0: case 1: | 59 | +TRANS_FEAT_NONSTREAMING(ADR_p32, aa64_sve, do_adr, a, gen_helper_sve_adr_p32) |
127 | + /* no-op */ | 60 | +TRANS_FEAT_NONSTREAMING(ADR_p64, aa64_sve, do_adr, a, gen_helper_sve_adr_p64) |
128 | + break; | 61 | +TRANS_FEAT_NONSTREAMING(ADR_s32, aa64_sve, do_adr, a, gen_helper_sve_adr_s32) |
129 | + case 2: case 3: | 62 | +TRANS_FEAT_NONSTREAMING(ADR_u32, aa64_sve, do_adr, a, gen_helper_sve_adr_u32) |
130 | + imm <<= 8; | 63 | |
131 | + break; | 64 | /* |
132 | + case 4: case 5: | 65 | *** SVE Integer Misc - Unpredicated Group |
133 | + imm <<= 16; | ||
134 | + break; | ||
135 | + case 6: case 7: | ||
136 | + imm <<= 24; | ||
137 | + break; | ||
138 | + case 8: case 9: | ||
139 | + imm |= imm << 16; | ||
140 | + break; | ||
141 | + case 10: case 11: | ||
142 | + imm = (imm << 8) | (imm << 24); | ||
143 | + break; | ||
144 | + case 12: | ||
145 | + imm = (imm << 8) | 0xff; | ||
146 | + break; | ||
147 | + case 13: | ||
148 | + imm = (imm << 16) | 0xffff; | ||
149 | + break; | ||
150 | + case 14: | ||
151 | + if (op) { | ||
152 | + /* | ||
153 | + * This is the only case where the top and bottom 32 bits | ||
154 | + * of the encoded constant differ. | ||
155 | + */ | ||
156 | + uint64_t imm64 = 0; | ||
157 | + int n; | ||
158 | + | ||
159 | + for (n = 0; n < 8; n++) { | ||
160 | + if (imm & (1 << n)) { | ||
161 | + imm64 |= (0xffULL << (n * 8)); | ||
162 | + } | ||
163 | + } | ||
164 | + return imm64; | ||
165 | + } | ||
166 | + imm |= (imm << 8) | (imm << 16) | (imm << 24); | ||
167 | + break; | ||
168 | + case 15: | ||
169 | + imm = ((imm & 0x80) << 24) | ((imm & 0x3f) << 19) | ||
170 | + | ((imm & 0x40) ? (0x1f << 25) : (1 << 30)); | ||
171 | + break; | ||
172 | + } | ||
173 | + if (op) { | ||
174 | + imm = ~imm; | ||
175 | + } | ||
176 | + return dup_const(MO_32, imm); | ||
177 | +} | ||
178 | + | ||
179 | /* Generate a label used for skipping this instruction */ | ||
180 | void arm_gen_condlabel(DisasContext *s) | ||
181 | { | ||
182 | -- | 66 | -- |
183 | 2.20.1 | 67 | 2.25.1 |
184 | |||
185 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Mark these as a non-streaming instructions, which should trap | ||
4 | if full a64 support is not enabled in streaming mode. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220708151540.18136-6-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/sme-fa64.decode | 2 -- | ||
12 | target/arm/translate-sve.c | 9 ++++++--- | ||
13 | 2 files changed, 6 insertions(+), 5 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/sme-fa64.decode b/target/arm/sme-fa64.decode | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/sme-fa64.decode | ||
18 | +++ b/target/arm/sme-fa64.decode | ||
19 | @@ -XXX,XX +XXX,XX @@ FAIL 0001 1110 0111 1110 0000 00-- ---- ---- # FJCVTZS | ||
20 | |||
21 | FAIL 0000 0100 --1- ---- 1011 -0-- ---- ---- # FTSSEL, FEXPA | ||
22 | FAIL 0000 0101 --10 0001 100- ---- ---- ---- # COMPACT | ||
23 | -FAIL 0010 0101 --01 100- 1111 000- ---0 ---- # RDFFR, RDFFRS | ||
24 | -FAIL 0010 0101 --10 1--- 1001 ---- ---- ---- # WRFFR, SETFFR | ||
25 | FAIL 0100 0101 --0- ---- 1011 ---- ---- ---- # BDEP, BEXT, BGRP | ||
26 | FAIL 0100 0101 000- ---- 0110 1--- ---- ---- # PMULLB, PMULLT (128b result) | ||
27 | FAIL 0110 0100 --1- ---- 1110 01-- ---- ---- # FMMLA, BFMMLA | ||
28 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/target/arm/translate-sve.c | ||
31 | +++ b/target/arm/translate-sve.c | ||
32 | @@ -XXX,XX +XXX,XX @@ static bool do_predset(DisasContext *s, int esz, int rd, int pat, bool setflag) | ||
33 | TRANS_FEAT(PTRUE, aa64_sve, do_predset, a->esz, a->rd, a->pat, a->s) | ||
34 | |||
35 | /* Note pat == 31 is #all, to set all elements. */ | ||
36 | -TRANS_FEAT(SETFFR, aa64_sve, do_predset, 0, FFR_PRED_NUM, 31, false) | ||
37 | +TRANS_FEAT_NONSTREAMING(SETFFR, aa64_sve, | ||
38 | + do_predset, 0, FFR_PRED_NUM, 31, false) | ||
39 | |||
40 | /* Note pat == 32 is #unimp, to set no elements. */ | ||
41 | TRANS_FEAT(PFALSE, aa64_sve, do_predset, 0, a->rd, 32, false) | ||
42 | @@ -XXX,XX +XXX,XX @@ static bool trans_RDFFR_p(DisasContext *s, arg_RDFFR_p *a) | ||
43 | .rd = a->rd, .pg = a->pg, .s = a->s, | ||
44 | .rn = FFR_PRED_NUM, .rm = FFR_PRED_NUM, | ||
45 | }; | ||
46 | + | ||
47 | + s->is_nonstreaming = true; | ||
48 | return trans_AND_pppp(s, &alt_a); | ||
49 | } | ||
50 | |||
51 | -TRANS_FEAT(RDFFR, aa64_sve, do_mov_p, a->rd, FFR_PRED_NUM) | ||
52 | -TRANS_FEAT(WRFFR, aa64_sve, do_mov_p, FFR_PRED_NUM, a->rn) | ||
53 | +TRANS_FEAT_NONSTREAMING(RDFFR, aa64_sve, do_mov_p, a->rd, FFR_PRED_NUM) | ||
54 | +TRANS_FEAT_NONSTREAMING(WRFFR, aa64_sve, do_mov_p, FFR_PRED_NUM, a->rn) | ||
55 | |||
56 | static bool do_pfirst_pnext(DisasContext *s, arg_rr_esz *a, | ||
57 | void (*gen_fn)(TCGv_i32, TCGv_ptr, | ||
58 | -- | ||
59 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Mark these as a non-streaming instructions, which should trap | ||
4 | if full a64 support is not enabled in streaming mode. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220708151540.18136-7-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/sme-fa64.decode | 3 --- | ||
12 | target/arm/translate-sve.c | 22 ++++++++++++---------- | ||
13 | 2 files changed, 12 insertions(+), 13 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/sme-fa64.decode b/target/arm/sme-fa64.decode | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/sme-fa64.decode | ||
18 | +++ b/target/arm/sme-fa64.decode | ||
19 | @@ -XXX,XX +XXX,XX @@ FAIL 0001 1110 0111 1110 0000 00-- ---- ---- # FJCVTZS | ||
20 | # --11 1100 --1- ---- ---- ---- ---- --10 # Load/store FP register (register offset) | ||
21 | # --11 1101 ---- ---- ---- ---- ---- ---- # Load/store FP register (scaled imm) | ||
22 | |||
23 | -FAIL 0000 0100 --1- ---- 1011 -0-- ---- ---- # FTSSEL, FEXPA | ||
24 | -FAIL 0000 0101 --10 0001 100- ---- ---- ---- # COMPACT | ||
25 | -FAIL 0100 0101 --0- ---- 1011 ---- ---- ---- # BDEP, BEXT, BGRP | ||
26 | FAIL 0100 0101 000- ---- 0110 1--- ---- ---- # PMULLB, PMULLT (128b result) | ||
27 | FAIL 0110 0100 --1- ---- 1110 01-- ---- ---- # FMMLA, BFMMLA | ||
28 | FAIL 0110 0101 --0- ---- 0000 11-- ---- ---- # FTSMUL | ||
29 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/target/arm/translate-sve.c | ||
32 | +++ b/target/arm/translate-sve.c | ||
33 | @@ -XXX,XX +XXX,XX @@ static gen_helper_gvec_2 * const fexpa_fns[4] = { | ||
34 | NULL, gen_helper_sve_fexpa_h, | ||
35 | gen_helper_sve_fexpa_s, gen_helper_sve_fexpa_d, | ||
36 | }; | ||
37 | -TRANS_FEAT(FEXPA, aa64_sve, gen_gvec_ool_zz, | ||
38 | - fexpa_fns[a->esz], a->rd, a->rn, 0) | ||
39 | +TRANS_FEAT_NONSTREAMING(FEXPA, aa64_sve, gen_gvec_ool_zz, | ||
40 | + fexpa_fns[a->esz], a->rd, a->rn, 0) | ||
41 | |||
42 | static gen_helper_gvec_3 * const ftssel_fns[4] = { | ||
43 | NULL, gen_helper_sve_ftssel_h, | ||
44 | gen_helper_sve_ftssel_s, gen_helper_sve_ftssel_d, | ||
45 | }; | ||
46 | -TRANS_FEAT(FTSSEL, aa64_sve, gen_gvec_ool_arg_zzz, ftssel_fns[a->esz], a, 0) | ||
47 | +TRANS_FEAT_NONSTREAMING(FTSSEL, aa64_sve, gen_gvec_ool_arg_zzz, | ||
48 | + ftssel_fns[a->esz], a, 0) | ||
49 | |||
50 | /* | ||
51 | *** SVE Predicate Logical Operations Group | ||
52 | @@ -XXX,XX +XXX,XX @@ TRANS_FEAT(TRN2_q, aa64_sve_f64mm, gen_gvec_ool_arg_zzz, | ||
53 | static gen_helper_gvec_3 * const compact_fns[4] = { | ||
54 | NULL, NULL, gen_helper_sve_compact_s, gen_helper_sve_compact_d | ||
55 | }; | ||
56 | -TRANS_FEAT(COMPACT, aa64_sve, gen_gvec_ool_arg_zpz, compact_fns[a->esz], a, 0) | ||
57 | +TRANS_FEAT_NONSTREAMING(COMPACT, aa64_sve, gen_gvec_ool_arg_zpz, | ||
58 | + compact_fns[a->esz], a, 0) | ||
59 | |||
60 | /* Call the helper that computes the ARM LastActiveElement pseudocode | ||
61 | * function, scaled by the element size. This includes the not found | ||
62 | @@ -XXX,XX +XXX,XX @@ static gen_helper_gvec_3 * const bext_fns[4] = { | ||
63 | gen_helper_sve2_bext_b, gen_helper_sve2_bext_h, | ||
64 | gen_helper_sve2_bext_s, gen_helper_sve2_bext_d, | ||
65 | }; | ||
66 | -TRANS_FEAT(BEXT, aa64_sve2_bitperm, gen_gvec_ool_arg_zzz, | ||
67 | - bext_fns[a->esz], a, 0) | ||
68 | +TRANS_FEAT_NONSTREAMING(BEXT, aa64_sve2_bitperm, gen_gvec_ool_arg_zzz, | ||
69 | + bext_fns[a->esz], a, 0) | ||
70 | |||
71 | static gen_helper_gvec_3 * const bdep_fns[4] = { | ||
72 | gen_helper_sve2_bdep_b, gen_helper_sve2_bdep_h, | ||
73 | gen_helper_sve2_bdep_s, gen_helper_sve2_bdep_d, | ||
74 | }; | ||
75 | -TRANS_FEAT(BDEP, aa64_sve2_bitperm, gen_gvec_ool_arg_zzz, | ||
76 | - bdep_fns[a->esz], a, 0) | ||
77 | +TRANS_FEAT_NONSTREAMING(BDEP, aa64_sve2_bitperm, gen_gvec_ool_arg_zzz, | ||
78 | + bdep_fns[a->esz], a, 0) | ||
79 | |||
80 | static gen_helper_gvec_3 * const bgrp_fns[4] = { | ||
81 | gen_helper_sve2_bgrp_b, gen_helper_sve2_bgrp_h, | ||
82 | gen_helper_sve2_bgrp_s, gen_helper_sve2_bgrp_d, | ||
83 | }; | ||
84 | -TRANS_FEAT(BGRP, aa64_sve2_bitperm, gen_gvec_ool_arg_zzz, | ||
85 | - bgrp_fns[a->esz], a, 0) | ||
86 | +TRANS_FEAT_NONSTREAMING(BGRP, aa64_sve2_bitperm, gen_gvec_ool_arg_zzz, | ||
87 | + bgrp_fns[a->esz], a, 0) | ||
88 | |||
89 | static gen_helper_gvec_3 * const cadd_fns[4] = { | ||
90 | gen_helper_sve2_cadd_b, gen_helper_sve2_cadd_h, | ||
91 | -- | ||
92 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Mark these as a non-streaming instructions, which should trap | ||
4 | if full a64 support is not enabled in streaming mode. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220708151540.18136-8-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/sme-fa64.decode | 2 -- | ||
12 | target/arm/translate-sve.c | 24 +++++++++++++++--------- | ||
13 | 2 files changed, 15 insertions(+), 11 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/sme-fa64.decode b/target/arm/sme-fa64.decode | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/sme-fa64.decode | ||
18 | +++ b/target/arm/sme-fa64.decode | ||
19 | @@ -XXX,XX +XXX,XX @@ FAIL 0001 1110 0111 1110 0000 00-- ---- ---- # FJCVTZS | ||
20 | # --11 1100 --1- ---- ---- ---- ---- --10 # Load/store FP register (register offset) | ||
21 | # --11 1101 ---- ---- ---- ---- ---- ---- # Load/store FP register (scaled imm) | ||
22 | |||
23 | -FAIL 0100 0101 000- ---- 0110 1--- ---- ---- # PMULLB, PMULLT (128b result) | ||
24 | -FAIL 0110 0100 --1- ---- 1110 01-- ---- ---- # FMMLA, BFMMLA | ||
25 | FAIL 0110 0101 --0- ---- 0000 11-- ---- ---- # FTSMUL | ||
26 | FAIL 0110 0101 --01 0--- 100- ---- ---- ---- # FTMAD | ||
27 | FAIL 0110 0101 --01 1--- 001- ---- ---- ---- # FADDA | ||
28 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/target/arm/translate-sve.c | ||
31 | +++ b/target/arm/translate-sve.c | ||
32 | @@ -XXX,XX +XXX,XX @@ static bool do_trans_pmull(DisasContext *s, arg_rrr_esz *a, bool sel) | ||
33 | gen_helper_gvec_pmull_q, gen_helper_sve2_pmull_h, | ||
34 | NULL, gen_helper_sve2_pmull_d, | ||
35 | }; | ||
36 | - if (a->esz == 0 | ||
37 | - ? !dc_isar_feature(aa64_sve2_pmull128, s) | ||
38 | - : !dc_isar_feature(aa64_sve, s)) { | ||
39 | + | ||
40 | + if (a->esz == 0) { | ||
41 | + if (!dc_isar_feature(aa64_sve2_pmull128, s)) { | ||
42 | + return false; | ||
43 | + } | ||
44 | + s->is_nonstreaming = true; | ||
45 | + } else if (!dc_isar_feature(aa64_sve, s)) { | ||
46 | return false; | ||
47 | } | ||
48 | return gen_gvec_ool_arg_zzz(s, fns[a->esz], a, sel); | ||
49 | @@ -XXX,XX +XXX,XX @@ DO_ZPZZ_FP(FMINP, aa64_sve2, sve2_fminp_zpzz) | ||
50 | * SVE Integer Multiply-Add (unpredicated) | ||
51 | */ | ||
52 | |||
53 | -TRANS_FEAT(FMMLA_s, aa64_sve_f32mm, gen_gvec_fpst_zzzz, gen_helper_fmmla_s, | ||
54 | - a->rd, a->rn, a->rm, a->ra, 0, FPST_FPCR) | ||
55 | -TRANS_FEAT(FMMLA_d, aa64_sve_f64mm, gen_gvec_fpst_zzzz, gen_helper_fmmla_d, | ||
56 | - a->rd, a->rn, a->rm, a->ra, 0, FPST_FPCR) | ||
57 | +TRANS_FEAT_NONSTREAMING(FMMLA_s, aa64_sve_f32mm, gen_gvec_fpst_zzzz, | ||
58 | + gen_helper_fmmla_s, a->rd, a->rn, a->rm, a->ra, | ||
59 | + 0, FPST_FPCR) | ||
60 | +TRANS_FEAT_NONSTREAMING(FMMLA_d, aa64_sve_f64mm, gen_gvec_fpst_zzzz, | ||
61 | + gen_helper_fmmla_d, a->rd, a->rn, a->rm, a->ra, | ||
62 | + 0, FPST_FPCR) | ||
63 | |||
64 | static gen_helper_gvec_4 * const sqdmlal_zzzw_fns[] = { | ||
65 | NULL, gen_helper_sve2_sqdmlal_zzzw_h, | ||
66 | @@ -XXX,XX +XXX,XX @@ TRANS_FEAT(BFDOT_zzzz, aa64_sve_bf16, gen_gvec_ool_arg_zzzz, | ||
67 | TRANS_FEAT(BFDOT_zzxz, aa64_sve_bf16, gen_gvec_ool_arg_zzxz, | ||
68 | gen_helper_gvec_bfdot_idx, a) | ||
69 | |||
70 | -TRANS_FEAT(BFMMLA, aa64_sve_bf16, gen_gvec_ool_arg_zzzz, | ||
71 | - gen_helper_gvec_bfmmla, a, 0) | ||
72 | +TRANS_FEAT_NONSTREAMING(BFMMLA, aa64_sve_bf16, gen_gvec_ool_arg_zzzz, | ||
73 | + gen_helper_gvec_bfmmla, a, 0) | ||
74 | |||
75 | static bool do_BFMLAL_zzzw(DisasContext *s, arg_rrrr_esz *a, bool sel) | ||
76 | { | ||
77 | -- | ||
78 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Mark these as a non-streaming instructions, which should trap | ||
4 | if full a64 support is not enabled in streaming mode. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220708151540.18136-9-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/sme-fa64.decode | 3 --- | ||
12 | target/arm/translate-sve.c | 15 +++++++++++---- | ||
13 | 2 files changed, 11 insertions(+), 7 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/sme-fa64.decode b/target/arm/sme-fa64.decode | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/sme-fa64.decode | ||
18 | +++ b/target/arm/sme-fa64.decode | ||
19 | @@ -XXX,XX +XXX,XX @@ FAIL 0001 1110 0111 1110 0000 00-- ---- ---- # FJCVTZS | ||
20 | # --11 1100 --1- ---- ---- ---- ---- --10 # Load/store FP register (register offset) | ||
21 | # --11 1101 ---- ---- ---- ---- ---- ---- # Load/store FP register (scaled imm) | ||
22 | |||
23 | -FAIL 0110 0101 --0- ---- 0000 11-- ---- ---- # FTSMUL | ||
24 | -FAIL 0110 0101 --01 0--- 100- ---- ---- ---- # FTMAD | ||
25 | -FAIL 0110 0101 --01 1--- 001- ---- ---- ---- # FADDA | ||
26 | FAIL 0100 0101 --0- ---- 1001 10-- ---- ---- # SMMLA, UMMLA, USMMLA | ||
27 | FAIL 0100 0101 --1- ---- 1--- ---- ---- ---- # SVE2 string/histo/crypto instructions | ||
28 | FAIL 1000 010- -00- ---- 10-- ---- ---- ---- # SVE2 32-bit gather NT load (vector+scalar) | ||
29 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/target/arm/translate-sve.c | ||
32 | +++ b/target/arm/translate-sve.c | ||
33 | @@ -XXX,XX +XXX,XX @@ static gen_helper_gvec_3_ptr * const ftmad_fns[4] = { | ||
34 | NULL, gen_helper_sve_ftmad_h, | ||
35 | gen_helper_sve_ftmad_s, gen_helper_sve_ftmad_d, | ||
36 | }; | ||
37 | -TRANS_FEAT(FTMAD, aa64_sve, gen_gvec_fpst_zzz, | ||
38 | - ftmad_fns[a->esz], a->rd, a->rn, a->rm, a->imm, | ||
39 | - a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR) | ||
40 | +TRANS_FEAT_NONSTREAMING(FTMAD, aa64_sve, gen_gvec_fpst_zzz, | ||
41 | + ftmad_fns[a->esz], a->rd, a->rn, a->rm, a->imm, | ||
42 | + a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR) | ||
43 | |||
44 | /* | ||
45 | *** SVE Floating Point Accumulating Reduction Group | ||
46 | @@ -XXX,XX +XXX,XX @@ static bool trans_FADDA(DisasContext *s, arg_rprr_esz *a) | ||
47 | if (a->esz == 0 || !dc_isar_feature(aa64_sve, s)) { | ||
48 | return false; | ||
49 | } | ||
50 | + s->is_nonstreaming = true; | ||
51 | if (!sve_access_check(s)) { | ||
52 | return true; | ||
53 | } | ||
54 | @@ -XXX,XX +XXX,XX @@ static bool trans_FADDA(DisasContext *s, arg_rprr_esz *a) | ||
55 | DO_FP3(FADD_zzz, fadd) | ||
56 | DO_FP3(FSUB_zzz, fsub) | ||
57 | DO_FP3(FMUL_zzz, fmul) | ||
58 | -DO_FP3(FTSMUL, ftsmul) | ||
59 | DO_FP3(FRECPS, recps) | ||
60 | DO_FP3(FRSQRTS, rsqrts) | ||
61 | |||
62 | #undef DO_FP3 | ||
63 | |||
64 | +static gen_helper_gvec_3_ptr * const ftsmul_fns[4] = { | ||
65 | + NULL, gen_helper_gvec_ftsmul_h, | ||
66 | + gen_helper_gvec_ftsmul_s, gen_helper_gvec_ftsmul_d | ||
67 | +}; | ||
68 | +TRANS_FEAT_NONSTREAMING(FTSMUL, aa64_sve, gen_gvec_fpst_arg_zzz, | ||
69 | + ftsmul_fns[a->esz], a, 0) | ||
70 | + | ||
71 | /* | ||
72 | *** SVE Floating Point Arithmetic - Predicated Group | ||
73 | */ | ||
74 | -- | ||
75 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Mark these as a non-streaming instructions, which should trap | ||
4 | if full a64 support is not enabled in streaming mode. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220708151540.18136-10-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/sme-fa64.decode | 1 - | ||
12 | target/arm/translate-sve.c | 12 ++++++------ | ||
13 | 2 files changed, 6 insertions(+), 7 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/sme-fa64.decode b/target/arm/sme-fa64.decode | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/sme-fa64.decode | ||
18 | +++ b/target/arm/sme-fa64.decode | ||
19 | @@ -XXX,XX +XXX,XX @@ FAIL 0001 1110 0111 1110 0000 00-- ---- ---- # FJCVTZS | ||
20 | # --11 1100 --1- ---- ---- ---- ---- --10 # Load/store FP register (register offset) | ||
21 | # --11 1101 ---- ---- ---- ---- ---- ---- # Load/store FP register (scaled imm) | ||
22 | |||
23 | -FAIL 0100 0101 --0- ---- 1001 10-- ---- ---- # SMMLA, UMMLA, USMMLA | ||
24 | FAIL 0100 0101 --1- ---- 1--- ---- ---- ---- # SVE2 string/histo/crypto instructions | ||
25 | FAIL 1000 010- -00- ---- 10-- ---- ---- ---- # SVE2 32-bit gather NT load (vector+scalar) | ||
26 | FAIL 1000 010- -00- ---- 111- ---- ---- ---- # SVE 32-bit gather prefetch (vector+imm) | ||
27 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/target/arm/translate-sve.c | ||
30 | +++ b/target/arm/translate-sve.c | ||
31 | @@ -XXX,XX +XXX,XX @@ TRANS_FEAT(FMLALT_zzxw, aa64_sve2, do_FMLAL_zzxw, a, false, true) | ||
32 | TRANS_FEAT(FMLSLB_zzxw, aa64_sve2, do_FMLAL_zzxw, a, true, false) | ||
33 | TRANS_FEAT(FMLSLT_zzxw, aa64_sve2, do_FMLAL_zzxw, a, true, true) | ||
34 | |||
35 | -TRANS_FEAT(SMMLA, aa64_sve_i8mm, gen_gvec_ool_arg_zzzz, | ||
36 | - gen_helper_gvec_smmla_b, a, 0) | ||
37 | -TRANS_FEAT(USMMLA, aa64_sve_i8mm, gen_gvec_ool_arg_zzzz, | ||
38 | - gen_helper_gvec_usmmla_b, a, 0) | ||
39 | -TRANS_FEAT(UMMLA, aa64_sve_i8mm, gen_gvec_ool_arg_zzzz, | ||
40 | - gen_helper_gvec_ummla_b, a, 0) | ||
41 | +TRANS_FEAT_NONSTREAMING(SMMLA, aa64_sve_i8mm, gen_gvec_ool_arg_zzzz, | ||
42 | + gen_helper_gvec_smmla_b, a, 0) | ||
43 | +TRANS_FEAT_NONSTREAMING(USMMLA, aa64_sve_i8mm, gen_gvec_ool_arg_zzzz, | ||
44 | + gen_helper_gvec_usmmla_b, a, 0) | ||
45 | +TRANS_FEAT_NONSTREAMING(UMMLA, aa64_sve_i8mm, gen_gvec_ool_arg_zzzz, | ||
46 | + gen_helper_gvec_ummla_b, a, 0) | ||
47 | |||
48 | TRANS_FEAT(BFDOT_zzzz, aa64_sve_bf16, gen_gvec_ool_arg_zzzz, | ||
49 | gen_helper_gvec_bfdot, a, 0) | ||
50 | -- | ||
51 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Mark these as non-streaming instructions, which should trap | ||
4 | if full a64 support is not enabled in streaming mode. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220708151540.18136-11-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/sme-fa64.decode | 1 - | ||
12 | target/arm/translate-sve.c | 35 ++++++++++++++++++----------------- | ||
13 | 2 files changed, 18 insertions(+), 18 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/sme-fa64.decode b/target/arm/sme-fa64.decode | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/sme-fa64.decode | ||
18 | +++ b/target/arm/sme-fa64.decode | ||
19 | @@ -XXX,XX +XXX,XX @@ FAIL 0001 1110 0111 1110 0000 00-- ---- ---- # FJCVTZS | ||
20 | # --11 1100 --1- ---- ---- ---- ---- --10 # Load/store FP register (register offset) | ||
21 | # --11 1101 ---- ---- ---- ---- ---- ---- # Load/store FP register (scaled imm) | ||
22 | |||
23 | -FAIL 0100 0101 --1- ---- 1--- ---- ---- ---- # SVE2 string/histo/crypto instructions | ||
24 | FAIL 1000 010- -00- ---- 10-- ---- ---- ---- # SVE2 32-bit gather NT load (vector+scalar) | ||
25 | FAIL 1000 010- -00- ---- 111- ---- ---- ---- # SVE 32-bit gather prefetch (vector+imm) | ||
26 | FAIL 1000 0100 0-1- ---- 0--- ---- ---- ---- # SVE 32-bit gather prefetch (scalar+vector) | ||
27 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/target/arm/translate-sve.c | ||
30 | +++ b/target/arm/translate-sve.c | ||
31 | @@ -XXX,XX +XXX,XX @@ DO_SVE2_ZZZ_NARROW(RSUBHNT, rsubhnt) | ||
32 | static gen_helper_gvec_flags_4 * const match_fns[4] = { | ||
33 | gen_helper_sve2_match_ppzz_b, gen_helper_sve2_match_ppzz_h, NULL, NULL | ||
34 | }; | ||
35 | -TRANS_FEAT(MATCH, aa64_sve2, do_ppzz_flags, a, match_fns[a->esz]) | ||
36 | +TRANS_FEAT_NONSTREAMING(MATCH, aa64_sve2, do_ppzz_flags, a, match_fns[a->esz]) | ||
37 | |||
38 | static gen_helper_gvec_flags_4 * const nmatch_fns[4] = { | ||
39 | gen_helper_sve2_nmatch_ppzz_b, gen_helper_sve2_nmatch_ppzz_h, NULL, NULL | ||
40 | }; | ||
41 | -TRANS_FEAT(NMATCH, aa64_sve2, do_ppzz_flags, a, nmatch_fns[a->esz]) | ||
42 | +TRANS_FEAT_NONSTREAMING(NMATCH, aa64_sve2, do_ppzz_flags, a, nmatch_fns[a->esz]) | ||
43 | |||
44 | static gen_helper_gvec_4 * const histcnt_fns[4] = { | ||
45 | NULL, NULL, gen_helper_sve2_histcnt_s, gen_helper_sve2_histcnt_d | ||
46 | }; | ||
47 | -TRANS_FEAT(HISTCNT, aa64_sve2, gen_gvec_ool_arg_zpzz, | ||
48 | - histcnt_fns[a->esz], a, 0) | ||
49 | +TRANS_FEAT_NONSTREAMING(HISTCNT, aa64_sve2, gen_gvec_ool_arg_zpzz, | ||
50 | + histcnt_fns[a->esz], a, 0) | ||
51 | |||
52 | -TRANS_FEAT(HISTSEG, aa64_sve2, gen_gvec_ool_arg_zzz, | ||
53 | - a->esz == 0 ? gen_helper_sve2_histseg : NULL, a, 0) | ||
54 | +TRANS_FEAT_NONSTREAMING(HISTSEG, aa64_sve2, gen_gvec_ool_arg_zzz, | ||
55 | + a->esz == 0 ? gen_helper_sve2_histseg : NULL, a, 0) | ||
56 | |||
57 | DO_ZPZZ_FP(FADDP, aa64_sve2, sve2_faddp_zpzz) | ||
58 | DO_ZPZZ_FP(FMAXNMP, aa64_sve2, sve2_fmaxnmp_zpzz) | ||
59 | @@ -XXX,XX +XXX,XX @@ TRANS_FEAT(SQRDCMLAH_zzzz, aa64_sve2, gen_gvec_ool_zzzz, | ||
60 | TRANS_FEAT(USDOT_zzzz, aa64_sve_i8mm, gen_gvec_ool_arg_zzzz, | ||
61 | a->esz == 2 ? gen_helper_gvec_usdot_b : NULL, a, 0) | ||
62 | |||
63 | -TRANS_FEAT(AESMC, aa64_sve2_aes, gen_gvec_ool_zz, | ||
64 | - gen_helper_crypto_aesmc, a->rd, a->rd, a->decrypt) | ||
65 | +TRANS_FEAT_NONSTREAMING(AESMC, aa64_sve2_aes, gen_gvec_ool_zz, | ||
66 | + gen_helper_crypto_aesmc, a->rd, a->rd, a->decrypt) | ||
67 | |||
68 | -TRANS_FEAT(AESE, aa64_sve2_aes, gen_gvec_ool_arg_zzz, | ||
69 | - gen_helper_crypto_aese, a, false) | ||
70 | -TRANS_FEAT(AESD, aa64_sve2_aes, gen_gvec_ool_arg_zzz, | ||
71 | - gen_helper_crypto_aese, a, true) | ||
72 | +TRANS_FEAT_NONSTREAMING(AESE, aa64_sve2_aes, gen_gvec_ool_arg_zzz, | ||
73 | + gen_helper_crypto_aese, a, false) | ||
74 | +TRANS_FEAT_NONSTREAMING(AESD, aa64_sve2_aes, gen_gvec_ool_arg_zzz, | ||
75 | + gen_helper_crypto_aese, a, true) | ||
76 | |||
77 | -TRANS_FEAT(SM4E, aa64_sve2_sm4, gen_gvec_ool_arg_zzz, | ||
78 | - gen_helper_crypto_sm4e, a, 0) | ||
79 | -TRANS_FEAT(SM4EKEY, aa64_sve2_sm4, gen_gvec_ool_arg_zzz, | ||
80 | - gen_helper_crypto_sm4ekey, a, 0) | ||
81 | +TRANS_FEAT_NONSTREAMING(SM4E, aa64_sve2_sm4, gen_gvec_ool_arg_zzz, | ||
82 | + gen_helper_crypto_sm4e, a, 0) | ||
83 | +TRANS_FEAT_NONSTREAMING(SM4EKEY, aa64_sve2_sm4, gen_gvec_ool_arg_zzz, | ||
84 | + gen_helper_crypto_sm4ekey, a, 0) | ||
85 | |||
86 | -TRANS_FEAT(RAX1, aa64_sve2_sha3, gen_gvec_fn_arg_zzz, gen_gvec_rax1, a) | ||
87 | +TRANS_FEAT_NONSTREAMING(RAX1, aa64_sve2_sha3, gen_gvec_fn_arg_zzz, | ||
88 | + gen_gvec_rax1, a) | ||
89 | |||
90 | TRANS_FEAT(FCVTNT_sh, aa64_sve2, gen_gvec_fpst_arg_zpz, | ||
91 | gen_helper_sve2_fcvtnt_sh, a, 0, FPST_FPCR) | ||
92 | -- | ||
93 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Mark these as a non-streaming instructions, which should trap | ||
4 | if full a64 support is not enabled in streaming mode. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220708151540.18136-12-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/sme-fa64.decode | 9 --------- | ||
12 | target/arm/translate-sve.c | 6 ++++++ | ||
13 | 2 files changed, 6 insertions(+), 9 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/sme-fa64.decode b/target/arm/sme-fa64.decode | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/sme-fa64.decode | ||
18 | +++ b/target/arm/sme-fa64.decode | ||
19 | @@ -XXX,XX +XXX,XX @@ FAIL 0001 1110 0111 1110 0000 00-- ---- ---- # FJCVTZS | ||
20 | # --11 1100 --1- ---- ---- ---- ---- --10 # Load/store FP register (register offset) | ||
21 | # --11 1101 ---- ---- ---- ---- ---- ---- # Load/store FP register (scaled imm) | ||
22 | |||
23 | -FAIL 1000 010- -00- ---- 10-- ---- ---- ---- # SVE2 32-bit gather NT load (vector+scalar) | ||
24 | FAIL 1000 010- -00- ---- 111- ---- ---- ---- # SVE 32-bit gather prefetch (vector+imm) | ||
25 | FAIL 1000 0100 0-1- ---- 0--- ---- ---- ---- # SVE 32-bit gather prefetch (scalar+vector) | ||
26 | -FAIL 1000 010- -01- ---- 1--- ---- ---- ---- # SVE 32-bit gather load (vector+imm) | ||
27 | -FAIL 1000 0100 0-0- ---- 0--- ---- ---- ---- # SVE 32-bit gather load byte (scalar+vector) | ||
28 | -FAIL 1000 0100 1--- ---- 0--- ---- ---- ---- # SVE 32-bit gather load half (scalar+vector) | ||
29 | -FAIL 1000 0101 0--- ---- 0--- ---- ---- ---- # SVE 32-bit gather load word (scalar+vector) | ||
30 | FAIL 1010 010- ---- ---- 011- ---- ---- ---- # SVE contiguous FF load (scalar+scalar) | ||
31 | FAIL 1010 010- ---1 ---- 101- ---- ---- ---- # SVE contiguous NF load (scalar+imm) | ||
32 | FAIL 1010 010- -01- ---- 000- ---- ---- ---- # SVE load & replicate 32 bytes (scalar+scalar) | ||
33 | FAIL 1010 010- -010 ---- 001- ---- ---- ---- # SVE load & replicate 32 bytes (scalar+imm) | ||
34 | FAIL 1100 010- ---- ---- ---- ---- ---- ---- # SVE 64-bit gather load/prefetch | ||
35 | -FAIL 1110 010- -00- ---- 001- ---- ---- ---- # SVE2 64-bit scatter NT store (vector+scalar) | ||
36 | -FAIL 1110 010- -10- ---- 001- ---- ---- ---- # SVE2 32-bit scatter NT store (vector+scalar) | ||
37 | -FAIL 1110 010- ---- ---- 1-0- ---- ---- ---- # SVE scatter store (scalar+32-bit vector) | ||
38 | -FAIL 1110 010- ---- ---- 101- ---- ---- ---- # SVE scatter store (misc) | ||
39 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | ||
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/target/arm/translate-sve.c | ||
42 | +++ b/target/arm/translate-sve.c | ||
43 | @@ -XXX,XX +XXX,XX @@ static bool trans_LD1_zprz(DisasContext *s, arg_LD1_zprz *a) | ||
44 | if (!dc_isar_feature(aa64_sve, s)) { | ||
45 | return false; | ||
46 | } | ||
47 | + s->is_nonstreaming = true; | ||
48 | if (!sve_access_check(s)) { | ||
49 | return true; | ||
50 | } | ||
51 | @@ -XXX,XX +XXX,XX @@ static bool trans_LD1_zpiz(DisasContext *s, arg_LD1_zpiz *a) | ||
52 | if (!dc_isar_feature(aa64_sve, s)) { | ||
53 | return false; | ||
54 | } | ||
55 | + s->is_nonstreaming = true; | ||
56 | if (!sve_access_check(s)) { | ||
57 | return true; | ||
58 | } | ||
59 | @@ -XXX,XX +XXX,XX @@ static bool trans_LDNT1_zprz(DisasContext *s, arg_LD1_zprz *a) | ||
60 | if (!dc_isar_feature(aa64_sve2, s)) { | ||
61 | return false; | ||
62 | } | ||
63 | + s->is_nonstreaming = true; | ||
64 | if (!sve_access_check(s)) { | ||
65 | return true; | ||
66 | } | ||
67 | @@ -XXX,XX +XXX,XX @@ static bool trans_ST1_zprz(DisasContext *s, arg_ST1_zprz *a) | ||
68 | if (!dc_isar_feature(aa64_sve, s)) { | ||
69 | return false; | ||
70 | } | ||
71 | + s->is_nonstreaming = true; | ||
72 | if (!sve_access_check(s)) { | ||
73 | return true; | ||
74 | } | ||
75 | @@ -XXX,XX +XXX,XX @@ static bool trans_ST1_zpiz(DisasContext *s, arg_ST1_zpiz *a) | ||
76 | if (!dc_isar_feature(aa64_sve, s)) { | ||
77 | return false; | ||
78 | } | ||
79 | + s->is_nonstreaming = true; | ||
80 | if (!sve_access_check(s)) { | ||
81 | return true; | ||
82 | } | ||
83 | @@ -XXX,XX +XXX,XX @@ static bool trans_STNT1_zprz(DisasContext *s, arg_ST1_zprz *a) | ||
84 | if (!dc_isar_feature(aa64_sve2, s)) { | ||
85 | return false; | ||
86 | } | ||
87 | + s->is_nonstreaming = true; | ||
88 | if (!sve_access_check(s)) { | ||
89 | return true; | ||
90 | } | ||
91 | -- | ||
92 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Mark these as a non-streaming instructions, which should trap if full | ||
4 | a64 support is not enabled in streaming mode. In this case, introduce | ||
5 | PRF_ns (prefetch non-streaming) to handle the checks. | ||
6 | |||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20220708151540.18136-13-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/sme-fa64.decode | 3 --- | ||
13 | target/arm/sve.decode | 10 +++++----- | ||
14 | target/arm/translate-sve.c | 11 +++++++++++ | ||
15 | 3 files changed, 16 insertions(+), 8 deletions(-) | ||
16 | |||
17 | diff --git a/target/arm/sme-fa64.decode b/target/arm/sme-fa64.decode | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/sme-fa64.decode | ||
20 | +++ b/target/arm/sme-fa64.decode | ||
21 | @@ -XXX,XX +XXX,XX @@ FAIL 0001 1110 0111 1110 0000 00-- ---- ---- # FJCVTZS | ||
22 | # --11 1100 --1- ---- ---- ---- ---- --10 # Load/store FP register (register offset) | ||
23 | # --11 1101 ---- ---- ---- ---- ---- ---- # Load/store FP register (scaled imm) | ||
24 | |||
25 | -FAIL 1000 010- -00- ---- 111- ---- ---- ---- # SVE 32-bit gather prefetch (vector+imm) | ||
26 | -FAIL 1000 0100 0-1- ---- 0--- ---- ---- ---- # SVE 32-bit gather prefetch (scalar+vector) | ||
27 | FAIL 1010 010- ---- ---- 011- ---- ---- ---- # SVE contiguous FF load (scalar+scalar) | ||
28 | FAIL 1010 010- ---1 ---- 101- ---- ---- ---- # SVE contiguous NF load (scalar+imm) | ||
29 | FAIL 1010 010- -01- ---- 000- ---- ---- ---- # SVE load & replicate 32 bytes (scalar+scalar) | ||
30 | FAIL 1010 010- -010 ---- 001- ---- ---- ---- # SVE load & replicate 32 bytes (scalar+imm) | ||
31 | -FAIL 1100 010- ---- ---- ---- ---- ---- ---- # SVE 64-bit gather load/prefetch | ||
32 | diff --git a/target/arm/sve.decode b/target/arm/sve.decode | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/target/arm/sve.decode | ||
35 | +++ b/target/arm/sve.decode | ||
36 | @@ -XXX,XX +XXX,XX @@ LD1RO_zpri 1010010 .. 01 0.... 001 ... ..... ..... \ | ||
37 | @rpri_load_msz nreg=0 | ||
38 | |||
39 | # SVE 32-bit gather prefetch (scalar plus 32-bit scaled offsets) | ||
40 | -PRF 1000010 00 -1 ----- 0-- --- ----- 0 ---- | ||
41 | +PRF_ns 1000010 00 -1 ----- 0-- --- ----- 0 ---- | ||
42 | |||
43 | # SVE 32-bit gather prefetch (vector plus immediate) | ||
44 | -PRF 1000010 -- 00 ----- 111 --- ----- 0 ---- | ||
45 | +PRF_ns 1000010 -- 00 ----- 111 --- ----- 0 ---- | ||
46 | |||
47 | # SVE contiguous prefetch (scalar plus immediate) | ||
48 | PRF 1000010 11 1- ----- 0-- --- ----- 0 ---- | ||
49 | @@ -XXX,XX +XXX,XX @@ LD1_zpiz 1100010 .. 01 ..... 1.. ... ..... ..... \ | ||
50 | @rpri_g_load esz=3 | ||
51 | |||
52 | # SVE 64-bit gather prefetch (scalar plus 64-bit scaled offsets) | ||
53 | -PRF 1100010 00 11 ----- 1-- --- ----- 0 ---- | ||
54 | +PRF_ns 1100010 00 11 ----- 1-- --- ----- 0 ---- | ||
55 | |||
56 | # SVE 64-bit gather prefetch (scalar plus unpacked 32-bit scaled offsets) | ||
57 | -PRF 1100010 00 -1 ----- 0-- --- ----- 0 ---- | ||
58 | +PRF_ns 1100010 00 -1 ----- 0-- --- ----- 0 ---- | ||
59 | |||
60 | # SVE 64-bit gather prefetch (vector plus immediate) | ||
61 | -PRF 1100010 -- 00 ----- 111 --- ----- 0 ---- | ||
62 | +PRF_ns 1100010 -- 00 ----- 111 --- ----- 0 ---- | ||
63 | |||
64 | ### SVE Memory Store Group | ||
65 | |||
66 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/target/arm/translate-sve.c | ||
69 | +++ b/target/arm/translate-sve.c | ||
70 | @@ -XXX,XX +XXX,XX @@ static bool trans_PRF_rr(DisasContext *s, arg_PRF_rr *a) | ||
71 | return true; | ||
72 | } | ||
73 | |||
74 | +static bool trans_PRF_ns(DisasContext *s, arg_PRF_ns *a) | ||
75 | +{ | ||
76 | + if (!dc_isar_feature(aa64_sve, s)) { | ||
77 | + return false; | ||
78 | + } | ||
79 | + /* Prefetch is a nop within QEMU. */ | ||
80 | + s->is_nonstreaming = true; | ||
81 | + (void)sve_access_check(s); | ||
82 | + return true; | ||
83 | +} | ||
84 | + | ||
85 | /* | ||
86 | * Move Prefix | ||
87 | * | ||
88 | -- | ||
89 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Mark these as a non-streaming instructions, which should trap | ||
4 | if full a64 support is not enabled in streaming mode. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220708151540.18136-14-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/sme-fa64.decode | 2 -- | ||
12 | target/arm/translate-sve.c | 2 ++ | ||
13 | 2 files changed, 2 insertions(+), 2 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/sme-fa64.decode b/target/arm/sme-fa64.decode | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/sme-fa64.decode | ||
18 | +++ b/target/arm/sme-fa64.decode | ||
19 | @@ -XXX,XX +XXX,XX @@ FAIL 0001 1110 0111 1110 0000 00-- ---- ---- # FJCVTZS | ||
20 | # --11 1100 --1- ---- ---- ---- ---- --10 # Load/store FP register (register offset) | ||
21 | # --11 1101 ---- ---- ---- ---- ---- ---- # Load/store FP register (scaled imm) | ||
22 | |||
23 | -FAIL 1010 010- ---- ---- 011- ---- ---- ---- # SVE contiguous FF load (scalar+scalar) | ||
24 | -FAIL 1010 010- ---1 ---- 101- ---- ---- ---- # SVE contiguous NF load (scalar+imm) | ||
25 | FAIL 1010 010- -01- ---- 000- ---- ---- ---- # SVE load & replicate 32 bytes (scalar+scalar) | ||
26 | FAIL 1010 010- -010 ---- 001- ---- ---- ---- # SVE load & replicate 32 bytes (scalar+imm) | ||
27 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/target/arm/translate-sve.c | ||
30 | +++ b/target/arm/translate-sve.c | ||
31 | @@ -XXX,XX +XXX,XX @@ static bool trans_LDFF1_zprr(DisasContext *s, arg_rprr_load *a) | ||
32 | if (!dc_isar_feature(aa64_sve, s)) { | ||
33 | return false; | ||
34 | } | ||
35 | + s->is_nonstreaming = true; | ||
36 | if (sve_access_check(s)) { | ||
37 | TCGv_i64 addr = new_tmp_a64(s); | ||
38 | tcg_gen_shli_i64(addr, cpu_reg(s, a->rm), dtype_msz(a->dtype)); | ||
39 | @@ -XXX,XX +XXX,XX @@ static bool trans_LDNF1_zpri(DisasContext *s, arg_rpri_load *a) | ||
40 | if (!dc_isar_feature(aa64_sve, s)) { | ||
41 | return false; | ||
42 | } | ||
43 | + s->is_nonstreaming = true; | ||
44 | if (sve_access_check(s)) { | ||
45 | int vsz = vec_full_reg_size(s); | ||
46 | int elements = vsz >> dtype_esz[a->dtype]; | ||
47 | -- | ||
48 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Mark these as a non-streaming instructions, which should trap | ||
4 | if full a64 support is not enabled in streaming mode. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220708151540.18136-15-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/sme-fa64.decode | 3 --- | ||
12 | target/arm/translate-sve.c | 2 ++ | ||
13 | 2 files changed, 2 insertions(+), 3 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/sme-fa64.decode b/target/arm/sme-fa64.decode | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/sme-fa64.decode | ||
18 | +++ b/target/arm/sme-fa64.decode | ||
19 | @@ -XXX,XX +XXX,XX @@ FAIL 0001 1110 0111 1110 0000 00-- ---- ---- # FJCVTZS | ||
20 | # --11 1100 --0- ---- ---- ---- ---- ---- # Load/store FP register (unscaled imm) | ||
21 | # --11 1100 --1- ---- ---- ---- ---- --10 # Load/store FP register (register offset) | ||
22 | # --11 1101 ---- ---- ---- ---- ---- ---- # Load/store FP register (scaled imm) | ||
23 | - | ||
24 | -FAIL 1010 010- -01- ---- 000- ---- ---- ---- # SVE load & replicate 32 bytes (scalar+scalar) | ||
25 | -FAIL 1010 010- -010 ---- 001- ---- ---- ---- # SVE load & replicate 32 bytes (scalar+imm) | ||
26 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/target/arm/translate-sve.c | ||
29 | +++ b/target/arm/translate-sve.c | ||
30 | @@ -XXX,XX +XXX,XX @@ static bool trans_LD1RO_zprr(DisasContext *s, arg_rprr_load *a) | ||
31 | if (a->rm == 31) { | ||
32 | return false; | ||
33 | } | ||
34 | + s->is_nonstreaming = true; | ||
35 | if (sve_access_check(s)) { | ||
36 | TCGv_i64 addr = new_tmp_a64(s); | ||
37 | tcg_gen_shli_i64(addr, cpu_reg(s, a->rm), dtype_msz(a->dtype)); | ||
38 | @@ -XXX,XX +XXX,XX @@ static bool trans_LD1RO_zpri(DisasContext *s, arg_rpri_load *a) | ||
39 | if (!dc_isar_feature(aa64_sve_f64mm, s)) { | ||
40 | return false; | ||
41 | } | ||
42 | + s->is_nonstreaming = true; | ||
43 | if (sve_access_check(s)) { | ||
44 | TCGv_i64 addr = new_tmp_a64(s); | ||
45 | tcg_gen_addi_i64(addr, cpu_reg_sp(s, a->rn), a->imm * 32); | ||
46 | -- | ||
47 | 2.25.1 | diff view generated by jsdifflib |
1 | Implement the MVE long shifts by register, which perform shifts on a | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | pair of general-purpose registers treated as a 64-bit quantity, with | ||
3 | the shift count in another general-purpose register, which might be | ||
4 | either positive or negative. | ||
5 | 2 | ||
6 | Like the long-shifts-by-immediate, these encodings sit in the space | 3 | These functions will be used to verify that the cpu |
7 | that was previously the UNPREDICTABLE MOVS/ORRS with Rm==13,15. | 4 | is in the correct state for a given instruction. |
8 | Because LSLL_rr and ASRL_rr overlap with both MOV_rxri/ORR_rrri and | ||
9 | also with CSEL (as one of the previously-UNPREDICTABLE Rm==13 cases), | ||
10 | we have to move the CSEL pattern into the same decodetree group. | ||
11 | 5 | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220708151540.18136-16-richard.henderson@linaro.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-id: 20210628135835.6690-17-peter.maydell@linaro.org | ||
15 | --- | 10 | --- |
16 | target/arm/helper-mve.h | 6 +++ | 11 | target/arm/translate-a64.h | 21 +++++++++++++++++++++ |
17 | target/arm/translate.h | 1 + | 12 | target/arm/translate-a64.c | 34 ++++++++++++++++++++++++++++++++++ |
18 | target/arm/t32.decode | 16 +++++-- | 13 | 2 files changed, 55 insertions(+) |
19 | target/arm/mve_helper.c | 93 +++++++++++++++++++++++++++++++++++++++++ | ||
20 | target/arm/translate.c | 69 ++++++++++++++++++++++++++++++ | ||
21 | 5 files changed, 182 insertions(+), 3 deletions(-) | ||
22 | 14 | ||
23 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 15 | diff --git a/target/arm/translate-a64.h b/target/arm/translate-a64.h |
24 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/target/arm/helper-mve.h | 17 | --- a/target/arm/translate-a64.h |
26 | +++ b/target/arm/helper-mve.h | 18 | +++ b/target/arm/translate-a64.h |
27 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqrshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 19 | @@ -XXX,XX +XXX,XX @@ void write_fp_dreg(DisasContext *s, int reg, TCGv_i64 v); |
28 | 20 | bool logic_imm_decode_wmask(uint64_t *result, unsigned int immn, | |
29 | DEF_HELPER_FLAGS_4(mve_vshlc, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) | 21 | unsigned int imms, unsigned int immr); |
30 | 22 | bool sve_access_check(DisasContext *s); | |
31 | +DEF_HELPER_FLAGS_3(mve_sshrl, TCG_CALL_NO_RWG, i64, env, i64, i32) | 23 | +bool sme_enabled_check(DisasContext *s); |
32 | +DEF_HELPER_FLAGS_3(mve_ushll, TCG_CALL_NO_RWG, i64, env, i64, i32) | 24 | +bool sme_enabled_check_with_svcr(DisasContext *s, unsigned); |
33 | DEF_HELPER_FLAGS_3(mve_sqshll, TCG_CALL_NO_RWG, i64, env, i64, i32) | ||
34 | DEF_HELPER_FLAGS_3(mve_uqshll, TCG_CALL_NO_RWG, i64, env, i64, i32) | ||
35 | +DEF_HELPER_FLAGS_3(mve_sqrshrl, TCG_CALL_NO_RWG, i64, env, i64, i32) | ||
36 | +DEF_HELPER_FLAGS_3(mve_uqrshll, TCG_CALL_NO_RWG, i64, env, i64, i32) | ||
37 | +DEF_HELPER_FLAGS_3(mve_sqrshrl48, TCG_CALL_NO_RWG, i64, env, i64, i32) | ||
38 | +DEF_HELPER_FLAGS_3(mve_uqrshll48, TCG_CALL_NO_RWG, i64, env, i64, i32) | ||
39 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/target/arm/translate.h | ||
42 | +++ b/target/arm/translate.h | ||
43 | @@ -XXX,XX +XXX,XX @@ typedef void CryptoThreeOpIntFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
44 | typedef void CryptoThreeOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
45 | typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp); | ||
46 | typedef void WideShiftImmFn(TCGv_i64, TCGv_i64, int64_t shift); | ||
47 | +typedef void WideShiftFn(TCGv_i64, TCGv_ptr, TCGv_i64, TCGv_i32); | ||
48 | |||
49 | /** | ||
50 | * arm_tbflags_from_tb: | ||
51 | diff --git a/target/arm/t32.decode b/target/arm/t32.decode | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/target/arm/t32.decode | ||
54 | +++ b/target/arm/t32.decode | ||
55 | @@ -XXX,XX +XXX,XX @@ | ||
56 | &mcrr !extern cp opc1 crm rt rt2 | ||
57 | |||
58 | &mve_shl_ri rdalo rdahi shim | ||
59 | +&mve_shl_rr rdalo rdahi rm | ||
60 | |||
61 | # rdahi: bits [3:1] from insn, bit 0 is 1 | ||
62 | # rdalo: bits [3:1] from insn, bit 0 is 0 | ||
63 | @@ -XXX,XX +XXX,XX @@ | ||
64 | |||
65 | @mve_shl_ri ....... .... . ... . . ... ... . .. .. .... \ | ||
66 | &mve_shl_ri shim=%imm5_12_6 rdalo=%rdalo_17 rdahi=%rdahi_9 | ||
67 | +@mve_shl_rr ....... .... . ... . rm:4 ... . .. .. .... \ | ||
68 | + &mve_shl_rr rdalo=%rdalo_17 rdahi=%rdahi_9 | ||
69 | |||
70 | { | ||
71 | TST_xrri 1110101 0000 1 .... 0 ... 1111 .... .... @S_xrr_shi | ||
72 | @@ -XXX,XX +XXX,XX @@ BIC_rrri 1110101 0001 . .... 0 ... .... .... .... @s_rrr_shi | ||
73 | URSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 01 1111 @mve_shl_ri | ||
74 | SRSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 10 1111 @mve_shl_ri | ||
75 | SQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 11 1111 @mve_shl_ri | ||
76 | + | 25 | + |
77 | + LSLL_rr 1110101 0010 1 ... 0 .... ... 1 0000 1101 @mve_shl_rr | 26 | +/* This function corresponds to CheckStreamingSVEEnabled. */ |
78 | + ASRL_rr 1110101 0010 1 ... 0 .... ... 1 0010 1101 @mve_shl_rr | 27 | +static inline bool sme_sm_enabled_check(DisasContext *s) |
79 | + UQRSHLL64_rr 1110101 0010 1 ... 1 .... ... 1 0000 1101 @mve_shl_rr | ||
80 | + SQRSHRL64_rr 1110101 0010 1 ... 1 .... ... 1 0010 1101 @mve_shl_rr | ||
81 | + UQRSHLL48_rr 1110101 0010 1 ... 1 .... ... 1 1000 1101 @mve_shl_rr | ||
82 | + SQRSHRL48_rr 1110101 0010 1 ... 1 .... ... 1 1010 1101 @mve_shl_rr | ||
83 | ] | ||
84 | |||
85 | MOV_rxri 1110101 0010 . 1111 0 ... .... .... .... @s_rxr_shi | ||
86 | ORR_rrri 1110101 0010 . .... 0 ... .... .... .... @s_rrr_shi | ||
87 | + | ||
88 | + # v8.1M CSEL and friends | ||
89 | + CSEL 1110101 0010 1 rn:4 10 op:2 rd:4 fcond:4 rm:4 | ||
90 | } | ||
91 | { | ||
92 | MVN_rxri 1110101 0011 . 1111 0 ... .... .... .... @s_rxr_shi | ||
93 | @@ -XXX,XX +XXX,XX @@ SBC_rrri 1110101 1011 . .... 0 ... .... .... .... @s_rrr_shi | ||
94 | } | ||
95 | RSB_rrri 1110101 1110 . .... 0 ... .... .... .... @s_rrr_shi | ||
96 | |||
97 | -# v8.1M CSEL and friends | ||
98 | -CSEL 1110101 0010 1 rn:4 10 op:2 rd:4 fcond:4 rm:4 | ||
99 | - | ||
100 | # Data-processing (register-shifted register) | ||
101 | |||
102 | MOV_rxrr 1111 1010 0 shty:2 s:1 rm:4 1111 rd:4 0000 rs:4 \ | ||
103 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
104 | index XXXXXXX..XXXXXXX 100644 | ||
105 | --- a/target/arm/mve_helper.c | ||
106 | +++ b/target/arm/mve_helper.c | ||
107 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(mve_vshlc)(CPUARMState *env, void *vd, uint32_t rdm, | ||
108 | return rdm; | ||
109 | } | ||
110 | |||
111 | +uint64_t HELPER(mve_sshrl)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
112 | +{ | 28 | +{ |
113 | + return do_sqrshl_d(n, -(int8_t)shift, false, NULL); | 29 | + return sme_enabled_check_with_svcr(s, R_SVCR_SM_MASK); |
114 | +} | 30 | +} |
115 | + | 31 | + |
116 | +uint64_t HELPER(mve_ushll)(CPUARMState *env, uint64_t n, uint32_t shift) | 32 | +/* This function corresponds to CheckSMEAndZAEnabled. */ |
33 | +static inline bool sme_za_enabled_check(DisasContext *s) | ||
117 | +{ | 34 | +{ |
118 | + return do_uqrshl_d(n, (int8_t)shift, false, NULL); | 35 | + return sme_enabled_check_with_svcr(s, R_SVCR_ZA_MASK); |
119 | +} | 36 | +} |
120 | + | 37 | + |
121 | uint64_t HELPER(mve_sqshll)(CPUARMState *env, uint64_t n, uint32_t shift) | 38 | +/* Note that this function corresponds to CheckStreamingSVEAndZAEnabled. */ |
122 | { | 39 | +static inline bool sme_smza_enabled_check(DisasContext *s) |
123 | return do_sqrshl_d(n, (int8_t)shift, false, &env->QF); | ||
124 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(mve_uqshll)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
125 | { | ||
126 | return do_uqrshl_d(n, (int8_t)shift, false, &env->QF); | ||
127 | } | ||
128 | + | ||
129 | +uint64_t HELPER(mve_sqrshrl)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
130 | +{ | 40 | +{ |
131 | + return do_sqrshl_d(n, -(int8_t)shift, true, &env->QF); | 41 | + return sme_enabled_check_with_svcr(s, R_SVCR_SM_MASK | R_SVCR_ZA_MASK); |
132 | +} | 42 | +} |
133 | + | 43 | + |
134 | +uint64_t HELPER(mve_uqrshll)(CPUARMState *env, uint64_t n, uint32_t shift) | 44 | TCGv_i64 clean_data_tbi(DisasContext *s, TCGv_i64 addr); |
45 | TCGv_i64 gen_mte_check1(DisasContext *s, TCGv_i64 addr, bool is_write, | ||
46 | bool tag_checked, int log2_size); | ||
47 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/target/arm/translate-a64.c | ||
50 | +++ b/target/arm/translate-a64.c | ||
51 | @@ -XXX,XX +XXX,XX @@ static bool sme_access_check(DisasContext *s) | ||
52 | return true; | ||
53 | } | ||
54 | |||
55 | +/* This function corresponds to CheckSMEEnabled. */ | ||
56 | +bool sme_enabled_check(DisasContext *s) | ||
135 | +{ | 57 | +{ |
136 | + return do_uqrshl_d(n, (int8_t)shift, true, &env->QF); | 58 | + /* |
59 | + * Note that unlike sve_excp_el, we have not constrained sme_excp_el | ||
60 | + * to be zero when fp_excp_el has priority. This is because we need | ||
61 | + * sme_excp_el by itself for cpregs access checks. | ||
62 | + */ | ||
63 | + if (!s->fp_excp_el || s->sme_excp_el < s->fp_excp_el) { | ||
64 | + s->fp_access_checked = true; | ||
65 | + return sme_access_check(s); | ||
66 | + } | ||
67 | + return fp_access_check_only(s); | ||
137 | +} | 68 | +} |
138 | + | 69 | + |
139 | +/* Operate on 64-bit values, but saturate at 48 bits */ | 70 | +/* Common subroutine for CheckSMEAnd*Enabled. */ |
140 | +static inline int64_t do_sqrshl48_d(int64_t src, int64_t shift, | 71 | +bool sme_enabled_check_with_svcr(DisasContext *s, unsigned req) |
141 | + bool round, uint32_t *sat) | ||
142 | +{ | 72 | +{ |
143 | + if (shift <= -48) { | 73 | + if (!sme_enabled_check(s)) { |
144 | + /* Rounding the sign bit always produces 0. */ | ||
145 | + if (round) { | ||
146 | + return 0; | ||
147 | + } | ||
148 | + return src >> 63; | ||
149 | + } else if (shift < 0) { | ||
150 | + if (round) { | ||
151 | + src >>= -shift - 1; | ||
152 | + return (src >> 1) + (src & 1); | ||
153 | + } | ||
154 | + return src >> -shift; | ||
155 | + } else if (shift < 48) { | ||
156 | + int64_t val = src << shift; | ||
157 | + int64_t extval = sextract64(val, 0, 48); | ||
158 | + if (!sat || val == extval) { | ||
159 | + return extval; | ||
160 | + } | ||
161 | + } else if (!sat || src == 0) { | ||
162 | + return 0; | ||
163 | + } | ||
164 | + | ||
165 | + *sat = 1; | ||
166 | + return (1ULL << 47) - (src >= 0); | ||
167 | +} | ||
168 | + | ||
169 | +/* Operate on 64-bit values, but saturate at 48 bits */ | ||
170 | +static inline uint64_t do_uqrshl48_d(uint64_t src, int64_t shift, | ||
171 | + bool round, uint32_t *sat) | ||
172 | +{ | ||
173 | + uint64_t val, extval; | ||
174 | + | ||
175 | + if (shift <= -(48 + round)) { | ||
176 | + return 0; | ||
177 | + } else if (shift < 0) { | ||
178 | + if (round) { | ||
179 | + val = src >> (-shift - 1); | ||
180 | + val = (val >> 1) + (val & 1); | ||
181 | + } else { | ||
182 | + val = src >> -shift; | ||
183 | + } | ||
184 | + extval = extract64(val, 0, 48); | ||
185 | + if (!sat || val == extval) { | ||
186 | + return extval; | ||
187 | + } | ||
188 | + } else if (shift < 48) { | ||
189 | + uint64_t val = src << shift; | ||
190 | + uint64_t extval = extract64(val, 0, 48); | ||
191 | + if (!sat || val == extval) { | ||
192 | + return extval; | ||
193 | + } | ||
194 | + } else if (!sat || src == 0) { | ||
195 | + return 0; | ||
196 | + } | ||
197 | + | ||
198 | + *sat = 1; | ||
199 | + return MAKE_64BIT_MASK(0, 48); | ||
200 | +} | ||
201 | + | ||
202 | +uint64_t HELPER(mve_sqrshrl48)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
203 | +{ | ||
204 | + return do_sqrshl48_d(n, -(int8_t)shift, true, &env->QF); | ||
205 | +} | ||
206 | + | ||
207 | +uint64_t HELPER(mve_uqrshll48)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
208 | +{ | ||
209 | + return do_uqrshl48_d(n, (int8_t)shift, true, &env->QF); | ||
210 | +} | ||
211 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
212 | index XXXXXXX..XXXXXXX 100644 | ||
213 | --- a/target/arm/translate.c | ||
214 | +++ b/target/arm/translate.c | ||
215 | @@ -XXX,XX +XXX,XX @@ static bool trans_URSHRL_ri(DisasContext *s, arg_mve_shl_ri *a) | ||
216 | return do_mve_shl_ri(s, a, gen_urshr64_i64); | ||
217 | } | ||
218 | |||
219 | +static bool do_mve_shl_rr(DisasContext *s, arg_mve_shl_rr *a, WideShiftFn *fn) | ||
220 | +{ | ||
221 | + TCGv_i64 rda; | ||
222 | + TCGv_i32 rdalo, rdahi; | ||
223 | + | ||
224 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { | ||
225 | + /* Decode falls through to ORR/MOV UNPREDICTABLE handling */ | ||
226 | + return false; | 74 | + return false; |
227 | + } | 75 | + } |
228 | + if (a->rdahi == 15) { | 76 | + if (FIELD_EX64(req, SVCR, SM) && !s->pstate_sm) { |
229 | + /* These are a different encoding (SQSHL/SRSHR/UQSHL/URSHR) */ | 77 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, |
78 | + syn_smetrap(SME_ET_NotStreaming, false)); | ||
230 | + return false; | 79 | + return false; |
231 | + } | 80 | + } |
232 | + if (!dc_isar_feature(aa32_mve, s) || | 81 | + if (FIELD_EX64(req, SVCR, ZA) && !s->pstate_za) { |
233 | + !arm_dc_feature(s, ARM_FEATURE_M_MAIN) || | 82 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, |
234 | + a->rdahi == 13 || a->rm == 13 || a->rm == 15 || | 83 | + syn_smetrap(SME_ET_InactiveZA, false)); |
235 | + a->rm == a->rdahi || a->rm == a->rdalo) { | 84 | + return false; |
236 | + /* These rdahi/rdalo/rm cases are UNPREDICTABLE; we choose to UNDEF */ | ||
237 | + unallocated_encoding(s); | ||
238 | + return true; | ||
239 | + } | 85 | + } |
240 | + | ||
241 | + rda = tcg_temp_new_i64(); | ||
242 | + rdalo = load_reg(s, a->rdalo); | ||
243 | + rdahi = load_reg(s, a->rdahi); | ||
244 | + tcg_gen_concat_i32_i64(rda, rdalo, rdahi); | ||
245 | + | ||
246 | + /* The helper takes care of the sign-extension of the low 8 bits of Rm */ | ||
247 | + fn(rda, cpu_env, rda, cpu_R[a->rm]); | ||
248 | + | ||
249 | + tcg_gen_extrl_i64_i32(rdalo, rda); | ||
250 | + tcg_gen_extrh_i64_i32(rdahi, rda); | ||
251 | + store_reg(s, a->rdalo, rdalo); | ||
252 | + store_reg(s, a->rdahi, rdahi); | ||
253 | + tcg_temp_free_i64(rda); | ||
254 | + | ||
255 | + return true; | 86 | + return true; |
256 | +} | 87 | +} |
257 | + | 88 | + |
258 | +static bool trans_LSLL_rr(DisasContext *s, arg_mve_shl_rr *a) | ||
259 | +{ | ||
260 | + return do_mve_shl_rr(s, a, gen_helper_mve_ushll); | ||
261 | +} | ||
262 | + | ||
263 | +static bool trans_ASRL_rr(DisasContext *s, arg_mve_shl_rr *a) | ||
264 | +{ | ||
265 | + return do_mve_shl_rr(s, a, gen_helper_mve_sshrl); | ||
266 | +} | ||
267 | + | ||
268 | +static bool trans_UQRSHLL64_rr(DisasContext *s, arg_mve_shl_rr *a) | ||
269 | +{ | ||
270 | + return do_mve_shl_rr(s, a, gen_helper_mve_uqrshll); | ||
271 | +} | ||
272 | + | ||
273 | +static bool trans_SQRSHRL64_rr(DisasContext *s, arg_mve_shl_rr *a) | ||
274 | +{ | ||
275 | + return do_mve_shl_rr(s, a, gen_helper_mve_sqrshrl); | ||
276 | +} | ||
277 | + | ||
278 | +static bool trans_UQRSHLL48_rr(DisasContext *s, arg_mve_shl_rr *a) | ||
279 | +{ | ||
280 | + return do_mve_shl_rr(s, a, gen_helper_mve_uqrshll48); | ||
281 | +} | ||
282 | + | ||
283 | +static bool trans_SQRSHRL48_rr(DisasContext *s, arg_mve_shl_rr *a) | ||
284 | +{ | ||
285 | + return do_mve_shl_rr(s, a, gen_helper_mve_sqrshrl48); | ||
286 | +} | ||
287 | + | ||
288 | /* | 89 | /* |
289 | * Multiply and multiply accumulate | 90 | * This utility function is for doing register extension with an |
290 | */ | 91 | * optional shift. You will likely want to pass a temporary for the |
291 | -- | 92 | -- |
292 | 2.20.1 | 93 | 2.25.1 |
293 | |||
294 | diff view generated by jsdifflib |
1 | Use dup_const() instead of bitfield_replicate() in | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | disas_simd_mod_imm(). | ||
3 | 2 | ||
4 | (We can't replace the other use of bitfield_replicate() in this file, | 3 | The pseudocode for CheckSVEEnabled gains a check for Streaming |
5 | in logic_imm_decode_wmask(), because that location needs to handle 2 | 4 | SVE mode, and for SME present but SVE absent. |
6 | and 4 bit elements, which dup_const() cannot.) | ||
7 | 5 | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220708151540.18136-17-richard.henderson@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20210628135835.6690-6-peter.maydell@linaro.org | ||
11 | --- | 10 | --- |
12 | target/arm/translate-a64.c | 2 +- | 11 | target/arm/translate-a64.c | 22 ++++++++++++++++------ |
13 | 1 file changed, 1 insertion(+), 1 deletion(-) | 12 | 1 file changed, 16 insertions(+), 6 deletions(-) |
14 | 13 | ||
15 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 14 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
16 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate-a64.c | 16 | --- a/target/arm/translate-a64.c |
18 | +++ b/target/arm/translate-a64.c | 17 | +++ b/target/arm/translate-a64.c |
19 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_mod_imm(DisasContext *s, uint32_t insn) | 18 | @@ -XXX,XX +XXX,XX @@ static bool fp_access_check(DisasContext *s) |
20 | /* FMOV (vector, immediate) - half-precision */ | 19 | return true; |
21 | imm = vfp_expand_imm(MO_16, abcdefgh); | 20 | } |
22 | /* now duplicate across the lanes */ | 21 | |
23 | - imm = bitfield_replicate(imm, 16); | 22 | -/* Check that SVE access is enabled. If it is, return true. |
24 | + imm = dup_const(MO_16, imm); | 23 | +/* |
25 | } else { | 24 | + * Check that SVE access is enabled. If it is, return true. |
26 | imm = asimd_imm_const(abcdefgh, cmode, is_neg); | 25 | * If not, emit code to generate an appropriate exception and return false. |
26 | + * This function corresponds to CheckSVEEnabled(). | ||
27 | */ | ||
28 | bool sve_access_check(DisasContext *s) | ||
29 | { | ||
30 | - if (s->sve_excp_el) { | ||
31 | - assert(!s->sve_access_checked); | ||
32 | - s->sve_access_checked = true; | ||
33 | - | ||
34 | + if (s->pstate_sm || !dc_isar_feature(aa64_sve, s)) { | ||
35 | + assert(dc_isar_feature(aa64_sme, s)); | ||
36 | + if (!sme_sm_enabled_check(s)) { | ||
37 | + goto fail_exit; | ||
38 | + } | ||
39 | + } else if (s->sve_excp_el) { | ||
40 | gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF, | ||
41 | syn_sve_access_trap(), s->sve_excp_el); | ||
42 | - return false; | ||
43 | + goto fail_exit; | ||
27 | } | 44 | } |
45 | s->sve_access_checked = true; | ||
46 | return fp_access_check(s); | ||
47 | + | ||
48 | + fail_exit: | ||
49 | + /* Assert that we only raise one exception per instruction. */ | ||
50 | + assert(!s->sve_access_checked); | ||
51 | + s->sve_access_checked = true; | ||
52 | + return false; | ||
53 | } | ||
54 | |||
55 | /* | ||
28 | -- | 56 | -- |
29 | 2.20.1 | 57 | 2.25.1 |
30 | |||
31 | diff view generated by jsdifflib |
1 | Implement the MVE shifts by register, which perform | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | shifts on a single general-purpose register. | ||
3 | 2 | ||
3 | These SME instructions are nominally within the SVE decode space, | ||
4 | so we add them to sve.decode and translate-sve.c. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220708151540.18136-18-richard.henderson@linaro.org | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20210628135835.6690-19-peter.maydell@linaro.org | ||
7 | --- | 10 | --- |
8 | target/arm/helper-mve.h | 2 ++ | 11 | target/arm/translate-a64.h | 12 ++++++++++++ |
9 | target/arm/translate.h | 1 + | 12 | target/arm/sve.decode | 5 ++++- |
10 | target/arm/t32.decode | 18 ++++++++++++++---- | 13 | target/arm/translate-sve.c | 38 ++++++++++++++++++++++++++++++++++++++ |
11 | target/arm/mve_helper.c | 10 ++++++++++ | 14 | 3 files changed, 54 insertions(+), 1 deletion(-) |
12 | target/arm/translate.c | 30 ++++++++++++++++++++++++++++++ | ||
13 | 5 files changed, 57 insertions(+), 4 deletions(-) | ||
14 | 15 | ||
15 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 16 | diff --git a/target/arm/translate-a64.h b/target/arm/translate-a64.h |
16 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/helper-mve.h | 18 | --- a/target/arm/translate-a64.h |
18 | +++ b/target/arm/helper-mve.h | 19 | +++ b/target/arm/translate-a64.h |
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_uqrshll48, TCG_CALL_NO_RWG, i64, env, i64, i32) | 20 | @@ -XXX,XX +XXX,XX @@ static inline int vec_full_reg_size(DisasContext *s) |
20 | 21 | return s->vl; | |
21 | DEF_HELPER_FLAGS_3(mve_uqshl, TCG_CALL_NO_RWG, i32, env, i32, i32) | ||
22 | DEF_HELPER_FLAGS_3(mve_sqshl, TCG_CALL_NO_RWG, i32, env, i32, i32) | ||
23 | +DEF_HELPER_FLAGS_3(mve_uqrshl, TCG_CALL_NO_RWG, i32, env, i32, i32) | ||
24 | +DEF_HELPER_FLAGS_3(mve_sqrshr, TCG_CALL_NO_RWG, i32, env, i32, i32) | ||
25 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/target/arm/translate.h | ||
28 | +++ b/target/arm/translate.h | ||
29 | @@ -XXX,XX +XXX,XX @@ typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp); | ||
30 | typedef void WideShiftImmFn(TCGv_i64, TCGv_i64, int64_t shift); | ||
31 | typedef void WideShiftFn(TCGv_i64, TCGv_ptr, TCGv_i64, TCGv_i32); | ||
32 | typedef void ShiftImmFn(TCGv_i32, TCGv_i32, int32_t shift); | ||
33 | +typedef void ShiftFn(TCGv_i32, TCGv_ptr, TCGv_i32, TCGv_i32); | ||
34 | |||
35 | /** | ||
36 | * arm_tbflags_from_tb: | ||
37 | diff --git a/target/arm/t32.decode b/target/arm/t32.decode | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/target/arm/t32.decode | ||
40 | +++ b/target/arm/t32.decode | ||
41 | @@ -XXX,XX +XXX,XX @@ | ||
42 | &mve_shl_ri rdalo rdahi shim | ||
43 | &mve_shl_rr rdalo rdahi rm | ||
44 | &mve_sh_ri rda shim | ||
45 | +&mve_sh_rr rda rm | ||
46 | |||
47 | # rdahi: bits [3:1] from insn, bit 0 is 1 | ||
48 | # rdalo: bits [3:1] from insn, bit 0 is 0 | ||
49 | @@ -XXX,XX +XXX,XX @@ | ||
50 | &mve_shl_rr rdalo=%rdalo_17 rdahi=%rdahi_9 | ||
51 | @mve_sh_ri ....... .... . rda:4 . ... ... . .. .. .... \ | ||
52 | &mve_sh_ri shim=%imm5_12_6 | ||
53 | +@mve_sh_rr ....... .... . rda:4 rm:4 .... .... .... &mve_sh_rr | ||
54 | |||
55 | { | ||
56 | TST_xrri 1110101 0000 1 .... 0 ... 1111 .... .... @S_xrr_shi | ||
57 | @@ -XXX,XX +XXX,XX @@ BIC_rrri 1110101 0001 . .... 0 ... .... .... .... @s_rrr_shi | ||
58 | SQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 11 1111 @mve_shl_ri | ||
59 | } | ||
60 | |||
61 | - LSLL_rr 1110101 0010 1 ... 0 .... ... 1 0000 1101 @mve_shl_rr | ||
62 | - ASRL_rr 1110101 0010 1 ... 0 .... ... 1 0010 1101 @mve_shl_rr | ||
63 | - UQRSHLL64_rr 1110101 0010 1 ... 1 .... ... 1 0000 1101 @mve_shl_rr | ||
64 | - SQRSHRL64_rr 1110101 0010 1 ... 1 .... ... 1 0010 1101 @mve_shl_rr | ||
65 | + { | ||
66 | + UQRSHL_rr 1110101 0010 1 .... .... 1111 0000 1101 @mve_sh_rr | ||
67 | + LSLL_rr 1110101 0010 1 ... 0 .... ... 1 0000 1101 @mve_shl_rr | ||
68 | + UQRSHLL64_rr 1110101 0010 1 ... 1 .... ... 1 0000 1101 @mve_shl_rr | ||
69 | + } | ||
70 | + | ||
71 | + { | ||
72 | + SQRSHR_rr 1110101 0010 1 .... .... 1111 0010 1101 @mve_sh_rr | ||
73 | + ASRL_rr 1110101 0010 1 ... 0 .... ... 1 0010 1101 @mve_shl_rr | ||
74 | + SQRSHRL64_rr 1110101 0010 1 ... 1 .... ... 1 0010 1101 @mve_shl_rr | ||
75 | + } | ||
76 | + | ||
77 | UQRSHLL48_rr 1110101 0010 1 ... 1 .... ... 1 1000 1101 @mve_shl_rr | ||
78 | SQRSHRL48_rr 1110101 0010 1 ... 1 .... ... 1 1010 1101 @mve_shl_rr | ||
79 | ] | ||
80 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
81 | index XXXXXXX..XXXXXXX 100644 | ||
82 | --- a/target/arm/mve_helper.c | ||
83 | +++ b/target/arm/mve_helper.c | ||
84 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(mve_sqshl)(CPUARMState *env, uint32_t n, uint32_t shift) | ||
85 | { | ||
86 | return do_sqrshl_bhs(n, (int8_t)shift, 32, false, &env->QF); | ||
87 | } | 22 | } |
88 | + | 23 | |
89 | +uint32_t HELPER(mve_uqrshl)(CPUARMState *env, uint32_t n, uint32_t shift) | 24 | +/* Return the byte size of the vector register, SVL / 8. */ |
25 | +static inline int streaming_vec_reg_size(DisasContext *s) | ||
90 | +{ | 26 | +{ |
91 | + return do_uqrshl_bhs(n, (int8_t)shift, 32, true, &env->QF); | 27 | + return s->svl; |
92 | +} | 28 | +} |
93 | + | 29 | + |
94 | +uint32_t HELPER(mve_sqrshr)(CPUARMState *env, uint32_t n, uint32_t shift) | 30 | /* |
31 | * Return the offset info CPUARMState of the predicate vector register Pn. | ||
32 | * Note for this purpose, FFR is P16. | ||
33 | @@ -XXX,XX +XXX,XX @@ static inline int pred_full_reg_size(DisasContext *s) | ||
34 | return s->vl >> 3; | ||
35 | } | ||
36 | |||
37 | +/* Return the byte size of the predicate register, SVL / 64. */ | ||
38 | +static inline int streaming_pred_reg_size(DisasContext *s) | ||
95 | +{ | 39 | +{ |
96 | + return do_sqrshl_bhs(n, -(int8_t)shift, 32, true, &env->QF); | 40 | + return s->svl >> 3; |
97 | +} | 41 | +} |
98 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 42 | + |
43 | /* | ||
44 | * Round up the size of a register to a size allowed by | ||
45 | * the tcg vector infrastructure. Any operation which uses this | ||
46 | diff --git a/target/arm/sve.decode b/target/arm/sve.decode | ||
99 | index XXXXXXX..XXXXXXX 100644 | 47 | index XXXXXXX..XXXXXXX 100644 |
100 | --- a/target/arm/translate.c | 48 | --- a/target/arm/sve.decode |
101 | +++ b/target/arm/translate.c | 49 | +++ b/target/arm/sve.decode |
102 | @@ -XXX,XX +XXX,XX @@ static bool trans_UQSHL_ri(DisasContext *s, arg_mve_sh_ri *a) | 50 | @@ -XXX,XX +XXX,XX @@ INDEX_ri 00000100 esz:2 1 imm:s5 010001 rn:5 rd:5 |
103 | return do_mve_sh_ri(s, a, gen_mve_uqshl); | 51 | # SVE index generation (register start, register increment) |
52 | INDEX_rr 00000100 .. 1 ..... 010011 ..... ..... @rd_rn_rm | ||
53 | |||
54 | -### SVE Stack Allocation Group | ||
55 | +### SVE / Streaming SVE Stack Allocation Group | ||
56 | |||
57 | # SVE stack frame adjustment | ||
58 | ADDVL 00000100 001 ..... 01010 ...... ..... @rd_rn_i6 | ||
59 | +ADDSVL 00000100 001 ..... 01011 ...... ..... @rd_rn_i6 | ||
60 | ADDPL 00000100 011 ..... 01010 ...... ..... @rd_rn_i6 | ||
61 | +ADDSPL 00000100 011 ..... 01011 ...... ..... @rd_rn_i6 | ||
62 | |||
63 | # SVE stack frame size | ||
64 | RDVL 00000100 101 11111 01010 imm:s6 rd:5 | ||
65 | +RDSVL 00000100 101 11111 01011 imm:s6 rd:5 | ||
66 | |||
67 | ### SVE Bitwise Shift - Unpredicated Group | ||
68 | |||
69 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | ||
70 | index XXXXXXX..XXXXXXX 100644 | ||
71 | --- a/target/arm/translate-sve.c | ||
72 | +++ b/target/arm/translate-sve.c | ||
73 | @@ -XXX,XX +XXX,XX @@ static bool trans_ADDVL(DisasContext *s, arg_ADDVL *a) | ||
74 | return true; | ||
104 | } | 75 | } |
105 | 76 | ||
106 | +static bool do_mve_sh_rr(DisasContext *s, arg_mve_sh_rr *a, ShiftFn *fn) | 77 | +static bool trans_ADDSVL(DisasContext *s, arg_ADDSVL *a) |
107 | +{ | 78 | +{ |
108 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { | 79 | + if (!dc_isar_feature(aa64_sme, s)) { |
109 | + /* Decode falls through to ORR/MOV UNPREDICTABLE handling */ | ||
110 | + return false; | 80 | + return false; |
111 | + } | 81 | + } |
112 | + if (!dc_isar_feature(aa32_mve, s) || | 82 | + if (sme_enabled_check(s)) { |
113 | + !arm_dc_feature(s, ARM_FEATURE_M_MAIN) || | 83 | + TCGv_i64 rd = cpu_reg_sp(s, a->rd); |
114 | + a->rda == 13 || a->rda == 15 || a->rm == 13 || a->rm == 15 || | 84 | + TCGv_i64 rn = cpu_reg_sp(s, a->rn); |
115 | + a->rm == a->rda) { | 85 | + tcg_gen_addi_i64(rd, rn, a->imm * streaming_vec_reg_size(s)); |
116 | + /* These rda/rm cases are UNPREDICTABLE; we choose to UNDEF */ | ||
117 | + unallocated_encoding(s); | ||
118 | + return true; | ||
119 | + } | 86 | + } |
120 | + | ||
121 | + /* The helper takes care of the sign-extension of the low 8 bits of Rm */ | ||
122 | + fn(cpu_R[a->rda], cpu_env, cpu_R[a->rda], cpu_R[a->rm]); | ||
123 | + return true; | 87 | + return true; |
124 | +} | 88 | +} |
125 | + | 89 | + |
126 | +static bool trans_SQRSHR_rr(DisasContext *s, arg_mve_sh_rr *a) | 90 | static bool trans_ADDPL(DisasContext *s, arg_ADDPL *a) |
91 | { | ||
92 | if (!dc_isar_feature(aa64_sve, s)) { | ||
93 | @@ -XXX,XX +XXX,XX @@ static bool trans_ADDPL(DisasContext *s, arg_ADDPL *a) | ||
94 | return true; | ||
95 | } | ||
96 | |||
97 | +static bool trans_ADDSPL(DisasContext *s, arg_ADDSPL *a) | ||
127 | +{ | 98 | +{ |
128 | + return do_mve_sh_rr(s, a, gen_helper_mve_sqrshr); | 99 | + if (!dc_isar_feature(aa64_sme, s)) { |
100 | + return false; | ||
101 | + } | ||
102 | + if (sme_enabled_check(s)) { | ||
103 | + TCGv_i64 rd = cpu_reg_sp(s, a->rd); | ||
104 | + TCGv_i64 rn = cpu_reg_sp(s, a->rn); | ||
105 | + tcg_gen_addi_i64(rd, rn, a->imm * streaming_pred_reg_size(s)); | ||
106 | + } | ||
107 | + return true; | ||
129 | +} | 108 | +} |
130 | + | 109 | + |
131 | +static bool trans_UQRSHL_rr(DisasContext *s, arg_mve_sh_rr *a) | 110 | static bool trans_RDVL(DisasContext *s, arg_RDVL *a) |
111 | { | ||
112 | if (!dc_isar_feature(aa64_sve, s)) { | ||
113 | @@ -XXX,XX +XXX,XX @@ static bool trans_RDVL(DisasContext *s, arg_RDVL *a) | ||
114 | return true; | ||
115 | } | ||
116 | |||
117 | +static bool trans_RDSVL(DisasContext *s, arg_RDSVL *a) | ||
132 | +{ | 118 | +{ |
133 | + return do_mve_sh_rr(s, a, gen_helper_mve_uqrshl); | 119 | + if (!dc_isar_feature(aa64_sme, s)) { |
120 | + return false; | ||
121 | + } | ||
122 | + if (sme_enabled_check(s)) { | ||
123 | + TCGv_i64 reg = cpu_reg(s, a->rd); | ||
124 | + tcg_gen_movi_i64(reg, a->imm * streaming_vec_reg_size(s)); | ||
125 | + } | ||
126 | + return true; | ||
134 | +} | 127 | +} |
135 | + | 128 | + |
136 | /* | 129 | /* |
137 | * Multiply and multiply accumulate | 130 | *** SVE Compute Vector Address Group |
138 | */ | 131 | */ |
139 | -- | 132 | -- |
140 | 2.20.1 | 133 | 2.25.1 |
141 | |||
142 | diff view generated by jsdifflib |
1 | The initial implementation of the MVE VRMLALDAVH and VRMLSLDAVH | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | insns had some bugs: | ||
3 | * the 32x32 multiply of elements was being done as 32x32->32, | ||
4 | not 32x32->64 | ||
5 | * we were incorrectly maintaining the accumulator in its full | ||
6 | 72-bit form across all 4 beats of the insn; in the pseudocode | ||
7 | it is squashed back into the 64 bits of the RdaHi:RdaLo | ||
8 | registers after each beat | ||
9 | 2 | ||
10 | In particular, fixing the second of these allows us to recast | 3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | the implementation to avoid 128-bit arithmetic entirely. | 4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
5 | Message-id: 20220708151540.18136-19-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/helper-sme.h | 2 ++ | ||
9 | target/arm/sme.decode | 4 ++++ | ||
10 | target/arm/sme_helper.c | 25 +++++++++++++++++++++++++ | ||
11 | target/arm/translate-sme.c | 13 +++++++++++++ | ||
12 | 4 files changed, 44 insertions(+) | ||
12 | 13 | ||
13 | Since the element size here is always 4, we can also drop the | 14 | diff --git a/target/arm/helper-sme.h b/target/arm/helper-sme.h |
14 | parameterization of ESIZE to make the code a little more readable. | ||
15 | |||
16 | Suggested-by: Richard Henderson <richard.henderson@linaro.org> | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
18 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
19 | Message-id: 20210628135835.6690-3-peter.maydell@linaro.org | ||
20 | --- | ||
21 | target/arm/mve_helper.c | 38 +++++++++++++++++++++----------------- | ||
22 | 1 file changed, 21 insertions(+), 17 deletions(-) | ||
23 | |||
24 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/target/arm/mve_helper.c | 16 | --- a/target/arm/helper-sme.h |
27 | +++ b/target/arm/mve_helper.c | 17 | +++ b/target/arm/helper-sme.h |
18 | @@ -XXX,XX +XXX,XX @@ | ||
19 | |||
20 | DEF_HELPER_FLAGS_2(set_pstate_sm, TCG_CALL_NO_RWG, void, env, i32) | ||
21 | DEF_HELPER_FLAGS_2(set_pstate_za, TCG_CALL_NO_RWG, void, env, i32) | ||
22 | + | ||
23 | +DEF_HELPER_FLAGS_3(sme_zero, TCG_CALL_NO_RWG, void, env, i32, i32) | ||
24 | diff --git a/target/arm/sme.decode b/target/arm/sme.decode | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/target/arm/sme.decode | ||
27 | +++ b/target/arm/sme.decode | ||
28 | @@ -XXX,XX +XXX,XX @@ | ||
29 | # | ||
30 | # This file is processed by scripts/decodetree.py | ||
31 | # | ||
32 | + | ||
33 | +### SME Misc | ||
34 | + | ||
35 | +ZERO 11000000 00 001 00000000000 imm:8 | ||
36 | diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/target/arm/sme_helper.c | ||
39 | +++ b/target/arm/sme_helper.c | ||
40 | @@ -XXX,XX +XXX,XX @@ void helper_set_pstate_za(CPUARMState *env, uint32_t i) | ||
41 | memset(env->zarray, 0, sizeof(env->zarray)); | ||
42 | } | ||
43 | } | ||
44 | + | ||
45 | +void helper_sme_zero(CPUARMState *env, uint32_t imm, uint32_t svl) | ||
46 | +{ | ||
47 | + uint32_t i; | ||
48 | + | ||
49 | + /* | ||
50 | + * Special case clearing the entire ZA space. | ||
51 | + * This falls into the CONSTRAINED UNPREDICTABLE zeroing of any | ||
52 | + * parts of the ZA storage outside of SVL. | ||
53 | + */ | ||
54 | + if (imm == 0xff) { | ||
55 | + memset(env->zarray, 0, sizeof(env->zarray)); | ||
56 | + return; | ||
57 | + } | ||
58 | + | ||
59 | + /* | ||
60 | + * Recall that ZAnH.D[m] is spread across ZA[n+8*m], | ||
61 | + * so each row is discontiguous within ZA[]. | ||
62 | + */ | ||
63 | + for (i = 0; i < svl; i++) { | ||
64 | + if (imm & (1 << (i % 8))) { | ||
65 | + memset(&env->zarray[i], 0, svl); | ||
66 | + } | ||
67 | + } | ||
68 | +} | ||
69 | diff --git a/target/arm/translate-sme.c b/target/arm/translate-sme.c | ||
70 | index XXXXXXX..XXXXXXX 100644 | ||
71 | --- a/target/arm/translate-sme.c | ||
72 | +++ b/target/arm/translate-sme.c | ||
28 | @@ -XXX,XX +XXX,XX @@ | 73 | @@ -XXX,XX +XXX,XX @@ |
29 | */ | 74 | */ |
30 | 75 | ||
31 | #include "qemu/osdep.h" | 76 | #include "decode-sme.c.inc" |
32 | -#include "qemu/int128.h" | 77 | + |
33 | #include "cpu.h" | 78 | + |
34 | #include "internals.h" | 79 | +static bool trans_ZERO(DisasContext *s, arg_ZERO *a) |
35 | #include "vec_internal.h" | 80 | +{ |
36 | @@ -XXX,XX +XXX,XX @@ DO_LDAV(vmlsldavsw, 4, int32_t, false, +=, -=) | 81 | + if (!dc_isar_feature(aa64_sme, s)) { |
37 | DO_LDAV(vmlsldavxsw, 4, int32_t, true, +=, -=) | 82 | + return false; |
38 | 83 | + } | |
39 | /* | 84 | + if (sme_za_enabled_check(s)) { |
40 | - * Rounding multiply add long dual accumulate high: we must keep | 85 | + gen_helper_sme_zero(cpu_env, tcg_constant_i32(a->imm), |
41 | - * a 72-bit internal accumulator value and return the top 64 bits. | 86 | + tcg_constant_i32(streaming_vec_reg_size(s))); |
42 | + * Rounding multiply add long dual accumulate high. In the pseudocode | 87 | + } |
43 | + * this is implemented with a 72-bit internal accumulator value of which | 88 | + return true; |
44 | + * the top 64 bits are returned. We optimize this to avoid having to | 89 | +} |
45 | + * use 128-bit arithmetic -- we can do this because the 74-bit accumulator | ||
46 | + * is squashed back into 64-bits after each beat. | ||
47 | */ | ||
48 | -#define DO_LDAVH(OP, ESIZE, TYPE, XCHG, EVENACC, ODDACC, TO128) \ | ||
49 | +#define DO_LDAVH(OP, TYPE, LTYPE, XCHG, SUB) \ | ||
50 | uint64_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vn, \ | ||
51 | void *vm, uint64_t a) \ | ||
52 | { \ | ||
53 | uint16_t mask = mve_element_mask(env); \ | ||
54 | unsigned e; \ | ||
55 | TYPE *n = vn, *m = vm; \ | ||
56 | - Int128 acc = int128_lshift(TO128(a), 8); \ | ||
57 | - for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
58 | + for (e = 0; e < 16 / 4; e++, mask >>= 4) { \ | ||
59 | if (mask & 1) { \ | ||
60 | + LTYPE mul; \ | ||
61 | if (e & 1) { \ | ||
62 | - acc = ODDACC(acc, TO128(n[H##ESIZE(e - 1 * XCHG)] * \ | ||
63 | - m[H##ESIZE(e)])); \ | ||
64 | + mul = (LTYPE)n[H4(e - 1 * XCHG)] * m[H4(e)]; \ | ||
65 | + if (SUB) { \ | ||
66 | + mul = -mul; \ | ||
67 | + } \ | ||
68 | } else { \ | ||
69 | - acc = EVENACC(acc, TO128(n[H##ESIZE(e + 1 * XCHG)] * \ | ||
70 | - m[H##ESIZE(e)])); \ | ||
71 | + mul = (LTYPE)n[H4(e + 1 * XCHG)] * m[H4(e)]; \ | ||
72 | } \ | ||
73 | - acc = int128_add(acc, int128_make64(1 << 7)); \ | ||
74 | + mul = (mul >> 8) + ((mul >> 7) & 1); \ | ||
75 | + a += mul; \ | ||
76 | } \ | ||
77 | } \ | ||
78 | mve_advance_vpt(env); \ | ||
79 | - return int128_getlo(int128_rshift(acc, 8)); \ | ||
80 | + return a; \ | ||
81 | } | ||
82 | |||
83 | -DO_LDAVH(vrmlaldavhsw, 4, int32_t, false, int128_add, int128_add, int128_makes64) | ||
84 | -DO_LDAVH(vrmlaldavhxsw, 4, int32_t, true, int128_add, int128_add, int128_makes64) | ||
85 | +DO_LDAVH(vrmlaldavhsw, int32_t, int64_t, false, false) | ||
86 | +DO_LDAVH(vrmlaldavhxsw, int32_t, int64_t, true, false) | ||
87 | |||
88 | -DO_LDAVH(vrmlaldavhuw, 4, uint32_t, false, int128_add, int128_add, int128_make64) | ||
89 | +DO_LDAVH(vrmlaldavhuw, uint32_t, uint64_t, false, false) | ||
90 | |||
91 | -DO_LDAVH(vrmlsldavhsw, 4, int32_t, false, int128_add, int128_sub, int128_makes64) | ||
92 | -DO_LDAVH(vrmlsldavhxsw, 4, int32_t, true, int128_add, int128_sub, int128_makes64) | ||
93 | +DO_LDAVH(vrmlsldavhsw, int32_t, int64_t, false, true) | ||
94 | +DO_LDAVH(vrmlsldavhxsw, int32_t, int64_t, true, true) | ||
95 | |||
96 | /* Vector add across vector */ | ||
97 | #define DO_VADDV(OP, ESIZE, TYPE) \ | ||
98 | -- | 90 | -- |
99 | 2.20.1 | 91 | 2.25.1 |
100 | |||
101 | diff view generated by jsdifflib |
1 | Implement the MVE shifts by immediate, which perform shifts | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | on a single general-purpose register. | ||
3 | 2 | ||
4 | These patterns overlap with the long-shift-by-immediates, | 3 | We can reuse the SVE functions for implementing moves to/from |
5 | so we have to rearrange the grouping a little here. | 4 | horizontal tile slices, but we need new ones for moves to/from |
5 | vertical tile slices. | ||
6 | 6 | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20220708151540.18136-20-richard.henderson@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: 20210628135835.6690-18-peter.maydell@linaro.org | ||
10 | --- | 11 | --- |
11 | target/arm/helper-mve.h | 3 ++ | 12 | target/arm/helper-sme.h | 12 +++ |
12 | target/arm/translate.h | 1 + | 13 | target/arm/helper-sve.h | 2 + |
13 | target/arm/t32.decode | 31 ++++++++++++++----- | 14 | target/arm/translate-a64.h | 8 ++ |
14 | target/arm/mve_helper.c | 10 ++++++ | 15 | target/arm/translate.h | 5 ++ |
15 | target/arm/translate.c | 68 +++++++++++++++++++++++++++++++++++++++-- | 16 | target/arm/sme.decode | 15 ++++ |
16 | 5 files changed, 104 insertions(+), 9 deletions(-) | 17 | target/arm/sme_helper.c | 151 ++++++++++++++++++++++++++++++++++++- |
18 | target/arm/sve_helper.c | 12 +++ | ||
19 | target/arm/translate-sme.c | 127 +++++++++++++++++++++++++++++++ | ||
20 | 8 files changed, 331 insertions(+), 1 deletion(-) | ||
17 | 21 | ||
18 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 22 | diff --git a/target/arm/helper-sme.h b/target/arm/helper-sme.h |
19 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/helper-mve.h | 24 | --- a/target/arm/helper-sme.h |
21 | +++ b/target/arm/helper-mve.h | 25 | +++ b/target/arm/helper-sme.h |
22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_sqrshrl, TCG_CALL_NO_RWG, i64, env, i64, i32) | 26 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_2(set_pstate_sm, TCG_CALL_NO_RWG, void, env, i32) |
23 | DEF_HELPER_FLAGS_3(mve_uqrshll, TCG_CALL_NO_RWG, i64, env, i64, i32) | 27 | DEF_HELPER_FLAGS_2(set_pstate_za, TCG_CALL_NO_RWG, void, env, i32) |
24 | DEF_HELPER_FLAGS_3(mve_sqrshrl48, TCG_CALL_NO_RWG, i64, env, i64, i32) | 28 | |
25 | DEF_HELPER_FLAGS_3(mve_uqrshll48, TCG_CALL_NO_RWG, i64, env, i64, i32) | 29 | DEF_HELPER_FLAGS_3(sme_zero, TCG_CALL_NO_RWG, void, env, i32, i32) |
26 | + | 30 | + |
27 | +DEF_HELPER_FLAGS_3(mve_uqshl, TCG_CALL_NO_RWG, i32, env, i32, i32) | 31 | +/* Move to/from vertical array slices, i.e. columns, so 'c'. */ |
28 | +DEF_HELPER_FLAGS_3(mve_sqshl, TCG_CALL_NO_RWG, i32, env, i32, i32) | 32 | +DEF_HELPER_FLAGS_4(sme_mova_cz_b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) |
33 | +DEF_HELPER_FLAGS_4(sme_mova_zc_b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
34 | +DEF_HELPER_FLAGS_4(sme_mova_cz_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
35 | +DEF_HELPER_FLAGS_4(sme_mova_zc_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
36 | +DEF_HELPER_FLAGS_4(sme_mova_cz_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
37 | +DEF_HELPER_FLAGS_4(sme_mova_zc_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
38 | +DEF_HELPER_FLAGS_4(sme_mova_cz_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
39 | +DEF_HELPER_FLAGS_4(sme_mova_zc_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
40 | +DEF_HELPER_FLAGS_4(sme_mova_cz_q, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
41 | +DEF_HELPER_FLAGS_4(sme_mova_zc_q, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
42 | diff --git a/target/arm/helper-sve.h b/target/arm/helper-sve.h | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/target/arm/helper-sve.h | ||
45 | +++ b/target/arm/helper-sve.h | ||
46 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_5(sve_sel_zpzz_s, TCG_CALL_NO_RWG, | ||
47 | void, ptr, ptr, ptr, ptr, i32) | ||
48 | DEF_HELPER_FLAGS_5(sve_sel_zpzz_d, TCG_CALL_NO_RWG, | ||
49 | void, ptr, ptr, ptr, ptr, i32) | ||
50 | +DEF_HELPER_FLAGS_5(sve_sel_zpzz_q, TCG_CALL_NO_RWG, | ||
51 | + void, ptr, ptr, ptr, ptr, i32) | ||
52 | |||
53 | DEF_HELPER_FLAGS_5(sve2_addp_zpzz_b, TCG_CALL_NO_RWG, | ||
54 | void, ptr, ptr, ptr, ptr, i32) | ||
55 | diff --git a/target/arm/translate-a64.h b/target/arm/translate-a64.h | ||
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/target/arm/translate-a64.h | ||
58 | +++ b/target/arm/translate-a64.h | ||
59 | @@ -XXX,XX +XXX,XX @@ static inline int pred_gvec_reg_size(DisasContext *s) | ||
60 | return size_for_gvec(pred_full_reg_size(s)); | ||
61 | } | ||
62 | |||
63 | +/* Return a newly allocated pointer to the predicate register. */ | ||
64 | +static inline TCGv_ptr pred_full_reg_ptr(DisasContext *s, int regno) | ||
65 | +{ | ||
66 | + TCGv_ptr ret = tcg_temp_new_ptr(); | ||
67 | + tcg_gen_addi_ptr(ret, cpu_env, pred_full_reg_offset(s, regno)); | ||
68 | + return ret; | ||
69 | +} | ||
70 | + | ||
71 | bool disas_sve(DisasContext *, uint32_t); | ||
72 | bool disas_sme(DisasContext *, uint32_t); | ||
73 | |||
29 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 74 | diff --git a/target/arm/translate.h b/target/arm/translate.h |
30 | index XXXXXXX..XXXXXXX 100644 | 75 | index XXXXXXX..XXXXXXX 100644 |
31 | --- a/target/arm/translate.h | 76 | --- a/target/arm/translate.h |
32 | +++ b/target/arm/translate.h | 77 | +++ b/target/arm/translate.h |
33 | @@ -XXX,XX +XXX,XX @@ typedef void CryptoThreeOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | 78 | @@ -XXX,XX +XXX,XX @@ static inline int plus_2(DisasContext *s, int x) |
34 | typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp); | 79 | return x + 2; |
35 | typedef void WideShiftImmFn(TCGv_i64, TCGv_i64, int64_t shift); | 80 | } |
36 | typedef void WideShiftFn(TCGv_i64, TCGv_ptr, TCGv_i64, TCGv_i32); | 81 | |
37 | +typedef void ShiftImmFn(TCGv_i32, TCGv_i32, int32_t shift); | 82 | +static inline int plus_12(DisasContext *s, int x) |
38 | 83 | +{ | |
39 | /** | 84 | + return x + 12; |
40 | * arm_tbflags_from_tb: | 85 | +} |
41 | diff --git a/target/arm/t32.decode b/target/arm/t32.decode | 86 | + |
42 | index XXXXXXX..XXXXXXX 100644 | 87 | static inline int times_2(DisasContext *s, int x) |
43 | --- a/target/arm/t32.decode | 88 | { |
44 | +++ b/target/arm/t32.decode | 89 | return x * 2; |
90 | diff --git a/target/arm/sme.decode b/target/arm/sme.decode | ||
91 | index XXXXXXX..XXXXXXX 100644 | ||
92 | --- a/target/arm/sme.decode | ||
93 | +++ b/target/arm/sme.decode | ||
45 | @@ -XXX,XX +XXX,XX @@ | 94 | @@ -XXX,XX +XXX,XX @@ |
46 | 95 | ### SME Misc | |
47 | &mve_shl_ri rdalo rdahi shim | 96 | |
48 | &mve_shl_rr rdalo rdahi rm | 97 | ZERO 11000000 00 001 00000000000 imm:8 |
49 | +&mve_sh_ri rda shim | 98 | + |
50 | 99 | +### SME Move into/from Array | |
51 | # rdahi: bits [3:1] from insn, bit 0 is 1 | 100 | + |
52 | # rdalo: bits [3:1] from insn, bit 0 is 0 | 101 | +%mova_rs 13:2 !function=plus_12 |
102 | +&mova esz rs pg zr za_imm v:bool to_vec:bool | ||
103 | + | ||
104 | +MOVA 11000000 esz:2 00000 0 v:1 .. pg:3 zr:5 0 za_imm:4 \ | ||
105 | + &mova to_vec=0 rs=%mova_rs | ||
106 | +MOVA 11000000 11 00000 1 v:1 .. pg:3 zr:5 0 za_imm:4 \ | ||
107 | + &mova to_vec=0 rs=%mova_rs esz=4 | ||
108 | + | ||
109 | +MOVA 11000000 esz:2 00001 0 v:1 .. pg:3 0 za_imm:4 zr:5 \ | ||
110 | + &mova to_vec=1 rs=%mova_rs | ||
111 | +MOVA 11000000 11 00001 1 v:1 .. pg:3 0 za_imm:4 zr:5 \ | ||
112 | + &mova to_vec=1 rs=%mova_rs esz=4 | ||
113 | diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c | ||
114 | index XXXXXXX..XXXXXXX 100644 | ||
115 | --- a/target/arm/sme_helper.c | ||
116 | +++ b/target/arm/sme_helper.c | ||
53 | @@ -XXX,XX +XXX,XX @@ | 117 | @@ -XXX,XX +XXX,XX @@ |
54 | &mve_shl_ri shim=%imm5_12_6 rdalo=%rdalo_17 rdahi=%rdahi_9 | 118 | |
55 | @mve_shl_rr ....... .... . ... . rm:4 ... . .. .. .... \ | 119 | #include "qemu/osdep.h" |
56 | &mve_shl_rr rdalo=%rdalo_17 rdahi=%rdahi_9 | 120 | #include "cpu.h" |
57 | +@mve_sh_ri ....... .... . rda:4 . ... ... . .. .. .... \ | 121 | -#include "internals.h" |
58 | + &mve_sh_ri shim=%imm5_12_6 | 122 | +#include "tcg/tcg-gvec-desc.h" |
59 | 123 | #include "exec/helper-proto.h" | |
124 | +#include "qemu/int128.h" | ||
125 | +#include "vec_internal.h" | ||
126 | |||
127 | /* ResetSVEState */ | ||
128 | void arm_reset_sve_state(CPUARMState *env) | ||
129 | @@ -XXX,XX +XXX,XX @@ void helper_sme_zero(CPUARMState *env, uint32_t imm, uint32_t svl) | ||
130 | } | ||
131 | } | ||
132 | } | ||
133 | + | ||
134 | + | ||
135 | +/* | ||
136 | + * When considering the ZA storage as an array of elements of | ||
137 | + * type T, the index within that array of the Nth element of | ||
138 | + * a vertical slice of a tile can be calculated like this, | ||
139 | + * regardless of the size of type T. This is because the tiles | ||
140 | + * are interleaved, so if type T is size N bytes then row 1 of | ||
141 | + * the tile is N rows away from row 0. The division by N to | ||
142 | + * convert a byte offset into an array index and the multiplication | ||
143 | + * by N to convert from vslice-index-within-the-tile to | ||
144 | + * the index within the ZA storage cancel out. | ||
145 | + */ | ||
146 | +#define tile_vslice_index(i) ((i) * sizeof(ARMVectorReg)) | ||
147 | + | ||
148 | +/* | ||
149 | + * When doing byte arithmetic on the ZA storage, the element | ||
150 | + * byteoff bytes away in a tile vertical slice is always this | ||
151 | + * many bytes away in the ZA storage, regardless of the | ||
152 | + * size of the tile element, assuming that byteoff is a multiple | ||
153 | + * of the element size. Again this is because of the interleaving | ||
154 | + * of the tiles. For instance if we have 1 byte per element then | ||
155 | + * each row of the ZA storage has one byte of the vslice data, | ||
156 | + * and (counting from 0) byte 8 goes in row 8 of the storage | ||
157 | + * at offset (8 * row-size-in-bytes). | ||
158 | + * If we have 8 bytes per element then each row of the ZA storage | ||
159 | + * has 8 bytes of the data, but there are 8 interleaved tiles and | ||
160 | + * so byte 8 of the data goes into row 1 of the tile, | ||
161 | + * which is again row 8 of the storage, so the offset is still | ||
162 | + * (8 * row-size-in-bytes). Similarly for other element sizes. | ||
163 | + */ | ||
164 | +#define tile_vslice_offset(byteoff) ((byteoff) * sizeof(ARMVectorReg)) | ||
165 | + | ||
166 | + | ||
167 | +/* | ||
168 | + * Move Zreg vector to ZArray column. | ||
169 | + */ | ||
170 | +#define DO_MOVA_C(NAME, TYPE, H) \ | ||
171 | +void HELPER(NAME)(void *za, void *vn, void *vg, uint32_t desc) \ | ||
172 | +{ \ | ||
173 | + int i, oprsz = simd_oprsz(desc); \ | ||
174 | + for (i = 0; i < oprsz; ) { \ | ||
175 | + uint16_t pg = *(uint16_t *)(vg + H1_2(i >> 3)); \ | ||
176 | + do { \ | ||
177 | + if (pg & 1) { \ | ||
178 | + *(TYPE *)(za + tile_vslice_offset(i)) = *(TYPE *)(vn + H(i)); \ | ||
179 | + } \ | ||
180 | + i += sizeof(TYPE); \ | ||
181 | + pg >>= sizeof(TYPE); \ | ||
182 | + } while (i & 15); \ | ||
183 | + } \ | ||
184 | +} | ||
185 | + | ||
186 | +DO_MOVA_C(sme_mova_cz_b, uint8_t, H1) | ||
187 | +DO_MOVA_C(sme_mova_cz_h, uint16_t, H1_2) | ||
188 | +DO_MOVA_C(sme_mova_cz_s, uint32_t, H1_4) | ||
189 | + | ||
190 | +void HELPER(sme_mova_cz_d)(void *za, void *vn, void *vg, uint32_t desc) | ||
191 | +{ | ||
192 | + int i, oprsz = simd_oprsz(desc) / 8; | ||
193 | + uint8_t *pg = vg; | ||
194 | + uint64_t *n = vn; | ||
195 | + uint64_t *a = za; | ||
196 | + | ||
197 | + for (i = 0; i < oprsz; i++) { | ||
198 | + if (pg[H1(i)] & 1) { | ||
199 | + a[tile_vslice_index(i)] = n[i]; | ||
200 | + } | ||
201 | + } | ||
202 | +} | ||
203 | + | ||
204 | +void HELPER(sme_mova_cz_q)(void *za, void *vn, void *vg, uint32_t desc) | ||
205 | +{ | ||
206 | + int i, oprsz = simd_oprsz(desc) / 16; | ||
207 | + uint16_t *pg = vg; | ||
208 | + Int128 *n = vn; | ||
209 | + Int128 *a = za; | ||
210 | + | ||
211 | + /* | ||
212 | + * Int128 is used here simply to copy 16 bytes, and to simplify | ||
213 | + * the address arithmetic. | ||
214 | + */ | ||
215 | + for (i = 0; i < oprsz; i++) { | ||
216 | + if (pg[H2(i)] & 1) { | ||
217 | + a[tile_vslice_index(i)] = n[i]; | ||
218 | + } | ||
219 | + } | ||
220 | +} | ||
221 | + | ||
222 | +#undef DO_MOVA_C | ||
223 | + | ||
224 | +/* | ||
225 | + * Move ZArray column to Zreg vector. | ||
226 | + */ | ||
227 | +#define DO_MOVA_Z(NAME, TYPE, H) \ | ||
228 | +void HELPER(NAME)(void *vd, void *za, void *vg, uint32_t desc) \ | ||
229 | +{ \ | ||
230 | + int i, oprsz = simd_oprsz(desc); \ | ||
231 | + for (i = 0; i < oprsz; ) { \ | ||
232 | + uint16_t pg = *(uint16_t *)(vg + H1_2(i >> 3)); \ | ||
233 | + do { \ | ||
234 | + if (pg & 1) { \ | ||
235 | + *(TYPE *)(vd + H(i)) = *(TYPE *)(za + tile_vslice_offset(i)); \ | ||
236 | + } \ | ||
237 | + i += sizeof(TYPE); \ | ||
238 | + pg >>= sizeof(TYPE); \ | ||
239 | + } while (i & 15); \ | ||
240 | + } \ | ||
241 | +} | ||
242 | + | ||
243 | +DO_MOVA_Z(sme_mova_zc_b, uint8_t, H1) | ||
244 | +DO_MOVA_Z(sme_mova_zc_h, uint16_t, H1_2) | ||
245 | +DO_MOVA_Z(sme_mova_zc_s, uint32_t, H1_4) | ||
246 | + | ||
247 | +void HELPER(sme_mova_zc_d)(void *vd, void *za, void *vg, uint32_t desc) | ||
248 | +{ | ||
249 | + int i, oprsz = simd_oprsz(desc) / 8; | ||
250 | + uint8_t *pg = vg; | ||
251 | + uint64_t *d = vd; | ||
252 | + uint64_t *a = za; | ||
253 | + | ||
254 | + for (i = 0; i < oprsz; i++) { | ||
255 | + if (pg[H1(i)] & 1) { | ||
256 | + d[i] = a[tile_vslice_index(i)]; | ||
257 | + } | ||
258 | + } | ||
259 | +} | ||
260 | + | ||
261 | +void HELPER(sme_mova_zc_q)(void *vd, void *za, void *vg, uint32_t desc) | ||
262 | +{ | ||
263 | + int i, oprsz = simd_oprsz(desc) / 16; | ||
264 | + uint16_t *pg = vg; | ||
265 | + Int128 *d = vd; | ||
266 | + Int128 *a = za; | ||
267 | + | ||
268 | + /* | ||
269 | + * Int128 is used here simply to copy 16 bytes, and to simplify | ||
270 | + * the address arithmetic. | ||
271 | + */ | ||
272 | + for (i = 0; i < oprsz; i++, za += sizeof(ARMVectorReg)) { | ||
273 | + if (pg[H2(i)] & 1) { | ||
274 | + d[i] = a[tile_vslice_index(i)]; | ||
275 | + } | ||
276 | + } | ||
277 | +} | ||
278 | + | ||
279 | +#undef DO_MOVA_Z | ||
280 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | ||
281 | index XXXXXXX..XXXXXXX 100644 | ||
282 | --- a/target/arm/sve_helper.c | ||
283 | +++ b/target/arm/sve_helper.c | ||
284 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_sel_zpzz_d)(void *vd, void *vn, void *vm, | ||
285 | } | ||
286 | } | ||
287 | |||
288 | +void HELPER(sve_sel_zpzz_q)(void *vd, void *vn, void *vm, | ||
289 | + void *vg, uint32_t desc) | ||
290 | +{ | ||
291 | + intptr_t i, opr_sz = simd_oprsz(desc) / 16; | ||
292 | + Int128 *d = vd, *n = vn, *m = vm; | ||
293 | + uint16_t *pg = vg; | ||
294 | + | ||
295 | + for (i = 0; i < opr_sz; i += 1) { | ||
296 | + d[i] = (pg[H2(i)] & 1 ? n : m)[i]; | ||
297 | + } | ||
298 | +} | ||
299 | + | ||
300 | /* Two operand comparison controlled by a predicate. | ||
301 | * ??? It is very tempting to want to be able to expand this inline | ||
302 | * with x86 instructions, e.g. | ||
303 | diff --git a/target/arm/translate-sme.c b/target/arm/translate-sme.c | ||
304 | index XXXXXXX..XXXXXXX 100644 | ||
305 | --- a/target/arm/translate-sme.c | ||
306 | +++ b/target/arm/translate-sme.c | ||
307 | @@ -XXX,XX +XXX,XX @@ | ||
308 | #include "decode-sme.c.inc" | ||
309 | |||
310 | |||
311 | +/* | ||
312 | + * Resolve tile.size[index] to a host pointer, where tile and index | ||
313 | + * are always decoded together, dependent on the element size. | ||
314 | + */ | ||
315 | +static TCGv_ptr get_tile_rowcol(DisasContext *s, int esz, int rs, | ||
316 | + int tile_index, bool vertical) | ||
317 | +{ | ||
318 | + int tile = tile_index >> (4 - esz); | ||
319 | + int index = esz == MO_128 ? 0 : extract32(tile_index, 0, 4 - esz); | ||
320 | + int pos, len, offset; | ||
321 | + TCGv_i32 tmp; | ||
322 | + TCGv_ptr addr; | ||
323 | + | ||
324 | + /* Compute the final index, which is Rs+imm. */ | ||
325 | + tmp = tcg_temp_new_i32(); | ||
326 | + tcg_gen_trunc_tl_i32(tmp, cpu_reg(s, rs)); | ||
327 | + tcg_gen_addi_i32(tmp, tmp, index); | ||
328 | + | ||
329 | + /* Prepare a power-of-two modulo via extraction of @len bits. */ | ||
330 | + len = ctz32(streaming_vec_reg_size(s)) - esz; | ||
331 | + | ||
332 | + if (vertical) { | ||
333 | + /* | ||
334 | + * Compute the byte offset of the index within the tile: | ||
335 | + * (index % (svl / size)) * size | ||
336 | + * = (index % (svl >> esz)) << esz | ||
337 | + * Perform the power-of-two modulo via extraction of the low @len bits. | ||
338 | + * Perform the multiply by shifting left by @pos bits. | ||
339 | + * Perform these operations simultaneously via deposit into zero. | ||
340 | + */ | ||
341 | + pos = esz; | ||
342 | + tcg_gen_deposit_z_i32(tmp, tmp, pos, len); | ||
343 | + | ||
344 | + /* | ||
345 | + * For big-endian, adjust the indexed column byte offset within | ||
346 | + * the uint64_t host words that make up env->zarray[]. | ||
347 | + */ | ||
348 | + if (HOST_BIG_ENDIAN && esz < MO_64) { | ||
349 | + tcg_gen_xori_i32(tmp, tmp, 8 - (1 << esz)); | ||
350 | + } | ||
351 | + } else { | ||
352 | + /* | ||
353 | + * Compute the byte offset of the index within the tile: | ||
354 | + * (index % (svl / size)) * (size * sizeof(row)) | ||
355 | + * = (index % (svl >> esz)) << (esz + log2(sizeof(row))) | ||
356 | + */ | ||
357 | + pos = esz + ctz32(sizeof(ARMVectorReg)); | ||
358 | + tcg_gen_deposit_z_i32(tmp, tmp, pos, len); | ||
359 | + | ||
360 | + /* Row slices are always aligned and need no endian adjustment. */ | ||
361 | + } | ||
362 | + | ||
363 | + /* The tile byte offset within env->zarray is the row. */ | ||
364 | + offset = tile * sizeof(ARMVectorReg); | ||
365 | + | ||
366 | + /* Include the byte offset of zarray to make this relative to env. */ | ||
367 | + offset += offsetof(CPUARMState, zarray); | ||
368 | + tcg_gen_addi_i32(tmp, tmp, offset); | ||
369 | + | ||
370 | + /* Add the byte offset to env to produce the final pointer. */ | ||
371 | + addr = tcg_temp_new_ptr(); | ||
372 | + tcg_gen_ext_i32_ptr(addr, tmp); | ||
373 | + tcg_temp_free_i32(tmp); | ||
374 | + tcg_gen_add_ptr(addr, addr, cpu_env); | ||
375 | + | ||
376 | + return addr; | ||
377 | +} | ||
378 | + | ||
379 | static bool trans_ZERO(DisasContext *s, arg_ZERO *a) | ||
60 | { | 380 | { |
61 | TST_xrri 1110101 0000 1 .... 0 ... 1111 .... .... @S_xrr_shi | 381 | if (!dc_isar_feature(aa64_sme, s)) { |
62 | @@ -XXX,XX +XXX,XX @@ BIC_rrri 1110101 0001 . .... 0 ... .... .... .... @s_rrr_shi | 382 | @@ -XXX,XX +XXX,XX @@ static bool trans_ZERO(DisasContext *s, arg_ZERO *a) |
63 | # the rest fall through (where ORR_rrri and MOV_rxri will end up | 383 | } |
64 | # handling them as r13 and r15 accesses with the same semantics as A32). | 384 | return true; |
65 | [ | ||
66 | - LSLL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 00 1111 @mve_shl_ri | ||
67 | - LSRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 01 1111 @mve_shl_ri | ||
68 | - ASRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 10 1111 @mve_shl_ri | ||
69 | + { | ||
70 | + UQSHL_ri 1110101 0010 1 .... 0 ... 1111 .. 00 1111 @mve_sh_ri | ||
71 | + LSLL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 00 1111 @mve_shl_ri | ||
72 | + UQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 00 1111 @mve_shl_ri | ||
73 | + } | ||
74 | |||
75 | - UQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 00 1111 @mve_shl_ri | ||
76 | - URSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 01 1111 @mve_shl_ri | ||
77 | - SRSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 10 1111 @mve_shl_ri | ||
78 | - SQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 11 1111 @mve_shl_ri | ||
79 | + { | ||
80 | + URSHR_ri 1110101 0010 1 .... 0 ... 1111 .. 01 1111 @mve_sh_ri | ||
81 | + LSRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 01 1111 @mve_shl_ri | ||
82 | + URSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 01 1111 @mve_shl_ri | ||
83 | + } | ||
84 | + | ||
85 | + { | ||
86 | + SRSHR_ri 1110101 0010 1 .... 0 ... 1111 .. 10 1111 @mve_sh_ri | ||
87 | + ASRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 10 1111 @mve_shl_ri | ||
88 | + SRSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 10 1111 @mve_shl_ri | ||
89 | + } | ||
90 | + | ||
91 | + { | ||
92 | + SQSHL_ri 1110101 0010 1 .... 0 ... 1111 .. 11 1111 @mve_sh_ri | ||
93 | + SQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 11 1111 @mve_shl_ri | ||
94 | + } | ||
95 | |||
96 | LSLL_rr 1110101 0010 1 ... 0 .... ... 1 0000 1101 @mve_shl_rr | ||
97 | ASRL_rr 1110101 0010 1 ... 0 .... ... 1 0010 1101 @mve_shl_rr | ||
98 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
99 | index XXXXXXX..XXXXXXX 100644 | ||
100 | --- a/target/arm/mve_helper.c | ||
101 | +++ b/target/arm/mve_helper.c | ||
102 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(mve_uqrshll48)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
103 | { | ||
104 | return do_uqrshl48_d(n, (int8_t)shift, true, &env->QF); | ||
105 | } | 385 | } |
106 | + | 386 | + |
107 | +uint32_t HELPER(mve_uqshl)(CPUARMState *env, uint32_t n, uint32_t shift) | 387 | +static bool trans_MOVA(DisasContext *s, arg_MOVA *a) |
108 | +{ | 388 | +{ |
109 | + return do_uqrshl_bhs(n, (int8_t)shift, 32, false, &env->QF); | 389 | + static gen_helper_gvec_4 * const h_fns[5] = { |
110 | +} | 390 | + gen_helper_sve_sel_zpzz_b, gen_helper_sve_sel_zpzz_h, |
111 | + | 391 | + gen_helper_sve_sel_zpzz_s, gen_helper_sve_sel_zpzz_d, |
112 | +uint32_t HELPER(mve_sqshl)(CPUARMState *env, uint32_t n, uint32_t shift) | 392 | + gen_helper_sve_sel_zpzz_q |
113 | +{ | 393 | + }; |
114 | + return do_sqrshl_bhs(n, (int8_t)shift, 32, false, &env->QF); | 394 | + static gen_helper_gvec_3 * const cz_fns[5] = { |
115 | +} | 395 | + gen_helper_sme_mova_cz_b, gen_helper_sme_mova_cz_h, |
116 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 396 | + gen_helper_sme_mova_cz_s, gen_helper_sme_mova_cz_d, |
117 | index XXXXXXX..XXXXXXX 100644 | 397 | + gen_helper_sme_mova_cz_q, |
118 | --- a/target/arm/translate.c | 398 | + }; |
119 | +++ b/target/arm/translate.c | 399 | + static gen_helper_gvec_3 * const zc_fns[5] = { |
120 | @@ -XXX,XX +XXX,XX @@ static void gen_srshr16_i64(TCGv_i64 d, TCGv_i64 a, int64_t sh) | 400 | + gen_helper_sme_mova_zc_b, gen_helper_sme_mova_zc_h, |
121 | 401 | + gen_helper_sme_mova_zc_s, gen_helper_sme_mova_zc_d, | |
122 | static void gen_srshr32_i32(TCGv_i32 d, TCGv_i32 a, int32_t sh) | 402 | + gen_helper_sme_mova_zc_q, |
123 | { | 403 | + }; |
124 | - TCGv_i32 t = tcg_temp_new_i32(); | 404 | + |
125 | + TCGv_i32 t; | 405 | + TCGv_ptr t_za, t_zr, t_pg; |
126 | 406 | + TCGv_i32 t_desc; | |
127 | + /* Handle shift by the input size for the benefit of trans_SRSHR_ri */ | 407 | + int svl; |
128 | + if (sh == 32) { | 408 | + |
129 | + tcg_gen_movi_i32(d, 0); | 409 | + if (!dc_isar_feature(aa64_sme, s)) { |
130 | + return; | ||
131 | + } | ||
132 | + t = tcg_temp_new_i32(); | ||
133 | tcg_gen_extract_i32(t, a, sh - 1, 1); | ||
134 | tcg_gen_sari_i32(d, a, sh); | ||
135 | tcg_gen_add_i32(d, d, t); | ||
136 | @@ -XXX,XX +XXX,XX @@ static void gen_urshr16_i64(TCGv_i64 d, TCGv_i64 a, int64_t sh) | ||
137 | |||
138 | static void gen_urshr32_i32(TCGv_i32 d, TCGv_i32 a, int32_t sh) | ||
139 | { | ||
140 | - TCGv_i32 t = tcg_temp_new_i32(); | ||
141 | + TCGv_i32 t; | ||
142 | |||
143 | + /* Handle shift by the input size for the benefit of trans_URSHR_ri */ | ||
144 | + if (sh == 32) { | ||
145 | + tcg_gen_extract_i32(d, a, sh - 1, 1); | ||
146 | + return; | ||
147 | + } | ||
148 | + t = tcg_temp_new_i32(); | ||
149 | tcg_gen_extract_i32(t, a, sh - 1, 1); | ||
150 | tcg_gen_shri_i32(d, a, sh); | ||
151 | tcg_gen_add_i32(d, d, t); | ||
152 | @@ -XXX,XX +XXX,XX @@ static bool trans_SQRSHRL48_rr(DisasContext *s, arg_mve_shl_rr *a) | ||
153 | return do_mve_shl_rr(s, a, gen_helper_mve_sqrshrl48); | ||
154 | } | ||
155 | |||
156 | +static bool do_mve_sh_ri(DisasContext *s, arg_mve_sh_ri *a, ShiftImmFn *fn) | ||
157 | +{ | ||
158 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { | ||
159 | + /* Decode falls through to ORR/MOV UNPREDICTABLE handling */ | ||
160 | + return false; | 410 | + return false; |
161 | + } | 411 | + } |
162 | + if (!dc_isar_feature(aa32_mve, s) || | 412 | + if (!sme_smza_enabled_check(s)) { |
163 | + !arm_dc_feature(s, ARM_FEATURE_M_MAIN) || | ||
164 | + a->rda == 13 || a->rda == 15) { | ||
165 | + /* These rda cases are UNPREDICTABLE; we choose to UNDEF */ | ||
166 | + unallocated_encoding(s); | ||
167 | + return true; | 413 | + return true; |
168 | + } | 414 | + } |
169 | + | 415 | + |
170 | + if (a->shim == 0) { | 416 | + t_za = get_tile_rowcol(s, a->esz, a->rs, a->za_imm, a->v); |
171 | + a->shim = 32; | 417 | + t_zr = vec_full_reg_ptr(s, a->zr); |
172 | + } | 418 | + t_pg = pred_full_reg_ptr(s, a->pg); |
173 | + fn(cpu_R[a->rda], cpu_R[a->rda], a->shim); | 419 | + |
420 | + svl = streaming_vec_reg_size(s); | ||
421 | + t_desc = tcg_constant_i32(simd_desc(svl, svl, 0)); | ||
422 | + | ||
423 | + if (a->v) { | ||
424 | + /* Vertical slice -- use sme mova helpers. */ | ||
425 | + if (a->to_vec) { | ||
426 | + zc_fns[a->esz](t_zr, t_za, t_pg, t_desc); | ||
427 | + } else { | ||
428 | + cz_fns[a->esz](t_za, t_zr, t_pg, t_desc); | ||
429 | + } | ||
430 | + } else { | ||
431 | + /* Horizontal slice -- reuse sve sel helpers. */ | ||
432 | + if (a->to_vec) { | ||
433 | + h_fns[a->esz](t_zr, t_za, t_zr, t_pg, t_desc); | ||
434 | + } else { | ||
435 | + h_fns[a->esz](t_za, t_zr, t_za, t_pg, t_desc); | ||
436 | + } | ||
437 | + } | ||
438 | + | ||
439 | + tcg_temp_free_ptr(t_za); | ||
440 | + tcg_temp_free_ptr(t_zr); | ||
441 | + tcg_temp_free_ptr(t_pg); | ||
174 | + | 442 | + |
175 | + return true; | 443 | + return true; |
176 | +} | 444 | +} |
177 | + | ||
178 | +static bool trans_URSHR_ri(DisasContext *s, arg_mve_sh_ri *a) | ||
179 | +{ | ||
180 | + return do_mve_sh_ri(s, a, gen_urshr32_i32); | ||
181 | +} | ||
182 | + | ||
183 | +static bool trans_SRSHR_ri(DisasContext *s, arg_mve_sh_ri *a) | ||
184 | +{ | ||
185 | + return do_mve_sh_ri(s, a, gen_srshr32_i32); | ||
186 | +} | ||
187 | + | ||
188 | +static void gen_mve_sqshl(TCGv_i32 r, TCGv_i32 n, int32_t shift) | ||
189 | +{ | ||
190 | + gen_helper_mve_sqshl(r, cpu_env, n, tcg_constant_i32(shift)); | ||
191 | +} | ||
192 | + | ||
193 | +static bool trans_SQSHL_ri(DisasContext *s, arg_mve_sh_ri *a) | ||
194 | +{ | ||
195 | + return do_mve_sh_ri(s, a, gen_mve_sqshl); | ||
196 | +} | ||
197 | + | ||
198 | +static void gen_mve_uqshl(TCGv_i32 r, TCGv_i32 n, int32_t shift) | ||
199 | +{ | ||
200 | + gen_helper_mve_uqshl(r, cpu_env, n, tcg_constant_i32(shift)); | ||
201 | +} | ||
202 | + | ||
203 | +static bool trans_UQSHL_ri(DisasContext *s, arg_mve_sh_ri *a) | ||
204 | +{ | ||
205 | + return do_mve_sh_ri(s, a, gen_mve_uqshl); | ||
206 | +} | ||
207 | + | ||
208 | /* | ||
209 | * Multiply and multiply accumulate | ||
210 | */ | ||
211 | -- | 445 | -- |
212 | 2.20.1 | 446 | 2.25.1 |
213 | |||
214 | diff view generated by jsdifflib |
1 | Implement the MVE shift-vector-left-by-immediate insns VSHL, VQSHL | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | and VQSHLU. | ||
3 | 2 | ||
4 | The size-and-immediate encoding here is the same as Neon, and we | 3 | We cannot reuse the SVE functions for LD[1-4] and ST[1-4], |
5 | handle it the same way neon-dp.decode does. | 4 | because those functions accept only a Zreg register number. |
5 | For SME, we want to pass a pointer into ZA storage. | ||
6 | 6 | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20220708151540.18136-21-richard.henderson@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: 20210628135835.6690-8-peter.maydell@linaro.org | ||
10 | --- | 11 | --- |
11 | target/arm/helper-mve.h | 16 +++++++++++ | 12 | target/arm/helper-sme.h | 82 +++++ |
12 | target/arm/mve.decode | 23 +++++++++++++++ | 13 | target/arm/sme.decode | 9 + |
13 | target/arm/mve_helper.c | 57 ++++++++++++++++++++++++++++++++++++++ | 14 | target/arm/sme_helper.c | 595 +++++++++++++++++++++++++++++++++++++ |
14 | target/arm/translate-mve.c | 51 ++++++++++++++++++++++++++++++++++ | 15 | target/arm/translate-sme.c | 70 +++++ |
15 | 4 files changed, 147 insertions(+) | 16 | 4 files changed, 756 insertions(+) |
16 | 17 | ||
17 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 18 | diff --git a/target/arm/helper-sme.h b/target/arm/helper-sme.h |
18 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/helper-mve.h | 20 | --- a/target/arm/helper-sme.h |
20 | +++ b/target/arm/helper-mve.h | 21 | +++ b/target/arm/helper-sme.h |
21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vaddvuw, TCG_CALL_NO_WG, i32, env, ptr, i32) | 22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(sme_mova_cz_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) |
22 | DEF_HELPER_FLAGS_3(mve_vmovi, TCG_CALL_NO_WG, void, env, ptr, i64) | 23 | DEF_HELPER_FLAGS_4(sme_mova_zc_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) |
23 | DEF_HELPER_FLAGS_3(mve_vandi, TCG_CALL_NO_WG, void, env, ptr, i64) | 24 | DEF_HELPER_FLAGS_4(sme_mova_cz_q, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) |
24 | DEF_HELPER_FLAGS_3(mve_vorri, TCG_CALL_NO_WG, void, env, ptr, i64) | 25 | DEF_HELPER_FLAGS_4(sme_mova_zc_q, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) |
25 | + | 26 | + |
26 | +DEF_HELPER_FLAGS_4(mve_vshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 27 | +DEF_HELPER_FLAGS_5(sme_ld1b_h, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) |
27 | +DEF_HELPER_FLAGS_4(mve_vshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 28 | +DEF_HELPER_FLAGS_5(sme_ld1b_v, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) |
28 | +DEF_HELPER_FLAGS_4(mve_vshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 29 | +DEF_HELPER_FLAGS_5(sme_ld1b_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) |
29 | + | 30 | +DEF_HELPER_FLAGS_5(sme_ld1b_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) |
30 | +DEF_HELPER_FLAGS_4(mve_vqshli_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 31 | + |
31 | +DEF_HELPER_FLAGS_4(mve_vqshli_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 32 | +DEF_HELPER_FLAGS_5(sme_ld1h_be_h, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) |
32 | +DEF_HELPER_FLAGS_4(mve_vqshli_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 33 | +DEF_HELPER_FLAGS_5(sme_ld1h_le_h, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) |
33 | + | 34 | +DEF_HELPER_FLAGS_5(sme_ld1h_be_v, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) |
34 | +DEF_HELPER_FLAGS_4(mve_vqshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 35 | +DEF_HELPER_FLAGS_5(sme_ld1h_le_v, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) |
35 | +DEF_HELPER_FLAGS_4(mve_vqshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 36 | +DEF_HELPER_FLAGS_5(sme_ld1h_be_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) |
36 | +DEF_HELPER_FLAGS_4(mve_vqshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 37 | +DEF_HELPER_FLAGS_5(sme_ld1h_le_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) |
37 | + | 38 | +DEF_HELPER_FLAGS_5(sme_ld1h_be_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) |
38 | +DEF_HELPER_FLAGS_4(mve_vqshlui_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 39 | +DEF_HELPER_FLAGS_5(sme_ld1h_le_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) |
39 | +DEF_HELPER_FLAGS_4(mve_vqshlui_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 40 | + |
40 | +DEF_HELPER_FLAGS_4(mve_vqshlui_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 41 | +DEF_HELPER_FLAGS_5(sme_ld1s_be_h, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) |
41 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | 42 | +DEF_HELPER_FLAGS_5(sme_ld1s_le_h, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) |
43 | +DEF_HELPER_FLAGS_5(sme_ld1s_be_v, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
44 | +DEF_HELPER_FLAGS_5(sme_ld1s_le_v, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
45 | +DEF_HELPER_FLAGS_5(sme_ld1s_be_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
46 | +DEF_HELPER_FLAGS_5(sme_ld1s_le_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
47 | +DEF_HELPER_FLAGS_5(sme_ld1s_be_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
48 | +DEF_HELPER_FLAGS_5(sme_ld1s_le_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
49 | + | ||
50 | +DEF_HELPER_FLAGS_5(sme_ld1d_be_h, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
51 | +DEF_HELPER_FLAGS_5(sme_ld1d_le_h, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
52 | +DEF_HELPER_FLAGS_5(sme_ld1d_be_v, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
53 | +DEF_HELPER_FLAGS_5(sme_ld1d_le_v, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
54 | +DEF_HELPER_FLAGS_5(sme_ld1d_be_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
55 | +DEF_HELPER_FLAGS_5(sme_ld1d_le_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
56 | +DEF_HELPER_FLAGS_5(sme_ld1d_be_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
57 | +DEF_HELPER_FLAGS_5(sme_ld1d_le_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
58 | + | ||
59 | +DEF_HELPER_FLAGS_5(sme_ld1q_be_h, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
60 | +DEF_HELPER_FLAGS_5(sme_ld1q_le_h, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
61 | +DEF_HELPER_FLAGS_5(sme_ld1q_be_v, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
62 | +DEF_HELPER_FLAGS_5(sme_ld1q_le_v, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
63 | +DEF_HELPER_FLAGS_5(sme_ld1q_be_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
64 | +DEF_HELPER_FLAGS_5(sme_ld1q_le_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
65 | +DEF_HELPER_FLAGS_5(sme_ld1q_be_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
66 | +DEF_HELPER_FLAGS_5(sme_ld1q_le_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
67 | + | ||
68 | +DEF_HELPER_FLAGS_5(sme_st1b_h, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
69 | +DEF_HELPER_FLAGS_5(sme_st1b_v, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
70 | +DEF_HELPER_FLAGS_5(sme_st1b_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
71 | +DEF_HELPER_FLAGS_5(sme_st1b_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
72 | + | ||
73 | +DEF_HELPER_FLAGS_5(sme_st1h_be_h, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
74 | +DEF_HELPER_FLAGS_5(sme_st1h_le_h, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
75 | +DEF_HELPER_FLAGS_5(sme_st1h_be_v, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
76 | +DEF_HELPER_FLAGS_5(sme_st1h_le_v, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
77 | +DEF_HELPER_FLAGS_5(sme_st1h_be_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
78 | +DEF_HELPER_FLAGS_5(sme_st1h_le_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
79 | +DEF_HELPER_FLAGS_5(sme_st1h_be_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
80 | +DEF_HELPER_FLAGS_5(sme_st1h_le_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
81 | + | ||
82 | +DEF_HELPER_FLAGS_5(sme_st1s_be_h, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
83 | +DEF_HELPER_FLAGS_5(sme_st1s_le_h, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
84 | +DEF_HELPER_FLAGS_5(sme_st1s_be_v, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
85 | +DEF_HELPER_FLAGS_5(sme_st1s_le_v, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
86 | +DEF_HELPER_FLAGS_5(sme_st1s_be_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
87 | +DEF_HELPER_FLAGS_5(sme_st1s_le_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
88 | +DEF_HELPER_FLAGS_5(sme_st1s_be_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
89 | +DEF_HELPER_FLAGS_5(sme_st1s_le_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
90 | + | ||
91 | +DEF_HELPER_FLAGS_5(sme_st1d_be_h, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
92 | +DEF_HELPER_FLAGS_5(sme_st1d_le_h, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
93 | +DEF_HELPER_FLAGS_5(sme_st1d_be_v, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
94 | +DEF_HELPER_FLAGS_5(sme_st1d_le_v, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
95 | +DEF_HELPER_FLAGS_5(sme_st1d_be_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
96 | +DEF_HELPER_FLAGS_5(sme_st1d_le_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
97 | +DEF_HELPER_FLAGS_5(sme_st1d_be_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
98 | +DEF_HELPER_FLAGS_5(sme_st1d_le_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
99 | + | ||
100 | +DEF_HELPER_FLAGS_5(sme_st1q_be_h, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
101 | +DEF_HELPER_FLAGS_5(sme_st1q_le_h, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
102 | +DEF_HELPER_FLAGS_5(sme_st1q_be_v, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
103 | +DEF_HELPER_FLAGS_5(sme_st1q_le_v, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
104 | +DEF_HELPER_FLAGS_5(sme_st1q_be_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
105 | +DEF_HELPER_FLAGS_5(sme_st1q_le_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
106 | +DEF_HELPER_FLAGS_5(sme_st1q_be_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
107 | +DEF_HELPER_FLAGS_5(sme_st1q_le_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | ||
108 | diff --git a/target/arm/sme.decode b/target/arm/sme.decode | ||
42 | index XXXXXXX..XXXXXXX 100644 | 109 | index XXXXXXX..XXXXXXX 100644 |
43 | --- a/target/arm/mve.decode | 110 | --- a/target/arm/sme.decode |
44 | +++ b/target/arm/mve.decode | 111 | +++ b/target/arm/sme.decode |
112 | @@ -XXX,XX +XXX,XX @@ MOVA 11000000 esz:2 00001 0 v:1 .. pg:3 0 za_imm:4 zr:5 \ | ||
113 | &mova to_vec=1 rs=%mova_rs | ||
114 | MOVA 11000000 11 00001 1 v:1 .. pg:3 0 za_imm:4 zr:5 \ | ||
115 | &mova to_vec=1 rs=%mova_rs esz=4 | ||
116 | + | ||
117 | +### SME Memory | ||
118 | + | ||
119 | +&ldst esz rs pg rn rm za_imm v:bool st:bool | ||
120 | + | ||
121 | +LDST1 1110000 0 esz:2 st:1 rm:5 v:1 .. pg:3 rn:5 0 za_imm:4 \ | ||
122 | + &ldst rs=%mova_rs | ||
123 | +LDST1 1110000 111 st:1 rm:5 v:1 .. pg:3 rn:5 0 za_imm:4 \ | ||
124 | + &ldst esz=4 rs=%mova_rs | ||
125 | diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c | ||
126 | index XXXXXXX..XXXXXXX 100644 | ||
127 | --- a/target/arm/sme_helper.c | ||
128 | +++ b/target/arm/sme_helper.c | ||
45 | @@ -XXX,XX +XXX,XX @@ | 129 | @@ -XXX,XX +XXX,XX @@ |
46 | &2op qd qm qn size | 130 | |
47 | &2scalar qd qn rm size | 131 | #include "qemu/osdep.h" |
48 | &1imm qd imm cmode op | 132 | #include "cpu.h" |
49 | +&2shift qd qm shift size | 133 | +#include "internals.h" |
50 | 134 | #include "tcg/tcg-gvec-desc.h" | |
51 | @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 | 135 | #include "exec/helper-proto.h" |
52 | # Note that both Rn and Qd are 3 bits only (no D bit) | 136 | +#include "exec/cpu_ldst.h" |
53 | @@ -XXX,XX +XXX,XX @@ | 137 | +#include "exec/exec-all.h" |
54 | @2scalar .... .... .. size:2 .... .... .... .... rm:4 &2scalar qd=%qd qn=%qn | 138 | #include "qemu/int128.h" |
55 | @2scalar_nosz .... .... .... .... .... .... .... rm:4 &2scalar qd=%qd qn=%qn | 139 | #include "vec_internal.h" |
56 | 140 | +#include "sve_ldst_internal.h" | |
57 | +@2_shl_b .... .... .. 001 shift:3 .... .... .... .... &2shift qd=%qd qm=%qm size=0 | 141 | |
58 | +@2_shl_h .... .... .. 01 shift:4 .... .... .... .... &2shift qd=%qd qm=%qm size=1 | 142 | /* ResetSVEState */ |
59 | +@2_shl_w .... .... .. 1 shift:5 .... .... .... .... &2shift qd=%qd qm=%qm size=2 | 143 | void arm_reset_sve_state(CPUARMState *env) |
60 | + | 144 | @@ -XXX,XX +XXX,XX @@ void HELPER(sme_mova_zc_q)(void *vd, void *za, void *vg, uint32_t desc) |
61 | # Vector loads and stores | 145 | } |
62 | 146 | ||
63 | # Widening loads and narrowing stores: | 147 | #undef DO_MOVA_Z |
64 | @@ -XXX,XX +XXX,XX @@ VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13 | 148 | + |
65 | # So we have a single decode line and check the cmode/op in the | 149 | +/* |
66 | # trans function. | 150 | + * Clear elements in a tile slice comprising len bytes. |
67 | Vimm_1r 111 . 1111 1 . 00 0 ... ... 0 .... 0 1 . 1 .... @1imm | 151 | + */ |
68 | + | 152 | + |
69 | +# Shifts by immediate | 153 | +typedef void ClearFn(void *ptr, size_t off, size_t len); |
70 | + | 154 | + |
71 | +VSHLI 111 0 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_b | 155 | +static void clear_horizontal(void *ptr, size_t off, size_t len) |
72 | +VSHLI 111 0 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_h | 156 | +{ |
73 | +VSHLI 111 0 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_w | 157 | + memset(ptr + off, 0, len); |
74 | + | 158 | +} |
75 | +VQSHLI_S 111 0 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_b | 159 | + |
76 | +VQSHLI_S 111 0 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_h | 160 | +static void clear_vertical_b(void *vptr, size_t off, size_t len) |
77 | +VQSHLI_S 111 0 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_w | 161 | +{ |
78 | + | 162 | + for (size_t i = 0; i < len; ++i) { |
79 | +VQSHLI_U 111 1 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_b | 163 | + *(uint8_t *)(vptr + tile_vslice_offset(i + off)) = 0; |
80 | +VQSHLI_U 111 1 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_h | 164 | + } |
81 | +VQSHLI_U 111 1 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_w | 165 | +} |
82 | + | 166 | + |
83 | +VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_b | 167 | +static void clear_vertical_h(void *vptr, size_t off, size_t len) |
84 | +VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_h | 168 | +{ |
85 | +VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_w | 169 | + for (size_t i = 0; i < len; i += 2) { |
86 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | 170 | + *(uint16_t *)(vptr + tile_vslice_offset(i + off)) = 0; |
171 | + } | ||
172 | +} | ||
173 | + | ||
174 | +static void clear_vertical_s(void *vptr, size_t off, size_t len) | ||
175 | +{ | ||
176 | + for (size_t i = 0; i < len; i += 4) { | ||
177 | + *(uint32_t *)(vptr + tile_vslice_offset(i + off)) = 0; | ||
178 | + } | ||
179 | +} | ||
180 | + | ||
181 | +static void clear_vertical_d(void *vptr, size_t off, size_t len) | ||
182 | +{ | ||
183 | + for (size_t i = 0; i < len; i += 8) { | ||
184 | + *(uint64_t *)(vptr + tile_vslice_offset(i + off)) = 0; | ||
185 | + } | ||
186 | +} | ||
187 | + | ||
188 | +static void clear_vertical_q(void *vptr, size_t off, size_t len) | ||
189 | +{ | ||
190 | + for (size_t i = 0; i < len; i += 16) { | ||
191 | + memset(vptr + tile_vslice_offset(i + off), 0, 16); | ||
192 | + } | ||
193 | +} | ||
194 | + | ||
195 | +/* | ||
196 | + * Copy elements from an array into a tile slice comprising len bytes. | ||
197 | + */ | ||
198 | + | ||
199 | +typedef void CopyFn(void *dst, const void *src, size_t len); | ||
200 | + | ||
201 | +static void copy_horizontal(void *dst, const void *src, size_t len) | ||
202 | +{ | ||
203 | + memcpy(dst, src, len); | ||
204 | +} | ||
205 | + | ||
206 | +static void copy_vertical_b(void *vdst, const void *vsrc, size_t len) | ||
207 | +{ | ||
208 | + const uint8_t *src = vsrc; | ||
209 | + uint8_t *dst = vdst; | ||
210 | + size_t i; | ||
211 | + | ||
212 | + for (i = 0; i < len; ++i) { | ||
213 | + dst[tile_vslice_index(i)] = src[i]; | ||
214 | + } | ||
215 | +} | ||
216 | + | ||
217 | +static void copy_vertical_h(void *vdst, const void *vsrc, size_t len) | ||
218 | +{ | ||
219 | + const uint16_t *src = vsrc; | ||
220 | + uint16_t *dst = vdst; | ||
221 | + size_t i; | ||
222 | + | ||
223 | + for (i = 0; i < len / 2; ++i) { | ||
224 | + dst[tile_vslice_index(i)] = src[i]; | ||
225 | + } | ||
226 | +} | ||
227 | + | ||
228 | +static void copy_vertical_s(void *vdst, const void *vsrc, size_t len) | ||
229 | +{ | ||
230 | + const uint32_t *src = vsrc; | ||
231 | + uint32_t *dst = vdst; | ||
232 | + size_t i; | ||
233 | + | ||
234 | + for (i = 0; i < len / 4; ++i) { | ||
235 | + dst[tile_vslice_index(i)] = src[i]; | ||
236 | + } | ||
237 | +} | ||
238 | + | ||
239 | +static void copy_vertical_d(void *vdst, const void *vsrc, size_t len) | ||
240 | +{ | ||
241 | + const uint64_t *src = vsrc; | ||
242 | + uint64_t *dst = vdst; | ||
243 | + size_t i; | ||
244 | + | ||
245 | + for (i = 0; i < len / 8; ++i) { | ||
246 | + dst[tile_vslice_index(i)] = src[i]; | ||
247 | + } | ||
248 | +} | ||
249 | + | ||
250 | +static void copy_vertical_q(void *vdst, const void *vsrc, size_t len) | ||
251 | +{ | ||
252 | + for (size_t i = 0; i < len; i += 16) { | ||
253 | + memcpy(vdst + tile_vslice_offset(i), vsrc + i, 16); | ||
254 | + } | ||
255 | +} | ||
256 | + | ||
257 | +/* | ||
258 | + * Host and TLB primitives for vertical tile slice addressing. | ||
259 | + */ | ||
260 | + | ||
261 | +#define DO_LD(NAME, TYPE, HOST, TLB) \ | ||
262 | +static inline void sme_##NAME##_v_host(void *za, intptr_t off, void *host) \ | ||
263 | +{ \ | ||
264 | + TYPE val = HOST(host); \ | ||
265 | + *(TYPE *)(za + tile_vslice_offset(off)) = val; \ | ||
266 | +} \ | ||
267 | +static inline void sme_##NAME##_v_tlb(CPUARMState *env, void *za, \ | ||
268 | + intptr_t off, target_ulong addr, uintptr_t ra) \ | ||
269 | +{ \ | ||
270 | + TYPE val = TLB(env, useronly_clean_ptr(addr), ra); \ | ||
271 | + *(TYPE *)(za + tile_vslice_offset(off)) = val; \ | ||
272 | +} | ||
273 | + | ||
274 | +#define DO_ST(NAME, TYPE, HOST, TLB) \ | ||
275 | +static inline void sme_##NAME##_v_host(void *za, intptr_t off, void *host) \ | ||
276 | +{ \ | ||
277 | + TYPE val = *(TYPE *)(za + tile_vslice_offset(off)); \ | ||
278 | + HOST(host, val); \ | ||
279 | +} \ | ||
280 | +static inline void sme_##NAME##_v_tlb(CPUARMState *env, void *za, \ | ||
281 | + intptr_t off, target_ulong addr, uintptr_t ra) \ | ||
282 | +{ \ | ||
283 | + TYPE val = *(TYPE *)(za + tile_vslice_offset(off)); \ | ||
284 | + TLB(env, useronly_clean_ptr(addr), val, ra); \ | ||
285 | +} | ||
286 | + | ||
287 | +/* | ||
288 | + * The ARMVectorReg elements are stored in host-endian 64-bit units. | ||
289 | + * For 128-bit quantities, the sequence defined by the Elem[] pseudocode | ||
290 | + * corresponds to storing the two 64-bit pieces in little-endian order. | ||
291 | + */ | ||
292 | +#define DO_LDQ(HNAME, VNAME, BE, HOST, TLB) \ | ||
293 | +static inline void HNAME##_host(void *za, intptr_t off, void *host) \ | ||
294 | +{ \ | ||
295 | + uint64_t val0 = HOST(host), val1 = HOST(host + 8); \ | ||
296 | + uint64_t *ptr = za + off; \ | ||
297 | + ptr[0] = BE ? val1 : val0, ptr[1] = BE ? val0 : val1; \ | ||
298 | +} \ | ||
299 | +static inline void VNAME##_v_host(void *za, intptr_t off, void *host) \ | ||
300 | +{ \ | ||
301 | + HNAME##_host(za, tile_vslice_offset(off), host); \ | ||
302 | +} \ | ||
303 | +static inline void HNAME##_tlb(CPUARMState *env, void *za, intptr_t off, \ | ||
304 | + target_ulong addr, uintptr_t ra) \ | ||
305 | +{ \ | ||
306 | + uint64_t val0 = TLB(env, useronly_clean_ptr(addr), ra); \ | ||
307 | + uint64_t val1 = TLB(env, useronly_clean_ptr(addr + 8), ra); \ | ||
308 | + uint64_t *ptr = za + off; \ | ||
309 | + ptr[0] = BE ? val1 : val0, ptr[1] = BE ? val0 : val1; \ | ||
310 | +} \ | ||
311 | +static inline void VNAME##_v_tlb(CPUARMState *env, void *za, intptr_t off, \ | ||
312 | + target_ulong addr, uintptr_t ra) \ | ||
313 | +{ \ | ||
314 | + HNAME##_tlb(env, za, tile_vslice_offset(off), addr, ra); \ | ||
315 | +} | ||
316 | + | ||
317 | +#define DO_STQ(HNAME, VNAME, BE, HOST, TLB) \ | ||
318 | +static inline void HNAME##_host(void *za, intptr_t off, void *host) \ | ||
319 | +{ \ | ||
320 | + uint64_t *ptr = za + off; \ | ||
321 | + HOST(host, ptr[BE]); \ | ||
322 | + HOST(host + 1, ptr[!BE]); \ | ||
323 | +} \ | ||
324 | +static inline void VNAME##_v_host(void *za, intptr_t off, void *host) \ | ||
325 | +{ \ | ||
326 | + HNAME##_host(za, tile_vslice_offset(off), host); \ | ||
327 | +} \ | ||
328 | +static inline void HNAME##_tlb(CPUARMState *env, void *za, intptr_t off, \ | ||
329 | + target_ulong addr, uintptr_t ra) \ | ||
330 | +{ \ | ||
331 | + uint64_t *ptr = za + off; \ | ||
332 | + TLB(env, useronly_clean_ptr(addr), ptr[BE], ra); \ | ||
333 | + TLB(env, useronly_clean_ptr(addr + 8), ptr[!BE], ra); \ | ||
334 | +} \ | ||
335 | +static inline void VNAME##_v_tlb(CPUARMState *env, void *za, intptr_t off, \ | ||
336 | + target_ulong addr, uintptr_t ra) \ | ||
337 | +{ \ | ||
338 | + HNAME##_tlb(env, za, tile_vslice_offset(off), addr, ra); \ | ||
339 | +} | ||
340 | + | ||
341 | +DO_LD(ld1b, uint8_t, ldub_p, cpu_ldub_data_ra) | ||
342 | +DO_LD(ld1h_be, uint16_t, lduw_be_p, cpu_lduw_be_data_ra) | ||
343 | +DO_LD(ld1h_le, uint16_t, lduw_le_p, cpu_lduw_le_data_ra) | ||
344 | +DO_LD(ld1s_be, uint32_t, ldl_be_p, cpu_ldl_be_data_ra) | ||
345 | +DO_LD(ld1s_le, uint32_t, ldl_le_p, cpu_ldl_le_data_ra) | ||
346 | +DO_LD(ld1d_be, uint64_t, ldq_be_p, cpu_ldq_be_data_ra) | ||
347 | +DO_LD(ld1d_le, uint64_t, ldq_le_p, cpu_ldq_le_data_ra) | ||
348 | + | ||
349 | +DO_LDQ(sve_ld1qq_be, sme_ld1q_be, 1, ldq_be_p, cpu_ldq_be_data_ra) | ||
350 | +DO_LDQ(sve_ld1qq_le, sme_ld1q_le, 0, ldq_le_p, cpu_ldq_le_data_ra) | ||
351 | + | ||
352 | +DO_ST(st1b, uint8_t, stb_p, cpu_stb_data_ra) | ||
353 | +DO_ST(st1h_be, uint16_t, stw_be_p, cpu_stw_be_data_ra) | ||
354 | +DO_ST(st1h_le, uint16_t, stw_le_p, cpu_stw_le_data_ra) | ||
355 | +DO_ST(st1s_be, uint32_t, stl_be_p, cpu_stl_be_data_ra) | ||
356 | +DO_ST(st1s_le, uint32_t, stl_le_p, cpu_stl_le_data_ra) | ||
357 | +DO_ST(st1d_be, uint64_t, stq_be_p, cpu_stq_be_data_ra) | ||
358 | +DO_ST(st1d_le, uint64_t, stq_le_p, cpu_stq_le_data_ra) | ||
359 | + | ||
360 | +DO_STQ(sve_st1qq_be, sme_st1q_be, 1, stq_be_p, cpu_stq_be_data_ra) | ||
361 | +DO_STQ(sve_st1qq_le, sme_st1q_le, 0, stq_le_p, cpu_stq_le_data_ra) | ||
362 | + | ||
363 | +#undef DO_LD | ||
364 | +#undef DO_ST | ||
365 | +#undef DO_LDQ | ||
366 | +#undef DO_STQ | ||
367 | + | ||
368 | +/* | ||
369 | + * Common helper for all contiguous predicated loads. | ||
370 | + */ | ||
371 | + | ||
372 | +static inline QEMU_ALWAYS_INLINE | ||
373 | +void sme_ld1(CPUARMState *env, void *za, uint64_t *vg, | ||
374 | + const target_ulong addr, uint32_t desc, const uintptr_t ra, | ||
375 | + const int esz, uint32_t mtedesc, bool vertical, | ||
376 | + sve_ldst1_host_fn *host_fn, | ||
377 | + sve_ldst1_tlb_fn *tlb_fn, | ||
378 | + ClearFn *clr_fn, | ||
379 | + CopyFn *cpy_fn) | ||
380 | +{ | ||
381 | + const intptr_t reg_max = simd_oprsz(desc); | ||
382 | + const intptr_t esize = 1 << esz; | ||
383 | + intptr_t reg_off, reg_last; | ||
384 | + SVEContLdSt info; | ||
385 | + void *host; | ||
386 | + int flags; | ||
387 | + | ||
388 | + /* Find the active elements. */ | ||
389 | + if (!sve_cont_ldst_elements(&info, addr, vg, reg_max, esz, esize)) { | ||
390 | + /* The entire predicate was false; no load occurs. */ | ||
391 | + clr_fn(za, 0, reg_max); | ||
392 | + return; | ||
393 | + } | ||
394 | + | ||
395 | + /* Probe the page(s). Exit with exception for any invalid page. */ | ||
396 | + sve_cont_ldst_pages(&info, FAULT_ALL, env, addr, MMU_DATA_LOAD, ra); | ||
397 | + | ||
398 | + /* Handle watchpoints for all active elements. */ | ||
399 | + sve_cont_ldst_watchpoints(&info, env, vg, addr, esize, esize, | ||
400 | + BP_MEM_READ, ra); | ||
401 | + | ||
402 | + /* | ||
403 | + * Handle mte checks for all active elements. | ||
404 | + * Since TBI must be set for MTE, !mtedesc => !mte_active. | ||
405 | + */ | ||
406 | + if (mtedesc) { | ||
407 | + sve_cont_ldst_mte_check(&info, env, vg, addr, esize, esize, | ||
408 | + mtedesc, ra); | ||
409 | + } | ||
410 | + | ||
411 | + flags = info.page[0].flags | info.page[1].flags; | ||
412 | + if (unlikely(flags != 0)) { | ||
413 | +#ifdef CONFIG_USER_ONLY | ||
414 | + g_assert_not_reached(); | ||
415 | +#else | ||
416 | + /* | ||
417 | + * At least one page includes MMIO. | ||
418 | + * Any bus operation can fail with cpu_transaction_failed, | ||
419 | + * which for ARM will raise SyncExternal. Perform the load | ||
420 | + * into scratch memory to preserve register state until the end. | ||
421 | + */ | ||
422 | + ARMVectorReg scratch = { }; | ||
423 | + | ||
424 | + reg_off = info.reg_off_first[0]; | ||
425 | + reg_last = info.reg_off_last[1]; | ||
426 | + if (reg_last < 0) { | ||
427 | + reg_last = info.reg_off_split; | ||
428 | + if (reg_last < 0) { | ||
429 | + reg_last = info.reg_off_last[0]; | ||
430 | + } | ||
431 | + } | ||
432 | + | ||
433 | + do { | ||
434 | + uint64_t pg = vg[reg_off >> 6]; | ||
435 | + do { | ||
436 | + if ((pg >> (reg_off & 63)) & 1) { | ||
437 | + tlb_fn(env, &scratch, reg_off, addr + reg_off, ra); | ||
438 | + } | ||
439 | + reg_off += esize; | ||
440 | + } while (reg_off & 63); | ||
441 | + } while (reg_off <= reg_last); | ||
442 | + | ||
443 | + cpy_fn(za, &scratch, reg_max); | ||
444 | + return; | ||
445 | +#endif | ||
446 | + } | ||
447 | + | ||
448 | + /* The entire operation is in RAM, on valid pages. */ | ||
449 | + | ||
450 | + reg_off = info.reg_off_first[0]; | ||
451 | + reg_last = info.reg_off_last[0]; | ||
452 | + host = info.page[0].host; | ||
453 | + | ||
454 | + if (!vertical) { | ||
455 | + memset(za, 0, reg_max); | ||
456 | + } else if (reg_off) { | ||
457 | + clr_fn(za, 0, reg_off); | ||
458 | + } | ||
459 | + | ||
460 | + while (reg_off <= reg_last) { | ||
461 | + uint64_t pg = vg[reg_off >> 6]; | ||
462 | + do { | ||
463 | + if ((pg >> (reg_off & 63)) & 1) { | ||
464 | + host_fn(za, reg_off, host + reg_off); | ||
465 | + } else if (vertical) { | ||
466 | + clr_fn(za, reg_off, esize); | ||
467 | + } | ||
468 | + reg_off += esize; | ||
469 | + } while (reg_off <= reg_last && (reg_off & 63)); | ||
470 | + } | ||
471 | + | ||
472 | + /* | ||
473 | + * Use the slow path to manage the cross-page misalignment. | ||
474 | + * But we know this is RAM and cannot trap. | ||
475 | + */ | ||
476 | + reg_off = info.reg_off_split; | ||
477 | + if (unlikely(reg_off >= 0)) { | ||
478 | + tlb_fn(env, za, reg_off, addr + reg_off, ra); | ||
479 | + } | ||
480 | + | ||
481 | + reg_off = info.reg_off_first[1]; | ||
482 | + if (unlikely(reg_off >= 0)) { | ||
483 | + reg_last = info.reg_off_last[1]; | ||
484 | + host = info.page[1].host; | ||
485 | + | ||
486 | + do { | ||
487 | + uint64_t pg = vg[reg_off >> 6]; | ||
488 | + do { | ||
489 | + if ((pg >> (reg_off & 63)) & 1) { | ||
490 | + host_fn(za, reg_off, host + reg_off); | ||
491 | + } else if (vertical) { | ||
492 | + clr_fn(za, reg_off, esize); | ||
493 | + } | ||
494 | + reg_off += esize; | ||
495 | + } while (reg_off & 63); | ||
496 | + } while (reg_off <= reg_last); | ||
497 | + } | ||
498 | +} | ||
499 | + | ||
500 | +static inline QEMU_ALWAYS_INLINE | ||
501 | +void sme_ld1_mte(CPUARMState *env, void *za, uint64_t *vg, | ||
502 | + target_ulong addr, uint32_t desc, uintptr_t ra, | ||
503 | + const int esz, bool vertical, | ||
504 | + sve_ldst1_host_fn *host_fn, | ||
505 | + sve_ldst1_tlb_fn *tlb_fn, | ||
506 | + ClearFn *clr_fn, | ||
507 | + CopyFn *cpy_fn) | ||
508 | +{ | ||
509 | + uint32_t mtedesc = desc >> (SIMD_DATA_SHIFT + SVE_MTEDESC_SHIFT); | ||
510 | + int bit55 = extract64(addr, 55, 1); | ||
511 | + | ||
512 | + /* Remove mtedesc from the normal sve descriptor. */ | ||
513 | + desc = extract32(desc, 0, SIMD_DATA_SHIFT + SVE_MTEDESC_SHIFT); | ||
514 | + | ||
515 | + /* Perform gross MTE suppression early. */ | ||
516 | + if (!tbi_check(desc, bit55) || | ||
517 | + tcma_check(desc, bit55, allocation_tag_from_addr(addr))) { | ||
518 | + mtedesc = 0; | ||
519 | + } | ||
520 | + | ||
521 | + sme_ld1(env, za, vg, addr, desc, ra, esz, mtedesc, vertical, | ||
522 | + host_fn, tlb_fn, clr_fn, cpy_fn); | ||
523 | +} | ||
524 | + | ||
525 | +#define DO_LD(L, END, ESZ) \ | ||
526 | +void HELPER(sme_ld1##L##END##_h)(CPUARMState *env, void *za, void *vg, \ | ||
527 | + target_ulong addr, uint32_t desc) \ | ||
528 | +{ \ | ||
529 | + sme_ld1(env, za, vg, addr, desc, GETPC(), ESZ, 0, false, \ | ||
530 | + sve_ld1##L##L##END##_host, sve_ld1##L##L##END##_tlb, \ | ||
531 | + clear_horizontal, copy_horizontal); \ | ||
532 | +} \ | ||
533 | +void HELPER(sme_ld1##L##END##_v)(CPUARMState *env, void *za, void *vg, \ | ||
534 | + target_ulong addr, uint32_t desc) \ | ||
535 | +{ \ | ||
536 | + sme_ld1(env, za, vg, addr, desc, GETPC(), ESZ, 0, true, \ | ||
537 | + sme_ld1##L##END##_v_host, sme_ld1##L##END##_v_tlb, \ | ||
538 | + clear_vertical_##L, copy_vertical_##L); \ | ||
539 | +} \ | ||
540 | +void HELPER(sme_ld1##L##END##_h_mte)(CPUARMState *env, void *za, void *vg, \ | ||
541 | + target_ulong addr, uint32_t desc) \ | ||
542 | +{ \ | ||
543 | + sme_ld1_mte(env, za, vg, addr, desc, GETPC(), ESZ, false, \ | ||
544 | + sve_ld1##L##L##END##_host, sve_ld1##L##L##END##_tlb, \ | ||
545 | + clear_horizontal, copy_horizontal); \ | ||
546 | +} \ | ||
547 | +void HELPER(sme_ld1##L##END##_v_mte)(CPUARMState *env, void *za, void *vg, \ | ||
548 | + target_ulong addr, uint32_t desc) \ | ||
549 | +{ \ | ||
550 | + sme_ld1_mte(env, za, vg, addr, desc, GETPC(), ESZ, true, \ | ||
551 | + sme_ld1##L##END##_v_host, sme_ld1##L##END##_v_tlb, \ | ||
552 | + clear_vertical_##L, copy_vertical_##L); \ | ||
553 | +} | ||
554 | + | ||
555 | +DO_LD(b, , MO_8) | ||
556 | +DO_LD(h, _be, MO_16) | ||
557 | +DO_LD(h, _le, MO_16) | ||
558 | +DO_LD(s, _be, MO_32) | ||
559 | +DO_LD(s, _le, MO_32) | ||
560 | +DO_LD(d, _be, MO_64) | ||
561 | +DO_LD(d, _le, MO_64) | ||
562 | +DO_LD(q, _be, MO_128) | ||
563 | +DO_LD(q, _le, MO_128) | ||
564 | + | ||
565 | +#undef DO_LD | ||
566 | + | ||
567 | +/* | ||
568 | + * Common helper for all contiguous predicated stores. | ||
569 | + */ | ||
570 | + | ||
571 | +static inline QEMU_ALWAYS_INLINE | ||
572 | +void sme_st1(CPUARMState *env, void *za, uint64_t *vg, | ||
573 | + const target_ulong addr, uint32_t desc, const uintptr_t ra, | ||
574 | + const int esz, uint32_t mtedesc, bool vertical, | ||
575 | + sve_ldst1_host_fn *host_fn, | ||
576 | + sve_ldst1_tlb_fn *tlb_fn) | ||
577 | +{ | ||
578 | + const intptr_t reg_max = simd_oprsz(desc); | ||
579 | + const intptr_t esize = 1 << esz; | ||
580 | + intptr_t reg_off, reg_last; | ||
581 | + SVEContLdSt info; | ||
582 | + void *host; | ||
583 | + int flags; | ||
584 | + | ||
585 | + /* Find the active elements. */ | ||
586 | + if (!sve_cont_ldst_elements(&info, addr, vg, reg_max, esz, esize)) { | ||
587 | + /* The entire predicate was false; no store occurs. */ | ||
588 | + return; | ||
589 | + } | ||
590 | + | ||
591 | + /* Probe the page(s). Exit with exception for any invalid page. */ | ||
592 | + sve_cont_ldst_pages(&info, FAULT_ALL, env, addr, MMU_DATA_STORE, ra); | ||
593 | + | ||
594 | + /* Handle watchpoints for all active elements. */ | ||
595 | + sve_cont_ldst_watchpoints(&info, env, vg, addr, esize, esize, | ||
596 | + BP_MEM_WRITE, ra); | ||
597 | + | ||
598 | + /* | ||
599 | + * Handle mte checks for all active elements. | ||
600 | + * Since TBI must be set for MTE, !mtedesc => !mte_active. | ||
601 | + */ | ||
602 | + if (mtedesc) { | ||
603 | + sve_cont_ldst_mte_check(&info, env, vg, addr, esize, esize, | ||
604 | + mtedesc, ra); | ||
605 | + } | ||
606 | + | ||
607 | + flags = info.page[0].flags | info.page[1].flags; | ||
608 | + if (unlikely(flags != 0)) { | ||
609 | +#ifdef CONFIG_USER_ONLY | ||
610 | + g_assert_not_reached(); | ||
611 | +#else | ||
612 | + /* | ||
613 | + * At least one page includes MMIO. | ||
614 | + * Any bus operation can fail with cpu_transaction_failed, | ||
615 | + * which for ARM will raise SyncExternal. We cannot avoid | ||
616 | + * this fault and will leave with the store incomplete. | ||
617 | + */ | ||
618 | + reg_off = info.reg_off_first[0]; | ||
619 | + reg_last = info.reg_off_last[1]; | ||
620 | + if (reg_last < 0) { | ||
621 | + reg_last = info.reg_off_split; | ||
622 | + if (reg_last < 0) { | ||
623 | + reg_last = info.reg_off_last[0]; | ||
624 | + } | ||
625 | + } | ||
626 | + | ||
627 | + do { | ||
628 | + uint64_t pg = vg[reg_off >> 6]; | ||
629 | + do { | ||
630 | + if ((pg >> (reg_off & 63)) & 1) { | ||
631 | + tlb_fn(env, za, reg_off, addr + reg_off, ra); | ||
632 | + } | ||
633 | + reg_off += esize; | ||
634 | + } while (reg_off & 63); | ||
635 | + } while (reg_off <= reg_last); | ||
636 | + return; | ||
637 | +#endif | ||
638 | + } | ||
639 | + | ||
640 | + reg_off = info.reg_off_first[0]; | ||
641 | + reg_last = info.reg_off_last[0]; | ||
642 | + host = info.page[0].host; | ||
643 | + | ||
644 | + while (reg_off <= reg_last) { | ||
645 | + uint64_t pg = vg[reg_off >> 6]; | ||
646 | + do { | ||
647 | + if ((pg >> (reg_off & 63)) & 1) { | ||
648 | + host_fn(za, reg_off, host + reg_off); | ||
649 | + } | ||
650 | + reg_off += 1 << esz; | ||
651 | + } while (reg_off <= reg_last && (reg_off & 63)); | ||
652 | + } | ||
653 | + | ||
654 | + /* | ||
655 | + * Use the slow path to manage the cross-page misalignment. | ||
656 | + * But we know this is RAM and cannot trap. | ||
657 | + */ | ||
658 | + reg_off = info.reg_off_split; | ||
659 | + if (unlikely(reg_off >= 0)) { | ||
660 | + tlb_fn(env, za, reg_off, addr + reg_off, ra); | ||
661 | + } | ||
662 | + | ||
663 | + reg_off = info.reg_off_first[1]; | ||
664 | + if (unlikely(reg_off >= 0)) { | ||
665 | + reg_last = info.reg_off_last[1]; | ||
666 | + host = info.page[1].host; | ||
667 | + | ||
668 | + do { | ||
669 | + uint64_t pg = vg[reg_off >> 6]; | ||
670 | + do { | ||
671 | + if ((pg >> (reg_off & 63)) & 1) { | ||
672 | + host_fn(za, reg_off, host + reg_off); | ||
673 | + } | ||
674 | + reg_off += 1 << esz; | ||
675 | + } while (reg_off & 63); | ||
676 | + } while (reg_off <= reg_last); | ||
677 | + } | ||
678 | +} | ||
679 | + | ||
680 | +static inline QEMU_ALWAYS_INLINE | ||
681 | +void sme_st1_mte(CPUARMState *env, void *za, uint64_t *vg, target_ulong addr, | ||
682 | + uint32_t desc, uintptr_t ra, int esz, bool vertical, | ||
683 | + sve_ldst1_host_fn *host_fn, | ||
684 | + sve_ldst1_tlb_fn *tlb_fn) | ||
685 | +{ | ||
686 | + uint32_t mtedesc = desc >> (SIMD_DATA_SHIFT + SVE_MTEDESC_SHIFT); | ||
687 | + int bit55 = extract64(addr, 55, 1); | ||
688 | + | ||
689 | + /* Remove mtedesc from the normal sve descriptor. */ | ||
690 | + desc = extract32(desc, 0, SIMD_DATA_SHIFT + SVE_MTEDESC_SHIFT); | ||
691 | + | ||
692 | + /* Perform gross MTE suppression early. */ | ||
693 | + if (!tbi_check(desc, bit55) || | ||
694 | + tcma_check(desc, bit55, allocation_tag_from_addr(addr))) { | ||
695 | + mtedesc = 0; | ||
696 | + } | ||
697 | + | ||
698 | + sme_st1(env, za, vg, addr, desc, ra, esz, mtedesc, | ||
699 | + vertical, host_fn, tlb_fn); | ||
700 | +} | ||
701 | + | ||
702 | +#define DO_ST(L, END, ESZ) \ | ||
703 | +void HELPER(sme_st1##L##END##_h)(CPUARMState *env, void *za, void *vg, \ | ||
704 | + target_ulong addr, uint32_t desc) \ | ||
705 | +{ \ | ||
706 | + sme_st1(env, za, vg, addr, desc, GETPC(), ESZ, 0, false, \ | ||
707 | + sve_st1##L##L##END##_host, sve_st1##L##L##END##_tlb); \ | ||
708 | +} \ | ||
709 | +void HELPER(sme_st1##L##END##_v)(CPUARMState *env, void *za, void *vg, \ | ||
710 | + target_ulong addr, uint32_t desc) \ | ||
711 | +{ \ | ||
712 | + sme_st1(env, za, vg, addr, desc, GETPC(), ESZ, 0, true, \ | ||
713 | + sme_st1##L##END##_v_host, sme_st1##L##END##_v_tlb); \ | ||
714 | +} \ | ||
715 | +void HELPER(sme_st1##L##END##_h_mte)(CPUARMState *env, void *za, void *vg, \ | ||
716 | + target_ulong addr, uint32_t desc) \ | ||
717 | +{ \ | ||
718 | + sme_st1_mte(env, za, vg, addr, desc, GETPC(), ESZ, false, \ | ||
719 | + sve_st1##L##L##END##_host, sve_st1##L##L##END##_tlb); \ | ||
720 | +} \ | ||
721 | +void HELPER(sme_st1##L##END##_v_mte)(CPUARMState *env, void *za, void *vg, \ | ||
722 | + target_ulong addr, uint32_t desc) \ | ||
723 | +{ \ | ||
724 | + sme_st1_mte(env, za, vg, addr, desc, GETPC(), ESZ, true, \ | ||
725 | + sme_st1##L##END##_v_host, sme_st1##L##END##_v_tlb); \ | ||
726 | +} | ||
727 | + | ||
728 | +DO_ST(b, , MO_8) | ||
729 | +DO_ST(h, _be, MO_16) | ||
730 | +DO_ST(h, _le, MO_16) | ||
731 | +DO_ST(s, _be, MO_32) | ||
732 | +DO_ST(s, _le, MO_32) | ||
733 | +DO_ST(d, _be, MO_64) | ||
734 | +DO_ST(d, _le, MO_64) | ||
735 | +DO_ST(q, _be, MO_128) | ||
736 | +DO_ST(q, _le, MO_128) | ||
737 | + | ||
738 | +#undef DO_ST | ||
739 | diff --git a/target/arm/translate-sme.c b/target/arm/translate-sme.c | ||
87 | index XXXXXXX..XXXXXXX 100644 | 740 | index XXXXXXX..XXXXXXX 100644 |
88 | --- a/target/arm/mve_helper.c | 741 | --- a/target/arm/translate-sme.c |
89 | +++ b/target/arm/mve_helper.c | 742 | +++ b/target/arm/translate-sme.c |
90 | @@ -XXX,XX +XXX,XX @@ DO_2OP_SAT(vqsubsw, 4, int32_t, DO_SQSUB_W) | 743 | @@ -XXX,XX +XXX,XX @@ static bool trans_MOVA(DisasContext *s, arg_MOVA *a) |
91 | WRAP_QRSHL_HELPER(do_sqrshl_bhs, N, M, true, satp) | 744 | |
92 | #define DO_UQRSHL_OP(N, M, satp) \ | 745 | return true; |
93 | WRAP_QRSHL_HELPER(do_uqrshl_bhs, N, M, true, satp) | ||
94 | +#define DO_SUQSHL_OP(N, M, satp) \ | ||
95 | + WRAP_QRSHL_HELPER(do_suqrshl_bhs, N, M, false, satp) | ||
96 | |||
97 | DO_2OP_SAT_S(vqshls, DO_SQSHL_OP) | ||
98 | DO_2OP_SAT_U(vqshlu, DO_UQSHL_OP) | ||
99 | @@ -XXX,XX +XXX,XX @@ DO_VADDV(vaddvsw, 4, uint32_t) | ||
100 | DO_VADDV(vaddvub, 1, uint8_t) | ||
101 | DO_VADDV(vaddvuh, 2, uint16_t) | ||
102 | DO_VADDV(vaddvuw, 4, uint32_t) | ||
103 | + | ||
104 | +/* Shifts by immediate */ | ||
105 | +#define DO_2SHIFT(OP, ESIZE, TYPE, FN) \ | ||
106 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ | ||
107 | + void *vm, uint32_t shift) \ | ||
108 | + { \ | ||
109 | + TYPE *d = vd, *m = vm; \ | ||
110 | + uint16_t mask = mve_element_mask(env); \ | ||
111 | + unsigned e; \ | ||
112 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
113 | + mergemask(&d[H##ESIZE(e)], \ | ||
114 | + FN(m[H##ESIZE(e)], shift), mask); \ | ||
115 | + } \ | ||
116 | + mve_advance_vpt(env); \ | ||
117 | + } | ||
118 | + | ||
119 | +#define DO_2SHIFT_SAT(OP, ESIZE, TYPE, FN) \ | ||
120 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ | ||
121 | + void *vm, uint32_t shift) \ | ||
122 | + { \ | ||
123 | + TYPE *d = vd, *m = vm; \ | ||
124 | + uint16_t mask = mve_element_mask(env); \ | ||
125 | + unsigned e; \ | ||
126 | + bool qc = false; \ | ||
127 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
128 | + bool sat = false; \ | ||
129 | + mergemask(&d[H##ESIZE(e)], \ | ||
130 | + FN(m[H##ESIZE(e)], shift, &sat), mask); \ | ||
131 | + qc |= sat & mask & 1; \ | ||
132 | + } \ | ||
133 | + if (qc) { \ | ||
134 | + env->vfp.qc[0] = qc; \ | ||
135 | + } \ | ||
136 | + mve_advance_vpt(env); \ | ||
137 | + } | ||
138 | + | ||
139 | +/* provide unsigned 2-op shift helpers for all sizes */ | ||
140 | +#define DO_2SHIFT_U(OP, FN) \ | ||
141 | + DO_2SHIFT(OP##b, 1, uint8_t, FN) \ | ||
142 | + DO_2SHIFT(OP##h, 2, uint16_t, FN) \ | ||
143 | + DO_2SHIFT(OP##w, 4, uint32_t, FN) | ||
144 | + | ||
145 | +#define DO_2SHIFT_SAT_U(OP, FN) \ | ||
146 | + DO_2SHIFT_SAT(OP##b, 1, uint8_t, FN) \ | ||
147 | + DO_2SHIFT_SAT(OP##h, 2, uint16_t, FN) \ | ||
148 | + DO_2SHIFT_SAT(OP##w, 4, uint32_t, FN) | ||
149 | +#define DO_2SHIFT_SAT_S(OP, FN) \ | ||
150 | + DO_2SHIFT_SAT(OP##b, 1, int8_t, FN) \ | ||
151 | + DO_2SHIFT_SAT(OP##h, 2, int16_t, FN) \ | ||
152 | + DO_2SHIFT_SAT(OP##w, 4, int32_t, FN) | ||
153 | + | ||
154 | +DO_2SHIFT_U(vshli_u, DO_VSHLU) | ||
155 | +DO_2SHIFT_SAT_U(vqshli_u, DO_UQSHL_OP) | ||
156 | +DO_2SHIFT_SAT_S(vqshli_s, DO_SQSHL_OP) | ||
157 | +DO_2SHIFT_SAT_S(vqshlui_s, DO_SUQSHL_OP) | ||
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 @@ typedef void MVEGenLdStFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
163 | typedef void MVEGenOneOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
164 | typedef void MVEGenTwoOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
165 | typedef void MVEGenTwoOpScalarFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
166 | +typedef void MVEGenTwoOpShiftFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
167 | typedef void MVEGenDualAccOpFn(TCGv_i64, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
168 | typedef void MVEGenVADDVFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
169 | typedef void MVEGenOneOpImmFn(TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
170 | @@ -XXX,XX +XXX,XX @@ static bool trans_Vimm_1r(DisasContext *s, arg_1imm *a) | ||
171 | } | ||
172 | return do_1imm(s, a, fn); | ||
173 | } | 746 | } |
174 | + | 747 | + |
175 | +static bool do_2shift(DisasContext *s, arg_2shift *a, MVEGenTwoOpShiftFn fn, | 748 | +static bool trans_LDST1(DisasContext *s, arg_LDST1 *a) |
176 | + bool negateshift) | 749 | +{ |
177 | +{ | 750 | + typedef void GenLdSt1(TCGv_env, TCGv_ptr, TCGv_ptr, TCGv, TCGv_i32); |
178 | + TCGv_ptr qd, qm; | 751 | + |
179 | + int shift = a->shift; | 752 | + /* |
180 | + | 753 | + * Indexed by [esz][be][v][mte][st], which is (except for load/store) |
181 | + if (!dc_isar_feature(aa32_mve, s) || | 754 | + * also the order in which the elements appear in the function names, |
182 | + !mve_check_qreg_bank(s, a->qd | a->qm) || | 755 | + * and so how we must concatenate the pieces. |
183 | + !fn) { | 756 | + */ |
757 | + | ||
758 | +#define FN_LS(F) { gen_helper_sme_ld1##F, gen_helper_sme_st1##F } | ||
759 | +#define FN_MTE(F) { FN_LS(F), FN_LS(F##_mte) } | ||
760 | +#define FN_HV(F) { FN_MTE(F##_h), FN_MTE(F##_v) } | ||
761 | +#define FN_END(L, B) { FN_HV(L), FN_HV(B) } | ||
762 | + | ||
763 | + static GenLdSt1 * const fns[5][2][2][2][2] = { | ||
764 | + FN_END(b, b), | ||
765 | + FN_END(h_le, h_be), | ||
766 | + FN_END(s_le, s_be), | ||
767 | + FN_END(d_le, d_be), | ||
768 | + FN_END(q_le, q_be), | ||
769 | + }; | ||
770 | + | ||
771 | +#undef FN_LS | ||
772 | +#undef FN_MTE | ||
773 | +#undef FN_HV | ||
774 | +#undef FN_END | ||
775 | + | ||
776 | + TCGv_ptr t_za, t_pg; | ||
777 | + TCGv_i64 addr; | ||
778 | + int svl, desc = 0; | ||
779 | + bool be = s->be_data == MO_BE; | ||
780 | + bool mte = s->mte_active[0]; | ||
781 | + | ||
782 | + if (!dc_isar_feature(aa64_sme, s)) { | ||
184 | + return false; | 783 | + return false; |
185 | + } | 784 | + } |
186 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | 785 | + if (!sme_smza_enabled_check(s)) { |
187 | + return true; | 786 | + return true; |
188 | + } | 787 | + } |
189 | + | 788 | + |
190 | + /* | 789 | + t_za = get_tile_rowcol(s, a->esz, a->rs, a->za_imm, a->v); |
191 | + * When we handle a right shift insn using a left-shift helper | 790 | + t_pg = pred_full_reg_ptr(s, a->pg); |
192 | + * which permits a negative shift count to indicate a right-shift, | 791 | + addr = tcg_temp_new_i64(); |
193 | + * we must negate the shift count. | 792 | + |
194 | + */ | 793 | + tcg_gen_shli_i64(addr, cpu_reg(s, a->rm), a->esz); |
195 | + if (negateshift) { | 794 | + tcg_gen_add_i64(addr, addr, cpu_reg_sp(s, a->rn)); |
196 | + shift = -shift; | 795 | + |
197 | + } | 796 | + if (mte) { |
198 | + | 797 | + desc = FIELD_DP32(desc, MTEDESC, MIDX, get_mem_index(s)); |
199 | + qd = mve_qreg_ptr(a->qd); | 798 | + desc = FIELD_DP32(desc, MTEDESC, TBI, s->tbid); |
200 | + qm = mve_qreg_ptr(a->qm); | 799 | + desc = FIELD_DP32(desc, MTEDESC, TCMA, s->tcma); |
201 | + fn(cpu_env, qd, qm, tcg_constant_i32(shift)); | 800 | + desc = FIELD_DP32(desc, MTEDESC, WRITE, a->st); |
202 | + tcg_temp_free_ptr(qd); | 801 | + desc = FIELD_DP32(desc, MTEDESC, SIZEM1, (1 << a->esz) - 1); |
203 | + tcg_temp_free_ptr(qm); | 802 | + desc <<= SVE_MTEDESC_SHIFT; |
204 | + mve_update_eci(s); | 803 | + } else { |
804 | + addr = clean_data_tbi(s, addr); | ||
805 | + } | ||
806 | + svl = streaming_vec_reg_size(s); | ||
807 | + desc = simd_desc(svl, svl, desc); | ||
808 | + | ||
809 | + fns[a->esz][be][a->v][mte][a->st](cpu_env, t_za, t_pg, addr, | ||
810 | + tcg_constant_i32(desc)); | ||
811 | + | ||
812 | + tcg_temp_free_ptr(t_za); | ||
813 | + tcg_temp_free_ptr(t_pg); | ||
814 | + tcg_temp_free_i64(addr); | ||
205 | + return true; | 815 | + return true; |
206 | +} | 816 | +} |
207 | + | ||
208 | +#define DO_2SHIFT(INSN, FN, NEGATESHIFT) \ | ||
209 | + static bool trans_##INSN(DisasContext *s, arg_2shift *a) \ | ||
210 | + { \ | ||
211 | + static MVEGenTwoOpShiftFn * const fns[] = { \ | ||
212 | + gen_helper_mve_##FN##b, \ | ||
213 | + gen_helper_mve_##FN##h, \ | ||
214 | + gen_helper_mve_##FN##w, \ | ||
215 | + NULL, \ | ||
216 | + }; \ | ||
217 | + return do_2shift(s, a, fns[a->size], NEGATESHIFT); \ | ||
218 | + } | ||
219 | + | ||
220 | +DO_2SHIFT(VSHLI, vshli_u, false) | ||
221 | +DO_2SHIFT(VQSHLI_S, vqshli_s, false) | ||
222 | +DO_2SHIFT(VQSHLI_U, vqshli_u, false) | ||
223 | +DO_2SHIFT(VQSHLUI, vqshlui_s, false) | ||
224 | -- | 817 | -- |
225 | 2.20.1 | 818 | 2.25.1 |
226 | |||
227 | diff view generated by jsdifflib |
1 | In do_ldst(), the calculation of the offset needs to be based on the | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | size of the memory access, not the size of the elements in the | ||
3 | vector. This meant we were getting it wrong for the widening and | ||
4 | narrowing variants of the various VLDR and VSTR insns. | ||
5 | 2 | ||
3 | Add a TCGv_ptr base argument, which will be cpu_env for SVE. | ||
4 | We will reuse this for SME save and restore array insns. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220708151540.18136-22-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210628135835.6690-2-peter.maydell@linaro.org | ||
9 | --- | 10 | --- |
10 | target/arm/translate-mve.c | 17 +++++++++-------- | 11 | target/arm/translate-a64.h | 3 +++ |
11 | 1 file changed, 9 insertions(+), 8 deletions(-) | 12 | target/arm/translate-sve.c | 48 ++++++++++++++++++++++++++++---------- |
13 | 2 files changed, 39 insertions(+), 12 deletions(-) | ||
12 | 14 | ||
13 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | 15 | diff --git a/target/arm/translate-a64.h b/target/arm/translate-a64.h |
14 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/translate-mve.c | 17 | --- a/target/arm/translate-a64.h |
16 | +++ b/target/arm/translate-mve.c | 18 | +++ b/target/arm/translate-a64.h |
17 | @@ -XXX,XX +XXX,XX @@ static bool mve_skip_first_beat(DisasContext *s) | 19 | @@ -XXX,XX +XXX,XX @@ void gen_gvec_xar(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs, |
20 | uint32_t rm_ofs, int64_t shift, | ||
21 | uint32_t opr_sz, uint32_t max_sz); | ||
22 | |||
23 | +void gen_sve_ldr(DisasContext *s, TCGv_ptr, int vofs, int len, int rn, int imm); | ||
24 | +void gen_sve_str(DisasContext *s, TCGv_ptr, int vofs, int len, int rn, int imm); | ||
25 | + | ||
26 | #endif /* TARGET_ARM_TRANSLATE_A64_H */ | ||
27 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/target/arm/translate-sve.c | ||
30 | +++ b/target/arm/translate-sve.c | ||
31 | @@ -XXX,XX +XXX,XX @@ TRANS_FEAT(UCVTF_dd, aa64_sve, gen_gvec_fpst_arg_zpz, | ||
32 | * The load should begin at the address Rn + IMM. | ||
33 | */ | ||
34 | |||
35 | -static void do_ldr(DisasContext *s, uint32_t vofs, int len, int rn, int imm) | ||
36 | +void gen_sve_ldr(DisasContext *s, TCGv_ptr base, int vofs, | ||
37 | + int len, int rn, int imm) | ||
38 | { | ||
39 | int len_align = QEMU_ALIGN_DOWN(len, 8); | ||
40 | int len_remain = len % 8; | ||
41 | @@ -XXX,XX +XXX,XX @@ static void do_ldr(DisasContext *s, uint32_t vofs, int len, int rn, int imm) | ||
42 | t0 = tcg_temp_new_i64(); | ||
43 | for (i = 0; i < len_align; i += 8) { | ||
44 | tcg_gen_qemu_ld_i64(t0, clean_addr, midx, MO_LEUQ); | ||
45 | - tcg_gen_st_i64(t0, cpu_env, vofs + i); | ||
46 | + tcg_gen_st_i64(t0, base, vofs + i); | ||
47 | tcg_gen_addi_i64(clean_addr, clean_addr, 8); | ||
48 | } | ||
49 | tcg_temp_free_i64(t0); | ||
50 | @@ -XXX,XX +XXX,XX @@ static void do_ldr(DisasContext *s, uint32_t vofs, int len, int rn, int imm) | ||
51 | clean_addr = new_tmp_a64_local(s); | ||
52 | tcg_gen_mov_i64(clean_addr, t0); | ||
53 | |||
54 | + if (base != cpu_env) { | ||
55 | + TCGv_ptr b = tcg_temp_local_new_ptr(); | ||
56 | + tcg_gen_mov_ptr(b, base); | ||
57 | + base = b; | ||
58 | + } | ||
59 | + | ||
60 | gen_set_label(loop); | ||
61 | |||
62 | t0 = tcg_temp_new_i64(); | ||
63 | @@ -XXX,XX +XXX,XX @@ static void do_ldr(DisasContext *s, uint32_t vofs, int len, int rn, int imm) | ||
64 | tcg_gen_addi_i64(clean_addr, clean_addr, 8); | ||
65 | |||
66 | tp = tcg_temp_new_ptr(); | ||
67 | - tcg_gen_add_ptr(tp, cpu_env, i); | ||
68 | + tcg_gen_add_ptr(tp, base, i); | ||
69 | tcg_gen_addi_ptr(i, i, 8); | ||
70 | tcg_gen_st_i64(t0, tp, vofs); | ||
71 | tcg_temp_free_ptr(tp); | ||
72 | @@ -XXX,XX +XXX,XX @@ static void do_ldr(DisasContext *s, uint32_t vofs, int len, int rn, int imm) | ||
73 | |||
74 | tcg_gen_brcondi_ptr(TCG_COND_LTU, i, len_align, loop); | ||
75 | tcg_temp_free_ptr(i); | ||
76 | + | ||
77 | + if (base != cpu_env) { | ||
78 | + tcg_temp_free_ptr(base); | ||
79 | + assert(len_remain == 0); | ||
80 | + } | ||
81 | } | ||
82 | |||
83 | /* | ||
84 | @@ -XXX,XX +XXX,XX @@ static void do_ldr(DisasContext *s, uint32_t vofs, int len, int rn, int imm) | ||
85 | default: | ||
86 | g_assert_not_reached(); | ||
87 | } | ||
88 | - tcg_gen_st_i64(t0, cpu_env, vofs + len_align); | ||
89 | + tcg_gen_st_i64(t0, base, vofs + len_align); | ||
90 | tcg_temp_free_i64(t0); | ||
18 | } | 91 | } |
19 | } | 92 | } |
20 | 93 | ||
21 | -static bool do_ldst(DisasContext *s, arg_VLDR_VSTR *a, MVEGenLdStFn *fn) | 94 | /* Similarly for stores. */ |
22 | +static bool do_ldst(DisasContext *s, arg_VLDR_VSTR *a, MVEGenLdStFn *fn, | 95 | -static void do_str(DisasContext *s, uint32_t vofs, int len, int rn, int imm) |
23 | + unsigned msize) | 96 | +void gen_sve_str(DisasContext *s, TCGv_ptr base, int vofs, |
97 | + int len, int rn, int imm) | ||
24 | { | 98 | { |
25 | TCGv_i32 addr; | 99 | int len_align = QEMU_ALIGN_DOWN(len, 8); |
26 | uint32_t offset; | 100 | int len_remain = len % 8; |
27 | @@ -XXX,XX +XXX,XX @@ static bool do_ldst(DisasContext *s, arg_VLDR_VSTR *a, MVEGenLdStFn *fn) | 101 | @@ -XXX,XX +XXX,XX @@ static void do_str(DisasContext *s, uint32_t vofs, int len, int rn, int imm) |
28 | return true; | 102 | |
103 | t0 = tcg_temp_new_i64(); | ||
104 | for (i = 0; i < len_align; i += 8) { | ||
105 | - tcg_gen_ld_i64(t0, cpu_env, vofs + i); | ||
106 | + tcg_gen_ld_i64(t0, base, vofs + i); | ||
107 | tcg_gen_qemu_st_i64(t0, clean_addr, midx, MO_LEUQ); | ||
108 | tcg_gen_addi_i64(clean_addr, clean_addr, 8); | ||
109 | } | ||
110 | @@ -XXX,XX +XXX,XX @@ static void do_str(DisasContext *s, uint32_t vofs, int len, int rn, int imm) | ||
111 | clean_addr = new_tmp_a64_local(s); | ||
112 | tcg_gen_mov_i64(clean_addr, t0); | ||
113 | |||
114 | + if (base != cpu_env) { | ||
115 | + TCGv_ptr b = tcg_temp_local_new_ptr(); | ||
116 | + tcg_gen_mov_ptr(b, base); | ||
117 | + base = b; | ||
118 | + } | ||
119 | + | ||
120 | gen_set_label(loop); | ||
121 | |||
122 | t0 = tcg_temp_new_i64(); | ||
123 | tp = tcg_temp_new_ptr(); | ||
124 | - tcg_gen_add_ptr(tp, cpu_env, i); | ||
125 | + tcg_gen_add_ptr(tp, base, i); | ||
126 | tcg_gen_ld_i64(t0, tp, vofs); | ||
127 | tcg_gen_addi_ptr(i, i, 8); | ||
128 | tcg_temp_free_ptr(tp); | ||
129 | @@ -XXX,XX +XXX,XX @@ static void do_str(DisasContext *s, uint32_t vofs, int len, int rn, int imm) | ||
130 | |||
131 | tcg_gen_brcondi_ptr(TCG_COND_LTU, i, len_align, loop); | ||
132 | tcg_temp_free_ptr(i); | ||
133 | + | ||
134 | + if (base != cpu_env) { | ||
135 | + tcg_temp_free_ptr(base); | ||
136 | + assert(len_remain == 0); | ||
137 | + } | ||
29 | } | 138 | } |
30 | 139 | ||
31 | - offset = a->imm << a->size; | 140 | /* Predicate register stores can be any multiple of 2. */ |
32 | + offset = a->imm << msize; | 141 | if (len_remain) { |
33 | if (!a->a) { | 142 | t0 = tcg_temp_new_i64(); |
34 | offset = -offset; | 143 | - tcg_gen_ld_i64(t0, cpu_env, vofs + len_align); |
144 | + tcg_gen_ld_i64(t0, base, vofs + len_align); | ||
145 | |||
146 | switch (len_remain) { | ||
147 | case 2: | ||
148 | @@ -XXX,XX +XXX,XX @@ static bool trans_LDR_zri(DisasContext *s, arg_rri *a) | ||
149 | if (sve_access_check(s)) { | ||
150 | int size = vec_full_reg_size(s); | ||
151 | int off = vec_full_reg_offset(s, a->rd); | ||
152 | - do_ldr(s, off, size, a->rn, a->imm * size); | ||
153 | + gen_sve_ldr(s, cpu_env, off, size, a->rn, a->imm * size); | ||
35 | } | 154 | } |
36 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR(DisasContext *s, arg_VLDR_VSTR *a) | 155 | return true; |
37 | { gen_helper_mve_vstrw, gen_helper_mve_vldrw }, | ||
38 | { NULL, NULL } | ||
39 | }; | ||
40 | - return do_ldst(s, a, ldstfns[a->size][a->l]); | ||
41 | + return do_ldst(s, a, ldstfns[a->size][a->l], a->size); | ||
42 | } | 156 | } |
43 | 157 | @@ -XXX,XX +XXX,XX @@ static bool trans_LDR_pri(DisasContext *s, arg_rri *a) | |
44 | -#define DO_VLDST_WIDE_NARROW(OP, SLD, ULD, ST) \ | 158 | if (sve_access_check(s)) { |
45 | +#define DO_VLDST_WIDE_NARROW(OP, SLD, ULD, ST, MSIZE) \ | 159 | int size = pred_full_reg_size(s); |
46 | static bool trans_##OP(DisasContext *s, arg_VLDR_VSTR *a) \ | 160 | int off = pred_full_reg_offset(s, a->rd); |
47 | { \ | 161 | - do_ldr(s, off, size, a->rn, a->imm * size); |
48 | static MVEGenLdStFn * const ldstfns[2][2] = { \ | 162 | + gen_sve_ldr(s, cpu_env, off, size, a->rn, a->imm * size); |
49 | { gen_helper_mve_##ST, gen_helper_mve_##SLD }, \ | ||
50 | { NULL, gen_helper_mve_##ULD }, \ | ||
51 | }; \ | ||
52 | - return do_ldst(s, a, ldstfns[a->u][a->l]); \ | ||
53 | + return do_ldst(s, a, ldstfns[a->u][a->l], MSIZE); \ | ||
54 | } | 163 | } |
55 | 164 | return true; | |
56 | -DO_VLDST_WIDE_NARROW(VLDSTB_H, vldrb_sh, vldrb_uh, vstrb_h) | 165 | } |
57 | -DO_VLDST_WIDE_NARROW(VLDSTB_W, vldrb_sw, vldrb_uw, vstrb_w) | 166 | @@ -XXX,XX +XXX,XX @@ static bool trans_STR_zri(DisasContext *s, arg_rri *a) |
58 | -DO_VLDST_WIDE_NARROW(VLDSTH_W, vldrh_sw, vldrh_uw, vstrh_w) | 167 | if (sve_access_check(s)) { |
59 | +DO_VLDST_WIDE_NARROW(VLDSTB_H, vldrb_sh, vldrb_uh, vstrb_h, MO_8) | 168 | int size = vec_full_reg_size(s); |
60 | +DO_VLDST_WIDE_NARROW(VLDSTB_W, vldrb_sw, vldrb_uw, vstrb_w, MO_8) | 169 | int off = vec_full_reg_offset(s, a->rd); |
61 | +DO_VLDST_WIDE_NARROW(VLDSTH_W, vldrh_sw, vldrh_uw, vstrh_w, MO_16) | 170 | - do_str(s, off, size, a->rn, a->imm * size); |
62 | 171 | + gen_sve_str(s, cpu_env, off, size, a->rn, a->imm * size); | |
63 | static bool trans_VDUP(DisasContext *s, arg_VDUP *a) | 172 | } |
64 | { | 173 | return true; |
174 | } | ||
175 | @@ -XXX,XX +XXX,XX @@ static bool trans_STR_pri(DisasContext *s, arg_rri *a) | ||
176 | if (sve_access_check(s)) { | ||
177 | int size = pred_full_reg_size(s); | ||
178 | int off = pred_full_reg_offset(s, a->rd); | ||
179 | - do_str(s, off, size, a->rn, a->imm * size); | ||
180 | + gen_sve_str(s, cpu_env, off, size, a->rn, a->imm * size); | ||
181 | } | ||
182 | return true; | ||
183 | } | ||
65 | -- | 184 | -- |
66 | 2.20.1 | 185 | 2.25.1 |
67 | |||
68 | diff view generated by jsdifflib |
1 | Implement the MVE logical-immediate insns (VMOV, VMVN, | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | VORR and VBIC). These have essentially the same encoding | ||
3 | as their Neon equivalents, and we implement the decode | ||
4 | in the same way. | ||
5 | 2 | ||
3 | We can reuse the SVE functions for LDR and STR, passing in the | ||
4 | base of the ZA vector and a zero offset. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220708151540.18136-23-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210628135835.6690-7-peter.maydell@linaro.org | ||
9 | --- | 10 | --- |
10 | target/arm/helper-mve.h | 4 +++ | 11 | target/arm/sme.decode | 7 +++++++ |
11 | target/arm/mve.decode | 17 +++++++++++++ | 12 | target/arm/translate-sme.c | 24 ++++++++++++++++++++++++ |
12 | target/arm/mve_helper.c | 24 ++++++++++++++++++ | 13 | 2 files changed, 31 insertions(+) |
13 | target/arm/translate-mve.c | 50 ++++++++++++++++++++++++++++++++++++++ | ||
14 | 4 files changed, 95 insertions(+) | ||
15 | 14 | ||
16 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 15 | diff --git a/target/arm/sme.decode b/target/arm/sme.decode |
17 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/helper-mve.h | 17 | --- a/target/arm/sme.decode |
19 | +++ b/target/arm/helper-mve.h | 18 | +++ b/target/arm/sme.decode |
20 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vaddvsh, TCG_CALL_NO_WG, i32, env, ptr, i32) | 19 | @@ -XXX,XX +XXX,XX @@ LDST1 1110000 0 esz:2 st:1 rm:5 v:1 .. pg:3 rn:5 0 za_imm:4 \ |
21 | DEF_HELPER_FLAGS_3(mve_vaddvuh, TCG_CALL_NO_WG, i32, env, ptr, i32) | 20 | &ldst rs=%mova_rs |
22 | DEF_HELPER_FLAGS_3(mve_vaddvsw, TCG_CALL_NO_WG, i32, env, ptr, i32) | 21 | LDST1 1110000 111 st:1 rm:5 v:1 .. pg:3 rn:5 0 za_imm:4 \ |
23 | DEF_HELPER_FLAGS_3(mve_vaddvuw, TCG_CALL_NO_WG, i32, env, ptr, i32) | 22 | &ldst esz=4 rs=%mova_rs |
24 | + | 23 | + |
25 | +DEF_HELPER_FLAGS_3(mve_vmovi, TCG_CALL_NO_WG, void, env, ptr, i64) | 24 | +&ldstr rv rn imm |
26 | +DEF_HELPER_FLAGS_3(mve_vandi, TCG_CALL_NO_WG, void, env, ptr, i64) | 25 | +@ldstr ....... ... . ...... .. ... rn:5 . imm:4 \ |
27 | +DEF_HELPER_FLAGS_3(mve_vorri, TCG_CALL_NO_WG, void, env, ptr, i64) | 26 | + &ldstr rv=%mova_rs |
28 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | 27 | + |
28 | +LDR 1110000 100 0 000000 .. 000 ..... 0 .... @ldstr | ||
29 | +STR 1110000 100 1 000000 .. 000 ..... 0 .... @ldstr | ||
30 | diff --git a/target/arm/translate-sme.c b/target/arm/translate-sme.c | ||
29 | index XXXXXXX..XXXXXXX 100644 | 31 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/target/arm/mve.decode | 32 | --- a/target/arm/translate-sme.c |
31 | +++ b/target/arm/mve.decode | 33 | +++ b/target/arm/translate-sme.c |
32 | @@ -XXX,XX +XXX,XX @@ | 34 | @@ -XXX,XX +XXX,XX @@ static bool trans_LDST1(DisasContext *s, arg_LDST1 *a) |
33 | # VQDMULL has size in bit 28: 0 for 16 bit, 1 for 32 bit | 35 | tcg_temp_free_i64(addr); |
34 | %size_28 28:1 !function=plus_1 | ||
35 | |||
36 | +# 1imm format immediate | ||
37 | +%imm_28_16_0 28:1 16:3 0:4 | ||
38 | + | ||
39 | &vldr_vstr rn qd imm p a w size l u | ||
40 | &1op qd qm size | ||
41 | &2op qd qm qn size | ||
42 | &2scalar qd qn rm size | ||
43 | +&1imm qd imm cmode op | ||
44 | |||
45 | @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 | ||
46 | # Note that both Rn and Qd are 3 bits only (no D bit) | ||
47 | @@ -XXX,XX +XXX,XX @@ | ||
48 | @2op_nosz .... .... .... .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn size=0 | ||
49 | @2op_sz28 .... .... .... .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn \ | ||
50 | size=%size_28 | ||
51 | +@1imm .... .... .... .... .... cmode:4 .. op:1 . .... &1imm qd=%qd imm=%imm_28_16_0 | ||
52 | |||
53 | # The _rev suffix indicates that Vn and Vm are reversed. This is | ||
54 | # the case for shifts. In the Arm ARM these insns are documented | ||
55 | @@ -XXX,XX +XXX,XX @@ VADDV 111 u:1 1110 1111 size:2 01 ... 0 1111 0 0 a:1 0 qm:3 0 rda=%rd | ||
56 | # Predicate operations | ||
57 | %mask_22_13 22:1 13:3 | ||
58 | VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13 | ||
59 | + | ||
60 | +# Logical immediate operations (1 reg and modified-immediate) | ||
61 | + | ||
62 | +# The cmode/op bits here decode VORR/VBIC/VMOV/VMVN, but | ||
63 | +# not in a way we can conveniently represent in decodetree without | ||
64 | +# a lot of repetition: | ||
65 | +# VORR: op=0, (cmode & 1) && cmode < 12 | ||
66 | +# VBIC: op=1, (cmode & 1) && cmode < 12 | ||
67 | +# VMOV: everything else | ||
68 | +# So we have a single decode line and check the cmode/op in the | ||
69 | +# trans function. | ||
70 | +Vimm_1r 111 . 1111 1 . 00 0 ... ... 0 .... 0 1 . 1 .... @1imm | ||
71 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
72 | index XXXXXXX..XXXXXXX 100644 | ||
73 | --- a/target/arm/mve_helper.c | ||
74 | +++ b/target/arm/mve_helper.c | ||
75 | @@ -XXX,XX +XXX,XX @@ DO_1OP(vnegw, 4, int32_t, DO_NEG) | ||
76 | DO_1OP(vfnegh, 8, uint64_t, DO_FNEGH) | ||
77 | DO_1OP(vfnegs, 8, uint64_t, DO_FNEGS) | ||
78 | |||
79 | +/* | ||
80 | + * 1 operand immediates: Vda is destination and possibly also one source. | ||
81 | + * All these insns work at 64-bit widths. | ||
82 | + */ | ||
83 | +#define DO_1OP_IMM(OP, FN) \ | ||
84 | + void HELPER(mve_##OP)(CPUARMState *env, void *vda, uint64_t imm) \ | ||
85 | + { \ | ||
86 | + uint64_t *da = vda; \ | ||
87 | + uint16_t mask = mve_element_mask(env); \ | ||
88 | + unsigned e; \ | ||
89 | + for (e = 0; e < 16 / 8; e++, mask >>= 8) { \ | ||
90 | + mergemask(&da[H8(e)], FN(da[H8(e)], imm), mask); \ | ||
91 | + } \ | ||
92 | + mve_advance_vpt(env); \ | ||
93 | + } | ||
94 | + | ||
95 | +#define DO_MOVI(N, I) (I) | ||
96 | +#define DO_ANDI(N, I) ((N) & (I)) | ||
97 | +#define DO_ORRI(N, I) ((N) | (I)) | ||
98 | + | ||
99 | +DO_1OP_IMM(vmovi, DO_MOVI) | ||
100 | +DO_1OP_IMM(vandi, DO_ANDI) | ||
101 | +DO_1OP_IMM(vorri, DO_ORRI) | ||
102 | + | ||
103 | #define DO_2OP(OP, ESIZE, TYPE, FN) \ | ||
104 | void HELPER(glue(mve_, OP))(CPUARMState *env, \ | ||
105 | void *vd, void *vn, void *vm) \ | ||
106 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
107 | index XXXXXXX..XXXXXXX 100644 | ||
108 | --- a/target/arm/translate-mve.c | ||
109 | +++ b/target/arm/translate-mve.c | ||
110 | @@ -XXX,XX +XXX,XX @@ typedef void MVEGenTwoOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
111 | typedef void MVEGenTwoOpScalarFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
112 | typedef void MVEGenDualAccOpFn(TCGv_i64, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
113 | typedef void MVEGenVADDVFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
114 | +typedef void MVEGenOneOpImmFn(TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
115 | |||
116 | /* Return the offset of a Qn register (same semantics as aa32_vfp_qreg()) */ | ||
117 | static inline long mve_qreg_offset(unsigned reg) | ||
118 | @@ -XXX,XX +XXX,XX @@ static bool trans_VADDV(DisasContext *s, arg_VADDV *a) | ||
119 | mve_update_eci(s); | ||
120 | return true; | 36 | return true; |
121 | } | 37 | } |
122 | + | 38 | + |
123 | +static bool do_1imm(DisasContext *s, arg_1imm *a, MVEGenOneOpImmFn *fn) | 39 | +typedef void GenLdStR(DisasContext *, TCGv_ptr, int, int, int, int); |
40 | + | ||
41 | +static bool do_ldst_r(DisasContext *s, arg_ldstr *a, GenLdStR *fn) | ||
124 | +{ | 42 | +{ |
125 | + TCGv_ptr qd; | 43 | + int svl = streaming_vec_reg_size(s); |
126 | + uint64_t imm; | 44 | + int imm = a->imm; |
45 | + TCGv_ptr base; | ||
127 | + | 46 | + |
128 | + if (!dc_isar_feature(aa32_mve, s) || | 47 | + if (!sme_za_enabled_check(s)) { |
129 | + !mve_check_qreg_bank(s, a->qd) || | ||
130 | + !fn) { | ||
131 | + return false; | ||
132 | + } | ||
133 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
134 | + return true; | 48 | + return true; |
135 | + } | 49 | + } |
136 | + | 50 | + |
137 | + imm = asimd_imm_const(a->imm, a->cmode, a->op); | 51 | + /* ZA[n] equates to ZA0H.B[n]. */ |
52 | + base = get_tile_rowcol(s, MO_8, a->rv, imm, false); | ||
138 | + | 53 | + |
139 | + qd = mve_qreg_ptr(a->qd); | 54 | + fn(s, base, 0, svl, a->rn, imm * svl); |
140 | + fn(cpu_env, qd, tcg_constant_i64(imm)); | 55 | + |
141 | + tcg_temp_free_ptr(qd); | 56 | + tcg_temp_free_ptr(base); |
142 | + mve_update_eci(s); | ||
143 | + return true; | 57 | + return true; |
144 | +} | 58 | +} |
145 | + | 59 | + |
146 | +static bool trans_Vimm_1r(DisasContext *s, arg_1imm *a) | 60 | +TRANS_FEAT(LDR, aa64_sme, do_ldst_r, a, gen_sve_ldr) |
147 | +{ | 61 | +TRANS_FEAT(STR, aa64_sme, do_ldst_r, a, gen_sve_str) |
148 | + /* Handle decode of cmode/op here between VORR/VBIC/VMOV */ | ||
149 | + MVEGenOneOpImmFn *fn; | ||
150 | + | ||
151 | + if ((a->cmode & 1) && a->cmode < 12) { | ||
152 | + if (a->op) { | ||
153 | + /* | ||
154 | + * For op=1, the immediate will be inverted by asimd_imm_const(), | ||
155 | + * so the VBIC becomes a logical AND operation. | ||
156 | + */ | ||
157 | + fn = gen_helper_mve_vandi; | ||
158 | + } else { | ||
159 | + fn = gen_helper_mve_vorri; | ||
160 | + } | ||
161 | + } else { | ||
162 | + /* There is one unallocated cmode/op combination in this space */ | ||
163 | + if (a->cmode == 15 && a->op == 1) { | ||
164 | + return false; | ||
165 | + } | ||
166 | + /* asimd_imm_const() sorts out VMVNI vs VMOVI for us */ | ||
167 | + fn = gen_helper_mve_vmovi; | ||
168 | + } | ||
169 | + return do_1imm(s, a, fn); | ||
170 | +} | ||
171 | -- | 62 | -- |
172 | 2.20.1 | 63 | 2.25.1 |
173 | |||
174 | diff view generated by jsdifflib |
1 | Implement the MVE vector shift right by immediate insns VSHRI and | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | VRSHRI. As with Neon, we implement these by using helper functions | ||
3 | which perform left shifts but allow negative shift counts to indicate | ||
4 | right shifts. | ||
5 | 2 | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20220708151540.18136-24-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210628135835.6690-9-peter.maydell@linaro.org | ||
9 | --- | 7 | --- |
10 | target/arm/helper-mve.h | 12 ++++++++++++ | 8 | target/arm/helper-sme.h | 5 +++ |
11 | target/arm/translate.h | 20 ++++++++++++++++++++ | 9 | target/arm/sme.decode | 11 +++++ |
12 | target/arm/mve.decode | 28 ++++++++++++++++++++++++++++ | 10 | target/arm/sme_helper.c | 90 ++++++++++++++++++++++++++++++++++++++ |
13 | target/arm/mve_helper.c | 7 +++++++ | 11 | target/arm/translate-sme.c | 31 +++++++++++++ |
14 | target/arm/translate-mve.c | 5 +++++ | 12 | 4 files changed, 137 insertions(+) |
15 | target/arm/translate-neon.c | 18 ------------------ | ||
16 | 6 files changed, 72 insertions(+), 18 deletions(-) | ||
17 | 13 | ||
18 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 14 | diff --git a/target/arm/helper-sme.h b/target/arm/helper-sme.h |
19 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/helper-mve.h | 16 | --- a/target/arm/helper-sme.h |
21 | +++ b/target/arm/helper-mve.h | 17 | +++ b/target/arm/helper-sme.h |
22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vmovi, TCG_CALL_NO_WG, void, env, ptr, i64) | 18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_5(sme_st1q_be_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i |
23 | DEF_HELPER_FLAGS_3(mve_vandi, TCG_CALL_NO_WG, void, env, ptr, i64) | 19 | DEF_HELPER_FLAGS_5(sme_st1q_le_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) |
24 | DEF_HELPER_FLAGS_3(mve_vorri, TCG_CALL_NO_WG, void, env, ptr, i64) | 20 | DEF_HELPER_FLAGS_5(sme_st1q_be_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) |
25 | 21 | DEF_HELPER_FLAGS_5(sme_st1q_le_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) | |
26 | +DEF_HELPER_FLAGS_4(mve_vshli_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
27 | +DEF_HELPER_FLAGS_4(mve_vshli_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
28 | +DEF_HELPER_FLAGS_4(mve_vshli_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
29 | + | 22 | + |
30 | DEF_HELPER_FLAGS_4(mve_vshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 23 | +DEF_HELPER_FLAGS_5(sme_addha_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) |
31 | DEF_HELPER_FLAGS_4(mve_vshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 24 | +DEF_HELPER_FLAGS_5(sme_addva_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) |
32 | DEF_HELPER_FLAGS_4(mve_vshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 25 | +DEF_HELPER_FLAGS_5(sme_addha_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) |
33 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 26 | +DEF_HELPER_FLAGS_5(sme_addva_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) |
34 | DEF_HELPER_FLAGS_4(mve_vqshlui_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 27 | diff --git a/target/arm/sme.decode b/target/arm/sme.decode |
35 | DEF_HELPER_FLAGS_4(mve_vqshlui_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 28 | index XXXXXXX..XXXXXXX 100644 |
36 | DEF_HELPER_FLAGS_4(mve_vqshlui_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 29 | --- a/target/arm/sme.decode |
30 | +++ b/target/arm/sme.decode | ||
31 | @@ -XXX,XX +XXX,XX @@ LDST1 1110000 111 st:1 rm:5 v:1 .. pg:3 rn:5 0 za_imm:4 \ | ||
32 | |||
33 | LDR 1110000 100 0 000000 .. 000 ..... 0 .... @ldstr | ||
34 | STR 1110000 100 1 000000 .. 000 ..... 0 .... @ldstr | ||
37 | + | 35 | + |
38 | +DEF_HELPER_FLAGS_4(mve_vrshli_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 36 | +### SME Add Vector to Array |
39 | +DEF_HELPER_FLAGS_4(mve_vrshli_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
40 | +DEF_HELPER_FLAGS_4(mve_vrshli_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
41 | + | 37 | + |
42 | +DEF_HELPER_FLAGS_4(mve_vrshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 38 | +&adda zad zn pm pn |
43 | +DEF_HELPER_FLAGS_4(mve_vrshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 39 | +@adda_32 ........ .. ..... . pm:3 pn:3 zn:5 ... zad:2 &adda |
44 | +DEF_HELPER_FLAGS_4(mve_vrshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 40 | +@adda_64 ........ .. ..... . pm:3 pn:3 zn:5 .. zad:3 &adda |
45 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 41 | + |
42 | +ADDHA_s 11000000 10 01000 0 ... ... ..... 000 .. @adda_32 | ||
43 | +ADDVA_s 11000000 10 01000 1 ... ... ..... 000 .. @adda_32 | ||
44 | +ADDHA_d 11000000 11 01000 0 ... ... ..... 00 ... @adda_64 | ||
45 | +ADDVA_d 11000000 11 01000 1 ... ... ..... 00 ... @adda_64 | ||
46 | diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | 47 | index XXXXXXX..XXXXXXX 100644 |
47 | --- a/target/arm/translate.h | 48 | --- a/target/arm/sme_helper.c |
48 | +++ b/target/arm/translate.h | 49 | +++ b/target/arm/sme_helper.c |
49 | @@ -XXX,XX +XXX,XX @@ static inline int times_2_plus_1(DisasContext *s, int x) | 50 | @@ -XXX,XX +XXX,XX @@ DO_ST(q, _be, MO_128) |
50 | return x * 2 + 1; | 51 | DO_ST(q, _le, MO_128) |
51 | } | 52 | |
52 | 53 | #undef DO_ST | |
53 | +static inline int rsub_64(DisasContext *s, int x) | 54 | + |
55 | +void HELPER(sme_addha_s)(void *vzda, void *vzn, void *vpn, | ||
56 | + void *vpm, uint32_t desc) | ||
54 | +{ | 57 | +{ |
55 | + return 64 - x; | 58 | + intptr_t row, col, oprsz = simd_oprsz(desc) / 4; |
59 | + uint64_t *pn = vpn, *pm = vpm; | ||
60 | + uint32_t *zda = vzda, *zn = vzn; | ||
61 | + | ||
62 | + for (row = 0; row < oprsz; ) { | ||
63 | + uint64_t pa = pn[row >> 4]; | ||
64 | + do { | ||
65 | + if (pa & 1) { | ||
66 | + for (col = 0; col < oprsz; ) { | ||
67 | + uint64_t pb = pm[col >> 4]; | ||
68 | + do { | ||
69 | + if (pb & 1) { | ||
70 | + zda[tile_vslice_index(row) + H4(col)] += zn[H4(col)]; | ||
71 | + } | ||
72 | + pb >>= 4; | ||
73 | + } while (++col & 15); | ||
74 | + } | ||
75 | + } | ||
76 | + pa >>= 4; | ||
77 | + } while (++row & 15); | ||
78 | + } | ||
56 | +} | 79 | +} |
57 | + | 80 | + |
58 | +static inline int rsub_32(DisasContext *s, int x) | 81 | +void HELPER(sme_addha_d)(void *vzda, void *vzn, void *vpn, |
82 | + void *vpm, uint32_t desc) | ||
59 | +{ | 83 | +{ |
60 | + return 32 - x; | 84 | + intptr_t row, col, oprsz = simd_oprsz(desc) / 8; |
85 | + uint8_t *pn = vpn, *pm = vpm; | ||
86 | + uint64_t *zda = vzda, *zn = vzn; | ||
87 | + | ||
88 | + for (row = 0; row < oprsz; ++row) { | ||
89 | + if (pn[H1(row)] & 1) { | ||
90 | + for (col = 0; col < oprsz; ++col) { | ||
91 | + if (pm[H1(col)] & 1) { | ||
92 | + zda[tile_vslice_index(row) + col] += zn[col]; | ||
93 | + } | ||
94 | + } | ||
95 | + } | ||
96 | + } | ||
61 | +} | 97 | +} |
62 | + | 98 | + |
63 | +static inline int rsub_16(DisasContext *s, int x) | 99 | +void HELPER(sme_addva_s)(void *vzda, void *vzn, void *vpn, |
100 | + void *vpm, uint32_t desc) | ||
64 | +{ | 101 | +{ |
65 | + return 16 - x; | 102 | + intptr_t row, col, oprsz = simd_oprsz(desc) / 4; |
103 | + uint64_t *pn = vpn, *pm = vpm; | ||
104 | + uint32_t *zda = vzda, *zn = vzn; | ||
105 | + | ||
106 | + for (row = 0; row < oprsz; ) { | ||
107 | + uint64_t pa = pn[row >> 4]; | ||
108 | + do { | ||
109 | + if (pa & 1) { | ||
110 | + uint32_t zn_row = zn[H4(row)]; | ||
111 | + for (col = 0; col < oprsz; ) { | ||
112 | + uint64_t pb = pm[col >> 4]; | ||
113 | + do { | ||
114 | + if (pb & 1) { | ||
115 | + zda[tile_vslice_index(row) + H4(col)] += zn_row; | ||
116 | + } | ||
117 | + pb >>= 4; | ||
118 | + } while (++col & 15); | ||
119 | + } | ||
120 | + } | ||
121 | + pa >>= 4; | ||
122 | + } while (++row & 15); | ||
123 | + } | ||
66 | +} | 124 | +} |
67 | + | 125 | + |
68 | +static inline int rsub_8(DisasContext *s, int x) | 126 | +void HELPER(sme_addva_d)(void *vzda, void *vzn, void *vpn, |
127 | + void *vpm, uint32_t desc) | ||
69 | +{ | 128 | +{ |
70 | + return 8 - x; | 129 | + intptr_t row, col, oprsz = simd_oprsz(desc) / 8; |
130 | + uint8_t *pn = vpn, *pm = vpm; | ||
131 | + uint64_t *zda = vzda, *zn = vzn; | ||
132 | + | ||
133 | + for (row = 0; row < oprsz; ++row) { | ||
134 | + if (pn[H1(row)] & 1) { | ||
135 | + uint64_t zn_row = zn[row]; | ||
136 | + for (col = 0; col < oprsz; ++col) { | ||
137 | + if (pm[H1(col)] & 1) { | ||
138 | + zda[tile_vslice_index(row) + col] += zn_row; | ||
139 | + } | ||
140 | + } | ||
141 | + } | ||
142 | + } | ||
143 | +} | ||
144 | diff --git a/target/arm/translate-sme.c b/target/arm/translate-sme.c | ||
145 | index XXXXXXX..XXXXXXX 100644 | ||
146 | --- a/target/arm/translate-sme.c | ||
147 | +++ b/target/arm/translate-sme.c | ||
148 | @@ -XXX,XX +XXX,XX @@ static bool do_ldst_r(DisasContext *s, arg_ldstr *a, GenLdStR *fn) | ||
149 | |||
150 | TRANS_FEAT(LDR, aa64_sme, do_ldst_r, a, gen_sve_ldr) | ||
151 | TRANS_FEAT(STR, aa64_sme, do_ldst_r, a, gen_sve_str) | ||
152 | + | ||
153 | +static bool do_adda(DisasContext *s, arg_adda *a, MemOp esz, | ||
154 | + gen_helper_gvec_4 *fn) | ||
155 | +{ | ||
156 | + int svl = streaming_vec_reg_size(s); | ||
157 | + uint32_t desc = simd_desc(svl, svl, 0); | ||
158 | + TCGv_ptr za, zn, pn, pm; | ||
159 | + | ||
160 | + if (!sme_smza_enabled_check(s)) { | ||
161 | + return true; | ||
162 | + } | ||
163 | + | ||
164 | + /* Sum XZR+zad to find ZAd. */ | ||
165 | + za = get_tile_rowcol(s, esz, 31, a->zad, false); | ||
166 | + zn = vec_full_reg_ptr(s, a->zn); | ||
167 | + pn = pred_full_reg_ptr(s, a->pn); | ||
168 | + pm = pred_full_reg_ptr(s, a->pm); | ||
169 | + | ||
170 | + fn(za, zn, pn, pm, tcg_constant_i32(desc)); | ||
171 | + | ||
172 | + tcg_temp_free_ptr(za); | ||
173 | + tcg_temp_free_ptr(zn); | ||
174 | + tcg_temp_free_ptr(pn); | ||
175 | + tcg_temp_free_ptr(pm); | ||
176 | + return true; | ||
71 | +} | 177 | +} |
72 | + | 178 | + |
73 | static inline int arm_dc_feature(DisasContext *dc, int feature) | 179 | +TRANS_FEAT(ADDHA_s, aa64_sme, do_adda, a, MO_32, gen_helper_sme_addha_s) |
74 | { | 180 | +TRANS_FEAT(ADDVA_s, aa64_sme, do_adda, a, MO_32, gen_helper_sme_addva_s) |
75 | return (dc->features & (1ULL << feature)) != 0; | 181 | +TRANS_FEAT(ADDHA_d, aa64_sme_i16i64, do_adda, a, MO_64, gen_helper_sme_addha_d) |
76 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | 182 | +TRANS_FEAT(ADDVA_d, aa64_sme_i16i64, do_adda, a, MO_64, gen_helper_sme_addva_d) |
77 | index XXXXXXX..XXXXXXX 100644 | ||
78 | --- a/target/arm/mve.decode | ||
79 | +++ b/target/arm/mve.decode | ||
80 | @@ -XXX,XX +XXX,XX @@ | ||
81 | @2_shl_h .... .... .. 01 shift:4 .... .... .... .... &2shift qd=%qd qm=%qm size=1 | ||
82 | @2_shl_w .... .... .. 1 shift:5 .... .... .... .... &2shift qd=%qd qm=%qm size=2 | ||
83 | |||
84 | +# Right shifts are encoded as N - shift, where N is the element size in bits. | ||
85 | +%rshift_i5 16:5 !function=rsub_32 | ||
86 | +%rshift_i4 16:4 !function=rsub_16 | ||
87 | +%rshift_i3 16:3 !function=rsub_8 | ||
88 | + | ||
89 | +@2_shr_b .... .... .. 001 ... .... .... .... .... &2shift qd=%qd qm=%qm \ | ||
90 | + size=0 shift=%rshift_i3 | ||
91 | +@2_shr_h .... .... .. 01 .... .... .... .... .... &2shift qd=%qd qm=%qm \ | ||
92 | + size=1 shift=%rshift_i4 | ||
93 | +@2_shr_w .... .... .. 1 ..... .... .... .... .... &2shift qd=%qd qm=%qm \ | ||
94 | + size=2 shift=%rshift_i5 | ||
95 | + | ||
96 | # Vector loads and stores | ||
97 | |||
98 | # Widening loads and narrowing stores: | ||
99 | @@ -XXX,XX +XXX,XX @@ VQSHLI_U 111 1 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_w | ||
100 | VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_b | ||
101 | VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_h | ||
102 | VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_w | ||
103 | + | ||
104 | +VSHRI_S 111 0 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_b | ||
105 | +VSHRI_S 111 0 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_h | ||
106 | +VSHRI_S 111 0 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_w | ||
107 | + | ||
108 | +VSHRI_U 111 1 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_b | ||
109 | +VSHRI_U 111 1 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_h | ||
110 | +VSHRI_U 111 1 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_w | ||
111 | + | ||
112 | +VRSHRI_S 111 0 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_b | ||
113 | +VRSHRI_S 111 0 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_h | ||
114 | +VRSHRI_S 111 0 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_w | ||
115 | + | ||
116 | +VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_b | ||
117 | +VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_h | ||
118 | +VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_w | ||
119 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
120 | index XXXXXXX..XXXXXXX 100644 | ||
121 | --- a/target/arm/mve_helper.c | ||
122 | +++ b/target/arm/mve_helper.c | ||
123 | @@ -XXX,XX +XXX,XX @@ DO_VADDV(vaddvuw, 4, uint32_t) | ||
124 | DO_2SHIFT(OP##b, 1, uint8_t, FN) \ | ||
125 | DO_2SHIFT(OP##h, 2, uint16_t, FN) \ | ||
126 | DO_2SHIFT(OP##w, 4, uint32_t, FN) | ||
127 | +#define DO_2SHIFT_S(OP, FN) \ | ||
128 | + DO_2SHIFT(OP##b, 1, int8_t, FN) \ | ||
129 | + DO_2SHIFT(OP##h, 2, int16_t, FN) \ | ||
130 | + DO_2SHIFT(OP##w, 4, int32_t, FN) | ||
131 | |||
132 | #define DO_2SHIFT_SAT_U(OP, FN) \ | ||
133 | DO_2SHIFT_SAT(OP##b, 1, uint8_t, FN) \ | ||
134 | @@ -XXX,XX +XXX,XX @@ DO_VADDV(vaddvuw, 4, uint32_t) | ||
135 | DO_2SHIFT_SAT(OP##w, 4, int32_t, FN) | ||
136 | |||
137 | DO_2SHIFT_U(vshli_u, DO_VSHLU) | ||
138 | +DO_2SHIFT_S(vshli_s, DO_VSHLS) | ||
139 | DO_2SHIFT_SAT_U(vqshli_u, DO_UQSHL_OP) | ||
140 | DO_2SHIFT_SAT_S(vqshli_s, DO_SQSHL_OP) | ||
141 | DO_2SHIFT_SAT_S(vqshlui_s, DO_SUQSHL_OP) | ||
142 | +DO_2SHIFT_U(vrshli_u, DO_VRSHLU) | ||
143 | +DO_2SHIFT_S(vrshli_s, DO_VRSHLS) | ||
144 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
145 | index XXXXXXX..XXXXXXX 100644 | ||
146 | --- a/target/arm/translate-mve.c | ||
147 | +++ b/target/arm/translate-mve.c | ||
148 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT(VSHLI, vshli_u, false) | ||
149 | DO_2SHIFT(VQSHLI_S, vqshli_s, false) | ||
150 | DO_2SHIFT(VQSHLI_U, vqshli_u, false) | ||
151 | DO_2SHIFT(VQSHLUI, vqshlui_s, false) | ||
152 | +/* These right shifts use a left-shift helper with negated shift count */ | ||
153 | +DO_2SHIFT(VSHRI_S, vshli_s, true) | ||
154 | +DO_2SHIFT(VSHRI_U, vshli_u, true) | ||
155 | +DO_2SHIFT(VRSHRI_S, vrshli_s, true) | ||
156 | +DO_2SHIFT(VRSHRI_U, vrshli_u, true) | ||
157 | diff --git a/target/arm/translate-neon.c b/target/arm/translate-neon.c | ||
158 | index XXXXXXX..XXXXXXX 100644 | ||
159 | --- a/target/arm/translate-neon.c | ||
160 | +++ b/target/arm/translate-neon.c | ||
161 | @@ -XXX,XX +XXX,XX @@ static inline int plus1(DisasContext *s, int x) | ||
162 | return x + 1; | ||
163 | } | ||
164 | |||
165 | -static inline int rsub_64(DisasContext *s, int x) | ||
166 | -{ | ||
167 | - return 64 - x; | ||
168 | -} | ||
169 | - | ||
170 | -static inline int rsub_32(DisasContext *s, int x) | ||
171 | -{ | ||
172 | - return 32 - x; | ||
173 | -} | ||
174 | -static inline int rsub_16(DisasContext *s, int x) | ||
175 | -{ | ||
176 | - return 16 - x; | ||
177 | -} | ||
178 | -static inline int rsub_8(DisasContext *s, int x) | ||
179 | -{ | ||
180 | - return 8 - x; | ||
181 | -} | ||
182 | - | ||
183 | static inline int neon_3same_fp_size(DisasContext *s, int x) | ||
184 | { | ||
185 | /* Convert 0==fp32, 1==fp16 into a MO_* value */ | ||
186 | -- | 183 | -- |
187 | 2.20.1 | 184 | 2.25.1 |
188 | |||
189 | diff view generated by jsdifflib |
1 | Implement the MVE saturating shift-right-and-narrow insns | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | VQSHRN, VQSHRUN, VQRSHRN and VQRSHRUN. | ||
3 | 2 | ||
4 | do_srshr() is borrowed from sve_helper.c. | 3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
4 | Message-id: 20220708151540.18136-25-richard.henderson@linaro.org | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/helper-sme.h | 5 +++ | ||
9 | target/arm/sme.decode | 9 +++++ | ||
10 | target/arm/sme_helper.c | 69 ++++++++++++++++++++++++++++++++++++++ | ||
11 | target/arm/translate-sme.c | 32 ++++++++++++++++++ | ||
12 | 4 files changed, 115 insertions(+) | ||
5 | 13 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | diff --git a/target/arm/helper-sme.h b/target/arm/helper-sme.h |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210628135835.6690-13-peter.maydell@linaro.org | ||
9 | --- | ||
10 | target/arm/helper-mve.h | 30 +++++++++++ | ||
11 | target/arm/mve.decode | 28 ++++++++++ | ||
12 | target/arm/mve_helper.c | 104 +++++++++++++++++++++++++++++++++++++ | ||
13 | target/arm/translate-mve.c | 12 +++++ | ||
14 | 4 files changed, 174 insertions(+) | ||
15 | |||
16 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/helper-mve.h | 16 | --- a/target/arm/helper-sme.h |
19 | +++ b/target/arm/helper-mve.h | 17 | +++ b/target/arm/helper-sme.h |
20 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vrshrnbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_5(sme_addha_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) |
21 | DEF_HELPER_FLAGS_4(mve_vrshrnbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 19 | DEF_HELPER_FLAGS_5(sme_addva_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) |
22 | DEF_HELPER_FLAGS_4(mve_vrshrntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 20 | DEF_HELPER_FLAGS_5(sme_addha_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) |
23 | DEF_HELPER_FLAGS_4(mve_vrshrnth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 21 | DEF_HELPER_FLAGS_5(sme_addva_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) |
24 | + | 22 | + |
25 | +DEF_HELPER_FLAGS_4(mve_vqshrnb_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 23 | +DEF_HELPER_FLAGS_7(sme_fmopa_s, TCG_CALL_NO_RWG, |
26 | +DEF_HELPER_FLAGS_4(mve_vqshrnb_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 24 | + void, ptr, ptr, ptr, ptr, ptr, ptr, i32) |
27 | +DEF_HELPER_FLAGS_4(mve_vqshrnt_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 25 | +DEF_HELPER_FLAGS_7(sme_fmopa_d, TCG_CALL_NO_RWG, |
28 | +DEF_HELPER_FLAGS_4(mve_vqshrnt_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 26 | + void, ptr, ptr, ptr, ptr, ptr, ptr, i32) |
27 | diff --git a/target/arm/sme.decode b/target/arm/sme.decode | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/target/arm/sme.decode | ||
30 | +++ b/target/arm/sme.decode | ||
31 | @@ -XXX,XX +XXX,XX @@ ADDHA_s 11000000 10 01000 0 ... ... ..... 000 .. @adda_32 | ||
32 | ADDVA_s 11000000 10 01000 1 ... ... ..... 000 .. @adda_32 | ||
33 | ADDHA_d 11000000 11 01000 0 ... ... ..... 00 ... @adda_64 | ||
34 | ADDVA_d 11000000 11 01000 1 ... ... ..... 00 ... @adda_64 | ||
29 | + | 35 | + |
30 | +DEF_HELPER_FLAGS_4(mve_vqshrnb_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 36 | +### SME Outer Product |
31 | +DEF_HELPER_FLAGS_4(mve_vqshrnb_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
32 | +DEF_HELPER_FLAGS_4(mve_vqshrnt_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
33 | +DEF_HELPER_FLAGS_4(mve_vqshrnt_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
34 | + | 37 | + |
35 | +DEF_HELPER_FLAGS_4(mve_vqshrunbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 38 | +&op zad zn zm pm pn sub:bool |
36 | +DEF_HELPER_FLAGS_4(mve_vqshrunbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 39 | +@op_32 ........ ... zm:5 pm:3 pn:3 zn:5 sub:1 .. zad:2 &op |
37 | +DEF_HELPER_FLAGS_4(mve_vqshruntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 40 | +@op_64 ........ ... zm:5 pm:3 pn:3 zn:5 sub:1 . zad:3 &op |
38 | +DEF_HELPER_FLAGS_4(mve_vqshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
39 | + | 41 | + |
40 | +DEF_HELPER_FLAGS_4(mve_vqrshrnb_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 42 | +FMOPA_s 10000000 100 ..... ... ... ..... . 00 .. @op_32 |
41 | +DEF_HELPER_FLAGS_4(mve_vqrshrnb_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 43 | +FMOPA_d 10000000 110 ..... ... ... ..... . 0 ... @op_64 |
42 | +DEF_HELPER_FLAGS_4(mve_vqrshrnt_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 44 | diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c |
43 | +DEF_HELPER_FLAGS_4(mve_vqrshrnt_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
44 | + | ||
45 | +DEF_HELPER_FLAGS_4(mve_vqrshrnb_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
46 | +DEF_HELPER_FLAGS_4(mve_vqrshrnb_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
47 | +DEF_HELPER_FLAGS_4(mve_vqrshrnt_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
48 | +DEF_HELPER_FLAGS_4(mve_vqrshrnt_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
49 | + | ||
50 | +DEF_HELPER_FLAGS_4(mve_vqrshrunbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
51 | +DEF_HELPER_FLAGS_4(mve_vqrshrunbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
52 | +DEF_HELPER_FLAGS_4(mve_vqrshruntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
53 | +DEF_HELPER_FLAGS_4(mve_vqrshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
54 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
55 | index XXXXXXX..XXXXXXX 100644 | 45 | index XXXXXXX..XXXXXXX 100644 |
56 | --- a/target/arm/mve.decode | 46 | --- a/target/arm/sme_helper.c |
57 | +++ b/target/arm/mve.decode | 47 | +++ b/target/arm/sme_helper.c |
58 | @@ -XXX,XX +XXX,XX @@ VRSHRNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_b | 48 | @@ -XXX,XX +XXX,XX @@ |
59 | VRSHRNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_h | 49 | #include "exec/cpu_ldst.h" |
60 | VRSHRNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_b | 50 | #include "exec/exec-all.h" |
61 | VRSHRNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_h | 51 | #include "qemu/int128.h" |
62 | + | 52 | +#include "fpu/softfloat.h" |
63 | +VQSHRNB_S 111 0 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 0 @2_shr_b | 53 | #include "vec_internal.h" |
64 | +VQSHRNB_S 111 0 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 0 @2_shr_h | 54 | #include "sve_ldst_internal.h" |
65 | +VQSHRNT_S 111 0 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 0 @2_shr_b | 55 | |
66 | +VQSHRNT_S 111 0 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 0 @2_shr_h | 56 | @@ -XXX,XX +XXX,XX @@ void HELPER(sme_addva_d)(void *vzda, void *vzn, void *vpn, |
67 | +VQSHRNB_U 111 1 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 0 @2_shr_b | 57 | } |
68 | +VQSHRNB_U 111 1 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 0 @2_shr_h | ||
69 | +VQSHRNT_U 111 1 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 0 @2_shr_b | ||
70 | +VQSHRNT_U 111 1 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 0 @2_shr_h | ||
71 | + | ||
72 | +VQSHRUNB 111 0 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_b | ||
73 | +VQSHRUNB 111 0 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_h | ||
74 | +VQSHRUNT 111 0 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_b | ||
75 | +VQSHRUNT 111 0 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_h | ||
76 | + | ||
77 | +VQRSHRNB_S 111 0 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 1 @2_shr_b | ||
78 | +VQRSHRNB_S 111 0 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 1 @2_shr_h | ||
79 | +VQRSHRNT_S 111 0 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 1 @2_shr_b | ||
80 | +VQRSHRNT_S 111 0 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 1 @2_shr_h | ||
81 | +VQRSHRNB_U 111 1 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 1 @2_shr_b | ||
82 | +VQRSHRNB_U 111 1 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 1 @2_shr_h | ||
83 | +VQRSHRNT_U 111 1 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 1 @2_shr_b | ||
84 | +VQRSHRNT_U 111 1 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 1 @2_shr_h | ||
85 | + | ||
86 | +VQRSHRUNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_b | ||
87 | +VQRSHRUNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_h | ||
88 | +VQRSHRUNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_b | ||
89 | +VQRSHRUNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_h | ||
90 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
91 | index XXXXXXX..XXXXXXX 100644 | ||
92 | --- a/target/arm/mve_helper.c | ||
93 | +++ b/target/arm/mve_helper.c | ||
94 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t do_urshr(uint64_t x, unsigned sh) | ||
95 | } | 58 | } |
96 | } | 59 | } |
97 | 60 | + | |
98 | +static inline int64_t do_srshr(int64_t x, unsigned sh) | 61 | +void HELPER(sme_fmopa_s)(void *vza, void *vzn, void *vzm, void *vpn, |
62 | + void *vpm, void *vst, uint32_t desc) | ||
99 | +{ | 63 | +{ |
100 | + if (likely(sh < 64)) { | 64 | + intptr_t row, col, oprsz = simd_maxsz(desc); |
101 | + return (x >> sh) + ((x >> (sh - 1)) & 1); | 65 | + uint32_t neg = simd_data(desc) << 31; |
102 | + } else { | 66 | + uint16_t *pn = vpn, *pm = vpm; |
103 | + /* Rounding the sign bit always produces 0. */ | 67 | + float_status fpst; |
104 | + return 0; | 68 | + |
69 | + /* | ||
70 | + * Make a copy of float_status because this operation does not | ||
71 | + * update the cumulative fp exception status. It also produces | ||
72 | + * default nans. | ||
73 | + */ | ||
74 | + fpst = *(float_status *)vst; | ||
75 | + set_default_nan_mode(true, &fpst); | ||
76 | + | ||
77 | + for (row = 0; row < oprsz; ) { | ||
78 | + uint16_t pa = pn[H2(row >> 4)]; | ||
79 | + do { | ||
80 | + if (pa & 1) { | ||
81 | + void *vza_row = vza + tile_vslice_offset(row); | ||
82 | + uint32_t n = *(uint32_t *)(vzn + H1_4(row)) ^ neg; | ||
83 | + | ||
84 | + for (col = 0; col < oprsz; ) { | ||
85 | + uint16_t pb = pm[H2(col >> 4)]; | ||
86 | + do { | ||
87 | + if (pb & 1) { | ||
88 | + uint32_t *a = vza_row + H1_4(col); | ||
89 | + uint32_t *m = vzm + H1_4(col); | ||
90 | + *a = float32_muladd(n, *m, *a, 0, vst); | ||
91 | + } | ||
92 | + col += 4; | ||
93 | + pb >>= 4; | ||
94 | + } while (col & 15); | ||
95 | + } | ||
96 | + } | ||
97 | + row += 4; | ||
98 | + pa >>= 4; | ||
99 | + } while (row & 15); | ||
105 | + } | 100 | + } |
106 | +} | 101 | +} |
107 | + | 102 | + |
108 | DO_VSHRN_ALL(vshrn, DO_SHR) | 103 | +void HELPER(sme_fmopa_d)(void *vza, void *vzn, void *vzm, void *vpn, |
109 | DO_VSHRN_ALL(vrshrn, do_urshr) | 104 | + void *vpm, void *vst, uint32_t desc) |
105 | +{ | ||
106 | + intptr_t row, col, oprsz = simd_oprsz(desc) / 8; | ||
107 | + uint64_t neg = (uint64_t)simd_data(desc) << 63; | ||
108 | + uint64_t *za = vza, *zn = vzn, *zm = vzm; | ||
109 | + uint8_t *pn = vpn, *pm = vpm; | ||
110 | + float_status fpst = *(float_status *)vst; | ||
110 | + | 111 | + |
111 | +static inline int32_t do_sat_bhs(int64_t val, int64_t min, int64_t max, | 112 | + set_default_nan_mode(true, &fpst); |
112 | + bool *satp) | 113 | + |
113 | +{ | 114 | + for (row = 0; row < oprsz; ++row) { |
114 | + if (val > max) { | 115 | + if (pn[H1(row)] & 1) { |
115 | + *satp = true; | 116 | + uint64_t *za_row = &za[tile_vslice_index(row)]; |
116 | + return max; | 117 | + uint64_t n = zn[row] ^ neg; |
117 | + } else if (val < min) { | 118 | + |
118 | + *satp = true; | 119 | + for (col = 0; col < oprsz; ++col) { |
119 | + return min; | 120 | + if (pm[H1(col)] & 1) { |
120 | + } else { | 121 | + uint64_t *a = &za_row[col]; |
121 | + return val; | 122 | + *a = float64_muladd(n, zm[col], *a, 0, &fpst); |
123 | + } | ||
124 | + } | ||
125 | + } | ||
122 | + } | 126 | + } |
123 | +} | 127 | +} |
128 | diff --git a/target/arm/translate-sme.c b/target/arm/translate-sme.c | ||
129 | index XXXXXXX..XXXXXXX 100644 | ||
130 | --- a/target/arm/translate-sme.c | ||
131 | +++ b/target/arm/translate-sme.c | ||
132 | @@ -XXX,XX +XXX,XX @@ TRANS_FEAT(ADDHA_s, aa64_sme, do_adda, a, MO_32, gen_helper_sme_addha_s) | ||
133 | TRANS_FEAT(ADDVA_s, aa64_sme, do_adda, a, MO_32, gen_helper_sme_addva_s) | ||
134 | TRANS_FEAT(ADDHA_d, aa64_sme_i16i64, do_adda, a, MO_64, gen_helper_sme_addha_d) | ||
135 | TRANS_FEAT(ADDVA_d, aa64_sme_i16i64, do_adda, a, MO_64, gen_helper_sme_addva_d) | ||
124 | + | 136 | + |
125 | +/* Saturating narrowing right shifts */ | 137 | +static bool do_outprod_fpst(DisasContext *s, arg_op *a, MemOp esz, |
126 | +#define DO_VSHRN_SAT(OP, TOP, ESIZE, TYPE, LESIZE, LTYPE, FN) \ | 138 | + gen_helper_gvec_5_ptr *fn) |
127 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ | 139 | +{ |
128 | + void *vm, uint32_t shift) \ | 140 | + int svl = streaming_vec_reg_size(s); |
129 | + { \ | 141 | + uint32_t desc = simd_desc(svl, svl, a->sub); |
130 | + LTYPE *m = vm; \ | 142 | + TCGv_ptr za, zn, zm, pn, pm, fpst; |
131 | + TYPE *d = vd; \ | 143 | + |
132 | + uint16_t mask = mve_element_mask(env); \ | 144 | + if (!sme_smza_enabled_check(s)) { |
133 | + bool qc = false; \ | 145 | + return true; |
134 | + unsigned le; \ | ||
135 | + for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \ | ||
136 | + bool sat = false; \ | ||
137 | + TYPE r = FN(m[H##LESIZE(le)], shift, &sat); \ | ||
138 | + mergemask(&d[H##ESIZE(le * 2 + TOP)], r, mask); \ | ||
139 | + qc |= sat && (mask & 1 << (TOP * ESIZE)); \ | ||
140 | + } \ | ||
141 | + if (qc) { \ | ||
142 | + env->vfp.qc[0] = qc; \ | ||
143 | + } \ | ||
144 | + mve_advance_vpt(env); \ | ||
145 | + } | 146 | + } |
146 | + | 147 | + |
147 | +#define DO_VSHRN_SAT_UB(BOP, TOP, FN) \ | 148 | + /* Sum XZR+zad to find ZAd. */ |
148 | + DO_VSHRN_SAT(BOP, false, 1, uint8_t, 2, uint16_t, FN) \ | 149 | + za = get_tile_rowcol(s, esz, 31, a->zad, false); |
149 | + DO_VSHRN_SAT(TOP, true, 1, uint8_t, 2, uint16_t, FN) | 150 | + zn = vec_full_reg_ptr(s, a->zn); |
151 | + zm = vec_full_reg_ptr(s, a->zm); | ||
152 | + pn = pred_full_reg_ptr(s, a->pn); | ||
153 | + pm = pred_full_reg_ptr(s, a->pm); | ||
154 | + fpst = fpstatus_ptr(FPST_FPCR); | ||
150 | + | 155 | + |
151 | +#define DO_VSHRN_SAT_UH(BOP, TOP, FN) \ | 156 | + fn(za, zn, zm, pn, pm, fpst, tcg_constant_i32(desc)); |
152 | + DO_VSHRN_SAT(BOP, false, 2, uint16_t, 4, uint32_t, FN) \ | ||
153 | + DO_VSHRN_SAT(TOP, true, 2, uint16_t, 4, uint32_t, FN) | ||
154 | + | 157 | + |
155 | +#define DO_VSHRN_SAT_SB(BOP, TOP, FN) \ | 158 | + tcg_temp_free_ptr(za); |
156 | + DO_VSHRN_SAT(BOP, false, 1, int8_t, 2, int16_t, FN) \ | 159 | + tcg_temp_free_ptr(zn); |
157 | + DO_VSHRN_SAT(TOP, true, 1, int8_t, 2, int16_t, FN) | 160 | + tcg_temp_free_ptr(pn); |
161 | + tcg_temp_free_ptr(pm); | ||
162 | + tcg_temp_free_ptr(fpst); | ||
163 | + return true; | ||
164 | +} | ||
158 | + | 165 | + |
159 | +#define DO_VSHRN_SAT_SH(BOP, TOP, FN) \ | 166 | +TRANS_FEAT(FMOPA_s, aa64_sme, do_outprod_fpst, a, MO_32, gen_helper_sme_fmopa_s) |
160 | + DO_VSHRN_SAT(BOP, false, 2, int16_t, 4, int32_t, FN) \ | 167 | +TRANS_FEAT(FMOPA_d, aa64_sme_f64f64, do_outprod_fpst, a, MO_64, gen_helper_sme_fmopa_d) |
161 | + DO_VSHRN_SAT(TOP, true, 2, int16_t, 4, int32_t, FN) | ||
162 | + | ||
163 | +#define DO_SHRN_SB(N, M, SATP) \ | ||
164 | + do_sat_bhs((int64_t)(N) >> (M), INT8_MIN, INT8_MAX, SATP) | ||
165 | +#define DO_SHRN_UB(N, M, SATP) \ | ||
166 | + do_sat_bhs((uint64_t)(N) >> (M), 0, UINT8_MAX, SATP) | ||
167 | +#define DO_SHRUN_B(N, M, SATP) \ | ||
168 | + do_sat_bhs((int64_t)(N) >> (M), 0, UINT8_MAX, SATP) | ||
169 | + | ||
170 | +#define DO_SHRN_SH(N, M, SATP) \ | ||
171 | + do_sat_bhs((int64_t)(N) >> (M), INT16_MIN, INT16_MAX, SATP) | ||
172 | +#define DO_SHRN_UH(N, M, SATP) \ | ||
173 | + do_sat_bhs((uint64_t)(N) >> (M), 0, UINT16_MAX, SATP) | ||
174 | +#define DO_SHRUN_H(N, M, SATP) \ | ||
175 | + do_sat_bhs((int64_t)(N) >> (M), 0, UINT16_MAX, SATP) | ||
176 | + | ||
177 | +#define DO_RSHRN_SB(N, M, SATP) \ | ||
178 | + do_sat_bhs(do_srshr(N, M), INT8_MIN, INT8_MAX, SATP) | ||
179 | +#define DO_RSHRN_UB(N, M, SATP) \ | ||
180 | + do_sat_bhs(do_urshr(N, M), 0, UINT8_MAX, SATP) | ||
181 | +#define DO_RSHRUN_B(N, M, SATP) \ | ||
182 | + do_sat_bhs(do_srshr(N, M), 0, UINT8_MAX, SATP) | ||
183 | + | ||
184 | +#define DO_RSHRN_SH(N, M, SATP) \ | ||
185 | + do_sat_bhs(do_srshr(N, M), INT16_MIN, INT16_MAX, SATP) | ||
186 | +#define DO_RSHRN_UH(N, M, SATP) \ | ||
187 | + do_sat_bhs(do_urshr(N, M), 0, UINT16_MAX, SATP) | ||
188 | +#define DO_RSHRUN_H(N, M, SATP) \ | ||
189 | + do_sat_bhs(do_srshr(N, M), 0, UINT16_MAX, SATP) | ||
190 | + | ||
191 | +DO_VSHRN_SAT_SB(vqshrnb_sb, vqshrnt_sb, DO_SHRN_SB) | ||
192 | +DO_VSHRN_SAT_SH(vqshrnb_sh, vqshrnt_sh, DO_SHRN_SH) | ||
193 | +DO_VSHRN_SAT_UB(vqshrnb_ub, vqshrnt_ub, DO_SHRN_UB) | ||
194 | +DO_VSHRN_SAT_UH(vqshrnb_uh, vqshrnt_uh, DO_SHRN_UH) | ||
195 | +DO_VSHRN_SAT_SB(vqshrunbb, vqshruntb, DO_SHRUN_B) | ||
196 | +DO_VSHRN_SAT_SH(vqshrunbh, vqshrunth, DO_SHRUN_H) | ||
197 | + | ||
198 | +DO_VSHRN_SAT_SB(vqrshrnb_sb, vqrshrnt_sb, DO_RSHRN_SB) | ||
199 | +DO_VSHRN_SAT_SH(vqrshrnb_sh, vqrshrnt_sh, DO_RSHRN_SH) | ||
200 | +DO_VSHRN_SAT_UB(vqrshrnb_ub, vqrshrnt_ub, DO_RSHRN_UB) | ||
201 | +DO_VSHRN_SAT_UH(vqrshrnb_uh, vqrshrnt_uh, DO_RSHRN_UH) | ||
202 | +DO_VSHRN_SAT_SB(vqrshrunbb, vqrshruntb, DO_RSHRUN_B) | ||
203 | +DO_VSHRN_SAT_SH(vqrshrunbh, vqrshrunth, DO_RSHRUN_H) | ||
204 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
205 | index XXXXXXX..XXXXXXX 100644 | ||
206 | --- a/target/arm/translate-mve.c | ||
207 | +++ b/target/arm/translate-mve.c | ||
208 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT_N(VSHRNB, vshrnb) | ||
209 | DO_2SHIFT_N(VSHRNT, vshrnt) | ||
210 | DO_2SHIFT_N(VRSHRNB, vrshrnb) | ||
211 | DO_2SHIFT_N(VRSHRNT, vrshrnt) | ||
212 | +DO_2SHIFT_N(VQSHRNB_S, vqshrnb_s) | ||
213 | +DO_2SHIFT_N(VQSHRNT_S, vqshrnt_s) | ||
214 | +DO_2SHIFT_N(VQSHRNB_U, vqshrnb_u) | ||
215 | +DO_2SHIFT_N(VQSHRNT_U, vqshrnt_u) | ||
216 | +DO_2SHIFT_N(VQSHRUNB, vqshrunb) | ||
217 | +DO_2SHIFT_N(VQSHRUNT, vqshrunt) | ||
218 | +DO_2SHIFT_N(VQRSHRNB_S, vqrshrnb_s) | ||
219 | +DO_2SHIFT_N(VQRSHRNT_S, vqrshrnt_s) | ||
220 | +DO_2SHIFT_N(VQRSHRNB_U, vqrshrnb_u) | ||
221 | +DO_2SHIFT_N(VQRSHRNT_U, vqrshrnt_u) | ||
222 | +DO_2SHIFT_N(VQRSHRUNB, vqrshrunb) | ||
223 | +DO_2SHIFT_N(VQRSHRUNT, vqrshrunt) | ||
224 | -- | 168 | -- |
225 | 2.20.1 | 169 | 2.25.1 |
226 | |||
227 | diff view generated by jsdifflib |
1 | Implement the MVE shift-right-and-narrow insn VSHRN and VRSHRN. | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | do_urshr() is borrowed from sve_helper.c. | 3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
4 | Message-id: 20220708151540.18136-26-richard.henderson@linaro.org | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/helper-sme.h | 2 ++ | ||
9 | target/arm/sme.decode | 2 ++ | ||
10 | target/arm/sme_helper.c | 56 ++++++++++++++++++++++++++++++++++++++ | ||
11 | target/arm/translate-sme.c | 30 ++++++++++++++++++++ | ||
12 | 4 files changed, 90 insertions(+) | ||
4 | 13 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | diff --git a/target/arm/helper-sme.h b/target/arm/helper-sme.h |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20210628135835.6690-12-peter.maydell@linaro.org | ||
8 | --- | ||
9 | target/arm/helper-mve.h | 10 ++++++++++ | ||
10 | target/arm/mve.decode | 11 +++++++++++ | ||
11 | target/arm/mve_helper.c | 40 ++++++++++++++++++++++++++++++++++++++ | ||
12 | target/arm/translate-mve.c | 15 ++++++++++++++ | ||
13 | 4 files changed, 76 insertions(+) | ||
14 | |||
15 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/helper-mve.h | 16 | --- a/target/arm/helper-sme.h |
18 | +++ b/target/arm/helper-mve.h | 17 | +++ b/target/arm/helper-sme.h |
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vsriw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_7(sme_fmopa_s, TCG_CALL_NO_RWG, |
20 | DEF_HELPER_FLAGS_4(mve_vslib, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 19 | void, ptr, ptr, ptr, ptr, ptr, ptr, i32) |
21 | DEF_HELPER_FLAGS_4(mve_vslih, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 20 | DEF_HELPER_FLAGS_7(sme_fmopa_d, TCG_CALL_NO_RWG, |
22 | DEF_HELPER_FLAGS_4(mve_vsliw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 21 | void, ptr, ptr, ptr, ptr, ptr, ptr, i32) |
22 | +DEF_HELPER_FLAGS_6(sme_bfmopa, TCG_CALL_NO_RWG, | ||
23 | + void, ptr, ptr, ptr, ptr, ptr, i32) | ||
24 | diff --git a/target/arm/sme.decode b/target/arm/sme.decode | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/target/arm/sme.decode | ||
27 | +++ b/target/arm/sme.decode | ||
28 | @@ -XXX,XX +XXX,XX @@ ADDVA_d 11000000 11 01000 1 ... ... ..... 00 ... @adda_64 | ||
29 | |||
30 | FMOPA_s 10000000 100 ..... ... ... ..... . 00 .. @op_32 | ||
31 | FMOPA_d 10000000 110 ..... ... ... ..... . 0 ... @op_64 | ||
23 | + | 32 | + |
24 | +DEF_HELPER_FLAGS_4(mve_vshrnbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 33 | +BFMOPA 10000001 100 ..... ... ... ..... . 00 .. @op_32 |
25 | +DEF_HELPER_FLAGS_4(mve_vshrnbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 34 | diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c |
26 | +DEF_HELPER_FLAGS_4(mve_vshrntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
27 | +DEF_HELPER_FLAGS_4(mve_vshrnth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
28 | + | ||
29 | +DEF_HELPER_FLAGS_4(mve_vrshrnbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
30 | +DEF_HELPER_FLAGS_4(mve_vrshrnbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
31 | +DEF_HELPER_FLAGS_4(mve_vrshrntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
32 | +DEF_HELPER_FLAGS_4(mve_vrshrnth, 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 | index XXXXXXX..XXXXXXX 100644 |
35 | --- a/target/arm/mve.decode | 36 | --- a/target/arm/sme_helper.c |
36 | +++ b/target/arm/mve.decode | 37 | +++ b/target/arm/sme_helper.c |
37 | @@ -XXX,XX +XXX,XX @@ VSRI 111 1 1111 1 . ... ... ... 0 0100 0 1 . 1 ... 0 @2_shr_w | 38 | @@ -XXX,XX +XXX,XX @@ void HELPER(sme_fmopa_d)(void *vza, void *vzn, void *vzm, void *vpn, |
38 | VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_b | 39 | } |
39 | VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_h | 40 | } |
40 | VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_w | 41 | } |
41 | + | ||
42 | +# Narrowing shifts (which only support b and h sizes) | ||
43 | +VSHRNB 111 0 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_b | ||
44 | +VSHRNB 111 0 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_h | ||
45 | +VSHRNT 111 0 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_b | ||
46 | +VSHRNT 111 0 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_h | ||
47 | + | ||
48 | +VRSHRNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_b | ||
49 | +VRSHRNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_h | ||
50 | +VRSHRNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_b | ||
51 | +VRSHRNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_h | ||
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_2SHIFT_INSERT(vsliw, 4, DO_SHL, SHL_MASK) | ||
57 | |||
58 | DO_VSHLL_ALL(vshllb, false) | ||
59 | DO_VSHLL_ALL(vshllt, true) | ||
60 | + | 42 | + |
61 | +/* | 43 | +/* |
62 | + * Narrowing right shifts, taking a double sized input, shifting it | 44 | + * Alter PAIR as needed for controlling predicates being false, |
63 | + * and putting the result in either the top or bottom half of the output. | 45 | + * and for NEG on an enabled row element. |
64 | + * ESIZE, TYPE are the output, and LESIZE, LTYPE the input. | ||
65 | + */ | 46 | + */ |
66 | +#define DO_VSHRN(OP, TOP, ESIZE, TYPE, LESIZE, LTYPE, FN) \ | 47 | +static inline uint32_t f16mop_adj_pair(uint32_t pair, uint32_t pg, uint32_t neg) |
67 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ | 48 | +{ |
68 | + void *vm, uint32_t shift) \ | 49 | + /* |
69 | + { \ | 50 | + * The pseudocode uses a conditional negate after the conditional zero. |
70 | + LTYPE *m = vm; \ | 51 | + * It is simpler here to unconditionally negate before conditional zero. |
71 | + TYPE *d = vd; \ | 52 | + */ |
72 | + uint16_t mask = mve_element_mask(env); \ | 53 | + pair ^= neg; |
73 | + unsigned le; \ | 54 | + if (!(pg & 1)) { |
74 | + for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \ | 55 | + pair &= 0xffff0000u; |
75 | + TYPE r = FN(m[H##LESIZE(le)], shift); \ | 56 | + } |
76 | + mergemask(&d[H##ESIZE(le * 2 + TOP)], r, mask); \ | 57 | + if (!(pg & 4)) { |
77 | + } \ | 58 | + pair &= 0x0000ffffu; |
78 | + mve_advance_vpt(env); \ | 59 | + } |
60 | + return pair; | ||
61 | +} | ||
62 | + | ||
63 | +void HELPER(sme_bfmopa)(void *vza, void *vzn, void *vzm, void *vpn, | ||
64 | + void *vpm, uint32_t desc) | ||
65 | +{ | ||
66 | + intptr_t row, col, oprsz = simd_maxsz(desc); | ||
67 | + uint32_t neg = simd_data(desc) * 0x80008000u; | ||
68 | + uint16_t *pn = vpn, *pm = vpm; | ||
69 | + | ||
70 | + for (row = 0; row < oprsz; ) { | ||
71 | + uint16_t prow = pn[H2(row >> 4)]; | ||
72 | + do { | ||
73 | + void *vza_row = vza + tile_vslice_offset(row); | ||
74 | + uint32_t n = *(uint32_t *)(vzn + H1_4(row)); | ||
75 | + | ||
76 | + n = f16mop_adj_pair(n, prow, neg); | ||
77 | + | ||
78 | + for (col = 0; col < oprsz; ) { | ||
79 | + uint16_t pcol = pm[H2(col >> 4)]; | ||
80 | + do { | ||
81 | + if (prow & pcol & 0b0101) { | ||
82 | + uint32_t *a = vza_row + H1_4(col); | ||
83 | + uint32_t m = *(uint32_t *)(vzm + H1_4(col)); | ||
84 | + | ||
85 | + m = f16mop_adj_pair(m, pcol, 0); | ||
86 | + *a = bfdotadd(*a, n, m); | ||
87 | + | ||
88 | + col += 4; | ||
89 | + pcol >>= 4; | ||
90 | + } | ||
91 | + } while (col & 15); | ||
92 | + } | ||
93 | + row += 4; | ||
94 | + prow >>= 4; | ||
95 | + } while (row & 15); | ||
96 | + } | ||
97 | +} | ||
98 | diff --git a/target/arm/translate-sme.c b/target/arm/translate-sme.c | ||
99 | index XXXXXXX..XXXXXXX 100644 | ||
100 | --- a/target/arm/translate-sme.c | ||
101 | +++ b/target/arm/translate-sme.c | ||
102 | @@ -XXX,XX +XXX,XX @@ TRANS_FEAT(ADDVA_s, aa64_sme, do_adda, a, MO_32, gen_helper_sme_addva_s) | ||
103 | TRANS_FEAT(ADDHA_d, aa64_sme_i16i64, do_adda, a, MO_64, gen_helper_sme_addha_d) | ||
104 | TRANS_FEAT(ADDVA_d, aa64_sme_i16i64, do_adda, a, MO_64, gen_helper_sme_addva_d) | ||
105 | |||
106 | +static bool do_outprod(DisasContext *s, arg_op *a, MemOp esz, | ||
107 | + gen_helper_gvec_5 *fn) | ||
108 | +{ | ||
109 | + int svl = streaming_vec_reg_size(s); | ||
110 | + uint32_t desc = simd_desc(svl, svl, a->sub); | ||
111 | + TCGv_ptr za, zn, zm, pn, pm; | ||
112 | + | ||
113 | + if (!sme_smza_enabled_check(s)) { | ||
114 | + return true; | ||
79 | + } | 115 | + } |
80 | + | 116 | + |
81 | +#define DO_VSHRN_ALL(OP, FN) \ | 117 | + /* Sum XZR+zad to find ZAd. */ |
82 | + DO_VSHRN(OP##bb, false, 1, uint8_t, 2, uint16_t, FN) \ | 118 | + za = get_tile_rowcol(s, esz, 31, a->zad, false); |
83 | + DO_VSHRN(OP##bh, false, 2, uint16_t, 4, uint32_t, FN) \ | 119 | + zn = vec_full_reg_ptr(s, a->zn); |
84 | + DO_VSHRN(OP##tb, true, 1, uint8_t, 2, uint16_t, FN) \ | 120 | + zm = vec_full_reg_ptr(s, a->zm); |
85 | + DO_VSHRN(OP##th, true, 2, uint16_t, 4, uint32_t, FN) | 121 | + pn = pred_full_reg_ptr(s, a->pn); |
122 | + pm = pred_full_reg_ptr(s, a->pm); | ||
86 | + | 123 | + |
87 | +static inline uint64_t do_urshr(uint64_t x, unsigned sh) | 124 | + fn(za, zn, zm, pn, pm, tcg_constant_i32(desc)); |
88 | +{ | 125 | + |
89 | + if (likely(sh < 64)) { | 126 | + tcg_temp_free_ptr(za); |
90 | + return (x >> sh) + ((x >> (sh - 1)) & 1); | 127 | + tcg_temp_free_ptr(zn); |
91 | + } else if (sh == 64) { | 128 | + tcg_temp_free_ptr(pn); |
92 | + return x >> 63; | 129 | + tcg_temp_free_ptr(pm); |
93 | + } else { | 130 | + return true; |
94 | + return 0; | ||
95 | + } | ||
96 | +} | 131 | +} |
97 | + | 132 | + |
98 | +DO_VSHRN_ALL(vshrn, DO_SHR) | 133 | static bool do_outprod_fpst(DisasContext *s, arg_op *a, MemOp esz, |
99 | +DO_VSHRN_ALL(vrshrn, do_urshr) | 134 | gen_helper_gvec_5_ptr *fn) |
100 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | 135 | { |
101 | index XXXXXXX..XXXXXXX 100644 | 136 | @@ -XXX,XX +XXX,XX @@ static bool do_outprod_fpst(DisasContext *s, arg_op *a, MemOp esz, |
102 | --- a/target/arm/translate-mve.c | 137 | |
103 | +++ b/target/arm/translate-mve.c | 138 | TRANS_FEAT(FMOPA_s, aa64_sme, do_outprod_fpst, a, MO_32, gen_helper_sme_fmopa_s) |
104 | @@ -XXX,XX +XXX,XX @@ DO_VSHLL(VSHLL_BS, vshllbs) | 139 | TRANS_FEAT(FMOPA_d, aa64_sme_f64f64, do_outprod_fpst, a, MO_64, gen_helper_sme_fmopa_d) |
105 | DO_VSHLL(VSHLL_BU, vshllbu) | ||
106 | DO_VSHLL(VSHLL_TS, vshllts) | ||
107 | DO_VSHLL(VSHLL_TU, vshlltu) | ||
108 | + | 140 | + |
109 | +#define DO_2SHIFT_N(INSN, FN) \ | 141 | +/* TODO: FEAT_EBF16 */ |
110 | + static bool trans_##INSN(DisasContext *s, arg_2shift *a) \ | 142 | +TRANS_FEAT(BFMOPA, aa64_sme, do_outprod, a, MO_32, gen_helper_sme_bfmopa) |
111 | + { \ | ||
112 | + static MVEGenTwoOpShiftFn * const fns[] = { \ | ||
113 | + gen_helper_mve_##FN##b, \ | ||
114 | + gen_helper_mve_##FN##h, \ | ||
115 | + }; \ | ||
116 | + return do_2shift(s, a, fns[a->size], false); \ | ||
117 | + } | ||
118 | + | ||
119 | +DO_2SHIFT_N(VSHRNB, vshrnb) | ||
120 | +DO_2SHIFT_N(VSHRNT, vshrnt) | ||
121 | +DO_2SHIFT_N(VRSHRNB, vrshrnb) | ||
122 | +DO_2SHIFT_N(VRSHRNT, vrshrnt) | ||
123 | -- | 143 | -- |
124 | 2.20.1 | 144 | 2.25.1 |
125 | |||
126 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Message-id: 20220708151540.18136-27-richard.henderson@linaro.org | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | target/arm/helper-sme.h | 2 ++ | ||
9 | target/arm/sme.decode | 1 + | ||
10 | target/arm/sme_helper.c | 74 ++++++++++++++++++++++++++++++++++++++ | ||
11 | target/arm/translate-sme.c | 1 + | ||
12 | 4 files changed, 78 insertions(+) | ||
13 | |||
14 | diff --git a/target/arm/helper-sme.h b/target/arm/helper-sme.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/helper-sme.h | ||
17 | +++ b/target/arm/helper-sme.h | ||
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_5(sme_addva_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) | ||
19 | DEF_HELPER_FLAGS_5(sme_addha_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) | ||
20 | DEF_HELPER_FLAGS_5(sme_addva_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) | ||
21 | |||
22 | +DEF_HELPER_FLAGS_7(sme_fmopa_h, TCG_CALL_NO_RWG, | ||
23 | + void, ptr, ptr, ptr, ptr, ptr, ptr, i32) | ||
24 | DEF_HELPER_FLAGS_7(sme_fmopa_s, TCG_CALL_NO_RWG, | ||
25 | void, ptr, ptr, ptr, ptr, ptr, ptr, i32) | ||
26 | DEF_HELPER_FLAGS_7(sme_fmopa_d, TCG_CALL_NO_RWG, | ||
27 | diff --git a/target/arm/sme.decode b/target/arm/sme.decode | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/target/arm/sme.decode | ||
30 | +++ b/target/arm/sme.decode | ||
31 | @@ -XXX,XX +XXX,XX @@ FMOPA_s 10000000 100 ..... ... ... ..... . 00 .. @op_32 | ||
32 | FMOPA_d 10000000 110 ..... ... ... ..... . 0 ... @op_64 | ||
33 | |||
34 | BFMOPA 10000001 100 ..... ... ... ..... . 00 .. @op_32 | ||
35 | +FMOPA_h 10000001 101 ..... ... ... ..... . 00 .. @op_32 | ||
36 | diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/target/arm/sme_helper.c | ||
39 | +++ b/target/arm/sme_helper.c | ||
40 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t f16mop_adj_pair(uint32_t pair, uint32_t pg, uint32_t neg) | ||
41 | return pair; | ||
42 | } | ||
43 | |||
44 | +static float32 f16_dotadd(float32 sum, uint32_t e1, uint32_t e2, | ||
45 | + float_status *s_std, float_status *s_odd) | ||
46 | +{ | ||
47 | + float64 e1r = float16_to_float64(e1 & 0xffff, true, s_std); | ||
48 | + float64 e1c = float16_to_float64(e1 >> 16, true, s_std); | ||
49 | + float64 e2r = float16_to_float64(e2 & 0xffff, true, s_std); | ||
50 | + float64 e2c = float16_to_float64(e2 >> 16, true, s_std); | ||
51 | + float64 t64; | ||
52 | + float32 t32; | ||
53 | + | ||
54 | + /* | ||
55 | + * The ARM pseudocode function FPDot performs both multiplies | ||
56 | + * and the add with a single rounding operation. Emulate this | ||
57 | + * by performing the first multiply in round-to-odd, then doing | ||
58 | + * the second multiply as fused multiply-add, and rounding to | ||
59 | + * float32 all in one step. | ||
60 | + */ | ||
61 | + t64 = float64_mul(e1r, e2r, s_odd); | ||
62 | + t64 = float64r32_muladd(e1c, e2c, t64, 0, s_std); | ||
63 | + | ||
64 | + /* This conversion is exact, because we've already rounded. */ | ||
65 | + t32 = float64_to_float32(t64, s_std); | ||
66 | + | ||
67 | + /* The final accumulation step is not fused. */ | ||
68 | + return float32_add(sum, t32, s_std); | ||
69 | +} | ||
70 | + | ||
71 | +void HELPER(sme_fmopa_h)(void *vza, void *vzn, void *vzm, void *vpn, | ||
72 | + void *vpm, void *vst, uint32_t desc) | ||
73 | +{ | ||
74 | + intptr_t row, col, oprsz = simd_maxsz(desc); | ||
75 | + uint32_t neg = simd_data(desc) * 0x80008000u; | ||
76 | + uint16_t *pn = vpn, *pm = vpm; | ||
77 | + float_status fpst_odd, fpst_std; | ||
78 | + | ||
79 | + /* | ||
80 | + * Make a copy of float_status because this operation does not | ||
81 | + * update the cumulative fp exception status. It also produces | ||
82 | + * default nans. Make a second copy with round-to-odd -- see above. | ||
83 | + */ | ||
84 | + fpst_std = *(float_status *)vst; | ||
85 | + set_default_nan_mode(true, &fpst_std); | ||
86 | + fpst_odd = fpst_std; | ||
87 | + set_float_rounding_mode(float_round_to_odd, &fpst_odd); | ||
88 | + | ||
89 | + for (row = 0; row < oprsz; ) { | ||
90 | + uint16_t prow = pn[H2(row >> 4)]; | ||
91 | + do { | ||
92 | + void *vza_row = vza + tile_vslice_offset(row); | ||
93 | + uint32_t n = *(uint32_t *)(vzn + H1_4(row)); | ||
94 | + | ||
95 | + n = f16mop_adj_pair(n, prow, neg); | ||
96 | + | ||
97 | + for (col = 0; col < oprsz; ) { | ||
98 | + uint16_t pcol = pm[H2(col >> 4)]; | ||
99 | + do { | ||
100 | + if (prow & pcol & 0b0101) { | ||
101 | + uint32_t *a = vza_row + H1_4(col); | ||
102 | + uint32_t m = *(uint32_t *)(vzm + H1_4(col)); | ||
103 | + | ||
104 | + m = f16mop_adj_pair(m, pcol, 0); | ||
105 | + *a = f16_dotadd(*a, n, m, &fpst_std, &fpst_odd); | ||
106 | + | ||
107 | + col += 4; | ||
108 | + pcol >>= 4; | ||
109 | + } | ||
110 | + } while (col & 15); | ||
111 | + } | ||
112 | + row += 4; | ||
113 | + prow >>= 4; | ||
114 | + } while (row & 15); | ||
115 | + } | ||
116 | +} | ||
117 | + | ||
118 | void HELPER(sme_bfmopa)(void *vza, void *vzn, void *vzm, void *vpn, | ||
119 | void *vpm, uint32_t desc) | ||
120 | { | ||
121 | diff --git a/target/arm/translate-sme.c b/target/arm/translate-sme.c | ||
122 | index XXXXXXX..XXXXXXX 100644 | ||
123 | --- a/target/arm/translate-sme.c | ||
124 | +++ b/target/arm/translate-sme.c | ||
125 | @@ -XXX,XX +XXX,XX @@ static bool do_outprod_fpst(DisasContext *s, arg_op *a, MemOp esz, | ||
126 | return true; | ||
127 | } | ||
128 | |||
129 | +TRANS_FEAT(FMOPA_h, aa64_sme, do_outprod_fpst, a, MO_32, gen_helper_sme_fmopa_h) | ||
130 | TRANS_FEAT(FMOPA_s, aa64_sme, do_outprod_fpst, a, MO_32, gen_helper_sme_fmopa_s) | ||
131 | TRANS_FEAT(FMOPA_d, aa64_sme_f64f64, do_outprod_fpst, a, MO_64, gen_helper_sme_fmopa_d) | ||
132 | |||
133 | -- | ||
134 | 2.25.1 | diff view generated by jsdifflib |
1 | Implement the MVE VHLL (vector shift left long) insn. This has two | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | encodings: the T1 encoding is the usual shift-by-immediate format, | ||
3 | and the T2 encoding is a special case where the shift count is always | ||
4 | equal to the element size. | ||
5 | 2 | ||
3 | This is SMOPA, SUMOPA, USMOPA_s, UMOPA, for both Int8 and Int16. | ||
4 | |||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20220708151540.18136-28-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210628135835.6690-10-peter.maydell@linaro.org | ||
9 | --- | 9 | --- |
10 | target/arm/helper-mve.h | 9 +++++++ | 10 | target/arm/helper-sme.h | 16 ++++++++ |
11 | target/arm/mve.decode | 53 +++++++++++++++++++++++++++++++++++--- | 11 | target/arm/sme.decode | 10 +++++ |
12 | target/arm/mve_helper.c | 32 +++++++++++++++++++++++ | 12 | target/arm/sme_helper.c | 82 ++++++++++++++++++++++++++++++++++++++ |
13 | target/arm/translate-mve.c | 15 +++++++++++ | 13 | target/arm/translate-sme.c | 10 +++++ |
14 | 4 files changed, 105 insertions(+), 4 deletions(-) | 14 | 4 files changed, 118 insertions(+) |
15 | 15 | ||
16 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 16 | diff --git a/target/arm/helper-sme.h b/target/arm/helper-sme.h |
17 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/helper-mve.h | 18 | --- a/target/arm/helper-sme.h |
19 | +++ b/target/arm/helper-mve.h | 19 | +++ b/target/arm/helper-sme.h |
20 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vrshli_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 20 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_7(sme_fmopa_d, TCG_CALL_NO_RWG, |
21 | DEF_HELPER_FLAGS_4(mve_vrshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 21 | void, ptr, ptr, ptr, ptr, ptr, ptr, i32) |
22 | DEF_HELPER_FLAGS_4(mve_vrshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 22 | DEF_HELPER_FLAGS_6(sme_bfmopa, TCG_CALL_NO_RWG, |
23 | DEF_HELPER_FLAGS_4(mve_vrshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 23 | void, ptr, ptr, ptr, ptr, ptr, i32) |
24 | +DEF_HELPER_FLAGS_6(sme_smopa_s, TCG_CALL_NO_RWG, | ||
25 | + void, ptr, ptr, ptr, ptr, ptr, i32) | ||
26 | +DEF_HELPER_FLAGS_6(sme_umopa_s, TCG_CALL_NO_RWG, | ||
27 | + void, ptr, ptr, ptr, ptr, ptr, i32) | ||
28 | +DEF_HELPER_FLAGS_6(sme_sumopa_s, TCG_CALL_NO_RWG, | ||
29 | + void, ptr, ptr, ptr, ptr, ptr, i32) | ||
30 | +DEF_HELPER_FLAGS_6(sme_usmopa_s, TCG_CALL_NO_RWG, | ||
31 | + void, ptr, ptr, ptr, ptr, ptr, i32) | ||
32 | +DEF_HELPER_FLAGS_6(sme_smopa_d, TCG_CALL_NO_RWG, | ||
33 | + void, ptr, ptr, ptr, ptr, ptr, i32) | ||
34 | +DEF_HELPER_FLAGS_6(sme_umopa_d, TCG_CALL_NO_RWG, | ||
35 | + void, ptr, ptr, ptr, ptr, ptr, i32) | ||
36 | +DEF_HELPER_FLAGS_6(sme_sumopa_d, TCG_CALL_NO_RWG, | ||
37 | + void, ptr, ptr, ptr, ptr, ptr, i32) | ||
38 | +DEF_HELPER_FLAGS_6(sme_usmopa_d, TCG_CALL_NO_RWG, | ||
39 | + void, ptr, ptr, ptr, ptr, ptr, i32) | ||
40 | diff --git a/target/arm/sme.decode b/target/arm/sme.decode | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/target/arm/sme.decode | ||
43 | +++ b/target/arm/sme.decode | ||
44 | @@ -XXX,XX +XXX,XX @@ FMOPA_d 10000000 110 ..... ... ... ..... . 0 ... @op_64 | ||
45 | |||
46 | BFMOPA 10000001 100 ..... ... ... ..... . 00 .. @op_32 | ||
47 | FMOPA_h 10000001 101 ..... ... ... ..... . 00 .. @op_32 | ||
24 | + | 48 | + |
25 | +DEF_HELPER_FLAGS_4(mve_vshllbsb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 49 | +SMOPA_s 1010000 0 10 0 ..... ... ... ..... . 00 .. @op_32 |
26 | +DEF_HELPER_FLAGS_4(mve_vshllbsh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 50 | +SUMOPA_s 1010000 0 10 1 ..... ... ... ..... . 00 .. @op_32 |
27 | +DEF_HELPER_FLAGS_4(mve_vshllbub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 51 | +USMOPA_s 1010000 1 10 0 ..... ... ... ..... . 00 .. @op_32 |
28 | +DEF_HELPER_FLAGS_4(mve_vshllbuh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 52 | +UMOPA_s 1010000 1 10 1 ..... ... ... ..... . 00 .. @op_32 |
29 | +DEF_HELPER_FLAGS_4(mve_vshlltsb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 53 | + |
30 | +DEF_HELPER_FLAGS_4(mve_vshlltsh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 54 | +SMOPA_d 1010000 0 11 0 ..... ... ... ..... . 0 ... @op_64 |
31 | +DEF_HELPER_FLAGS_4(mve_vshlltub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 55 | +SUMOPA_d 1010000 0 11 1 ..... ... ... ..... . 0 ... @op_64 |
32 | +DEF_HELPER_FLAGS_4(mve_vshlltuh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 56 | +USMOPA_d 1010000 1 11 0 ..... ... ... ..... . 0 ... @op_64 |
33 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | 57 | +UMOPA_d 1010000 1 11 1 ..... ... ... ..... . 0 ... @op_64 |
58 | diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | 59 | index XXXXXXX..XXXXXXX 100644 |
35 | --- a/target/arm/mve.decode | 60 | --- a/target/arm/sme_helper.c |
36 | +++ b/target/arm/mve.decode | 61 | +++ b/target/arm/sme_helper.c |
37 | @@ -XXX,XX +XXX,XX @@ | 62 | @@ -XXX,XX +XXX,XX @@ void HELPER(sme_bfmopa)(void *vza, void *vzn, void *vzm, void *vpn, |
38 | @2_shl_h .... .... .. 01 shift:4 .... .... .... .... &2shift qd=%qd qm=%qm size=1 | 63 | } while (row & 15); |
39 | @2_shl_w .... .... .. 1 shift:5 .... .... .... .... &2shift qd=%qd qm=%qm size=2 | 64 | } |
40 | 65 | } | |
41 | +@2_shll_b .... .... ... 01 shift:3 .... .... .... .... &2shift qd=%qd qm=%qm size=0 | ||
42 | +@2_shll_h .... .... ... 1 shift:4 .... .... .... .... &2shift qd=%qd qm=%qm size=1 | ||
43 | +# VSHLL encoding T2 where shift == esize | ||
44 | +@2_shll_esize_b .... .... .... 00 .. .... .... .... .... &2shift \ | ||
45 | + qd=%qd qm=%qm size=0 shift=8 | ||
46 | +@2_shll_esize_h .... .... .... 01 .. .... .... .... .... &2shift \ | ||
47 | + qd=%qd qm=%qm size=1 shift=16 | ||
48 | + | 66 | + |
49 | # Right shifts are encoded as N - shift, where N is the element size in bits. | 67 | +typedef uint64_t IMOPFn(uint64_t, uint64_t, uint64_t, uint8_t, bool); |
50 | %rshift_i5 16:5 !function=rsub_32 | 68 | + |
51 | %rshift_i4 16:4 !function=rsub_16 | 69 | +static inline void do_imopa(uint64_t *za, uint64_t *zn, uint64_t *zm, |
52 | @@ -XXX,XX +XXX,XX @@ VADD 1110 1111 0 . .. ... 0 ... 0 1000 . 1 . 0 ... 0 @2op | 70 | + uint8_t *pn, uint8_t *pm, |
53 | VSUB 1111 1111 0 . .. ... 0 ... 0 1000 . 1 . 0 ... 0 @2op | 71 | + uint32_t desc, IMOPFn *fn) |
54 | VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op | ||
55 | |||
56 | -VMULH_S 111 0 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op | ||
57 | -VMULH_U 111 1 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op | ||
58 | +# The VSHLL T2 encoding is not a @2op pattern, but is here because it | ||
59 | +# overlaps what would be size=0b11 VMULH/VRMULH | ||
60 | +{ | 72 | +{ |
61 | + VSHLL_BS 111 0 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_b | 73 | + intptr_t row, col, oprsz = simd_oprsz(desc) / 8; |
62 | + VSHLL_BS 111 0 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_h | 74 | + bool neg = simd_data(desc); |
63 | 75 | + | |
64 | -VRMULH_S 111 0 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op | 76 | + for (row = 0; row < oprsz; ++row) { |
65 | -VRMULH_U 111 1 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op | 77 | + uint8_t pa = pn[H1(row)]; |
66 | + VMULH_S 111 0 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op | 78 | + uint64_t *za_row = &za[tile_vslice_index(row)]; |
79 | + uint64_t n = zn[row]; | ||
80 | + | ||
81 | + for (col = 0; col < oprsz; ++col) { | ||
82 | + uint8_t pb = pm[H1(col)]; | ||
83 | + uint64_t *a = &za_row[col]; | ||
84 | + | ||
85 | + *a = fn(n, zm[col], *a, pa & pb, neg); | ||
86 | + } | ||
87 | + } | ||
67 | +} | 88 | +} |
68 | + | 89 | + |
69 | +{ | 90 | +#define DEF_IMOP_32(NAME, NTYPE, MTYPE) \ |
70 | + VSHLL_BU 111 1 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_b | 91 | +static uint64_t NAME(uint64_t n, uint64_t m, uint64_t a, uint8_t p, bool neg) \ |
71 | + VSHLL_BU 111 1 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_h | 92 | +{ \ |
72 | + | 93 | + uint32_t sum0 = 0, sum1 = 0; \ |
73 | + VMULH_U 111 1 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op | 94 | + /* Apply P to N as a mask, making the inactive elements 0. */ \ |
95 | + n &= expand_pred_b(p); \ | ||
96 | + sum0 += (NTYPE)(n >> 0) * (MTYPE)(m >> 0); \ | ||
97 | + sum0 += (NTYPE)(n >> 8) * (MTYPE)(m >> 8); \ | ||
98 | + sum0 += (NTYPE)(n >> 16) * (MTYPE)(m >> 16); \ | ||
99 | + sum0 += (NTYPE)(n >> 24) * (MTYPE)(m >> 24); \ | ||
100 | + sum1 += (NTYPE)(n >> 32) * (MTYPE)(m >> 32); \ | ||
101 | + sum1 += (NTYPE)(n >> 40) * (MTYPE)(m >> 40); \ | ||
102 | + sum1 += (NTYPE)(n >> 48) * (MTYPE)(m >> 48); \ | ||
103 | + sum1 += (NTYPE)(n >> 56) * (MTYPE)(m >> 56); \ | ||
104 | + if (neg) { \ | ||
105 | + sum0 = (uint32_t)a - sum0, sum1 = (uint32_t)(a >> 32) - sum1; \ | ||
106 | + } else { \ | ||
107 | + sum0 = (uint32_t)a + sum0, sum1 = (uint32_t)(a >> 32) + sum1; \ | ||
108 | + } \ | ||
109 | + return ((uint64_t)sum1 << 32) | sum0; \ | ||
74 | +} | 110 | +} |
75 | + | 111 | + |
76 | +{ | 112 | +#define DEF_IMOP_64(NAME, NTYPE, MTYPE) \ |
77 | + VSHLL_TS 111 0 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_b | 113 | +static uint64_t NAME(uint64_t n, uint64_t m, uint64_t a, uint8_t p, bool neg) \ |
78 | + VSHLL_TS 111 0 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_h | 114 | +{ \ |
79 | + | 115 | + uint64_t sum = 0; \ |
80 | + VRMULH_S 111 0 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op | 116 | + /* Apply P to N as a mask, making the inactive elements 0. */ \ |
117 | + n &= expand_pred_h(p); \ | ||
118 | + sum += (NTYPE)(n >> 0) * (MTYPE)(m >> 0); \ | ||
119 | + sum += (NTYPE)(n >> 16) * (MTYPE)(m >> 16); \ | ||
120 | + sum += (NTYPE)(n >> 32) * (MTYPE)(m >> 32); \ | ||
121 | + sum += (NTYPE)(n >> 48) * (MTYPE)(m >> 48); \ | ||
122 | + return neg ? a - sum : a + sum; \ | ||
81 | +} | 123 | +} |
82 | + | 124 | + |
83 | +{ | 125 | +DEF_IMOP_32(smopa_s, int8_t, int8_t) |
84 | + VSHLL_TU 111 1 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_b | 126 | +DEF_IMOP_32(umopa_s, uint8_t, uint8_t) |
85 | + VSHLL_TU 111 1 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_h | 127 | +DEF_IMOP_32(sumopa_s, int8_t, uint8_t) |
128 | +DEF_IMOP_32(usmopa_s, uint8_t, int8_t) | ||
86 | + | 129 | + |
87 | + VRMULH_U 111 1 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op | 130 | +DEF_IMOP_64(smopa_d, int16_t, int16_t) |
88 | +} | 131 | +DEF_IMOP_64(umopa_d, uint16_t, uint16_t) |
89 | 132 | +DEF_IMOP_64(sumopa_d, int16_t, uint16_t) | |
90 | VMAX_S 111 0 1111 0 . .. ... 0 ... 0 0110 . 1 . 0 ... 0 @2op | 133 | +DEF_IMOP_64(usmopa_d, uint16_t, int16_t) |
91 | VMAX_U 111 1 1111 0 . .. ... 0 ... 0 0110 . 1 . 0 ... 0 @2op | ||
92 | @@ -XXX,XX +XXX,XX @@ VRSHRI_S 111 0 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_w | ||
93 | VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_b | ||
94 | VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_h | ||
95 | VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_w | ||
96 | + | 134 | + |
97 | +# VSHLL T1 encoding; the T2 VSHLL encoding is elsewhere in this file | 135 | +#define DEF_IMOPH(NAME) \ |
98 | +VSHLL_BS 111 0 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_b | 136 | + void HELPER(sme_##NAME)(void *vza, void *vzn, void *vzm, void *vpn, \ |
99 | +VSHLL_BS 111 0 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_h | 137 | + void *vpm, uint32_t desc) \ |
138 | + { do_imopa(vza, vzn, vzm, vpn, vpm, desc, NAME); } | ||
100 | + | 139 | + |
101 | +VSHLL_BU 111 1 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_b | 140 | +DEF_IMOPH(smopa_s) |
102 | +VSHLL_BU 111 1 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_h | 141 | +DEF_IMOPH(umopa_s) |
142 | +DEF_IMOPH(sumopa_s) | ||
143 | +DEF_IMOPH(usmopa_s) | ||
144 | +DEF_IMOPH(smopa_d) | ||
145 | +DEF_IMOPH(umopa_d) | ||
146 | +DEF_IMOPH(sumopa_d) | ||
147 | +DEF_IMOPH(usmopa_d) | ||
148 | diff --git a/target/arm/translate-sme.c b/target/arm/translate-sme.c | ||
149 | index XXXXXXX..XXXXXXX 100644 | ||
150 | --- a/target/arm/translate-sme.c | ||
151 | +++ b/target/arm/translate-sme.c | ||
152 | @@ -XXX,XX +XXX,XX @@ TRANS_FEAT(FMOPA_d, aa64_sme_f64f64, do_outprod_fpst, a, MO_64, gen_helper_sme_f | ||
153 | |||
154 | /* TODO: FEAT_EBF16 */ | ||
155 | TRANS_FEAT(BFMOPA, aa64_sme, do_outprod, a, MO_32, gen_helper_sme_bfmopa) | ||
103 | + | 156 | + |
104 | +VSHLL_TS 111 0 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_b | 157 | +TRANS_FEAT(SMOPA_s, aa64_sme, do_outprod, a, MO_32, gen_helper_sme_smopa_s) |
105 | +VSHLL_TS 111 0 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_h | 158 | +TRANS_FEAT(UMOPA_s, aa64_sme, do_outprod, a, MO_32, gen_helper_sme_umopa_s) |
159 | +TRANS_FEAT(SUMOPA_s, aa64_sme, do_outprod, a, MO_32, gen_helper_sme_sumopa_s) | ||
160 | +TRANS_FEAT(USMOPA_s, aa64_sme, do_outprod, a, MO_32, gen_helper_sme_usmopa_s) | ||
106 | + | 161 | + |
107 | +VSHLL_TU 111 1 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_b | 162 | +TRANS_FEAT(SMOPA_d, aa64_sme_i16i64, do_outprod, a, MO_64, gen_helper_sme_smopa_d) |
108 | +VSHLL_TU 111 1 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_h | 163 | +TRANS_FEAT(UMOPA_d, aa64_sme_i16i64, do_outprod, a, MO_64, gen_helper_sme_umopa_d) |
109 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | 164 | +TRANS_FEAT(SUMOPA_d, aa64_sme_i16i64, do_outprod, a, MO_64, gen_helper_sme_sumopa_d) |
110 | index XXXXXXX..XXXXXXX 100644 | 165 | +TRANS_FEAT(USMOPA_d, aa64_sme_i16i64, do_outprod, a, MO_64, gen_helper_sme_usmopa_d) |
111 | --- a/target/arm/mve_helper.c | ||
112 | +++ b/target/arm/mve_helper.c | ||
113 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT_SAT_S(vqshli_s, DO_SQSHL_OP) | ||
114 | DO_2SHIFT_SAT_S(vqshlui_s, DO_SUQSHL_OP) | ||
115 | DO_2SHIFT_U(vrshli_u, DO_VRSHLU) | ||
116 | DO_2SHIFT_S(vrshli_s, DO_VRSHLS) | ||
117 | + | ||
118 | +/* | ||
119 | + * Long shifts taking half-sized inputs from top or bottom of the input | ||
120 | + * vector and producing a double-width result. ESIZE, TYPE are for | ||
121 | + * the input, and LESIZE, LTYPE for the output. | ||
122 | + * Unlike the normal shift helpers, we do not handle negative shift counts, | ||
123 | + * because the long shift is strictly left-only. | ||
124 | + */ | ||
125 | +#define DO_VSHLL(OP, TOP, ESIZE, TYPE, LESIZE, LTYPE) \ | ||
126 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ | ||
127 | + void *vm, uint32_t shift) \ | ||
128 | + { \ | ||
129 | + LTYPE *d = vd; \ | ||
130 | + TYPE *m = vm; \ | ||
131 | + uint16_t mask = mve_element_mask(env); \ | ||
132 | + unsigned le; \ | ||
133 | + assert(shift <= 16); \ | ||
134 | + for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \ | ||
135 | + LTYPE r = (LTYPE)m[H##ESIZE(le * 2 + TOP)] << shift; \ | ||
136 | + mergemask(&d[H##LESIZE(le)], r, mask); \ | ||
137 | + } \ | ||
138 | + mve_advance_vpt(env); \ | ||
139 | + } | ||
140 | + | ||
141 | +#define DO_VSHLL_ALL(OP, TOP) \ | ||
142 | + DO_VSHLL(OP##sb, TOP, 1, int8_t, 2, int16_t) \ | ||
143 | + DO_VSHLL(OP##ub, TOP, 1, uint8_t, 2, uint16_t) \ | ||
144 | + DO_VSHLL(OP##sh, TOP, 2, int16_t, 4, int32_t) \ | ||
145 | + DO_VSHLL(OP##uh, TOP, 2, uint16_t, 4, uint32_t) \ | ||
146 | + | ||
147 | +DO_VSHLL_ALL(vshllb, false) | ||
148 | +DO_VSHLL_ALL(vshllt, true) | ||
149 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
150 | index XXXXXXX..XXXXXXX 100644 | ||
151 | --- a/target/arm/translate-mve.c | ||
152 | +++ b/target/arm/translate-mve.c | ||
153 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT(VSHRI_S, vshli_s, true) | ||
154 | DO_2SHIFT(VSHRI_U, vshli_u, true) | ||
155 | DO_2SHIFT(VRSHRI_S, vrshli_s, true) | ||
156 | DO_2SHIFT(VRSHRI_U, vrshli_u, true) | ||
157 | + | ||
158 | +#define DO_VSHLL(INSN, FN) \ | ||
159 | + static bool trans_##INSN(DisasContext *s, arg_2shift *a) \ | ||
160 | + { \ | ||
161 | + static MVEGenTwoOpShiftFn * const fns[] = { \ | ||
162 | + gen_helper_mve_##FN##b, \ | ||
163 | + gen_helper_mve_##FN##h, \ | ||
164 | + }; \ | ||
165 | + return do_2shift(s, a, fns[a->size], false); \ | ||
166 | + } | ||
167 | + | ||
168 | +DO_VSHLL(VSHLL_BS, vshllbs) | ||
169 | +DO_VSHLL(VSHLL_BU, vshllbu) | ||
170 | +DO_VSHLL(VSHLL_TS, vshllts) | ||
171 | +DO_VSHLL(VSHLL_TU, vshlltu) | ||
172 | -- | 166 | -- |
173 | 2.20.1 | 167 | 2.25.1 |
174 | |||
175 | diff view generated by jsdifflib |
1 | Implement the MVE VSHLC insn, which performs a shift left of the | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | entire vector with carry in bits provided from a general purpose | ||
3 | register and carry out bits written back to that register. | ||
4 | 2 | ||
3 | This is an SVE instruction that operates using the SVE vector | ||
4 | length but that it is present only if SME is implemented. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220708151540.18136-29-richard.henderson@linaro.org | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20210628135835.6690-14-peter.maydell@linaro.org | ||
8 | --- | 10 | --- |
9 | target/arm/helper-mve.h | 2 ++ | 11 | target/arm/sve.decode | 20 +++++++++++++ |
10 | target/arm/mve.decode | 2 ++ | 12 | target/arm/translate-sve.c | 57 ++++++++++++++++++++++++++++++++++++++ |
11 | target/arm/mve_helper.c | 38 ++++++++++++++++++++++++++++++++++++++ | 13 | 2 files changed, 77 insertions(+) |
12 | target/arm/translate-mve.c | 30 ++++++++++++++++++++++++++++++ | ||
13 | 4 files changed, 72 insertions(+) | ||
14 | 14 | ||
15 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 15 | diff --git a/target/arm/sve.decode b/target/arm/sve.decode |
16 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/helper-mve.h | 17 | --- a/target/arm/sve.decode |
18 | +++ b/target/arm/helper-mve.h | 18 | +++ b/target/arm/sve.decode |
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqrshrunbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 19 | @@ -XXX,XX +XXX,XX @@ BFMLALT_zzxw 01100100 11 1 ..... 0100.1 ..... ..... @rrxr_3a esz=2 |
20 | DEF_HELPER_FLAGS_4(mve_vqrshrunbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 20 | |
21 | DEF_HELPER_FLAGS_4(mve_vqrshruntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 21 | ### SVE2 floating-point bfloat16 dot-product (indexed) |
22 | DEF_HELPER_FLAGS_4(mve_vqrshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 22 | BFDOT_zzxz 01100100 01 1 ..... 010000 ..... ..... @rrxr_2 esz=2 |
23 | + | 23 | + |
24 | +DEF_HELPER_FLAGS_4(mve_vshlc, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) | 24 | +### SVE broadcast predicate element |
25 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | 25 | + |
26 | +&psel esz pd pn pm rv imm | ||
27 | +%psel_rv 16:2 !function=plus_12 | ||
28 | +%psel_imm_b 22:2 19:2 | ||
29 | +%psel_imm_h 22:2 20:1 | ||
30 | +%psel_imm_s 22:2 | ||
31 | +%psel_imm_d 23:1 | ||
32 | +@psel ........ .. . ... .. .. pn:4 . pm:4 . pd:4 \ | ||
33 | + &psel rv=%psel_rv | ||
34 | + | ||
35 | +PSEL 00100101 .. 1 ..1 .. 01 .... 0 .... 0 .... \ | ||
36 | + @psel esz=0 imm=%psel_imm_b | ||
37 | +PSEL 00100101 .. 1 .10 .. 01 .... 0 .... 0 .... \ | ||
38 | + @psel esz=1 imm=%psel_imm_h | ||
39 | +PSEL 00100101 .. 1 100 .. 01 .... 0 .... 0 .... \ | ||
40 | + @psel esz=2 imm=%psel_imm_s | ||
41 | +PSEL 00100101 .1 1 000 .. 01 .... 0 .... 0 .... \ | ||
42 | + @psel esz=3 imm=%psel_imm_d | ||
43 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | ||
26 | index XXXXXXX..XXXXXXX 100644 | 44 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/target/arm/mve.decode | 45 | --- a/target/arm/translate-sve.c |
28 | +++ b/target/arm/mve.decode | 46 | +++ b/target/arm/translate-sve.c |
29 | @@ -XXX,XX +XXX,XX @@ VQRSHRUNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_b | 47 | @@ -XXX,XX +XXX,XX @@ static bool do_BFMLAL_zzxw(DisasContext *s, arg_rrxr_esz *a, bool sel) |
30 | VQRSHRUNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_h | 48 | |
31 | VQRSHRUNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_b | 49 | TRANS_FEAT(BFMLALB_zzxw, aa64_sve_bf16, do_BFMLAL_zzxw, a, false) |
32 | VQRSHRUNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_h | 50 | TRANS_FEAT(BFMLALT_zzxw, aa64_sve_bf16, do_BFMLAL_zzxw, a, true) |
33 | + | 51 | + |
34 | +VSHLC 111 0 1110 1 . 1 imm:5 ... 0 1111 1100 rdm:4 qd=%qd | 52 | +static bool trans_PSEL(DisasContext *s, arg_psel *a) |
35 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | 53 | +{ |
36 | index XXXXXXX..XXXXXXX 100644 | 54 | + int vl = vec_full_reg_size(s); |
37 | --- a/target/arm/mve_helper.c | 55 | + int pl = pred_gvec_reg_size(s); |
38 | +++ b/target/arm/mve_helper.c | 56 | + int elements = vl >> a->esz; |
39 | @@ -XXX,XX +XXX,XX @@ DO_VSHRN_SAT_UB(vqrshrnb_ub, vqrshrnt_ub, DO_RSHRN_UB) | 57 | + TCGv_i64 tmp, didx, dbit; |
40 | DO_VSHRN_SAT_UH(vqrshrnb_uh, vqrshrnt_uh, DO_RSHRN_UH) | 58 | + TCGv_ptr ptr; |
41 | DO_VSHRN_SAT_SB(vqrshrunbb, vqrshruntb, DO_RSHRUN_B) | ||
42 | DO_VSHRN_SAT_SH(vqrshrunbh, vqrshrunth, DO_RSHRUN_H) | ||
43 | + | 59 | + |
44 | +uint32_t HELPER(mve_vshlc)(CPUARMState *env, void *vd, uint32_t rdm, | 60 | + if (!dc_isar_feature(aa64_sme, s)) { |
45 | + uint32_t shift) | ||
46 | +{ | ||
47 | + uint32_t *d = vd; | ||
48 | + uint16_t mask = mve_element_mask(env); | ||
49 | + unsigned e; | ||
50 | + uint32_t r; | ||
51 | + | ||
52 | + /* | ||
53 | + * For each 32-bit element, we shift it left, bringing in the | ||
54 | + * low 'shift' bits of rdm at the bottom. Bits shifted out at | ||
55 | + * the top become the new rdm, if the predicate mask permits. | ||
56 | + * The final rdm value is returned to update the register. | ||
57 | + * shift == 0 here means "shift by 32 bits". | ||
58 | + */ | ||
59 | + if (shift == 0) { | ||
60 | + for (e = 0; e < 16 / 4; e++, mask >>= 4) { | ||
61 | + r = rdm; | ||
62 | + if (mask & 1) { | ||
63 | + rdm = d[H4(e)]; | ||
64 | + } | ||
65 | + mergemask(&d[H4(e)], r, mask); | ||
66 | + } | ||
67 | + } else { | ||
68 | + uint32_t shiftmask = MAKE_64BIT_MASK(0, shift); | ||
69 | + | ||
70 | + for (e = 0; e < 16 / 4; e++, mask >>= 4) { | ||
71 | + r = (d[H4(e)] << shift) | (rdm & shiftmask); | ||
72 | + if (mask & 1) { | ||
73 | + rdm = d[H4(e)] >> (32 - shift); | ||
74 | + } | ||
75 | + mergemask(&d[H4(e)], r, mask); | ||
76 | + } | ||
77 | + } | ||
78 | + mve_advance_vpt(env); | ||
79 | + return rdm; | ||
80 | +} | ||
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_2SHIFT_N(VQRSHRNB_U, vqrshrnb_u) | ||
86 | DO_2SHIFT_N(VQRSHRNT_U, vqrshrnt_u) | ||
87 | DO_2SHIFT_N(VQRSHRUNB, vqrshrunb) | ||
88 | DO_2SHIFT_N(VQRSHRUNT, vqrshrunt) | ||
89 | + | ||
90 | +static bool trans_VSHLC(DisasContext *s, arg_VSHLC *a) | ||
91 | +{ | ||
92 | + /* | ||
93 | + * Whole Vector Left Shift with Carry. The carry is taken | ||
94 | + * from a general purpose register and written back there. | ||
95 | + * An imm of 0 means "shift by 32". | ||
96 | + */ | ||
97 | + TCGv_ptr qd; | ||
98 | + TCGv_i32 rdm; | ||
99 | + | ||
100 | + if (!dc_isar_feature(aa32_mve, s) || !mve_check_qreg_bank(s, a->qd)) { | ||
101 | + return false; | 61 | + return false; |
102 | + } | 62 | + } |
103 | + if (a->rdm == 13 || a->rdm == 15) { | 63 | + if (!sve_access_check(s)) { |
104 | + /* CONSTRAINED UNPREDICTABLE: we UNDEF */ | ||
105 | + return false; | ||
106 | + } | ||
107 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
108 | + return true; | 64 | + return true; |
109 | + } | 65 | + } |
110 | + | 66 | + |
111 | + qd = mve_qreg_ptr(a->qd); | 67 | + tmp = tcg_temp_new_i64(); |
112 | + rdm = load_reg(s, a->rdm); | 68 | + dbit = tcg_temp_new_i64(); |
113 | + gen_helper_mve_vshlc(rdm, cpu_env, qd, rdm, tcg_constant_i32(a->imm)); | 69 | + didx = tcg_temp_new_i64(); |
114 | + store_reg(s, a->rdm, rdm); | 70 | + ptr = tcg_temp_new_ptr(); |
115 | + tcg_temp_free_ptr(qd); | 71 | + |
116 | + mve_update_eci(s); | 72 | + /* Compute the predicate element. */ |
73 | + tcg_gen_addi_i64(tmp, cpu_reg(s, a->rv), a->imm); | ||
74 | + if (is_power_of_2(elements)) { | ||
75 | + tcg_gen_andi_i64(tmp, tmp, elements - 1); | ||
76 | + } else { | ||
77 | + tcg_gen_remu_i64(tmp, tmp, tcg_constant_i64(elements)); | ||
78 | + } | ||
79 | + | ||
80 | + /* Extract the predicate byte and bit indices. */ | ||
81 | + tcg_gen_shli_i64(tmp, tmp, a->esz); | ||
82 | + tcg_gen_andi_i64(dbit, tmp, 7); | ||
83 | + tcg_gen_shri_i64(didx, tmp, 3); | ||
84 | + if (HOST_BIG_ENDIAN) { | ||
85 | + tcg_gen_xori_i64(didx, didx, 7); | ||
86 | + } | ||
87 | + | ||
88 | + /* Load the predicate word. */ | ||
89 | + tcg_gen_trunc_i64_ptr(ptr, didx); | ||
90 | + tcg_gen_add_ptr(ptr, ptr, cpu_env); | ||
91 | + tcg_gen_ld8u_i64(tmp, ptr, pred_full_reg_offset(s, a->pm)); | ||
92 | + | ||
93 | + /* Extract the predicate bit and replicate to MO_64. */ | ||
94 | + tcg_gen_shr_i64(tmp, tmp, dbit); | ||
95 | + tcg_gen_andi_i64(tmp, tmp, 1); | ||
96 | + tcg_gen_neg_i64(tmp, tmp); | ||
97 | + | ||
98 | + /* Apply to either copy the source, or write zeros. */ | ||
99 | + tcg_gen_gvec_ands(MO_64, pred_full_reg_offset(s, a->pd), | ||
100 | + pred_full_reg_offset(s, a->pn), tmp, pl, pl); | ||
101 | + | ||
102 | + tcg_temp_free_i64(tmp); | ||
103 | + tcg_temp_free_i64(dbit); | ||
104 | + tcg_temp_free_i64(didx); | ||
105 | + tcg_temp_free_ptr(ptr); | ||
117 | + return true; | 106 | + return true; |
118 | +} | 107 | +} |
119 | -- | 108 | -- |
120 | 2.20.1 | 109 | 2.25.1 |
121 | |||
122 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | This is an SVE instruction that operates using the SVE vector | ||
4 | length but that it is present only if SME is implemented. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220708151540.18136-30-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/helper-sve.h | 2 ++ | ||
12 | target/arm/sve.decode | 1 + | ||
13 | target/arm/sve_helper.c | 16 ++++++++++++++++ | ||
14 | target/arm/translate-sve.c | 2 ++ | ||
15 | 4 files changed, 21 insertions(+) | ||
16 | |||
17 | diff --git a/target/arm/helper-sve.h b/target/arm/helper-sve.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/helper-sve.h | ||
20 | +++ b/target/arm/helper-sve.h | ||
21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(sve_revh_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
22 | |||
23 | DEF_HELPER_FLAGS_4(sve_revw_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
24 | |||
25 | +DEF_HELPER_FLAGS_4(sme_revd_q, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
26 | + | ||
27 | DEF_HELPER_FLAGS_4(sve_rbit_b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
28 | DEF_HELPER_FLAGS_4(sve_rbit_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
29 | DEF_HELPER_FLAGS_4(sve_rbit_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
30 | diff --git a/target/arm/sve.decode b/target/arm/sve.decode | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/target/arm/sve.decode | ||
33 | +++ b/target/arm/sve.decode | ||
34 | @@ -XXX,XX +XXX,XX @@ REVB 00000101 .. 1001 00 100 ... ..... ..... @rd_pg_rn | ||
35 | REVH 00000101 .. 1001 01 100 ... ..... ..... @rd_pg_rn | ||
36 | REVW 00000101 .. 1001 10 100 ... ..... ..... @rd_pg_rn | ||
37 | RBIT 00000101 .. 1001 11 100 ... ..... ..... @rd_pg_rn | ||
38 | +REVD 00000101 00 1011 10 100 ... ..... ..... @rd_pg_rn_e0 | ||
39 | |||
40 | # SVE vector splice (predicated, destructive) | ||
41 | SPLICE 00000101 .. 101 100 100 ... ..... ..... @rdn_pg_rm | ||
42 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/target/arm/sve_helper.c | ||
45 | +++ b/target/arm/sve_helper.c | ||
46 | @@ -XXX,XX +XXX,XX @@ DO_ZPZ_D(sve_revh_d, uint64_t, hswap64) | ||
47 | |||
48 | DO_ZPZ_D(sve_revw_d, uint64_t, wswap64) | ||
49 | |||
50 | +void HELPER(sme_revd_q)(void *vd, void *vn, void *vg, uint32_t desc) | ||
51 | +{ | ||
52 | + intptr_t i, opr_sz = simd_oprsz(desc) / 8; | ||
53 | + uint64_t *d = vd, *n = vn; | ||
54 | + uint8_t *pg = vg; | ||
55 | + | ||
56 | + for (i = 0; i < opr_sz; i += 2) { | ||
57 | + if (pg[H1(i)] & 1) { | ||
58 | + uint64_t n0 = n[i + 0]; | ||
59 | + uint64_t n1 = n[i + 1]; | ||
60 | + d[i + 0] = n1; | ||
61 | + d[i + 1] = n0; | ||
62 | + } | ||
63 | + } | ||
64 | +} | ||
65 | + | ||
66 | DO_ZPZ(sve_rbit_b, uint8_t, H1, revbit8) | ||
67 | DO_ZPZ(sve_rbit_h, uint16_t, H1_2, revbit16) | ||
68 | DO_ZPZ(sve_rbit_s, uint32_t, H1_4, revbit32) | ||
69 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | ||
70 | index XXXXXXX..XXXXXXX 100644 | ||
71 | --- a/target/arm/translate-sve.c | ||
72 | +++ b/target/arm/translate-sve.c | ||
73 | @@ -XXX,XX +XXX,XX @@ TRANS_FEAT(REVH, aa64_sve, gen_gvec_ool_arg_zpz, revh_fns[a->esz], a, 0) | ||
74 | TRANS_FEAT(REVW, aa64_sve, gen_gvec_ool_arg_zpz, | ||
75 | a->esz == 3 ? gen_helper_sve_revw_d : NULL, a, 0) | ||
76 | |||
77 | +TRANS_FEAT(REVD, aa64_sme, gen_gvec_ool_arg_zpz, gen_helper_sme_revd_q, a, 0) | ||
78 | + | ||
79 | TRANS_FEAT(SPLICE, aa64_sve, gen_gvec_ool_arg_zpzz, | ||
80 | gen_helper_sve_splice, a, a->esz) | ||
81 | |||
82 | -- | ||
83 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | This is an SVE instruction that operates using the SVE vector | ||
4 | length but that it is present only if SME is implemented. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220708151540.18136-31-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/helper.h | 18 +++++++ | ||
12 | target/arm/sve.decode | 5 ++ | ||
13 | target/arm/translate-sve.c | 102 +++++++++++++++++++++++++++++++++++++ | ||
14 | target/arm/vec_helper.c | 24 +++++++++ | ||
15 | 4 files changed, 149 insertions(+) | ||
16 | |||
17 | diff --git a/target/arm/helper.h b/target/arm/helper.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/helper.h | ||
20 | +++ b/target/arm/helper.h | ||
21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_6(gvec_bfmlal, TCG_CALL_NO_RWG, | ||
22 | DEF_HELPER_FLAGS_6(gvec_bfmlal_idx, TCG_CALL_NO_RWG, | ||
23 | void, ptr, ptr, ptr, ptr, ptr, i32) | ||
24 | |||
25 | +DEF_HELPER_FLAGS_5(gvec_sclamp_b, TCG_CALL_NO_RWG, | ||
26 | + void, ptr, ptr, ptr, ptr, i32) | ||
27 | +DEF_HELPER_FLAGS_5(gvec_sclamp_h, TCG_CALL_NO_RWG, | ||
28 | + void, ptr, ptr, ptr, ptr, i32) | ||
29 | +DEF_HELPER_FLAGS_5(gvec_sclamp_s, TCG_CALL_NO_RWG, | ||
30 | + void, ptr, ptr, ptr, ptr, i32) | ||
31 | +DEF_HELPER_FLAGS_5(gvec_sclamp_d, TCG_CALL_NO_RWG, | ||
32 | + void, ptr, ptr, ptr, ptr, i32) | ||
33 | + | ||
34 | +DEF_HELPER_FLAGS_5(gvec_uclamp_b, TCG_CALL_NO_RWG, | ||
35 | + void, ptr, ptr, ptr, ptr, i32) | ||
36 | +DEF_HELPER_FLAGS_5(gvec_uclamp_h, TCG_CALL_NO_RWG, | ||
37 | + void, ptr, ptr, ptr, ptr, i32) | ||
38 | +DEF_HELPER_FLAGS_5(gvec_uclamp_s, TCG_CALL_NO_RWG, | ||
39 | + void, ptr, ptr, ptr, ptr, i32) | ||
40 | +DEF_HELPER_FLAGS_5(gvec_uclamp_d, TCG_CALL_NO_RWG, | ||
41 | + void, ptr, ptr, ptr, ptr, i32) | ||
42 | + | ||
43 | #ifdef TARGET_AARCH64 | ||
44 | #include "helper-a64.h" | ||
45 | #include "helper-sve.h" | ||
46 | diff --git a/target/arm/sve.decode b/target/arm/sve.decode | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/target/arm/sve.decode | ||
49 | +++ b/target/arm/sve.decode | ||
50 | @@ -XXX,XX +XXX,XX @@ PSEL 00100101 .. 1 100 .. 01 .... 0 .... 0 .... \ | ||
51 | @psel esz=2 imm=%psel_imm_s | ||
52 | PSEL 00100101 .1 1 000 .. 01 .... 0 .... 0 .... \ | ||
53 | @psel esz=3 imm=%psel_imm_d | ||
54 | + | ||
55 | +### SVE clamp | ||
56 | + | ||
57 | +SCLAMP 01000100 .. 0 ..... 110000 ..... ..... @rda_rn_rm | ||
58 | +UCLAMP 01000100 .. 0 ..... 110001 ..... ..... @rda_rn_rm | ||
59 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | ||
60 | index XXXXXXX..XXXXXXX 100644 | ||
61 | --- a/target/arm/translate-sve.c | ||
62 | +++ b/target/arm/translate-sve.c | ||
63 | @@ -XXX,XX +XXX,XX @@ static bool trans_PSEL(DisasContext *s, arg_psel *a) | ||
64 | tcg_temp_free_ptr(ptr); | ||
65 | return true; | ||
66 | } | ||
67 | + | ||
68 | +static void gen_sclamp_i32(TCGv_i32 d, TCGv_i32 n, TCGv_i32 m, TCGv_i32 a) | ||
69 | +{ | ||
70 | + tcg_gen_smax_i32(d, a, n); | ||
71 | + tcg_gen_smin_i32(d, d, m); | ||
72 | +} | ||
73 | + | ||
74 | +static void gen_sclamp_i64(TCGv_i64 d, TCGv_i64 n, TCGv_i64 m, TCGv_i64 a) | ||
75 | +{ | ||
76 | + tcg_gen_smax_i64(d, a, n); | ||
77 | + tcg_gen_smin_i64(d, d, m); | ||
78 | +} | ||
79 | + | ||
80 | +static void gen_sclamp_vec(unsigned vece, TCGv_vec d, TCGv_vec n, | ||
81 | + TCGv_vec m, TCGv_vec a) | ||
82 | +{ | ||
83 | + tcg_gen_smax_vec(vece, d, a, n); | ||
84 | + tcg_gen_smin_vec(vece, d, d, m); | ||
85 | +} | ||
86 | + | ||
87 | +static void gen_sclamp(unsigned vece, uint32_t d, uint32_t n, uint32_t m, | ||
88 | + uint32_t a, uint32_t oprsz, uint32_t maxsz) | ||
89 | +{ | ||
90 | + static const TCGOpcode vecop[] = { | ||
91 | + INDEX_op_smin_vec, INDEX_op_smax_vec, 0 | ||
92 | + }; | ||
93 | + static const GVecGen4 ops[4] = { | ||
94 | + { .fniv = gen_sclamp_vec, | ||
95 | + .fno = gen_helper_gvec_sclamp_b, | ||
96 | + .opt_opc = vecop, | ||
97 | + .vece = MO_8 }, | ||
98 | + { .fniv = gen_sclamp_vec, | ||
99 | + .fno = gen_helper_gvec_sclamp_h, | ||
100 | + .opt_opc = vecop, | ||
101 | + .vece = MO_16 }, | ||
102 | + { .fni4 = gen_sclamp_i32, | ||
103 | + .fniv = gen_sclamp_vec, | ||
104 | + .fno = gen_helper_gvec_sclamp_s, | ||
105 | + .opt_opc = vecop, | ||
106 | + .vece = MO_32 }, | ||
107 | + { .fni8 = gen_sclamp_i64, | ||
108 | + .fniv = gen_sclamp_vec, | ||
109 | + .fno = gen_helper_gvec_sclamp_d, | ||
110 | + .opt_opc = vecop, | ||
111 | + .vece = MO_64, | ||
112 | + .prefer_i64 = TCG_TARGET_REG_BITS == 64 } | ||
113 | + }; | ||
114 | + tcg_gen_gvec_4(d, n, m, a, oprsz, maxsz, &ops[vece]); | ||
115 | +} | ||
116 | + | ||
117 | +TRANS_FEAT(SCLAMP, aa64_sme, gen_gvec_fn_arg_zzzz, gen_sclamp, a) | ||
118 | + | ||
119 | +static void gen_uclamp_i32(TCGv_i32 d, TCGv_i32 n, TCGv_i32 m, TCGv_i32 a) | ||
120 | +{ | ||
121 | + tcg_gen_umax_i32(d, a, n); | ||
122 | + tcg_gen_umin_i32(d, d, m); | ||
123 | +} | ||
124 | + | ||
125 | +static void gen_uclamp_i64(TCGv_i64 d, TCGv_i64 n, TCGv_i64 m, TCGv_i64 a) | ||
126 | +{ | ||
127 | + tcg_gen_umax_i64(d, a, n); | ||
128 | + tcg_gen_umin_i64(d, d, m); | ||
129 | +} | ||
130 | + | ||
131 | +static void gen_uclamp_vec(unsigned vece, TCGv_vec d, TCGv_vec n, | ||
132 | + TCGv_vec m, TCGv_vec a) | ||
133 | +{ | ||
134 | + tcg_gen_umax_vec(vece, d, a, n); | ||
135 | + tcg_gen_umin_vec(vece, d, d, m); | ||
136 | +} | ||
137 | + | ||
138 | +static void gen_uclamp(unsigned vece, uint32_t d, uint32_t n, uint32_t m, | ||
139 | + uint32_t a, uint32_t oprsz, uint32_t maxsz) | ||
140 | +{ | ||
141 | + static const TCGOpcode vecop[] = { | ||
142 | + INDEX_op_umin_vec, INDEX_op_umax_vec, 0 | ||
143 | + }; | ||
144 | + static const GVecGen4 ops[4] = { | ||
145 | + { .fniv = gen_uclamp_vec, | ||
146 | + .fno = gen_helper_gvec_uclamp_b, | ||
147 | + .opt_opc = vecop, | ||
148 | + .vece = MO_8 }, | ||
149 | + { .fniv = gen_uclamp_vec, | ||
150 | + .fno = gen_helper_gvec_uclamp_h, | ||
151 | + .opt_opc = vecop, | ||
152 | + .vece = MO_16 }, | ||
153 | + { .fni4 = gen_uclamp_i32, | ||
154 | + .fniv = gen_uclamp_vec, | ||
155 | + .fno = gen_helper_gvec_uclamp_s, | ||
156 | + .opt_opc = vecop, | ||
157 | + .vece = MO_32 }, | ||
158 | + { .fni8 = gen_uclamp_i64, | ||
159 | + .fniv = gen_uclamp_vec, | ||
160 | + .fno = gen_helper_gvec_uclamp_d, | ||
161 | + .opt_opc = vecop, | ||
162 | + .vece = MO_64, | ||
163 | + .prefer_i64 = TCG_TARGET_REG_BITS == 64 } | ||
164 | + }; | ||
165 | + tcg_gen_gvec_4(d, n, m, a, oprsz, maxsz, &ops[vece]); | ||
166 | +} | ||
167 | + | ||
168 | +TRANS_FEAT(UCLAMP, aa64_sme, gen_gvec_fn_arg_zzzz, gen_uclamp, a) | ||
169 | diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c | ||
170 | index XXXXXXX..XXXXXXX 100644 | ||
171 | --- a/target/arm/vec_helper.c | ||
172 | +++ b/target/arm/vec_helper.c | ||
173 | @@ -XXX,XX +XXX,XX @@ void HELPER(gvec_bfmlal_idx)(void *vd, void *vn, void *vm, | ||
174 | } | ||
175 | clear_tail(d, opr_sz, simd_maxsz(desc)); | ||
176 | } | ||
177 | + | ||
178 | +#define DO_CLAMP(NAME, TYPE) \ | ||
179 | +void HELPER(NAME)(void *d, void *n, void *m, void *a, uint32_t desc) \ | ||
180 | +{ \ | ||
181 | + intptr_t i, opr_sz = simd_oprsz(desc); \ | ||
182 | + for (i = 0; i < opr_sz; i += sizeof(TYPE)) { \ | ||
183 | + TYPE aa = *(TYPE *)(a + i); \ | ||
184 | + TYPE nn = *(TYPE *)(n + i); \ | ||
185 | + TYPE mm = *(TYPE *)(m + i); \ | ||
186 | + TYPE dd = MIN(MAX(aa, nn), mm); \ | ||
187 | + *(TYPE *)(d + i) = dd; \ | ||
188 | + } \ | ||
189 | + clear_tail(d, opr_sz, simd_maxsz(desc)); \ | ||
190 | +} | ||
191 | + | ||
192 | +DO_CLAMP(gvec_sclamp_b, int8_t) | ||
193 | +DO_CLAMP(gvec_sclamp_h, int16_t) | ||
194 | +DO_CLAMP(gvec_sclamp_s, int32_t) | ||
195 | +DO_CLAMP(gvec_sclamp_d, int64_t) | ||
196 | + | ||
197 | +DO_CLAMP(gvec_uclamp_b, uint8_t) | ||
198 | +DO_CLAMP(gvec_uclamp_h, uint16_t) | ||
199 | +DO_CLAMP(gvec_uclamp_s, uint32_t) | ||
200 | +DO_CLAMP(gvec_uclamp_d, uint64_t) | ||
201 | -- | ||
202 | 2.25.1 | diff view generated by jsdifflib |
1 | Implement the MVE VSRI and VSLI insns, which perform a | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | shift-and-insert operation. | ||
3 | 2 | ||
3 | We can handle both exception entry and exception return by | ||
4 | hooking into aarch64_sve_change_el. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220708151540.18136-32-richard.henderson@linaro.org | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20210628135835.6690-11-peter.maydell@linaro.org | ||
7 | --- | 10 | --- |
8 | target/arm/helper-mve.h | 8 ++++++++ | 11 | target/arm/helper.c | 15 +++++++++++++-- |
9 | target/arm/mve.decode | 9 ++++++++ | 12 | 1 file changed, 13 insertions(+), 2 deletions(-) |
10 | target/arm/mve_helper.c | 42 ++++++++++++++++++++++++++++++++++++++ | ||
11 | target/arm/translate-mve.c | 3 +++ | ||
12 | 4 files changed, 62 insertions(+) | ||
13 | 13 | ||
14 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 14 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
15 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/helper-mve.h | 16 | --- a/target/arm/helper.c |
17 | +++ b/target/arm/helper-mve.h | 17 | +++ b/target/arm/helper.c |
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vshlltsb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 18 | @@ -XXX,XX +XXX,XX @@ void aarch64_sve_change_el(CPUARMState *env, int old_el, |
19 | DEF_HELPER_FLAGS_4(mve_vshlltsh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 19 | return; |
20 | DEF_HELPER_FLAGS_4(mve_vshlltub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 20 | } |
21 | DEF_HELPER_FLAGS_4(mve_vshlltuh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 21 | |
22 | + old_a64 = old_el ? arm_el_is_aa64(env, old_el) : el0_a64; | ||
23 | + new_a64 = new_el ? arm_el_is_aa64(env, new_el) : el0_a64; | ||
22 | + | 24 | + |
23 | +DEF_HELPER_FLAGS_4(mve_vsrib, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 25 | + /* |
24 | +DEF_HELPER_FLAGS_4(mve_vsrih, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 26 | + * Both AArch64.TakeException and AArch64.ExceptionReturn |
25 | +DEF_HELPER_FLAGS_4(mve_vsriw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 27 | + * invoke ResetSVEState when taking an exception from, or |
26 | + | 28 | + * returning to, AArch32 state when PSTATE.SM is enabled. |
27 | +DEF_HELPER_FLAGS_4(mve_vslib, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 29 | + */ |
28 | +DEF_HELPER_FLAGS_4(mve_vslih, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 30 | + if (old_a64 != new_a64 && FIELD_EX64(env->svcr, SVCR, SM)) { |
29 | +DEF_HELPER_FLAGS_4(mve_vsliw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 31 | + arm_reset_sve_state(env); |
30 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | 32 | + return; |
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/target/arm/mve.decode | ||
33 | +++ b/target/arm/mve.decode | ||
34 | @@ -XXX,XX +XXX,XX @@ VSHLL_TS 111 0 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_h | ||
35 | |||
36 | VSHLL_TU 111 1 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_b | ||
37 | VSHLL_TU 111 1 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_h | ||
38 | + | ||
39 | +# Shift-and-insert | ||
40 | +VSRI 111 1 1111 1 . ... ... ... 0 0100 0 1 . 1 ... 0 @2_shr_b | ||
41 | +VSRI 111 1 1111 1 . ... ... ... 0 0100 0 1 . 1 ... 0 @2_shr_h | ||
42 | +VSRI 111 1 1111 1 . ... ... ... 0 0100 0 1 . 1 ... 0 @2_shr_w | ||
43 | + | ||
44 | +VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_b | ||
45 | +VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_h | ||
46 | +VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_w | ||
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_2SHIFT_SAT_S(vqshlui_s, DO_SUQSHL_OP) | ||
52 | DO_2SHIFT_U(vrshli_u, DO_VRSHLU) | ||
53 | DO_2SHIFT_S(vrshli_s, DO_VRSHLS) | ||
54 | |||
55 | +/* Shift-and-insert; we always work with 64 bits at a time */ | ||
56 | +#define DO_2SHIFT_INSERT(OP, ESIZE, SHIFTFN, MASKFN) \ | ||
57 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ | ||
58 | + void *vm, uint32_t shift) \ | ||
59 | + { \ | ||
60 | + uint64_t *d = vd, *m = vm; \ | ||
61 | + uint16_t mask; \ | ||
62 | + uint64_t shiftmask; \ | ||
63 | + unsigned e; \ | ||
64 | + if (shift == 0 || shift == ESIZE * 8) { \ | ||
65 | + /* \ | ||
66 | + * Only VSLI can shift by 0; only VSRI can shift by <dt>. \ | ||
67 | + * The generic logic would give the right answer for 0 but \ | ||
68 | + * fails for <dt>. \ | ||
69 | + */ \ | ||
70 | + goto done; \ | ||
71 | + } \ | ||
72 | + assert(shift < ESIZE * 8); \ | ||
73 | + mask = mve_element_mask(env); \ | ||
74 | + /* ESIZE / 2 gives the MO_* value if ESIZE is in [1,2,4] */ \ | ||
75 | + shiftmask = dup_const(ESIZE / 2, MASKFN(ESIZE * 8, shift)); \ | ||
76 | + for (e = 0; e < 16 / 8; e++, mask >>= 8) { \ | ||
77 | + uint64_t r = (SHIFTFN(m[H8(e)], shift) & shiftmask) | \ | ||
78 | + (d[H8(e)] & ~shiftmask); \ | ||
79 | + mergemask(&d[H8(e)], r, mask); \ | ||
80 | + } \ | ||
81 | +done: \ | ||
82 | + mve_advance_vpt(env); \ | ||
83 | + } | 33 | + } |
84 | + | 34 | + |
85 | +#define DO_SHL(N, SHIFT) ((N) << (SHIFT)) | 35 | /* |
86 | +#define DO_SHR(N, SHIFT) ((N) >> (SHIFT)) | 36 | * DDI0584A.d sec 3.2: "If SVE instructions are disabled or trapped |
87 | +#define SHL_MASK(EBITS, SHIFT) MAKE_64BIT_MASK((SHIFT), (EBITS) - (SHIFT)) | 37 | * at ELx, or not available because the EL is in AArch32 state, then |
88 | +#define SHR_MASK(EBITS, SHIFT) MAKE_64BIT_MASK(0, (EBITS) - (SHIFT)) | 38 | @@ -XXX,XX +XXX,XX @@ void aarch64_sve_change_el(CPUARMState *env, int old_el, |
89 | + | 39 | * we already have the correct register contents when encountering the |
90 | +DO_2SHIFT_INSERT(vsrib, 1, DO_SHR, SHR_MASK) | 40 | * vq0->vq0 transition between EL0->EL1. |
91 | +DO_2SHIFT_INSERT(vsrih, 2, DO_SHR, SHR_MASK) | 41 | */ |
92 | +DO_2SHIFT_INSERT(vsriw, 4, DO_SHR, SHR_MASK) | 42 | - old_a64 = old_el ? arm_el_is_aa64(env, old_el) : el0_a64; |
93 | +DO_2SHIFT_INSERT(vslib, 1, DO_SHL, SHL_MASK) | 43 | old_len = (old_a64 && !sve_exception_el(env, old_el) |
94 | +DO_2SHIFT_INSERT(vslih, 2, DO_SHL, SHL_MASK) | 44 | ? sve_vqm1_for_el(env, old_el) : 0); |
95 | +DO_2SHIFT_INSERT(vsliw, 4, DO_SHL, SHL_MASK) | 45 | - new_a64 = new_el ? arm_el_is_aa64(env, new_el) : el0_a64; |
96 | + | 46 | new_len = (new_a64 && !sve_exception_el(env, new_el) |
97 | /* | 47 | ? sve_vqm1_for_el(env, new_el) : 0); |
98 | * Long shifts taking half-sized inputs from top or bottom of the input | 48 | |
99 | * vector and producing a double-width result. ESIZE, TYPE are for | ||
100 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
101 | index XXXXXXX..XXXXXXX 100644 | ||
102 | --- a/target/arm/translate-mve.c | ||
103 | +++ b/target/arm/translate-mve.c | ||
104 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT(VSHRI_U, vshli_u, true) | ||
105 | DO_2SHIFT(VRSHRI_S, vrshli_s, true) | ||
106 | DO_2SHIFT(VRSHRI_U, vrshli_u, true) | ||
107 | |||
108 | +DO_2SHIFT(VSRI, vsri, false) | ||
109 | +DO_2SHIFT(VSLI, vsli, false) | ||
110 | + | ||
111 | #define DO_VSHLL(INSN, FN) \ | ||
112 | static bool trans_##INSN(DisasContext *s, arg_2shift *a) \ | ||
113 | { \ | ||
114 | -- | 49 | -- |
115 | 2.20.1 | 50 | 2.25.1 |
116 | |||
117 | diff view generated by jsdifflib |
1 | From: Patrick Venture <venture@google.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Adds a line-item reference to the supported quanta-q71l-bmc aspeed | 3 | Note that SME remains effectively disabled for user-only, |
4 | entry. | 4 | because we do not yet set CPACR_EL1.SMEN. This needs to |
5 | wait until the kernel ABI is implemented. | ||
5 | 6 | ||
6 | Signed-off-by: Patrick Venture <venture@google.com> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20210615192848.1065297-2-venture@google.com | 9 | Message-id: 20220708151540.18136-33-richard.henderson@linaro.org |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 11 | --- |
11 | docs/system/arm/aspeed.rst | 1 + | 12 | docs/system/arm/emulation.rst | 4 ++++ |
12 | 1 file changed, 1 insertion(+) | 13 | target/arm/cpu64.c | 11 +++++++++++ |
14 | 2 files changed, 15 insertions(+) | ||
13 | 15 | ||
14 | diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst | 16 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst |
15 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/docs/system/arm/aspeed.rst | 18 | --- a/docs/system/arm/emulation.rst |
17 | +++ b/docs/system/arm/aspeed.rst | 19 | +++ b/docs/system/arm/emulation.rst |
18 | @@ -XXX,XX +XXX,XX @@ etc. | 20 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
19 | AST2400 SoC based machines : | 21 | - FEAT_SHA512 (Advanced SIMD SHA512 instructions) |
20 | 22 | - FEAT_SM3 (Advanced SIMD SM3 instructions) | |
21 | - ``palmetto-bmc`` OpenPOWER Palmetto POWER8 BMC | 23 | - FEAT_SM4 (Advanced SIMD SM4 instructions) |
22 | +- ``quanta-q71l-bmc`` OpenBMC Quanta BMC | 24 | +- FEAT_SME (Scalable Matrix Extension) |
23 | 25 | +- FEAT_SME_FA64 (Full A64 instruction set in Streaming SVE mode) | |
24 | AST2500 SoC based machines : | 26 | +- FEAT_SME_F64F64 (Double-precision floating-point outer product instructions) |
27 | +- FEAT_SME_I16I64 (16-bit to 64-bit integer widening outer product instructions) | ||
28 | - FEAT_SPECRES (Speculation restriction instructions) | ||
29 | - FEAT_SSBS (Speculative Store Bypass Safe) | ||
30 | - FEAT_TLBIOS (TLB invalidate instructions in Outer Shareable domain) | ||
31 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/target/arm/cpu64.c | ||
34 | +++ b/target/arm/cpu64.c | ||
35 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
36 | */ | ||
37 | t = FIELD_DP64(t, ID_AA64PFR1, MTE, 3); /* FEAT_MTE3 */ | ||
38 | t = FIELD_DP64(t, ID_AA64PFR1, RAS_FRAC, 0); /* FEAT_RASv1p1 + FEAT_DoubleFault */ | ||
39 | + t = FIELD_DP64(t, ID_AA64PFR1, SME, 1); /* FEAT_SME */ | ||
40 | t = FIELD_DP64(t, ID_AA64PFR1, CSV2_FRAC, 0); /* FEAT_CSV2_2 */ | ||
41 | cpu->isar.id_aa64pfr1 = t; | ||
42 | |||
43 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
44 | t = FIELD_DP64(t, ID_AA64DFR0, PMUVER, 5); /* FEAT_PMUv3p4 */ | ||
45 | cpu->isar.id_aa64dfr0 = t; | ||
46 | |||
47 | + t = cpu->isar.id_aa64smfr0; | ||
48 | + t = FIELD_DP64(t, ID_AA64SMFR0, F32F32, 1); /* FEAT_SME */ | ||
49 | + t = FIELD_DP64(t, ID_AA64SMFR0, B16F32, 1); /* FEAT_SME */ | ||
50 | + t = FIELD_DP64(t, ID_AA64SMFR0, F16F32, 1); /* FEAT_SME */ | ||
51 | + t = FIELD_DP64(t, ID_AA64SMFR0, I8I32, 0xf); /* FEAT_SME */ | ||
52 | + t = FIELD_DP64(t, ID_AA64SMFR0, F64F64, 1); /* FEAT_SME_F64F64 */ | ||
53 | + t = FIELD_DP64(t, ID_AA64SMFR0, I16I64, 0xf); /* FEAT_SME_I16I64 */ | ||
54 | + t = FIELD_DP64(t, ID_AA64SMFR0, FA64, 1); /* FEAT_SME_FA64 */ | ||
55 | + cpu->isar.id_aa64smfr0 = t; | ||
56 | + | ||
57 | /* Replicate the same data to the 32-bit id registers. */ | ||
58 | aa32_max_features(cpu); | ||
25 | 59 | ||
26 | -- | 60 | -- |
27 | 2.20.1 | 61 | 2.25.1 |
28 | |||
29 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20220708151540.18136-34-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | linux-user/aarch64/target_cpu.h | 5 ++++- | ||
9 | 1 file changed, 4 insertions(+), 1 deletion(-) | ||
10 | |||
11 | diff --git a/linux-user/aarch64/target_cpu.h b/linux-user/aarch64/target_cpu.h | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/linux-user/aarch64/target_cpu.h | ||
14 | +++ b/linux-user/aarch64/target_cpu.h | ||
15 | @@ -XXX,XX +XXX,XX @@ static inline void cpu_clone_regs_parent(CPUARMState *env, unsigned flags) | ||
16 | |||
17 | static inline void cpu_set_tls(CPUARMState *env, target_ulong newtls) | ||
18 | { | ||
19 | - /* Note that AArch64 Linux keeps the TLS pointer in TPIDR; this is | ||
20 | + /* | ||
21 | + * Note that AArch64 Linux keeps the TLS pointer in TPIDR; this is | ||
22 | * different from AArch32 Linux, which uses TPIDRRO. | ||
23 | */ | ||
24 | env->cp15.tpidr_el[0] = newtls; | ||
25 | + /* TPIDR2_EL0 is cleared with CLONE_SETTLS. */ | ||
26 | + env->cp15.tpidr2_el0 = 0; | ||
27 | } | ||
28 | |||
29 | static inline abi_ulong get_sp_from_cpustate(CPUARMState *state) | ||
30 | -- | ||
31 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20220708151540.18136-35-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | linux-user/aarch64/cpu_loop.c | 9 +++++++++ | ||
9 | 1 file changed, 9 insertions(+) | ||
10 | |||
11 | diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/linux-user/aarch64/cpu_loop.c | ||
14 | +++ b/linux-user/aarch64/cpu_loop.c | ||
15 | @@ -XXX,XX +XXX,XX @@ void cpu_loop(CPUARMState *env) | ||
16 | |||
17 | switch (trapnr) { | ||
18 | case EXCP_SWI: | ||
19 | + /* | ||
20 | + * On syscall, PSTATE.ZA is preserved, along with the ZA matrix. | ||
21 | + * PSTATE.SM is cleared, per SMSTOP, which does ResetSVEState. | ||
22 | + */ | ||
23 | + if (FIELD_EX64(env->svcr, SVCR, SM)) { | ||
24 | + env->svcr = FIELD_DP64(env->svcr, SVCR, SM, 0); | ||
25 | + arm_rebuild_hflags(env); | ||
26 | + arm_reset_sve_state(env); | ||
27 | + } | ||
28 | ret = do_syscall(env, | ||
29 | env->xregs[8], | ||
30 | env->xregs[0], | ||
31 | -- | ||
32 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Make sure to zero the currently reserved fields. | ||
4 | |||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20220708151540.18136-36-richard.henderson@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | linux-user/aarch64/signal.c | 9 ++++++++- | ||
11 | 1 file changed, 8 insertions(+), 1 deletion(-) | ||
12 | |||
13 | diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/linux-user/aarch64/signal.c | ||
16 | +++ b/linux-user/aarch64/signal.c | ||
17 | @@ -XXX,XX +XXX,XX @@ struct target_extra_context { | ||
18 | struct target_sve_context { | ||
19 | struct target_aarch64_ctx head; | ||
20 | uint16_t vl; | ||
21 | - uint16_t reserved[3]; | ||
22 | + uint16_t flags; | ||
23 | + uint16_t reserved[2]; | ||
24 | /* The actual SVE data immediately follows. It is laid out | ||
25 | * according to TARGET_SVE_SIG_{Z,P}REG_OFFSET, based off of | ||
26 | * the original struct pointer. | ||
27 | @@ -XXX,XX +XXX,XX @@ struct target_sve_context { | ||
28 | #define TARGET_SVE_SIG_CONTEXT_SIZE(VQ) \ | ||
29 | (TARGET_SVE_SIG_PREG_OFFSET(VQ, 17)) | ||
30 | |||
31 | +#define TARGET_SVE_SIG_FLAG_SM 1 | ||
32 | + | ||
33 | struct target_rt_sigframe { | ||
34 | struct target_siginfo info; | ||
35 | struct target_ucontext uc; | ||
36 | @@ -XXX,XX +XXX,XX @@ static void target_setup_sve_record(struct target_sve_context *sve, | ||
37 | { | ||
38 | int i, j; | ||
39 | |||
40 | + memset(sve, 0, sizeof(*sve)); | ||
41 | __put_user(TARGET_SVE_MAGIC, &sve->head.magic); | ||
42 | __put_user(size, &sve->head.size); | ||
43 | __put_user(vq * TARGET_SVE_VQ_BYTES, &sve->vl); | ||
44 | + if (FIELD_EX64(env->svcr, SVCR, SM)) { | ||
45 | + __put_user(TARGET_SVE_SIG_FLAG_SM, &sve->flags); | ||
46 | + } | ||
47 | |||
48 | /* Note that SVE regs are stored as a byte stream, with each byte element | ||
49 | * at a subsequent address. This corresponds to a little-endian store | ||
50 | -- | ||
51 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Maxim Uvarov <maxim.uvarov@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | qemu has 2 type of functions: shutdown and reboot. Shutdown | 3 | Fold the return value setting into the goto, so each |
4 | function has to be used for machine shutdown. Otherwise we cause | 4 | point of failure need not do both. |
5 | a reset with a bogus "cause" value, when we intended a shutdown. | ||
6 | 5 | ||
7 | Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Message-id: 20210625111842.3790-3-maxim.uvarov@linaro.org | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
10 | [PMM: tweaked commit message] | 8 | Message-id: 20220708151540.18136-37-richard.henderson@linaro.org |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 10 | --- |
13 | hw/gpio/gpio_pwr.c | 2 +- | 11 | linux-user/aarch64/signal.c | 26 +++++++++++--------------- |
14 | 1 file changed, 1 insertion(+), 1 deletion(-) | 12 | 1 file changed, 11 insertions(+), 15 deletions(-) |
15 | 13 | ||
16 | diff --git a/hw/gpio/gpio_pwr.c b/hw/gpio/gpio_pwr.c | 14 | diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c |
17 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/gpio/gpio_pwr.c | 16 | --- a/linux-user/aarch64/signal.c |
19 | +++ b/hw/gpio/gpio_pwr.c | 17 | +++ b/linux-user/aarch64/signal.c |
20 | @@ -XXX,XX +XXX,XX @@ static void gpio_pwr_reset(void *opaque, int n, int level) | 18 | @@ -XXX,XX +XXX,XX @@ static int target_restore_sigframe(CPUARMState *env, |
21 | static void gpio_pwr_shutdown(void *opaque, int n, int level) | 19 | struct target_sve_context *sve = NULL; |
22 | { | 20 | uint64_t extra_datap = 0; |
23 | if (level) { | 21 | bool used_extra = false; |
24 | - qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); | 22 | - bool err = false; |
25 | + qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); | 23 | int vq = 0, sve_size = 0; |
24 | |||
25 | target_restore_general_frame(env, sf); | ||
26 | @@ -XXX,XX +XXX,XX @@ static int target_restore_sigframe(CPUARMState *env, | ||
27 | switch (magic) { | ||
28 | case 0: | ||
29 | if (size != 0) { | ||
30 | - err = true; | ||
31 | - goto exit; | ||
32 | + goto err; | ||
33 | } | ||
34 | if (used_extra) { | ||
35 | ctx = NULL; | ||
36 | @@ -XXX,XX +XXX,XX @@ static int target_restore_sigframe(CPUARMState *env, | ||
37 | |||
38 | case TARGET_FPSIMD_MAGIC: | ||
39 | if (fpsimd || size != sizeof(struct target_fpsimd_context)) { | ||
40 | - err = true; | ||
41 | - goto exit; | ||
42 | + goto err; | ||
43 | } | ||
44 | fpsimd = (struct target_fpsimd_context *)ctx; | ||
45 | break; | ||
46 | @@ -XXX,XX +XXX,XX @@ static int target_restore_sigframe(CPUARMState *env, | ||
47 | break; | ||
48 | } | ||
49 | } | ||
50 | - err = true; | ||
51 | - goto exit; | ||
52 | + goto err; | ||
53 | |||
54 | case TARGET_EXTRA_MAGIC: | ||
55 | if (extra || size != sizeof(struct target_extra_context)) { | ||
56 | - err = true; | ||
57 | - goto exit; | ||
58 | + goto err; | ||
59 | } | ||
60 | __get_user(extra_datap, | ||
61 | &((struct target_extra_context *)ctx)->datap); | ||
62 | @@ -XXX,XX +XXX,XX @@ static int target_restore_sigframe(CPUARMState *env, | ||
63 | /* Unknown record -- we certainly didn't generate it. | ||
64 | * Did we in fact get out of sync? | ||
65 | */ | ||
66 | - err = true; | ||
67 | - goto exit; | ||
68 | + goto err; | ||
69 | } | ||
70 | ctx = (void *)ctx + size; | ||
26 | } | 71 | } |
72 | @@ -XXX,XX +XXX,XX @@ static int target_restore_sigframe(CPUARMState *env, | ||
73 | if (fpsimd) { | ||
74 | target_restore_fpsimd_record(env, fpsimd); | ||
75 | } else { | ||
76 | - err = true; | ||
77 | + goto err; | ||
78 | } | ||
79 | |||
80 | /* SVE data, if present, overwrites FPSIMD data. */ | ||
81 | if (sve) { | ||
82 | target_restore_sve_record(env, sve, vq); | ||
83 | } | ||
84 | - | ||
85 | - exit: | ||
86 | unlock_user(extra, extra_datap, 0); | ||
87 | - return err; | ||
88 | + return 0; | ||
89 | + | ||
90 | + err: | ||
91 | + unlock_user(extra, extra_datap, 0); | ||
92 | + return 1; | ||
27 | } | 93 | } |
28 | 94 | ||
95 | static abi_ulong get_sigframe(struct target_sigaction *ka, | ||
29 | -- | 96 | -- |
30 | 2.20.1 | 97 | 2.25.1 |
31 | |||
32 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | In parse_user_sigframe, the kernel rejects duplicate sve records, | ||
4 | or records that are smaller than the header. We were silently | ||
5 | allowing these cases to pass, dropping the record. | ||
6 | |||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20220708151540.18136-38-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | linux-user/aarch64/signal.c | 5 ++++- | ||
13 | 1 file changed, 4 insertions(+), 1 deletion(-) | ||
14 | |||
15 | diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/linux-user/aarch64/signal.c | ||
18 | +++ b/linux-user/aarch64/signal.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static int target_restore_sigframe(CPUARMState *env, | ||
20 | break; | ||
21 | |||
22 | case TARGET_SVE_MAGIC: | ||
23 | + if (sve || size < sizeof(struct target_sve_context)) { | ||
24 | + goto err; | ||
25 | + } | ||
26 | if (cpu_isar_feature(aa64_sve, env_archcpu(env))) { | ||
27 | vq = sve_vq(env); | ||
28 | sve_size = QEMU_ALIGN_UP(TARGET_SVE_SIG_CONTEXT_SIZE(vq), 16); | ||
29 | - if (!sve && size == sve_size) { | ||
30 | + if (size == sve_size) { | ||
31 | sve = (struct target_sve_context *)ctx; | ||
32 | break; | ||
33 | } | ||
34 | -- | ||
35 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20220708151540.18136-39-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | linux-user/aarch64/signal.c | 3 +++ | ||
9 | 1 file changed, 3 insertions(+) | ||
10 | |||
11 | diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/linux-user/aarch64/signal.c | ||
14 | +++ b/linux-user/aarch64/signal.c | ||
15 | @@ -XXX,XX +XXX,XX @@ static int target_restore_sigframe(CPUARMState *env, | ||
16 | __get_user(extra_size, | ||
17 | &((struct target_extra_context *)ctx)->size); | ||
18 | extra = lock_user(VERIFY_READ, extra_datap, extra_size, 0); | ||
19 | + if (!extra) { | ||
20 | + return 1; | ||
21 | + } | ||
22 | break; | ||
23 | |||
24 | default: | ||
25 | -- | ||
26 | 2.25.1 | diff view generated by jsdifflib |
1 | Implement the MVE VADDLV insn; this is similar to VADDV, except | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | that it accumulates 32-bit elements into a 64-bit accumulator | ||
3 | stored in a pair of general-purpose registers. | ||
4 | 2 | ||
3 | Move the checks out of the parsing loop and into the | ||
4 | restore function. This more closely mirrors the code | ||
5 | structure in the kernel, and is slightly clearer. | ||
6 | |||
7 | Reject rather than silently skip incorrect VL and SVE record sizes, | ||
8 | bringing our checks in to line with those the kernel does. | ||
9 | |||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-id: 20220708151540.18136-40-richard.henderson@linaro.org | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20210628135835.6690-15-peter.maydell@linaro.org | ||
8 | --- | 14 | --- |
9 | target/arm/helper-mve.h | 3 ++ | 15 | linux-user/aarch64/signal.c | 51 +++++++++++++++++++++++++------------ |
10 | target/arm/mve.decode | 6 +++- | 16 | 1 file changed, 35 insertions(+), 16 deletions(-) |
11 | target/arm/mve_helper.c | 19 ++++++++++++ | ||
12 | target/arm/translate-mve.c | 63 ++++++++++++++++++++++++++++++++++++++ | ||
13 | 4 files changed, 90 insertions(+), 1 deletion(-) | ||
14 | 17 | ||
15 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 18 | diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c |
16 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/helper-mve.h | 20 | --- a/linux-user/aarch64/signal.c |
18 | +++ b/target/arm/helper-mve.h | 21 | +++ b/linux-user/aarch64/signal.c |
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vaddvuh, TCG_CALL_NO_WG, i32, env, ptr, i32) | 22 | @@ -XXX,XX +XXX,XX @@ static void target_restore_fpsimd_record(CPUARMState *env, |
20 | DEF_HELPER_FLAGS_3(mve_vaddvsw, TCG_CALL_NO_WG, i32, env, ptr, i32) | 23 | } |
21 | DEF_HELPER_FLAGS_3(mve_vaddvuw, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
22 | |||
23 | +DEF_HELPER_FLAGS_3(mve_vaddlv_s, TCG_CALL_NO_WG, i64, env, ptr, i64) | ||
24 | +DEF_HELPER_FLAGS_3(mve_vaddlv_u, TCG_CALL_NO_WG, i64, env, ptr, i64) | ||
25 | + | ||
26 | DEF_HELPER_FLAGS_3(mve_vmovi, TCG_CALL_NO_WG, void, env, ptr, i64) | ||
27 | DEF_HELPER_FLAGS_3(mve_vandi, TCG_CALL_NO_WG, void, env, ptr, i64) | ||
28 | DEF_HELPER_FLAGS_3(mve_vorri, TCG_CALL_NO_WG, void, env, 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 @@ VQDMULH_scalar 1110 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
34 | VQRDMULH_scalar 1111 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
35 | |||
36 | # Vector add across vector | ||
37 | -VADDV 111 u:1 1110 1111 size:2 01 ... 0 1111 0 0 a:1 0 qm:3 0 rda=%rdalo | ||
38 | +{ | ||
39 | + VADDV 111 u:1 1110 1111 size:2 01 ... 0 1111 0 0 a:1 0 qm:3 0 rda=%rdalo | ||
40 | + VADDLV 111 u:1 1110 1 ... 1001 ... 0 1111 00 a:1 0 qm:3 0 \ | ||
41 | + rdahi=%rdahi rdalo=%rdalo | ||
42 | +} | ||
43 | |||
44 | # Predicate operations | ||
45 | %mask_22_13 22:1 13:3 | ||
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_VADDV(vaddvub, 1, uint8_t) | ||
51 | DO_VADDV(vaddvuh, 2, uint16_t) | ||
52 | DO_VADDV(vaddvuw, 4, uint32_t) | ||
53 | |||
54 | +#define DO_VADDLV(OP, TYPE, LTYPE) \ | ||
55 | + uint64_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vm, \ | ||
56 | + uint64_t ra) \ | ||
57 | + { \ | ||
58 | + uint16_t mask = mve_element_mask(env); \ | ||
59 | + unsigned e; \ | ||
60 | + TYPE *m = vm; \ | ||
61 | + for (e = 0; e < 16 / 4; e++, mask >>= 4) { \ | ||
62 | + if (mask & 1) { \ | ||
63 | + ra += (LTYPE)m[H4(e)]; \ | ||
64 | + } \ | ||
65 | + } \ | ||
66 | + mve_advance_vpt(env); \ | ||
67 | + return ra; \ | ||
68 | + } \ | ||
69 | + | ||
70 | +DO_VADDLV(vaddlv_s, int32_t, int64_t) | ||
71 | +DO_VADDLV(vaddlv_u, uint32_t, uint64_t) | ||
72 | + | ||
73 | /* Shifts by immediate */ | ||
74 | #define DO_2SHIFT(OP, ESIZE, TYPE, FN) \ | ||
75 | void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ | ||
76 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
77 | index XXXXXXX..XXXXXXX 100644 | ||
78 | --- a/target/arm/translate-mve.c | ||
79 | +++ b/target/arm/translate-mve.c | ||
80 | @@ -XXX,XX +XXX,XX @@ static bool trans_VADDV(DisasContext *s, arg_VADDV *a) | ||
81 | return true; | ||
82 | } | 24 | } |
83 | 25 | ||
84 | +static bool trans_VADDLV(DisasContext *s, arg_VADDLV *a) | 26 | -static void target_restore_sve_record(CPUARMState *env, |
85 | +{ | 27 | - struct target_sve_context *sve, int vq) |
86 | + /* | 28 | +static bool target_restore_sve_record(CPUARMState *env, |
87 | + * Vector Add Long Across Vector: accumulate the 32-bit | 29 | + struct target_sve_context *sve, |
88 | + * elements of the vector into a 64-bit result stored in | 30 | + int size) |
89 | + * a pair of general-purpose registers. | 31 | { |
90 | + * No need to check Qm's bank: it is only 3 bits in decode. | 32 | - int i, j; |
91 | + */ | 33 | + int i, j, vl, vq; |
92 | + TCGv_ptr qm; | 34 | |
93 | + TCGv_i64 rda; | 35 | - /* Note that SVE regs are stored as a byte stream, with each byte element |
94 | + TCGv_i32 rdalo, rdahi; | 36 | + if (!cpu_isar_feature(aa64_sve, env_archcpu(env))) { |
95 | + | ||
96 | + if (!dc_isar_feature(aa32_mve, s)) { | ||
97 | + return false; | 37 | + return false; |
98 | + } | 38 | + } |
99 | + /* | 39 | + |
100 | + * rdahi == 13 is UNPREDICTABLE; rdahi == 15 is a related | 40 | + __get_user(vl, &sve->vl); |
101 | + * encoding; rdalo always has bit 0 clear so cannot be 13 or 15. | 41 | + vq = sve_vq(env); |
102 | + */ | 42 | + |
103 | + if (a->rdahi == 13 || a->rdahi == 15) { | 43 | + /* Reject mismatched VL. */ |
44 | + if (vl != vq * TARGET_SVE_VQ_BYTES) { | ||
104 | + return false; | 45 | + return false; |
105 | + } | 46 | + } |
106 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | 47 | + |
48 | + /* Accept empty record -- used to clear PSTATE.SM. */ | ||
49 | + if (size <= sizeof(*sve)) { | ||
107 | + return true; | 50 | + return true; |
108 | + } | 51 | + } |
109 | + | 52 | + |
110 | + /* | 53 | + /* Reject non-empty but incomplete record. */ |
111 | + * This insn is subject to beat-wise execution. Partial execution | 54 | + if (size < TARGET_SVE_SIG_CONTEXT_SIZE(vq)) { |
112 | + * of an A=0 (no-accumulate) insn which does not execute the first | 55 | + return false; |
113 | + * beat must start with the current value of RdaHi:RdaLo, not zero. | ||
114 | + */ | ||
115 | + if (a->a || mve_skip_first_beat(s)) { | ||
116 | + /* Accumulate input from RdaHi:RdaLo */ | ||
117 | + rda = tcg_temp_new_i64(); | ||
118 | + rdalo = load_reg(s, a->rdalo); | ||
119 | + rdahi = load_reg(s, a->rdahi); | ||
120 | + tcg_gen_concat_i32_i64(rda, rdalo, rdahi); | ||
121 | + tcg_temp_free_i32(rdalo); | ||
122 | + tcg_temp_free_i32(rdahi); | ||
123 | + } else { | ||
124 | + /* Accumulate starting at zero */ | ||
125 | + rda = tcg_const_i64(0); | ||
126 | + } | 56 | + } |
127 | + | 57 | + |
128 | + qm = mve_qreg_ptr(a->qm); | 58 | + /* |
129 | + if (a->u) { | 59 | + * Note that SVE regs are stored as a byte stream, with each byte element |
130 | + gen_helper_mve_vaddlv_u(rda, cpu_env, qm, rda); | 60 | * at a subsequent address. This corresponds to a little-endian load |
131 | + } else { | 61 | * of our 64-bit hunks. |
132 | + gen_helper_mve_vaddlv_s(rda, cpu_env, qm, rda); | 62 | */ |
133 | + } | 63 | @@ -XXX,XX +XXX,XX @@ static void target_restore_sve_record(CPUARMState *env, |
134 | + tcg_temp_free_ptr(qm); | 64 | } |
135 | + | 65 | } |
136 | + rdalo = tcg_temp_new_i32(); | 66 | } |
137 | + rdahi = tcg_temp_new_i32(); | ||
138 | + tcg_gen_extrl_i64_i32(rdalo, rda); | ||
139 | + tcg_gen_extrh_i64_i32(rdahi, rda); | ||
140 | + store_reg(s, a->rdalo, rdalo); | ||
141 | + store_reg(s, a->rdahi, rdahi); | ||
142 | + tcg_temp_free_i64(rda); | ||
143 | + mve_update_eci(s); | ||
144 | + return true; | 67 | + return true; |
145 | +} | 68 | } |
146 | + | 69 | |
147 | static bool do_1imm(DisasContext *s, arg_1imm *a, MVEGenOneOpImmFn *fn) | 70 | static int target_restore_sigframe(CPUARMState *env, |
148 | { | 71 | @@ -XXX,XX +XXX,XX @@ static int target_restore_sigframe(CPUARMState *env, |
149 | TCGv_ptr qd; | 72 | struct target_sve_context *sve = NULL; |
73 | uint64_t extra_datap = 0; | ||
74 | bool used_extra = false; | ||
75 | - int vq = 0, sve_size = 0; | ||
76 | + int sve_size = 0; | ||
77 | |||
78 | target_restore_general_frame(env, sf); | ||
79 | |||
80 | @@ -XXX,XX +XXX,XX @@ static int target_restore_sigframe(CPUARMState *env, | ||
81 | if (sve || size < sizeof(struct target_sve_context)) { | ||
82 | goto err; | ||
83 | } | ||
84 | - if (cpu_isar_feature(aa64_sve, env_archcpu(env))) { | ||
85 | - vq = sve_vq(env); | ||
86 | - sve_size = QEMU_ALIGN_UP(TARGET_SVE_SIG_CONTEXT_SIZE(vq), 16); | ||
87 | - if (size == sve_size) { | ||
88 | - sve = (struct target_sve_context *)ctx; | ||
89 | - break; | ||
90 | - } | ||
91 | - } | ||
92 | - goto err; | ||
93 | + sve = (struct target_sve_context *)ctx; | ||
94 | + sve_size = size; | ||
95 | + break; | ||
96 | |||
97 | case TARGET_EXTRA_MAGIC: | ||
98 | if (extra || size != sizeof(struct target_extra_context)) { | ||
99 | @@ -XXX,XX +XXX,XX @@ static int target_restore_sigframe(CPUARMState *env, | ||
100 | } | ||
101 | |||
102 | /* SVE data, if present, overwrites FPSIMD data. */ | ||
103 | - if (sve) { | ||
104 | - target_restore_sve_record(env, sve, vq); | ||
105 | + if (sve && !target_restore_sve_record(env, sve, sve_size)) { | ||
106 | + goto err; | ||
107 | } | ||
108 | unlock_user(extra, extra_datap, 0); | ||
109 | return 0; | ||
150 | -- | 110 | -- |
151 | 2.20.1 | 111 | 2.25.1 |
152 | |||
153 | diff view generated by jsdifflib |
1 | The MVE extension to v8.1M includes some new shift instructions which | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | sit entirely within the non-coprocessor part of the encoding space | ||
3 | and which operate only on general-purpose registers. They take up | ||
4 | the space which was previously UNPREDICTABLE MOVS and ORRS encodings | ||
5 | with Rm == 13 or 15. | ||
6 | 2 | ||
7 | Implement the long shifts by immediate, which perform shifts on a | 3 | Set the SM bit in the SVE record on signal delivery, create the ZA record. |
8 | pair of general-purpose registers treated as a 64-bit quantity, with | 4 | Restore SM and ZA state according to the records present on return. |
9 | an immediate shift count between 1 and 32. | ||
10 | 5 | ||
11 | Awkwardly, because the MOVS and ORRS trans functions do not UNDEF for | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
12 | the Rm==13,15 case, we need to explicitly emit code to UNDEF for the | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
13 | cases where v8.1M now requires that. (Trying to change MOVS and ORRS | 8 | Message-id: 20220708151540.18136-41-richard.henderson@linaro.org |
14 | is too difficult, because the functions that generate the code are | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | shared between a dozen different kinds of arithmetic or logical | 10 | --- |
16 | instruction for all A32, T16 and T32 encodings, and for some insns | 11 | linux-user/aarch64/signal.c | 167 +++++++++++++++++++++++++++++++++--- |
17 | and some encodings Rm==13,15 are valid.) | 12 | 1 file changed, 154 insertions(+), 13 deletions(-) |
18 | 13 | ||
19 | We make the helper functions we need for UQSHLL and SQSHLL take | 14 | diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c |
20 | a 32-bit value which the helper casts to int8_t because we'll need | ||
21 | these helpers also for the shift-by-register insns, where the shift | ||
22 | count might be < 0 or > 32. | ||
23 | |||
24 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
25 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
26 | Message-id: 20210628135835.6690-16-peter.maydell@linaro.org | ||
27 | --- | ||
28 | target/arm/helper-mve.h | 3 ++ | ||
29 | target/arm/translate.h | 1 + | ||
30 | target/arm/t32.decode | 28 +++++++++++++ | ||
31 | target/arm/mve_helper.c | 10 +++++ | ||
32 | target/arm/translate.c | 90 +++++++++++++++++++++++++++++++++++++++++ | ||
33 | 5 files changed, 132 insertions(+) | ||
34 | |||
35 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
36 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
37 | --- a/target/arm/helper-mve.h | 16 | --- a/linux-user/aarch64/signal.c |
38 | +++ b/target/arm/helper-mve.h | 17 | +++ b/linux-user/aarch64/signal.c |
39 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqrshruntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 18 | @@ -XXX,XX +XXX,XX @@ struct target_sve_context { |
40 | DEF_HELPER_FLAGS_4(mve_vqrshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 19 | |
41 | 20 | #define TARGET_SVE_SIG_FLAG_SM 1 | |
42 | DEF_HELPER_FLAGS_4(mve_vshlc, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) | 21 | |
43 | + | 22 | +#define TARGET_ZA_MAGIC 0x54366345 |
44 | +DEF_HELPER_FLAGS_3(mve_sqshll, TCG_CALL_NO_RWG, i64, env, i64, i32) | 23 | + |
45 | +DEF_HELPER_FLAGS_3(mve_uqshll, TCG_CALL_NO_RWG, i64, env, i64, i32) | 24 | +struct target_za_context { |
46 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 25 | + struct target_aarch64_ctx head; |
47 | index XXXXXXX..XXXXXXX 100644 | 26 | + uint16_t vl; |
48 | --- a/target/arm/translate.h | 27 | + uint16_t reserved[3]; |
49 | +++ b/target/arm/translate.h | 28 | + /* The actual ZA data immediately follows. */ |
50 | @@ -XXX,XX +XXX,XX @@ typedef void CryptoTwoOpFn(TCGv_ptr, TCGv_ptr); | 29 | +}; |
51 | typedef void CryptoThreeOpIntFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | 30 | + |
52 | typedef void CryptoThreeOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | 31 | +#define TARGET_ZA_SIG_REGS_OFFSET \ |
53 | typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp); | 32 | + QEMU_ALIGN_UP(sizeof(struct target_za_context), TARGET_SVE_VQ_BYTES) |
54 | +typedef void WideShiftImmFn(TCGv_i64, TCGv_i64, int64_t shift); | 33 | +#define TARGET_ZA_SIG_ZAV_OFFSET(VQ, N) \ |
55 | 34 | + (TARGET_ZA_SIG_REGS_OFFSET + (VQ) * TARGET_SVE_VQ_BYTES * (N)) | |
56 | /** | 35 | +#define TARGET_ZA_SIG_CONTEXT_SIZE(VQ) \ |
57 | * arm_tbflags_from_tb: | 36 | + TARGET_ZA_SIG_ZAV_OFFSET(VQ, VQ * TARGET_SVE_VQ_BYTES) |
58 | diff --git a/target/arm/t32.decode b/target/arm/t32.decode | 37 | + |
59 | index XXXXXXX..XXXXXXX 100644 | 38 | struct target_rt_sigframe { |
60 | --- a/target/arm/t32.decode | 39 | struct target_siginfo info; |
61 | +++ b/target/arm/t32.decode | 40 | struct target_ucontext uc; |
62 | @@ -XXX,XX +XXX,XX @@ | 41 | @@ -XXX,XX +XXX,XX @@ static void target_setup_end_record(struct target_aarch64_ctx *end) |
63 | &mcr !extern cp opc1 crn crm opc2 rt | ||
64 | &mcrr !extern cp opc1 crm rt rt2 | ||
65 | |||
66 | +&mve_shl_ri rdalo rdahi shim | ||
67 | + | ||
68 | +# rdahi: bits [3:1] from insn, bit 0 is 1 | ||
69 | +# rdalo: bits [3:1] from insn, bit 0 is 0 | ||
70 | +%rdahi_9 9:3 !function=times_2_plus_1 | ||
71 | +%rdalo_17 17:3 !function=times_2 | ||
72 | + | ||
73 | # Data-processing (register) | ||
74 | |||
75 | %imm5_12_6 12:3 6:2 | ||
76 | @@ -XXX,XX +XXX,XX @@ | ||
77 | @S_xrr_shi ....... .... . rn:4 .... .... .. shty:2 rm:4 \ | ||
78 | &s_rrr_shi shim=%imm5_12_6 s=1 rd=0 | ||
79 | |||
80 | +@mve_shl_ri ....... .... . ... . . ... ... . .. .. .... \ | ||
81 | + &mve_shl_ri shim=%imm5_12_6 rdalo=%rdalo_17 rdahi=%rdahi_9 | ||
82 | + | ||
83 | { | ||
84 | TST_xrri 1110101 0000 1 .... 0 ... 1111 .... .... @S_xrr_shi | ||
85 | AND_rrri 1110101 0000 . .... 0 ... .... .... .... @s_rrr_shi | ||
86 | } | 42 | } |
87 | BIC_rrri 1110101 0001 . .... 0 ... .... .... .... @s_rrr_shi | 43 | |
88 | { | 44 | static void target_setup_sve_record(struct target_sve_context *sve, |
89 | + # The v8.1M MVE shift insns overlap in encoding with MOVS/ORRS | 45 | - CPUARMState *env, int vq, int size) |
90 | + # and are distinguished by having Rm==13 or 15. Those are UNPREDICTABLE | 46 | + CPUARMState *env, int size) |
91 | + # cases for MOVS/ORRS. We decode the MVE cases first, ensuring that | 47 | { |
92 | + # they explicitly call unallocated_encoding() for cases that must UNDEF | 48 | - int i, j; |
93 | + # (eg "using a new shift insn on a v8.1M CPU without MVE"), and letting | 49 | + int i, j, vq = sve_vq(env); |
94 | + # the rest fall through (where ORR_rrri and MOV_rxri will end up | 50 | |
95 | + # handling them as r13 and r15 accesses with the same semantics as A32). | 51 | memset(sve, 0, sizeof(*sve)); |
96 | + [ | 52 | __put_user(TARGET_SVE_MAGIC, &sve->head.magic); |
97 | + LSLL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 00 1111 @mve_shl_ri | 53 | @@ -XXX,XX +XXX,XX @@ static void target_setup_sve_record(struct target_sve_context *sve, |
98 | + LSRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 01 1111 @mve_shl_ri | 54 | } |
99 | + ASRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 10 1111 @mve_shl_ri | ||
100 | + | ||
101 | + UQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 00 1111 @mve_shl_ri | ||
102 | + URSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 01 1111 @mve_shl_ri | ||
103 | + SRSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 10 1111 @mve_shl_ri | ||
104 | + SQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 11 1111 @mve_shl_ri | ||
105 | + ] | ||
106 | + | ||
107 | MOV_rxri 1110101 0010 . 1111 0 ... .... .... .... @s_rxr_shi | ||
108 | ORR_rrri 1110101 0010 . .... 0 ... .... .... .... @s_rrr_shi | ||
109 | } | 55 | } |
110 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | 56 | |
111 | index XXXXXXX..XXXXXXX 100644 | 57 | +static void target_setup_za_record(struct target_za_context *za, |
112 | --- a/target/arm/mve_helper.c | 58 | + CPUARMState *env, int size) |
113 | +++ b/target/arm/mve_helper.c | ||
114 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(mve_vshlc)(CPUARMState *env, void *vd, uint32_t rdm, | ||
115 | mve_advance_vpt(env); | ||
116 | return rdm; | ||
117 | } | ||
118 | + | ||
119 | +uint64_t HELPER(mve_sqshll)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
120 | +{ | 59 | +{ |
121 | + return do_sqrshl_d(n, (int8_t)shift, false, &env->QF); | 60 | + int vq = sme_vq(env); |
61 | + int vl = vq * TARGET_SVE_VQ_BYTES; | ||
62 | + int i, j; | ||
63 | + | ||
64 | + memset(za, 0, sizeof(*za)); | ||
65 | + __put_user(TARGET_ZA_MAGIC, &za->head.magic); | ||
66 | + __put_user(size, &za->head.size); | ||
67 | + __put_user(vl, &za->vl); | ||
68 | + | ||
69 | + if (size == TARGET_ZA_SIG_CONTEXT_SIZE(0)) { | ||
70 | + return; | ||
71 | + } | ||
72 | + assert(size == TARGET_ZA_SIG_CONTEXT_SIZE(vq)); | ||
73 | + | ||
74 | + /* | ||
75 | + * Note that ZA vectors are stored as a byte stream, | ||
76 | + * with each byte element at a subsequent address. | ||
77 | + */ | ||
78 | + for (i = 0; i < vl; ++i) { | ||
79 | + uint64_t *z = (void *)za + TARGET_ZA_SIG_ZAV_OFFSET(vq, i); | ||
80 | + for (j = 0; j < vq * 2; ++j) { | ||
81 | + __put_user_e(env->zarray[i].d[j], z + j, le); | ||
82 | + } | ||
83 | + } | ||
122 | +} | 84 | +} |
123 | + | 85 | + |
124 | +uint64_t HELPER(mve_uqshll)(CPUARMState *env, uint64_t n, uint32_t shift) | 86 | static void target_restore_general_frame(CPUARMState *env, |
125 | +{ | 87 | struct target_rt_sigframe *sf) |
126 | + return do_uqrshl_d(n, (int8_t)shift, false, &env->QF); | 88 | { |
127 | +} | 89 | @@ -XXX,XX +XXX,XX @@ static void target_restore_fpsimd_record(CPUARMState *env, |
128 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 90 | |
129 | index XXXXXXX..XXXXXXX 100644 | 91 | static bool target_restore_sve_record(CPUARMState *env, |
130 | --- a/target/arm/translate.c | 92 | struct target_sve_context *sve, |
131 | +++ b/target/arm/translate.c | 93 | - int size) |
132 | @@ -XXX,XX +XXX,XX @@ static bool trans_MOVT(DisasContext *s, arg_MOVW *a) | 94 | + int size, int *svcr) |
95 | { | ||
96 | - int i, j, vl, vq; | ||
97 | + int i, j, vl, vq, flags; | ||
98 | + bool sm; | ||
99 | |||
100 | - if (!cpu_isar_feature(aa64_sve, env_archcpu(env))) { | ||
101 | + __get_user(vl, &sve->vl); | ||
102 | + __get_user(flags, &sve->flags); | ||
103 | + | ||
104 | + sm = flags & TARGET_SVE_SIG_FLAG_SM; | ||
105 | + | ||
106 | + /* The cpu must support Streaming or Non-streaming SVE. */ | ||
107 | + if (sm | ||
108 | + ? !cpu_isar_feature(aa64_sme, env_archcpu(env)) | ||
109 | + : !cpu_isar_feature(aa64_sve, env_archcpu(env))) { | ||
110 | return false; | ||
111 | } | ||
112 | |||
113 | - __get_user(vl, &sve->vl); | ||
114 | - vq = sve_vq(env); | ||
115 | + /* | ||
116 | + * Note that we cannot use sve_vq() because that depends on the | ||
117 | + * current setting of PSTATE.SM, not the state to be restored. | ||
118 | + */ | ||
119 | + vq = sve_vqm1_for_el_sm(env, 0, sm) + 1; | ||
120 | |||
121 | /* Reject mismatched VL. */ | ||
122 | if (vl != vq * TARGET_SVE_VQ_BYTES) { | ||
123 | @@ -XXX,XX +XXX,XX @@ static bool target_restore_sve_record(CPUARMState *env, | ||
124 | return false; | ||
125 | } | ||
126 | |||
127 | + *svcr = FIELD_DP64(*svcr, SVCR, SM, sm); | ||
128 | + | ||
129 | /* | ||
130 | * Note that SVE regs are stored as a byte stream, with each byte element | ||
131 | * at a subsequent address. This corresponds to a little-endian load | ||
132 | @@ -XXX,XX +XXX,XX @@ static bool target_restore_sve_record(CPUARMState *env, | ||
133 | return true; | 133 | return true; |
134 | } | 134 | } |
135 | 135 | ||
136 | +/* | 136 | +static bool target_restore_za_record(CPUARMState *env, |
137 | + * v8.1M MVE wide-shifts | 137 | + struct target_za_context *za, |
138 | + */ | 138 | + int size, int *svcr) |
139 | +static bool do_mve_shl_ri(DisasContext *s, arg_mve_shl_ri *a, | ||
140 | + WideShiftImmFn *fn) | ||
141 | +{ | 139 | +{ |
142 | + TCGv_i64 rda; | 140 | + int i, j, vl, vq; |
143 | + TCGv_i32 rdalo, rdahi; | 141 | + |
144 | + | 142 | + if (!cpu_isar_feature(aa64_sme, env_archcpu(env))) { |
145 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { | ||
146 | + /* Decode falls through to ORR/MOV UNPREDICTABLE handling */ | ||
147 | + return false; | 143 | + return false; |
148 | + } | 144 | + } |
149 | + if (a->rdahi == 15) { | 145 | + |
150 | + /* These are a different encoding (SQSHL/SRSHR/UQSHL/URSHR) */ | 146 | + __get_user(vl, &za->vl); |
147 | + vq = sme_vq(env); | ||
148 | + | ||
149 | + /* Reject mismatched VL. */ | ||
150 | + if (vl != vq * TARGET_SVE_VQ_BYTES) { | ||
151 | + return false; | 151 | + return false; |
152 | + } | 152 | + } |
153 | + if (!dc_isar_feature(aa32_mve, s) || | 153 | + |
154 | + !arm_dc_feature(s, ARM_FEATURE_M_MAIN) || | 154 | + /* Accept empty record -- used to clear PSTATE.ZA. */ |
155 | + a->rdahi == 13) { | 155 | + if (size <= TARGET_ZA_SIG_CONTEXT_SIZE(0)) { |
156 | + /* RdaHi == 13 is UNPREDICTABLE; we choose to UNDEF */ | ||
157 | + unallocated_encoding(s); | ||
158 | + return true; | 156 | + return true; |
159 | + } | 157 | + } |
160 | + | 158 | + |
161 | + if (a->shim == 0) { | 159 | + /* Reject non-empty but incomplete record. */ |
162 | + a->shim = 32; | 160 | + if (size < TARGET_ZA_SIG_CONTEXT_SIZE(vq)) { |
163 | + } | 161 | + return false; |
164 | + | 162 | + } |
165 | + rda = tcg_temp_new_i64(); | 163 | + |
166 | + rdalo = load_reg(s, a->rdalo); | 164 | + *svcr = FIELD_DP64(*svcr, SVCR, ZA, 1); |
167 | + rdahi = load_reg(s, a->rdahi); | 165 | + |
168 | + tcg_gen_concat_i32_i64(rda, rdalo, rdahi); | 166 | + for (i = 0; i < vl; ++i) { |
169 | + | 167 | + uint64_t *z = (void *)za + TARGET_ZA_SIG_ZAV_OFFSET(vq, i); |
170 | + fn(rda, rda, a->shim); | 168 | + for (j = 0; j < vq * 2; ++j) { |
171 | + | 169 | + __get_user_e(env->zarray[i].d[j], z + j, le); |
172 | + tcg_gen_extrl_i64_i32(rdalo, rda); | 170 | + } |
173 | + tcg_gen_extrh_i64_i32(rdahi, rda); | 171 | + } |
174 | + store_reg(s, a->rdalo, rdalo); | ||
175 | + store_reg(s, a->rdahi, rdahi); | ||
176 | + tcg_temp_free_i64(rda); | ||
177 | + | ||
178 | + return true; | 172 | + return true; |
179 | +} | 173 | +} |
180 | + | 174 | + |
181 | +static bool trans_ASRL_ri(DisasContext *s, arg_mve_shl_ri *a) | 175 | static int target_restore_sigframe(CPUARMState *env, |
182 | +{ | 176 | struct target_rt_sigframe *sf) |
183 | + return do_mve_shl_ri(s, a, tcg_gen_sari_i64); | 177 | { |
184 | +} | 178 | struct target_aarch64_ctx *ctx, *extra = NULL; |
185 | + | 179 | struct target_fpsimd_context *fpsimd = NULL; |
186 | +static bool trans_LSLL_ri(DisasContext *s, arg_mve_shl_ri *a) | 180 | struct target_sve_context *sve = NULL; |
187 | +{ | 181 | + struct target_za_context *za = NULL; |
188 | + return do_mve_shl_ri(s, a, tcg_gen_shli_i64); | 182 | uint64_t extra_datap = 0; |
189 | +} | 183 | bool used_extra = false; |
190 | + | 184 | int sve_size = 0; |
191 | +static bool trans_LSRL_ri(DisasContext *s, arg_mve_shl_ri *a) | 185 | + int za_size = 0; |
192 | +{ | 186 | + int svcr = 0; |
193 | + return do_mve_shl_ri(s, a, tcg_gen_shri_i64); | 187 | |
194 | +} | 188 | target_restore_general_frame(env, sf); |
195 | + | 189 | |
196 | +static void gen_mve_sqshll(TCGv_i64 r, TCGv_i64 n, int64_t shift) | 190 | @@ -XXX,XX +XXX,XX @@ static int target_restore_sigframe(CPUARMState *env, |
197 | +{ | 191 | sve_size = size; |
198 | + gen_helper_mve_sqshll(r, cpu_env, n, tcg_constant_i32(shift)); | 192 | break; |
199 | +} | 193 | |
200 | + | 194 | + case TARGET_ZA_MAGIC: |
201 | +static bool trans_SQSHLL_ri(DisasContext *s, arg_mve_shl_ri *a) | 195 | + if (za || size < sizeof(struct target_za_context)) { |
202 | +{ | 196 | + goto err; |
203 | + return do_mve_shl_ri(s, a, gen_mve_sqshll); | 197 | + } |
204 | +} | 198 | + za = (struct target_za_context *)ctx; |
205 | + | 199 | + za_size = size; |
206 | +static void gen_mve_uqshll(TCGv_i64 r, TCGv_i64 n, int64_t shift) | 200 | + break; |
207 | +{ | 201 | + |
208 | + gen_helper_mve_uqshll(r, cpu_env, n, tcg_constant_i32(shift)); | 202 | case TARGET_EXTRA_MAGIC: |
209 | +} | 203 | if (extra || size != sizeof(struct target_extra_context)) { |
210 | + | 204 | goto err; |
211 | +static bool trans_UQSHLL_ri(DisasContext *s, arg_mve_shl_ri *a) | 205 | @@ -XXX,XX +XXX,XX @@ static int target_restore_sigframe(CPUARMState *env, |
212 | +{ | 206 | } |
213 | + return do_mve_shl_ri(s, a, gen_mve_uqshll); | 207 | |
214 | +} | 208 | /* SVE data, if present, overwrites FPSIMD data. */ |
215 | + | 209 | - if (sve && !target_restore_sve_record(env, sve, sve_size)) { |
216 | +static bool trans_SRSHRL_ri(DisasContext *s, arg_mve_shl_ri *a) | 210 | + if (sve && !target_restore_sve_record(env, sve, sve_size, &svcr)) { |
217 | +{ | 211 | goto err; |
218 | + return do_mve_shl_ri(s, a, gen_srshr64_i64); | 212 | } |
219 | +} | 213 | + if (za && !target_restore_za_record(env, za, za_size, &svcr)) { |
220 | + | 214 | + goto err; |
221 | +static bool trans_URSHRL_ri(DisasContext *s, arg_mve_shl_ri *a) | 215 | + } |
222 | +{ | 216 | + if (env->svcr != svcr) { |
223 | + return do_mve_shl_ri(s, a, gen_urshr64_i64); | 217 | + env->svcr = svcr; |
224 | +} | 218 | + arm_rebuild_hflags(env); |
225 | + | 219 | + } |
226 | /* | 220 | unlock_user(extra, extra_datap, 0); |
227 | * Multiply and multiply accumulate | 221 | return 0; |
228 | */ | 222 | |
223 | @@ -XXX,XX +XXX,XX @@ static void target_setup_frame(int usig, struct target_sigaction *ka, | ||
224 | .total_size = offsetof(struct target_rt_sigframe, | ||
225 | uc.tuc_mcontext.__reserved), | ||
226 | }; | ||
227 | - int fpsimd_ofs, fr_ofs, sve_ofs = 0, vq = 0, sve_size = 0; | ||
228 | + int fpsimd_ofs, fr_ofs, sve_ofs = 0, za_ofs = 0; | ||
229 | + int sve_size = 0, za_size = 0; | ||
230 | struct target_rt_sigframe *frame; | ||
231 | struct target_rt_frame_record *fr; | ||
232 | abi_ulong frame_addr, return_addr; | ||
233 | @@ -XXX,XX +XXX,XX @@ static void target_setup_frame(int usig, struct target_sigaction *ka, | ||
234 | &layout); | ||
235 | |||
236 | /* SVE state needs saving only if it exists. */ | ||
237 | - if (cpu_isar_feature(aa64_sve, env_archcpu(env))) { | ||
238 | - vq = sve_vq(env); | ||
239 | - sve_size = QEMU_ALIGN_UP(TARGET_SVE_SIG_CONTEXT_SIZE(vq), 16); | ||
240 | + if (cpu_isar_feature(aa64_sve, env_archcpu(env)) || | ||
241 | + cpu_isar_feature(aa64_sme, env_archcpu(env))) { | ||
242 | + sve_size = QEMU_ALIGN_UP(TARGET_SVE_SIG_CONTEXT_SIZE(sve_vq(env)), 16); | ||
243 | sve_ofs = alloc_sigframe_space(sve_size, &layout); | ||
244 | } | ||
245 | + if (cpu_isar_feature(aa64_sme, env_archcpu(env))) { | ||
246 | + /* ZA state needs saving only if it is enabled. */ | ||
247 | + if (FIELD_EX64(env->svcr, SVCR, ZA)) { | ||
248 | + za_size = TARGET_ZA_SIG_CONTEXT_SIZE(sme_vq(env)); | ||
249 | + } else { | ||
250 | + za_size = TARGET_ZA_SIG_CONTEXT_SIZE(0); | ||
251 | + } | ||
252 | + za_ofs = alloc_sigframe_space(za_size, &layout); | ||
253 | + } | ||
254 | |||
255 | if (layout.extra_ofs) { | ||
256 | /* Reserve space for the extra end marker. The standard end marker | ||
257 | @@ -XXX,XX +XXX,XX @@ static void target_setup_frame(int usig, struct target_sigaction *ka, | ||
258 | target_setup_end_record((void *)frame + layout.extra_end_ofs); | ||
259 | } | ||
260 | if (sve_ofs) { | ||
261 | - target_setup_sve_record((void *)frame + sve_ofs, env, vq, sve_size); | ||
262 | + target_setup_sve_record((void *)frame + sve_ofs, env, sve_size); | ||
263 | + } | ||
264 | + if (za_ofs) { | ||
265 | + target_setup_za_record((void *)frame + za_ofs, env, za_size); | ||
266 | } | ||
267 | |||
268 | /* Set up the stack frame for unwinding. */ | ||
269 | @@ -XXX,XX +XXX,XX @@ static void target_setup_frame(int usig, struct target_sigaction *ka, | ||
270 | env->btype = 2; | ||
271 | } | ||
272 | |||
273 | + /* | ||
274 | + * Invoke the signal handler with both SM and ZA disabled. | ||
275 | + * When clearing SM, ResetSVEState, per SMSTOP. | ||
276 | + */ | ||
277 | + if (FIELD_EX64(env->svcr, SVCR, SM)) { | ||
278 | + arm_reset_sve_state(env); | ||
279 | + } | ||
280 | + if (env->svcr) { | ||
281 | + env->svcr = 0; | ||
282 | + arm_rebuild_hflags(env); | ||
283 | + } | ||
284 | + | ||
285 | if (info) { | ||
286 | tswap_siginfo(&frame->info, info); | ||
287 | env->xregs[1] = frame_addr + offsetof(struct target_rt_sigframe, info); | ||
229 | -- | 288 | -- |
230 | 2.20.1 | 289 | 2.25.1 |
231 | |||
232 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Add "sve" to the sve prctl functions, to distinguish | ||
4 | them from the coming "sme" prctls with similar names. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220708151540.18136-42-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | linux-user/aarch64/target_prctl.h | 8 ++++---- | ||
12 | linux-user/syscall.c | 12 ++++++------ | ||
13 | 2 files changed, 10 insertions(+), 10 deletions(-) | ||
14 | |||
15 | diff --git a/linux-user/aarch64/target_prctl.h b/linux-user/aarch64/target_prctl.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/linux-user/aarch64/target_prctl.h | ||
18 | +++ b/linux-user/aarch64/target_prctl.h | ||
19 | @@ -XXX,XX +XXX,XX @@ | ||
20 | #ifndef AARCH64_TARGET_PRCTL_H | ||
21 | #define AARCH64_TARGET_PRCTL_H | ||
22 | |||
23 | -static abi_long do_prctl_get_vl(CPUArchState *env) | ||
24 | +static abi_long do_prctl_sve_get_vl(CPUArchState *env) | ||
25 | { | ||
26 | ARMCPU *cpu = env_archcpu(env); | ||
27 | if (cpu_isar_feature(aa64_sve, cpu)) { | ||
28 | @@ -XXX,XX +XXX,XX @@ static abi_long do_prctl_get_vl(CPUArchState *env) | ||
29 | } | ||
30 | return -TARGET_EINVAL; | ||
31 | } | ||
32 | -#define do_prctl_get_vl do_prctl_get_vl | ||
33 | +#define do_prctl_sve_get_vl do_prctl_sve_get_vl | ||
34 | |||
35 | -static abi_long do_prctl_set_vl(CPUArchState *env, abi_long arg2) | ||
36 | +static abi_long do_prctl_sve_set_vl(CPUArchState *env, abi_long arg2) | ||
37 | { | ||
38 | /* | ||
39 | * We cannot support either PR_SVE_SET_VL_ONEXEC or PR_SVE_VL_INHERIT. | ||
40 | @@ -XXX,XX +XXX,XX @@ static abi_long do_prctl_set_vl(CPUArchState *env, abi_long arg2) | ||
41 | } | ||
42 | return -TARGET_EINVAL; | ||
43 | } | ||
44 | -#define do_prctl_set_vl do_prctl_set_vl | ||
45 | +#define do_prctl_sve_set_vl do_prctl_sve_set_vl | ||
46 | |||
47 | static abi_long do_prctl_reset_keys(CPUArchState *env, abi_long arg2) | ||
48 | { | ||
49 | diff --git a/linux-user/syscall.c b/linux-user/syscall.c | ||
50 | index XXXXXXX..XXXXXXX 100644 | ||
51 | --- a/linux-user/syscall.c | ||
52 | +++ b/linux-user/syscall.c | ||
53 | @@ -XXX,XX +XXX,XX @@ static abi_long do_prctl_inval1(CPUArchState *env, abi_long arg2) | ||
54 | #ifndef do_prctl_set_fp_mode | ||
55 | #define do_prctl_set_fp_mode do_prctl_inval1 | ||
56 | #endif | ||
57 | -#ifndef do_prctl_get_vl | ||
58 | -#define do_prctl_get_vl do_prctl_inval0 | ||
59 | +#ifndef do_prctl_sve_get_vl | ||
60 | +#define do_prctl_sve_get_vl do_prctl_inval0 | ||
61 | #endif | ||
62 | -#ifndef do_prctl_set_vl | ||
63 | -#define do_prctl_set_vl do_prctl_inval1 | ||
64 | +#ifndef do_prctl_sve_set_vl | ||
65 | +#define do_prctl_sve_set_vl do_prctl_inval1 | ||
66 | #endif | ||
67 | #ifndef do_prctl_reset_keys | ||
68 | #define do_prctl_reset_keys do_prctl_inval1 | ||
69 | @@ -XXX,XX +XXX,XX @@ static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2, | ||
70 | case PR_SET_FP_MODE: | ||
71 | return do_prctl_set_fp_mode(env, arg2); | ||
72 | case PR_SVE_GET_VL: | ||
73 | - return do_prctl_get_vl(env); | ||
74 | + return do_prctl_sve_get_vl(env); | ||
75 | case PR_SVE_SET_VL: | ||
76 | - return do_prctl_set_vl(env, arg2); | ||
77 | + return do_prctl_sve_set_vl(env, arg2); | ||
78 | case PR_PAC_RESET_KEYS: | ||
79 | if (arg3 || arg4 || arg5) { | ||
80 | return -TARGET_EINVAL; | ||
81 | -- | ||
82 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | These prctl set the Streaming SVE vector length, which may | ||
4 | be completely different from the Normal SVE vector length. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220708151540.18136-43-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | linux-user/aarch64/target_prctl.h | 54 +++++++++++++++++++++++++++++++ | ||
12 | linux-user/syscall.c | 16 +++++++++ | ||
13 | 2 files changed, 70 insertions(+) | ||
14 | |||
15 | diff --git a/linux-user/aarch64/target_prctl.h b/linux-user/aarch64/target_prctl.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/linux-user/aarch64/target_prctl.h | ||
18 | +++ b/linux-user/aarch64/target_prctl.h | ||
19 | @@ -XXX,XX +XXX,XX @@ static abi_long do_prctl_sve_get_vl(CPUArchState *env) | ||
20 | { | ||
21 | ARMCPU *cpu = env_archcpu(env); | ||
22 | if (cpu_isar_feature(aa64_sve, cpu)) { | ||
23 | + /* PSTATE.SM is always unset on syscall entry. */ | ||
24 | return sve_vq(env) * 16; | ||
25 | } | ||
26 | return -TARGET_EINVAL; | ||
27 | @@ -XXX,XX +XXX,XX @@ static abi_long do_prctl_sve_set_vl(CPUArchState *env, abi_long arg2) | ||
28 | && arg2 >= 0 && arg2 <= 512 * 16 && !(arg2 & 15)) { | ||
29 | uint32_t vq, old_vq; | ||
30 | |||
31 | + /* PSTATE.SM is always unset on syscall entry. */ | ||
32 | old_vq = sve_vq(env); | ||
33 | |||
34 | /* | ||
35 | @@ -XXX,XX +XXX,XX @@ static abi_long do_prctl_sve_set_vl(CPUArchState *env, abi_long arg2) | ||
36 | } | ||
37 | #define do_prctl_sve_set_vl do_prctl_sve_set_vl | ||
38 | |||
39 | +static abi_long do_prctl_sme_get_vl(CPUArchState *env) | ||
40 | +{ | ||
41 | + ARMCPU *cpu = env_archcpu(env); | ||
42 | + if (cpu_isar_feature(aa64_sme, cpu)) { | ||
43 | + return sme_vq(env) * 16; | ||
44 | + } | ||
45 | + return -TARGET_EINVAL; | ||
46 | +} | ||
47 | +#define do_prctl_sme_get_vl do_prctl_sme_get_vl | ||
48 | + | ||
49 | +static abi_long do_prctl_sme_set_vl(CPUArchState *env, abi_long arg2) | ||
50 | +{ | ||
51 | + /* | ||
52 | + * We cannot support either PR_SME_SET_VL_ONEXEC or PR_SME_VL_INHERIT. | ||
53 | + * Note the kernel definition of sve_vl_valid allows for VQ=512, | ||
54 | + * i.e. VL=8192, even though the architectural maximum is VQ=16. | ||
55 | + */ | ||
56 | + if (cpu_isar_feature(aa64_sme, env_archcpu(env)) | ||
57 | + && arg2 >= 0 && arg2 <= 512 * 16 && !(arg2 & 15)) { | ||
58 | + int vq, old_vq; | ||
59 | + | ||
60 | + old_vq = sme_vq(env); | ||
61 | + | ||
62 | + /* | ||
63 | + * Bound the value of vq, so that we know that it fits into | ||
64 | + * the 4-bit field in SMCR_EL1. Because PSTATE.SM is cleared | ||
65 | + * on syscall entry, we are not modifying the current SVE | ||
66 | + * vector length. | ||
67 | + */ | ||
68 | + vq = MAX(arg2 / 16, 1); | ||
69 | + vq = MIN(vq, 16); | ||
70 | + env->vfp.smcr_el[1] = | ||
71 | + FIELD_DP64(env->vfp.smcr_el[1], SMCR, LEN, vq - 1); | ||
72 | + | ||
73 | + /* Delay rebuilding hflags until we know if ZA must change. */ | ||
74 | + vq = sve_vqm1_for_el_sm(env, 0, true) + 1; | ||
75 | + | ||
76 | + if (vq != old_vq) { | ||
77 | + /* | ||
78 | + * PSTATE.ZA state is cleared on any change to SVL. | ||
79 | + * We need not call arm_rebuild_hflags because PSTATE.SM was | ||
80 | + * cleared on syscall entry, so this hasn't changed VL. | ||
81 | + */ | ||
82 | + env->svcr = FIELD_DP64(env->svcr, SVCR, ZA, 0); | ||
83 | + arm_rebuild_hflags(env); | ||
84 | + } | ||
85 | + return vq * 16; | ||
86 | + } | ||
87 | + return -TARGET_EINVAL; | ||
88 | +} | ||
89 | +#define do_prctl_sme_set_vl do_prctl_sme_set_vl | ||
90 | + | ||
91 | static abi_long do_prctl_reset_keys(CPUArchState *env, abi_long arg2) | ||
92 | { | ||
93 | ARMCPU *cpu = env_archcpu(env); | ||
94 | diff --git a/linux-user/syscall.c b/linux-user/syscall.c | ||
95 | index XXXXXXX..XXXXXXX 100644 | ||
96 | --- a/linux-user/syscall.c | ||
97 | +++ b/linux-user/syscall.c | ||
98 | @@ -XXX,XX +XXX,XX @@ abi_long do_arch_prctl(CPUX86State *env, int code, abi_ulong addr) | ||
99 | #ifndef PR_SET_SYSCALL_USER_DISPATCH | ||
100 | # define PR_SET_SYSCALL_USER_DISPATCH 59 | ||
101 | #endif | ||
102 | +#ifndef PR_SME_SET_VL | ||
103 | +# define PR_SME_SET_VL 63 | ||
104 | +# define PR_SME_GET_VL 64 | ||
105 | +# define PR_SME_VL_LEN_MASK 0xffff | ||
106 | +# define PR_SME_VL_INHERIT (1 << 17) | ||
107 | +#endif | ||
108 | |||
109 | #include "target_prctl.h" | ||
110 | |||
111 | @@ -XXX,XX +XXX,XX @@ static abi_long do_prctl_inval1(CPUArchState *env, abi_long arg2) | ||
112 | #ifndef do_prctl_set_unalign | ||
113 | #define do_prctl_set_unalign do_prctl_inval1 | ||
114 | #endif | ||
115 | +#ifndef do_prctl_sme_get_vl | ||
116 | +#define do_prctl_sme_get_vl do_prctl_inval0 | ||
117 | +#endif | ||
118 | +#ifndef do_prctl_sme_set_vl | ||
119 | +#define do_prctl_sme_set_vl do_prctl_inval1 | ||
120 | +#endif | ||
121 | |||
122 | static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2, | ||
123 | abi_long arg3, abi_long arg4, abi_long arg5) | ||
124 | @@ -XXX,XX +XXX,XX @@ static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2, | ||
125 | return do_prctl_sve_get_vl(env); | ||
126 | case PR_SVE_SET_VL: | ||
127 | return do_prctl_sve_set_vl(env, arg2); | ||
128 | + case PR_SME_GET_VL: | ||
129 | + return do_prctl_sme_get_vl(env); | ||
130 | + case PR_SME_SET_VL: | ||
131 | + return do_prctl_sme_set_vl(env, arg2); | ||
132 | case PR_PAC_RESET_KEYS: | ||
133 | if (arg3 || arg4 || arg5) { | ||
134 | return -TARGET_EINVAL; | ||
135 | -- | ||
136 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Joe Komlodi <joe.komlodi@xilinx.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | If the CPU is running in default NaN mode (FPCR.DN == 1) and we execute | 3 | There's no reason to set CPACR_EL1.ZEN if SVE disabled. |
4 | FRSQRTE, FRECPE, or FRECPX with a signaling NaN, parts_silence_nan_frac() will | ||
5 | assert due to fpst->default_nan_mode being set. | ||
6 | 4 | ||
7 | To avoid this, we check to see what NaN mode we're running in before we call | ||
8 | floatxx_silence_nan(). | ||
9 | |||
10 | Signed-off-by: Joe Komlodi <joe.komlodi@xilinx.com> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-id: 1624662174-175828-2-git-send-email-joe.komlodi@xilinx.com | ||
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20220708151540.18136-44-richard.henderson@linaro.org | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 9 | --- |
16 | target/arm/helper-a64.c | 12 +++++++++--- | 10 | target/arm/cpu.c | 7 +++---- |
17 | target/arm/vfp_helper.c | 24 ++++++++++++++++++------ | 11 | 1 file changed, 3 insertions(+), 4 deletions(-) |
18 | 2 files changed, 27 insertions(+), 9 deletions(-) | ||
19 | 12 | ||
20 | diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c | 13 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
21 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/helper-a64.c | 15 | --- a/target/arm/cpu.c |
23 | +++ b/target/arm/helper-a64.c | 16 | +++ b/target/arm/cpu.c |
24 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(frecpx_f16)(uint32_t a, void *fpstp) | 17 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(DeviceState *dev) |
25 | float16 nan = a; | 18 | /* and to the FP/Neon instructions */ |
26 | if (float16_is_signaling_nan(a, fpst)) { | 19 | env->cp15.cpacr_el1 = FIELD_DP64(env->cp15.cpacr_el1, |
27 | float_raise(float_flag_invalid, fpst); | 20 | CPACR_EL1, FPEN, 3); |
28 | - nan = float16_silence_nan(a, fpst); | 21 | - /* and to the SVE instructions */ |
29 | + if (!fpst->default_nan_mode) { | 22 | - env->cp15.cpacr_el1 = FIELD_DP64(env->cp15.cpacr_el1, |
30 | + nan = float16_silence_nan(a, fpst); | 23 | - CPACR_EL1, ZEN, 3); |
31 | + } | 24 | - /* with reasonable vector length */ |
25 | + /* and to the SVE instructions, with default vector length */ | ||
26 | if (cpu_isar_feature(aa64_sve, cpu)) { | ||
27 | + env->cp15.cpacr_el1 = FIELD_DP64(env->cp15.cpacr_el1, | ||
28 | + CPACR_EL1, ZEN, 3); | ||
29 | env->vfp.zcr_el[1] = cpu->sve_default_vq - 1; | ||
32 | } | 30 | } |
33 | if (fpst->default_nan_mode) { | 31 | /* |
34 | nan = float16_default_nan(fpst); | ||
35 | @@ -XXX,XX +XXX,XX @@ float32 HELPER(frecpx_f32)(float32 a, void *fpstp) | ||
36 | float32 nan = a; | ||
37 | if (float32_is_signaling_nan(a, fpst)) { | ||
38 | float_raise(float_flag_invalid, fpst); | ||
39 | - nan = float32_silence_nan(a, fpst); | ||
40 | + if (!fpst->default_nan_mode) { | ||
41 | + nan = float32_silence_nan(a, fpst); | ||
42 | + } | ||
43 | } | ||
44 | if (fpst->default_nan_mode) { | ||
45 | nan = float32_default_nan(fpst); | ||
46 | @@ -XXX,XX +XXX,XX @@ float64 HELPER(frecpx_f64)(float64 a, void *fpstp) | ||
47 | float64 nan = a; | ||
48 | if (float64_is_signaling_nan(a, fpst)) { | ||
49 | float_raise(float_flag_invalid, fpst); | ||
50 | - nan = float64_silence_nan(a, fpst); | ||
51 | + if (!fpst->default_nan_mode) { | ||
52 | + nan = float64_silence_nan(a, fpst); | ||
53 | + } | ||
54 | } | ||
55 | if (fpst->default_nan_mode) { | ||
56 | nan = float64_default_nan(fpst); | ||
57 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | ||
58 | index XXXXXXX..XXXXXXX 100644 | ||
59 | --- a/target/arm/vfp_helper.c | ||
60 | +++ b/target/arm/vfp_helper.c | ||
61 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(recpe_f16)(uint32_t input, void *fpstp) | ||
62 | float16 nan = f16; | ||
63 | if (float16_is_signaling_nan(f16, fpst)) { | ||
64 | float_raise(float_flag_invalid, fpst); | ||
65 | - nan = float16_silence_nan(f16, fpst); | ||
66 | + if (!fpst->default_nan_mode) { | ||
67 | + nan = float16_silence_nan(f16, fpst); | ||
68 | + } | ||
69 | } | ||
70 | if (fpst->default_nan_mode) { | ||
71 | nan = float16_default_nan(fpst); | ||
72 | @@ -XXX,XX +XXX,XX @@ float32 HELPER(recpe_f32)(float32 input, void *fpstp) | ||
73 | float32 nan = f32; | ||
74 | if (float32_is_signaling_nan(f32, fpst)) { | ||
75 | float_raise(float_flag_invalid, fpst); | ||
76 | - nan = float32_silence_nan(f32, fpst); | ||
77 | + if (!fpst->default_nan_mode) { | ||
78 | + nan = float32_silence_nan(f32, fpst); | ||
79 | + } | ||
80 | } | ||
81 | if (fpst->default_nan_mode) { | ||
82 | nan = float32_default_nan(fpst); | ||
83 | @@ -XXX,XX +XXX,XX @@ float64 HELPER(recpe_f64)(float64 input, void *fpstp) | ||
84 | float64 nan = f64; | ||
85 | if (float64_is_signaling_nan(f64, fpst)) { | ||
86 | float_raise(float_flag_invalid, fpst); | ||
87 | - nan = float64_silence_nan(f64, fpst); | ||
88 | + if (!fpst->default_nan_mode) { | ||
89 | + nan = float64_silence_nan(f64, fpst); | ||
90 | + } | ||
91 | } | ||
92 | if (fpst->default_nan_mode) { | ||
93 | nan = float64_default_nan(fpst); | ||
94 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(rsqrte_f16)(uint32_t input, void *fpstp) | ||
95 | float16 nan = f16; | ||
96 | if (float16_is_signaling_nan(f16, s)) { | ||
97 | float_raise(float_flag_invalid, s); | ||
98 | - nan = float16_silence_nan(f16, s); | ||
99 | + if (!s->default_nan_mode) { | ||
100 | + nan = float16_silence_nan(f16, fpstp); | ||
101 | + } | ||
102 | } | ||
103 | if (s->default_nan_mode) { | ||
104 | nan = float16_default_nan(s); | ||
105 | @@ -XXX,XX +XXX,XX @@ float32 HELPER(rsqrte_f32)(float32 input, void *fpstp) | ||
106 | float32 nan = f32; | ||
107 | if (float32_is_signaling_nan(f32, s)) { | ||
108 | float_raise(float_flag_invalid, s); | ||
109 | - nan = float32_silence_nan(f32, s); | ||
110 | + if (!s->default_nan_mode) { | ||
111 | + nan = float32_silence_nan(f32, fpstp); | ||
112 | + } | ||
113 | } | ||
114 | if (s->default_nan_mode) { | ||
115 | nan = float32_default_nan(s); | ||
116 | @@ -XXX,XX +XXX,XX @@ float64 HELPER(rsqrte_f64)(float64 input, void *fpstp) | ||
117 | float64 nan = f64; | ||
118 | if (float64_is_signaling_nan(f64, s)) { | ||
119 | float_raise(float_flag_invalid, s); | ||
120 | - nan = float64_silence_nan(f64, s); | ||
121 | + if (!s->default_nan_mode) { | ||
122 | + nan = float64_silence_nan(f64, fpstp); | ||
123 | + } | ||
124 | } | ||
125 | if (s->default_nan_mode) { | ||
126 | nan = float64_default_nan(s); | ||
127 | -- | 32 | -- |
128 | 2.20.1 | 33 | 2.25.1 |
129 | |||
130 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Add a test booting and quickly shutdown a raspi2 machine, | 3 | Enable SME, TPIDR2_EL0, and FA64 if supported by the cpu. |
4 | to test the power management model: | ||
5 | 4 | ||
6 | (1/1) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_raspi2_initrd: | 5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | console: [ 0.000000] Booting Linux on physical CPU 0xf00 | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | console: [ 0.000000] Linux version 4.14.98-v7+ (dom@dom-XPS-13-9370) (gcc version 4.9.3 (crosstool-NG crosstool-ng-1.22.0-88-g8460611)) #1200 SMP Tue Feb 12 20:27:48 GMT 2019 | 7 | Message-id: 20220708151540.18136-45-richard.henderson@linaro.org |
9 | console: [ 0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c5387d | ||
10 | console: [ 0.000000] CPU: div instructions available: patching division code | ||
11 | console: [ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache | ||
12 | console: [ 0.000000] OF: fdt: Machine model: Raspberry Pi 2 Model B | ||
13 | ... | ||
14 | console: Boot successful. | ||
15 | console: cat /proc/cpuinfo | ||
16 | console: / # cat /proc/cpuinfo | ||
17 | ... | ||
18 | console: processor : 3 | ||
19 | console: model name : ARMv7 Processor rev 5 (v7l) | ||
20 | console: BogoMIPS : 125.00 | ||
21 | console: Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm | ||
22 | console: CPU implementer : 0x41 | ||
23 | console: CPU architecture: 7 | ||
24 | console: CPU variant : 0x0 | ||
25 | console: CPU part : 0xc07 | ||
26 | console: CPU revision : 5 | ||
27 | console: Hardware : BCM2835 | ||
28 | console: Revision : 0000 | ||
29 | console: Serial : 0000000000000000 | ||
30 | console: cat /proc/iomem | ||
31 | console: / # cat /proc/iomem | ||
32 | console: 00000000-3bffffff : System RAM | ||
33 | console: 00008000-00afffff : Kernel code | ||
34 | console: 00c00000-00d468ef : Kernel data | ||
35 | console: 3f006000-3f006fff : dwc_otg | ||
36 | console: 3f007000-3f007eff : /soc/dma@7e007000 | ||
37 | console: 3f00b880-3f00b8bf : /soc/mailbox@7e00b880 | ||
38 | console: 3f100000-3f100027 : /soc/watchdog@7e100000 | ||
39 | console: 3f101000-3f102fff : /soc/cprman@7e101000 | ||
40 | console: 3f200000-3f2000b3 : /soc/gpio@7e200000 | ||
41 | PASS (24.59 s) | ||
42 | RESULTS : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0 | ||
43 | JOB TIME : 25.02 s | ||
44 | |||
45 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
46 | Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com> | ||
47 | Message-id: 20210531113837.1689775-1-f4bug@amsat.org | ||
48 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
49 | --- | 9 | --- |
50 | tests/acceptance/boot_linux_console.py | 43 ++++++++++++++++++++++++++ | 10 | target/arm/cpu.c | 11 +++++++++++ |
51 | 1 file changed, 43 insertions(+) | 11 | 1 file changed, 11 insertions(+) |
52 | 12 | ||
53 | diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py | 13 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
54 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
55 | --- a/tests/acceptance/boot_linux_console.py | 15 | --- a/target/arm/cpu.c |
56 | +++ b/tests/acceptance/boot_linux_console.py | 16 | +++ b/target/arm/cpu.c |
57 | @@ -XXX,XX +XXX,XX @@ | 17 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(DeviceState *dev) |
58 | from avocado import skip | 18 | CPACR_EL1, ZEN, 3); |
59 | from avocado import skipUnless | 19 | env->vfp.zcr_el[1] = cpu->sve_default_vq - 1; |
60 | from avocado_qemu import Test | 20 | } |
61 | +from avocado_qemu import exec_command | 21 | + /* and for SME instructions, with default vector length, and TPIDR2 */ |
62 | from avocado_qemu import exec_command_and_wait_for_pattern | 22 | + if (cpu_isar_feature(aa64_sme, cpu)) { |
63 | from avocado_qemu import interrupt_interactive_console_until_pattern | 23 | + env->cp15.sctlr_el[1] |= SCTLR_EnTP2; |
64 | from avocado_qemu import wait_for_console_pattern | 24 | + env->cp15.cpacr_el1 = FIELD_DP64(env->cp15.cpacr_el1, |
65 | @@ -XXX,XX +XXX,XX @@ def test_arm_raspi2_uart0(self): | 25 | + CPACR_EL1, SMEN, 3); |
66 | """ | 26 | + env->vfp.smcr_el[1] = cpu->sme_default_vq - 1; |
67 | self.do_test_arm_raspi2(0) | 27 | + if (cpu_isar_feature(aa64_sme_fa64, cpu)) { |
68 | 28 | + env->vfp.smcr_el[1] = FIELD_DP64(env->vfp.smcr_el[1], | |
69 | + def test_arm_raspi2_initrd(self): | 29 | + SMCR, FA64, 1); |
70 | + """ | 30 | + } |
71 | + :avocado: tags=arch:arm | 31 | + } |
72 | + :avocado: tags=machine:raspi2 | 32 | /* |
73 | + """ | 33 | * Enable 48-bit address space (TODO: take reserved_va into account). |
74 | + deb_url = ('http://archive.raspberrypi.org/debian/' | 34 | * Enable TBI0 but not TBI1. |
75 | + 'pool/main/r/raspberrypi-firmware/' | ||
76 | + 'raspberrypi-kernel_1.20190215-1_armhf.deb') | ||
77 | + deb_hash = 'cd284220b32128c5084037553db3c482426f3972' | ||
78 | + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) | ||
79 | + kernel_path = self.extract_from_deb(deb_path, '/boot/kernel7.img') | ||
80 | + dtb_path = self.extract_from_deb(deb_path, '/boot/bcm2709-rpi-2-b.dtb') | ||
81 | + | ||
82 | + initrd_url = ('https://github.com/groeck/linux-build-test/raw/' | ||
83 | + '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' | ||
84 | + 'arm/rootfs-armv7a.cpio.gz') | ||
85 | + initrd_hash = '604b2e45cdf35045846b8bbfbf2129b1891bdc9c' | ||
86 | + initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash) | ||
87 | + initrd_path = os.path.join(self.workdir, 'rootfs.cpio') | ||
88 | + archive.gzip_uncompress(initrd_path_gz, initrd_path) | ||
89 | + | ||
90 | + self.vm.set_console() | ||
91 | + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + | ||
92 | + 'earlycon=pl011,0x3f201000 console=ttyAMA0 ' | ||
93 | + 'panic=-1 noreboot ' + | ||
94 | + 'dwc_otg.fiq_fsm_enable=0') | ||
95 | + self.vm.add_args('-kernel', kernel_path, | ||
96 | + '-dtb', dtb_path, | ||
97 | + '-initrd', initrd_path, | ||
98 | + '-append', kernel_command_line, | ||
99 | + '-no-reboot') | ||
100 | + self.vm.launch() | ||
101 | + self.wait_for_console_pattern('Boot successful.') | ||
102 | + | ||
103 | + exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', | ||
104 | + 'BCM2835') | ||
105 | + exec_command_and_wait_for_pattern(self, 'cat /proc/iomem', | ||
106 | + '/soc/cprman@7e101000') | ||
107 | + exec_command(self, 'halt') | ||
108 | + # Wait for VM to shut down gracefully | ||
109 | + self.vm.wait() | ||
110 | + | ||
111 | def test_arm_exynos4210_initrd(self): | ||
112 | """ | ||
113 | :avocado: tags=arch:arm | ||
114 | -- | 35 | -- |
115 | 2.20.1 | 36 | 2.25.1 |
116 | |||
117 | diff view generated by jsdifflib |
1 | From: Patrick Venture <venture@google.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Add line item reference to quanta-gbs-bmc machine. | 3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
4 | 4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | |
5 | Signed-off-by: Patrick Venture <venture@google.com> | 5 | Message-id: 20220708151540.18136-46-richard.henderson@linaro.org |
6 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
7 | Message-id: 20210615192848.1065297-3-venture@google.com | ||
8 | [PMM: fixed underline Sphinx warning] | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 7 | --- |
11 | docs/system/arm/nuvoton.rst | 5 +++-- | 8 | linux-user/elfload.c | 20 ++++++++++++++++++++ |
12 | 1 file changed, 3 insertions(+), 2 deletions(-) | 9 | 1 file changed, 20 insertions(+) |
13 | 10 | ||
14 | diff --git a/docs/system/arm/nuvoton.rst b/docs/system/arm/nuvoton.rst | 11 | diff --git a/linux-user/elfload.c b/linux-user/elfload.c |
15 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/docs/system/arm/nuvoton.rst | 13 | --- a/linux-user/elfload.c |
17 | +++ b/docs/system/arm/nuvoton.rst | 14 | +++ b/linux-user/elfload.c |
18 | @@ -XXX,XX +XXX,XX @@ | 15 | @@ -XXX,XX +XXX,XX @@ enum { |
19 | -Nuvoton iBMC boards (``npcm750-evb``, ``quanta-gsj``) | 16 | ARM_HWCAP2_A64_RNG = 1 << 16, |
20 | -===================================================== | 17 | ARM_HWCAP2_A64_BTI = 1 << 17, |
21 | +Nuvoton iBMC boards (``*-bmc``, ``npcm750-evb``, ``quanta-gsj``) | 18 | ARM_HWCAP2_A64_MTE = 1 << 18, |
22 | +================================================================ | 19 | + ARM_HWCAP2_A64_ECV = 1 << 19, |
23 | 20 | + ARM_HWCAP2_A64_AFP = 1 << 20, | |
24 | The `Nuvoton iBMC`_ chips (NPCM7xx) are a family of ARM-based SoCs that are | 21 | + ARM_HWCAP2_A64_RPRES = 1 << 21, |
25 | designed to be used as Baseboard Management Controllers (BMCs) in various | 22 | + ARM_HWCAP2_A64_MTE3 = 1 << 22, |
26 | @@ -XXX,XX +XXX,XX @@ segment. The following machines are based on this chip : | 23 | + ARM_HWCAP2_A64_SME = 1 << 23, |
27 | The NPCM730 SoC has two Cortex-A9 cores and is targeted for Data Center and | 24 | + ARM_HWCAP2_A64_SME_I16I64 = 1 << 24, |
28 | Hyperscale applications. The following machines are based on this chip : | 25 | + ARM_HWCAP2_A64_SME_F64F64 = 1 << 25, |
29 | 26 | + ARM_HWCAP2_A64_SME_I8I32 = 1 << 26, | |
30 | +- ``quanta-gbs-bmc`` Quanta GBS server BMC | 27 | + ARM_HWCAP2_A64_SME_F16F32 = 1 << 27, |
31 | - ``quanta-gsj`` Quanta GSJ server BMC | 28 | + ARM_HWCAP2_A64_SME_B16F32 = 1 << 28, |
32 | 29 | + ARM_HWCAP2_A64_SME_F32F32 = 1 << 29, | |
33 | There are also two more SoCs, NPCM710 and NPCM705, which are single-core | 30 | + ARM_HWCAP2_A64_SME_FA64 = 1 << 30, |
31 | }; | ||
32 | |||
33 | #define ELF_HWCAP get_elf_hwcap() | ||
34 | @@ -XXX,XX +XXX,XX @@ static uint32_t get_elf_hwcap2(void) | ||
35 | GET_FEATURE_ID(aa64_rndr, ARM_HWCAP2_A64_RNG); | ||
36 | GET_FEATURE_ID(aa64_bti, ARM_HWCAP2_A64_BTI); | ||
37 | GET_FEATURE_ID(aa64_mte, ARM_HWCAP2_A64_MTE); | ||
38 | + GET_FEATURE_ID(aa64_sme, (ARM_HWCAP2_A64_SME | | ||
39 | + ARM_HWCAP2_A64_SME_F32F32 | | ||
40 | + ARM_HWCAP2_A64_SME_B16F32 | | ||
41 | + ARM_HWCAP2_A64_SME_F16F32 | | ||
42 | + ARM_HWCAP2_A64_SME_I8I32)); | ||
43 | + GET_FEATURE_ID(aa64_sme_f64f64, ARM_HWCAP2_A64_SME_F64F64); | ||
44 | + GET_FEATURE_ID(aa64_sme_i16i64, ARM_HWCAP2_A64_SME_I16I64); | ||
45 | + GET_FEATURE_ID(aa64_sme_fa64, ARM_HWCAP2_A64_SME_FA64); | ||
46 | |||
47 | return hwcaps; | ||
48 | } | ||
34 | -- | 49 | -- |
35 | 2.20.1 | 50 | 2.25.1 |
36 | |||
37 | diff view generated by jsdifflib |