1
Arm queue -- I have more stuff pending but I prefer to push
1
The following changes since commit 5a67d7735d4162630769ef495cf813244fc850df:
2
this first lot out and keep the pull below 50 patches.
3
Most of this is Alex's FP16 support work.
4
2
5
-- PMM
3
Merge remote-tracking branch 'remotes/berrange-gitlab/tags/tls-deps-pull-request' into staging (2021-07-02 08:22:39 +0100)
6
7
8
The following changes since commit 6697439794f72b3501ee16bb95d16854f9981421:
9
10
Merge remote-tracking branch 'remotes/kraxel/tags/usb-20180227-pull-request' into staging (2018-02-27 17:50:46 +0000)
11
4
12
are available in the Git repository at:
5
are available in the Git repository at:
13
6
14
git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180301
7
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210702
15
8
16
for you to fetch changes up to c22e580c2ad1cccef582e1490e732f254d4ac064:
9
for you to fetch changes up to 04ea4d3cfd0a21b248ece8eb7a9436a3d9898dd8:
17
10
18
MAINTAINERS: Update my email address (2018-03-01 11:13:59 +0000)
11
target/arm: Implement MVE shifts by register (2021-07-02 11:48:38 +0100)
19
12
20
----------------------------------------------------------------
13
----------------------------------------------------------------
21
target-arm queue:
14
target-arm queue:
22
* update MAINTAINERS for Alistair's new email address
15
* more MVE instructions
23
* add Arm v8.2 FP16 arithmetic extension for linux-user
16
* hw/gpio/gpio_pwr: use shutdown function for reboot
24
* implement display connector emulation for vexpress board
17
* target/arm: Check NaN mode before silencing NaN
25
* xilinx_spips: Enable only two slaves when reading/writing with stripe
18
* tests: Boot and halt a Linux guest on the Raspberry Pi 2 machine
26
* xilinx_spips: Use 8 dummy cycles with the QIOR/QIOR4 commands
19
* hw/arm: Add basic power management to raspi.
27
* hw: register: Run post_write hook on reset
20
* docs/system/arm: Add quanta-gbs-bmc, quanta-q7l1-bmc
28
21
29
----------------------------------------------------------------
22
----------------------------------------------------------------
30
Alex Bennée (31):
23
Joe Komlodi (1):
31
include/exec/helper-head.h: support f16 in helper calls
24
target/arm: Check NaN mode before silencing NaN
32
target/arm/cpu64: introduce ARM_V8_FP16 feature bit
33
target/arm/cpu.h: update comment for half-precision values
34
target/arm/cpu.h: add additional float_status flags
35
target/arm/helper: pass explicit fpst to set_rmode
36
arm/translate-a64: implement half-precision F(MIN|MAX)(V|NMV)
37
arm/translate-a64: handle_3same_64 comment fix
38
arm/translate-a64: initial decode for simd_three_reg_same_fp16
39
arm/translate-a64: add FP16 FADD/FABD/FSUB/FMUL/FDIV to simd_three_reg_same_fp16
40
arm/translate-a64: add FP16 F[A]C[EQ/GE/GT] to simd_three_reg_same_fp16
41
arm/translate-a64: add FP16 FMULA/X/S to simd_three_reg_same_fp16
42
arm/translate-a64: add FP16 FR[ECP/SQRT]S to simd_three_reg_same_fp16
43
arm/translate-a64: add FP16 pairwise ops simd_three_reg_same_fp16
44
arm/translate-a64: add FP16 FMULX/MLS/FMLA to simd_indexed
45
arm/translate-a64: add FP16 x2 ops for simd_indexed
46
arm/translate-a64: initial decode for simd_two_reg_misc_fp16
47
arm/translate-a64: add FP16 FPRINTx to simd_two_reg_misc_fp16
48
arm/translate-a64: add FCVTxx to simd_two_reg_misc_fp16
49
arm/translate-a64: add FP16 FCMxx (zero) to simd_two_reg_misc_fp16
50
arm/translate-a64: add FP16 SCVTF/UCVFT to simd_two_reg_misc_fp16
51
arm/translate-a64: add FP16 FNEG/FABS to simd_two_reg_misc_fp16
52
arm/helper.c: re-factor recpe and add recepe_f16
53
arm/translate-a64: add FP16 FRECPE
54
arm/translate-a64: add FP16 FRCPX to simd_two_reg_misc_fp16
55
arm/translate-a64: add FP16 FSQRT to simd_two_reg_misc_fp16
56
arm/helper.c: re-factor rsqrte and add rsqrte_f16
57
arm/translate-a64: add FP16 FRSQRTE to simd_two_reg_misc_fp16
58
arm/translate-a64: add FP16 FMOV to simd_mod_imm
59
arm/translate-a64: add all FP16 ops in simd_scalar_pairwise
60
arm/translate-a64: implement simd_scalar_three_reg_same_fp16
61
arm/translate-a64: add all single op FP16 to handle_fp_1src_half
62
25
63
Alistair Francis (2):
26
Maxim Uvarov (1):
64
hw: register: Run post_write hook on reset
27
hw/gpio/gpio_pwr: use shutdown function for reboot
65
MAINTAINERS: Update my email address
66
28
67
Corey Minyard (2):
29
Nolan Leake (1):
68
i2c: Fix some brace style issues
30
hw/arm: Add basic power management to raspi.
69
i2c: Move the bus class to i2c.h
70
31
71
Francisco Iglesias (2):
32
Patrick Venture (2):
72
xilinx_spips: Enable only two slaves when reading/writing with stripe
33
docs/system/arm: Add quanta-q7l1-bmc reference
73
xilinx_spips: Use 8 dummy cycles with the QIOR/QIOR4 commands
34
docs/system/arm: Add quanta-gbs-bmc reference
74
35
75
Linus Walleij (3):
36
Peter Maydell (18):
76
hw/i2c-ddc: Do not fail writes
37
target/arm: Fix MVE widening/narrowing VLDR/VSTR offset calculation
77
hw/sii9022: Add support for Silicon Image SII9022
38
target/arm: Fix bugs in MVE VRMLALDAVH, VRMLSLDAVH
78
arm/vexpress: Add proper display connector emulation
39
target/arm: Make asimd_imm_const() public
40
target/arm: Use asimd_imm_const for A64 decode
41
target/arm: Use dup_const() instead of bitfield_replicate()
42
target/arm: Implement MVE logical immediate insns
43
target/arm: Implement MVE vector shift left by immediate insns
44
target/arm: Implement MVE vector shift right by immediate insns
45
target/arm: Implement MVE VSHLL
46
target/arm: Implement MVE VSRI, VSLI
47
target/arm: Implement MVE VSHRN, VRSHRN
48
target/arm: Implement MVE saturating narrowing shifts
49
target/arm: Implement MVE VSHLC
50
target/arm: Implement MVE VADDLV
51
target/arm: Implement MVE long shifts by immediate
52
target/arm: Implement MVE long shifts by register
53
target/arm: Implement MVE shifts by immediate
54
target/arm: Implement MVE shifts by register
79
55
80
Peter Maydell (2):
56
Philippe Mathieu-Daudé (1):
81
target/arm: Enable ARM_V8_FP16 feature bit for the AArch64 "any" CPU
57
tests: Boot and halt a Linux guest on the Raspberry Pi 2 machine
82
linux-user: Report AArch64 FP16 support via hwcap bits
83
58
84
hw/display/Makefile.objs | 1 +
59
docs/system/arm/aspeed.rst | 1 +
85
include/exec/helper-head.h | 3 +
60
docs/system/arm/nuvoton.rst | 5 +-
86
include/fpu/softfloat.h | 18 +-
61
include/hw/arm/bcm2835_peripherals.h | 3 +-
87
include/hw/i2c/i2c.h | 23 +-
62
include/hw/misc/bcm2835_powermgt.h | 29 ++
88
include/hw/register.h | 6 +-
63
target/arm/helper-mve.h | 108 +++++++
89
target/arm/cpu.h | 34 +-
64
target/arm/translate.h | 41 +++
90
target/arm/helper-a64.h | 33 +
65
target/arm/mve.decode | 177 ++++++++++-
91
target/arm/helper.h | 14 +-
66
target/arm/t32.decode | 71 ++++-
92
hw/arm/vexpress.c | 6 +-
67
hw/arm/bcm2835_peripherals.c | 13 +-
93
hw/core/register.c | 8 +
68
hw/gpio/gpio_pwr.c | 2 +-
94
hw/display/sii9022.c | 191 ++++++
69
hw/misc/bcm2835_powermgt.c | 160 ++++++++++
95
hw/i2c/core.c | 18 -
70
target/arm/helper-a64.c | 12 +-
96
hw/i2c/i2c-ddc.c | 4 +-
71
target/arm/mve_helper.c | 524 +++++++++++++++++++++++++++++++--
97
hw/ssi/xilinx_spips.c | 43 +-
72
target/arm/translate-a64.c | 86 +-----
98
linux-user/elfload.c | 2 +
73
target/arm/translate-mve.c | 261 +++++++++++++++-
99
target/arm/cpu64.c | 1 +
74
target/arm/translate-neon.c | 81 -----
100
target/arm/helper-a64.c | 269 +++++++++
75
target/arm/translate.c | 327 +++++++++++++++++++-
101
target/arm/helper.c | 481 ++++++++-------
76
target/arm/vfp_helper.c | 24 +-
102
target/arm/translate-a64.c | 1266 +++++++++++++++++++++++++++++++++------
77
hw/misc/meson.build | 1 +
103
target/arm/translate.c | 12 +-
78
tests/acceptance/boot_linux_console.py | 43 +++
104
MAINTAINERS | 12 +-
79
20 files changed, 1760 insertions(+), 209 deletions(-)
105
default-configs/arm-softmmu.mak | 2 +
80
create mode 100644 include/hw/misc/bcm2835_powermgt.h
106
hw/display/trace-events | 5 +
81
create mode 100644 hw/misc/bcm2835_powermgt.c
107
23 files changed, 1981 insertions(+), 471 deletions(-)
108
create mode 100644 hw/display/sii9022.c
109
82
diff view generated by jsdifflib
1
Now we have implemented FP16 we can enable it for the "any" CPU.
1
From: Patrick Venture <venture@google.com>
2
2
3
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
3
Adds a line-item reference to the supported quanta-q71l-bmc aspeed
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
4
entry.
5
[PMM: split out from an earlier patch in the series]
5
6
Signed-off-by: Patrick Venture <venture@google.com>
7
Reviewed-by: Cédric Le Goater <clg@kaod.org>
8
Message-id: 20210615192848.1065297-2-venture@google.com
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
10
---
8
target/arm/cpu64.c | 1 +
11
docs/system/arm/aspeed.rst | 1 +
9
1 file changed, 1 insertion(+)
12
1 file changed, 1 insertion(+)
10
13
11
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
14
diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst
12
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/cpu64.c
16
--- a/docs/system/arm/aspeed.rst
14
+++ b/target/arm/cpu64.c
17
+++ b/docs/system/arm/aspeed.rst
15
@@ -XXX,XX +XXX,XX @@ static void aarch64_any_initfn(Object *obj)
18
@@ -XXX,XX +XXX,XX @@ etc.
16
set_feature(&cpu->env, ARM_FEATURE_V8_SM4);
19
AST2400 SoC based machines :
17
set_feature(&cpu->env, ARM_FEATURE_V8_PMULL);
20
18
set_feature(&cpu->env, ARM_FEATURE_CRC);
21
- ``palmetto-bmc`` OpenPOWER Palmetto POWER8 BMC
19
+ set_feature(&cpu->env, ARM_FEATURE_V8_FP16);
22
+- ``quanta-q71l-bmc`` OpenBMC Quanta BMC
20
cpu->ctr = 0x80038003; /* 32 byte I and D cacheline size, VIPT icache */
23
21
cpu->dcz_blocksize = 7; /* 512 bytes */
24
AST2500 SoC based machines :
22
}
25
23
--
26
--
24
2.16.2
27
2.20.1
25
28
26
29
diff view generated by jsdifflib
1
From: Alistair Francis <alistair.francis@xilinx.com>
1
From: Patrick Venture <venture@google.com>
2
2
3
I am leaving Xilinx, so to avoid having an email address that bounces
3
Add line item reference to quanta-gbs-bmc machine.
4
update my maintainer address to point to my personal email address.
5
4
6
Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
5
Signed-off-by: Patrick Venture <venture@google.com>
7
Signed-off-by: Alistair Francis <alistair@alistair23.me>
6
Reviewed-by: Cédric Le Goater <clg@kaod.org>
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Message-id: 20210615192848.1065297-3-venture@google.com
9
Message-id: 7bb690382e3370aa1c1e047a84e36603c787ec0e.1519749987.git.alistair.francis@xilinx.com
8
[PMM: fixed underline Sphinx warning]
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
10
---
12
MAINTAINERS | 12 ++++++------
11
docs/system/arm/nuvoton.rst | 5 +++--
13
1 file changed, 6 insertions(+), 6 deletions(-)
12
1 file changed, 3 insertions(+), 2 deletions(-)
14
13
15
diff --git a/MAINTAINERS b/MAINTAINERS
14
diff --git a/docs/system/arm/nuvoton.rst b/docs/system/arm/nuvoton.rst
16
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
17
--- a/MAINTAINERS
16
--- a/docs/system/arm/nuvoton.rst
18
+++ b/MAINTAINERS
17
+++ b/docs/system/arm/nuvoton.rst
19
@@ -XXX,XX +XXX,XX @@ F: hw/misc/arm_sysctl.c
18
@@ -XXX,XX +XXX,XX @@
20
19
-Nuvoton iBMC boards (``npcm750-evb``, ``quanta-gsj``)
21
Xilinx Zynq
20
-=====================================================
22
M: Edgar E. Iglesias <edgar.iglesias@gmail.com>
21
+Nuvoton iBMC boards (``*-bmc``, ``npcm750-evb``, ``quanta-gsj``)
23
-M: Alistair Francis <alistair.francis@xilinx.com>
22
+================================================================
24
+M: Alistair Francis <alistair@alistair23.me>
23
25
L: qemu-arm@nongnu.org
24
The `Nuvoton iBMC`_ chips (NPCM7xx) are a family of ARM-based SoCs that are
26
S: Maintained
25
designed to be used as Baseboard Management Controllers (BMCs) in various
27
F: hw/*/xilinx_*
26
@@ -XXX,XX +XXX,XX @@ segment. The following machines are based on this chip :
28
@@ -XXX,XX +XXX,XX @@ F: include/hw/misc/zynq*
27
The NPCM730 SoC has two Cortex-A9 cores and is targeted for Data Center and
29
X: hw/ssi/xilinx_*
28
Hyperscale applications. The following machines are based on this chip :
30
29
31
Xilinx ZynqMP
30
+- ``quanta-gbs-bmc`` Quanta GBS server BMC
32
-M: Alistair Francis <alistair.francis@xilinx.com>
31
- ``quanta-gsj`` Quanta GSJ server BMC
33
+M: Alistair Francis <alistair@alistair23.me>
32
34
M: Edgar E. Iglesias <edgar.iglesias@gmail.com>
33
There are also two more SoCs, NPCM710 and NPCM705, which are single-core
35
L: qemu-arm@nongnu.org
36
S: Maintained
37
@@ -XXX,XX +XXX,XX @@ T: git git://github.com/bonzini/qemu.git scsi-next
38
39
SSI
40
M: Peter Crosthwaite <crosthwaite.peter@gmail.com>
41
-M: Alistair Francis <alistair.francis@xilinx.com>
42
+M: Alistair Francis <alistair@alistair23.me>
43
S: Maintained
44
F: hw/ssi/*
45
F: hw/block/m25p80.c
46
@@ -XXX,XX +XXX,XX @@ X: hw/ssi/xilinx_*
47
F: tests/m25p80-test.c
48
49
Xilinx SPI
50
-M: Alistair Francis <alistair.francis@xilinx.com>
51
+M: Alistair Francis <alistair@alistair23.me>
52
M: Peter Crosthwaite <crosthwaite.peter@gmail.com>
53
S: Maintained
54
F: hw/ssi/xilinx_*
55
@@ -XXX,XX +XXX,XX @@ S: Maintained
56
F: hw/net/eepro100.c
57
58
Generic Loader
59
-M: Alistair Francis <alistair.francis@xilinx.com>
60
+M: Alistair Francis <alistair@alistair23.me>
61
S: Maintained
62
F: hw/core/generic-loader.c
63
F: include/hw/core/generic-loader.h
64
@@ -XXX,XX +XXX,XX @@ F: tests/qmp-test.c
65
T: git git://repo.or.cz/qemu/armbru.git qapi-next
66
67
Register API
68
-M: Alistair Francis <alistair.francis@xilinx.com>
69
+M: Alistair Francis <alistair@alistair23.me>
70
S: Maintained
71
F: hw/core/register.c
72
F: include/hw/register.h
73
--
34
--
74
2.16.2
35
2.20.1
75
36
76
37
diff view generated by jsdifflib
1
From: Linus Walleij <linus.walleij@linaro.org>
1
From: Nolan Leake <nolan@sigbus.net>
2
2
3
This adds support for emulating the Silicon Image SII9022 DVI/HDMI
3
This is just enough to make reboot and poweroff work. Works for
4
bridge. It's not very clever right now, it just acknowledges
4
linux, u-boot, and the arm trusted firmware. Not tested, but should
5
the switch into DDC I2C mode and back. Combining this with the
5
work for plan9, and bare-metal/hobby OSes, since they seem to generally
6
existing DDC I2C emulation gives the right behavior on the Versatile
6
do what linux does for reset.
7
Express emulation passing through the QEMU EDID to the emulated
7
8
platform.
8
The watchdog timer functionality is not yet implemented.
9
9
10
Cc: Peter Maydell <peter.maydell@linaro.org>
10
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/64
11
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
11
Signed-off-by: Nolan Leake <nolan@sigbus.net>
12
Message-id: 20180227104903.21353-5-linus.walleij@linaro.org
12
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
13
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
14
[PMM: explictly reset ddc_req/ddc_skip_finish/ddc]
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/]
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
---
18
---
17
hw/display/Makefile.objs | 1 +
19
include/hw/arm/bcm2835_peripherals.h | 3 +-
18
hw/display/sii9022.c | 191 +++++++++++++++++++++++++++++++++++++++++++++++
20
include/hw/misc/bcm2835_powermgt.h | 29 +++++
19
hw/display/trace-events | 5 ++
21
hw/arm/bcm2835_peripherals.c | 13 ++-
20
3 files changed, 197 insertions(+)
22
hw/misc/bcm2835_powermgt.c | 160 +++++++++++++++++++++++++++
21
create mode 100644 hw/display/sii9022.c
23
hw/misc/meson.build | 1 +
22
24
5 files changed, 204 insertions(+), 2 deletions(-)
23
diff --git a/hw/display/Makefile.objs b/hw/display/Makefile.objs
25
create mode 100644 include/hw/misc/bcm2835_powermgt.h
26
create mode 100644 hw/misc/bcm2835_powermgt.c
27
28
diff --git a/include/hw/arm/bcm2835_peripherals.h b/include/hw/arm/bcm2835_peripherals.h
24
index XXXXXXX..XXXXXXX 100644
29
index XXXXXXX..XXXXXXX 100644
25
--- a/hw/display/Makefile.objs
30
--- a/include/hw/arm/bcm2835_peripherals.h
26
+++ b/hw/display/Makefile.objs
31
+++ b/include/hw/arm/bcm2835_peripherals.h
27
@@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_VGA_CIRRUS) += cirrus_vga.o
32
@@ -XXX,XX +XXX,XX @@
28
common-obj-$(CONFIG_G364FB) += g364fb.o
33
#include "hw/misc/bcm2835_mphi.h"
29
common-obj-$(CONFIG_JAZZ_LED) += jazz_led.o
34
#include "hw/misc/bcm2835_thermal.h"
30
common-obj-$(CONFIG_PL110) += pl110.o
35
#include "hw/misc/bcm2835_cprman.h"
31
+common-obj-$(CONFIG_SII9022) += sii9022.o
36
+#include "hw/misc/bcm2835_powermgt.h"
32
common-obj-$(CONFIG_SSD0303) += ssd0303.o
37
#include "hw/sd/sdhci.h"
33
common-obj-$(CONFIG_SSD0323) += ssd0323.o
38
#include "hw/sd/bcm2835_sdhost.h"
34
common-obj-$(CONFIG_XEN) += xenfb.o
39
#include "hw/gpio/bcm2835_gpio.h"
35
diff --git a/hw/display/sii9022.c b/hw/display/sii9022.c
40
@@ -XXX,XX +XXX,XX @@ struct BCM2835PeripheralState {
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
36
new file mode 100644
50
new file mode 100644
37
index XXXXXXX..XXXXXXX
51
index XXXXXXX..XXXXXXX
38
--- /dev/null
52
--- /dev/null
39
+++ b/hw/display/sii9022.c
53
+++ b/include/hw/misc/bcm2835_powermgt.h
40
@@ -XXX,XX +XXX,XX @@
54
@@ -XXX,XX +XXX,XX @@
41
+/*
55
+/*
42
+ * Silicon Image SiI9022
56
+ * BCM2835 Power Management emulation
43
+ *
57
+ *
44
+ * This is a pretty hollow emulation: all we do is acknowledge that we
58
+ * Copyright (C) 2017 Marcin Chojnacki <marcinch7@gmail.com>
45
+ * exist (chip ID) and confirm that we get switched over into DDC mode
59
+ * Copyright (C) 2021 Nolan Leake <nolan@sigbus.net>
46
+ * so the emulated host can proceed to read out EDID data. All subsequent
47
+ * set-up of connectors etc will be acknowledged and ignored.
48
+ *
49
+ * Copyright (C) 2018 Linus Walleij
50
+ *
60
+ *
51
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
61
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
52
+ * See the COPYING file in the top-level directory.
62
+ * See the COPYING file in the top-level directory.
53
+ * SPDX-License-Identifier: GPL-2.0-or-later
54
+ */
63
+ */
55
+
64
+
65
+#ifndef BCM2835_POWERMGT_H
66
+#define BCM2835_POWERMGT_H
67
+
68
+#include "hw/sysbus.h"
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
86
--- a/hw/arm/bcm2835_peripherals.c
87
+++ b/hw/arm/bcm2835_peripherals.c
88
@@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_init(Object *obj)
89
90
object_property_add_const_link(OBJECT(&s->dwc2), "dma-mr",
91
OBJECT(&s->gpu_bus_mr));
92
+
93
+ /* Power Management */
94
+ object_initialize_child(obj, "powermgt", &s->powermgt,
95
+ TYPE_BCM2835_POWERMGT);
96
}
97
98
static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
99
@@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
100
qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ,
101
INTERRUPT_USB));
102
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
119
index XXXXXXX..XXXXXXX
120
--- /dev/null
121
+++ b/hw/misc/bcm2835_powermgt.c
122
@@ -XXX,XX +XXX,XX @@
123
+/*
124
+ * BCM2835 Power Management emulation
125
+ *
126
+ * Copyright (C) 2017 Marcin Chojnacki <marcinch7@gmail.com>
127
+ * Copyright (C) 2021 Nolan Leake <nolan@sigbus.net>
128
+ *
129
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
130
+ * See the COPYING file in the top-level directory.
131
+ */
132
+
56
+#include "qemu/osdep.h"
133
+#include "qemu/osdep.h"
57
+#include "qemu-common.h"
134
+#include "qemu/log.h"
58
+#include "hw/i2c/i2c.h"
135
+#include "qemu/module.h"
59
+#include "hw/i2c/i2c-ddc.h"
136
+#include "hw/misc/bcm2835_powermgt.h"
60
+#include "trace.h"
137
+#include "migration/vmstate.h"
61
+
138
+#include "sysemu/runstate.h"
62
+#define SII9022_SYS_CTRL_DATA 0x1a
139
+
63
+#define SII9022_SYS_CTRL_PWR_DWN 0x10
140
+#define PASSWORD 0x5a000000
64
+#define SII9022_SYS_CTRL_AV_MUTE 0x08
141
+#define PASSWORD_MASK 0xff000000
65
+#define SII9022_SYS_CTRL_DDC_BUS_REQ 0x04
142
+
66
+#define SII9022_SYS_CTRL_DDC_BUS_GRTD 0x02
143
+#define R_RSTC 0x1c
67
+#define SII9022_SYS_CTRL_OUTPUT_MODE 0x01
144
+#define V_RSTC_RESET 0x20
68
+#define SII9022_SYS_CTRL_OUTPUT_HDMI 1
145
+#define R_RSTS 0x20
69
+#define SII9022_SYS_CTRL_OUTPUT_DVI 0
146
+#define V_RSTS_POWEROFF 0x555 /* Linux uses partition 63 to indicate halt. */
70
+#define SII9022_REG_CHIPID 0x1b
147
+#define R_WDOG 0x24
71
+#define SII9022_INT_ENABLE 0x3c
148
+
72
+#define SII9022_INT_STATUS 0x3d
149
+static uint64_t bcm2835_powermgt_read(void *opaque, hwaddr offset,
73
+#define SII9022_INT_STATUS_HOTPLUG 0x01;
150
+ unsigned size)
74
+#define SII9022_INT_STATUS_PLUGGED 0x04;
151
+{
75
+
152
+ BCM2835PowerMgtState *s = (BCM2835PowerMgtState *)opaque;
76
+#define TYPE_SII9022 "sii9022"
153
+ uint32_t res = 0;
77
+#define SII9022(obj) OBJECT_CHECK(sii9022_state, (obj), TYPE_SII9022)
154
+
78
+
155
+ switch (offset) {
79
+typedef struct sii9022_state {
156
+ case R_RSTC:
80
+ I2CSlave parent_obj;
157
+ res = s->rstc;
81
+ uint8_t ptr;
158
+ break;
82
+ bool addr_byte;
159
+ case R_RSTS:
83
+ bool ddc_req;
160
+ res = s->rsts;
84
+ bool ddc_skip_finish;
161
+ break;
85
+ bool ddc;
162
+ case R_WDOG:
86
+} sii9022_state;
163
+ res = s->wdog;
87
+
164
+ break;
88
+static const VMStateDescription vmstate_sii9022 = {
165
+
89
+ .name = "sii9022",
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,
90
+ .version_id = 1,
232
+ .version_id = 1,
91
+ .minimum_version_id = 1,
233
+ .minimum_version_id = 1,
92
+ .fields = (VMStateField[]) {
234
+ .fields = (VMStateField[]) {
93
+ VMSTATE_I2C_SLAVE(parent_obj, sii9022_state),
235
+ VMSTATE_UINT32(rstc, BCM2835PowerMgtState),
94
+ VMSTATE_UINT8(ptr, sii9022_state),
236
+ VMSTATE_UINT32(rsts, BCM2835PowerMgtState),
95
+ VMSTATE_BOOL(addr_byte, sii9022_state),
237
+ VMSTATE_UINT32(wdog, BCM2835PowerMgtState),
96
+ VMSTATE_BOOL(ddc_req, sii9022_state),
97
+ VMSTATE_BOOL(ddc_skip_finish, sii9022_state),
98
+ VMSTATE_BOOL(ddc, sii9022_state),
99
+ VMSTATE_END_OF_LIST()
238
+ VMSTATE_END_OF_LIST()
100
+ }
239
+ }
101
+};
240
+};
102
+
241
+
103
+static int sii9022_event(I2CSlave *i2c, enum i2c_event event)
242
+static void bcm2835_powermgt_init(Object *obj)
104
+{
243
+{
105
+ sii9022_state *s = SII9022(i2c);
244
+ BCM2835PowerMgtState *s = BCM2835_POWERMGT(obj);
106
+
245
+
107
+ switch (event) {
246
+ memory_region_init_io(&s->iomem, obj, &bcm2835_powermgt_ops, s,
108
+ case I2C_START_SEND:
247
+ TYPE_BCM2835_POWERMGT, 0x200);
109
+ s->addr_byte = true;
248
+ sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem);
110
+ break;
249
+}
111
+ case I2C_START_RECV:
250
+
112
+ break;
251
+static void bcm2835_powermgt_reset(DeviceState *dev)
113
+ case I2C_FINISH:
252
+{
114
+ break;
253
+ BCM2835PowerMgtState *s = BCM2835_POWERMGT(dev);
115
+ case I2C_NACK:
254
+
116
+ break;
255
+ /* https://elinux.org/BCM2835_registers#PM */
117
+ }
256
+ s->rstc = 0x00000102;
118
+
257
+ s->rsts = 0x00001000;
119
+ return 0;
258
+ s->wdog = 0x00000000;
120
+}
259
+}
121
+
260
+
122
+static int sii9022_rx(I2CSlave *i2c)
261
+static void bcm2835_powermgt_class_init(ObjectClass *klass, void *data)
123
+{
124
+ sii9022_state *s = SII9022(i2c);
125
+ uint8_t res = 0x00;
126
+
127
+ switch (s->ptr) {
128
+ case SII9022_SYS_CTRL_DATA:
129
+ if (s->ddc_req) {
130
+ /* Acknowledge DDC bus request */
131
+ res = SII9022_SYS_CTRL_DDC_BUS_GRTD | SII9022_SYS_CTRL_DDC_BUS_REQ;
132
+ }
133
+ break;
134
+ case SII9022_REG_CHIPID:
135
+ res = 0xb0;
136
+ break;
137
+ case SII9022_INT_STATUS:
138
+ /* Something is cold-plugged in, no interrupts */
139
+ res = SII9022_INT_STATUS_PLUGGED;
140
+ break;
141
+ default:
142
+ break;
143
+ }
144
+
145
+ trace_sii9022_read_reg(s->ptr, res);
146
+ s->ptr++;
147
+
148
+ return res;
149
+}
150
+
151
+static int sii9022_tx(I2CSlave *i2c, uint8_t data)
152
+{
153
+ sii9022_state *s = SII9022(i2c);
154
+
155
+ if (s->addr_byte) {
156
+ s->ptr = data;
157
+ s->addr_byte = false;
158
+ return 0;
159
+ }
160
+
161
+ switch (s->ptr) {
162
+ case SII9022_SYS_CTRL_DATA:
163
+ if (data & SII9022_SYS_CTRL_DDC_BUS_REQ) {
164
+ s->ddc_req = true;
165
+ if (data & SII9022_SYS_CTRL_DDC_BUS_GRTD) {
166
+ s->ddc = true;
167
+ /* Skip this finish since we just switched to DDC */
168
+ s->ddc_skip_finish = true;
169
+ trace_sii9022_switch_mode("DDC");
170
+ }
171
+ } else {
172
+ s->ddc_req = false;
173
+ s->ddc = false;
174
+ trace_sii9022_switch_mode("normal");
175
+ }
176
+ break;
177
+ default:
178
+ break;
179
+ }
180
+
181
+ trace_sii9022_write_reg(s->ptr, data);
182
+ s->ptr++;
183
+
184
+ return 0;
185
+}
186
+
187
+static void sii9022_reset(DeviceState *dev)
188
+{
189
+ sii9022_state *s = SII9022(dev);
190
+
191
+ s->ptr = 0;
192
+ s->addr_byte = false;
193
+ s->ddc_req = false;
194
+ s->ddc_skip_finish = false;
195
+ s->ddc = false;
196
+}
197
+
198
+static void sii9022_realize(DeviceState *dev, Error **errp)
199
+{
200
+ I2CBus *bus;
201
+
202
+ bus = I2C_BUS(qdev_get_parent_bus(dev));
203
+ i2c_create_slave(bus, TYPE_I2CDDC, 0x50);
204
+}
205
+
206
+static void sii9022_class_init(ObjectClass *klass, void *data)
207
+{
262
+{
208
+ DeviceClass *dc = DEVICE_CLASS(klass);
263
+ DeviceClass *dc = DEVICE_CLASS(klass);
209
+ I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
264
+
210
+
265
+ dc->reset = bcm2835_powermgt_reset;
211
+ k->event = sii9022_event;
266
+ dc->vmsd = &vmstate_bcm2835_powermgt;
212
+ k->recv = sii9022_rx;
267
+}
213
+ k->send = sii9022_tx;
268
+
214
+ dc->reset = sii9022_reset;
269
+static TypeInfo bcm2835_powermgt_info = {
215
+ dc->realize = sii9022_realize;
270
+ .name = TYPE_BCM2835_POWERMGT,
216
+ dc->vmsd = &vmstate_sii9022;
271
+ .parent = TYPE_SYS_BUS_DEVICE,
217
+}
272
+ .instance_size = sizeof(BCM2835PowerMgtState),
218
+
273
+ .class_init = bcm2835_powermgt_class_init,
219
+static const TypeInfo sii9022_info = {
274
+ .instance_init = bcm2835_powermgt_init,
220
+ .name = TYPE_SII9022,
275
+};
221
+ .parent = TYPE_I2C_SLAVE,
276
+
222
+ .instance_size = sizeof(sii9022_state),
277
+static void bcm2835_powermgt_register_types(void)
223
+ .class_init = sii9022_class_init,
278
+{
224
+};
279
+ type_register_static(&bcm2835_powermgt_info);
225
+
280
+}
226
+static void sii9022_register_types(void)
281
+
227
+{
282
+type_init(bcm2835_powermgt_register_types)
228
+ type_register_static(&sii9022_info);
283
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
229
+}
230
+
231
+type_init(sii9022_register_types)
232
diff --git a/hw/display/trace-events b/hw/display/trace-events
233
index XXXXXXX..XXXXXXX 100644
284
index XXXXXXX..XXXXXXX 100644
234
--- a/hw/display/trace-events
285
--- a/hw/misc/meson.build
235
+++ b/hw/display/trace-events
286
+++ b/hw/misc/meson.build
236
@@ -XXX,XX +XXX,XX @@ vga_cirrus_read_io(uint32_t addr, uint32_t val) "addr 0x%x, val 0x%x"
287
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_RASPI', if_true: files(
237
vga_cirrus_write_io(uint32_t addr, uint32_t val) "addr 0x%x, val 0x%x"
288
'bcm2835_rng.c',
238
vga_cirrus_read_blt(uint32_t offset, uint32_t val) "offset 0x%x, val 0x%x"
289
'bcm2835_thermal.c',
239
vga_cirrus_write_blt(uint32_t offset, uint32_t val) "offset 0x%x, val 0x%x"
290
'bcm2835_cprman.c',
240
+
291
+ 'bcm2835_powermgt.c',
241
+# hw/display/sii9022.c
292
))
242
+sii9022_read_reg(uint8_t addr, uint8_t val) "addr 0x%02x, val 0x%02x"
293
softmmu_ss.add(when: 'CONFIG_SLAVIO', if_true: files('slavio_misc.c'))
243
+sii9022_write_reg(uint8_t addr, uint8_t val) "addr 0x%02x, val 0x%02x"
294
softmmu_ss.add(when: 'CONFIG_ZYNQ', if_true: files('zynq_slcr.c', 'zynq-xadc.c'))
244
+sii9022_switch_mode(const char *mode) "mode: %s"
245
--
295
--
246
2.16.2
296
2.20.1
247
297
248
298
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
2
3
This includes FMOV, FABS, FNEG, FSQRT and FRINT[NPMZAXI]. We re-use
3
Add a test booting and quickly shutdown a raspi2 machine,
4
existing helpers to achieve this.
4
to test the power management model:
5
5
6
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
6
(1/1) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_raspi2_initrd:
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
console: [ 0.000000] Booting Linux on physical CPU 0xf00
8
Message-id: 20180227143852.11175-32-alex.bennee@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
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
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
48
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
49
---
11
target/arm/translate-a64.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++
50
tests/acceptance/boot_linux_console.py | 43 ++++++++++++++++++++++++++
12
1 file changed, 71 insertions(+)
51
1 file changed, 43 insertions(+)
13
52
14
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
53
diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
15
index XXXXXXX..XXXXXXX 100644
54
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/translate-a64.c
55
--- a/tests/acceptance/boot_linux_console.py
17
+++ b/target/arm/translate-a64.c
56
+++ b/tests/acceptance/boot_linux_console.py
18
@@ -XXX,XX +XXX,XX @@ static void disas_fp_csel(DisasContext *s, uint32_t insn)
57
@@ -XXX,XX +XXX,XX @@
19
tcg_temp_free_i64(t_true);
58
from avocado import skip
20
}
59
from avocado import skipUnless
21
60
from avocado_qemu import Test
22
+/* Floating-point data-processing (1 source) - half precision */
61
+from avocado_qemu import exec_command
23
+static void handle_fp_1src_half(DisasContext *s, int opcode, int rd, int rn)
62
from avocado_qemu import exec_command_and_wait_for_pattern
24
+{
63
from avocado_qemu import interrupt_interactive_console_until_pattern
25
+ TCGv_ptr fpst = NULL;
64
from avocado_qemu import wait_for_console_pattern
26
+ TCGv_i32 tcg_op = tcg_temp_new_i32();
65
@@ -XXX,XX +XXX,XX @@ def test_arm_raspi2_uart0(self):
27
+ TCGv_i32 tcg_res = tcg_temp_new_i32();
66
"""
67
self.do_test_arm_raspi2(0)
68
69
+ def test_arm_raspi2_initrd(self):
70
+ """
71
+ :avocado: tags=arch:arm
72
+ :avocado: tags=machine:raspi2
73
+ """
74
+ deb_url = ('http://archive.raspberrypi.org/debian/'
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')
28
+
81
+
29
+ read_vec_element_i32(s, tcg_op, rn, 0, MO_16);
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)
30
+
89
+
31
+ switch (opcode) {
90
+ self.vm.set_console()
32
+ case 0x0: /* FMOV */
91
+ kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
33
+ tcg_gen_mov_i32(tcg_res, tcg_op);
92
+ 'earlycon=pl011,0x3f201000 console=ttyAMA0 '
34
+ break;
93
+ 'panic=-1 noreboot ' +
35
+ case 0x1: /* FABS */
94
+ 'dwc_otg.fiq_fsm_enable=0')
36
+ tcg_gen_andi_i32(tcg_res, tcg_op, 0x7fff);
95
+ self.vm.add_args('-kernel', kernel_path,
37
+ break;
96
+ '-dtb', dtb_path,
38
+ case 0x2: /* FNEG */
97
+ '-initrd', initrd_path,
39
+ tcg_gen_xori_i32(tcg_res, tcg_op, 0x8000);
98
+ '-append', kernel_command_line,
40
+ break;
99
+ '-no-reboot')
41
+ case 0x3: /* FSQRT */
100
+ self.vm.launch()
42
+ gen_helper_sqrt_f16(tcg_res, tcg_op, cpu_env);
101
+ self.wait_for_console_pattern('Boot successful.')
43
+ break;
44
+ case 0x8: /* FRINTN */
45
+ case 0x9: /* FRINTP */
46
+ case 0xa: /* FRINTM */
47
+ case 0xb: /* FRINTZ */
48
+ case 0xc: /* FRINTA */
49
+ {
50
+ TCGv_i32 tcg_rmode = tcg_const_i32(arm_rmode_to_sf(opcode & 7));
51
+ fpst = get_fpstatus_ptr(true);
52
+
102
+
53
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
103
+ exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
54
+ gen_helper_advsimd_rinth(tcg_res, tcg_op, fpst);
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()
55
+
110
+
56
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
111
def test_arm_exynos4210_initrd(self):
57
+ tcg_temp_free_i32(tcg_rmode);
112
"""
58
+ break;
113
:avocado: tags=arch:arm
59
+ }
60
+ case 0xe: /* FRINTX */
61
+ fpst = get_fpstatus_ptr(true);
62
+ gen_helper_advsimd_rinth_exact(tcg_res, tcg_op, fpst);
63
+ break;
64
+ case 0xf: /* FRINTI */
65
+ fpst = get_fpstatus_ptr(true);
66
+ gen_helper_advsimd_rinth(tcg_res, tcg_op, fpst);
67
+ break;
68
+ default:
69
+ abort();
70
+ }
71
+
72
+ write_fp_sreg(s, rd, tcg_res);
73
+
74
+ if (fpst) {
75
+ tcg_temp_free_ptr(fpst);
76
+ }
77
+ tcg_temp_free_i32(tcg_op);
78
+ tcg_temp_free_i32(tcg_res);
79
+}
80
+
81
/* Floating-point data-processing (1 source) - single precision */
82
static void handle_fp_1src_single(DisasContext *s, int opcode, int rd, int rn)
83
{
84
@@ -XXX,XX +XXX,XX @@ static void disas_fp_1src(DisasContext *s, uint32_t insn)
85
86
handle_fp_1src_double(s, opcode, rd, rn);
87
break;
88
+ case 3:
89
+ if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) {
90
+ unallocated_encoding(s);
91
+ return;
92
+ }
93
+
94
+ if (!fp_access_check(s)) {
95
+ return;
96
+ }
97
+
98
+ handle_fp_1src_half(s, opcode, rd, rn);
99
+ break;
100
default:
101
unallocated_encoding(s);
102
}
103
--
114
--
104
2.16.2
115
2.20.1
105
116
106
117
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
From: Joe Komlodi <joe.komlodi@xilinx.com>
2
2
3
The fprintf is only there for debugging as the skeleton is added to,
3
If the CPU is running in default NaN mode (FPCR.DN == 1) and we execute
4
it will be removed once the skeleton is complete.
4
FRSQRTE, FRECPE, or FRECPX with a signaling NaN, parts_silence_nan_frac() will
5
assert due to fpst->default_nan_mode being set.
5
6
6
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
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>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20180227143852.11175-10-alex.bennee@linaro.org
12
Message-id: 1624662174-175828-2-git-send-email-joe.komlodi@xilinx.com
13
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
15
---
11
target/arm/helper-a64.h | 4 ++++
16
target/arm/helper-a64.c | 12 +++++++++---
12
target/arm/helper-a64.c | 4 ++++
17
target/arm/vfp_helper.c | 24 ++++++++++++++++++------
13
target/arm/translate-a64.c | 28 ++++++++++++++++++++++++++++
18
2 files changed, 27 insertions(+), 9 deletions(-)
14
3 files changed, 36 insertions(+)
15
19
16
diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h
17
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/helper-a64.h
19
+++ b/target/arm/helper-a64.h
20
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(advsimd_maxh, TCG_CALL_NO_RWG, f16, f16, f16, ptr)
21
DEF_HELPER_FLAGS_3(advsimd_minh, TCG_CALL_NO_RWG, f16, f16, f16, ptr)
22
DEF_HELPER_FLAGS_3(advsimd_maxnumh, TCG_CALL_NO_RWG, f16, f16, f16, ptr)
23
DEF_HELPER_FLAGS_3(advsimd_minnumh, TCG_CALL_NO_RWG, f16, f16, f16, ptr)
24
+DEF_HELPER_3(advsimd_addh, f16, f16, f16, ptr)
25
+DEF_HELPER_3(advsimd_subh, f16, f16, f16, ptr)
26
+DEF_HELPER_3(advsimd_mulh, f16, f16, f16, ptr)
27
+DEF_HELPER_3(advsimd_divh, f16, f16, f16, ptr)
28
diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c
20
diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c
29
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
30
--- a/target/arm/helper-a64.c
22
--- a/target/arm/helper-a64.c
31
+++ b/target/arm/helper-a64.c
23
+++ b/target/arm/helper-a64.c
32
@@ -XXX,XX +XXX,XX @@ float16 ADVSIMD_HELPER(name, h)(float16 a, float16 b, void *fpstp) \
24
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(frecpx_f16)(uint32_t a, void *fpstp)
33
return float16_ ## name(a, b, fpst); \
25
float16 nan = a;
34
}
26
if (float16_is_signaling_nan(a, fpst)) {
35
27
float_raise(float_flag_invalid, fpst);
36
+ADVSIMD_HALFOP(add)
28
- nan = float16_silence_nan(a, fpst);
37
+ADVSIMD_HALFOP(sub)
29
+ if (!fpst->default_nan_mode) {
38
+ADVSIMD_HALFOP(mul)
30
+ nan = float16_silence_nan(a, fpst);
39
+ADVSIMD_HALFOP(div)
31
+ }
40
ADVSIMD_HALFOP(min)
32
}
41
ADVSIMD_HALFOP(max)
33
if (fpst->default_nan_mode) {
42
ADVSIMD_HALFOP(minnum)
34
nan = float16_default_nan(fpst);
43
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
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
44
index XXXXXXX..XXXXXXX 100644
58
index XXXXXXX..XXXXXXX 100644
45
--- a/target/arm/translate-a64.c
59
--- a/target/arm/vfp_helper.c
46
+++ b/target/arm/translate-a64.c
60
+++ b/target/arm/vfp_helper.c
47
@@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn)
61
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(recpe_f16)(uint32_t input, void *fpstp)
48
read_vec_element_i32(s, tcg_op2, rm, pass, MO_16);
62
float16 nan = f16;
49
63
if (float16_is_signaling_nan(f16, fpst)) {
50
switch (fpopcode) {
64
float_raise(float_flag_invalid, fpst);
51
+ case 0x0: /* FMAXNM */
65
- nan = float16_silence_nan(f16, fpst);
52
+ gen_helper_advsimd_maxnumh(tcg_res, tcg_op1, tcg_op2, fpst);
66
+ if (!fpst->default_nan_mode) {
53
+ break;
67
+ nan = float16_silence_nan(f16, fpst);
54
+ case 0x2: /* FADD */
68
+ }
55
+ gen_helper_advsimd_addh(tcg_res, tcg_op1, tcg_op2, fpst);
69
}
56
+ break;
70
if (fpst->default_nan_mode) {
57
+ case 0x6: /* FMAX */
71
nan = float16_default_nan(fpst);
58
+ gen_helper_advsimd_maxh(tcg_res, tcg_op1, tcg_op2, fpst);
72
@@ -XXX,XX +XXX,XX @@ float32 HELPER(recpe_f32)(float32 input, void *fpstp)
59
+ break;
73
float32 nan = f32;
60
+ case 0x8: /* FMINNM */
74
if (float32_is_signaling_nan(f32, fpst)) {
61
+ gen_helper_advsimd_minnumh(tcg_res, tcg_op1, tcg_op2, fpst);
75
float_raise(float_flag_invalid, fpst);
62
+ break;
76
- nan = float32_silence_nan(f32, fpst);
63
+ case 0xa: /* FSUB */
77
+ if (!fpst->default_nan_mode) {
64
+ gen_helper_advsimd_subh(tcg_res, tcg_op1, tcg_op2, fpst);
78
+ nan = float32_silence_nan(f32, fpst);
65
+ break;
79
+ }
66
+ case 0xe: /* FMIN */
80
}
67
+ gen_helper_advsimd_minh(tcg_res, tcg_op1, tcg_op2, fpst);
81
if (fpst->default_nan_mode) {
68
+ break;
82
nan = float32_default_nan(fpst);
69
+ case 0x13: /* FMUL */
83
@@ -XXX,XX +XXX,XX @@ float64 HELPER(recpe_f64)(float64 input, void *fpstp)
70
+ gen_helper_advsimd_mulh(tcg_res, tcg_op1, tcg_op2, fpst);
84
float64 nan = f64;
71
+ break;
85
if (float64_is_signaling_nan(f64, fpst)) {
72
+ case 0x17: /* FDIV */
86
float_raise(float_flag_invalid, fpst);
73
+ gen_helper_advsimd_divh(tcg_res, tcg_op1, tcg_op2, fpst);
87
- nan = float64_silence_nan(f64, fpst);
74
+ break;
88
+ if (!fpst->default_nan_mode) {
75
+ case 0x1a: /* FABD */
89
+ nan = float64_silence_nan(f64, fpst);
76
+ gen_helper_advsimd_subh(tcg_res, tcg_op1, tcg_op2, fpst);
90
+ }
77
+ tcg_gen_andi_i32(tcg_res, tcg_res, 0x7fff);
91
}
78
+ break;
92
if (fpst->default_nan_mode) {
79
default:
93
nan = float64_default_nan(fpst);
80
fprintf(stderr, "%s: insn %#04x, fpop %#2x @ %#" PRIx64 "\n",
94
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(rsqrte_f16)(uint32_t input, void *fpstp)
81
__func__, insn, fpopcode, s->pc);
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);
82
--
127
--
83
2.16.2
128
2.20.1
84
129
85
130
diff view generated by jsdifflib
1
From: Francisco Iglesias <frasse.iglesias@gmail.com>
1
From: Maxim Uvarov <maxim.uvarov@linaro.org>
2
2
3
Assert only the lower cs on bus 0 and upper cs on bus 1 when both buses and
3
qemu has 2 type of functions: shutdown and reboot. Shutdown
4
chip selects are enabled (e.g reading/writing with stripe).
4
function has to be used for machine shutdown. Otherwise we cause
5
a reset with a bogus "cause" value, when we intended a shutdown.
5
6
6
Signed-off-by: Francisco Iglesias <frasse.iglesias@gmail.com>
7
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
7
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Tested-by: Alistair Francis <alistair.francis@xilinx.com>
9
Message-id: 20210625111842.3790-3-maxim.uvarov@linaro.org
9
Message-id: 20180223232233.31482-2-frasse.iglesias@gmail.com
10
[PMM: tweaked commit message]
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
---
12
hw/ssi/xilinx_spips.c | 41 +++++++++++++++++++++++++++++++++++++----
13
hw/gpio/gpio_pwr.c | 2 +-
13
1 file changed, 37 insertions(+), 4 deletions(-)
14
1 file changed, 1 insertion(+), 1 deletion(-)
14
15
15
diff --git a/hw/ssi/xilinx_spips.c b/hw/ssi/xilinx_spips.c
16
diff --git a/hw/gpio/gpio_pwr.c b/hw/gpio/gpio_pwr.c
16
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/ssi/xilinx_spips.c
18
--- a/hw/gpio/gpio_pwr.c
18
+++ b/hw/ssi/xilinx_spips.c
19
+++ b/hw/gpio/gpio_pwr.c
19
@@ -XXX,XX +XXX,XX @@ static void xilinx_spips_update_cs(XilinxSPIPS *s, int field)
20
@@ -XXX,XX +XXX,XX @@ static void gpio_pwr_reset(void *opaque, int n, int level)
21
static void gpio_pwr_shutdown(void *opaque, int n, int level)
20
{
22
{
21
int i;
23
if (level) {
22
24
- qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
23
- for (i = 0; i < s->num_cs; i++) {
25
+ qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
24
+ for (i = 0; i < s->num_cs * s->num_busses; i++) {
25
bool old_state = s->cs_lines_state[i];
26
bool new_state = field & (1 << i);
27
28
@@ -XXX,XX +XXX,XX @@ static void xilinx_spips_update_cs(XilinxSPIPS *s, int field)
29
}
30
qemu_set_irq(s->cs_lines[i], !new_state);
31
}
32
- if (!(field & ((1 << s->num_cs) - 1))) {
33
+ if (!(field & ((1 << (s->num_cs * s->num_busses)) - 1))) {
34
s->snoop_state = SNOOP_CHECKING;
35
s->cmd_dummies = 0;
36
s->link_state = 1;
37
@@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_qspips_update_cs_lines(XlnxZynqMPQSPIPS *s)
38
{
39
if (s->regs[R_GQSPI_GF_SNAPSHOT]) {
40
int field = ARRAY_FIELD_EX32(s->regs, GQSPI_GF_SNAPSHOT, CHIP_SELECT);
41
- xilinx_spips_update_cs(XILINX_SPIPS(s), field);
42
+ bool upper_cs_sel = field & (1 << 1);
43
+ bool lower_cs_sel = field & 1;
44
+ bool bus0_enabled;
45
+ bool bus1_enabled;
46
+ uint8_t buses;
47
+ int cs = 0;
48
+
49
+ buses = ARRAY_FIELD_EX32(s->regs, GQSPI_GF_SNAPSHOT, DATA_BUS_SELECT);
50
+ bus0_enabled = buses & 1;
51
+ bus1_enabled = buses & (1 << 1);
52
+
53
+ if (bus0_enabled && bus1_enabled) {
54
+ if (lower_cs_sel) {
55
+ cs |= 1;
56
+ }
57
+ if (upper_cs_sel) {
58
+ cs |= 1 << 3;
59
+ }
60
+ } else if (bus0_enabled) {
61
+ if (lower_cs_sel) {
62
+ cs |= 1;
63
+ }
64
+ if (upper_cs_sel) {
65
+ cs |= 1 << 1;
66
+ }
67
+ } else if (bus1_enabled) {
68
+ if (lower_cs_sel) {
69
+ cs |= 1 << 2;
70
+ }
71
+ if (upper_cs_sel) {
72
+ cs |= 1 << 3;
73
+ }
74
+ }
75
+ xilinx_spips_update_cs(XILINX_SPIPS(s), cs);
76
}
26
}
77
}
27
}
78
28
79
@@ -XXX,XX +XXX,XX @@ static void xilinx_spips_update_cs_lines(XilinxSPIPS *s)
80
if (num_effective_busses(s) == 2) {
81
/* Single bit chip-select for qspi */
82
field &= 0x1;
83
- field |= field << 1;
84
+ field |= field << 3;
85
/* Dual stack U-Page */
86
} else if (s->regs[R_LQSPI_CFG] & LQSPI_CFG_TWO_MEM &&
87
s->regs[R_LQSPI_STS] & LQSPI_CFG_U_PAGE) {
88
--
29
--
89
2.16.2
30
2.20.1
90
31
91
32
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
In do_ldst(), the calculation of the offset needs to be based on the
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.
2
5
3
This implements the half-precision variants of the across vector
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
reduction operations. This involves a re-factor of the reduction code
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
which more closely matches the ARM ARM order (and handles 8 element
8
Message-id: 20210628135835.6690-2-peter.maydell@linaro.org
6
reductions).
9
---
10
target/arm/translate-mve.c | 17 +++++++++--------
11
1 file changed, 9 insertions(+), 8 deletions(-)
7
12
8
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
13
diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20180227143852.11175-7-alex.bennee@linaro.org
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
13
target/arm/helper-a64.h | 4 ++
14
target/arm/helper-a64.c | 18 ++++++
15
target/arm/translate-a64.c | 140 ++++++++++++++++++++++++++++-----------------
16
3 files changed, 109 insertions(+), 53 deletions(-)
17
18
diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h
19
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/helper-a64.h
15
--- a/target/arm/translate-mve.c
21
+++ b/target/arm/helper-a64.h
16
+++ b/target/arm/translate-mve.c
22
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(paired_cmpxchg64_le_parallel, TCG_CALL_NO_WG,
17
@@ -XXX,XX +XXX,XX @@ static bool mve_skip_first_beat(DisasContext *s)
23
DEF_HELPER_FLAGS_4(paired_cmpxchg64_be, TCG_CALL_NO_WG, i64, env, i64, i64, i64)
24
DEF_HELPER_FLAGS_4(paired_cmpxchg64_be_parallel, TCG_CALL_NO_WG,
25
i64, env, i64, i64, i64)
26
+DEF_HELPER_FLAGS_3(advsimd_maxh, TCG_CALL_NO_RWG, f16, f16, f16, ptr)
27
+DEF_HELPER_FLAGS_3(advsimd_minh, TCG_CALL_NO_RWG, f16, f16, f16, ptr)
28
+DEF_HELPER_FLAGS_3(advsimd_maxnumh, TCG_CALL_NO_RWG, f16, f16, f16, ptr)
29
+DEF_HELPER_FLAGS_3(advsimd_minnumh, TCG_CALL_NO_RWG, f16, f16, f16, ptr)
30
diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c
31
index XXXXXXX..XXXXXXX 100644
32
--- a/target/arm/helper-a64.c
33
+++ b/target/arm/helper-a64.c
34
@@ -XXX,XX +XXX,XX @@ uint64_t HELPER(paired_cmpxchg64_be_parallel)(CPUARMState *env, uint64_t addr,
35
{
36
return do_paired_cmpxchg64_be(env, addr, new_lo, new_hi, true, GETPC());
37
}
38
+
39
+/*
40
+ * AdvSIMD half-precision
41
+ */
42
+
43
+#define ADVSIMD_HELPER(name, suffix) HELPER(glue(glue(advsimd_, name), suffix))
44
+
45
+#define ADVSIMD_HALFOP(name) \
46
+float16 ADVSIMD_HELPER(name, h)(float16 a, float16 b, void *fpstp) \
47
+{ \
48
+ float_status *fpst = fpstp; \
49
+ return float16_ ## name(a, b, fpst); \
50
+}
51
+
52
+ADVSIMD_HALFOP(min)
53
+ADVSIMD_HALFOP(max)
54
+ADVSIMD_HALFOP(minnum)
55
+ADVSIMD_HALFOP(maxnum)
56
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
57
index XXXXXXX..XXXXXXX 100644
58
--- a/target/arm/translate-a64.c
59
+++ b/target/arm/translate-a64.c
60
@@ -XXX,XX +XXX,XX @@ static void disas_simd_zip_trn(DisasContext *s, uint32_t insn)
61
tcg_temp_free_i64(tcg_resh);
62
}
63
64
-static void do_minmaxop(DisasContext *s, TCGv_i32 tcg_elt1, TCGv_i32 tcg_elt2,
65
- int opc, bool is_min, TCGv_ptr fpst)
66
+/*
67
+ * do_reduction_op helper
68
+ *
69
+ * This mirrors the Reduce() pseudocode in the ARM ARM. It is
70
+ * important for correct NaN propagation that we do these
71
+ * operations in exactly the order specified by the pseudocode.
72
+ *
73
+ * This is a recursive function, TCG temps should be freed by the
74
+ * calling function once it is done with the values.
75
+ */
76
+static TCGv_i32 do_reduction_op(DisasContext *s, int fpopcode, int rn,
77
+ int esize, int size, int vmap, TCGv_ptr fpst)
78
{
79
- /* Helper function for disas_simd_across_lanes: do a single precision
80
- * min/max operation on the specified two inputs,
81
- * and return the result in tcg_elt1.
82
- */
83
- if (opc == 0xc) {
84
- if (is_min) {
85
- gen_helper_vfp_minnums(tcg_elt1, tcg_elt1, tcg_elt2, fpst);
86
- } else {
87
- gen_helper_vfp_maxnums(tcg_elt1, tcg_elt1, tcg_elt2, fpst);
88
- }
89
+ if (esize == size) {
90
+ int element;
91
+ TCGMemOp msize = esize == 16 ? MO_16 : MO_32;
92
+ TCGv_i32 tcg_elem;
93
+
94
+ /* We should have one register left here */
95
+ assert(ctpop8(vmap) == 1);
96
+ element = ctz32(vmap);
97
+ assert(element < 8);
98
+
99
+ tcg_elem = tcg_temp_new_i32();
100
+ read_vec_element_i32(s, tcg_elem, rn, element, msize);
101
+ return tcg_elem;
102
} else {
103
- assert(opc == 0xf);
104
- if (is_min) {
105
- gen_helper_vfp_mins(tcg_elt1, tcg_elt1, tcg_elt2, fpst);
106
- } else {
107
- gen_helper_vfp_maxs(tcg_elt1, tcg_elt1, tcg_elt2, fpst);
108
+ int bits = size / 2;
109
+ int shift = ctpop8(vmap) / 2;
110
+ int vmap_lo = (vmap >> shift) & vmap;
111
+ int vmap_hi = (vmap & ~vmap_lo);
112
+ TCGv_i32 tcg_hi, tcg_lo, tcg_res;
113
+
114
+ tcg_hi = do_reduction_op(s, fpopcode, rn, esize, bits, vmap_hi, fpst);
115
+ tcg_lo = do_reduction_op(s, fpopcode, rn, esize, bits, vmap_lo, fpst);
116
+ tcg_res = tcg_temp_new_i32();
117
+
118
+ switch (fpopcode) {
119
+ case 0x0c: /* fmaxnmv half-precision */
120
+ gen_helper_advsimd_maxnumh(tcg_res, tcg_lo, tcg_hi, fpst);
121
+ break;
122
+ case 0x0f: /* fmaxv half-precision */
123
+ gen_helper_advsimd_maxh(tcg_res, tcg_lo, tcg_hi, fpst);
124
+ break;
125
+ case 0x1c: /* fminnmv half-precision */
126
+ gen_helper_advsimd_minnumh(tcg_res, tcg_lo, tcg_hi, fpst);
127
+ break;
128
+ case 0x1f: /* fminv half-precision */
129
+ gen_helper_advsimd_minh(tcg_res, tcg_lo, tcg_hi, fpst);
130
+ break;
131
+ case 0x2c: /* fmaxnmv */
132
+ gen_helper_vfp_maxnums(tcg_res, tcg_lo, tcg_hi, fpst);
133
+ break;
134
+ case 0x2f: /* fmaxv */
135
+ gen_helper_vfp_maxs(tcg_res, tcg_lo, tcg_hi, fpst);
136
+ break;
137
+ case 0x3c: /* fminnmv */
138
+ gen_helper_vfp_minnums(tcg_res, tcg_lo, tcg_hi, fpst);
139
+ break;
140
+ case 0x3f: /* fminv */
141
+ gen_helper_vfp_mins(tcg_res, tcg_lo, tcg_hi, fpst);
142
+ break;
143
+ default:
144
+ g_assert_not_reached();
145
}
146
+
147
+ tcg_temp_free_i32(tcg_hi);
148
+ tcg_temp_free_i32(tcg_lo);
149
+ return tcg_res;
150
}
18
}
151
}
19
}
152
20
153
@@ -XXX,XX +XXX,XX @@ static void disas_simd_across_lanes(DisasContext *s, uint32_t insn)
21
-static bool do_ldst(DisasContext *s, arg_VLDR_VSTR *a, MVEGenLdStFn *fn)
154
break;
22
+static bool do_ldst(DisasContext *s, arg_VLDR_VSTR *a, MVEGenLdStFn *fn,
155
case 0xc: /* FMAXNMV, FMINNMV */
23
+ unsigned msize)
156
case 0xf: /* FMAXV, FMINV */
24
{
157
- if (!is_u || !is_q || extract32(size, 0, 1)) {
25
TCGv_i32 addr;
158
- unallocated_encoding(s);
26
uint32_t offset;
159
- return;
27
@@ -XXX,XX +XXX,XX @@ static bool do_ldst(DisasContext *s, arg_VLDR_VSTR *a, MVEGenLdStFn *fn)
160
- }
28
return true;
161
- /* Bit 1 of size field encodes min vs max, and actual size is always
162
- * 32 bits: adjust the size variable so following code can rely on it
163
+ /* Bit 1 of size field encodes min vs max and the actual size
164
+ * depends on the encoding of the U bit. If not set (and FP16
165
+ * enabled) then we do half-precision float instead of single
166
+ * precision.
167
*/
168
is_min = extract32(size, 1, 1);
169
is_fp = true;
170
- size = 2;
171
+ if (!is_u && arm_dc_feature(s, ARM_FEATURE_V8_FP16)) {
172
+ size = 1;
173
+ } else if (!is_u || !is_q || extract32(size, 0, 1)) {
174
+ unallocated_encoding(s);
175
+ return;
176
+ } else {
177
+ size = 2;
178
+ }
179
break;
180
default:
181
unallocated_encoding(s);
182
@@ -XXX,XX +XXX,XX @@ static void disas_simd_across_lanes(DisasContext *s, uint32_t insn)
183
184
}
185
} else {
186
- /* Floating point ops which work on 32 bit (single) intermediates.
187
+ /* Floating point vector reduction ops which work across 32
188
+ * bit (single) or 16 bit (half-precision) intermediates.
189
* Note that correct NaN propagation requires that we do these
190
* operations in exactly the order specified by the pseudocode.
191
*/
192
- TCGv_i32 tcg_elt1 = tcg_temp_new_i32();
193
- TCGv_i32 tcg_elt2 = tcg_temp_new_i32();
194
- TCGv_i32 tcg_elt3 = tcg_temp_new_i32();
195
- TCGv_ptr fpst = get_fpstatus_ptr(false);
196
-
197
- assert(esize == 32);
198
- assert(elements == 4);
199
-
200
- read_vec_element(s, tcg_elt, rn, 0, MO_32);
201
- tcg_gen_extrl_i64_i32(tcg_elt1, tcg_elt);
202
- read_vec_element(s, tcg_elt, rn, 1, MO_32);
203
- tcg_gen_extrl_i64_i32(tcg_elt2, tcg_elt);
204
-
205
- do_minmaxop(s, tcg_elt1, tcg_elt2, opcode, is_min, fpst);
206
-
207
- read_vec_element(s, tcg_elt, rn, 2, MO_32);
208
- tcg_gen_extrl_i64_i32(tcg_elt2, tcg_elt);
209
- read_vec_element(s, tcg_elt, rn, 3, MO_32);
210
- tcg_gen_extrl_i64_i32(tcg_elt3, tcg_elt);
211
-
212
- do_minmaxop(s, tcg_elt2, tcg_elt3, opcode, is_min, fpst);
213
-
214
- do_minmaxop(s, tcg_elt1, tcg_elt2, opcode, is_min, fpst);
215
-
216
- tcg_gen_extu_i32_i64(tcg_res, tcg_elt1);
217
- tcg_temp_free_i32(tcg_elt1);
218
- tcg_temp_free_i32(tcg_elt2);
219
- tcg_temp_free_i32(tcg_elt3);
220
+ TCGv_ptr fpst = get_fpstatus_ptr(size == MO_16);
221
+ int fpopcode = opcode | is_min << 4 | is_u << 5;
222
+ int vmap = (1 << elements) - 1;
223
+ TCGv_i32 tcg_res32 = do_reduction_op(s, fpopcode, rn, esize,
224
+ (is_q ? 128 : 64), vmap, fpst);
225
+ tcg_gen_extu_i32_i64(tcg_res, tcg_res32);
226
+ tcg_temp_free_i32(tcg_res32);
227
tcg_temp_free_ptr(fpst);
228
}
29
}
229
30
31
- offset = a->imm << a->size;
32
+ offset = a->imm << msize;
33
if (!a->a) {
34
offset = -offset;
35
}
36
@@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR(DisasContext *s, arg_VLDR_VSTR *a)
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
}
43
44
-#define DO_VLDST_WIDE_NARROW(OP, SLD, ULD, ST) \
45
+#define DO_VLDST_WIDE_NARROW(OP, SLD, ULD, ST, MSIZE) \
46
static bool trans_##OP(DisasContext *s, arg_VLDR_VSTR *a) \
47
{ \
48
static MVEGenLdStFn * const ldstfns[2][2] = { \
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
}
55
56
-DO_VLDST_WIDE_NARROW(VLDSTB_H, vldrb_sh, vldrb_uh, vstrb_h)
57
-DO_VLDST_WIDE_NARROW(VLDSTB_W, vldrb_sw, vldrb_uw, vstrb_w)
58
-DO_VLDST_WIDE_NARROW(VLDSTH_W, vldrh_sw, vldrh_uw, vstrh_w)
59
+DO_VLDST_WIDE_NARROW(VLDSTB_H, vldrb_sh, vldrb_uh, vstrb_h, MO_8)
60
+DO_VLDST_WIDE_NARROW(VLDSTB_W, vldrb_sw, vldrb_uw, vstrb_w, MO_8)
61
+DO_VLDST_WIDE_NARROW(VLDSTH_W, vldrh_sw, vldrh_uw, vstrh_w, MO_16)
62
63
static bool trans_VDUP(DisasContext *s, arg_VDUP *a)
64
{
230
--
65
--
231
2.16.2
66
2.20.1
232
67
233
68
diff view generated by jsdifflib
1
From: Alistair Francis <alistair.francis@xilinx.com>
1
The initial implementation of the MVE VRMLALDAVH and VRMLSLDAVH
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
2
9
3
Ensure that the post write hook is called during reset. This allows us
10
In particular, fixing the second of these allows us to recast
4
to rely on the post write functions instead of having to call them from
11
the implementation to avoid 128-bit arithmetic entirely.
5
the reset() function.
6
12
7
Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
13
Since the element size here is always 4, we can also drop the
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
14
parameterization of ESIZE to make the code a little more readable.
9
Message-id: d131e24b911653a945e46ca2d8f90f572469e1dd.1517856214.git.alistair.francis@xilinx.com
15
16
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@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
11
---
20
---
12
include/hw/register.h | 6 +++---
21
target/arm/mve_helper.c | 38 +++++++++++++++++++++-----------------
13
hw/core/register.c | 8 ++++++++
22
1 file changed, 21 insertions(+), 17 deletions(-)
14
2 files changed, 11 insertions(+), 3 deletions(-)
15
23
16
diff --git a/include/hw/register.h b/include/hw/register.h
24
diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c
17
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
18
--- a/include/hw/register.h
26
--- a/target/arm/mve_helper.c
19
+++ b/include/hw/register.h
27
+++ b/target/arm/mve_helper.c
20
@@ -XXX,XX +XXX,XX @@ typedef struct RegisterInfoArray RegisterInfoArray;
28
@@ -XXX,XX +XXX,XX @@
21
* immediately before the actual write. The returned value is what is written,
22
* giving the handler a chance to modify the written value.
23
* @post_write: Post write callback. Passed the written value. Most write side
24
- * effects should be implemented here.
25
+ * effects should be implemented here. This is called during device reset.
26
*
27
* @post_read: Post read callback. Passes the value that is about to be returned
28
* for a read. The return value from this function is what is ultimately read,
29
@@ -XXX,XX +XXX,XX @@ uint64_t register_read(RegisterInfo *reg, uint64_t re, const char* prefix,
30
bool debug);
31
32
/**
33
- * reset a register
34
- * @reg: register to reset
35
+ * Resets a register. This will also call the post_write hook if it exists.
36
+ * @reg: The register to reset.
37
*/
29
*/
38
30
39
void register_reset(RegisterInfo *reg);
31
#include "qemu/osdep.h"
40
diff --git a/hw/core/register.c b/hw/core/register.c
32
-#include "qemu/int128.h"
41
index XXXXXXX..XXXXXXX 100644
33
#include "cpu.h"
42
--- a/hw/core/register.c
34
#include "internals.h"
43
+++ b/hw/core/register.c
35
#include "vec_internal.h"
44
@@ -XXX,XX +XXX,XX @@ uint64_t register_read(RegisterInfo *reg, uint64_t re, const char* prefix,
36
@@ -XXX,XX +XXX,XX @@ DO_LDAV(vmlsldavsw, 4, int32_t, false, +=, -=)
45
37
DO_LDAV(vmlsldavxsw, 4, int32_t, true, +=, -=)
46
void register_reset(RegisterInfo *reg)
38
47
{
39
/*
48
+ const RegisterAccessInfo *ac;
40
- * Rounding multiply add long dual accumulate high: we must keep
49
+
41
- * a 72-bit internal accumulator value and return the top 64 bits.
50
g_assert(reg);
42
+ * Rounding multiply add long dual accumulate high. In the pseudocode
51
43
+ * this is implemented with a 72-bit internal accumulator value of which
52
if (!reg->data || !reg->access) {
44
+ * the top 64 bits are returned. We optimize this to avoid having to
53
return;
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; \
54
}
81
}
55
82
56
+ ac = reg->access;
83
-DO_LDAVH(vrmlaldavhsw, 4, int32_t, false, int128_add, int128_add, int128_makes64)
57
+
84
-DO_LDAVH(vrmlaldavhxsw, 4, int32_t, true, int128_add, int128_add, int128_makes64)
58
register_write_val(reg, reg->access->reset);
85
+DO_LDAVH(vrmlaldavhsw, int32_t, int64_t, false, false)
59
+
86
+DO_LDAVH(vrmlaldavhxsw, int32_t, int64_t, true, false)
60
+ if (ac->post_write) {
87
61
+ ac->post_write(reg, reg->access->reset);
88
-DO_LDAVH(vrmlaldavhuw, 4, uint32_t, false, int128_add, int128_add, int128_make64)
62
+ }
89
+DO_LDAVH(vrmlaldavhuw, uint32_t, uint64_t, false, false)
63
}
90
64
91
-DO_LDAVH(vrmlsldavhsw, 4, int32_t, false, int128_add, int128_sub, int128_makes64)
65
void register_init(RegisterInfo *reg)
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) \
66
--
98
--
67
2.16.2
99
2.20.1
68
100
69
101
diff view generated by jsdifflib
Deleted patch
1
From: Francisco Iglesias <frasse.iglesias@gmail.com>
2
1
3
Use 8 dummy cycles (4 dummy bytes) with the QIOR/QIOR4 commands in legacy mode
4
for matching what is expected by Micron (Numonyx) flashes (the default target
5
flash type of the QSPI).
6
7
Signed-off-by: Francisco Iglesias <frasse.iglesias@gmail.com>
8
Tested-by: Alistair Francis <alistair.francis@xilinx.com>
9
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
10
Message-id: 20180223232233.31482-3-frasse.iglesias@gmail.com
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
13
hw/ssi/xilinx_spips.c | 2 +-
14
1 file changed, 1 insertion(+), 1 deletion(-)
15
16
diff --git a/hw/ssi/xilinx_spips.c b/hw/ssi/xilinx_spips.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/ssi/xilinx_spips.c
19
+++ b/hw/ssi/xilinx_spips.c
20
@@ -XXX,XX +XXX,XX @@ static int xilinx_spips_num_dummies(XilinxQSPIPS *qs, uint8_t command)
21
return 2;
22
case QIOR:
23
case QIOR_4:
24
- return 5;
25
+ return 4;
26
default:
27
return -1;
28
}
29
--
30
2.16.2
31
32
diff view generated by jsdifflib
Deleted patch
1
From: Corey Minyard <cminyard@mvista.com>
2
1
3
Signed-off-by: Corey Minyard <cminyard@mvista.com>
4
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6
Message-id: 20180227104903.21353-2-linus.walleij@linaro.org
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
9
include/hw/i2c/i2c.h | 6 ++----
10
hw/i2c/core.c | 3 +--
11
2 files changed, 3 insertions(+), 6 deletions(-)
12
13
diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h
14
index XXXXXXX..XXXXXXX 100644
15
--- a/include/hw/i2c/i2c.h
16
+++ b/include/hw/i2c/i2c.h
17
@@ -XXX,XX +XXX,XX @@ typedef struct I2CSlave I2CSlave;
18
#define I2C_SLAVE_GET_CLASS(obj) \
19
OBJECT_GET_CLASS(I2CSlaveClass, (obj), TYPE_I2C_SLAVE)
20
21
-typedef struct I2CSlaveClass
22
-{
23
+typedef struct I2CSlaveClass {
24
DeviceClass parent_class;
25
26
/* Callbacks provided by the device. */
27
@@ -XXX,XX +XXX,XX @@ typedef struct I2CSlaveClass
28
int (*event)(I2CSlave *s, enum i2c_event event);
29
} I2CSlaveClass;
30
31
-struct I2CSlave
32
-{
33
+struct I2CSlave {
34
DeviceState qdev;
35
36
/* Remaining fields for internal use by the I2C code. */
37
diff --git a/hw/i2c/core.c b/hw/i2c/core.c
38
index XXXXXXX..XXXXXXX 100644
39
--- a/hw/i2c/core.c
40
+++ b/hw/i2c/core.c
41
@@ -XXX,XX +XXX,XX @@ struct I2CNode {
42
43
#define I2C_BROADCAST 0x00
44
45
-struct I2CBus
46
-{
47
+struct I2CBus {
48
BusState qbus;
49
QLIST_HEAD(, I2CNode) current_devs;
50
uint8_t saved_address;
51
--
52
2.16.2
53
54
diff view generated by jsdifflib
Deleted patch
1
From: Corey Minyard <cminyard@mvista.com>
2
1
3
Some devices need access to it.
4
5
Signed-off-by: Corey Minyard <cminyard@mvista.com>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
8
Message-id: 20180227104903.21353-3-linus.walleij@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
include/hw/i2c/i2c.h | 17 +++++++++++++++++
12
hw/i2c/core.c | 17 -----------------
13
2 files changed, 17 insertions(+), 17 deletions(-)
14
15
diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h
16
index XXXXXXX..XXXXXXX 100644
17
--- a/include/hw/i2c/i2c.h
18
+++ b/include/hw/i2c/i2c.h
19
@@ -XXX,XX +XXX,XX @@ struct I2CSlave {
20
uint8_t address;
21
};
22
23
+#define TYPE_I2C_BUS "i2c-bus"
24
+#define I2C_BUS(obj) OBJECT_CHECK(I2CBus, (obj), TYPE_I2C_BUS)
25
+
26
+typedef struct I2CNode I2CNode;
27
+
28
+struct I2CNode {
29
+ I2CSlave *elt;
30
+ QLIST_ENTRY(I2CNode) next;
31
+};
32
+
33
+struct I2CBus {
34
+ BusState qbus;
35
+ QLIST_HEAD(, I2CNode) current_devs;
36
+ uint8_t saved_address;
37
+ bool broadcast;
38
+};
39
+
40
I2CBus *i2c_init_bus(DeviceState *parent, const char *name);
41
void i2c_set_slave_address(I2CSlave *dev, uint8_t address);
42
int i2c_bus_busy(I2CBus *bus);
43
diff --git a/hw/i2c/core.c b/hw/i2c/core.c
44
index XXXXXXX..XXXXXXX 100644
45
--- a/hw/i2c/core.c
46
+++ b/hw/i2c/core.c
47
@@ -XXX,XX +XXX,XX @@
48
#include "qemu/osdep.h"
49
#include "hw/i2c/i2c.h"
50
51
-typedef struct I2CNode I2CNode;
52
-
53
-struct I2CNode {
54
- I2CSlave *elt;
55
- QLIST_ENTRY(I2CNode) next;
56
-};
57
-
58
#define I2C_BROADCAST 0x00
59
60
-struct I2CBus {
61
- BusState qbus;
62
- QLIST_HEAD(, I2CNode) current_devs;
63
- uint8_t saved_address;
64
- bool broadcast;
65
-};
66
-
67
static Property i2c_props[] = {
68
DEFINE_PROP_UINT8("address", struct I2CSlave, address, 0),
69
DEFINE_PROP_END_OF_LIST(),
70
};
71
72
-#define TYPE_I2C_BUS "i2c-bus"
73
-#define I2C_BUS(obj) OBJECT_CHECK(I2CBus, (obj), TYPE_I2C_BUS)
74
-
75
static const TypeInfo i2c_bus_info = {
76
.name = TYPE_I2C_BUS,
77
.parent = TYPE_BUS,
78
--
79
2.16.2
80
81
diff view generated by jsdifflib
Deleted patch
1
From: Linus Walleij <linus.walleij@linaro.org>
2
1
3
The tx function of the DDC I2C slave emulation was returning 1
4
on all writes resulting in NACK in the I2C bus. Changing it to
5
0 makes the DDC I2C work fine with bit-banged I2C such as the
6
versatile I2C.
7
8
I guess it was not affecting whatever I2C controller this was
9
used with until now, but with the Versatile I2C it surely
10
does not work.
11
12
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
14
Message-id: 20180227104903.21353-4-linus.walleij@linaro.org
15
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
---
18
hw/i2c/i2c-ddc.c | 4 ++--
19
1 file changed, 2 insertions(+), 2 deletions(-)
20
21
diff --git a/hw/i2c/i2c-ddc.c b/hw/i2c/i2c-ddc.c
22
index XXXXXXX..XXXXXXX 100644
23
--- a/hw/i2c/i2c-ddc.c
24
+++ b/hw/i2c/i2c-ddc.c
25
@@ -XXX,XX +XXX,XX @@ static int i2c_ddc_tx(I2CSlave *i2c, uint8_t data)
26
s->reg = data;
27
s->firstbyte = false;
28
DPRINTF("[EDID] Written new pointer: %u\n", data);
29
- return 1;
30
+ return 0;
31
}
32
33
/* Ignore all writes */
34
s->reg++;
35
- return 1;
36
+ return 0;
37
}
38
39
static void i2c_ddc_init(Object *obj)
40
--
41
2.16.2
42
43
diff view generated by jsdifflib
Deleted patch
1
From: Linus Walleij <linus.walleij@linaro.org>
2
1
3
This adds the SiI9022 (and implicitly EDID I2C) device to the ARM
4
Versatile Express machine, and selects the two I2C devices necessary
5
in the arm-softmmu.mak configuration so everything will build
6
smoothly.
7
8
I am implementing proper handling of the graphics in the Linux
9
kernel and adding proper emulation of SiI9022 and EDID makes the
10
driver probe as nicely as before, retrieving the resolutions
11
supported by the "QEMU monitor" and overall just working nice.
12
13
Cc: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
15
Message-id: 20180227104903.21353-6-linus.walleij@linaro.org
16
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
17
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
---
20
hw/arm/vexpress.c | 6 +++++-
21
default-configs/arm-softmmu.mak | 2 ++
22
2 files changed, 7 insertions(+), 1 deletion(-)
23
24
diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
25
index XXXXXXX..XXXXXXX 100644
26
--- a/hw/arm/vexpress.c
27
+++ b/hw/arm/vexpress.c
28
@@ -XXX,XX +XXX,XX @@
29
#include "hw/arm/arm.h"
30
#include "hw/arm/primecell.h"
31
#include "hw/devices.h"
32
+#include "hw/i2c/i2c.h"
33
#include "net/net.h"
34
#include "sysemu/sysemu.h"
35
#include "hw/boards.h"
36
@@ -XXX,XX +XXX,XX @@ static void vexpress_common_init(MachineState *machine)
37
uint32_t sys_id;
38
DriveInfo *dinfo;
39
pflash_t *pflash0;
40
+ I2CBus *i2c;
41
ram_addr_t vram_size, sram_size;
42
MemoryRegion *sysmem = get_system_memory();
43
MemoryRegion *vram = g_new(MemoryRegion, 1);
44
@@ -XXX,XX +XXX,XX @@ static void vexpress_common_init(MachineState *machine)
45
sysbus_create_simple("sp804", map[VE_TIMER01], pic[2]);
46
sysbus_create_simple("sp804", map[VE_TIMER23], pic[3]);
47
48
- /* VE_SERIALDVI: not modelled */
49
+ dev = sysbus_create_simple("versatile_i2c", map[VE_SERIALDVI], NULL);
50
+ i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c");
51
+ i2c_create_slave(i2c, "sii9022", 0x39);
52
53
sysbus_create_simple("pl031", map[VE_RTC], pic[4]); /* RTC */
54
55
diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
56
index XXXXXXX..XXXXXXX 100644
57
--- a/default-configs/arm-softmmu.mak
58
+++ b/default-configs/arm-softmmu.mak
59
@@ -XXX,XX +XXX,XX @@ CONFIG_STELLARIS_INPUT=y
60
CONFIG_STELLARIS_ENET=y
61
CONFIG_SSD0303=y
62
CONFIG_SSD0323=y
63
+CONFIG_DDC=y
64
+CONFIG_SII9022=y
65
CONFIG_ADS7846=y
66
CONFIG_MAX111X=y
67
CONFIG_SSI=y
68
--
69
2.16.2
70
71
diff view generated by jsdifflib
Deleted patch
1
From: Alex Bennée <alex.bennee@linaro.org>
2
1
3
This allows us to explicitly pass float16 to helpers rather than
4
assuming uint32_t and dealing with the result. Of course they will be
5
passed in i32 sized registers by default.
6
7
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20180227143852.11175-2-alex.bennee@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
include/exec/helper-head.h | 3 +++
13
1 file changed, 3 insertions(+)
14
15
diff --git a/include/exec/helper-head.h b/include/exec/helper-head.h
16
index XXXXXXX..XXXXXXX 100644
17
--- a/include/exec/helper-head.h
18
+++ b/include/exec/helper-head.h
19
@@ -XXX,XX +XXX,XX @@
20
#define dh_alias_int i32
21
#define dh_alias_i64 i64
22
#define dh_alias_s64 i64
23
+#define dh_alias_f16 i32
24
#define dh_alias_f32 i32
25
#define dh_alias_f64 i64
26
#define dh_alias_ptr ptr
27
@@ -XXX,XX +XXX,XX @@
28
#define dh_ctype_int int
29
#define dh_ctype_i64 uint64_t
30
#define dh_ctype_s64 int64_t
31
+#define dh_ctype_f16 float16
32
#define dh_ctype_f32 float32
33
#define dh_ctype_f64 float64
34
#define dh_ctype_ptr void *
35
@@ -XXX,XX +XXX,XX @@
36
#define dh_is_signed_s32 1
37
#define dh_is_signed_i64 0
38
#define dh_is_signed_s64 1
39
+#define dh_is_signed_f16 0
40
#define dh_is_signed_f32 0
41
#define dh_is_signed_f64 0
42
#define dh_is_signed_tl 0
43
--
44
2.16.2
45
46
diff view generated by jsdifflib
Deleted patch
1
From: Alex Bennée <alex.bennee@linaro.org>
2
1
3
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20180227143852.11175-3-alex.bennee@linaro.org
6
[PMM: postpone actually enabling feature until end of the
7
patch series]
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
10
target/arm/cpu.h | 1 +
11
1 file changed, 1 insertion(+)
12
13
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/cpu.h
16
+++ b/target/arm/cpu.h
17
@@ -XXX,XX +XXX,XX @@ enum arm_features {
18
ARM_FEATURE_V8_SHA3, /* implements SHA3 part of v8 Crypto Extensions */
19
ARM_FEATURE_V8_SM3, /* implements SM3 part of v8 Crypto Extensions */
20
ARM_FEATURE_V8_SM4, /* implements SM4 part of v8 Crypto Extensions */
21
+ ARM_FEATURE_V8_FP16, /* implements v8.2 half-precision float */
22
};
23
24
static inline int arm_feature(CPUARMState *env, int feature)
25
--
26
2.16.2
27
28
diff view generated by jsdifflib
Deleted patch
1
From: Alex Bennée <alex.bennee@linaro.org>
2
1
3
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20180227143852.11175-4-alex.bennee@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
target/arm/cpu.h | 1 +
9
1 file changed, 1 insertion(+)
10
11
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
12
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/cpu.h
14
+++ b/target/arm/cpu.h
15
@@ -XXX,XX +XXX,XX @@ typedef struct {
16
* Qn = regs[n].d[1]:regs[n].d[0]
17
* Dn = regs[n].d[0]
18
* Sn = regs[n].d[0] bits 31..0
19
+ * Hn = regs[n].d[0] bits 15..0
20
*
21
* This corresponds to the architecturally defined mapping between
22
* the two execution states, and means we do not need to explicitly
23
--
24
2.16.2
25
26
diff view generated by jsdifflib
Deleted patch
1
From: Alex Bennée <alex.bennee@linaro.org>
2
1
3
Half-precision flush to zero behaviour is controlled by a separate
4
FZ16 bit in the FPCR. To handle this we pass a pointer to
5
fp_status_fp16 when working on half-precision operations. The value of
6
the presented FPCR is calculated from an amalgam of the two when read.
7
8
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20180227143852.11175-5-alex.bennee@linaro.org
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
13
target/arm/cpu.h | 32 ++++++++++++++++++++++------
14
target/arm/helper.c | 26 ++++++++++++++++++-----
15
target/arm/translate-a64.c | 53 +++++++++++++++++++++++++---------------------
16
3 files changed, 75 insertions(+), 36 deletions(-)
17
18
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
19
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/cpu.h
21
+++ b/target/arm/cpu.h
22
@@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState {
23
/* scratch space when Tn are not sufficient. */
24
uint32_t scratch[8];
25
26
- /* fp_status is the "normal" fp status. standard_fp_status retains
27
- * values corresponding to the ARM "Standard FPSCR Value", ie
28
- * default-NaN, flush-to-zero, round-to-nearest and is used by
29
- * any operations (generally Neon) which the architecture defines
30
- * as controlled by the standard FPSCR value rather than the FPSCR.
31
+ /* There are a number of distinct float control structures:
32
+ *
33
+ * fp_status: is the "normal" fp status.
34
+ * fp_status_fp16: used for half-precision calculations
35
+ * standard_fp_status : the ARM "Standard FPSCR Value"
36
+ *
37
+ * Half-precision operations are governed by a separate
38
+ * flush-to-zero control bit in FPSCR:FZ16. We pass a separate
39
+ * status structure to control this.
40
+ *
41
+ * The "Standard FPSCR", ie default-NaN, flush-to-zero,
42
+ * round-to-nearest and is used by any operations (generally
43
+ * Neon) which the architecture defines as controlled by the
44
+ * standard FPSCR value rather than the FPSCR.
45
*
46
* To avoid having to transfer exception bits around, we simply
47
* say that the FPSCR cumulative exception flags are the logical
48
- * OR of the flags in the two fp statuses. This relies on the
49
+ * OR of the flags in the three fp statuses. This relies on the
50
* only thing which needs to read the exception flags being
51
* an explicit FPSCR read.
52
*/
53
float_status fp_status;
54
+ float_status fp_status_f16;
55
float_status standard_fp_status;
56
57
/* ZCR_EL[1-3] */
58
@@ -XXX,XX +XXX,XX @@ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask)
59
uint32_t vfp_get_fpscr(CPUARMState *env);
60
void vfp_set_fpscr(CPUARMState *env, uint32_t val);
61
62
-/* For A64 the FPSCR is split into two logically distinct registers,
63
+/* FPCR, Floating Point Control Register
64
+ * FPSR, Floating Poiht Status Register
65
+ *
66
+ * For A64 the FPSCR is split into two logically distinct registers,
67
* FPCR and FPSR. However since they still use non-overlapping bits
68
* we store the underlying state in fpscr and just mask on read/write.
69
*/
70
#define FPSR_MASK 0xf800009f
71
#define FPCR_MASK 0x07f79f00
72
+
73
+#define FPCR_FZ16 (1 << 19) /* ARMv8.2+, FP16 flush-to-zero */
74
+#define FPCR_FZ (1 << 24) /* Flush-to-zero enable bit */
75
+#define FPCR_DN (1 << 25) /* Default NaN enable bit */
76
+
77
static inline uint32_t vfp_get_fpsr(CPUARMState *env)
78
{
79
return vfp_get_fpscr(env) & FPSR_MASK;
80
diff --git a/target/arm/helper.c b/target/arm/helper.c
81
index XXXXXXX..XXXXXXX 100644
82
--- a/target/arm/helper.c
83
+++ b/target/arm/helper.c
84
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env)
85
| (env->vfp.vec_stride << 20);
86
i = get_float_exception_flags(&env->vfp.fp_status);
87
i |= get_float_exception_flags(&env->vfp.standard_fp_status);
88
+ i |= get_float_exception_flags(&env->vfp.fp_status_f16);
89
fpscr |= vfp_exceptbits_from_host(i);
90
return fpscr;
91
}
92
@@ -XXX,XX +XXX,XX @@ void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val)
93
break;
94
}
95
set_float_rounding_mode(i, &env->vfp.fp_status);
96
+ set_float_rounding_mode(i, &env->vfp.fp_status_f16);
97
}
98
- if (changed & (1 << 24)) {
99
- set_flush_to_zero((val & (1 << 24)) != 0, &env->vfp.fp_status);
100
- set_flush_inputs_to_zero((val & (1 << 24)) != 0, &env->vfp.fp_status);
101
+ if (changed & FPCR_FZ16) {
102
+ bool ftz_enabled = val & FPCR_FZ16;
103
+ set_flush_to_zero(ftz_enabled, &env->vfp.fp_status_f16);
104
+ set_flush_inputs_to_zero(ftz_enabled, &env->vfp.fp_status_f16);
105
+ }
106
+ if (changed & FPCR_FZ) {
107
+ bool ftz_enabled = val & FPCR_FZ;
108
+ set_flush_to_zero(ftz_enabled, &env->vfp.fp_status);
109
+ set_flush_inputs_to_zero(ftz_enabled, &env->vfp.fp_status);
110
+ }
111
+ if (changed & FPCR_DN) {
112
+ bool dnan_enabled = val & FPCR_DN;
113
+ set_default_nan_mode(dnan_enabled, &env->vfp.fp_status);
114
+ set_default_nan_mode(dnan_enabled, &env->vfp.fp_status_f16);
115
}
116
- if (changed & (1 << 25))
117
- set_default_nan_mode((val & (1 << 25)) != 0, &env->vfp.fp_status);
118
119
+ /* The exception flags are ORed together when we read fpscr so we
120
+ * only need to preserve the current state in one of our
121
+ * float_status values.
122
+ */
123
i = vfp_exceptbits_to_host(val);
124
set_float_exception_flags(i, &env->vfp.fp_status);
125
+ set_float_exception_flags(0, &env->vfp.fp_status_f16);
126
set_float_exception_flags(0, &env->vfp.standard_fp_status);
127
}
128
129
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
130
index XXXXXXX..XXXXXXX 100644
131
--- a/target/arm/translate-a64.c
132
+++ b/target/arm/translate-a64.c
133
@@ -XXX,XX +XXX,XX @@ static void write_fp_sreg(DisasContext *s, int reg, TCGv_i32 v)
134
tcg_temp_free_i64(tmp);
135
}
136
137
-static TCGv_ptr get_fpstatus_ptr(void)
138
+static TCGv_ptr get_fpstatus_ptr(bool is_f16)
139
{
140
TCGv_ptr statusptr = tcg_temp_new_ptr();
141
int offset;
142
143
- /* In A64 all instructions (both FP and Neon) use the FPCR;
144
- * there is no equivalent of the A32 Neon "standard FPSCR value"
145
- * and all operations use vfp.fp_status.
146
+ /* In A64 all instructions (both FP and Neon) use the FPCR; there
147
+ * is no equivalent of the A32 Neon "standard FPSCR value".
148
+ * However half-precision operations operate under a different
149
+ * FZ16 flag and use vfp.fp_status_f16 instead of vfp.fp_status.
150
*/
151
- offset = offsetof(CPUARMState, vfp.fp_status);
152
+ if (is_f16) {
153
+ offset = offsetof(CPUARMState, vfp.fp_status_f16);
154
+ } else {
155
+ offset = offsetof(CPUARMState, vfp.fp_status);
156
+ }
157
tcg_gen_addi_ptr(statusptr, cpu_env, offset);
158
return statusptr;
159
}
160
@@ -XXX,XX +XXX,XX @@ static void handle_fp_compare(DisasContext *s, bool is_double,
161
bool cmp_with_zero, bool signal_all_nans)
162
{
163
TCGv_i64 tcg_flags = tcg_temp_new_i64();
164
- TCGv_ptr fpst = get_fpstatus_ptr();
165
+ TCGv_ptr fpst = get_fpstatus_ptr(false);
166
167
if (is_double) {
168
TCGv_i64 tcg_vn, tcg_vm;
169
@@ -XXX,XX +XXX,XX @@ static void handle_fp_1src_single(DisasContext *s, int opcode, int rd, int rn)
170
TCGv_i32 tcg_op;
171
TCGv_i32 tcg_res;
172
173
- fpst = get_fpstatus_ptr();
174
+ fpst = get_fpstatus_ptr(false);
175
tcg_op = read_fp_sreg(s, rn);
176
tcg_res = tcg_temp_new_i32();
177
178
@@ -XXX,XX +XXX,XX @@ static void handle_fp_1src_double(DisasContext *s, int opcode, int rd, int rn)
179
return;
180
}
181
182
- fpst = get_fpstatus_ptr();
183
+ fpst = get_fpstatus_ptr(false);
184
tcg_op = read_fp_dreg(s, rn);
185
tcg_res = tcg_temp_new_i64();
186
187
@@ -XXX,XX +XXX,XX @@ static void handle_fp_2src_single(DisasContext *s, int opcode,
188
TCGv_ptr fpst;
189
190
tcg_res = tcg_temp_new_i32();
191
- fpst = get_fpstatus_ptr();
192
+ fpst = get_fpstatus_ptr(false);
193
tcg_op1 = read_fp_sreg(s, rn);
194
tcg_op2 = read_fp_sreg(s, rm);
195
196
@@ -XXX,XX +XXX,XX @@ static void handle_fp_2src_double(DisasContext *s, int opcode,
197
TCGv_ptr fpst;
198
199
tcg_res = tcg_temp_new_i64();
200
- fpst = get_fpstatus_ptr();
201
+ fpst = get_fpstatus_ptr(false);
202
tcg_op1 = read_fp_dreg(s, rn);
203
tcg_op2 = read_fp_dreg(s, rm);
204
205
@@ -XXX,XX +XXX,XX @@ static void handle_fp_3src_single(DisasContext *s, bool o0, bool o1,
206
{
207
TCGv_i32 tcg_op1, tcg_op2, tcg_op3;
208
TCGv_i32 tcg_res = tcg_temp_new_i32();
209
- TCGv_ptr fpst = get_fpstatus_ptr();
210
+ TCGv_ptr fpst = get_fpstatus_ptr(false);
211
212
tcg_op1 = read_fp_sreg(s, rn);
213
tcg_op2 = read_fp_sreg(s, rm);
214
@@ -XXX,XX +XXX,XX @@ static void handle_fp_3src_double(DisasContext *s, bool o0, bool o1,
215
{
216
TCGv_i64 tcg_op1, tcg_op2, tcg_op3;
217
TCGv_i64 tcg_res = tcg_temp_new_i64();
218
- TCGv_ptr fpst = get_fpstatus_ptr();
219
+ TCGv_ptr fpst = get_fpstatus_ptr(false);
220
221
tcg_op1 = read_fp_dreg(s, rn);
222
tcg_op2 = read_fp_dreg(s, rm);
223
@@ -XXX,XX +XXX,XX @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode,
224
TCGv_ptr tcg_fpstatus;
225
TCGv_i32 tcg_shift;
226
227
- tcg_fpstatus = get_fpstatus_ptr();
228
+ tcg_fpstatus = get_fpstatus_ptr(false);
229
230
tcg_shift = tcg_const_i32(64 - scale);
231
232
@@ -XXX,XX +XXX,XX @@ static void disas_simd_across_lanes(DisasContext *s, uint32_t insn)
233
TCGv_i32 tcg_elt1 = tcg_temp_new_i32();
234
TCGv_i32 tcg_elt2 = tcg_temp_new_i32();
235
TCGv_i32 tcg_elt3 = tcg_temp_new_i32();
236
- TCGv_ptr fpst = get_fpstatus_ptr();
237
+ TCGv_ptr fpst = get_fpstatus_ptr(false);
238
239
assert(esize == 32);
240
assert(elements == 4);
241
@@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_pairwise(DisasContext *s, uint32_t insn)
242
}
243
244
size = extract32(size, 0, 1) ? 3 : 2;
245
- fpst = get_fpstatus_ptr();
246
+ fpst = get_fpstatus_ptr(false);
247
break;
248
default:
249
unallocated_encoding(s);
250
@@ -XXX,XX +XXX,XX @@ static void handle_simd_intfp_conv(DisasContext *s, int rd, int rn,
251
int fracbits, int size)
252
{
253
bool is_double = size == 3 ? true : false;
254
- TCGv_ptr tcg_fpst = get_fpstatus_ptr();
255
+ TCGv_ptr tcg_fpst = get_fpstatus_ptr(false);
256
TCGv_i32 tcg_shift = tcg_const_i32(fracbits);
257
TCGv_i64 tcg_int = tcg_temp_new_i64();
258
TCGMemOp mop = size | (is_signed ? MO_SIGN : 0);
259
@@ -XXX,XX +XXX,XX @@ static void handle_simd_shift_fpint_conv(DisasContext *s, bool is_scalar,
260
261
tcg_rmode = tcg_const_i32(arm_rmode_to_sf(FPROUNDING_ZERO));
262
gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
263
- tcg_fpstatus = get_fpstatus_ptr();
264
+ tcg_fpstatus = get_fpstatus_ptr(false);
265
tcg_shift = tcg_const_i32(fracbits);
266
267
if (is_double) {
268
@@ -XXX,XX +XXX,XX @@ static void handle_3same_float(DisasContext *s, int size, int elements,
269
int fpopcode, int rd, int rn, int rm)
270
{
271
int pass;
272
- TCGv_ptr fpst = get_fpstatus_ptr();
273
+ TCGv_ptr fpst = get_fpstatus_ptr(false);
274
275
for (pass = 0; pass < elements; pass++) {
276
if (size) {
277
@@ -XXX,XX +XXX,XX @@ static void handle_2misc_fcmp_zero(DisasContext *s, int opcode,
278
return;
279
}
280
281
- fpst = get_fpstatus_ptr();
282
+ fpst = get_fpstatus_ptr(false);
283
284
if (is_double) {
285
TCGv_i64 tcg_op = tcg_temp_new_i64();
286
@@ -XXX,XX +XXX,XX @@ static void handle_2misc_reciprocal(DisasContext *s, int opcode,
287
int size, int rn, int rd)
288
{
289
bool is_double = (size == 3);
290
- TCGv_ptr fpst = get_fpstatus_ptr();
291
+ TCGv_ptr fpst = get_fpstatus_ptr(false);
292
293
if (is_double) {
294
TCGv_i64 tcg_op = tcg_temp_new_i64();
295
@@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_two_reg_misc(DisasContext *s, uint32_t insn)
296
if (is_fcvt) {
297
tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rmode));
298
gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
299
- tcg_fpstatus = get_fpstatus_ptr();
300
+ tcg_fpstatus = get_fpstatus_ptr(false);
301
} else {
302
tcg_rmode = NULL;
303
tcg_fpstatus = NULL;
304
@@ -XXX,XX +XXX,XX @@ static void handle_simd_3same_pair(DisasContext *s, int is_q, int u, int opcode,
305
306
/* Floating point operations need fpst */
307
if (opcode >= 0x58) {
308
- fpst = get_fpstatus_ptr();
309
+ fpst = get_fpstatus_ptr(false);
310
} else {
311
fpst = NULL;
312
}
313
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn)
314
}
315
316
if (need_fpstatus) {
317
- tcg_fpstatus = get_fpstatus_ptr();
318
+ tcg_fpstatus = get_fpstatus_ptr(false);
319
} else {
320
tcg_fpstatus = NULL;
321
}
322
@@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn)
323
}
324
325
if (is_fp) {
326
- fpst = get_fpstatus_ptr();
327
+ fpst = get_fpstatus_ptr(false);
328
} else {
329
fpst = NULL;
330
}
331
--
332
2.16.2
333
334
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
The function asimd_imm_const() in translate-neon.c is an
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.
2
5
3
As some of the constants here will also be needed
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
elsewhere (specifically for the upcoming SVE support) we move them out
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
to softfloat.h.
8
Message-id: 20210628135835.6690-4-peter.maydell@linaro.org
9
---
10
target/arm/translate.h | 16 ++++++++++
11
target/arm/translate-neon.c | 63 -------------------------------------
12
target/arm/translate.c | 57 +++++++++++++++++++++++++++++++++
13
3 files changed, 73 insertions(+), 63 deletions(-)
6
14
7
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
15
diff --git a/target/arm/translate.h b/target/arm/translate.h
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20180227143852.11175-13-alex.bennee@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
include/fpu/softfloat.h | 18 +++++++++++++-----
13
target/arm/helper-a64.h | 2 ++
14
target/arm/helper-a64.c | 34 ++++++++++++++++++++++++++++++++++
15
target/arm/translate-a64.c | 6 ++++++
16
4 files changed, 55 insertions(+), 5 deletions(-)
17
18
diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
19
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
20
--- a/include/fpu/softfloat.h
17
--- a/target/arm/translate.h
21
+++ b/include/fpu/softfloat.h
18
+++ b/target/arm/translate.h
22
@@ -XXX,XX +XXX,XX @@ static inline float16 float16_set_sign(float16 a, int sign)
19
@@ -XXX,XX +XXX,XX @@ static inline MemOp finalize_memop(DisasContext *s, MemOp opc)
20
return opc | s->be_data;
23
}
21
}
24
22
25
#define float16_zero make_float16(0)
23
+/**
26
-#define float16_one make_float16(0x3c00)
24
+ * asimd_imm_const: Expand an encoded SIMD constant value
27
#define float16_half make_float16(0x3800)
25
+ *
28
+#define float16_one make_float16(0x3c00)
26
+ * Expand a SIMD constant value. This is essentially the pseudocode
29
+#define float16_one_point_five make_float16(0x3e00)
27
+ * AdvSIMDExpandImm, except that we also perform the boolean NOT needed for
30
+#define float16_two make_float16(0x4000)
28
+ * VMVN and VBIC (when cmode < 14 && op == 1).
31
+#define float16_three make_float16(0x4200)
29
+ *
32
#define float16_infinity make_float16(0x7c00)
30
+ * The combination cmode == 15 op == 1 is a reserved encoding for AArch32;
33
31
+ * callers must catch this.
34
/*----------------------------------------------------------------------------
32
+ *
35
@@ -XXX,XX +XXX,XX @@ static inline float32 float32_set_sign(float32 a, int sign)
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
+
39
#endif /* TARGET_ARM_TRANSLATE_H */
40
diff --git a/target/arm/translate-neon.c b/target/arm/translate-neon.c
41
index XXXXXXX..XXXXXXX 100644
42
--- a/target/arm/translate-neon.c
43
+++ b/target/arm/translate-neon.c
44
@@ -XXX,XX +XXX,XX @@ DO_FP_2SH(VCVT_UH, gen_helper_gvec_vcvt_uh)
45
DO_FP_2SH(VCVT_HS, gen_helper_gvec_vcvt_hs)
46
DO_FP_2SH(VCVT_HU, gen_helper_gvec_vcvt_hu)
47
48
-static uint64_t asimd_imm_const(uint32_t imm, int cmode, int op)
49
-{
50
- /*
51
- * Expand the encoded constant.
52
- * Note that cmode = 2,3,4,5,6,7,10,11,12,13 imm=0 is UNPREDICTABLE.
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
116
--- a/target/arm/translate.c
117
+++ b/target/arm/translate.c
118
@@ -XXX,XX +XXX,XX @@ void arm_translate_init(void)
119
a64_translate_init();
36
}
120
}
37
121
38
#define float32_zero make_float32(0)
122
+uint64_t asimd_imm_const(uint32_t imm, int cmode, int op)
39
-#define float32_one make_float32(0x3f800000)
123
+{
40
#define float32_half make_float32(0x3f000000)
124
+ /* Expand the encoded constant as per AdvSIMDExpandImm pseudocode */
41
+#define float32_one make_float32(0x3f800000)
125
+ switch (cmode) {
42
+#define float32_one_point_five make_float32(0x3fc00000)
126
+ case 0: case 1:
43
+#define float32_two make_float32(0x40000000)
127
+ /* no-op */
44
+#define float32_three make_float32(0x40400000)
128
+ break;
45
#define float32_infinity make_float32(0x7f800000)
129
+ case 2: case 3:
46
130
+ imm <<= 8;
47
-
131
+ break;
48
/*----------------------------------------------------------------------------
132
+ case 4: case 5:
49
| The pattern for a default generated single-precision NaN.
133
+ imm <<= 16;
50
*----------------------------------------------------------------------------*/
134
+ break;
51
@@ -XXX,XX +XXX,XX @@ static inline float64 float64_set_sign(float64 a, int sign)
135
+ case 6: case 7:
52
}
136
+ imm <<= 24;
53
137
+ break;
54
#define float64_zero make_float64(0)
138
+ case 8: case 9:
55
-#define float64_one make_float64(0x3ff0000000000000LL)
139
+ imm |= imm << 16;
56
-#define float64_ln2 make_float64(0x3fe62e42fefa39efLL)
140
+ break;
57
#define float64_half make_float64(0x3fe0000000000000LL)
141
+ case 10: case 11:
58
+#define float64_one make_float64(0x3ff0000000000000LL)
142
+ imm = (imm << 8) | (imm << 24);
59
+#define float64_one_point_five make_float64(0x3FF8000000000000ULL)
143
+ break;
60
+#define float64_two make_float64(0x4000000000000000ULL)
144
+ case 12:
61
+#define float64_three make_float64(0x4008000000000000ULL)
145
+ imm = (imm << 8) | 0xff;
62
+#define float64_ln2 make_float64(0x3fe62e42fefa39efLL)
146
+ break;
63
#define float64_infinity make_float64(0x7ff0000000000000LL)
147
+ case 13:
64
148
+ imm = (imm << 16) | 0xffff;
65
/*----------------------------------------------------------------------------
149
+ break;
66
diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h
150
+ case 14:
67
index XXXXXXX..XXXXXXX 100644
151
+ if (op) {
68
--- a/target/arm/helper-a64.h
152
+ /*
69
+++ b/target/arm/helper-a64.h
153
+ * This is the only case where the top and bottom 32 bits
70
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(vfp_mulxd, TCG_CALL_NO_RWG, f64, f64, f64, ptr)
154
+ * of the encoded constant differ.
71
DEF_HELPER_FLAGS_3(neon_ceq_f64, TCG_CALL_NO_RWG, i64, i64, i64, ptr)
155
+ */
72
DEF_HELPER_FLAGS_3(neon_cge_f64, TCG_CALL_NO_RWG, i64, i64, i64, ptr)
156
+ uint64_t imm64 = 0;
73
DEF_HELPER_FLAGS_3(neon_cgt_f64, TCG_CALL_NO_RWG, i64, i64, i64, ptr)
157
+ int n;
74
+DEF_HELPER_FLAGS_3(recpsf_f16, TCG_CALL_NO_RWG, f16, f16, f16, ptr)
75
DEF_HELPER_FLAGS_3(recpsf_f32, TCG_CALL_NO_RWG, f32, f32, f32, ptr)
76
DEF_HELPER_FLAGS_3(recpsf_f64, TCG_CALL_NO_RWG, f64, f64, f64, ptr)
77
+DEF_HELPER_FLAGS_3(rsqrtsf_f16, TCG_CALL_NO_RWG, f16, f16, f16, ptr)
78
DEF_HELPER_FLAGS_3(rsqrtsf_f32, TCG_CALL_NO_RWG, f32, f32, f32, ptr)
79
DEF_HELPER_FLAGS_3(rsqrtsf_f64, TCG_CALL_NO_RWG, f64, f64, f64, ptr)
80
DEF_HELPER_FLAGS_1(neon_addlp_s8, TCG_CALL_NO_RWG_SE, i64, i64)
81
diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c
82
index XXXXXXX..XXXXXXX 100644
83
--- a/target/arm/helper-a64.c
84
+++ b/target/arm/helper-a64.c
85
@@ -XXX,XX +XXX,XX @@ uint64_t HELPER(neon_cgt_f64)(float64 a, float64 b, void *fpstp)
86
* versions, these do a fully fused multiply-add or
87
* multiply-add-and-halve.
88
*/
89
+#define float16_two make_float16(0x4000)
90
+#define float16_three make_float16(0x4200)
91
+#define float16_one_point_five make_float16(0x3e00)
92
+
158
+
93
#define float32_two make_float32(0x40000000)
159
+ for (n = 0; n < 8; n++) {
94
#define float32_three make_float32(0x40400000)
160
+ if (imm & (1 << n)) {
95
#define float32_one_point_five make_float32(0x3fc00000)
161
+ imm64 |= (0xffULL << (n * 8));
96
@@ -XXX,XX +XXX,XX @@ uint64_t HELPER(neon_cgt_f64)(float64 a, float64 b, void *fpstp)
162
+ }
97
#define float64_three make_float64(0x4008000000000000ULL)
163
+ }
98
#define float64_one_point_five make_float64(0x3FF8000000000000ULL)
164
+ return imm64;
99
165
+ }
100
+float16 HELPER(recpsf_f16)(float16 a, float16 b, void *fpstp)
166
+ imm |= (imm << 8) | (imm << 16) | (imm << 24);
101
+{
167
+ break;
102
+ float_status *fpst = fpstp;
168
+ case 15:
103
+
169
+ imm = ((imm & 0x80) << 24) | ((imm & 0x3f) << 19)
104
+ a = float16_squash_input_denormal(a, fpst);
170
+ | ((imm & 0x40) ? (0x1f << 25) : (1 << 30));
105
+ b = float16_squash_input_denormal(b, fpst);
171
+ break;
106
+
107
+ a = float16_chs(a);
108
+ if ((float16_is_infinity(a) && float16_is_zero(b)) ||
109
+ (float16_is_infinity(b) && float16_is_zero(a))) {
110
+ return float16_two;
111
+ }
172
+ }
112
+ return float16_muladd(a, b, float16_two, 0, fpst);
173
+ if (op) {
174
+ imm = ~imm;
175
+ }
176
+ return dup_const(MO_32, imm);
113
+}
177
+}
114
+
178
+
115
float32 HELPER(recpsf_f32)(float32 a, float32 b, void *fpstp)
179
/* Generate a label used for skipping this instruction */
180
void arm_gen_condlabel(DisasContext *s)
116
{
181
{
117
float_status *fpst = fpstp;
118
@@ -XXX,XX +XXX,XX @@ float64 HELPER(recpsf_f64)(float64 a, float64 b, void *fpstp)
119
return float64_muladd(a, b, float64_two, 0, fpst);
120
}
121
122
+float16 HELPER(rsqrtsf_f16)(float16 a, float16 b, void *fpstp)
123
+{
124
+ float_status *fpst = fpstp;
125
+
126
+ a = float16_squash_input_denormal(a, fpst);
127
+ b = float16_squash_input_denormal(b, fpst);
128
+
129
+ a = float16_chs(a);
130
+ if ((float16_is_infinity(a) && float16_is_zero(b)) ||
131
+ (float16_is_infinity(b) && float16_is_zero(a))) {
132
+ return float16_one_point_five;
133
+ }
134
+ return float16_muladd(a, b, float16_three, float_muladd_halve_result, fpst);
135
+}
136
+
137
float32 HELPER(rsqrtsf_f32)(float32 a, float32 b, void *fpstp)
138
{
139
float_status *fpst = fpstp;
140
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
141
index XXXXXXX..XXXXXXX 100644
142
--- a/target/arm/translate-a64.c
143
+++ b/target/arm/translate-a64.c
144
@@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn)
145
case 0x6: /* FMAX */
146
gen_helper_advsimd_maxh(tcg_res, tcg_op1, tcg_op2, fpst);
147
break;
148
+ case 0x7: /* FRECPS */
149
+ gen_helper_recpsf_f16(tcg_res, tcg_op1, tcg_op2, fpst);
150
+ break;
151
case 0x8: /* FMINNM */
152
gen_helper_advsimd_minnumh(tcg_res, tcg_op1, tcg_op2, fpst);
153
break;
154
@@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn)
155
case 0xe: /* FMIN */
156
gen_helper_advsimd_minh(tcg_res, tcg_op1, tcg_op2, fpst);
157
break;
158
+ case 0xf: /* FRSQRTS */
159
+ gen_helper_rsqrtsf_f16(tcg_res, tcg_op1, tcg_op2, fpst);
160
+ break;
161
case 0x13: /* FMUL */
162
gen_helper_advsimd_mulh(tcg_res, tcg_op1, tcg_op2, fpst);
163
break;
164
--
182
--
165
2.16.2
183
2.20.1
166
184
167
185
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
The A64 AdvSIMD modified-immediate grouping uses almost the same
2
constant encoding that A32 Neon does; reuse asimd_imm_const() (to
3
which we add the AArch64-specific case for cmode 15 op 1) instead of
4
reimplementing it all.
2
5
3
Neither of these operations alter the floating point status registers
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
so we can do a pure bitwise operation, either squashing any sign
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
bit (ABS) or inverting it (NEG).
8
Message-id: 20210628135835.6690-5-peter.maydell@linaro.org
9
---
10
target/arm/translate.h | 3 +-
11
target/arm/translate-a64.c | 86 ++++----------------------------------
12
target/arm/translate.c | 17 +++++++-
13
3 files changed, 24 insertions(+), 82 deletions(-)
6
14
7
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
15
diff --git a/target/arm/translate.h b/target/arm/translate.h
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
16
index XXXXXXX..XXXXXXX 100644
9
Message-id: 20180227143852.11175-22-alex.bennee@linaro.org
17
--- a/target/arm/translate.h
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
+++ b/target/arm/translate.h
11
---
19
@@ -XXX,XX +XXX,XX @@ static inline MemOp finalize_memop(DisasContext *s, MemOp opc)
12
target/arm/translate-a64.c | 16 +++++++++++++++-
20
* VMVN and VBIC (when cmode < 14 && op == 1).
13
1 file changed, 15 insertions(+), 1 deletion(-)
21
*
14
22
* The combination cmode == 15 op == 1 is a reserved encoding for AArch32;
23
- * callers must catch this.
24
+ * callers must catch this; we return the 64-bit constant value defined
25
+ * for AArch64.
26
*
27
* cmode = 2,3,4,5,6,7,10,11,12,13 imm=0 was UNPREDICTABLE in v7A but
28
* is either not unpredictable or merely CONSTRAINED UNPREDICTABLE in v8A;
15
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
29
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
16
index XXXXXXX..XXXXXXX 100644
30
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/translate-a64.c
31
--- a/target/arm/translate-a64.c
18
+++ b/target/arm/translate-a64.c
32
+++ b/target/arm/translate-a64.c
19
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
33
@@ -XXX,XX +XXX,XX @@ static void disas_simd_mod_imm(DisasContext *s, uint32_t insn)
20
TCGv_i32 tcg_rmode = NULL;
34
{
21
TCGv_ptr tcg_fpstatus = NULL;
35
int rd = extract32(insn, 0, 5);
22
bool need_rmode = false;
36
int cmode = extract32(insn, 12, 4);
23
+ bool need_fpst = true;
37
- int cmode_3_1 = extract32(cmode, 1, 3);
24
int rmode;
38
- int cmode_0 = extract32(cmode, 0, 1);
25
39
int o2 = extract32(insn, 11, 1);
26
if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) {
40
uint64_t abcdefgh = extract32(insn, 5, 5) | (extract32(insn, 16, 3) << 5);
27
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
41
bool is_neg = extract32(insn, 29, 1);
28
need_rmode = true;
42
@@ -XXX,XX +XXX,XX @@ static void disas_simd_mod_imm(DisasContext *s, uint32_t insn)
29
rmode = FPROUNDING_ZERO;
30
break;
31
+ case 0x2f: /* FABS */
32
+ case 0x6f: /* FNEG */
33
+ need_fpst = false;
34
+ break;
35
default:
36
fprintf(stderr, "%s: insn %#04x fpop %#2x\n", __func__, insn, fpop);
37
g_assert_not_reached();
38
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
39
return;
43
return;
40
}
44
}
41
45
42
- if (need_rmode) {
46
- /* See AdvSIMDExpandImm() in ARM ARM */
43
+ if (need_rmode || need_fpst) {
47
- switch (cmode_3_1) {
44
tcg_fpstatus = get_fpstatus_ptr(true);
48
- case 0: /* Replicate(Zeros(24):imm8, 2) */
49
- case 1: /* Replicate(Zeros(16):imm8:Zeros(8), 2) */
50
- case 2: /* Replicate(Zeros(8):imm8:Zeros(16), 2) */
51
- case 3: /* Replicate(imm8:Zeros(24), 2) */
52
- {
53
- int shift = cmode_3_1 * 8;
54
- imm = bitfield_replicate(abcdefgh << shift, 32);
55
- break;
56
- }
57
- case 4: /* Replicate(Zeros(8):imm8, 4) */
58
- case 5: /* Replicate(imm8:Zeros(8), 4) */
59
- {
60
- int shift = (cmode_3_1 & 0x1) * 8;
61
- imm = bitfield_replicate(abcdefgh << shift, 16);
62
- break;
63
- }
64
- case 6:
65
- if (cmode_0) {
66
- /* Replicate(Zeros(8):imm8:Ones(16), 2) */
67
- imm = (abcdefgh << 16) | 0xffff;
68
- } else {
69
- /* Replicate(Zeros(16):imm8:Ones(8), 2) */
70
- imm = (abcdefgh << 8) | 0xff;
71
- }
72
- imm = bitfield_replicate(imm, 32);
73
- break;
74
- case 7:
75
- if (!cmode_0 && !is_neg) {
76
- imm = bitfield_replicate(abcdefgh, 8);
77
- } else if (!cmode_0 && is_neg) {
78
- int i;
79
- imm = 0;
80
- for (i = 0; i < 8; i++) {
81
- if ((abcdefgh) & (1 << i)) {
82
- imm |= 0xffULL << (i * 8);
83
- }
84
- }
85
- } else if (cmode_0) {
86
- if (is_neg) {
87
- imm = (abcdefgh & 0x3f) << 48;
88
- if (abcdefgh & 0x80) {
89
- imm |= 0x8000000000000000ULL;
90
- }
91
- if (abcdefgh & 0x40) {
92
- imm |= 0x3fc0000000000000ULL;
93
- } else {
94
- imm |= 0x4000000000000000ULL;
95
- }
96
- } else {
97
- if (o2) {
98
- /* FMOV (vector, immediate) - half-precision */
99
- imm = vfp_expand_imm(MO_16, abcdefgh);
100
- /* now duplicate across the lanes */
101
- imm = bitfield_replicate(imm, 16);
102
- } else {
103
- imm = (abcdefgh & 0x3f) << 19;
104
- if (abcdefgh & 0x80) {
105
- imm |= 0x80000000;
106
- }
107
- if (abcdefgh & 0x40) {
108
- imm |= 0x3e000000;
109
- } else {
110
- imm |= 0x40000000;
111
- }
112
- imm |= (imm << 32);
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);
45
}
130
}
46
131
47
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
132
if (!((cmode & 0x9) == 0x1 || (cmode & 0xd) == 0x9)) {
48
case 0x7b: /* FCVTZU */
133
diff --git a/target/arm/translate.c b/target/arm/translate.c
49
gen_helper_advsimd_f16touinth(tcg_res, tcg_op, tcg_fpstatus);
134
index XXXXXXX..XXXXXXX 100644
50
break;
135
--- a/target/arm/translate.c
51
+ case 0x6f: /* FNEG */
136
+++ b/target/arm/translate.c
52
+ tcg_gen_xori_i32(tcg_res, tcg_op, 0x8000);
137
@@ -XXX,XX +XXX,XX @@ uint64_t asimd_imm_const(uint32_t imm, int cmode, int op)
53
+ break;
138
case 14:
54
default:
139
if (op) {
55
g_assert_not_reached();
140
/*
56
}
141
- * This is the only case where the top and bottom 32 bits
57
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
142
- * of the encoded constant differ.
58
case 0x59: /* FRINTX */
143
+ * This and cmode == 15 op == 1 are the only cases where
59
gen_helper_advsimd_rinth_exact(tcg_res, tcg_op, tcg_fpstatus);
144
+ * the top and bottom 32 bits of the encoded constant differ.
60
break;
145
*/
61
+ case 0x2f: /* FABS */
146
uint64_t imm64 = 0;
62
+ tcg_gen_andi_i32(tcg_res, tcg_op, 0x7fff);
147
int n;
63
+ break;
148
@@ -XXX,XX +XXX,XX @@ uint64_t asimd_imm_const(uint32_t imm, int cmode, int op)
64
+ case 0x6f: /* FNEG */
149
imm |= (imm << 8) | (imm << 16) | (imm << 24);
65
+ tcg_gen_xori_i32(tcg_res, tcg_op, 0x8000);
150
break;
66
+ break;
151
case 15:
67
default:
152
+ if (op) {
68
g_assert_not_reached();
153
+ /* Reserved encoding for AArch32; valid for AArch64 */
69
}
154
+ uint64_t imm64 = (uint64_t)(imm & 0x3f) << 48;
155
+ if (imm & 0x80) {
156
+ imm64 |= 0x8000000000000000ULL;
157
+ }
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;
70
--
168
--
71
2.16.2
169
2.20.1
72
170
73
171
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
Use dup_const() instead of bitfield_replicate() in
2
disas_simd_mod_imm().
2
3
3
This covers the encoding group:
4
(We can't replace the other use of bitfield_replicate() in this file,
5
in logic_imm_decode_wmask(), because that location needs to handle 2
6
and 4 bit elements, which dup_const() cannot.)
4
7
5
Advanced SIMD scalar three same FP16
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
7
As all the helpers are already there it is simply a case of calling the
8
existing helpers in the scalar context.
9
10
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 20180227143852.11175-31-alex.bennee@linaro.org
10
Message-id: 20210628135835.6690-6-peter.maydell@linaro.org
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
11
---
15
target/arm/translate-a64.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++
12
target/arm/translate-a64.c | 2 +-
16
1 file changed, 99 insertions(+)
13
1 file changed, 1 insertion(+), 1 deletion(-)
17
14
18
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
15
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
19
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/translate-a64.c
17
--- a/target/arm/translate-a64.c
21
+++ b/target/arm/translate-a64.c
18
+++ b/target/arm/translate-a64.c
22
@@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_three_reg_same(DisasContext *s, uint32_t insn)
19
@@ -XXX,XX +XXX,XX @@ static void disas_simd_mod_imm(DisasContext *s, uint32_t insn)
23
tcg_temp_free_i64(tcg_rd);
20
/* FMOV (vector, immediate) - half-precision */
24
}
21
imm = vfp_expand_imm(MO_16, abcdefgh);
25
22
/* now duplicate across the lanes */
26
+/* AdvSIMD scalar three same FP16
23
- imm = bitfield_replicate(imm, 16);
27
+ * 31 30 29 28 24 23 22 21 20 16 15 14 13 11 10 9 5 4 0
24
+ imm = dup_const(MO_16, imm);
28
+ * +-----+---+-----------+---+-----+------+-----+--------+---+----+----+
25
} else {
29
+ * | 0 1 | U | 1 1 1 1 0 | a | 1 0 | Rm | 0 0 | opcode | 1 | Rn | Rd |
26
imm = asimd_imm_const(abcdefgh, cmode, is_neg);
30
+ * +-----+---+-----------+---+-----+------+-----+--------+---+----+----+
27
}
31
+ * v: 0101 1110 0100 0000 0000 0100 0000 0000 => 5e400400
32
+ * m: 1101 1111 0110 0000 1100 0100 0000 0000 => df60c400
33
+ */
34
+static void disas_simd_scalar_three_reg_same_fp16(DisasContext *s,
35
+ uint32_t insn)
36
+{
37
+ int rd = extract32(insn, 0, 5);
38
+ int rn = extract32(insn, 5, 5);
39
+ int opcode = extract32(insn, 11, 3);
40
+ int rm = extract32(insn, 16, 5);
41
+ bool u = extract32(insn, 29, 1);
42
+ bool a = extract32(insn, 23, 1);
43
+ int fpopcode = opcode | (a << 3) | (u << 4);
44
+ TCGv_ptr fpst;
45
+ TCGv_i32 tcg_op1;
46
+ TCGv_i32 tcg_op2;
47
+ TCGv_i32 tcg_res;
48
+
49
+ switch (fpopcode) {
50
+ case 0x03: /* FMULX */
51
+ case 0x04: /* FCMEQ (reg) */
52
+ case 0x07: /* FRECPS */
53
+ case 0x0f: /* FRSQRTS */
54
+ case 0x14: /* FCMGE (reg) */
55
+ case 0x15: /* FACGE */
56
+ case 0x1a: /* FABD */
57
+ case 0x1c: /* FCMGT (reg) */
58
+ case 0x1d: /* FACGT */
59
+ break;
60
+ default:
61
+ unallocated_encoding(s);
62
+ return;
63
+ }
64
+
65
+ if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) {
66
+ unallocated_encoding(s);
67
+ }
68
+
69
+ if (!fp_access_check(s)) {
70
+ return;
71
+ }
72
+
73
+ fpst = get_fpstatus_ptr(true);
74
+
75
+ tcg_op1 = tcg_temp_new_i32();
76
+ tcg_op2 = tcg_temp_new_i32();
77
+ tcg_res = tcg_temp_new_i32();
78
+
79
+ read_vec_element_i32(s, tcg_op1, rn, 0, MO_16);
80
+ read_vec_element_i32(s, tcg_op2, rm, 0, MO_16);
81
+
82
+ switch (fpopcode) {
83
+ case 0x03: /* FMULX */
84
+ gen_helper_advsimd_mulxh(tcg_res, tcg_op1, tcg_op2, fpst);
85
+ break;
86
+ case 0x04: /* FCMEQ (reg) */
87
+ gen_helper_advsimd_ceq_f16(tcg_res, tcg_op1, tcg_op2, fpst);
88
+ break;
89
+ case 0x07: /* FRECPS */
90
+ gen_helper_recpsf_f16(tcg_res, tcg_op1, tcg_op2, fpst);
91
+ break;
92
+ case 0x0f: /* FRSQRTS */
93
+ gen_helper_rsqrtsf_f16(tcg_res, tcg_op1, tcg_op2, fpst);
94
+ break;
95
+ case 0x14: /* FCMGE (reg) */
96
+ gen_helper_advsimd_cge_f16(tcg_res, tcg_op1, tcg_op2, fpst);
97
+ break;
98
+ case 0x15: /* FACGE */
99
+ gen_helper_advsimd_acge_f16(tcg_res, tcg_op1, tcg_op2, fpst);
100
+ break;
101
+ case 0x1a: /* FABD */
102
+ gen_helper_advsimd_subh(tcg_res, tcg_op1, tcg_op2, fpst);
103
+ tcg_gen_andi_i32(tcg_res, tcg_res, 0x7fff);
104
+ break;
105
+ case 0x1c: /* FCMGT (reg) */
106
+ gen_helper_advsimd_cgt_f16(tcg_res, tcg_op1, tcg_op2, fpst);
107
+ break;
108
+ case 0x1d: /* FACGT */
109
+ gen_helper_advsimd_acgt_f16(tcg_res, tcg_op1, tcg_op2, fpst);
110
+ break;
111
+ default:
112
+ g_assert_not_reached();
113
+ }
114
+
115
+ write_fp_sreg(s, rd, tcg_res);
116
+
117
+
118
+ tcg_temp_free_i32(tcg_res);
119
+ tcg_temp_free_i32(tcg_op1);
120
+ tcg_temp_free_i32(tcg_op2);
121
+ tcg_temp_free_ptr(fpst);
122
+}
123
+
124
static void handle_2misc_64(DisasContext *s, int opcode, bool u,
125
TCGv_i64 tcg_rd, TCGv_i64 tcg_rn,
126
TCGv_i32 tcg_rmode, TCGv_ptr tcg_fpstatus)
127
@@ -XXX,XX +XXX,XX @@ static const AArch64DecodeTable data_proc_simd[] = {
128
{ 0xce408000, 0xffe0c000, disas_crypto_three_reg_imm2 },
129
{ 0x0e400400, 0x9f60c400, disas_simd_three_reg_same_fp16 },
130
{ 0x0e780800, 0x8f7e0c00, disas_simd_two_reg_misc_fp16 },
131
+ { 0x5e400400, 0xdf60c400, disas_simd_scalar_three_reg_same_fp16 },
132
{ 0x00000000, 0x00000000, NULL }
133
};
134
135
--
28
--
136
2.16.2
29
2.20.1
137
30
138
31
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
Implement the MVE logical-immediate insns (VMOV, VMVN,
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.
2
5
3
This is the initial decode skeleton for the Advanced SIMD three same
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
instruction group.
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20210628135835.6690-7-peter.maydell@linaro.org
9
---
10
target/arm/helper-mve.h | 4 +++
11
target/arm/mve.decode | 17 +++++++++++++
12
target/arm/mve_helper.c | 24 ++++++++++++++++++
13
target/arm/translate-mve.c | 50 ++++++++++++++++++++++++++++++++++++++
14
4 files changed, 95 insertions(+)
5
15
6
The fprintf is purely to aid debugging as the additional instructions
16
diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h
7
are added. It will be removed once the group is complete.
8
9
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20180227143852.11175-9-alex.bennee@linaro.org
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
14
target/arm/translate-a64.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++
15
1 file changed, 73 insertions(+)
16
17
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
18
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/translate-a64.c
18
--- a/target/arm/helper-mve.h
20
+++ b/target/arm/translate-a64.c
19
+++ b/target/arm/helper-mve.h
21
@@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same(DisasContext *s, uint32_t insn)
20
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vaddvsh, TCG_CALL_NO_WG, i32, env, ptr, i32)
22
}
21
DEF_HELPER_FLAGS_3(mve_vaddvuh, TCG_CALL_NO_WG, i32, env, ptr, i32)
23
}
22
DEF_HELPER_FLAGS_3(mve_vaddvsw, TCG_CALL_NO_WG, i32, env, ptr, i32)
23
DEF_HELPER_FLAGS_3(mve_vaddvuw, TCG_CALL_NO_WG, i32, env, ptr, i32)
24
+
25
+DEF_HELPER_FLAGS_3(mve_vmovi, TCG_CALL_NO_WG, void, env, ptr, i64)
26
+DEF_HELPER_FLAGS_3(mve_vandi, TCG_CALL_NO_WG, void, env, ptr, i64)
27
+DEF_HELPER_FLAGS_3(mve_vorri, TCG_CALL_NO_WG, void, env, ptr, i64)
28
diff --git a/target/arm/mve.decode b/target/arm/mve.decode
29
index XXXXXXX..XXXXXXX 100644
30
--- a/target/arm/mve.decode
31
+++ b/target/arm/mve.decode
32
@@ -XXX,XX +XXX,XX @@
33
# VQDMULL has size in bit 28: 0 for 16 bit, 1 for 32 bit
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)
24
78
25
+/*
79
+/*
26
+ * Advanced SIMD three same (ARMv8.2 FP16 variants)
80
+ * 1 operand immediates: Vda is destination and possibly also one source.
27
+ *
81
+ * All these insns work at 64-bit widths.
28
+ * 31 30 29 28 24 23 22 21 20 16 15 14 13 11 10 9 5 4 0
29
+ * +---+---+---+-----------+---------+------+-----+--------+---+------+------+
30
+ * | 0 | Q | U | 0 1 1 1 0 | a | 1 0 | Rm | 0 0 | opcode | 1 | Rn | Rd |
31
+ * +---+---+---+-----------+---------+------+-----+--------+---+------+------+
32
+ *
33
+ * This includes FMULX, FCMEQ (register), FRECPS, FRSQRTS, FCMGE
34
+ * (register), FACGE, FABD, FCMGT (register) and FACGT.
35
+ *
36
+ */
82
+ */
37
+static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn)
83
+#define DO_1OP_IMM(OP, FN) \
38
+{
84
+ void HELPER(mve_##OP)(CPUARMState *env, void *vda, uint64_t imm) \
39
+ int opcode, fpopcode;
85
+ { \
40
+ int is_q, u, a, rm, rn, rd;
86
+ uint64_t *da = vda; \
41
+ int datasize, elements;
87
+ uint16_t mask = mve_element_mask(env); \
42
+ int pass;
88
+ unsigned e; \
43
+ TCGv_ptr fpst;
89
+ for (e = 0; e < 16 / 8; e++, mask >>= 8) { \
44
+
90
+ mergemask(&da[H8(e)], FN(da[H8(e)], imm), mask); \
45
+ if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) {
91
+ } \
46
+ unallocated_encoding(s);
92
+ mve_advance_vpt(env); \
47
+ return;
48
+ }
93
+ }
49
+
94
+
50
+ if (!fp_access_check(s)) {
95
+#define DO_MOVI(N, I) (I)
51
+ return;
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;
121
}
122
+
123
+static bool do_1imm(DisasContext *s, arg_1imm *a, MVEGenOneOpImmFn *fn)
124
+{
125
+ TCGv_ptr qd;
126
+ uint64_t imm;
127
+
128
+ if (!dc_isar_feature(aa32_mve, 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;
52
+ }
135
+ }
53
+
136
+
54
+ /* For these floating point ops, the U, a and opcode bits
137
+ imm = asimd_imm_const(a->imm, a->cmode, a->op);
55
+ * together indicate the operation.
56
+ */
57
+ opcode = extract32(insn, 11, 3);
58
+ u = extract32(insn, 29, 1);
59
+ a = extract32(insn, 23, 1);
60
+ is_q = extract32(insn, 30, 1);
61
+ rm = extract32(insn, 16, 5);
62
+ rn = extract32(insn, 5, 5);
63
+ rd = extract32(insn, 0, 5);
64
+
138
+
65
+ fpopcode = opcode | (a << 3) | (u << 4);
139
+ qd = mve_qreg_ptr(a->qd);
66
+ datasize = is_q ? 128 : 64;
140
+ fn(cpu_env, qd, tcg_constant_i64(imm));
67
+ elements = datasize / 16;
141
+ tcg_temp_free_ptr(qd);
68
+
142
+ mve_update_eci(s);
69
+ fpst = get_fpstatus_ptr(true);
143
+ return true;
70
+
71
+ for (pass = 0; pass < elements; pass++) {
72
+ TCGv_i32 tcg_op1 = tcg_temp_new_i32();
73
+ TCGv_i32 tcg_op2 = tcg_temp_new_i32();
74
+ TCGv_i32 tcg_res = tcg_temp_new_i32();
75
+
76
+ read_vec_element_i32(s, tcg_op1, rn, pass, MO_16);
77
+ read_vec_element_i32(s, tcg_op2, rm, pass, MO_16);
78
+
79
+ switch (fpopcode) {
80
+ default:
81
+ fprintf(stderr, "%s: insn %#04x, fpop %#2x @ %#" PRIx64 "\n",
82
+ __func__, insn, fpopcode, s->pc);
83
+ g_assert_not_reached();
84
+ }
85
+
86
+ write_vec_element_i32(s, tcg_res, rd, pass, MO_16);
87
+ tcg_temp_free_i32(tcg_res);
88
+ tcg_temp_free_i32(tcg_op1);
89
+ tcg_temp_free_i32(tcg_op2);
90
+ }
91
+
92
+ tcg_temp_free_ptr(fpst);
93
+
94
+ clear_vec_high(s, is_q, rd);
95
+}
144
+}
96
+
145
+
97
static void handle_2misc_widening(DisasContext *s, int opcode, bool is_q,
146
+static bool trans_Vimm_1r(DisasContext *s, arg_1imm *a)
98
int size, int rn, int rd)
147
+{
99
{
148
+ /* Handle decode of cmode/op here between VORR/VBIC/VMOV */
100
@@ -XXX,XX +XXX,XX @@ static const AArch64DecodeTable data_proc_simd[] = {
149
+ MVEGenOneOpImmFn *fn;
101
{ 0xce000000, 0xff808000, disas_crypto_four_reg },
150
+
102
{ 0xce800000, 0xffe00000, disas_crypto_xar },
151
+ if ((a->cmode & 1) && a->cmode < 12) {
103
{ 0xce408000, 0xffe0c000, disas_crypto_three_reg_imm2 },
152
+ if (a->op) {
104
+ { 0x0e400400, 0x9f60c400, disas_simd_three_reg_same_fp16 },
153
+ /*
105
{ 0x00000000, 0x00000000, NULL }
154
+ * For op=1, the immediate will be inverted by asimd_imm_const(),
106
};
155
+ * so the VBIC becomes a logical AND operation.
107
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
+}
108
--
171
--
109
2.16.2
172
2.20.1
110
173
111
174
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
Implement the MVE shift-vector-left-by-immediate insns VSHL, VQSHL
2
2
and VQSHLU.
3
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
3
4
The size-and-immediate encoding here is the same as Neon, and we
5
handle it the same way neon-dp.decode does.
6
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20180227143852.11175-26-alex.bennee@linaro.org
9
Message-id: 20210628135835.6690-8-peter.maydell@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
10
---
8
target/arm/helper-a64.h | 1 +
11
target/arm/helper-mve.h | 16 +++++++++++
9
target/arm/helper-a64.c | 13 +++++++++++++
12
target/arm/mve.decode | 23 +++++++++++++++
10
target/arm/translate-a64.c | 5 +++++
13
target/arm/mve_helper.c | 57 ++++++++++++++++++++++++++++++++++++++
11
3 files changed, 19 insertions(+)
14
target/arm/translate-mve.c | 51 ++++++++++++++++++++++++++++++++++
12
15
4 files changed, 147 insertions(+)
13
diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h
16
14
index XXXXXXX..XXXXXXX 100644
17
diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h
15
--- a/target/arm/helper-a64.h
18
index XXXXXXX..XXXXXXX 100644
16
+++ b/target/arm/helper-a64.h
19
--- a/target/arm/helper-mve.h
17
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_2(advsimd_rinth_exact, f16, f16, ptr)
20
+++ b/target/arm/helper-mve.h
18
DEF_HELPER_2(advsimd_rinth, f16, f16, ptr)
21
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vaddvuw, TCG_CALL_NO_WG, i32, env, ptr, i32)
19
DEF_HELPER_2(advsimd_f16tosinth, i32, f16, ptr)
22
DEF_HELPER_FLAGS_3(mve_vmovi, TCG_CALL_NO_WG, void, env, ptr, i64)
20
DEF_HELPER_2(advsimd_f16touinth, i32, f16, ptr)
23
DEF_HELPER_FLAGS_3(mve_vandi, TCG_CALL_NO_WG, void, env, ptr, i64)
21
+DEF_HELPER_2(sqrt_f16, f16, f16, ptr)
24
DEF_HELPER_FLAGS_3(mve_vorri, TCG_CALL_NO_WG, void, env, ptr, i64)
22
diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c
25
+
23
index XXXXXXX..XXXXXXX 100644
26
+DEF_HELPER_FLAGS_4(mve_vshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
24
--- a/target/arm/helper-a64.c
27
+DEF_HELPER_FLAGS_4(mve_vshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
25
+++ b/target/arm/helper-a64.c
28
+DEF_HELPER_FLAGS_4(mve_vshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
26
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_f16touinth)(float16 a, void *fpstp)
29
+
30
+DEF_HELPER_FLAGS_4(mve_vqshli_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
31
+DEF_HELPER_FLAGS_4(mve_vqshli_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
32
+DEF_HELPER_FLAGS_4(mve_vqshli_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
33
+
34
+DEF_HELPER_FLAGS_4(mve_vqshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
35
+DEF_HELPER_FLAGS_4(mve_vqshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
36
+DEF_HELPER_FLAGS_4(mve_vqshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
37
+
38
+DEF_HELPER_FLAGS_4(mve_vqshlui_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
39
+DEF_HELPER_FLAGS_4(mve_vqshlui_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
40
+DEF_HELPER_FLAGS_4(mve_vqshlui_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
41
diff --git a/target/arm/mve.decode b/target/arm/mve.decode
42
index XXXXXXX..XXXXXXX 100644
43
--- a/target/arm/mve.decode
44
+++ b/target/arm/mve.decode
45
@@ -XXX,XX +XXX,XX @@
46
&2op qd qm qn size
47
&2scalar qd qn rm size
48
&1imm qd imm cmode op
49
+&2shift qd qm shift size
50
51
@vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0
52
# Note that both Rn and Qd are 3 bits only (no D bit)
53
@@ -XXX,XX +XXX,XX @@
54
@2scalar .... .... .. size:2 .... .... .... .... rm:4 &2scalar qd=%qd qn=%qn
55
@2scalar_nosz .... .... .... .... .... .... .... rm:4 &2scalar qd=%qd qn=%qn
56
57
+@2_shl_b .... .... .. 001 shift:3 .... .... .... .... &2shift qd=%qd qm=%qm size=0
58
+@2_shl_h .... .... .. 01 shift:4 .... .... .... .... &2shift qd=%qd qm=%qm size=1
59
+@2_shl_w .... .... .. 1 shift:5 .... .... .... .... &2shift qd=%qd qm=%qm size=2
60
+
61
# Vector loads and stores
62
63
# Widening loads and narrowing stores:
64
@@ -XXX,XX +XXX,XX @@ VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13
65
# So we have a single decode line and check the cmode/op in the
66
# trans function.
67
Vimm_1r 111 . 1111 1 . 00 0 ... ... 0 .... 0 1 . 1 .... @1imm
68
+
69
+# Shifts by immediate
70
+
71
+VSHLI 111 0 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_b
72
+VSHLI 111 0 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_h
73
+VSHLI 111 0 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_w
74
+
75
+VQSHLI_S 111 0 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_b
76
+VQSHLI_S 111 0 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_h
77
+VQSHLI_S 111 0 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_w
78
+
79
+VQSHLI_U 111 1 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_b
80
+VQSHLI_U 111 1 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_h
81
+VQSHLI_U 111 1 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_w
82
+
83
+VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_b
84
+VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_h
85
+VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_w
86
diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c
87
index XXXXXXX..XXXXXXX 100644
88
--- a/target/arm/mve_helper.c
89
+++ b/target/arm/mve_helper.c
90
@@ -XXX,XX +XXX,XX @@ DO_2OP_SAT(vqsubsw, 4, int32_t, DO_SQSUB_W)
91
WRAP_QRSHL_HELPER(do_sqrshl_bhs, N, M, true, satp)
92
#define DO_UQRSHL_OP(N, M, satp) \
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)
27
}
171
}
28
return float16_to_uint16(a, fpst);
172
return do_1imm(s, a, fn);
29
}
173
}
30
+
174
+
31
+/*
175
+static bool do_2shift(DisasContext *s, arg_2shift *a, MVEGenTwoOpShiftFn fn,
32
+ * Square Root and Reciprocal square root
176
+ bool negateshift)
33
+ */
34
+
35
+float16 HELPER(sqrt_f16)(float16 a, void *fpstp)
36
+{
177
+{
37
+ float_status *s = fpstp;
178
+ TCGv_ptr qd, qm;
38
+
179
+ int shift = a->shift;
39
+ return float16_sqrt(a, s);
180
+
181
+ if (!dc_isar_feature(aa32_mve, s) ||
182
+ !mve_check_qreg_bank(s, a->qd | a->qm) ||
183
+ !fn) {
184
+ return false;
185
+ }
186
+ if (!mve_eci_check(s) || !vfp_access_check(s)) {
187
+ return true;
188
+ }
189
+
190
+ /*
191
+ * When we handle a right shift insn using a left-shift helper
192
+ * which permits a negative shift count to indicate a right-shift,
193
+ * we must negate the shift count.
194
+ */
195
+ if (negateshift) {
196
+ shift = -shift;
197
+ }
198
+
199
+ qd = mve_qreg_ptr(a->qd);
200
+ qm = mve_qreg_ptr(a->qm);
201
+ fn(cpu_env, qd, qm, tcg_constant_i32(shift));
202
+ tcg_temp_free_ptr(qd);
203
+ tcg_temp_free_ptr(qm);
204
+ mve_update_eci(s);
205
+ return true;
40
+}
206
+}
41
+
207
+
42
+
208
+#define DO_2SHIFT(INSN, FN, NEGATESHIFT) \
43
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
209
+ static bool trans_##INSN(DisasContext *s, arg_2shift *a) \
44
index XXXXXXX..XXXXXXX 100644
210
+ { \
45
--- a/target/arm/translate-a64.c
211
+ static MVEGenTwoOpShiftFn * const fns[] = { \
46
+++ b/target/arm/translate-a64.c
212
+ gen_helper_mve_##FN##b, \
47
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
213
+ gen_helper_mve_##FN##h, \
48
case 0x6f: /* FNEG */
214
+ gen_helper_mve_##FN##w, \
49
need_fpst = false;
215
+ NULL, \
50
break;
216
+ }; \
51
+ case 0x7f: /* FSQRT (vector) */
217
+ return do_2shift(s, a, fns[a->size], NEGATESHIFT); \
52
+ break;
218
+ }
53
default:
219
+
54
fprintf(stderr, "%s: insn %#04x fpop %#2x\n", __func__, insn, fpop);
220
+DO_2SHIFT(VSHLI, vshli_u, false)
55
g_assert_not_reached();
221
+DO_2SHIFT(VQSHLI_S, vqshli_s, false)
56
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
222
+DO_2SHIFT(VQSHLI_U, vqshli_u, false)
57
case 0x6f: /* FNEG */
223
+DO_2SHIFT(VQSHLUI, vqshlui_s, false)
58
tcg_gen_xori_i32(tcg_res, tcg_op, 0x8000);
59
break;
60
+ case 0x7f: /* FSQRT */
61
+ gen_helper_sqrt_f16(tcg_res, tcg_op, tcg_fpstatus);
62
+ break;
63
default:
64
g_assert_not_reached();
65
}
66
--
224
--
67
2.16.2
225
2.20.1
68
226
69
227
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
Implement the MVE vector shift right by immediate insns VSHRI and
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.
2
5
3
These use the generic float16_compare functionality which in turn uses
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
the common float_compare code from the softfloat re-factor.
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20210628135835.6690-9-peter.maydell@linaro.org
9
---
10
target/arm/helper-mve.h | 12 ++++++++++++
11
target/arm/translate.h | 20 ++++++++++++++++++++
12
target/arm/mve.decode | 28 ++++++++++++++++++++++++++++
13
target/arm/mve_helper.c | 7 +++++++
14
target/arm/translate-mve.c | 5 +++++
15
target/arm/translate-neon.c | 18 ------------------
16
6 files changed, 72 insertions(+), 18 deletions(-)
5
17
6
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
18
diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20180227143852.11175-11-alex.bennee@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/helper-a64.h | 5 +++++
12
target/arm/helper-a64.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++
13
target/arm/translate-a64.c | 15 ++++++++++++++
14
3 files changed, 69 insertions(+)
15
16
diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h
17
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/helper-a64.h
20
--- a/target/arm/helper-mve.h
19
+++ b/target/arm/helper-a64.h
21
+++ b/target/arm/helper-mve.h
20
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(advsimd_addh, f16, f16, f16, ptr)
22
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vmovi, TCG_CALL_NO_WG, void, env, ptr, i64)
21
DEF_HELPER_3(advsimd_subh, f16, f16, f16, ptr)
23
DEF_HELPER_FLAGS_3(mve_vandi, TCG_CALL_NO_WG, void, env, ptr, i64)
22
DEF_HELPER_3(advsimd_mulh, f16, f16, f16, ptr)
24
DEF_HELPER_FLAGS_3(mve_vorri, TCG_CALL_NO_WG, void, env, ptr, i64)
23
DEF_HELPER_3(advsimd_divh, f16, f16, f16, ptr)
25
24
+DEF_HELPER_3(advsimd_ceq_f16, i32, f16, f16, ptr)
26
+DEF_HELPER_FLAGS_4(mve_vshli_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
25
+DEF_HELPER_3(advsimd_cge_f16, i32, f16, f16, ptr)
27
+DEF_HELPER_FLAGS_4(mve_vshli_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
26
+DEF_HELPER_3(advsimd_cgt_f16, i32, f16, f16, ptr)
28
+DEF_HELPER_FLAGS_4(mve_vshli_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
27
+DEF_HELPER_3(advsimd_acge_f16, i32, f16, f16, ptr)
29
+
28
+DEF_HELPER_3(advsimd_acgt_f16, i32, f16, f16, ptr)
30
DEF_HELPER_FLAGS_4(mve_vshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
29
diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c
31
DEF_HELPER_FLAGS_4(mve_vshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
32
DEF_HELPER_FLAGS_4(mve_vshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
33
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
34
DEF_HELPER_FLAGS_4(mve_vqshlui_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
35
DEF_HELPER_FLAGS_4(mve_vqshlui_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
36
DEF_HELPER_FLAGS_4(mve_vqshlui_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
37
+
38
+DEF_HELPER_FLAGS_4(mve_vrshli_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
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
+
42
+DEF_HELPER_FLAGS_4(mve_vrshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
43
+DEF_HELPER_FLAGS_4(mve_vrshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
44
+DEF_HELPER_FLAGS_4(mve_vrshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
45
diff --git a/target/arm/translate.h b/target/arm/translate.h
30
index XXXXXXX..XXXXXXX 100644
46
index XXXXXXX..XXXXXXX 100644
31
--- a/target/arm/helper-a64.c
47
--- a/target/arm/translate.h
32
+++ b/target/arm/helper-a64.c
48
+++ b/target/arm/translate.h
33
@@ -XXX,XX +XXX,XX @@ ADVSIMD_HALFOP(min)
49
@@ -XXX,XX +XXX,XX @@ static inline int times_2_plus_1(DisasContext *s, int x)
34
ADVSIMD_HALFOP(max)
50
return x * 2 + 1;
35
ADVSIMD_HALFOP(minnum)
51
}
36
ADVSIMD_HALFOP(maxnum)
52
37
+
53
+static inline int rsub_64(DisasContext *s, int x)
38
+/*
39
+ * Floating point comparisons produce an integer result. Softfloat
40
+ * routines return float_relation types which we convert to the 0/-1
41
+ * Neon requires.
42
+ */
43
+
44
+#define ADVSIMD_CMPRES(test) (test) ? 0xffff : 0
45
+
46
+uint32_t HELPER(advsimd_ceq_f16)(float16 a, float16 b, void *fpstp)
47
+{
54
+{
48
+ float_status *fpst = fpstp;
55
+ return 64 - x;
49
+ int compare = float16_compare_quiet(a, b, fpst);
50
+ return ADVSIMD_CMPRES(compare == float_relation_equal);
51
+}
56
+}
52
+
57
+
53
+uint32_t HELPER(advsimd_cge_f16)(float16 a, float16 b, void *fpstp)
58
+static inline int rsub_32(DisasContext *s, int x)
54
+{
59
+{
55
+ float_status *fpst = fpstp;
60
+ return 32 - x;
56
+ int compare = float16_compare(a, b, fpst);
57
+ return ADVSIMD_CMPRES(compare == float_relation_greater ||
58
+ compare == float_relation_equal);
59
+}
61
+}
60
+
62
+
61
+uint32_t HELPER(advsimd_cgt_f16)(float16 a, float16 b, void *fpstp)
63
+static inline int rsub_16(DisasContext *s, int x)
62
+{
64
+{
63
+ float_status *fpst = fpstp;
65
+ return 16 - x;
64
+ int compare = float16_compare(a, b, fpst);
65
+ return ADVSIMD_CMPRES(compare == float_relation_greater);
66
+}
66
+}
67
+
67
+
68
+uint32_t HELPER(advsimd_acge_f16)(float16 a, float16 b, void *fpstp)
68
+static inline int rsub_8(DisasContext *s, int x)
69
+{
69
+{
70
+ float_status *fpst = fpstp;
70
+ return 8 - x;
71
+ float16 f0 = float16_abs(a);
72
+ float16 f1 = float16_abs(b);
73
+ int compare = float16_compare(f0, f1, fpst);
74
+ return ADVSIMD_CMPRES(compare == float_relation_greater ||
75
+ compare == float_relation_equal);
76
+}
71
+}
77
+
72
+
78
+uint32_t HELPER(advsimd_acgt_f16)(float16 a, float16 b, void *fpstp)
73
static inline int arm_dc_feature(DisasContext *dc, int feature)
79
+{
74
{
80
+ float_status *fpst = fpstp;
75
return (dc->features & (1ULL << feature)) != 0;
81
+ float16 f0 = float16_abs(a);
76
diff --git a/target/arm/mve.decode b/target/arm/mve.decode
82
+ float16 f1 = float16_abs(b);
83
+ int compare = float16_compare(f0, f1, fpst);
84
+ return ADVSIMD_CMPRES(compare == float_relation_greater);
85
+}
86
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
87
index XXXXXXX..XXXXXXX 100644
77
index XXXXXXX..XXXXXXX 100644
88
--- a/target/arm/translate-a64.c
78
--- a/target/arm/mve.decode
89
+++ b/target/arm/translate-a64.c
79
+++ b/target/arm/mve.decode
90
@@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn)
80
@@ -XXX,XX +XXX,XX @@
91
case 0x2: /* FADD */
81
@2_shl_h .... .... .. 01 shift:4 .... .... .... .... &2shift qd=%qd qm=%qm size=1
92
gen_helper_advsimd_addh(tcg_res, tcg_op1, tcg_op2, fpst);
82
@2_shl_w .... .... .. 1 shift:5 .... .... .... .... &2shift qd=%qd qm=%qm size=2
93
break;
83
94
+ case 0x4: /* FCMEQ */
84
+# Right shifts are encoded as N - shift, where N is the element size in bits.
95
+ gen_helper_advsimd_ceq_f16(tcg_res, tcg_op1, tcg_op2, fpst);
85
+%rshift_i5 16:5 !function=rsub_32
96
+ break;
86
+%rshift_i4 16:4 !function=rsub_16
97
case 0x6: /* FMAX */
87
+%rshift_i3 16:3 !function=rsub_8
98
gen_helper_advsimd_maxh(tcg_res, tcg_op1, tcg_op2, fpst);
88
+
99
break;
89
+@2_shr_b .... .... .. 001 ... .... .... .... .... &2shift qd=%qd qm=%qm \
100
@@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn)
90
+ size=0 shift=%rshift_i3
101
case 0x13: /* FMUL */
91
+@2_shr_h .... .... .. 01 .... .... .... .... .... &2shift qd=%qd qm=%qm \
102
gen_helper_advsimd_mulh(tcg_res, tcg_op1, tcg_op2, fpst);
92
+ size=1 shift=%rshift_i4
103
break;
93
+@2_shr_w .... .... .. 1 ..... .... .... .... .... &2shift qd=%qd qm=%qm \
104
+ case 0x14: /* FCMGE */
94
+ size=2 shift=%rshift_i5
105
+ gen_helper_advsimd_cge_f16(tcg_res, tcg_op1, tcg_op2, fpst);
95
+
106
+ break;
96
# Vector loads and stores
107
+ case 0x15: /* FACGE */
97
108
+ gen_helper_advsimd_acge_f16(tcg_res, tcg_op1, tcg_op2, fpst);
98
# Widening loads and narrowing stores:
109
+ break;
99
@@ -XXX,XX +XXX,XX @@ VQSHLI_U 111 1 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_w
110
case 0x17: /* FDIV */
100
VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_b
111
gen_helper_advsimd_divh(tcg_res, tcg_op1, tcg_op2, fpst);
101
VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_h
112
break;
102
VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_w
113
@@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn)
103
+
114
gen_helper_advsimd_subh(tcg_res, tcg_op1, tcg_op2, fpst);
104
+VSHRI_S 111 0 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_b
115
tcg_gen_andi_i32(tcg_res, tcg_res, 0x7fff);
105
+VSHRI_S 111 0 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_h
116
break;
106
+VSHRI_S 111 0 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_w
117
+ case 0x1c: /* FCMGT */
107
+
118
+ gen_helper_advsimd_cgt_f16(tcg_res, tcg_op1, tcg_op2, fpst);
108
+VSHRI_U 111 1 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_b
119
+ break;
109
+VSHRI_U 111 1 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_h
120
+ case 0x1d: /* FACGT */
110
+VSHRI_U 111 1 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_w
121
+ gen_helper_advsimd_acgt_f16(tcg_res, tcg_op1, tcg_op2, fpst);
111
+
122
+ break;
112
+VRSHRI_S 111 0 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_b
123
default:
113
+VRSHRI_S 111 0 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_h
124
fprintf(stderr, "%s: insn %#04x, fpop %#2x @ %#" PRIx64 "\n",
114
+VRSHRI_S 111 0 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_w
125
__func__, insn, fpopcode, s->pc);
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 */
126
--
186
--
127
2.16.2
187
2.20.1
128
188
129
189
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
Implement the MVE VHLL (vector shift left long) insn. This has two
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.
2
5
3
This adds the full range of half-precision floating point to integral
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
instructions.
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20210628135835.6690-10-peter.maydell@linaro.org
9
---
10
target/arm/helper-mve.h | 9 +++++++
11
target/arm/mve.decode | 53 +++++++++++++++++++++++++++++++++++---
12
target/arm/mve_helper.c | 32 +++++++++++++++++++++++
13
target/arm/translate-mve.c | 15 +++++++++++
14
4 files changed, 105 insertions(+), 4 deletions(-)
5
15
6
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
16
diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20180227143852.11175-18-alex.bennee@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/helper-a64.h | 2 +
12
target/arm/helper-a64.c | 22 ++++++++
13
target/arm/translate-a64.c | 123 +++++++++++++++++++++++++++++++++++++++++++--
14
3 files changed, 142 insertions(+), 5 deletions(-)
15
16
diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h
17
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/helper-a64.h
18
--- a/target/arm/helper-mve.h
19
+++ b/target/arm/helper-a64.h
19
+++ b/target/arm/helper-mve.h
20
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(advsimd_maxnum2h, i32, i32, i32, ptr)
20
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vrshli_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
21
DEF_HELPER_3(advsimd_minnum2h, i32, i32, i32, ptr)
21
DEF_HELPER_FLAGS_4(mve_vrshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
22
DEF_HELPER_3(advsimd_mulx2h, i32, i32, i32, ptr)
22
DEF_HELPER_FLAGS_4(mve_vrshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
23
DEF_HELPER_4(advsimd_muladd2h, i32, i32, i32, i32, ptr)
23
DEF_HELPER_FLAGS_4(mve_vrshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
24
+DEF_HELPER_2(advsimd_rinth_exact, f16, f16, ptr)
24
+
25
+DEF_HELPER_2(advsimd_rinth, f16, f16, ptr)
25
+DEF_HELPER_FLAGS_4(mve_vshllbsb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
26
diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c
26
+DEF_HELPER_FLAGS_4(mve_vshllbsh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
27
+DEF_HELPER_FLAGS_4(mve_vshllbub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
28
+DEF_HELPER_FLAGS_4(mve_vshllbuh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
29
+DEF_HELPER_FLAGS_4(mve_vshlltsb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
30
+DEF_HELPER_FLAGS_4(mve_vshlltsh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
31
+DEF_HELPER_FLAGS_4(mve_vshlltub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
32
+DEF_HELPER_FLAGS_4(mve_vshlltuh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
33
diff --git a/target/arm/mve.decode b/target/arm/mve.decode
27
index XXXXXXX..XXXXXXX 100644
34
index XXXXXXX..XXXXXXX 100644
28
--- a/target/arm/helper-a64.c
35
--- a/target/arm/mve.decode
29
+++ b/target/arm/helper-a64.c
36
+++ b/target/arm/mve.decode
30
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_acgt_f16)(float16 a, float16 b, void *fpstp)
37
@@ -XXX,XX +XXX,XX @@
31
int compare = float16_compare(f0, f1, fpst);
38
@2_shl_h .... .... .. 01 shift:4 .... .... .... .... &2shift qd=%qd qm=%qm size=1
32
return ADVSIMD_CMPRES(compare == float_relation_greater);
39
@2_shl_w .... .... .. 1 shift:5 .... .... .... .... &2shift qd=%qd qm=%qm size=2
33
}
40
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
34
+
48
+
35
+/* round to integral */
49
# Right shifts are encoded as N - shift, where N is the element size in bits.
36
+float16 HELPER(advsimd_rinth_exact)(float16 x, void *fp_status)
50
%rshift_i5 16:5 !function=rsub_32
51
%rshift_i4 16:4 !function=rsub_16
52
@@ -XXX,XX +XXX,XX @@ VADD 1110 1111 0 . .. ... 0 ... 0 1000 . 1 . 0 ... 0 @2op
53
VSUB 1111 1111 0 . .. ... 0 ... 0 1000 . 1 . 0 ... 0 @2op
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
37
+{
60
+{
38
+ return float16_round_to_int(x, fp_status);
61
+ VSHLL_BS 111 0 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_b
62
+ VSHLL_BS 111 0 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_h
63
64
-VRMULH_S 111 0 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op
65
-VRMULH_U 111 1 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op
66
+ VMULH_S 111 0 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op
39
+}
67
+}
40
+
68
+
41
+float16 HELPER(advsimd_rinth)(float16 x, void *fp_status)
42
+{
69
+{
43
+ int old_flags = get_float_exception_flags(fp_status), new_flags;
70
+ VSHLL_BU 111 1 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_b
44
+ float16 ret;
71
+ VSHLL_BU 111 1 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_h
45
+
72
+
46
+ ret = float16_round_to_int(x, fp_status);
73
+ VMULH_U 111 1 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op
74
+}
47
+
75
+
48
+ /* Suppress any inexact exceptions the conversion produced */
76
+{
49
+ if (!(old_flags & float_flag_inexact)) {
77
+ VSHLL_TS 111 0 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_b
50
+ new_flags = get_float_exception_flags(fp_status);
78
+ VSHLL_TS 111 0 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_h
51
+ set_float_exception_flags(new_flags & ~float_flag_inexact, fp_status);
79
+
80
+ VRMULH_S 111 0 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op
81
+}
82
+
83
+{
84
+ VSHLL_TU 111 1 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_b
85
+ VSHLL_TU 111 1 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_h
86
+
87
+ VRMULH_U 111 1 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op
88
+}
89
90
VMAX_S 111 0 1111 0 . .. ... 0 ... 0 0110 . 1 . 0 ... 0 @2op
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
+
97
+# VSHLL T1 encoding; the T2 VSHLL encoding is elsewhere in this file
98
+VSHLL_BS 111 0 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_b
99
+VSHLL_BS 111 0 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_h
100
+
101
+VSHLL_BU 111 1 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_b
102
+VSHLL_BU 111 1 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_h
103
+
104
+VSHLL_TS 111 0 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_b
105
+VSHLL_TS 111 0 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_h
106
+
107
+VSHLL_TU 111 1 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_b
108
+VSHLL_TU 111 1 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_h
109
diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c
110
index XXXXXXX..XXXXXXX 100644
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); \
52
+ }
139
+ }
53
+
140
+
54
+ return ret;
141
+#define DO_VSHLL_ALL(OP, TOP) \
55
+}
142
+ DO_VSHLL(OP##sb, TOP, 1, int8_t, 2, int16_t) \
56
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
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
57
index XXXXXXX..XXXXXXX 100644
150
index XXXXXXX..XXXXXXX 100644
58
--- a/target/arm/translate-a64.c
151
--- a/target/arm/translate-mve.c
59
+++ b/target/arm/translate-a64.c
152
+++ b/target/arm/translate-mve.c
60
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn)
153
@@ -XXX,XX +XXX,XX @@ DO_2SHIFT(VSHRI_S, vshli_s, true)
61
*/
154
DO_2SHIFT(VSHRI_U, vshli_u, true)
62
static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
155
DO_2SHIFT(VRSHRI_S, vrshli_s, true)
63
{
156
DO_2SHIFT(VRSHRI_U, vrshli_u, true)
64
- int fpop, opcode, a;
65
+ int fpop, opcode, a, u;
66
+ int rn, rd;
67
+ bool is_q;
68
+ bool is_scalar;
69
+ bool only_in_vector = false;
70
+
157
+
71
+ int pass;
158
+#define DO_VSHLL(INSN, FN) \
72
+ TCGv_i32 tcg_rmode = NULL;
159
+ static bool trans_##INSN(DisasContext *s, arg_2shift *a) \
73
+ TCGv_ptr tcg_fpstatus = NULL;
160
+ { \
74
+ bool need_rmode = false;
161
+ static MVEGenTwoOpShiftFn * const fns[] = { \
75
+ int rmode;
162
+ gen_helper_mve_##FN##b, \
76
163
+ gen_helper_mve_##FN##h, \
77
if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) {
164
+ }; \
78
unallocated_encoding(s);
165
+ return do_2shift(s, a, fns[a->size], false); \
79
return;
80
}
81
82
- if (!fp_access_check(s)) {
83
- return;
84
- }
85
+ rd = extract32(insn, 0, 5);
86
+ rn = extract32(insn, 5, 5);
87
88
- opcode = extract32(insn, 12, 4);
89
a = extract32(insn, 23, 1);
90
+ u = extract32(insn, 29, 1);
91
+ is_scalar = extract32(insn, 28, 1);
92
+ is_q = extract32(insn, 30, 1);
93
+
94
+ opcode = extract32(insn, 12, 5);
95
fpop = deposit32(opcode, 5, 1, a);
96
+ fpop = deposit32(fpop, 6, 1, u);
97
98
switch (fpop) {
99
+ case 0x18: /* FRINTN */
100
+ need_rmode = true;
101
+ only_in_vector = true;
102
+ rmode = FPROUNDING_TIEEVEN;
103
+ break;
104
+ case 0x19: /* FRINTM */
105
+ need_rmode = true;
106
+ only_in_vector = true;
107
+ rmode = FPROUNDING_NEGINF;
108
+ break;
109
+ case 0x38: /* FRINTP */
110
+ need_rmode = true;
111
+ only_in_vector = true;
112
+ rmode = FPROUNDING_POSINF;
113
+ break;
114
+ case 0x39: /* FRINTZ */
115
+ need_rmode = true;
116
+ only_in_vector = true;
117
+ rmode = FPROUNDING_ZERO;
118
+ break;
119
+ case 0x58: /* FRINTA */
120
+ need_rmode = true;
121
+ only_in_vector = true;
122
+ rmode = FPROUNDING_TIEAWAY;
123
+ break;
124
+ case 0x59: /* FRINTX */
125
+ case 0x79: /* FRINTI */
126
+ only_in_vector = true;
127
+ /* current rounding mode */
128
+ break;
129
default:
130
fprintf(stderr, "%s: insn %#04x fpop %#2x\n", __func__, insn, fpop);
131
g_assert_not_reached();
132
}
133
134
+
135
+ /* Check additional constraints for the scalar encoding */
136
+ if (is_scalar) {
137
+ if (!is_q) {
138
+ unallocated_encoding(s);
139
+ return;
140
+ }
141
+ /* FRINTxx is only in the vector form */
142
+ if (only_in_vector) {
143
+ unallocated_encoding(s);
144
+ return;
145
+ }
146
+ }
166
+ }
147
+
167
+
148
+ if (!fp_access_check(s)) {
168
+DO_VSHLL(VSHLL_BS, vshllbs)
149
+ return;
169
+DO_VSHLL(VSHLL_BU, vshllbu)
150
+ }
170
+DO_VSHLL(VSHLL_TS, vshllts)
151
+
171
+DO_VSHLL(VSHLL_TU, vshlltu)
152
+ if (need_rmode) {
153
+ tcg_fpstatus = get_fpstatus_ptr(true);
154
+ }
155
+
156
+ if (need_rmode) {
157
+ tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rmode));
158
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus);
159
+ }
160
+
161
+ if (is_scalar) {
162
+ /* no operations yet */
163
+ } else {
164
+ for (pass = 0; pass < (is_q ? 8 : 4); pass++) {
165
+ TCGv_i32 tcg_op = tcg_temp_new_i32();
166
+ TCGv_i32 tcg_res = tcg_temp_new_i32();
167
+
168
+ read_vec_element_i32(s, tcg_op, rn, pass, MO_16);
169
+
170
+ switch (fpop) {
171
+ case 0x18: /* FRINTN */
172
+ case 0x19: /* FRINTM */
173
+ case 0x38: /* FRINTP */
174
+ case 0x39: /* FRINTZ */
175
+ case 0x58: /* FRINTA */
176
+ case 0x79: /* FRINTI */
177
+ gen_helper_advsimd_rinth(tcg_res, tcg_op, tcg_fpstatus);
178
+ break;
179
+ case 0x59: /* FRINTX */
180
+ gen_helper_advsimd_rinth_exact(tcg_res, tcg_op, tcg_fpstatus);
181
+ break;
182
+ default:
183
+ g_assert_not_reached();
184
+ }
185
+
186
+ write_vec_element_i32(s, tcg_res, rd, pass, MO_16);
187
+
188
+ tcg_temp_free_i32(tcg_res);
189
+ tcg_temp_free_i32(tcg_op);
190
+ }
191
+
192
+ clear_vec_high(s, is_q, rd);
193
+ }
194
+
195
+ if (tcg_rmode) {
196
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus);
197
+ tcg_temp_free_i32(tcg_rmode);
198
+ }
199
+
200
+ if (tcg_fpstatus) {
201
+ tcg_temp_free_ptr(tcg_fpstatus);
202
+ }
203
}
204
205
/* AdvSIMD scalar x indexed element
206
--
172
--
207
2.16.2
173
2.20.1
208
174
209
175
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
Implement the MVE VSRI and VSLI insns, which perform a
2
shift-and-insert operation.
2
3
3
Much like recpe the ARM ARM has simplified the pseudo code for the
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
calculation which is done on a fixed point 9 bit integer maths. So
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
while adding f16 we can also clean this up to be a little less heavy
6
Message-id: 20210628135835.6690-11-peter.maydell@linaro.org
6
on the floating point and just return the fractional part and leave
7
---
7
the calle's to do the final packing of the result.
8
target/arm/helper-mve.h | 8 ++++++++
9
target/arm/mve.decode | 9 ++++++++
10
target/arm/mve_helper.c | 42 ++++++++++++++++++++++++++++++++++++++
11
target/arm/translate-mve.c | 3 +++
12
4 files changed, 62 insertions(+)
8
13
9
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
14
diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20180227143852.11175-27-alex.bennee@linaro.org
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
14
target/arm/helper.h | 1 +
15
target/arm/helper.c | 221 ++++++++++++++++++++++++----------------------------
16
2 files changed, 104 insertions(+), 118 deletions(-)
17
18
diff --git a/target/arm/helper.h b/target/arm/helper.h
19
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/helper.h
16
--- a/target/arm/helper-mve.h
21
+++ b/target/arm/helper.h
17
+++ b/target/arm/helper-mve.h
22
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(rsqrts_f32, f32, f32, f32, env)
18
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vshlltsb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
23
DEF_HELPER_FLAGS_2(recpe_f16, TCG_CALL_NO_RWG, f16, f16, ptr)
19
DEF_HELPER_FLAGS_4(mve_vshlltsh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
24
DEF_HELPER_FLAGS_2(recpe_f32, TCG_CALL_NO_RWG, f32, f32, ptr)
20
DEF_HELPER_FLAGS_4(mve_vshlltub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
25
DEF_HELPER_FLAGS_2(recpe_f64, TCG_CALL_NO_RWG, f64, f64, ptr)
21
DEF_HELPER_FLAGS_4(mve_vshlltuh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
26
+DEF_HELPER_FLAGS_2(rsqrte_f16, TCG_CALL_NO_RWG, f16, f16, ptr)
22
+
27
DEF_HELPER_FLAGS_2(rsqrte_f32, TCG_CALL_NO_RWG, f32, f32, ptr)
23
+DEF_HELPER_FLAGS_4(mve_vsrib, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
28
DEF_HELPER_FLAGS_2(rsqrte_f64, TCG_CALL_NO_RWG, f64, f64, ptr)
24
+DEF_HELPER_FLAGS_4(mve_vsrih, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
29
DEF_HELPER_2(recpe_u32, i32, i32, ptr)
25
+DEF_HELPER_FLAGS_4(mve_vsriw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
30
diff --git a/target/arm/helper.c b/target/arm/helper.c
26
+
27
+DEF_HELPER_FLAGS_4(mve_vslib, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
28
+DEF_HELPER_FLAGS_4(mve_vslih, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
29
+DEF_HELPER_FLAGS_4(mve_vsliw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
30
diff --git a/target/arm/mve.decode b/target/arm/mve.decode
31
index XXXXXXX..XXXXXXX 100644
31
index XXXXXXX..XXXXXXX 100644
32
--- a/target/arm/helper.c
32
--- a/target/arm/mve.decode
33
+++ b/target/arm/helper.c
33
+++ b/target/arm/mve.decode
34
@@ -XXX,XX +XXX,XX @@ float64 HELPER(recpe_f64)(float64 input, void *fpstp)
34
@@ -XXX,XX +XXX,XX @@ VSHLL_TS 111 0 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_h
35
/* The algorithm that must be used to calculate the estimate
35
36
* is specified by the ARM ARM.
36
VSHLL_TU 111 1 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_b
37
*/
37
VSHLL_TU 111 1 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_h
38
-static float64 recip_sqrt_estimate(float64 a, float_status *real_fp_status)
39
+
38
+
40
+static int do_recip_sqrt_estimate(int a)
39
+# Shift-and-insert
41
{
40
+VSRI 111 1 1111 1 . ... ... ... 0 0100 0 1 . 1 ... 0 @2_shr_b
42
- /* These calculations mustn't set any fp exception flags,
41
+VSRI 111 1 1111 1 . ... ... ... 0 0100 0 1 . 1 ... 0 @2_shr_h
43
- * so we use a local copy of the fp_status.
42
+VSRI 111 1 1111 1 . ... ... ... 0 0100 0 1 . 1 ... 0 @2_shr_w
44
- */
45
- float_status dummy_status = *real_fp_status;
46
- float_status *s = &dummy_status;
47
- float64 q;
48
- int64_t q_int;
49
+ int b, estimate;
50
51
- if (float64_lt(a, float64_half, s)) {
52
- /* range 0.25 <= a < 0.5 */
53
-
54
- /* a in units of 1/512 rounded down */
55
- /* q0 = (int)(a * 512.0); */
56
- q = float64_mul(float64_512, a, s);
57
- q_int = float64_to_int64_round_to_zero(q, s);
58
-
59
- /* reciprocal root r */
60
- /* r = 1.0 / sqrt(((double)q0 + 0.5) / 512.0); */
61
- q = int64_to_float64(q_int, s);
62
- q = float64_add(q, float64_half, s);
63
- q = float64_div(q, float64_512, s);
64
- q = float64_sqrt(q, s);
65
- q = float64_div(float64_one, q, s);
66
+ assert(128 <= a && a < 512);
67
+ if (a < 256) {
68
+ a = a * 2 + 1;
69
} else {
70
- /* range 0.5 <= a < 1.0 */
71
-
72
- /* a in units of 1/256 rounded down */
73
- /* q1 = (int)(a * 256.0); */
74
- q = float64_mul(float64_256, a, s);
75
- int64_t q_int = float64_to_int64_round_to_zero(q, s);
76
-
77
- /* reciprocal root r */
78
- /* r = 1.0 /sqrt(((double)q1 + 0.5) / 256); */
79
- q = int64_to_float64(q_int, s);
80
- q = float64_add(q, float64_half, s);
81
- q = float64_div(q, float64_256, s);
82
- q = float64_sqrt(q, s);
83
- q = float64_div(float64_one, q, s);
84
+ a = (a >> 1) << 1;
85
+ a = (a + 1) * 2;
86
}
87
- /* r in units of 1/256 rounded to nearest */
88
- /* s = (int)(256.0 * r + 0.5); */
89
+ b = 512;
90
+ while (a * (b + 1) * (b + 1) < (1 << 28)) {
91
+ b += 1;
92
+ }
93
+ estimate = (b + 1) / 2;
94
+ assert(256 <= estimate && estimate < 512);
95
96
- q = float64_mul(q, float64_256,s );
97
- q = float64_add(q, float64_half, s);
98
- q_int = float64_to_int64_round_to_zero(q, s);
99
+ return estimate;
100
+}
101
102
- /* return (double)s / 256.0;*/
103
- return float64_div(int64_to_float64(q_int, s), float64_256, s);
104
+
43
+
105
+static uint64_t recip_sqrt_estimate(int *exp , int exp_off, uint64_t frac)
44
+VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_b
106
+{
45
+VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_h
107
+ int estimate;
46
+VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_w
108
+ uint32_t scaled;
47
diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c
109
+
48
index XXXXXXX..XXXXXXX 100644
110
+ if (*exp == 0) {
49
--- a/target/arm/mve_helper.c
111
+ while (extract64(frac, 51, 1) == 0) {
50
+++ b/target/arm/mve_helper.c
112
+ frac = frac << 1;
51
@@ -XXX,XX +XXX,XX @@ DO_2SHIFT_SAT_S(vqshlui_s, DO_SUQSHL_OP)
113
+ *exp -= 1;
52
DO_2SHIFT_U(vrshli_u, DO_VRSHLU)
114
+ }
53
DO_2SHIFT_S(vrshli_s, DO_VRSHLS)
115
+ frac = extract64(frac, 0, 51) << 1;
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); \
116
+ }
83
+ }
117
+
84
+
118
+ if (*exp & 1) {
85
+#define DO_SHL(N, SHIFT) ((N) << (SHIFT))
119
+ /* scaled = UInt('01':fraction<51:45>) */
86
+#define DO_SHR(N, SHIFT) ((N) >> (SHIFT))
120
+ scaled = deposit32(1 << 7, 0, 7, extract64(frac, 45, 7));
87
+#define SHL_MASK(EBITS, SHIFT) MAKE_64BIT_MASK((SHIFT), (EBITS) - (SHIFT))
121
+ } else {
88
+#define SHR_MASK(EBITS, SHIFT) MAKE_64BIT_MASK(0, (EBITS) - (SHIFT))
122
+ /* scaled = UInt('1':fraction<51:44>) */
123
+ scaled = deposit32(1 << 8, 0, 8, extract64(frac, 44, 8));
124
+ }
125
+ estimate = do_recip_sqrt_estimate(scaled);
126
+
89
+
127
+ *exp = (exp_off - *exp) / 2;
90
+DO_2SHIFT_INSERT(vsrib, 1, DO_SHR, SHR_MASK)
128
+ return extract64(estimate, 0, 8) << 44;
91
+DO_2SHIFT_INSERT(vsrih, 2, DO_SHR, SHR_MASK)
129
+}
92
+DO_2SHIFT_INSERT(vsriw, 4, DO_SHR, SHR_MASK)
93
+DO_2SHIFT_INSERT(vslib, 1, DO_SHL, SHL_MASK)
94
+DO_2SHIFT_INSERT(vslih, 2, DO_SHL, SHL_MASK)
95
+DO_2SHIFT_INSERT(vsliw, 4, DO_SHL, SHL_MASK)
130
+
96
+
131
+float16 HELPER(rsqrte_f16)(float16 input, void *fpstp)
97
/*
132
+{
98
* Long shifts taking half-sized inputs from top or bottom of the input
133
+ float_status *s = fpstp;
99
* vector and producing a double-width result. ESIZE, TYPE are for
134
+ float16 f16 = float16_squash_input_denormal(input, s);
100
diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c
135
+ uint16_t val = float16_val(f16);
101
index XXXXXXX..XXXXXXX 100644
136
+ bool f16_sign = float16_is_neg(f16);
102
--- a/target/arm/translate-mve.c
137
+ int f16_exp = extract32(val, 10, 5);
103
+++ b/target/arm/translate-mve.c
138
+ uint16_t f16_frac = extract32(val, 0, 10);
104
@@ -XXX,XX +XXX,XX @@ DO_2SHIFT(VSHRI_U, vshli_u, true)
139
+ uint64_t f64_frac;
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)
140
+
110
+
141
+ if (float16_is_any_nan(f16)) {
111
#define DO_VSHLL(INSN, FN) \
142
+ float16 nan = f16;
112
static bool trans_##INSN(DisasContext *s, arg_2shift *a) \
143
+ if (float16_is_signaling_nan(f16, s)) {
113
{ \
144
+ float_raise(float_flag_invalid, s);
145
+ nan = float16_maybe_silence_nan(f16, s);
146
+ }
147
+ if (s->default_nan_mode) {
148
+ nan = float16_default_nan(s);
149
+ }
150
+ return nan;
151
+ } else if (float16_is_zero(f16)) {
152
+ float_raise(float_flag_divbyzero, s);
153
+ return float16_set_sign(float16_infinity, f16_sign);
154
+ } else if (f16_sign) {
155
+ float_raise(float_flag_invalid, s);
156
+ return float16_default_nan(s);
157
+ } else if (float16_is_infinity(f16)) {
158
+ return float16_zero;
159
+ }
160
+
161
+ /* Scale and normalize to a double-precision value between 0.25 and 1.0,
162
+ * preserving the parity of the exponent. */
163
+
164
+ f64_frac = ((uint64_t) f16_frac) << (52 - 10);
165
+
166
+ f64_frac = recip_sqrt_estimate(&f16_exp, 44, f64_frac);
167
+
168
+ /* result = sign : result_exp<4:0> : estimate<7:0> : Zeros(2) */
169
+ val = deposit32(0, 15, 1, f16_sign);
170
+ val = deposit32(val, 10, 5, f16_exp);
171
+ val = deposit32(val, 2, 8, extract64(f64_frac, 52 - 8, 8));
172
+ return make_float16(val);
173
}
174
175
float32 HELPER(rsqrte_f32)(float32 input, void *fpstp)
176
@@ -XXX,XX +XXX,XX @@ float32 HELPER(rsqrte_f32)(float32 input, void *fpstp)
177
float_status *s = fpstp;
178
float32 f32 = float32_squash_input_denormal(input, s);
179
uint32_t val = float32_val(f32);
180
- uint32_t f32_sbit = 0x80000000 & val;
181
- int32_t f32_exp = extract32(val, 23, 8);
182
+ uint32_t f32_sign = float32_is_neg(f32);
183
+ int f32_exp = extract32(val, 23, 8);
184
uint32_t f32_frac = extract32(val, 0, 23);
185
uint64_t f64_frac;
186
- uint64_t val64;
187
- int result_exp;
188
- float64 f64;
189
190
if (float32_is_any_nan(f32)) {
191
float32 nan = f32;
192
@@ -XXX,XX +XXX,XX @@ float32 HELPER(rsqrte_f32)(float32 input, void *fpstp)
193
* preserving the parity of the exponent. */
194
195
f64_frac = ((uint64_t) f32_frac) << 29;
196
- if (f32_exp == 0) {
197
- while (extract64(f64_frac, 51, 1) == 0) {
198
- f64_frac = f64_frac << 1;
199
- f32_exp = f32_exp-1;
200
- }
201
- f64_frac = extract64(f64_frac, 0, 51) << 1;
202
- }
203
204
- if (extract64(f32_exp, 0, 1) == 0) {
205
- f64 = make_float64(((uint64_t) f32_sbit) << 32
206
- | (0x3feULL << 52)
207
- | f64_frac);
208
- } else {
209
- f64 = make_float64(((uint64_t) f32_sbit) << 32
210
- | (0x3fdULL << 52)
211
- | f64_frac);
212
- }
213
+ f64_frac = recip_sqrt_estimate(&f32_exp, 380, f64_frac);
214
215
- result_exp = (380 - f32_exp) / 2;
216
-
217
- f64 = recip_sqrt_estimate(f64, s);
218
-
219
- val64 = float64_val(f64);
220
-
221
- val = ((result_exp & 0xff) << 23)
222
- | ((val64 >> 29) & 0x7fffff);
223
+ /* result = sign : result_exp<4:0> : estimate<7:0> : Zeros(15) */
224
+ val = deposit32(0, 31, 1, f32_sign);
225
+ val = deposit32(val, 23, 8, f32_exp);
226
+ val = deposit32(val, 15, 8, extract64(f64_frac, 52 - 8, 8));
227
return make_float32(val);
228
}
229
230
@@ -XXX,XX +XXX,XX @@ float64 HELPER(rsqrte_f64)(float64 input, void *fpstp)
231
float_status *s = fpstp;
232
float64 f64 = float64_squash_input_denormal(input, s);
233
uint64_t val = float64_val(f64);
234
- uint64_t f64_sbit = 0x8000000000000000ULL & val;
235
- int64_t f64_exp = extract64(val, 52, 11);
236
+ bool f64_sign = float64_is_neg(f64);
237
+ int f64_exp = extract64(val, 52, 11);
238
uint64_t f64_frac = extract64(val, 0, 52);
239
- int64_t result_exp;
240
- uint64_t result_frac;
241
242
if (float64_is_any_nan(f64)) {
243
float64 nan = f64;
244
@@ -XXX,XX +XXX,XX @@ float64 HELPER(rsqrte_f64)(float64 input, void *fpstp)
245
return float64_zero;
246
}
247
248
- /* Scale and normalize to a double-precision value between 0.25 and 1.0,
249
- * preserving the parity of the exponent. */
250
+ f64_frac = recip_sqrt_estimate(&f64_exp, 3068, f64_frac);
251
252
- if (f64_exp == 0) {
253
- while (extract64(f64_frac, 51, 1) == 0) {
254
- f64_frac = f64_frac << 1;
255
- f64_exp = f64_exp - 1;
256
- }
257
- f64_frac = extract64(f64_frac, 0, 51) << 1;
258
- }
259
-
260
- if (extract64(f64_exp, 0, 1) == 0) {
261
- f64 = make_float64(f64_sbit
262
- | (0x3feULL << 52)
263
- | f64_frac);
264
- } else {
265
- f64 = make_float64(f64_sbit
266
- | (0x3fdULL << 52)
267
- | f64_frac);
268
- }
269
-
270
- result_exp = (3068 - f64_exp) / 2;
271
-
272
- f64 = recip_sqrt_estimate(f64, s);
273
-
274
- result_frac = extract64(float64_val(f64), 0, 52);
275
-
276
- return make_float64(f64_sbit |
277
- ((result_exp & 0x7ff) << 52) |
278
- result_frac);
279
+ /* result = sign : result_exp<4:0> : estimate<7:0> : Zeros(44) */
280
+ val = deposit64(0, 61, 1, f64_sign);
281
+ val = deposit64(val, 52, 11, f64_exp);
282
+ val = deposit64(val, 44, 8, extract64(f64_frac, 52 - 8, 8));
283
+ return make_float64(val);
284
}
285
286
uint32_t HELPER(recpe_u32)(uint32_t a, void *fpstp)
287
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(recpe_u32)(uint32_t a, void *fpstp)
288
289
uint32_t HELPER(rsqrte_u32)(uint32_t a, void *fpstp)
290
{
291
- float_status *fpst = fpstp;
292
- float64 f64;
293
+ int estimate;
294
295
if ((a & 0xc0000000) == 0) {
296
return 0xffffffff;
297
}
298
299
- if (a & 0x80000000) {
300
- f64 = make_float64((0x3feULL << 52)
301
- | ((uint64_t)(a & 0x7fffffff) << 21));
302
- } else { /* bits 31-30 == '01' */
303
- f64 = make_float64((0x3fdULL << 52)
304
- | ((uint64_t)(a & 0x3fffffff) << 22));
305
- }
306
+ estimate = do_recip_sqrt_estimate(extract32(a, 23, 9));
307
308
- f64 = recip_sqrt_estimate(f64, fpst);
309
-
310
- return 0x80000000 | ((float64_val(f64) >> 21) & 0x7fffffff);
311
+ return deposit32(0, 23, 9, estimate);
312
}
313
314
/* VFPv4 fused multiply-accumulate */
315
--
114
--
316
2.16.2
115
2.20.1
317
116
318
117
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
Implement the MVE shift-right-and-narrow insn VSHRN and VRSHRN.
2
2
3
This covers all the floating point convert operations.
3
do_urshr() is borrowed from sve_helper.c.
4
4
5
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20180227143852.11175-19-alex.bennee@linaro.org
7
Message-id: 20210628135835.6690-12-peter.maydell@linaro.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
8
---
10
target/arm/helper-a64.h | 2 ++
9
target/arm/helper-mve.h | 10 ++++++++++
11
target/arm/helper-a64.c | 32 +++++++++++++++++
10
target/arm/mve.decode | 11 +++++++++++
12
target/arm/translate-a64.c | 85 +++++++++++++++++++++++++++++++++++++++++++++-
11
target/arm/mve_helper.c | 40 ++++++++++++++++++++++++++++++++++++++
13
3 files changed, 118 insertions(+), 1 deletion(-)
12
target/arm/translate-mve.c | 15 ++++++++++++++
13
4 files changed, 76 insertions(+)
14
14
15
diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h
15
diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h
16
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/helper-a64.h
17
--- a/target/arm/helper-mve.h
18
+++ b/target/arm/helper-a64.h
18
+++ b/target/arm/helper-mve.h
19
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(advsimd_mulx2h, i32, i32, i32, ptr)
19
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vsriw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
20
DEF_HELPER_4(advsimd_muladd2h, i32, i32, i32, i32, ptr)
20
DEF_HELPER_FLAGS_4(mve_vslib, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
21
DEF_HELPER_2(advsimd_rinth_exact, f16, f16, ptr)
21
DEF_HELPER_FLAGS_4(mve_vslih, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
22
DEF_HELPER_2(advsimd_rinth, f16, f16, ptr)
22
DEF_HELPER_FLAGS_4(mve_vsliw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
23
+DEF_HELPER_2(advsimd_f16tosinth, i32, f16, ptr)
23
+
24
+DEF_HELPER_2(advsimd_f16touinth, i32, f16, ptr)
24
+DEF_HELPER_FLAGS_4(mve_vshrnbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
25
diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c
25
+DEF_HELPER_FLAGS_4(mve_vshrnbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
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
26
index XXXXXXX..XXXXXXX 100644
34
index XXXXXXX..XXXXXXX 100644
27
--- a/target/arm/helper-a64.c
35
--- a/target/arm/mve.decode
28
+++ b/target/arm/helper-a64.c
36
+++ b/target/arm/mve.decode
29
@@ -XXX,XX +XXX,XX @@ float16 HELPER(advsimd_rinth)(float16 x, void *fp_status)
37
@@ -XXX,XX +XXX,XX @@ VSRI 111 1 1111 1 . ... ... ... 0 0100 0 1 . 1 ... 0 @2_shr_w
30
38
VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_b
31
return ret;
39
VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_h
32
}
40
VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_w
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)
33
+
60
+
34
+/*
61
+/*
35
+ * Half-precision floating point conversion functions
62
+ * Narrowing right shifts, taking a double sized input, shifting it
36
+ *
63
+ * and putting the result in either the top or bottom half of the output.
37
+ * There are a multitude of conversion functions with various
64
+ * ESIZE, TYPE are the output, and LESIZE, LTYPE the input.
38
+ * different rounding modes. This is dealt with by the calling code
39
+ * setting the mode appropriately before calling the helper.
40
+ */
65
+ */
66
+#define DO_VSHRN(OP, TOP, ESIZE, TYPE, LESIZE, LTYPE, FN) \
67
+ void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \
68
+ void *vm, uint32_t shift) \
69
+ { \
70
+ LTYPE *m = vm; \
71
+ TYPE *d = vd; \
72
+ uint16_t mask = mve_element_mask(env); \
73
+ unsigned le; \
74
+ for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \
75
+ TYPE r = FN(m[H##LESIZE(le)], shift); \
76
+ mergemask(&d[H##ESIZE(le * 2 + TOP)], r, mask); \
77
+ } \
78
+ mve_advance_vpt(env); \
79
+ }
41
+
80
+
42
+uint32_t HELPER(advsimd_f16tosinth)(float16 a, void *fpstp)
81
+#define DO_VSHRN_ALL(OP, FN) \
82
+ DO_VSHRN(OP##bb, false, 1, uint8_t, 2, uint16_t, FN) \
83
+ DO_VSHRN(OP##bh, false, 2, uint16_t, 4, uint32_t, FN) \
84
+ DO_VSHRN(OP##tb, true, 1, uint8_t, 2, uint16_t, FN) \
85
+ DO_VSHRN(OP##th, true, 2, uint16_t, 4, uint32_t, FN)
86
+
87
+static inline uint64_t do_urshr(uint64_t x, unsigned sh)
43
+{
88
+{
44
+ float_status *fpst = fpstp;
89
+ if (likely(sh < 64)) {
45
+
90
+ return (x >> sh) + ((x >> (sh - 1)) & 1);
46
+ /* Invalid if we are passed a NaN */
91
+ } else if (sh == 64) {
47
+ if (float16_is_any_nan(a)) {
92
+ return x >> 63;
48
+ float_raise(float_flag_invalid, fpst);
93
+ } else {
49
+ return 0;
94
+ return 0;
50
+ }
95
+ }
51
+ return float16_to_int16(a, fpst);
52
+}
96
+}
53
+
97
+
54
+uint32_t HELPER(advsimd_f16touinth)(float16 a, void *fpstp)
98
+DO_VSHRN_ALL(vshrn, DO_SHR)
55
+{
99
+DO_VSHRN_ALL(vrshrn, do_urshr)
56
+ float_status *fpst = fpstp;
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_VSHLL(VSHLL_BS, vshllbs)
105
DO_VSHLL(VSHLL_BU, vshllbu)
106
DO_VSHLL(VSHLL_TS, vshllts)
107
DO_VSHLL(VSHLL_TU, vshlltu)
57
+
108
+
58
+ /* Invalid if we are passed a NaN */
109
+#define DO_2SHIFT_N(INSN, FN) \
59
+ if (float16_is_any_nan(a)) {
110
+ static bool trans_##INSN(DisasContext *s, arg_2shift *a) \
60
+ float_raise(float_flag_invalid, fpst);
111
+ { \
61
+ return 0;
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); \
62
+ }
117
+ }
63
+ return float16_to_uint16(a, fpst);
64
+}
65
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
66
index XXXXXXX..XXXXXXX 100644
67
--- a/target/arm/translate-a64.c
68
+++ b/target/arm/translate-a64.c
69
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
70
only_in_vector = true;
71
/* current rounding mode */
72
break;
73
+ case 0x1a: /* FCVTNS */
74
+ need_rmode = true;
75
+ rmode = FPROUNDING_TIEEVEN;
76
+ break;
77
+ case 0x1b: /* FCVTMS */
78
+ need_rmode = true;
79
+ rmode = FPROUNDING_NEGINF;
80
+ break;
81
+ case 0x1c: /* FCVTAS */
82
+ need_rmode = true;
83
+ rmode = FPROUNDING_TIEAWAY;
84
+ break;
85
+ case 0x3a: /* FCVTPS */
86
+ need_rmode = true;
87
+ rmode = FPROUNDING_POSINF;
88
+ break;
89
+ case 0x3b: /* FCVTZS */
90
+ need_rmode = true;
91
+ rmode = FPROUNDING_ZERO;
92
+ break;
93
+ case 0x5a: /* FCVTNU */
94
+ need_rmode = true;
95
+ rmode = FPROUNDING_TIEEVEN;
96
+ break;
97
+ case 0x5b: /* FCVTMU */
98
+ need_rmode = true;
99
+ rmode = FPROUNDING_NEGINF;
100
+ break;
101
+ case 0x5c: /* FCVTAU */
102
+ need_rmode = true;
103
+ rmode = FPROUNDING_TIEAWAY;
104
+ break;
105
+ case 0x7a: /* FCVTPU */
106
+ need_rmode = true;
107
+ rmode = FPROUNDING_POSINF;
108
+ break;
109
+ case 0x7b: /* FCVTZU */
110
+ need_rmode = true;
111
+ rmode = FPROUNDING_ZERO;
112
+ break;
113
default:
114
fprintf(stderr, "%s: insn %#04x fpop %#2x\n", __func__, insn, fpop);
115
g_assert_not_reached();
116
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
117
}
118
119
if (is_scalar) {
120
- /* no operations yet */
121
+ TCGv_i32 tcg_op = tcg_temp_new_i32();
122
+ TCGv_i32 tcg_res = tcg_temp_new_i32();
123
+
118
+
124
+ read_vec_element_i32(s, tcg_op, rn, 0, MO_16);
119
+DO_2SHIFT_N(VSHRNB, vshrnb)
125
+
120
+DO_2SHIFT_N(VSHRNT, vshrnt)
126
+ switch (fpop) {
121
+DO_2SHIFT_N(VRSHRNB, vrshrnb)
127
+ case 0x1a: /* FCVTNS */
122
+DO_2SHIFT_N(VRSHRNT, vrshrnt)
128
+ case 0x1b: /* FCVTMS */
129
+ case 0x1c: /* FCVTAS */
130
+ case 0x3a: /* FCVTPS */
131
+ case 0x3b: /* FCVTZS */
132
+ gen_helper_advsimd_f16tosinth(tcg_res, tcg_op, tcg_fpstatus);
133
+ break;
134
+ case 0x5a: /* FCVTNU */
135
+ case 0x5b: /* FCVTMU */
136
+ case 0x5c: /* FCVTAU */
137
+ case 0x7a: /* FCVTPU */
138
+ case 0x7b: /* FCVTZU */
139
+ gen_helper_advsimd_f16touinth(tcg_res, tcg_op, tcg_fpstatus);
140
+ break;
141
+ default:
142
+ g_assert_not_reached();
143
+ }
144
+
145
+ /* limit any sign extension going on */
146
+ tcg_gen_andi_i32(tcg_res, tcg_res, 0xffff);
147
+ write_fp_sreg(s, rd, tcg_res);
148
+
149
+ tcg_temp_free_i32(tcg_res);
150
+ tcg_temp_free_i32(tcg_op);
151
} else {
152
for (pass = 0; pass < (is_q ? 8 : 4); pass++) {
153
TCGv_i32 tcg_op = tcg_temp_new_i32();
154
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
155
read_vec_element_i32(s, tcg_op, rn, pass, MO_16);
156
157
switch (fpop) {
158
+ case 0x1a: /* FCVTNS */
159
+ case 0x1b: /* FCVTMS */
160
+ case 0x1c: /* FCVTAS */
161
+ case 0x3a: /* FCVTPS */
162
+ case 0x3b: /* FCVTZS */
163
+ gen_helper_advsimd_f16tosinth(tcg_res, tcg_op, tcg_fpstatus);
164
+ break;
165
+ case 0x5a: /* FCVTNU */
166
+ case 0x5b: /* FCVTMU */
167
+ case 0x5c: /* FCVTAU */
168
+ case 0x7a: /* FCVTPU */
169
+ case 0x7b: /* FCVTZU */
170
+ gen_helper_advsimd_f16touinth(tcg_res, tcg_op, tcg_fpstatus);
171
+ break;
172
case 0x18: /* FRINTN */
173
case 0x19: /* FRINTM */
174
case 0x38: /* FRINTP */
175
--
123
--
176
2.16.2
124
2.20.1
177
125
178
126
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
Implement the MVE saturating shift-right-and-narrow insns
2
2
VQSHRN, VQSHRUN, VQRSHRN and VQRSHRUN.
3
We go with the localised helper.
3
4
4
do_srshr() is borrowed from sve_helper.c.
5
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
5
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20180227143852.11175-25-alex.bennee@linaro.org
8
Message-id: 20210628135835.6690-13-peter.maydell@linaro.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
9
---
10
target/arm/helper-a64.h | 1 +
10
target/arm/helper-mve.h | 30 +++++++++++
11
target/arm/helper-a64.c | 29 +++++++++++++++++++++++++++++
11
target/arm/mve.decode | 28 ++++++++++
12
target/arm/translate-a64.c | 4 ++++
12
target/arm/mve_helper.c | 104 +++++++++++++++++++++++++++++++++++++
13
3 files changed, 34 insertions(+)
13
target/arm/translate-mve.c | 12 +++++
14
14
4 files changed, 174 insertions(+)
15
diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h
15
16
index XXXXXXX..XXXXXXX 100644
16
diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h
17
--- a/target/arm/helper-a64.h
17
index XXXXXXX..XXXXXXX 100644
18
+++ b/target/arm/helper-a64.h
18
--- a/target/arm/helper-mve.h
19
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_1(neon_addlp_s16, TCG_CALL_NO_RWG_SE, i64, i64)
19
+++ b/target/arm/helper-mve.h
20
DEF_HELPER_FLAGS_1(neon_addlp_u16, TCG_CALL_NO_RWG_SE, i64, i64)
20
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vrshrnbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
21
DEF_HELPER_FLAGS_2(frecpx_f64, TCG_CALL_NO_RWG, f64, f64, ptr)
21
DEF_HELPER_FLAGS_4(mve_vrshrnbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
22
DEF_HELPER_FLAGS_2(frecpx_f32, TCG_CALL_NO_RWG, f32, f32, ptr)
22
DEF_HELPER_FLAGS_4(mve_vrshrntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
23
+DEF_HELPER_FLAGS_2(frecpx_f16, TCG_CALL_NO_RWG, f16, f16, ptr)
23
DEF_HELPER_FLAGS_4(mve_vrshrnth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
24
DEF_HELPER_FLAGS_2(fcvtx_f64_to_f32, TCG_CALL_NO_RWG, f32, f64, env)
24
+
25
DEF_HELPER_FLAGS_3(crc32_64, TCG_CALL_NO_RWG_SE, i64, i64, i64, i32)
25
+DEF_HELPER_FLAGS_4(mve_vqshrnb_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
26
DEF_HELPER_FLAGS_3(crc32c_64, TCG_CALL_NO_RWG_SE, i64, i64, i64, i32)
26
+DEF_HELPER_FLAGS_4(mve_vqshrnb_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
27
diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c
27
+DEF_HELPER_FLAGS_4(mve_vqshrnt_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
28
index XXXXXXX..XXXXXXX 100644
28
+DEF_HELPER_FLAGS_4(mve_vqshrnt_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
29
--- a/target/arm/helper-a64.c
29
+
30
+++ b/target/arm/helper-a64.c
30
+DEF_HELPER_FLAGS_4(mve_vqshrnb_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
31
@@ -XXX,XX +XXX,XX @@ uint64_t HELPER(neon_addlp_u16)(uint64_t a)
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
+
35
+DEF_HELPER_FLAGS_4(mve_vqshrunbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
36
+DEF_HELPER_FLAGS_4(mve_vqshrunbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
37
+DEF_HELPER_FLAGS_4(mve_vqshruntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
38
+DEF_HELPER_FLAGS_4(mve_vqshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
39
+
40
+DEF_HELPER_FLAGS_4(mve_vqrshrnb_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
41
+DEF_HELPER_FLAGS_4(mve_vqrshrnb_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
42
+DEF_HELPER_FLAGS_4(mve_vqrshrnt_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
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
56
--- a/target/arm/mve.decode
57
+++ b/target/arm/mve.decode
58
@@ -XXX,XX +XXX,XX @@ VRSHRNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_b
59
VRSHRNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_h
60
VRSHRNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_b
61
VRSHRNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_h
62
+
63
+VQSHRNB_S 111 0 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 0 @2_shr_b
64
+VQSHRNB_S 111 0 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 0 @2_shr_h
65
+VQSHRNT_S 111 0 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 0 @2_shr_b
66
+VQSHRNT_S 111 0 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 0 @2_shr_h
67
+VQSHRNB_U 111 1 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 0 @2_shr_b
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
}
32
}
96
}
33
97
34
/* Floating-point reciprocal exponent - see FPRecpX in ARM ARM */
98
+static inline int64_t do_srshr(int64_t x, unsigned sh)
35
+float16 HELPER(frecpx_f16)(float16 a, void *fpstp)
36
+{
99
+{
37
+ float_status *fpst = fpstp;
100
+ if (likely(sh < 64)) {
38
+ uint16_t val16, sbit;
101
+ return (x >> sh) + ((x >> (sh - 1)) & 1);
39
+ int16_t exp;
40
+
41
+ if (float16_is_any_nan(a)) {
42
+ float16 nan = a;
43
+ if (float16_is_signaling_nan(a, fpst)) {
44
+ float_raise(float_flag_invalid, fpst);
45
+ nan = float16_maybe_silence_nan(a, fpst);
46
+ }
47
+ if (fpst->default_nan_mode) {
48
+ nan = float16_default_nan(fpst);
49
+ }
50
+ return nan;
51
+ }
52
+
53
+ val16 = float16_val(a);
54
+ sbit = 0x8000 & val16;
55
+ exp = extract32(val16, 10, 5);
56
+
57
+ if (exp == 0) {
58
+ return make_float16(deposit32(sbit, 10, 5, 0x1e));
59
+ } else {
102
+ } else {
60
+ return make_float16(deposit32(sbit, 10, 5, ~exp));
103
+ /* Rounding the sign bit always produces 0. */
104
+ return 0;
61
+ }
105
+ }
62
+}
106
+}
63
+
107
+
64
float32 HELPER(frecpx_f32)(float32 a, void *fpstp)
108
DO_VSHRN_ALL(vshrn, DO_SHR)
65
{
109
DO_VSHRN_ALL(vrshrn, do_urshr)
66
float_status *fpst = fpstp;
110
+
67
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
111
+static inline int32_t do_sat_bhs(int64_t val, int64_t min, int64_t max,
68
index XXXXXXX..XXXXXXX 100644
112
+ bool *satp)
69
--- a/target/arm/translate-a64.c
113
+{
70
+++ b/target/arm/translate-a64.c
114
+ if (val > max) {
71
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
115
+ *satp = true;
72
handle_2misc_fcmp_zero(s, fpop, is_scalar, 0, is_q, MO_16, rn, rd);
116
+ return max;
73
return;
117
+ } else if (val < min) {
74
case 0x3d: /* FRECPE */
118
+ *satp = true;
75
+ case 0x3f: /* FRECPX */
119
+ return min;
76
break;
120
+ } else {
77
case 0x18: /* FRINTN */
121
+ return val;
78
need_rmode = true;
122
+ }
79
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
123
+}
80
case 0x3d: /* FRECPE */
124
+
81
gen_helper_recpe_f16(tcg_res, tcg_op, tcg_fpstatus);
125
+/* Saturating narrowing right shifts */
82
break;
126
+#define DO_VSHRN_SAT(OP, TOP, ESIZE, TYPE, LESIZE, LTYPE, FN) \
83
+ case 0x3f: /* FRECPX */
127
+ void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \
84
+ gen_helper_frecpx_f16(tcg_res, tcg_op, tcg_fpstatus);
128
+ void *vm, uint32_t shift) \
85
+ break;
129
+ { \
86
case 0x5a: /* FCVTNU */
130
+ LTYPE *m = vm; \
87
case 0x5b: /* FCVTMU */
131
+ TYPE *d = vd; \
88
case 0x5c: /* FCVTAU */
132
+ uint16_t mask = mve_element_mask(env); \
133
+ bool qc = false; \
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
+
147
+#define DO_VSHRN_SAT_UB(BOP, TOP, FN) \
148
+ DO_VSHRN_SAT(BOP, false, 1, uint8_t, 2, uint16_t, FN) \
149
+ DO_VSHRN_SAT(TOP, true, 1, uint8_t, 2, uint16_t, FN)
150
+
151
+#define DO_VSHRN_SAT_UH(BOP, TOP, FN) \
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
+
155
+#define DO_VSHRN_SAT_SB(BOP, TOP, FN) \
156
+ DO_VSHRN_SAT(BOP, false, 1, int8_t, 2, int16_t, FN) \
157
+ DO_VSHRN_SAT(TOP, true, 1, int8_t, 2, int16_t, FN)
158
+
159
+#define DO_VSHRN_SAT_SH(BOP, TOP, FN) \
160
+ DO_VSHRN_SAT(BOP, false, 2, int16_t, 4, int32_t, FN) \
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)
89
--
224
--
90
2.16.2
225
2.20.1
91
226
92
227
diff view generated by jsdifflib
1
Set the appropriate Linux hwcap bits to tell the guest binary if we
1
Implement the MVE VSHLC insn, which performs a shift left of the
2
have implemented half-precision floating point support.
2
entire vector with carry in bits provided from a general purpose
3
register and carry out bits written back to that register.
3
4
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20210628135835.6690-14-peter.maydell@linaro.org
6
---
8
---
7
linux-user/elfload.c | 2 ++
9
target/arm/helper-mve.h | 2 ++
8
1 file changed, 2 insertions(+)
10
target/arm/mve.decode | 2 ++
11
target/arm/mve_helper.c | 38 ++++++++++++++++++++++++++++++++++++++
12
target/arm/translate-mve.c | 30 ++++++++++++++++++++++++++++++
13
4 files changed, 72 insertions(+)
9
14
10
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
15
diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h
11
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
12
--- a/linux-user/elfload.c
17
--- a/target/arm/helper-mve.h
13
+++ b/linux-user/elfload.c
18
+++ b/target/arm/helper-mve.h
14
@@ -XXX,XX +XXX,XX @@ static uint32_t get_elf_hwcap(void)
19
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqrshrunbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
15
GET_FEATURE(ARM_FEATURE_V8_SM3, ARM_HWCAP_A64_SM3);
20
DEF_HELPER_FLAGS_4(mve_vqrshrunbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
16
GET_FEATURE(ARM_FEATURE_V8_SM4, ARM_HWCAP_A64_SM4);
21
DEF_HELPER_FLAGS_4(mve_vqrshruntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
17
GET_FEATURE(ARM_FEATURE_V8_SHA512, ARM_HWCAP_A64_SHA512);
22
DEF_HELPER_FLAGS_4(mve_vqrshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
18
+ GET_FEATURE(ARM_FEATURE_V8_FP16,
23
+
19
+ ARM_HWCAP_A64_FPHP | ARM_HWCAP_A64_ASIMDHP);
24
+DEF_HELPER_FLAGS_4(mve_vshlc, TCG_CALL_NO_WG, i32, env, ptr, i32, i32)
20
#undef GET_FEATURE
25
diff --git a/target/arm/mve.decode b/target/arm/mve.decode
21
26
index XXXXXXX..XXXXXXX 100644
22
return hwcaps;
27
--- a/target/arm/mve.decode
28
+++ b/target/arm/mve.decode
29
@@ -XXX,XX +XXX,XX @@ VQRSHRUNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_b
30
VQRSHRUNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_h
31
VQRSHRUNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_b
32
VQRSHRUNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_h
33
+
34
+VSHLC 111 0 1110 1 . 1 imm:5 ... 0 1111 1100 rdm:4 qd=%qd
35
diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c
36
index XXXXXXX..XXXXXXX 100644
37
--- a/target/arm/mve_helper.c
38
+++ b/target/arm/mve_helper.c
39
@@ -XXX,XX +XXX,XX @@ DO_VSHRN_SAT_UB(vqrshrnb_ub, vqrshrnt_ub, DO_RSHRN_UB)
40
DO_VSHRN_SAT_UH(vqrshrnb_uh, vqrshrnt_uh, DO_RSHRN_UH)
41
DO_VSHRN_SAT_SB(vqrshrunbb, vqrshruntb, DO_RSHRUN_B)
42
DO_VSHRN_SAT_SH(vqrshrunbh, vqrshrunth, DO_RSHRUN_H)
43
+
44
+uint32_t HELPER(mve_vshlc)(CPUARMState *env, void *vd, uint32_t rdm,
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;
102
+ }
103
+ if (a->rdm == 13 || a->rdm == 15) {
104
+ /* CONSTRAINED UNPREDICTABLE: we UNDEF */
105
+ return false;
106
+ }
107
+ if (!mve_eci_check(s) || !vfp_access_check(s)) {
108
+ return true;
109
+ }
110
+
111
+ qd = mve_qreg_ptr(a->qd);
112
+ rdm = load_reg(s, a->rdm);
113
+ gen_helper_mve_vshlc(rdm, cpu_env, qd, rdm, tcg_constant_i32(a->imm));
114
+ store_reg(s, a->rdm, rdm);
115
+ tcg_temp_free_ptr(qd);
116
+ mve_update_eci(s);
117
+ return true;
118
+}
23
--
119
--
24
2.16.2
120
2.20.1
25
121
26
122
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
Implement the MVE VADDLV insn; this is similar to VADDV, except
2
that it accumulates 32-bit elements into a 64-bit accumulator
3
stored in a pair of general-purpose registers.
2
4
3
This actually covers two different sections of the encoding table:
5
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
---
9
target/arm/helper-mve.h | 3 ++
10
target/arm/mve.decode | 6 +++-
11
target/arm/mve_helper.c | 19 ++++++++++++
12
target/arm/translate-mve.c | 63 ++++++++++++++++++++++++++++++++++++++
13
4 files changed, 90 insertions(+), 1 deletion(-)
4
14
5
Advanced SIMD scalar two-register miscellaneous FP16
15
diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h
6
Advanced SIMD two-register miscellaneous (FP16)
7
8
The difference between the two is covered by a combination of Q (bit
9
30) and S (bit 28). Notably the FRINTx instructions are only
10
available in the vector form.
11
12
This is just the decode skeleton which will be filled out by later
13
patches.
14
15
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
16
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
17
Message-id: 20180227143852.11175-17-alex.bennee@linaro.org
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
---
20
target/arm/translate-a64.c | 40 ++++++++++++++++++++++++++++++++++++++++
21
1 file changed, 40 insertions(+)
22
23
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
24
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
25
--- a/target/arm/translate-a64.c
17
--- a/target/arm/helper-mve.h
26
+++ b/target/arm/translate-a64.c
18
+++ b/target/arm/helper-mve.h
27
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn)
19
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vaddvuh, TCG_CALL_NO_WG, i32, env, ptr, i32)
28
}
20
DEF_HELPER_FLAGS_3(mve_vaddvsw, TCG_CALL_NO_WG, i32, env, ptr, i32)
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;
29
}
82
}
30
83
31
+/* AdvSIMD [scalar] two register miscellaneous (FP16)
84
+static bool trans_VADDLV(DisasContext *s, arg_VADDLV *a)
32
+ *
33
+ * 31 30 29 28 27 24 23 22 21 17 16 12 11 10 9 5 4 0
34
+ * +---+---+---+---+---------+---+-------------+--------+-----+------+------+
35
+ * | 0 | Q | U | S | 1 1 1 0 | a | 1 1 1 1 0 0 | opcode | 1 0 | Rn | Rd |
36
+ * +---+---+---+---+---------+---+-------------+--------+-----+------+------+
37
+ * mask: 1000 1111 0111 1110 0000 1100 0000 0000 0x8f7e 0c00
38
+ * val: 0000 1110 0111 1000 0000 1000 0000 0000 0x0e78 0800
39
+ *
40
+ * This actually covers two groups where scalar access is governed by
41
+ * bit 28. A bunch of the instructions (float to integral) only exist
42
+ * in the vector form and are un-allocated for the scalar decode. Also
43
+ * in the scalar decode Q is always 1.
44
+ */
45
+static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
46
+{
85
+{
47
+ int fpop, opcode, a;
86
+ /*
87
+ * Vector Add Long Across Vector: accumulate the 32-bit
88
+ * elements of the vector into a 64-bit result stored in
89
+ * a pair of general-purpose registers.
90
+ * No need to check Qm's bank: it is only 3 bits in decode.
91
+ */
92
+ TCGv_ptr qm;
93
+ TCGv_i64 rda;
94
+ TCGv_i32 rdalo, rdahi;
48
+
95
+
49
+ if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) {
96
+ if (!dc_isar_feature(aa32_mve, s)) {
50
+ unallocated_encoding(s);
97
+ return false;
51
+ return;
98
+ }
99
+ /*
100
+ * rdahi == 13 is UNPREDICTABLE; rdahi == 15 is a related
101
+ * encoding; rdalo always has bit 0 clear so cannot be 13 or 15.
102
+ */
103
+ if (a->rdahi == 13 || a->rdahi == 15) {
104
+ return false;
105
+ }
106
+ if (!mve_eci_check(s) || !vfp_access_check(s)) {
107
+ return true;
52
+ }
108
+ }
53
+
109
+
54
+ if (!fp_access_check(s)) {
110
+ /*
55
+ return;
111
+ * This insn is subject to beat-wise execution. Partial execution
112
+ * of an A=0 (no-accumulate) insn which does not execute the first
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);
56
+ }
126
+ }
57
+
127
+
58
+ opcode = extract32(insn, 12, 4);
128
+ qm = mve_qreg_ptr(a->qm);
59
+ a = extract32(insn, 23, 1);
129
+ if (a->u) {
60
+ fpop = deposit32(opcode, 5, 1, a);
130
+ gen_helper_mve_vaddlv_u(rda, cpu_env, qm, rda);
131
+ } else {
132
+ gen_helper_mve_vaddlv_s(rda, cpu_env, qm, rda);
133
+ }
134
+ tcg_temp_free_ptr(qm);
61
+
135
+
62
+ switch (fpop) {
136
+ rdalo = tcg_temp_new_i32();
63
+ default:
137
+ rdahi = tcg_temp_new_i32();
64
+ fprintf(stderr, "%s: insn %#04x fpop %#2x\n", __func__, insn, fpop);
138
+ tcg_gen_extrl_i64_i32(rdalo, rda);
65
+ g_assert_not_reached();
139
+ tcg_gen_extrh_i64_i32(rdahi, rda);
66
+ }
140
+ store_reg(s, a->rdalo, rdalo);
67
+
141
+ store_reg(s, a->rdahi, rdahi);
142
+ tcg_temp_free_i64(rda);
143
+ mve_update_eci(s);
144
+ return true;
68
+}
145
+}
69
+
146
+
70
/* AdvSIMD scalar x indexed element
147
static bool do_1imm(DisasContext *s, arg_1imm *a, MVEGenOneOpImmFn *fn)
71
* 31 30 29 28 24 23 22 21 20 19 16 15 12 11 10 9 5 4 0
148
{
72
* +-----+---+-----------+------+---+---+------+-----+---+---+------+------+
149
TCGv_ptr qd;
73
@@ -XXX,XX +XXX,XX @@ static const AArch64DecodeTable data_proc_simd[] = {
74
{ 0xce800000, 0xffe00000, disas_crypto_xar },
75
{ 0xce408000, 0xffe0c000, disas_crypto_three_reg_imm2 },
76
{ 0x0e400400, 0x9f60c400, disas_simd_three_reg_same_fp16 },
77
+ { 0x0e780800, 0x8f7e0c00, disas_simd_two_reg_misc_fp16 },
78
{ 0x00000000, 0x00000000, NULL }
79
};
80
81
--
150
--
82
2.16.2
151
2.20.1
83
152
84
153
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
The MVE extension to v8.1M includes some new shift instructions which
2
2
sit entirely within the non-coprocessor part of the encoding space
3
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
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
7
Implement the long shifts by immediate, which perform shifts on a
8
pair of general-purpose registers treated as a 64-bit quantity, with
9
an immediate shift count between 1 and 32.
10
11
Awkwardly, because the MOVS and ORRS trans functions do not UNDEF for
12
the Rm==13,15 case, we need to explicitly emit code to UNDEF for the
13
cases where v8.1M now requires that. (Trying to change MOVS and ORRS
14
is too difficult, because the functions that generate the code are
15
shared between a dozen different kinds of arithmetic or logical
16
instruction for all A32, T16 and T32 encodings, and for some insns
17
and some encodings Rm==13,15 are valid.)
18
19
We make the helper functions we need for UQSHLL and SQSHLL take
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>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
25
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20180227143852.11175-12-alex.bennee@linaro.org
26
Message-id: 20210628135835.6690-16-peter.maydell@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
27
---
8
target/arm/helper-a64.h | 2 ++
28
target/arm/helper-mve.h | 3 ++
9
target/arm/helper-a64.c | 24 ++++++++++++++++++++++++
29
target/arm/translate.h | 1 +
10
target/arm/translate-a64.c | 15 +++++++++++++++
30
target/arm/t32.decode | 28 +++++++++++++
11
3 files changed, 41 insertions(+)
31
target/arm/mve_helper.c | 10 +++++
12
32
target/arm/translate.c | 90 +++++++++++++++++++++++++++++++++++++++++
13
diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h
33
5 files changed, 132 insertions(+)
14
index XXXXXXX..XXXXXXX 100644
34
15
--- a/target/arm/helper-a64.h
35
diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h
16
+++ b/target/arm/helper-a64.h
36
index XXXXXXX..XXXXXXX 100644
17
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(advsimd_cge_f16, i32, f16, f16, ptr)
37
--- a/target/arm/helper-mve.h
18
DEF_HELPER_3(advsimd_cgt_f16, i32, f16, f16, ptr)
38
+++ b/target/arm/helper-mve.h
19
DEF_HELPER_3(advsimd_acge_f16, i32, f16, f16, ptr)
39
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqrshruntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
20
DEF_HELPER_3(advsimd_acgt_f16, i32, f16, f16, ptr)
40
DEF_HELPER_FLAGS_4(mve_vqrshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
21
+DEF_HELPER_3(advsimd_mulxh, f16, f16, f16, ptr)
41
22
+DEF_HELPER_4(advsimd_muladdh, f16, f16, f16, f16, ptr)
42
DEF_HELPER_FLAGS_4(mve_vshlc, TCG_CALL_NO_WG, i32, env, ptr, i32, i32)
23
diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c
43
+
24
index XXXXXXX..XXXXXXX 100644
44
+DEF_HELPER_FLAGS_3(mve_sqshll, TCG_CALL_NO_RWG, i64, env, i64, i32)
25
--- a/target/arm/helper-a64.c
45
+DEF_HELPER_FLAGS_3(mve_uqshll, TCG_CALL_NO_RWG, i64, env, i64, i32)
26
+++ b/target/arm/helper-a64.c
46
diff --git a/target/arm/translate.h b/target/arm/translate.h
27
@@ -XXX,XX +XXX,XX @@ ADVSIMD_HALFOP(max)
47
index XXXXXXX..XXXXXXX 100644
28
ADVSIMD_HALFOP(minnum)
48
--- a/target/arm/translate.h
29
ADVSIMD_HALFOP(maxnum)
49
+++ b/target/arm/translate.h
30
50
@@ -XXX,XX +XXX,XX @@ typedef void CryptoTwoOpFn(TCGv_ptr, TCGv_ptr);
31
+/* Data processing - scalar floating-point and advanced SIMD */
51
typedef void CryptoThreeOpIntFn(TCGv_ptr, TCGv_ptr, TCGv_i32);
32
+float16 HELPER(advsimd_mulxh)(float16 a, float16 b, void *fpstp)
52
typedef void CryptoThreeOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr);
33
+{
53
typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp);
34
+ float_status *fpst = fpstp;
54
+typedef void WideShiftImmFn(TCGv_i64, TCGv_i64, int64_t shift);
35
+
55
36
+ a = float16_squash_input_denormal(a, fpst);
56
/**
37
+ b = float16_squash_input_denormal(b, fpst);
57
* arm_tbflags_from_tb:
38
+
58
diff --git a/target/arm/t32.decode b/target/arm/t32.decode
39
+ if ((float16_is_zero(a) && float16_is_infinity(b)) ||
59
index XXXXXXX..XXXXXXX 100644
40
+ (float16_is_infinity(a) && float16_is_zero(b))) {
60
--- a/target/arm/t32.decode
41
+ /* 2.0 with the sign bit set to sign(A) XOR sign(B) */
61
+++ b/target/arm/t32.decode
42
+ return make_float16((1U << 14) |
62
@@ -XXX,XX +XXX,XX @@
43
+ ((float16_val(a) ^ float16_val(b)) & (1U << 15)));
63
&mcr !extern cp opc1 crn crm opc2 rt
44
+ }
64
&mcrr !extern cp opc1 crm rt rt2
45
+ return float16_mul(a, b, fpst);
65
46
+}
66
+&mve_shl_ri rdalo rdahi shim
47
+
67
+
48
+/* fused multiply-accumulate */
68
+# rdahi: bits [3:1] from insn, bit 0 is 1
49
+float16 HELPER(advsimd_muladdh)(float16 a, float16 b, float16 c, void *fpstp)
69
+# rdalo: bits [3:1] from insn, bit 0 is 0
50
+{
70
+%rdahi_9 9:3 !function=times_2_plus_1
51
+ float_status *fpst = fpstp;
71
+%rdalo_17 17:3 !function=times_2
52
+ return float16_muladd(a, b, c, 0, fpst);
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
}
87
BIC_rrri 1110101 0001 . .... 0 ... .... .... .... @s_rrr_shi
88
{
89
+ # The v8.1M MVE shift insns overlap in encoding with MOVS/ORRS
90
+ # and are distinguished by having Rm==13 or 15. Those are UNPREDICTABLE
91
+ # cases for MOVS/ORRS. We decode the MVE cases first, ensuring that
92
+ # they explicitly call unallocated_encoding() for cases that must UNDEF
93
+ # (eg "using a new shift insn on a v8.1M CPU without MVE"), and letting
94
+ # the rest fall through (where ORR_rrri and MOV_rxri will end up
95
+ # handling them as r13 and r15 accesses with the same semantics as A32).
96
+ [
97
+ LSLL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 00 1111 @mve_shl_ri
98
+ LSRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 01 1111 @mve_shl_ri
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
}
110
diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c
111
index XXXXXXX..XXXXXXX 100644
112
--- a/target/arm/mve_helper.c
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
+{
121
+ return do_sqrshl_d(n, (int8_t)shift, false, &env->QF);
122
+}
123
+
124
+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
diff --git a/target/arm/translate.c b/target/arm/translate.c
129
index XXXXXXX..XXXXXXX 100644
130
--- a/target/arm/translate.c
131
+++ b/target/arm/translate.c
132
@@ -XXX,XX +XXX,XX @@ static bool trans_MOVT(DisasContext *s, arg_MOVW *a)
133
return true;
134
}
135
136
+/*
137
+ * v8.1M MVE wide-shifts
138
+ */
139
+static bool do_mve_shl_ri(DisasContext *s, arg_mve_shl_ri *a,
140
+ WideShiftImmFn *fn)
141
+{
142
+ TCGv_i64 rda;
143
+ TCGv_i32 rdalo, rdahi;
144
+
145
+ if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) {
146
+ /* Decode falls through to ORR/MOV UNPREDICTABLE handling */
147
+ return false;
148
+ }
149
+ if (a->rdahi == 15) {
150
+ /* These are a different encoding (SQSHL/SRSHR/UQSHL/URSHR) */
151
+ return false;
152
+ }
153
+ if (!dc_isar_feature(aa32_mve, s) ||
154
+ !arm_dc_feature(s, ARM_FEATURE_M_MAIN) ||
155
+ a->rdahi == 13) {
156
+ /* RdaHi == 13 is UNPREDICTABLE; we choose to UNDEF */
157
+ unallocated_encoding(s);
158
+ return true;
159
+ }
160
+
161
+ if (a->shim == 0) {
162
+ a->shim = 32;
163
+ }
164
+
165
+ rda = tcg_temp_new_i64();
166
+ rdalo = load_reg(s, a->rdalo);
167
+ rdahi = load_reg(s, a->rdahi);
168
+ tcg_gen_concat_i32_i64(rda, rdalo, rdahi);
169
+
170
+ fn(rda, rda, a->shim);
171
+
172
+ tcg_gen_extrl_i64_i32(rdalo, rda);
173
+ tcg_gen_extrh_i64_i32(rdahi, rda);
174
+ store_reg(s, a->rdalo, rdalo);
175
+ store_reg(s, a->rdahi, rdahi);
176
+ tcg_temp_free_i64(rda);
177
+
178
+ return true;
179
+}
180
+
181
+static bool trans_ASRL_ri(DisasContext *s, arg_mve_shl_ri *a)
182
+{
183
+ return do_mve_shl_ri(s, a, tcg_gen_sari_i64);
184
+}
185
+
186
+static bool trans_LSLL_ri(DisasContext *s, arg_mve_shl_ri *a)
187
+{
188
+ return do_mve_shl_ri(s, a, tcg_gen_shli_i64);
189
+}
190
+
191
+static bool trans_LSRL_ri(DisasContext *s, arg_mve_shl_ri *a)
192
+{
193
+ return do_mve_shl_ri(s, a, tcg_gen_shri_i64);
194
+}
195
+
196
+static void gen_mve_sqshll(TCGv_i64 r, TCGv_i64 n, int64_t shift)
197
+{
198
+ gen_helper_mve_sqshll(r, cpu_env, n, tcg_constant_i32(shift));
199
+}
200
+
201
+static bool trans_SQSHLL_ri(DisasContext *s, arg_mve_shl_ri *a)
202
+{
203
+ return do_mve_shl_ri(s, a, gen_mve_sqshll);
204
+}
205
+
206
+static void gen_mve_uqshll(TCGv_i64 r, TCGv_i64 n, int64_t shift)
207
+{
208
+ gen_helper_mve_uqshll(r, cpu_env, n, tcg_constant_i32(shift));
209
+}
210
+
211
+static bool trans_UQSHLL_ri(DisasContext *s, arg_mve_shl_ri *a)
212
+{
213
+ return do_mve_shl_ri(s, a, gen_mve_uqshll);
214
+}
215
+
216
+static bool trans_SRSHRL_ri(DisasContext *s, arg_mve_shl_ri *a)
217
+{
218
+ return do_mve_shl_ri(s, a, gen_srshr64_i64);
219
+}
220
+
221
+static bool trans_URSHRL_ri(DisasContext *s, arg_mve_shl_ri *a)
222
+{
223
+ return do_mve_shl_ri(s, a, gen_urshr64_i64);
53
+}
224
+}
54
+
225
+
55
/*
226
/*
56
* Floating point comparisons produce an integer result. Softfloat
227
* Multiply and multiply accumulate
57
* routines return float_relation types which we convert to the 0/-1
228
*/
58
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
59
index XXXXXXX..XXXXXXX 100644
60
--- a/target/arm/translate-a64.c
61
+++ b/target/arm/translate-a64.c
62
@@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn)
63
case 0x0: /* FMAXNM */
64
gen_helper_advsimd_maxnumh(tcg_res, tcg_op1, tcg_op2, fpst);
65
break;
66
+ case 0x1: /* FMLA */
67
+ read_vec_element_i32(s, tcg_res, rd, pass, MO_16);
68
+ gen_helper_advsimd_muladdh(tcg_res, tcg_op1, tcg_op2, tcg_res,
69
+ fpst);
70
+ break;
71
case 0x2: /* FADD */
72
gen_helper_advsimd_addh(tcg_res, tcg_op1, tcg_op2, fpst);
73
break;
74
+ case 0x3: /* FMULX */
75
+ gen_helper_advsimd_mulxh(tcg_res, tcg_op1, tcg_op2, fpst);
76
+ break;
77
case 0x4: /* FCMEQ */
78
gen_helper_advsimd_ceq_f16(tcg_res, tcg_op1, tcg_op2, fpst);
79
break;
80
@@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn)
81
case 0x8: /* FMINNM */
82
gen_helper_advsimd_minnumh(tcg_res, tcg_op1, tcg_op2, fpst);
83
break;
84
+ case 0x9: /* FMLS */
85
+ /* As usual for ARM, separate negation for fused multiply-add */
86
+ tcg_gen_xori_i32(tcg_op1, tcg_op1, 0x8000);
87
+ read_vec_element_i32(s, tcg_res, rd, pass, MO_16);
88
+ gen_helper_advsimd_muladdh(tcg_res, tcg_op1, tcg_op2, tcg_res,
89
+ fpst);
90
+ break;
91
case 0xa: /* FSUB */
92
gen_helper_advsimd_subh(tcg_res, tcg_op1, tcg_op2, fpst);
93
break;
94
--
229
--
95
2.16.2
230
2.20.1
96
231
97
232
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
Implement the MVE long shifts by register, which perform shifts on a
2
2
pair of general-purpose registers treated as a 64-bit quantity, with
3
As the rounding mode is now split between FP16 and the rest of
3
the shift count in another general-purpose register, which might be
4
floating point we need to be explicit when tweaking it. Instead of
4
either positive or negative.
5
passing the CPU env we now pass the appropriate fpst pointer directly.
5
6
6
Like the long-shifts-by-immediate, these encodings sit in the space
7
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
7
that was previously the UNPREDICTABLE MOVS/ORRS with Rm==13,15.
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
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20180227143852.11175-6-alex.bennee@linaro.org
14
Message-id: 20210628135835.6690-17-peter.maydell@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
15
---
12
target/arm/helper.h | 2 +-
16
target/arm/helper-mve.h | 6 +++
13
target/arm/helper.c | 4 ++--
17
target/arm/translate.h | 1 +
14
target/arm/translate-a64.c | 26 +++++++++++++-------------
18
target/arm/t32.decode | 16 +++++--
15
target/arm/translate.c | 12 ++++++------
19
target/arm/mve_helper.c | 93 +++++++++++++++++++++++++++++++++++++++++
16
4 files changed, 22 insertions(+), 22 deletions(-)
20
target/arm/translate.c | 69 ++++++++++++++++++++++++++++++
17
21
5 files changed, 182 insertions(+), 3 deletions(-)
18
diff --git a/target/arm/helper.h b/target/arm/helper.h
22
19
index XXXXXXX..XXXXXXX 100644
23
diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h
20
--- a/target/arm/helper.h
24
index XXXXXXX..XXXXXXX 100644
21
+++ b/target/arm/helper.h
25
--- a/target/arm/helper-mve.h
22
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(vfp_uhtod, f64, i64, i32, ptr)
26
+++ b/target/arm/helper-mve.h
23
DEF_HELPER_3(vfp_ultod, f64, i64, i32, ptr)
27
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqrshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32)
24
DEF_HELPER_3(vfp_uqtod, f64, i64, i32, ptr)
28
25
29
DEF_HELPER_FLAGS_4(mve_vshlc, TCG_CALL_NO_WG, i32, env, ptr, i32, i32)
26
-DEF_HELPER_FLAGS_2(set_rmode, TCG_CALL_NO_RWG, i32, i32, env)
30
27
+DEF_HELPER_FLAGS_2(set_rmode, TCG_CALL_NO_RWG, i32, i32, ptr)
31
+DEF_HELPER_FLAGS_3(mve_sshrl, TCG_CALL_NO_RWG, i64, env, i64, i32)
28
DEF_HELPER_FLAGS_2(set_neon_rmode, TCG_CALL_NO_RWG, i32, i32, env)
32
+DEF_HELPER_FLAGS_3(mve_ushll, TCG_CALL_NO_RWG, i64, env, i64, i32)
29
33
DEF_HELPER_FLAGS_3(mve_sqshll, TCG_CALL_NO_RWG, i64, env, i64, i32)
30
DEF_HELPER_2(vfp_fcvt_f16_to_f32, f32, i32, env)
34
DEF_HELPER_FLAGS_3(mve_uqshll, TCG_CALL_NO_RWG, i64, env, i64, i32)
31
diff --git a/target/arm/helper.c b/target/arm/helper.c
35
+DEF_HELPER_FLAGS_3(mve_sqrshrl, TCG_CALL_NO_RWG, i64, env, i64, i32)
32
index XXXXXXX..XXXXXXX 100644
36
+DEF_HELPER_FLAGS_3(mve_uqrshll, TCG_CALL_NO_RWG, i64, env, i64, i32)
33
--- a/target/arm/helper.c
37
+DEF_HELPER_FLAGS_3(mve_sqrshrl48, TCG_CALL_NO_RWG, i64, env, i64, i32)
34
+++ b/target/arm/helper.c
38
+DEF_HELPER_FLAGS_3(mve_uqrshll48, TCG_CALL_NO_RWG, i64, env, i64, i32)
35
@@ -XXX,XX +XXX,XX @@ VFP_CONV_FIX_A64(uq, s, 32, 64, uint64)
39
diff --git a/target/arm/translate.h b/target/arm/translate.h
36
/* Set the current fp rounding mode and return the old one.
40
index XXXXXXX..XXXXXXX 100644
37
* The argument is a softfloat float_round_ value.
41
--- a/target/arm/translate.h
38
*/
42
+++ b/target/arm/translate.h
39
-uint32_t HELPER(set_rmode)(uint32_t rmode, CPUARMState *env)
43
@@ -XXX,XX +XXX,XX @@ typedef void CryptoThreeOpIntFn(TCGv_ptr, TCGv_ptr, TCGv_i32);
40
+uint32_t HELPER(set_rmode)(uint32_t rmode, void *fpstp)
44
typedef void CryptoThreeOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr);
41
{
45
typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp);
42
- float_status *fp_status = &env->vfp.fp_status;
46
typedef void WideShiftImmFn(TCGv_i64, TCGv_i64, int64_t shift);
43
+ float_status *fp_status = fpstp;
47
+typedef void WideShiftFn(TCGv_i64, TCGv_ptr, TCGv_i64, TCGv_i32);
44
48
45
uint32_t prev_rmode = get_float_rounding_mode(fp_status);
49
/**
46
set_float_rounding_mode(rmode, fp_status);
50
* arm_tbflags_from_tb:
47
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
51
diff --git a/target/arm/t32.decode b/target/arm/t32.decode
48
index XXXXXXX..XXXXXXX 100644
52
index XXXXXXX..XXXXXXX 100644
49
--- a/target/arm/translate-a64.c
53
--- a/target/arm/t32.decode
50
+++ b/target/arm/translate-a64.c
54
+++ b/target/arm/t32.decode
51
@@ -XXX,XX +XXX,XX @@ static void handle_fp_1src_single(DisasContext *s, int opcode, int rd, int rn)
55
@@ -XXX,XX +XXX,XX @@
52
{
56
&mcrr !extern cp opc1 crm rt rt2
53
TCGv_i32 tcg_rmode = tcg_const_i32(arm_rmode_to_sf(opcode & 7));
57
54
58
&mve_shl_ri rdalo rdahi shim
55
- gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
59
+&mve_shl_rr rdalo rdahi rm
56
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
60
57
gen_helper_rints(tcg_res, tcg_op, fpst);
61
# rdahi: bits [3:1] from insn, bit 0 is 1
58
62
# rdalo: bits [3:1] from insn, bit 0 is 0
59
- gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
63
@@ -XXX,XX +XXX,XX @@
60
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
64
61
tcg_temp_free_i32(tcg_rmode);
65
@mve_shl_ri ....... .... . ... . . ... ... . .. .. .... \
62
break;
66
&mve_shl_ri shim=%imm5_12_6 rdalo=%rdalo_17 rdahi=%rdahi_9
63
}
67
+@mve_shl_rr ....... .... . ... . rm:4 ... . .. .. .... \
64
@@ -XXX,XX +XXX,XX @@ static void handle_fp_1src_double(DisasContext *s, int opcode, int rd, int rn)
68
+ &mve_shl_rr rdalo=%rdalo_17 rdahi=%rdahi_9
65
{
69
66
TCGv_i32 tcg_rmode = tcg_const_i32(arm_rmode_to_sf(opcode & 7));
70
{
67
71
TST_xrri 1110101 0000 1 .... 0 ... 1111 .... .... @S_xrr_shi
68
- gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
72
@@ -XXX,XX +XXX,XX @@ BIC_rrri 1110101 0001 . .... 0 ... .... .... .... @s_rrr_shi
69
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
73
URSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 01 1111 @mve_shl_ri
70
gen_helper_rintd(tcg_res, tcg_op, fpst);
74
SRSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 10 1111 @mve_shl_ri
71
75
SQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 11 1111 @mve_shl_ri
72
- gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
76
+
73
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
77
+ LSLL_rr 1110101 0010 1 ... 0 .... ... 1 0000 1101 @mve_shl_rr
74
tcg_temp_free_i32(tcg_rmode);
78
+ ASRL_rr 1110101 0010 1 ... 0 .... ... 1 0010 1101 @mve_shl_rr
75
break;
79
+ UQRSHLL64_rr 1110101 0010 1 ... 1 .... ... 1 0000 1101 @mve_shl_rr
76
}
80
+ SQRSHRL64_rr 1110101 0010 1 ... 1 .... ... 1 0010 1101 @mve_shl_rr
77
@@ -XXX,XX +XXX,XX @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode,
81
+ UQRSHLL48_rr 1110101 0010 1 ... 1 .... ... 1 1000 1101 @mve_shl_rr
78
82
+ SQRSHRL48_rr 1110101 0010 1 ... 1 .... ... 1 1010 1101 @mve_shl_rr
79
tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rmode));
83
]
80
84
81
- gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
85
MOV_rxri 1110101 0010 . 1111 0 ... .... .... .... @s_rxr_shi
82
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus);
86
ORR_rrri 1110101 0010 . .... 0 ... .... .... .... @s_rrr_shi
83
87
+
84
if (is_double) {
88
+ # v8.1M CSEL and friends
85
TCGv_i64 tcg_double = read_fp_dreg(s, rn);
89
+ CSEL 1110101 0010 1 rn:4 10 op:2 rd:4 fcond:4 rm:4
86
@@ -XXX,XX +XXX,XX @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode,
90
}
87
tcg_temp_free_i32(tcg_single);
91
{
88
}
92
MVN_rxri 1110101 0011 . 1111 0 ... .... .... .... @s_rxr_shi
89
93
@@ -XXX,XX +XXX,XX @@ SBC_rrri 1110101 1011 . .... 0 ... .... .... .... @s_rrr_shi
90
- gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
94
}
91
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus);
95
RSB_rrri 1110101 1110 . .... 0 ... .... .... .... @s_rrr_shi
92
tcg_temp_free_i32(tcg_rmode);
96
93
97
-# v8.1M CSEL and friends
94
if (!sf) {
98
-CSEL 1110101 0010 1 rn:4 10 op:2 rd:4 fcond:4 rm:4
95
@@ -XXX,XX +XXX,XX @@ static void handle_simd_shift_fpint_conv(DisasContext *s, bool is_scalar,
99
-
96
assert(!(is_scalar && is_q));
100
# Data-processing (register-shifted register)
97
101
98
tcg_rmode = tcg_const_i32(arm_rmode_to_sf(FPROUNDING_ZERO));
102
MOV_rxrr 1111 1010 0 shty:2 s:1 rm:4 1111 rd:4 0000 rs:4 \
99
- gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
103
diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c
100
tcg_fpstatus = get_fpstatus_ptr(false);
104
index XXXXXXX..XXXXXXX 100644
101
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus);
105
--- a/target/arm/mve_helper.c
102
tcg_shift = tcg_const_i32(fracbits);
106
+++ b/target/arm/mve_helper.c
103
107
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(mve_vshlc)(CPUARMState *env, void *vd, uint32_t rdm,
104
if (is_double) {
108
return rdm;
105
@@ -XXX,XX +XXX,XX @@ static void handle_simd_shift_fpint_conv(DisasContext *s, bool is_scalar,
109
}
106
110
107
tcg_temp_free_ptr(tcg_fpstatus);
111
+uint64_t HELPER(mve_sshrl)(CPUARMState *env, uint64_t n, uint32_t shift)
108
tcg_temp_free_i32(tcg_shift);
112
+{
109
- gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
113
+ return do_sqrshl_d(n, -(int8_t)shift, false, NULL);
110
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus);
114
+}
111
tcg_temp_free_i32(tcg_rmode);
115
+
112
}
116
+uint64_t HELPER(mve_ushll)(CPUARMState *env, uint64_t n, uint32_t shift)
113
117
+{
114
@@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_two_reg_misc(DisasContext *s, uint32_t insn)
118
+ return do_uqrshl_d(n, (int8_t)shift, false, NULL);
115
119
+}
116
if (is_fcvt) {
120
+
117
tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rmode));
121
uint64_t HELPER(mve_sqshll)(CPUARMState *env, uint64_t n, uint32_t shift)
118
- gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
122
{
119
tcg_fpstatus = get_fpstatus_ptr(false);
123
return do_sqrshl_d(n, (int8_t)shift, false, &env->QF);
120
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus);
124
@@ -XXX,XX +XXX,XX @@ uint64_t HELPER(mve_uqshll)(CPUARMState *env, uint64_t n, uint32_t shift)
121
} else {
125
{
122
tcg_rmode = NULL;
126
return do_uqrshl_d(n, (int8_t)shift, false, &env->QF);
123
tcg_fpstatus = NULL;
127
}
124
@@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_two_reg_misc(DisasContext *s, uint32_t insn)
128
+
125
}
129
+uint64_t HELPER(mve_sqrshrl)(CPUARMState *env, uint64_t n, uint32_t shift)
126
130
+{
127
if (is_fcvt) {
131
+ return do_sqrshl_d(n, -(int8_t)shift, true, &env->QF);
128
- gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
132
+}
129
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus);
133
+
130
tcg_temp_free_i32(tcg_rmode);
134
+uint64_t HELPER(mve_uqrshll)(CPUARMState *env, uint64_t n, uint32_t shift)
131
tcg_temp_free_ptr(tcg_fpstatus);
135
+{
132
}
136
+ return do_uqrshl_d(n, (int8_t)shift, true, &env->QF);
133
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn)
137
+}
134
return;
138
+
135
}
139
+/* Operate on 64-bit values, but saturate at 48 bits */
136
140
+static inline int64_t do_sqrshl48_d(int64_t src, int64_t shift,
137
- if (need_fpstatus) {
141
+ bool round, uint32_t *sat)
138
+ if (need_fpstatus || need_rmode) {
142
+{
139
tcg_fpstatus = get_fpstatus_ptr(false);
143
+ if (shift <= -48) {
140
} else {
144
+ /* Rounding the sign bit always produces 0. */
141
tcg_fpstatus = NULL;
145
+ if (round) {
142
}
146
+ return 0;
143
if (need_rmode) {
147
+ }
144
tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rmode));
148
+ return src >> 63;
145
- gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
149
+ } else if (shift < 0) {
146
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus);
150
+ if (round) {
147
} else {
151
+ src >>= -shift - 1;
148
tcg_rmode = NULL;
152
+ return (src >> 1) + (src & 1);
149
}
153
+ }
150
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn)
154
+ return src >> -shift;
151
clear_vec_high(s, is_q, rd);
155
+ } else if (shift < 48) {
152
156
+ int64_t val = src << shift;
153
if (need_rmode) {
157
+ int64_t extval = sextract64(val, 0, 48);
154
- gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
158
+ if (!sat || val == extval) {
155
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus);
159
+ return extval;
156
tcg_temp_free_i32(tcg_rmode);
160
+ }
157
}
161
+ } else if (!sat || src == 0) {
158
if (need_fpstatus) {
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
+}
159
diff --git a/target/arm/translate.c b/target/arm/translate.c
211
diff --git a/target/arm/translate.c b/target/arm/translate.c
160
index XXXXXXX..XXXXXXX 100644
212
index XXXXXXX..XXXXXXX 100644
161
--- a/target/arm/translate.c
213
--- a/target/arm/translate.c
162
+++ b/target/arm/translate.c
214
+++ b/target/arm/translate.c
163
@@ -XXX,XX +XXX,XX @@ static int handle_vrint(uint32_t insn, uint32_t rd, uint32_t rm, uint32_t dp,
215
@@ -XXX,XX +XXX,XX @@ static bool trans_URSHRL_ri(DisasContext *s, arg_mve_shl_ri *a)
164
TCGv_i32 tcg_rmode;
216
return do_mve_shl_ri(s, a, gen_urshr64_i64);
165
217
}
166
tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rounding));
218
167
- gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
219
+static bool do_mve_shl_rr(DisasContext *s, arg_mve_shl_rr *a, WideShiftFn *fn)
168
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
220
+{
169
221
+ TCGv_i64 rda;
170
if (dp) {
222
+ TCGv_i32 rdalo, rdahi;
171
TCGv_i64 tcg_op;
223
+
172
@@ -XXX,XX +XXX,XX @@ static int handle_vrint(uint32_t insn, uint32_t rd, uint32_t rm, uint32_t dp,
224
+ if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) {
173
tcg_temp_free_i32(tcg_res);
225
+ /* Decode falls through to ORR/MOV UNPREDICTABLE handling */
174
}
226
+ return false;
175
227
+ }
176
- gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
228
+ if (a->rdahi == 15) {
177
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
229
+ /* These are a different encoding (SQSHL/SRSHR/UQSHL/URSHR) */
178
tcg_temp_free_i32(tcg_rmode);
230
+ return false;
179
231
+ }
180
tcg_temp_free_ptr(fpst);
232
+ if (!dc_isar_feature(aa32_mve, s) ||
181
@@ -XXX,XX +XXX,XX @@ static int handle_vcvt(uint32_t insn, uint32_t rd, uint32_t rm, uint32_t dp,
233
+ !arm_dc_feature(s, ARM_FEATURE_M_MAIN) ||
182
tcg_shift = tcg_const_i32(0);
234
+ a->rdahi == 13 || a->rm == 13 || a->rm == 15 ||
183
235
+ a->rm == a->rdahi || a->rm == a->rdalo) {
184
tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rounding));
236
+ /* These rdahi/rdalo/rm cases are UNPREDICTABLE; we choose to UNDEF */
185
- gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
237
+ unallocated_encoding(s);
186
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
238
+ return true;
187
239
+ }
188
if (dp) {
240
+
189
TCGv_i64 tcg_double, tcg_res;
241
+ rda = tcg_temp_new_i64();
190
@@ -XXX,XX +XXX,XX @@ static int handle_vcvt(uint32_t insn, uint32_t rd, uint32_t rm, uint32_t dp,
242
+ rdalo = load_reg(s, a->rdalo);
191
tcg_temp_free_i32(tcg_single);
243
+ rdahi = load_reg(s, a->rdahi);
192
}
244
+ tcg_gen_concat_i32_i64(rda, rdalo, rdahi);
193
245
+
194
- gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
246
+ /* The helper takes care of the sign-extension of the low 8 bits of Rm */
195
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
247
+ fn(rda, cpu_env, rda, cpu_R[a->rm]);
196
tcg_temp_free_i32(tcg_rmode);
248
+
197
249
+ tcg_gen_extrl_i64_i32(rdalo, rda);
198
tcg_temp_free_i32(tcg_shift);
250
+ tcg_gen_extrh_i64_i32(rdahi, rda);
199
@@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn)
251
+ store_reg(s, a->rdalo, rdalo);
200
TCGv_ptr fpst = get_fpstatus_ptr(0);
252
+ store_reg(s, a->rdahi, rdahi);
201
TCGv_i32 tcg_rmode;
253
+ tcg_temp_free_i64(rda);
202
tcg_rmode = tcg_const_i32(float_round_to_zero);
254
+
203
- gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
255
+ return true;
204
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
256
+}
205
if (dp) {
257
+
206
gen_helper_rintd(cpu_F0d, cpu_F0d, fpst);
258
+static bool trans_LSLL_rr(DisasContext *s, arg_mve_shl_rr *a)
207
} else {
259
+{
208
gen_helper_rints(cpu_F0s, cpu_F0s, fpst);
260
+ return do_mve_shl_rr(s, a, gen_helper_mve_ushll);
209
}
261
+}
210
- gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
262
+
211
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
263
+static bool trans_ASRL_rr(DisasContext *s, arg_mve_shl_rr *a)
212
tcg_temp_free_i32(tcg_rmode);
264
+{
213
tcg_temp_free_ptr(fpst);
265
+ return do_mve_shl_rr(s, a, gen_helper_mve_sshrl);
214
break;
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
/*
289
* Multiply and multiply accumulate
290
*/
215
--
291
--
216
2.16.2
292
2.20.1
217
293
218
294
diff view generated by jsdifflib
Deleted patch
1
From: Alex Bennée <alex.bennee@linaro.org>
2
1
3
We do implement all the opcodes.
4
5
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20180227143852.11175-8-alex.bennee@linaro.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
10
target/arm/translate-a64.c | 3 +--
11
1 file changed, 1 insertion(+), 2 deletions(-)
12
13
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/translate-a64.c
16
+++ b/target/arm/translate-a64.c
17
@@ -XXX,XX +XXX,XX @@ static void handle_3same_64(DisasContext *s, int opcode, bool u,
18
/* Handle 64x64->64 opcodes which are shared between the scalar
19
* and vector 3-same groups. We cover every opcode where size == 3
20
* is valid in either the three-reg-same (integer, not pairwise)
21
- * or scalar-three-reg-same groups. (Some opcodes are not yet
22
- * implemented.)
23
+ * or scalar-three-reg-same groups.
24
*/
25
TCGCond cond;
26
27
--
28
2.16.2
29
30
diff view generated by jsdifflib
Deleted patch
1
From: Alex Bennée <alex.bennee@linaro.org>
2
1
3
This includes FMAXNMP, FADDP, FMAXP, FMINNMP, FMINP.
4
5
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20180227143852.11175-14-alex.bennee@linaro.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
10
target/arm/translate-a64.c | 208 +++++++++++++++++++++++++++++----------------
11
1 file changed, 133 insertions(+), 75 deletions(-)
12
13
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/translate-a64.c
16
+++ b/target/arm/translate-a64.c
17
@@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn)
18
int datasize, elements;
19
int pass;
20
TCGv_ptr fpst;
21
+ bool pairwise = false;
22
23
if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) {
24
unallocated_encoding(s);
25
@@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn)
26
datasize = is_q ? 128 : 64;
27
elements = datasize / 16;
28
29
+ switch (fpopcode) {
30
+ case 0x10: /* FMAXNMP */
31
+ case 0x12: /* FADDP */
32
+ case 0x16: /* FMAXP */
33
+ case 0x18: /* FMINNMP */
34
+ case 0x1e: /* FMINP */
35
+ pairwise = true;
36
+ break;
37
+ }
38
+
39
fpst = get_fpstatus_ptr(true);
40
41
- for (pass = 0; pass < elements; pass++) {
42
+ if (pairwise) {
43
+ int maxpass = is_q ? 8 : 4;
44
TCGv_i32 tcg_op1 = tcg_temp_new_i32();
45
TCGv_i32 tcg_op2 = tcg_temp_new_i32();
46
- TCGv_i32 tcg_res = tcg_temp_new_i32();
47
+ TCGv_i32 tcg_res[8];
48
49
- read_vec_element_i32(s, tcg_op1, rn, pass, MO_16);
50
- read_vec_element_i32(s, tcg_op2, rm, pass, MO_16);
51
+ for (pass = 0; pass < maxpass; pass++) {
52
+ int passreg = pass < (maxpass / 2) ? rn : rm;
53
+ int passelt = (pass << 1) & (maxpass - 1);
54
55
- switch (fpopcode) {
56
- case 0x0: /* FMAXNM */
57
- gen_helper_advsimd_maxnumh(tcg_res, tcg_op1, tcg_op2, fpst);
58
- break;
59
- case 0x1: /* FMLA */
60
- read_vec_element_i32(s, tcg_res, rd, pass, MO_16);
61
- gen_helper_advsimd_muladdh(tcg_res, tcg_op1, tcg_op2, tcg_res,
62
- fpst);
63
- break;
64
- case 0x2: /* FADD */
65
- gen_helper_advsimd_addh(tcg_res, tcg_op1, tcg_op2, fpst);
66
- break;
67
- case 0x3: /* FMULX */
68
- gen_helper_advsimd_mulxh(tcg_res, tcg_op1, tcg_op2, fpst);
69
- break;
70
- case 0x4: /* FCMEQ */
71
- gen_helper_advsimd_ceq_f16(tcg_res, tcg_op1, tcg_op2, fpst);
72
- break;
73
- case 0x6: /* FMAX */
74
- gen_helper_advsimd_maxh(tcg_res, tcg_op1, tcg_op2, fpst);
75
- break;
76
- case 0x7: /* FRECPS */
77
- gen_helper_recpsf_f16(tcg_res, tcg_op1, tcg_op2, fpst);
78
- break;
79
- case 0x8: /* FMINNM */
80
- gen_helper_advsimd_minnumh(tcg_res, tcg_op1, tcg_op2, fpst);
81
- break;
82
- case 0x9: /* FMLS */
83
- /* As usual for ARM, separate negation for fused multiply-add */
84
- tcg_gen_xori_i32(tcg_op1, tcg_op1, 0x8000);
85
- read_vec_element_i32(s, tcg_res, rd, pass, MO_16);
86
- gen_helper_advsimd_muladdh(tcg_res, tcg_op1, tcg_op2, tcg_res,
87
- fpst);
88
- break;
89
- case 0xa: /* FSUB */
90
- gen_helper_advsimd_subh(tcg_res, tcg_op1, tcg_op2, fpst);
91
- break;
92
- case 0xe: /* FMIN */
93
- gen_helper_advsimd_minh(tcg_res, tcg_op1, tcg_op2, fpst);
94
- break;
95
- case 0xf: /* FRSQRTS */
96
- gen_helper_rsqrtsf_f16(tcg_res, tcg_op1, tcg_op2, fpst);
97
- break;
98
- case 0x13: /* FMUL */
99
- gen_helper_advsimd_mulh(tcg_res, tcg_op1, tcg_op2, fpst);
100
- break;
101
- case 0x14: /* FCMGE */
102
- gen_helper_advsimd_cge_f16(tcg_res, tcg_op1, tcg_op2, fpst);
103
- break;
104
- case 0x15: /* FACGE */
105
- gen_helper_advsimd_acge_f16(tcg_res, tcg_op1, tcg_op2, fpst);
106
- break;
107
- case 0x17: /* FDIV */
108
- gen_helper_advsimd_divh(tcg_res, tcg_op1, tcg_op2, fpst);
109
- break;
110
- case 0x1a: /* FABD */
111
- gen_helper_advsimd_subh(tcg_res, tcg_op1, tcg_op2, fpst);
112
- tcg_gen_andi_i32(tcg_res, tcg_res, 0x7fff);
113
- break;
114
- case 0x1c: /* FCMGT */
115
- gen_helper_advsimd_cgt_f16(tcg_res, tcg_op1, tcg_op2, fpst);
116
- break;
117
- case 0x1d: /* FACGT */
118
- gen_helper_advsimd_acgt_f16(tcg_res, tcg_op1, tcg_op2, fpst);
119
- break;
120
- default:
121
- fprintf(stderr, "%s: insn %#04x, fpop %#2x @ %#" PRIx64 "\n",
122
- __func__, insn, fpopcode, s->pc);
123
- g_assert_not_reached();
124
+ read_vec_element_i32(s, tcg_op1, passreg, passelt, MO_16);
125
+ read_vec_element_i32(s, tcg_op2, passreg, passelt + 1, MO_16);
126
+ tcg_res[pass] = tcg_temp_new_i32();
127
+
128
+ switch (fpopcode) {
129
+ case 0x10: /* FMAXNMP */
130
+ gen_helper_advsimd_maxnumh(tcg_res[pass], tcg_op1, tcg_op2,
131
+ fpst);
132
+ break;
133
+ case 0x12: /* FADDP */
134
+ gen_helper_advsimd_addh(tcg_res[pass], tcg_op1, tcg_op2, fpst);
135
+ break;
136
+ case 0x16: /* FMAXP */
137
+ gen_helper_advsimd_maxh(tcg_res[pass], tcg_op1, tcg_op2, fpst);
138
+ break;
139
+ case 0x18: /* FMINNMP */
140
+ gen_helper_advsimd_minnumh(tcg_res[pass], tcg_op1, tcg_op2,
141
+ fpst);
142
+ break;
143
+ case 0x1e: /* FMINP */
144
+ gen_helper_advsimd_minh(tcg_res[pass], tcg_op1, tcg_op2, fpst);
145
+ break;
146
+ default:
147
+ g_assert_not_reached();
148
+ }
149
+ }
150
+
151
+ for (pass = 0; pass < maxpass; pass++) {
152
+ write_vec_element_i32(s, tcg_res[pass], rd, pass, MO_16);
153
+ tcg_temp_free_i32(tcg_res[pass]);
154
}
155
156
- write_vec_element_i32(s, tcg_res, rd, pass, MO_16);
157
- tcg_temp_free_i32(tcg_res);
158
tcg_temp_free_i32(tcg_op1);
159
tcg_temp_free_i32(tcg_op2);
160
+
161
+ } else {
162
+ for (pass = 0; pass < elements; pass++) {
163
+ TCGv_i32 tcg_op1 = tcg_temp_new_i32();
164
+ TCGv_i32 tcg_op2 = tcg_temp_new_i32();
165
+ TCGv_i32 tcg_res = tcg_temp_new_i32();
166
+
167
+ read_vec_element_i32(s, tcg_op1, rn, pass, MO_16);
168
+ read_vec_element_i32(s, tcg_op2, rm, pass, MO_16);
169
+
170
+ switch (fpopcode) {
171
+ case 0x0: /* FMAXNM */
172
+ gen_helper_advsimd_maxnumh(tcg_res, tcg_op1, tcg_op2, fpst);
173
+ break;
174
+ case 0x1: /* FMLA */
175
+ read_vec_element_i32(s, tcg_res, rd, pass, MO_16);
176
+ gen_helper_advsimd_muladdh(tcg_res, tcg_op1, tcg_op2, tcg_res,
177
+ fpst);
178
+ break;
179
+ case 0x2: /* FADD */
180
+ gen_helper_advsimd_addh(tcg_res, tcg_op1, tcg_op2, fpst);
181
+ break;
182
+ case 0x3: /* FMULX */
183
+ gen_helper_advsimd_mulxh(tcg_res, tcg_op1, tcg_op2, fpst);
184
+ break;
185
+ case 0x4: /* FCMEQ */
186
+ gen_helper_advsimd_ceq_f16(tcg_res, tcg_op1, tcg_op2, fpst);
187
+ break;
188
+ case 0x6: /* FMAX */
189
+ gen_helper_advsimd_maxh(tcg_res, tcg_op1, tcg_op2, fpst);
190
+ break;
191
+ case 0x7: /* FRECPS */
192
+ gen_helper_recpsf_f16(tcg_res, tcg_op1, tcg_op2, fpst);
193
+ break;
194
+ case 0x8: /* FMINNM */
195
+ gen_helper_advsimd_minnumh(tcg_res, tcg_op1, tcg_op2, fpst);
196
+ break;
197
+ case 0x9: /* FMLS */
198
+ /* As usual for ARM, separate negation for fused multiply-add */
199
+ tcg_gen_xori_i32(tcg_op1, tcg_op1, 0x8000);
200
+ read_vec_element_i32(s, tcg_res, rd, pass, MO_16);
201
+ gen_helper_advsimd_muladdh(tcg_res, tcg_op1, tcg_op2, tcg_res,
202
+ fpst);
203
+ break;
204
+ case 0xa: /* FSUB */
205
+ gen_helper_advsimd_subh(tcg_res, tcg_op1, tcg_op2, fpst);
206
+ break;
207
+ case 0xe: /* FMIN */
208
+ gen_helper_advsimd_minh(tcg_res, tcg_op1, tcg_op2, fpst);
209
+ break;
210
+ case 0xf: /* FRSQRTS */
211
+ gen_helper_rsqrtsf_f16(tcg_res, tcg_op1, tcg_op2, fpst);
212
+ break;
213
+ case 0x13: /* FMUL */
214
+ gen_helper_advsimd_mulh(tcg_res, tcg_op1, tcg_op2, fpst);
215
+ break;
216
+ case 0x14: /* FCMGE */
217
+ gen_helper_advsimd_cge_f16(tcg_res, tcg_op1, tcg_op2, fpst);
218
+ break;
219
+ case 0x15: /* FACGE */
220
+ gen_helper_advsimd_acge_f16(tcg_res, tcg_op1, tcg_op2, fpst);
221
+ break;
222
+ case 0x17: /* FDIV */
223
+ gen_helper_advsimd_divh(tcg_res, tcg_op1, tcg_op2, fpst);
224
+ break;
225
+ case 0x1a: /* FABD */
226
+ gen_helper_advsimd_subh(tcg_res, tcg_op1, tcg_op2, fpst);
227
+ tcg_gen_andi_i32(tcg_res, tcg_res, 0x7fff);
228
+ break;
229
+ case 0x1c: /* FCMGT */
230
+ gen_helper_advsimd_cgt_f16(tcg_res, tcg_op1, tcg_op2, fpst);
231
+ break;
232
+ case 0x1d: /* FACGT */
233
+ gen_helper_advsimd_acgt_f16(tcg_res, tcg_op1, tcg_op2, fpst);
234
+ break;
235
+ default:
236
+ fprintf(stderr, "%s: insn %#04x, fpop %#2x @ %#" PRIx64 "\n",
237
+ __func__, insn, fpopcode, s->pc);
238
+ g_assert_not_reached();
239
+ }
240
+
241
+ write_vec_element_i32(s, tcg_res, rd, pass, MO_16);
242
+ tcg_temp_free_i32(tcg_res);
243
+ tcg_temp_free_i32(tcg_op1);
244
+ tcg_temp_free_i32(tcg_op2);
245
+ }
246
}
247
248
tcg_temp_free_ptr(fpst);
249
--
250
2.16.2
251
252
diff view generated by jsdifflib
Deleted patch
1
From: Alex Bennée <alex.bennee@linaro.org>
2
1
3
The helpers use the new re-factored muladd support in SoftFloat for
4
the float16 work.
5
6
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
7
Message-id: 20180227143852.11175-15-alex.bennee@linaro.org
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/translate-a64.c | 82 +++++++++++++++++++++++++++++++++++++---------
12
1 file changed, 66 insertions(+), 16 deletions(-)
13
14
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/translate-a64.c
17
+++ b/target/arm/translate-a64.c
18
@@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn)
19
int rd = extract32(insn, 0, 5);
20
bool is_long = false;
21
bool is_fp = false;
22
+ bool is_fp16 = false;
23
int index;
24
TCGv_ptr fpst;
25
26
@@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn)
27
}
28
/* fall through */
29
case 0x9: /* FMUL, FMULX */
30
- if (!extract32(size, 1, 1)) {
31
+ if (size == 1) {
32
unallocated_encoding(s);
33
return;
34
}
35
@@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn)
36
}
37
38
if (is_fp) {
39
- /* low bit of size indicates single/double */
40
- size = extract32(size, 0, 1) ? 3 : 2;
41
- if (size == 2) {
42
+ /* convert insn encoded size to TCGMemOp size */
43
+ switch (size) {
44
+ case 2: /* single precision */
45
+ size = MO_32;
46
index = h << 1 | l;
47
- } else {
48
+ rm |= (m << 4);
49
+ break;
50
+ case 3: /* double precision */
51
+ size = MO_64;
52
if (l || !is_q) {
53
unallocated_encoding(s);
54
return;
55
}
56
index = h;
57
+ rm |= (m << 4);
58
+ break;
59
+ case 0: /* half precision */
60
+ size = MO_16;
61
+ index = h << 2 | l << 1 | m;
62
+ is_fp16 = true;
63
+ if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) {
64
+ break;
65
+ }
66
+ /* fallthru */
67
+ default: /* unallocated */
68
+ unallocated_encoding(s);
69
+ return;
70
}
71
- rm |= (m << 4);
72
} else {
73
switch (size) {
74
case 1:
75
@@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn)
76
}
77
78
if (is_fp) {
79
- fpst = get_fpstatus_ptr(false);
80
+ fpst = get_fpstatus_ptr(is_fp16);
81
} else {
82
fpst = NULL;
83
}
84
@@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn)
85
break;
86
}
87
case 0x5: /* FMLS */
88
- /* As usual for ARM, separate negation for fused multiply-add */
89
- gen_helper_vfp_negs(tcg_op, tcg_op);
90
- /* fall through */
91
case 0x1: /* FMLA */
92
- read_vec_element_i32(s, tcg_res, rd, pass, MO_32);
93
- gen_helper_vfp_muladds(tcg_res, tcg_op, tcg_idx, tcg_res, fpst);
94
+ read_vec_element_i32(s, tcg_res, rd, pass,
95
+ is_scalar ? size : MO_32);
96
+ switch (size) {
97
+ case 1:
98
+ if (opcode == 0x5) {
99
+ /* As usual for ARM, separate negation for fused
100
+ * multiply-add */
101
+ tcg_gen_xori_i32(tcg_op, tcg_op, 0x80008000);
102
+ }
103
+ gen_helper_advsimd_muladdh(tcg_res, tcg_op, tcg_idx,
104
+ tcg_res, fpst);
105
+ break;
106
+ case 2:
107
+ if (opcode == 0x5) {
108
+ /* As usual for ARM, separate negation for
109
+ * fused multiply-add */
110
+ tcg_gen_xori_i32(tcg_op, tcg_op, 0x80000000);
111
+ }
112
+ gen_helper_vfp_muladds(tcg_res, tcg_op, tcg_idx,
113
+ tcg_res, fpst);
114
+ break;
115
+ default:
116
+ g_assert_not_reached();
117
+ }
118
break;
119
case 0x9: /* FMUL, FMULX */
120
- if (u) {
121
- gen_helper_vfp_mulxs(tcg_res, tcg_op, tcg_idx, fpst);
122
- } else {
123
- gen_helper_vfp_muls(tcg_res, tcg_op, tcg_idx, fpst);
124
+ switch (size) {
125
+ case 1:
126
+ if (u) {
127
+ gen_helper_advsimd_mulxh(tcg_res, tcg_op, tcg_idx,
128
+ fpst);
129
+ } else {
130
+ g_assert_not_reached();
131
+ }
132
+ break;
133
+ case 2:
134
+ if (u) {
135
+ gen_helper_vfp_mulxs(tcg_res, tcg_op, tcg_idx, fpst);
136
+ } else {
137
+ gen_helper_vfp_muls(tcg_res, tcg_op, tcg_idx, fpst);
138
+ }
139
+ break;
140
+ default:
141
+ g_assert_not_reached();
142
}
143
break;
144
case 0xc: /* SQDMULH */
145
--
146
2.16.2
147
148
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
Implement the MVE shifts by immediate, which perform shifts
2
2
on a single general-purpose register.
3
A bunch of the vectorised bitwise operations just operate on larger
3
4
chunks at a time. We can do the same for the new half-precision
4
These patterns overlap with the long-shift-by-immediates,
5
operations by introducing some TWOHALFOP helpers which work on each
5
so we have to rearrange the grouping a little here.
6
half of a pair of half-precision operations at once.
6
7
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Hopefully all this hoop jumping will get simpler once we have
9
generically vectorised helpers here.
10
11
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
12
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
Message-id: 20180227143852.11175-16-alex.bennee@linaro.org
9
Message-id: 20210628135835.6690-18-peter.maydell@linaro.org
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
---
10
---
16
target/arm/helper-a64.h | 10 ++++++++++
11
target/arm/helper-mve.h | 3 ++
17
target/arm/helper-a64.c | 46 +++++++++++++++++++++++++++++++++++++++++++++-
12
target/arm/translate.h | 1 +
18
target/arm/translate-a64.c | 26 +++++++++++++++++++++-----
13
target/arm/t32.decode | 31 ++++++++++++++-----
19
3 files changed, 76 insertions(+), 6 deletions(-)
14
target/arm/mve_helper.c | 10 ++++++
20
15
target/arm/translate.c | 68 +++++++++++++++++++++++++++++++++++++++--
21
diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h
16
5 files changed, 104 insertions(+), 9 deletions(-)
22
index XXXXXXX..XXXXXXX 100644
17
23
--- a/target/arm/helper-a64.h
18
diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h
24
+++ b/target/arm/helper-a64.h
19
index XXXXXXX..XXXXXXX 100644
25
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(advsimd_acge_f16, i32, f16, f16, ptr)
20
--- a/target/arm/helper-mve.h
26
DEF_HELPER_3(advsimd_acgt_f16, i32, f16, f16, ptr)
21
+++ b/target/arm/helper-mve.h
27
DEF_HELPER_3(advsimd_mulxh, f16, f16, f16, ptr)
22
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_sqrshrl, TCG_CALL_NO_RWG, i64, env, i64, i32)
28
DEF_HELPER_4(advsimd_muladdh, f16, f16, f16, f16, ptr)
23
DEF_HELPER_FLAGS_3(mve_uqrshll, TCG_CALL_NO_RWG, i64, env, i64, i32)
29
+DEF_HELPER_3(advsimd_add2h, i32, i32, i32, ptr)
24
DEF_HELPER_FLAGS_3(mve_sqrshrl48, TCG_CALL_NO_RWG, i64, env, i64, i32)
30
+DEF_HELPER_3(advsimd_sub2h, i32, i32, i32, ptr)
25
DEF_HELPER_FLAGS_3(mve_uqrshll48, TCG_CALL_NO_RWG, i64, env, i64, i32)
31
+DEF_HELPER_3(advsimd_mul2h, i32, i32, i32, ptr)
26
+
32
+DEF_HELPER_3(advsimd_div2h, i32, i32, i32, ptr)
27
+DEF_HELPER_FLAGS_3(mve_uqshl, TCG_CALL_NO_RWG, i32, env, i32, i32)
33
+DEF_HELPER_3(advsimd_max2h, i32, i32, i32, ptr)
28
+DEF_HELPER_FLAGS_3(mve_sqshl, TCG_CALL_NO_RWG, i32, env, i32, i32)
34
+DEF_HELPER_3(advsimd_min2h, i32, i32, i32, ptr)
29
diff --git a/target/arm/translate.h b/target/arm/translate.h
35
+DEF_HELPER_3(advsimd_maxnum2h, i32, i32, i32, ptr)
30
index XXXXXXX..XXXXXXX 100644
36
+DEF_HELPER_3(advsimd_minnum2h, i32, i32, i32, ptr)
31
--- a/target/arm/translate.h
37
+DEF_HELPER_3(advsimd_mulx2h, i32, i32, i32, ptr)
32
+++ b/target/arm/translate.h
38
+DEF_HELPER_4(advsimd_muladd2h, i32, i32, i32, i32, ptr)
33
@@ -XXX,XX +XXX,XX @@ typedef void CryptoThreeOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr);
39
diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c
34
typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp);
40
index XXXXXXX..XXXXXXX 100644
35
typedef void WideShiftImmFn(TCGv_i64, TCGv_i64, int64_t shift);
41
--- a/target/arm/helper-a64.c
36
typedef void WideShiftFn(TCGv_i64, TCGv_ptr, TCGv_i64, TCGv_i32);
42
+++ b/target/arm/helper-a64.c
37
+typedef void ShiftImmFn(TCGv_i32, TCGv_i32, int32_t shift);
43
@@ -XXX,XX +XXX,XX @@ ADVSIMD_HALFOP(max)
38
44
ADVSIMD_HALFOP(minnum)
39
/**
45
ADVSIMD_HALFOP(maxnum)
40
* arm_tbflags_from_tb:
46
41
diff --git a/target/arm/t32.decode b/target/arm/t32.decode
47
+#define ADVSIMD_TWOHALFOP(name) \
42
index XXXXXXX..XXXXXXX 100644
48
+uint32_t ADVSIMD_HELPER(name, 2h)(uint32_t two_a, uint32_t two_b, void *fpstp) \
43
--- a/target/arm/t32.decode
49
+{ \
44
+++ b/target/arm/t32.decode
50
+ float16 a1, a2, b1, b2; \
45
@@ -XXX,XX +XXX,XX @@
51
+ uint32_t r1, r2; \
46
52
+ float_status *fpst = fpstp; \
47
&mve_shl_ri rdalo rdahi shim
53
+ a1 = extract32(two_a, 0, 16); \
48
&mve_shl_rr rdalo rdahi rm
54
+ a2 = extract32(two_a, 16, 16); \
49
+&mve_sh_ri rda shim
55
+ b1 = extract32(two_b, 0, 16); \
50
56
+ b2 = extract32(two_b, 16, 16); \
51
# rdahi: bits [3:1] from insn, bit 0 is 1
57
+ r1 = float16_ ## name(a1, b1, fpst); \
52
# rdalo: bits [3:1] from insn, bit 0 is 0
58
+ r2 = float16_ ## name(a2, b2, fpst); \
53
@@ -XXX,XX +XXX,XX @@
59
+ return deposit32(r1, 16, 16, r2); \
54
&mve_shl_ri shim=%imm5_12_6 rdalo=%rdalo_17 rdahi=%rdahi_9
60
+}
55
@mve_shl_rr ....... .... . ... . rm:4 ... . .. .. .... \
61
+
56
&mve_shl_rr rdalo=%rdalo_17 rdahi=%rdahi_9
62
+ADVSIMD_TWOHALFOP(add)
57
+@mve_sh_ri ....... .... . rda:4 . ... ... . .. .. .... \
63
+ADVSIMD_TWOHALFOP(sub)
58
+ &mve_sh_ri shim=%imm5_12_6
64
+ADVSIMD_TWOHALFOP(mul)
59
65
+ADVSIMD_TWOHALFOP(div)
60
{
66
+ADVSIMD_TWOHALFOP(min)
61
TST_xrri 1110101 0000 1 .... 0 ... 1111 .... .... @S_xrr_shi
67
+ADVSIMD_TWOHALFOP(max)
62
@@ -XXX,XX +XXX,XX @@ BIC_rrri 1110101 0001 . .... 0 ... .... .... .... @s_rrr_shi
68
+ADVSIMD_TWOHALFOP(minnum)
63
# the rest fall through (where ORR_rrri and MOV_rxri will end up
69
+ADVSIMD_TWOHALFOP(maxnum)
64
# handling them as r13 and r15 accesses with the same semantics as A32).
70
+
65
[
71
/* Data processing - scalar floating-point and advanced SIMD */
66
- LSLL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 00 1111 @mve_shl_ri
72
-float16 HELPER(advsimd_mulxh)(float16 a, float16 b, void *fpstp)
67
- LSRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 01 1111 @mve_shl_ri
73
+static float16 float16_mulx(float16 a, float16 b, void *fpstp)
68
- ASRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 10 1111 @mve_shl_ri
74
{
69
+ {
75
float_status *fpst = fpstp;
70
+ UQSHL_ri 1110101 0010 1 .... 0 ... 1111 .. 00 1111 @mve_sh_ri
76
71
+ LSLL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 00 1111 @mve_shl_ri
77
@@ -XXX,XX +XXX,XX @@ float16 HELPER(advsimd_mulxh)(float16 a, float16 b, void *fpstp)
72
+ UQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 00 1111 @mve_shl_ri
78
return float16_mul(a, b, fpst);
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);
79
}
105
}
80
106
+
81
+ADVSIMD_HALFOP(mulx)
107
+uint32_t HELPER(mve_uqshl)(CPUARMState *env, uint32_t n, uint32_t shift)
82
+ADVSIMD_TWOHALFOP(mulx)
108
+{
83
+
109
+ return do_uqrshl_bhs(n, (int8_t)shift, 32, false, &env->QF);
84
/* fused multiply-accumulate */
110
+}
85
float16 HELPER(advsimd_muladdh)(float16 a, float16 b, float16 c, void *fpstp)
111
+
86
{
112
+uint32_t HELPER(mve_sqshl)(CPUARMState *env, uint32_t n, uint32_t shift)
87
@@ -XXX,XX +XXX,XX @@ float16 HELPER(advsimd_muladdh)(float16 a, float16 b, float16 c, void *fpstp)
113
+{
88
return float16_muladd(a, b, c, 0, fpst);
114
+ return do_sqrshl_bhs(n, (int8_t)shift, 32, false, &env->QF);
115
+}
116
diff --git a/target/arm/translate.c b/target/arm/translate.c
117
index XXXXXXX..XXXXXXX 100644
118
--- a/target/arm/translate.c
119
+++ b/target/arm/translate.c
120
@@ -XXX,XX +XXX,XX @@ static void gen_srshr16_i64(TCGv_i64 d, TCGv_i64 a, int64_t sh)
121
122
static void gen_srshr32_i32(TCGv_i32 d, TCGv_i32 a, int32_t sh)
123
{
124
- TCGv_i32 t = tcg_temp_new_i32();
125
+ TCGv_i32 t;
126
127
+ /* Handle shift by the input size for the benefit of trans_SRSHR_ri */
128
+ if (sh == 32) {
129
+ tcg_gen_movi_i32(d, 0);
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);
89
}
154
}
90
155
91
+uint32_t HELPER(advsimd_muladd2h)(uint32_t two_a, uint32_t two_b,
156
+static bool do_mve_sh_ri(DisasContext *s, arg_mve_sh_ri *a, ShiftImmFn *fn)
92
+ uint32_t two_c, void *fpstp)
157
+{
93
+{
158
+ if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) {
94
+ float_status *fpst = fpstp;
159
+ /* Decode falls through to ORR/MOV UNPREDICTABLE handling */
95
+ float16 a1, a2, b1, b2, c1, c2;
160
+ return false;
96
+ uint32_t r1, r2;
161
+ }
97
+ a1 = extract32(two_a, 0, 16);
162
+ if (!dc_isar_feature(aa32_mve, s) ||
98
+ a2 = extract32(two_a, 16, 16);
163
+ !arm_dc_feature(s, ARM_FEATURE_M_MAIN) ||
99
+ b1 = extract32(two_b, 0, 16);
164
+ a->rda == 13 || a->rda == 15) {
100
+ b2 = extract32(two_b, 16, 16);
165
+ /* These rda cases are UNPREDICTABLE; we choose to UNDEF */
101
+ c1 = extract32(two_c, 0, 16);
166
+ unallocated_encoding(s);
102
+ c2 = extract32(two_c, 16, 16);
167
+ return true;
103
+ r1 = float16_muladd(a1, b1, c1, 0, fpst);
168
+ }
104
+ r2 = float16_muladd(a2, b2, c2, 0, fpst);
169
+
105
+ return deposit32(r1, 16, 16, r2);
170
+ if (a->shim == 0) {
171
+ a->shim = 32;
172
+ }
173
+ fn(cpu_R[a->rda], cpu_R[a->rda], a->shim);
174
+
175
+ return true;
176
+}
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);
106
+}
206
+}
107
+
207
+
108
/*
208
/*
109
* Floating point comparisons produce an integer result. Softfloat
209
* Multiply and multiply accumulate
110
* routines return float_relation types which we convert to the 0/-1
210
*/
111
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
112
index XXXXXXX..XXXXXXX 100644
113
--- a/target/arm/translate-a64.c
114
+++ b/target/arm/translate-a64.c
115
@@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn)
116
* multiply-add */
117
tcg_gen_xori_i32(tcg_op, tcg_op, 0x80008000);
118
}
119
- gen_helper_advsimd_muladdh(tcg_res, tcg_op, tcg_idx,
120
- tcg_res, fpst);
121
+ if (is_scalar) {
122
+ gen_helper_advsimd_muladdh(tcg_res, tcg_op, tcg_idx,
123
+ tcg_res, fpst);
124
+ } else {
125
+ gen_helper_advsimd_muladd2h(tcg_res, tcg_op, tcg_idx,
126
+ tcg_res, fpst);
127
+ }
128
break;
129
case 2:
130
if (opcode == 0x5) {
131
@@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn)
132
switch (size) {
133
case 1:
134
if (u) {
135
- gen_helper_advsimd_mulxh(tcg_res, tcg_op, tcg_idx,
136
- fpst);
137
+ if (is_scalar) {
138
+ gen_helper_advsimd_mulxh(tcg_res, tcg_op,
139
+ tcg_idx, fpst);
140
+ } else {
141
+ gen_helper_advsimd_mulx2h(tcg_res, tcg_op,
142
+ tcg_idx, fpst);
143
+ }
144
} else {
145
- g_assert_not_reached();
146
+ if (is_scalar) {
147
+ gen_helper_advsimd_mulh(tcg_res, tcg_op,
148
+ tcg_idx, fpst);
149
+ } else {
150
+ gen_helper_advsimd_mul2h(tcg_res, tcg_op,
151
+ tcg_idx, fpst);
152
+ }
153
}
154
break;
155
case 2:
156
--
211
--
157
2.16.2
212
2.20.1
158
213
159
214
diff view generated by jsdifflib
Deleted patch
1
From: Alex Bennée <alex.bennee@linaro.org>
2
1
3
I re-use the existing handle_2misc_fcmp_zero handler and tweak it
4
slightly to deal with the half-precision case.
5
6
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20180227143852.11175-20-alex.bennee@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/translate-a64.c | 80 +++++++++++++++++++++++++++++++++-------------
12
1 file changed, 57 insertions(+), 23 deletions(-)
13
14
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/translate-a64.c
17
+++ b/target/arm/translate-a64.c
18
@@ -XXX,XX +XXX,XX @@ static void handle_2misc_fcmp_zero(DisasContext *s, int opcode,
19
bool is_scalar, bool is_u, bool is_q,
20
int size, int rn, int rd)
21
{
22
- bool is_double = (size == 3);
23
+ bool is_double = (size == MO_64);
24
TCGv_ptr fpst;
25
26
if (!fp_access_check(s)) {
27
return;
28
}
29
30
- fpst = get_fpstatus_ptr(false);
31
+ fpst = get_fpstatus_ptr(size == MO_16);
32
33
if (is_double) {
34
TCGv_i64 tcg_op = tcg_temp_new_i64();
35
@@ -XXX,XX +XXX,XX @@ static void handle_2misc_fcmp_zero(DisasContext *s, int opcode,
36
bool swap = false;
37
int pass, maxpasses;
38
39
- switch (opcode) {
40
- case 0x2e: /* FCMLT (zero) */
41
- swap = true;
42
- /* fall through */
43
- case 0x2c: /* FCMGT (zero) */
44
- genfn = gen_helper_neon_cgt_f32;
45
- break;
46
- case 0x2d: /* FCMEQ (zero) */
47
- genfn = gen_helper_neon_ceq_f32;
48
- break;
49
- case 0x6d: /* FCMLE (zero) */
50
- swap = true;
51
- /* fall through */
52
- case 0x6c: /* FCMGE (zero) */
53
- genfn = gen_helper_neon_cge_f32;
54
- break;
55
- default:
56
- g_assert_not_reached();
57
+ if (size == MO_16) {
58
+ switch (opcode) {
59
+ case 0x2e: /* FCMLT (zero) */
60
+ swap = true;
61
+ /* fall through */
62
+ case 0x2c: /* FCMGT (zero) */
63
+ genfn = gen_helper_advsimd_cgt_f16;
64
+ break;
65
+ case 0x2d: /* FCMEQ (zero) */
66
+ genfn = gen_helper_advsimd_ceq_f16;
67
+ break;
68
+ case 0x6d: /* FCMLE (zero) */
69
+ swap = true;
70
+ /* fall through */
71
+ case 0x6c: /* FCMGE (zero) */
72
+ genfn = gen_helper_advsimd_cge_f16;
73
+ break;
74
+ default:
75
+ g_assert_not_reached();
76
+ }
77
+ } else {
78
+ switch (opcode) {
79
+ case 0x2e: /* FCMLT (zero) */
80
+ swap = true;
81
+ /* fall through */
82
+ case 0x2c: /* FCMGT (zero) */
83
+ genfn = gen_helper_neon_cgt_f32;
84
+ break;
85
+ case 0x2d: /* FCMEQ (zero) */
86
+ genfn = gen_helper_neon_ceq_f32;
87
+ break;
88
+ case 0x6d: /* FCMLE (zero) */
89
+ swap = true;
90
+ /* fall through */
91
+ case 0x6c: /* FCMGE (zero) */
92
+ genfn = gen_helper_neon_cge_f32;
93
+ break;
94
+ default:
95
+ g_assert_not_reached();
96
+ }
97
}
98
99
if (is_scalar) {
100
maxpasses = 1;
101
} else {
102
- maxpasses = is_q ? 4 : 2;
103
+ int vector_size = 8 << is_q;
104
+ maxpasses = vector_size >> size;
105
}
106
107
for (pass = 0; pass < maxpasses; pass++) {
108
- read_vec_element_i32(s, tcg_op, rn, pass, MO_32);
109
+ read_vec_element_i32(s, tcg_op, rn, pass, size);
110
if (swap) {
111
genfn(tcg_res, tcg_zero, tcg_op, fpst);
112
} else {
113
@@ -XXX,XX +XXX,XX @@ static void handle_2misc_fcmp_zero(DisasContext *s, int opcode,
114
if (is_scalar) {
115
write_fp_sreg(s, rd, tcg_res);
116
} else {
117
- write_vec_element_i32(s, tcg_res, rd, pass, MO_32);
118
+ write_vec_element_i32(s, tcg_res, rd, pass, size);
119
}
120
}
121
tcg_temp_free_i32(tcg_res);
122
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
123
fpop = deposit32(opcode, 5, 1, a);
124
fpop = deposit32(fpop, 6, 1, u);
125
126
+ rd = extract32(insn, 0, 5);
127
+ rn = extract32(insn, 5, 5);
128
+
129
switch (fpop) {
130
+ break;
131
+ case 0x2c: /* FCMGT (zero) */
132
+ case 0x2d: /* FCMEQ (zero) */
133
+ case 0x2e: /* FCMLT (zero) */
134
+ case 0x6c: /* FCMGE (zero) */
135
+ case 0x6d: /* FCMLE (zero) */
136
+ handle_2misc_fcmp_zero(s, fpop, is_scalar, 0, is_q, MO_16, rn, rd);
137
+ return;
138
case 0x18: /* FRINTN */
139
need_rmode = true;
140
only_in_vector = true;
141
--
142
2.16.2
143
144
diff view generated by jsdifflib
Deleted patch
1
From: Alex Bennée <alex.bennee@linaro.org>
2
1
3
I've re-factored the handle_simd_intfp_conv helper to properly handle
4
half-precision as well as call plain conversion helpers when we are
5
not doing fixed point conversion.
6
7
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20180227143852.11175-21-alex.bennee@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
target/arm/helper.h | 10 ++++
13
target/arm/helper.c | 4 ++
14
target/arm/translate-a64.c | 122 ++++++++++++++++++++++++++++++++++-----------
15
3 files changed, 108 insertions(+), 28 deletions(-)
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_3(vfp_cmped, void, f64, f64, env)
22
DEF_HELPER_2(vfp_fcvtds, f64, f32, env)
23
DEF_HELPER_2(vfp_fcvtsd, f32, f64, env)
24
25
+DEF_HELPER_2(vfp_uitoh, f16, i32, ptr)
26
DEF_HELPER_2(vfp_uitos, f32, i32, ptr)
27
DEF_HELPER_2(vfp_uitod, f64, i32, ptr)
28
+DEF_HELPER_2(vfp_sitoh, f16, i32, ptr)
29
DEF_HELPER_2(vfp_sitos, f32, i32, ptr)
30
DEF_HELPER_2(vfp_sitod, f64, i32, ptr)
31
32
+DEF_HELPER_2(vfp_touih, i32, f16, ptr)
33
DEF_HELPER_2(vfp_touis, i32, f32, ptr)
34
DEF_HELPER_2(vfp_touid, i32, f64, ptr)
35
+DEF_HELPER_2(vfp_touizh, i32, f16, ptr)
36
DEF_HELPER_2(vfp_touizs, i32, f32, ptr)
37
DEF_HELPER_2(vfp_touizd, i32, f64, ptr)
38
+DEF_HELPER_2(vfp_tosih, i32, f16, ptr)
39
DEF_HELPER_2(vfp_tosis, i32, f32, ptr)
40
DEF_HELPER_2(vfp_tosid, i32, f64, ptr)
41
+DEF_HELPER_2(vfp_tosizh, i32, f16, ptr)
42
DEF_HELPER_2(vfp_tosizs, i32, f32, ptr)
43
DEF_HELPER_2(vfp_tosizd, i32, f64, ptr)
44
45
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(vfp_toshd_round_to_zero, i64, f64, i32, ptr)
46
DEF_HELPER_3(vfp_tosld_round_to_zero, i64, f64, i32, ptr)
47
DEF_HELPER_3(vfp_touhd_round_to_zero, i64, f64, i32, ptr)
48
DEF_HELPER_3(vfp_tould_round_to_zero, i64, f64, i32, ptr)
49
+DEF_HELPER_3(vfp_toulh, i32, f16, i32, ptr)
50
+DEF_HELPER_3(vfp_toslh, i32, f16, i32, ptr)
51
DEF_HELPER_3(vfp_toshs, i32, f32, i32, ptr)
52
DEF_HELPER_3(vfp_tosls, i32, f32, i32, ptr)
53
DEF_HELPER_3(vfp_tosqs, i64, f32, i32, ptr)
54
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(vfp_sqtod, f64, i64, i32, ptr)
55
DEF_HELPER_3(vfp_uhtod, f64, i64, i32, ptr)
56
DEF_HELPER_3(vfp_ultod, f64, i64, i32, ptr)
57
DEF_HELPER_3(vfp_uqtod, f64, i64, i32, ptr)
58
+DEF_HELPER_3(vfp_sltoh, f16, i32, i32, ptr)
59
+DEF_HELPER_3(vfp_ultoh, f16, i32, i32, ptr)
60
61
DEF_HELPER_FLAGS_2(set_rmode, TCG_CALL_NO_RWG, i32, i32, ptr)
62
DEF_HELPER_FLAGS_2(set_neon_rmode, TCG_CALL_NO_RWG, i32, i32, env)
63
diff --git a/target/arm/helper.c b/target/arm/helper.c
64
index XXXXXXX..XXXXXXX 100644
65
--- a/target/arm/helper.c
66
+++ b/target/arm/helper.c
67
@@ -XXX,XX +XXX,XX @@ CONV_ITOF(vfp_##name##to##p, fsz, sign) \
68
CONV_FTOI(vfp_to##name##p, fsz, sign, ) \
69
CONV_FTOI(vfp_to##name##z##p, fsz, sign, _round_to_zero)
70
71
+FLOAT_CONVS(si, h, 16, )
72
FLOAT_CONVS(si, s, 32, )
73
FLOAT_CONVS(si, d, 64, )
74
+FLOAT_CONVS(ui, h, 16, u)
75
FLOAT_CONVS(ui, s, 32, u)
76
FLOAT_CONVS(ui, d, 64, u)
77
78
@@ -XXX,XX +XXX,XX @@ VFP_CONV_FIX_A64(sq, s, 32, 64, int64)
79
VFP_CONV_FIX(uh, s, 32, 32, uint16)
80
VFP_CONV_FIX(ul, s, 32, 32, uint32)
81
VFP_CONV_FIX_A64(uq, s, 32, 64, uint64)
82
+VFP_CONV_FIX_A64(sl, h, 16, 32, int32)
83
+VFP_CONV_FIX_A64(ul, h, 16, 32, uint32)
84
#undef VFP_CONV_FIX
85
#undef VFP_CONV_FIX_FLOAT
86
#undef VFP_CONV_FLOAT_FIX_ROUND
87
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
88
index XXXXXXX..XXXXXXX 100644
89
--- a/target/arm/translate-a64.c
90
+++ b/target/arm/translate-a64.c
91
@@ -XXX,XX +XXX,XX @@ static void handle_simd_intfp_conv(DisasContext *s, int rd, int rn,
92
int elements, int is_signed,
93
int fracbits, int size)
94
{
95
- bool is_double = size == 3 ? true : false;
96
- TCGv_ptr tcg_fpst = get_fpstatus_ptr(false);
97
- TCGv_i32 tcg_shift = tcg_const_i32(fracbits);
98
- TCGv_i64 tcg_int = tcg_temp_new_i64();
99
+ TCGv_ptr tcg_fpst = get_fpstatus_ptr(size == MO_16);
100
+ TCGv_i32 tcg_shift = NULL;
101
+
102
TCGMemOp mop = size | (is_signed ? MO_SIGN : 0);
103
int pass;
104
105
- for (pass = 0; pass < elements; pass++) {
106
- read_vec_element(s, tcg_int, rn, pass, mop);
107
+ if (fracbits || size == MO_64) {
108
+ tcg_shift = tcg_const_i32(fracbits);
109
+ }
110
+
111
+ if (size == MO_64) {
112
+ TCGv_i64 tcg_int64 = tcg_temp_new_i64();
113
+ TCGv_i64 tcg_double = tcg_temp_new_i64();
114
+
115
+ for (pass = 0; pass < elements; pass++) {
116
+ read_vec_element(s, tcg_int64, rn, pass, mop);
117
118
- if (is_double) {
119
- TCGv_i64 tcg_double = tcg_temp_new_i64();
120
if (is_signed) {
121
- gen_helper_vfp_sqtod(tcg_double, tcg_int,
122
+ gen_helper_vfp_sqtod(tcg_double, tcg_int64,
123
tcg_shift, tcg_fpst);
124
} else {
125
- gen_helper_vfp_uqtod(tcg_double, tcg_int,
126
+ gen_helper_vfp_uqtod(tcg_double, tcg_int64,
127
tcg_shift, tcg_fpst);
128
}
129
if (elements == 1) {
130
@@ -XXX,XX +XXX,XX @@ static void handle_simd_intfp_conv(DisasContext *s, int rd, int rn,
131
} else {
132
write_vec_element(s, tcg_double, rd, pass, MO_64);
133
}
134
- tcg_temp_free_i64(tcg_double);
135
- } else {
136
- TCGv_i32 tcg_single = tcg_temp_new_i32();
137
- if (is_signed) {
138
- gen_helper_vfp_sqtos(tcg_single, tcg_int,
139
- tcg_shift, tcg_fpst);
140
- } else {
141
- gen_helper_vfp_uqtos(tcg_single, tcg_int,
142
- tcg_shift, tcg_fpst);
143
- }
144
- if (elements == 1) {
145
- write_fp_sreg(s, rd, tcg_single);
146
- } else {
147
- write_vec_element_i32(s, tcg_single, rd, pass, MO_32);
148
- }
149
- tcg_temp_free_i32(tcg_single);
150
}
151
+
152
+ tcg_temp_free_i64(tcg_int64);
153
+ tcg_temp_free_i64(tcg_double);
154
+
155
+ } else {
156
+ TCGv_i32 tcg_int32 = tcg_temp_new_i32();
157
+ TCGv_i32 tcg_float = tcg_temp_new_i32();
158
+
159
+ for (pass = 0; pass < elements; pass++) {
160
+ read_vec_element_i32(s, tcg_int32, rn, pass, mop);
161
+
162
+ switch (size) {
163
+ case MO_32:
164
+ if (fracbits) {
165
+ if (is_signed) {
166
+ gen_helper_vfp_sltos(tcg_float, tcg_int32,
167
+ tcg_shift, tcg_fpst);
168
+ } else {
169
+ gen_helper_vfp_ultos(tcg_float, tcg_int32,
170
+ tcg_shift, tcg_fpst);
171
+ }
172
+ } else {
173
+ if (is_signed) {
174
+ gen_helper_vfp_sitos(tcg_float, tcg_int32, tcg_fpst);
175
+ } else {
176
+ gen_helper_vfp_uitos(tcg_float, tcg_int32, tcg_fpst);
177
+ }
178
+ }
179
+ break;
180
+ case MO_16:
181
+ if (fracbits) {
182
+ if (is_signed) {
183
+ gen_helper_vfp_sltoh(tcg_float, tcg_int32,
184
+ tcg_shift, tcg_fpst);
185
+ } else {
186
+ gen_helper_vfp_ultoh(tcg_float, tcg_int32,
187
+ tcg_shift, tcg_fpst);
188
+ }
189
+ } else {
190
+ if (is_signed) {
191
+ gen_helper_vfp_sitoh(tcg_float, tcg_int32, tcg_fpst);
192
+ } else {
193
+ gen_helper_vfp_uitoh(tcg_float, tcg_int32, tcg_fpst);
194
+ }
195
+ }
196
+ break;
197
+ default:
198
+ g_assert_not_reached();
199
+ }
200
+
201
+ if (elements == 1) {
202
+ write_fp_sreg(s, rd, tcg_float);
203
+ } else {
204
+ write_vec_element_i32(s, tcg_float, rd, pass, size);
205
+ }
206
+ }
207
+
208
+ tcg_temp_free_i32(tcg_int32);
209
+ tcg_temp_free_i32(tcg_float);
210
}
211
212
- tcg_temp_free_i64(tcg_int);
213
tcg_temp_free_ptr(tcg_fpst);
214
- tcg_temp_free_i32(tcg_shift);
215
+ if (tcg_shift) {
216
+ tcg_temp_free_i32(tcg_shift);
217
+ }
218
219
clear_vec_high(s, elements << size == 16, rd);
220
}
221
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
222
rn = extract32(insn, 5, 5);
223
224
switch (fpop) {
225
+ case 0x1d: /* SCVTF */
226
+ case 0x5d: /* UCVTF */
227
+ {
228
+ int elements;
229
+
230
+ if (is_scalar) {
231
+ elements = 1;
232
+ } else {
233
+ elements = (is_q ? 8 : 4);
234
+ }
235
+
236
+ if (!fp_access_check(s)) {
237
+ return;
238
+ }
239
+ handle_simd_intfp_conv(s, rd, rn, elements, !u, 0, MO_16);
240
+ return;
241
+ }
242
break;
243
case 0x2c: /* FCMGT (zero) */
244
case 0x2d: /* FCMEQ (zero) */
245
--
246
2.16.2
247
248
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
Implement the MVE shifts by register, which perform
2
shifts on a single general-purpose register.
2
3
3
It looks like the ARM ARM has simplified the pseudo code for the
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
calculation which is done on a fixed point 9 bit integer maths. So
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
while adding f16 we can also clean this up to be a little less heavy
6
Message-id: 20210628135835.6690-19-peter.maydell@linaro.org
6
on the floating point and just return the fractional part and leave
7
---
7
the calle's to do the final packing of the result.
8
target/arm/helper-mve.h | 2 ++
9
target/arm/translate.h | 1 +
10
target/arm/t32.decode | 18 ++++++++++++++----
11
target/arm/mve_helper.c | 10 ++++++++++
12
target/arm/translate.c | 30 ++++++++++++++++++++++++++++++
13
5 files changed, 57 insertions(+), 4 deletions(-)
8
14
9
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
15
diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20180227143852.11175-23-alex.bennee@linaro.org
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
14
target/arm/helper.h | 1 +
15
target/arm/helper.c | 226 +++++++++++++++++++++++++++++-----------------------
16
2 files changed, 129 insertions(+), 98 deletions(-)
17
18
diff --git a/target/arm/helper.h b/target/arm/helper.h
19
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/helper.h
17
--- a/target/arm/helper-mve.h
21
+++ b/target/arm/helper.h
18
+++ b/target/arm/helper-mve.h
22
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_4(vfp_muladds, f32, f32, f32, f32, ptr)
19
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_uqrshll48, TCG_CALL_NO_RWG, i64, env, i64, i32)
23
20
24
DEF_HELPER_3(recps_f32, f32, f32, f32, env)
21
DEF_HELPER_FLAGS_3(mve_uqshl, TCG_CALL_NO_RWG, i32, env, i32, i32)
25
DEF_HELPER_3(rsqrts_f32, f32, f32, f32, env)
22
DEF_HELPER_FLAGS_3(mve_sqshl, TCG_CALL_NO_RWG, i32, env, i32, i32)
26
+DEF_HELPER_FLAGS_2(recpe_f16, TCG_CALL_NO_RWG, f16, f16, ptr)
23
+DEF_HELPER_FLAGS_3(mve_uqrshl, TCG_CALL_NO_RWG, i32, env, i32, i32)
27
DEF_HELPER_FLAGS_2(recpe_f32, TCG_CALL_NO_RWG, f32, f32, ptr)
24
+DEF_HELPER_FLAGS_3(mve_sqrshr, TCG_CALL_NO_RWG, i32, env, i32, i32)
28
DEF_HELPER_FLAGS_2(recpe_f64, TCG_CALL_NO_RWG, f64, f64, ptr)
25
diff --git a/target/arm/translate.h b/target/arm/translate.h
29
DEF_HELPER_FLAGS_2(rsqrte_f32, TCG_CALL_NO_RWG, f32, f32, ptr)
30
diff --git a/target/arm/helper.c b/target/arm/helper.c
31
index XXXXXXX..XXXXXXX 100644
26
index XXXXXXX..XXXXXXX 100644
32
--- a/target/arm/helper.c
27
--- a/target/arm/translate.h
33
+++ b/target/arm/helper.c
28
+++ b/target/arm/translate.h
34
@@ -XXX,XX +XXX,XX @@ float32 HELPER(rsqrts_f32)(float32 a, float32 b, CPUARMState *env)
29
@@ -XXX,XX +XXX,XX @@ typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp);
35
* int->float conversions at run-time. */
30
typedef void WideShiftImmFn(TCGv_i64, TCGv_i64, int64_t shift);
36
#define float64_256 make_float64(0x4070000000000000LL)
31
typedef void WideShiftFn(TCGv_i64, TCGv_ptr, TCGv_i64, TCGv_i32);
37
#define float64_512 make_float64(0x4080000000000000LL)
32
typedef void ShiftImmFn(TCGv_i32, TCGv_i32, int32_t shift);
38
+#define float16_maxnorm make_float16(0x7bff)
33
+typedef void ShiftFn(TCGv_i32, TCGv_ptr, TCGv_i32, TCGv_i32);
39
#define float32_maxnorm make_float32(0x7f7fffff)
34
40
#define float64_maxnorm make_float64(0x7fefffffffffffffLL)
35
/**
41
36
* arm_tbflags_from_tb:
42
/* Reciprocal functions
37
diff --git a/target/arm/t32.decode b/target/arm/t32.decode
43
*
38
index XXXXXXX..XXXXXXX 100644
44
* The algorithm that must be used to calculate the estimate
39
--- a/target/arm/t32.decode
45
- * is specified by the ARM ARM, see FPRecipEstimate()
40
+++ b/target/arm/t32.decode
46
+ * is specified by the ARM ARM, see FPRecipEstimate()/RecipEstimate
41
@@ -XXX,XX +XXX,XX @@
47
*/
42
&mve_shl_ri rdalo rdahi shim
48
43
&mve_shl_rr rdalo rdahi rm
49
-static float64 recip_estimate(float64 a, float_status *real_fp_status)
44
&mve_sh_ri rda shim
50
+/* See RecipEstimate()
45
+&mve_sh_rr rda rm
51
+ *
46
52
+ * input is a 9 bit fixed point number
47
# rdahi: bits [3:1] from insn, bit 0 is 1
53
+ * input range 256 .. 511 for a number from 0.5 <= x < 1.0.
48
# rdalo: bits [3:1] from insn, bit 0 is 0
54
+ * result range 256 .. 511 for a number from 1.0 to 511/256.
49
@@ -XXX,XX +XXX,XX @@
55
+ */
50
&mve_shl_rr rdalo=%rdalo_17 rdahi=%rdahi_9
56
+
51
@mve_sh_ri ....... .... . rda:4 . ... ... . .. .. .... \
57
+static int recip_estimate(int input)
52
&mve_sh_ri shim=%imm5_12_6
53
+@mve_sh_rr ....... .... . rda:4 rm:4 .... .... .... &mve_sh_rr
54
58
{
55
{
59
- /* These calculations mustn't set any fp exception flags,
56
TST_xrri 1110101 0000 1 .... 0 ... 1111 .... .... @S_xrr_shi
60
- * so we use a local copy of the fp_status.
57
@@ -XXX,XX +XXX,XX @@ BIC_rrri 1110101 0001 . .... 0 ... .... .... .... @s_rrr_shi
61
- */
58
SQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 11 1111 @mve_shl_ri
62
- float_status dummy_status = *real_fp_status;
63
- float_status *s = &dummy_status;
64
- /* q = (int)(a * 512.0) */
65
- float64 q = float64_mul(float64_512, a, s);
66
- int64_t q_int = float64_to_int64_round_to_zero(q, s);
67
-
68
- /* r = 1.0 / (((double)q + 0.5) / 512.0) */
69
- q = int64_to_float64(q_int, s);
70
- q = float64_add(q, float64_half, s);
71
- q = float64_div(q, float64_512, s);
72
- q = float64_div(float64_one, q, s);
73
-
74
- /* s = (int)(256.0 * r + 0.5) */
75
- q = float64_mul(q, float64_256, s);
76
- q = float64_add(q, float64_half, s);
77
- q_int = float64_to_int64_round_to_zero(q, s);
78
-
79
- /* return (double)s / 256.0 */
80
- return float64_div(int64_to_float64(q_int, s), float64_256, s);
81
+ int a, b, r;
82
+ assert(256 <= input && input < 512);
83
+ a = (input * 2) + 1;
84
+ b = (1 << 19) / a;
85
+ r = (b + 1) >> 1;
86
+ assert(256 <= r && r < 512);
87
+ return r;
88
}
89
90
-/* Common wrapper to call recip_estimate */
91
-static float64 call_recip_estimate(float64 num, int off, float_status *fpst)
92
-{
93
- uint64_t val64 = float64_val(num);
94
- uint64_t frac = extract64(val64, 0, 52);
95
- int64_t exp = extract64(val64, 52, 11);
96
- uint64_t sbit;
97
- float64 scaled, estimate;
98
+/*
99
+ * Common wrapper to call recip_estimate
100
+ *
101
+ * The parameters are exponent and 64 bit fraction (without implicit
102
+ * bit) where the binary point is nominally at bit 52. Returns a
103
+ * float64 which can then be rounded to the appropriate size by the
104
+ * callee.
105
+ */
106
107
- /* Generate the scaled number for the estimate function */
108
- if (exp == 0) {
109
+static uint64_t call_recip_estimate(int *exp, int exp_off, uint64_t frac)
110
+{
111
+ uint32_t scaled, estimate;
112
+ uint64_t result_frac;
113
+ int result_exp;
114
+
115
+ /* Handle sub-normals */
116
+ if (*exp == 0) {
117
if (extract64(frac, 51, 1) == 0) {
118
- exp = -1;
119
- frac = extract64(frac, 0, 50) << 2;
120
+ *exp = -1;
121
+ frac <<= 2;
122
} else {
123
- frac = extract64(frac, 0, 51) << 1;
124
+ frac <<= 1;
125
}
126
}
59
}
127
60
128
- /* scaled = '0' : '01111111110' : fraction<51:44> : Zeros(44); */
61
- LSLL_rr 1110101 0010 1 ... 0 .... ... 1 0000 1101 @mve_shl_rr
129
- scaled = make_float64((0x3feULL << 52)
62
- ASRL_rr 1110101 0010 1 ... 0 .... ... 1 0010 1101 @mve_shl_rr
130
- | extract64(frac, 44, 8) << 44);
63
- UQRSHLL64_rr 1110101 0010 1 ... 1 .... ... 1 0000 1101 @mve_shl_rr
131
+ /* scaled = UInt('1':fraction<51:44>) */
64
- SQRSHRL64_rr 1110101 0010 1 ... 1 .... ... 1 0010 1101 @mve_shl_rr
132
+ scaled = deposit32(1 << 8, 0, 8, extract64(frac, 44, 8));
65
+ {
133
+ estimate = recip_estimate(scaled);
66
+ UQRSHL_rr 1110101 0010 1 .... .... 1111 0000 1101 @mve_sh_rr
134
67
+ LSLL_rr 1110101 0010 1 ... 0 .... ... 1 0000 1101 @mve_shl_rr
135
- estimate = recip_estimate(scaled, fpst);
68
+ UQRSHLL64_rr 1110101 0010 1 ... 1 .... ... 1 0000 1101 @mve_shl_rr
136
-
137
- /* Build new result */
138
- val64 = float64_val(estimate);
139
- sbit = 0x8000000000000000ULL & val64;
140
- exp = off - exp;
141
- frac = extract64(val64, 0, 52);
142
-
143
- if (exp == 0) {
144
- frac = 1ULL << 51 | extract64(frac, 1, 51);
145
- } else if (exp == -1) {
146
- frac = 1ULL << 50 | extract64(frac, 2, 50);
147
- exp = 0;
148
+ result_exp = exp_off - *exp;
149
+ result_frac = deposit64(0, 44, 8, estimate);
150
+ if (result_exp == 0) {
151
+ result_frac = deposit64(result_frac >> 1, 51, 1, 1);
152
+ } else if (result_exp == -1) {
153
+ result_frac = deposit64(result_frac >> 2, 50, 2, 1);
154
+ result_exp = 0;
155
}
156
157
- return make_float64(sbit | (exp << 52) | frac);
158
+ *exp = result_exp;
159
+
160
+ return result_frac;
161
}
162
163
static bool round_to_inf(float_status *fpst, bool sign_bit)
164
@@ -XXX,XX +XXX,XX @@ static bool round_to_inf(float_status *fpst, bool sign_bit)
165
g_assert_not_reached();
166
}
167
168
+float16 HELPER(recpe_f16)(float16 input, void *fpstp)
169
+{
170
+ float_status *fpst = fpstp;
171
+ float16 f16 = float16_squash_input_denormal(input, fpst);
172
+ uint32_t f16_val = float16_val(f16);
173
+ uint32_t f16_sign = float16_is_neg(f16);
174
+ int f16_exp = extract32(f16_val, 10, 5);
175
+ uint32_t f16_frac = extract32(f16_val, 0, 10);
176
+ uint64_t f64_frac;
177
+
178
+ if (float16_is_any_nan(f16)) {
179
+ float16 nan = f16;
180
+ if (float16_is_signaling_nan(f16, fpst)) {
181
+ float_raise(float_flag_invalid, fpst);
182
+ nan = float16_maybe_silence_nan(f16, fpst);
183
+ }
184
+ if (fpst->default_nan_mode) {
185
+ nan = float16_default_nan(fpst);
186
+ }
187
+ return nan;
188
+ } else if (float16_is_infinity(f16)) {
189
+ return float16_set_sign(float16_zero, float16_is_neg(f16));
190
+ } else if (float16_is_zero(f16)) {
191
+ float_raise(float_flag_divbyzero, fpst);
192
+ return float16_set_sign(float16_infinity, float16_is_neg(f16));
193
+ } else if (float16_abs(f16) < (1 << 8)) {
194
+ /* Abs(value) < 2.0^-16 */
195
+ float_raise(float_flag_overflow | float_flag_inexact, fpst);
196
+ if (round_to_inf(fpst, f16_sign)) {
197
+ return float16_set_sign(float16_infinity, f16_sign);
198
+ } else {
199
+ return float16_set_sign(float16_maxnorm, f16_sign);
200
+ }
201
+ } else if (f16_exp >= 29 && fpst->flush_to_zero) {
202
+ float_raise(float_flag_underflow, fpst);
203
+ return float16_set_sign(float16_zero, float16_is_neg(f16));
204
+ }
69
+ }
205
+
70
+
206
+ f64_frac = call_recip_estimate(&f16_exp, 29,
71
+ {
207
+ ((uint64_t) f16_frac) << (52 - 10));
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
+ }
208
+
76
+
209
+ /* result = sign : result_exp<4:0> : fraction<51:42> */
77
UQRSHLL48_rr 1110101 0010 1 ... 1 .... ... 1 1000 1101 @mve_shl_rr
210
+ f16_val = deposit32(0, 15, 1, f16_sign);
78
SQRSHRL48_rr 1110101 0010 1 ... 1 .... ... 1 1010 1101 @mve_shl_rr
211
+ f16_val = deposit32(f16_val, 10, 5, f16_exp);
79
]
212
+ f16_val = deposit32(f16_val, 0, 10, extract64(f64_frac, 52 - 10, 10));
80
diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c
213
+ return make_float16(f16_val);
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
}
88
+
89
+uint32_t HELPER(mve_uqrshl)(CPUARMState *env, uint32_t n, uint32_t shift)
90
+{
91
+ return do_uqrshl_bhs(n, (int8_t)shift, 32, true, &env->QF);
214
+}
92
+}
215
+
93
+
216
float32 HELPER(recpe_f32)(float32 input, void *fpstp)
94
+uint32_t HELPER(mve_sqrshr)(CPUARMState *env, uint32_t n, uint32_t shift)
217
{
95
+{
218
float_status *fpst = fpstp;
96
+ return do_sqrshl_bhs(n, -(int8_t)shift, 32, true, &env->QF);
219
float32 f32 = float32_squash_input_denormal(input, fpst);
97
+}
220
uint32_t f32_val = float32_val(f32);
98
diff --git a/target/arm/translate.c b/target/arm/translate.c
221
- uint32_t f32_sbit = 0x80000000ULL & f32_val;
99
index XXXXXXX..XXXXXXX 100644
222
- int32_t f32_exp = extract32(f32_val, 23, 8);
100
--- a/target/arm/translate.c
223
+ bool f32_sign = float32_is_neg(f32);
101
+++ b/target/arm/translate.c
224
+ int f32_exp = extract32(f32_val, 23, 8);
102
@@ -XXX,XX +XXX,XX @@ static bool trans_UQSHL_ri(DisasContext *s, arg_mve_sh_ri *a)
225
uint32_t f32_frac = extract32(f32_val, 0, 23);
103
return do_mve_sh_ri(s, a, gen_mve_uqshl);
226
- float64 f64, r64;
227
- uint64_t r64_val;
228
- int64_t r64_exp;
229
- uint64_t r64_frac;
230
+ uint64_t f64_frac;
231
232
if (float32_is_any_nan(f32)) {
233
float32 nan = f32;
234
@@ -XXX,XX +XXX,XX @@ float32 HELPER(recpe_f32)(float32 input, void *fpstp)
235
} else if (float32_is_zero(f32)) {
236
float_raise(float_flag_divbyzero, fpst);
237
return float32_set_sign(float32_infinity, float32_is_neg(f32));
238
- } else if ((f32_val & ~(1ULL << 31)) < (1ULL << 21)) {
239
+ } else if (float32_abs(f32) < (1ULL << 21)) {
240
/* Abs(value) < 2.0^-128 */
241
float_raise(float_flag_overflow | float_flag_inexact, fpst);
242
- if (round_to_inf(fpst, f32_sbit)) {
243
- return float32_set_sign(float32_infinity, float32_is_neg(f32));
244
+ if (round_to_inf(fpst, f32_sign)) {
245
+ return float32_set_sign(float32_infinity, f32_sign);
246
} else {
247
- return float32_set_sign(float32_maxnorm, float32_is_neg(f32));
248
+ return float32_set_sign(float32_maxnorm, f32_sign);
249
}
250
} else if (f32_exp >= 253 && fpst->flush_to_zero) {
251
float_raise(float_flag_underflow, fpst);
252
return float32_set_sign(float32_zero, float32_is_neg(f32));
253
}
254
255
+ f64_frac = call_recip_estimate(&f32_exp, 253,
256
+ ((uint64_t) f32_frac) << (52 - 23));
257
258
- f64 = make_float64(((int64_t)(f32_exp) << 52) | (int64_t)(f32_frac) << 29);
259
- r64 = call_recip_estimate(f64, 253, fpst);
260
- r64_val = float64_val(r64);
261
- r64_exp = extract64(r64_val, 52, 11);
262
- r64_frac = extract64(r64_val, 0, 52);
263
-
264
- /* result = sign : result_exp<7:0> : fraction<51:29>; */
265
- return make_float32(f32_sbit |
266
- (r64_exp & 0xff) << 23 |
267
- extract64(r64_frac, 29, 24));
268
+ /* result = sign : result_exp<7:0> : fraction<51:29> */
269
+ f32_val = deposit32(0, 31, 1, f32_sign);
270
+ f32_val = deposit32(f32_val, 23, 8, f32_exp);
271
+ f32_val = deposit32(f32_val, 0, 23, extract64(f64_frac, 52 - 23, 23));
272
+ return make_float32(f32_val);
273
}
104
}
274
105
275
float64 HELPER(recpe_f64)(float64 input, void *fpstp)
106
+static bool do_mve_sh_rr(DisasContext *s, arg_mve_sh_rr *a, ShiftFn *fn)
276
@@ -XXX,XX +XXX,XX @@ float64 HELPER(recpe_f64)(float64 input, void *fpstp)
107
+{
277
float_status *fpst = fpstp;
108
+ if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) {
278
float64 f64 = float64_squash_input_denormal(input, fpst);
109
+ /* Decode falls through to ORR/MOV UNPREDICTABLE handling */
279
uint64_t f64_val = float64_val(f64);
110
+ return false;
280
- uint64_t f64_sbit = 0x8000000000000000ULL & f64_val;
111
+ }
281
- int64_t f64_exp = extract64(f64_val, 52, 11);
112
+ if (!dc_isar_feature(aa32_mve, s) ||
282
- float64 r64;
113
+ !arm_dc_feature(s, ARM_FEATURE_M_MAIN) ||
283
- uint64_t r64_val;
114
+ a->rda == 13 || a->rda == 15 || a->rm == 13 || a->rm == 15 ||
284
- int64_t r64_exp;
115
+ a->rm == a->rda) {
285
- uint64_t r64_frac;
116
+ /* These rda/rm cases are UNPREDICTABLE; we choose to UNDEF */
286
+ bool f64_sign = float64_is_neg(f64);
117
+ unallocated_encoding(s);
287
+ int f64_exp = extract64(f64_val, 52, 11);
118
+ return true;
288
+ uint64_t f64_frac = extract64(f64_val, 0, 52);
119
+ }
289
120
+
290
/* Deal with any special cases */
121
+ /* The helper takes care of the sign-extension of the low 8 bits of Rm */
291
if (float64_is_any_nan(f64)) {
122
+ fn(cpu_R[a->rda], cpu_env, cpu_R[a->rda], cpu_R[a->rm]);
292
@@ -XXX,XX +XXX,XX @@ float64 HELPER(recpe_f64)(float64 input, void *fpstp)
123
+ return true;
293
} else if ((f64_val & ~(1ULL << 63)) < (1ULL << 50)) {
124
+}
294
/* Abs(value) < 2.0^-1024 */
125
+
295
float_raise(float_flag_overflow | float_flag_inexact, fpst);
126
+static bool trans_SQRSHR_rr(DisasContext *s, arg_mve_sh_rr *a)
296
- if (round_to_inf(fpst, f64_sbit)) {
127
+{
297
- return float64_set_sign(float64_infinity, float64_is_neg(f64));
128
+ return do_mve_sh_rr(s, a, gen_helper_mve_sqrshr);
298
+ if (round_to_inf(fpst, f64_sign)) {
129
+}
299
+ return float64_set_sign(float64_infinity, f64_sign);
130
+
300
} else {
131
+static bool trans_UQRSHL_rr(DisasContext *s, arg_mve_sh_rr *a)
301
- return float64_set_sign(float64_maxnorm, float64_is_neg(f64));
132
+{
302
+ return float64_set_sign(float64_maxnorm, f64_sign);
133
+ return do_mve_sh_rr(s, a, gen_helper_mve_uqrshl);
303
}
134
+}
304
} else if (f64_exp >= 2045 && fpst->flush_to_zero) {
135
+
305
float_raise(float_flag_underflow, fpst);
136
/*
306
return float64_set_sign(float64_zero, float64_is_neg(f64));
137
* Multiply and multiply accumulate
307
}
138
*/
308
309
- r64 = call_recip_estimate(f64, 2045, fpst);
310
- r64_val = float64_val(r64);
311
- r64_exp = extract64(r64_val, 52, 11);
312
- r64_frac = extract64(r64_val, 0, 52);
313
+ f64_frac = call_recip_estimate(&f64_exp, 2045, f64_frac);
314
315
- /* result = sign : result_exp<10:0> : fraction<51:0> */
316
- return make_float64(f64_sbit |
317
- ((r64_exp & 0x7ff) << 52) |
318
- r64_frac);
319
+ /* result = sign : result_exp<10:0> : fraction<51:0>; */
320
+ f64_val = deposit64(0, 63, 1, f64_sign);
321
+ f64_val = deposit64(f64_val, 52, 11, f64_exp);
322
+ f64_val = deposit64(f64_val, 0, 52, f64_frac);
323
+ return make_float64(f64_val);
324
}
325
326
/* The algorithm that must be used to calculate the estimate
327
@@ -XXX,XX +XXX,XX @@ float64 HELPER(rsqrte_f64)(float64 input, void *fpstp)
328
329
uint32_t HELPER(recpe_u32)(uint32_t a, void *fpstp)
330
{
331
- float_status *s = fpstp;
332
- float64 f64;
333
+ /* float_status *s = fpstp; */
334
+ int input, estimate;
335
336
if ((a & 0x80000000) == 0) {
337
return 0xffffffff;
338
}
339
340
- f64 = make_float64((0x3feULL << 52)
341
- | ((int64_t)(a & 0x7fffffff) << 21));
342
+ input = extract32(a, 23, 9);
343
+ estimate = recip_estimate(input);
344
345
- f64 = recip_estimate(f64, s);
346
-
347
- return 0x80000000 | ((float64_val(f64) >> 21) & 0x7fffffff);
348
+ return deposit32(0, (32 - 9), 9, estimate);
349
}
350
351
uint32_t HELPER(rsqrte_u32)(uint32_t a, void *fpstp)
352
--
139
--
353
2.16.2
140
2.20.1
354
141
355
142
diff view generated by jsdifflib
Deleted patch
1
From: Alex Bennée <alex.bennee@linaro.org>
2
1
3
Now we have added f16 during the re-factoring we can simply call the
4
helper.
5
6
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20180227143852.11175-24-alex.bennee@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/translate-a64.c | 8 ++++++++
12
1 file changed, 8 insertions(+)
13
14
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/translate-a64.c
17
+++ b/target/arm/translate-a64.c
18
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
19
case 0x6d: /* FCMLE (zero) */
20
handle_2misc_fcmp_zero(s, fpop, is_scalar, 0, is_q, MO_16, rn, rd);
21
return;
22
+ case 0x3d: /* FRECPE */
23
+ break;
24
case 0x18: /* FRINTN */
25
need_rmode = true;
26
only_in_vector = true;
27
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
28
case 0x3b: /* FCVTZS */
29
gen_helper_advsimd_f16tosinth(tcg_res, tcg_op, tcg_fpstatus);
30
break;
31
+ case 0x3d: /* FRECPE */
32
+ gen_helper_recpe_f16(tcg_res, tcg_op, tcg_fpstatus);
33
+ break;
34
case 0x5a: /* FCVTNU */
35
case 0x5b: /* FCVTMU */
36
case 0x5c: /* FCVTAU */
37
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
38
case 0x3b: /* FCVTZS */
39
gen_helper_advsimd_f16tosinth(tcg_res, tcg_op, tcg_fpstatus);
40
break;
41
+ case 0x3d: /* FRECPE */
42
+ gen_helper_recpe_f16(tcg_res, tcg_op, tcg_fpstatus);
43
+ break;
44
case 0x5a: /* FCVTNU */
45
case 0x5b: /* FCVTMU */
46
case 0x5c: /* FCVTAU */
47
--
48
2.16.2
49
50
diff view generated by jsdifflib
Deleted patch
1
From: Alex Bennée <alex.bennee@linaro.org>
2
1
3
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20180227143852.11175-28-alex.bennee@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
target/arm/translate-a64.c | 7 +++++++
9
1 file changed, 7 insertions(+)
10
11
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/translate-a64.c
14
+++ b/target/arm/translate-a64.c
15
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
16
case 0x6f: /* FNEG */
17
need_fpst = false;
18
break;
19
+ case 0x7d: /* FRSQRTE */
20
case 0x7f: /* FSQRT (vector) */
21
break;
22
default:
23
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
24
case 0x6f: /* FNEG */
25
tcg_gen_xori_i32(tcg_res, tcg_op, 0x8000);
26
break;
27
+ case 0x7d: /* FRSQRTE */
28
+ gen_helper_rsqrte_f16(tcg_res, tcg_op, tcg_fpstatus);
29
+ break;
30
default:
31
g_assert_not_reached();
32
}
33
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
34
case 0x6f: /* FNEG */
35
tcg_gen_xori_i32(tcg_res, tcg_op, 0x8000);
36
break;
37
+ case 0x7d: /* FRSQRTE */
38
+ gen_helper_rsqrte_f16(tcg_res, tcg_op, tcg_fpstatus);
39
+ break;
40
case 0x7f: /* FSQRT */
41
gen_helper_sqrt_f16(tcg_res, tcg_op, tcg_fpstatus);
42
break;
43
--
44
2.16.2
45
46
diff view generated by jsdifflib
Deleted patch
1
From: Alex Bennée <alex.bennee@linaro.org>
2
1
3
Only one half-precision instruction has been added to this group.
4
5
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20180227143852.11175-29-alex.bennee@linaro.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
10
target/arm/translate-a64.c | 35 +++++++++++++++++++++++++----------
11
1 file changed, 25 insertions(+), 10 deletions(-)
12
13
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/translate-a64.c
16
+++ b/target/arm/translate-a64.c
17
@@ -XXX,XX +XXX,XX @@ static void disas_simd_copy(DisasContext *s, uint32_t insn)
18
* MVNI - move inverted (shifted) imm into register
19
* ORR - bitwise OR of (shifted) imm with register
20
* BIC - bitwise clear of (shifted) imm with register
21
+ * With ARMv8.2 we also have:
22
+ * FMOV half-precision
23
*/
24
static void disas_simd_mod_imm(DisasContext *s, uint32_t insn)
25
{
26
@@ -XXX,XX +XXX,XX @@ static void disas_simd_mod_imm(DisasContext *s, uint32_t insn)
27
uint64_t imm = 0;
28
29
if (o2 != 0 || ((cmode == 0xf) && is_neg && !is_q)) {
30
- unallocated_encoding(s);
31
- return;
32
+ /* Check for FMOV (vector, immediate) - half-precision */
33
+ if (!(arm_dc_feature(s, ARM_FEATURE_V8_FP16) && o2 && cmode == 0xf)) {
34
+ unallocated_encoding(s);
35
+ return;
36
+ }
37
}
38
39
if (!fp_access_check(s)) {
40
@@ -XXX,XX +XXX,XX @@ static void disas_simd_mod_imm(DisasContext *s, uint32_t insn)
41
imm |= 0x4000000000000000ULL;
42
}
43
} else {
44
- imm = (abcdefgh & 0x3f) << 19;
45
- if (abcdefgh & 0x80) {
46
- imm |= 0x80000000;
47
- }
48
- if (abcdefgh & 0x40) {
49
- imm |= 0x3e000000;
50
+ if (o2) {
51
+ /* FMOV (vector, immediate) - half-precision */
52
+ imm = vfp_expand_imm(MO_16, abcdefgh);
53
+ /* now duplicate across the lanes */
54
+ imm = bitfield_replicate(imm, 16);
55
} else {
56
- imm |= 0x40000000;
57
+ imm = (abcdefgh & 0x3f) << 19;
58
+ if (abcdefgh & 0x80) {
59
+ imm |= 0x80000000;
60
+ }
61
+ if (abcdefgh & 0x40) {
62
+ imm |= 0x3e000000;
63
+ } else {
64
+ imm |= 0x40000000;
65
+ }
66
+ imm |= (imm << 32);
67
}
68
- imm |= (imm << 32);
69
}
70
}
71
break;
72
+ default:
73
+ fprintf(stderr, "%s: cmode_3_1: %x\n", __func__, cmode_3_1);
74
+ g_assert_not_reached();
75
}
76
77
if (cmode_3_1 != 7 && is_neg) {
78
--
79
2.16.2
80
81
diff view generated by jsdifflib
Deleted patch
1
From: Alex Bennée <alex.bennee@linaro.org>
2
1
3
I only needed to do a little light re-factoring to support the
4
half-precision helpers.
5
6
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20180227143852.11175-30-alex.bennee@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/translate-a64.c | 80 +++++++++++++++++++++++++++++++---------------
12
1 file changed, 54 insertions(+), 26 deletions(-)
13
14
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/translate-a64.c
17
+++ b/target/arm/translate-a64.c
18
@@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_pairwise(DisasContext *s, uint32_t insn)
19
case 0xf: /* FMAXP */
20
case 0x2c: /* FMINNMP */
21
case 0x2f: /* FMINP */
22
- /* FP op, size[0] is 32 or 64 bit */
23
+ /* FP op, size[0] is 32 or 64 bit*/
24
if (!u) {
25
- unallocated_encoding(s);
26
- return;
27
+ if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) {
28
+ unallocated_encoding(s);
29
+ return;
30
+ } else {
31
+ size = MO_16;
32
+ }
33
+ } else {
34
+ size = extract32(size, 0, 1) ? MO_64 : MO_32;
35
}
36
+
37
if (!fp_access_check(s)) {
38
return;
39
}
40
41
- size = extract32(size, 0, 1) ? 3 : 2;
42
- fpst = get_fpstatus_ptr(false);
43
+ fpst = get_fpstatus_ptr(size == MO_16);
44
break;
45
default:
46
unallocated_encoding(s);
47
return;
48
}
49
50
- if (size == 3) {
51
+ if (size == MO_64) {
52
TCGv_i64 tcg_op1 = tcg_temp_new_i64();
53
TCGv_i64 tcg_op2 = tcg_temp_new_i64();
54
TCGv_i64 tcg_res = tcg_temp_new_i64();
55
@@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_pairwise(DisasContext *s, uint32_t insn)
56
TCGv_i32 tcg_op2 = tcg_temp_new_i32();
57
TCGv_i32 tcg_res = tcg_temp_new_i32();
58
59
- read_vec_element_i32(s, tcg_op1, rn, 0, MO_32);
60
- read_vec_element_i32(s, tcg_op2, rn, 1, MO_32);
61
+ read_vec_element_i32(s, tcg_op1, rn, 0, size);
62
+ read_vec_element_i32(s, tcg_op2, rn, 1, size);
63
64
- switch (opcode) {
65
- case 0xc: /* FMAXNMP */
66
- gen_helper_vfp_maxnums(tcg_res, tcg_op1, tcg_op2, fpst);
67
- break;
68
- case 0xd: /* FADDP */
69
- gen_helper_vfp_adds(tcg_res, tcg_op1, tcg_op2, fpst);
70
- break;
71
- case 0xf: /* FMAXP */
72
- gen_helper_vfp_maxs(tcg_res, tcg_op1, tcg_op2, fpst);
73
- break;
74
- case 0x2c: /* FMINNMP */
75
- gen_helper_vfp_minnums(tcg_res, tcg_op1, tcg_op2, fpst);
76
- break;
77
- case 0x2f: /* FMINP */
78
- gen_helper_vfp_mins(tcg_res, tcg_op1, tcg_op2, fpst);
79
- break;
80
- default:
81
- g_assert_not_reached();
82
+ if (size == MO_16) {
83
+ switch (opcode) {
84
+ case 0xc: /* FMAXNMP */
85
+ gen_helper_advsimd_maxnumh(tcg_res, tcg_op1, tcg_op2, fpst);
86
+ break;
87
+ case 0xd: /* FADDP */
88
+ gen_helper_advsimd_addh(tcg_res, tcg_op1, tcg_op2, fpst);
89
+ break;
90
+ case 0xf: /* FMAXP */
91
+ gen_helper_advsimd_maxh(tcg_res, tcg_op1, tcg_op2, fpst);
92
+ break;
93
+ case 0x2c: /* FMINNMP */
94
+ gen_helper_advsimd_minnumh(tcg_res, tcg_op1, tcg_op2, fpst);
95
+ break;
96
+ case 0x2f: /* FMINP */
97
+ gen_helper_advsimd_minh(tcg_res, tcg_op1, tcg_op2, fpst);
98
+ break;
99
+ default:
100
+ g_assert_not_reached();
101
+ }
102
+ } else {
103
+ switch (opcode) {
104
+ case 0xc: /* FMAXNMP */
105
+ gen_helper_vfp_maxnums(tcg_res, tcg_op1, tcg_op2, fpst);
106
+ break;
107
+ case 0xd: /* FADDP */
108
+ gen_helper_vfp_adds(tcg_res, tcg_op1, tcg_op2, fpst);
109
+ break;
110
+ case 0xf: /* FMAXP */
111
+ gen_helper_vfp_maxs(tcg_res, tcg_op1, tcg_op2, fpst);
112
+ break;
113
+ case 0x2c: /* FMINNMP */
114
+ gen_helper_vfp_minnums(tcg_res, tcg_op1, tcg_op2, fpst);
115
+ break;
116
+ case 0x2f: /* FMINP */
117
+ gen_helper_vfp_mins(tcg_res, tcg_op1, tcg_op2, fpst);
118
+ break;
119
+ default:
120
+ g_assert_not_reached();
121
+ }
122
}
123
124
write_fp_sreg(s, rd, tcg_res);
125
--
126
2.16.2
127
128
diff view generated by jsdifflib