1
The following changes since commit a35947f15c0ee695eba3c55248ec8ac3e4e23cca:
1
From: Alistair Francis <alistair.francis@wdc.com>
2
2
3
Merge remote-tracking branch 'remotes/stsquad/tags/pull-testing-updates-070621-2' into staging (2021-06-07 15:45:48 +0100)
3
The following changes since commit c5fbdd60cf1fb52f01bdfe342b6fa65d5343e1b1:
4
5
Merge tag 'qemu-sparc-20211121' of git://github.com/mcayland/qemu into staging (2021-11-21 14:12:25 +0100)
4
6
5
are available in the Git repository at:
7
are available in the Git repository at:
6
8
7
git@github.com:alistair23/qemu.git tags/pull-riscv-to-apply-20210608-1
9
git@github.com:alistair23/qemu.git tags/pull-riscv-to-apply-20211122
8
10
9
for you to fetch changes up to d2c1a177b138be35cb96216baa870c3564b123e4:
11
for you to fetch changes up to 526e7443027c71fe7b04c29df529e1f9f425f9e3:
10
12
11
target/riscv: rvb: add b-ext version cpu option (2021-06-08 09:59:46 +1000)
13
hw/misc/sifive_u_otp: Do not reset OTP content on hardware reset (2021-11-22 10:46:22 +1000)
12
14
13
----------------------------------------------------------------
15
----------------------------------------------------------------
14
Second RISC-V PR for QEMU 6.1
16
Seventh RISC-V PR for QEMU 6.2
15
17
16
- Update the PLIC and CLINT DT bindings
18
- Deprecate IF_NONE for SiFive OTP
17
- Improve documentation for RISC-V machines
19
- Don't reset SiFive OTP content
18
- Support direct kernel boot for microchip_pfsoc
19
- Fix WFI exception behaviour
20
- Improve CSR printing
21
- Initial support for the experimental Bit Manip extension
22
20
23
----------------------------------------------------------------
21
----------------------------------------------------------------
24
Alistair Francis (2):
22
Philippe Mathieu-Daudé (1):
25
docs/system: Move the RISC-V -bios information to removed
23
hw/misc/sifive_u_otp: Do not reset OTP content on hardware reset
26
target/riscv/pmp: Add assert for ePMP operations
27
24
28
Bin Meng (9):
25
Thomas Huth (1):
29
hw/riscv: sifive_u: Switch to use qemu_fdt_setprop_string_array() helper
26
hw/misc/sifive_u_otp: Use IF_PFLASH for the OTP device instead of IF_NONE
30
hw/riscv: virt: Switch to use qemu_fdt_setprop_string_array() helper
31
hw/riscv: Support the official CLINT DT bindings
32
hw/riscv: Support the official PLIC DT bindings
33
docs/system/riscv: Correct the indentation level of supported devices
34
docs/system/riscv: sifive_u: Document '-dtb' usage
35
hw/riscv: Use macros for BIOS image names
36
hw/riscv: microchip_pfsoc: Support direct kernel boot
37
target/riscv: Remove unnecessary riscv_*_names[] declaration
38
27
39
Changbin Du (1):
28
docs/about/deprecated.rst | 6 ++++++
40
target/riscv: Dump CSR mscratch/sscratch/satp
29
hw/misc/sifive_u_otp.c | 22 +++++++++++++---------
30
2 files changed, 19 insertions(+), 9 deletions(-)
41
31
42
Frank Chang (6):
43
target/riscv: rvb: count bits set
44
target/riscv: add gen_shifti() and gen_shiftiw() helper functions
45
target/riscv: rvb: single-bit instructions
46
target/riscv: rvb: generalized reverse
47
target/riscv: rvb: generalized or-combine
48
target/riscv: rvb: add b-ext version cpu option
49
50
Jose Martins (1):
51
target/riscv: fix wfi exception behavior
52
53
Kito Cheng (11):
54
target/riscv: reformat @sh format encoding for B-extension
55
target/riscv: rvb: count leading/trailing zeros
56
target/riscv: rvb: logic-with-negate
57
target/riscv: rvb: pack two words into one register
58
target/riscv: rvb: min/max instructions
59
target/riscv: rvb: sign-extend instructions
60
target/riscv: rvb: shift ones
61
target/riscv: rvb: rotate (left/right)
62
target/riscv: rvb: address calculation
63
target/riscv: rvb: add/shift with prefix zero-extend
64
target/riscv: rvb: support and turn on B-extension from command line
65
66
LIU Zhiwei (1):
67
target/riscv: Pass the same value to oprsz and maxsz.
68
69
Philippe Mathieu-Daudé (1):
70
target/riscv: Do not include 'pmp.h' in user emulation
71
72
docs/system/deprecated.rst | 19 --
73
docs/system/removed-features.rst | 5 +
74
docs/system/riscv/microchip-icicle-kit.rst | 50 +++-
75
docs/system/riscv/sifive_u.rst | 77 +++--
76
docs/system/target-riscv.rst | 13 +-
77
include/hw/riscv/boot.h | 5 +
78
target/riscv/cpu.h | 9 +-
79
target/riscv/cpu_bits.h | 1 +
80
target/riscv/helper.h | 6 +
81
target/riscv/insn32.decode | 87 +++++-
82
hw/riscv/microchip_pfsoc.c | 81 +++++-
83
hw/riscv/sifive_u.c | 24 +-
84
hw/riscv/spike.c | 12 +-
85
hw/riscv/virt.c | 25 +-
86
target/riscv/bitmanip_helper.c | 90 ++++++
87
target/riscv/cpu.c | 38 ++-
88
target/riscv/op_helper.c | 11 +-
89
target/riscv/pmp.c | 4 +
90
target/riscv/translate.c | 306 ++++++++++++++++++++
91
target/riscv/insn_trans/trans_rvb.c.inc | 438 +++++++++++++++++++++++++++++
92
target/riscv/insn_trans/trans_rvi.c.inc | 54 +---
93
target/riscv/insn_trans/trans_rvv.c.inc | 89 +++---
94
target/riscv/meson.build | 1 +
95
23 files changed, 1260 insertions(+), 185 deletions(-)
96
create mode 100644 target/riscv/bitmanip_helper.c
97
create mode 100644 target/riscv/insn_trans/trans_rvb.c.inc
98
diff view generated by jsdifflib
Deleted patch
1
From: Bin Meng <bin.meng@windriver.com>
2
1
3
Since commit 78da6a1bca22 ("device_tree: add qemu_fdt_setprop_string_array helper"),
4
we can use the new helper to set the clock name for the ethernet
5
controller node.
6
7
Signed-off-by: Bin Meng <bin.meng@windriver.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Message-id: 20210430071302.1489082-1-bmeng.cn@gmail.com
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
12
hw/riscv/sifive_u.c | 6 +++---
13
1 file changed, 3 insertions(+), 3 deletions(-)
14
15
diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/riscv/sifive_u.c
18
+++ b/hw/riscv/sifive_u.c
19
@@ -XXX,XX +XXX,XX @@ static void create_fdt(SiFiveUState *s, const MemMapEntry *memmap,
20
int cpu;
21
uint32_t *cells;
22
char *nodename;
23
- char ethclk_names[] = "pclk\0hclk";
24
uint32_t plic_phandle, prci_phandle, gpio_phandle, phandle = 1;
25
uint32_t hfclk_phandle, rtcclk_phandle, phy_phandle;
26
+ static const char * const ethclk_names[2] = { "pclk", "hclk" };
27
28
if (ms->dtb) {
29
fdt = s->fdt = load_device_tree(ms->dtb, &s->fdt_size);
30
@@ -XXX,XX +XXX,XX @@ static void create_fdt(SiFiveUState *s, const MemMapEntry *memmap,
31
qemu_fdt_setprop_cell(fdt, nodename, "interrupts", SIFIVE_U_GEM_IRQ);
32
qemu_fdt_setprop_cells(fdt, nodename, "clocks",
33
prci_phandle, PRCI_CLK_GEMGXLPLL, prci_phandle, PRCI_CLK_GEMGXLPLL);
34
- qemu_fdt_setprop(fdt, nodename, "clock-names", ethclk_names,
35
- sizeof(ethclk_names));
36
+ qemu_fdt_setprop_string_array(fdt, nodename, "clock-names",
37
+ (char **)&ethclk_names, ARRAY_SIZE(ethclk_names));
38
qemu_fdt_setprop(fdt, nodename, "local-mac-address",
39
s->soc.gem.conf.macaddr.a, ETH_ALEN);
40
qemu_fdt_setprop_cell(fdt, nodename, "#address-cells", 1);
41
--
42
2.31.1
43
44
diff view generated by jsdifflib
Deleted patch
1
From: Bin Meng <bin.meng@windriver.com>
2
1
3
Since commit 78da6a1bca22 ("device_tree: add qemu_fdt_setprop_string_array helper"),
4
we can use the new helper to set the compatible strings for the
5
SiFive test device node.
6
7
Signed-off-by: Bin Meng <bin.meng@windriver.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Message-id: 20210430071302.1489082-2-bmeng.cn@gmail.com
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
12
hw/riscv/virt.c | 7 +++++--
13
1 file changed, 5 insertions(+), 2 deletions(-)
14
15
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/riscv/virt.c
18
+++ b/hw/riscv/virt.c
19
@@ -XXX,XX +XXX,XX @@ static void create_fdt(RISCVVirtState *s, const MemMapEntry *memmap,
20
(long)memmap[VIRT_TEST].base);
21
qemu_fdt_add_subnode(fdt, name);
22
{
23
- const char compat[] = "sifive,test1\0sifive,test0\0syscon";
24
- qemu_fdt_setprop(fdt, name, "compatible", compat, sizeof(compat));
25
+ static const char * const compat[3] = {
26
+ "sifive,test1", "sifive,test0", "syscon"
27
+ };
28
+ qemu_fdt_setprop_string_array(fdt, name, "compatible", (char **)&compat,
29
+ ARRAY_SIZE(compat));
30
}
31
qemu_fdt_setprop_cells(fdt, name, "reg",
32
0x0, memmap[VIRT_TEST].base,
33
--
34
2.31.1
35
36
diff view generated by jsdifflib
Deleted patch
1
From: Bin Meng <bin.meng@windriver.com>
2
1
3
Linux kernel commit a2770b57d083 ("dt-bindings: timer: Add CLINT bindings")
4
adds the official DT bindings for CLINT, which uses "sifive,clint0"
5
as the compatible string. "riscv,clint0" is now legacy and has to
6
be kept for backward compatibility of legacy systems.
7
8
Signed-off-by: Bin Meng <bin.meng@windriver.com>
9
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
10
Message-id: 20210430071302.1489082-3-bmeng.cn@gmail.com
11
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
12
---
13
hw/riscv/sifive_u.c | 6 +++++-
14
hw/riscv/spike.c | 6 +++++-
15
hw/riscv/virt.c | 6 +++++-
16
3 files changed, 15 insertions(+), 3 deletions(-)
17
18
diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
19
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/riscv/sifive_u.c
21
+++ b/hw/riscv/sifive_u.c
22
@@ -XXX,XX +XXX,XX @@ static void create_fdt(SiFiveUState *s, const MemMapEntry *memmap,
23
uint32_t plic_phandle, prci_phandle, gpio_phandle, phandle = 1;
24
uint32_t hfclk_phandle, rtcclk_phandle, phy_phandle;
25
static const char * const ethclk_names[2] = { "pclk", "hclk" };
26
+ static const char * const clint_compat[2] = {
27
+ "sifive,clint0", "riscv,clint0"
28
+ };
29
30
if (ms->dtb) {
31
fdt = s->fdt = load_device_tree(ms->dtb, &s->fdt_size);
32
@@ -XXX,XX +XXX,XX @@ static void create_fdt(SiFiveUState *s, const MemMapEntry *memmap,
33
nodename = g_strdup_printf("/soc/clint@%lx",
34
(long)memmap[SIFIVE_U_DEV_CLINT].base);
35
qemu_fdt_add_subnode(fdt, nodename);
36
- qemu_fdt_setprop_string(fdt, nodename, "compatible", "riscv,clint0");
37
+ qemu_fdt_setprop_string_array(fdt, nodename, "compatible",
38
+ (char **)&clint_compat, ARRAY_SIZE(clint_compat));
39
qemu_fdt_setprop_cells(fdt, nodename, "reg",
40
0x0, memmap[SIFIVE_U_DEV_CLINT].base,
41
0x0, memmap[SIFIVE_U_DEV_CLINT].size);
42
diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c
43
index XXXXXXX..XXXXXXX 100644
44
--- a/hw/riscv/spike.c
45
+++ b/hw/riscv/spike.c
46
@@ -XXX,XX +XXX,XX @@ static void create_fdt(SpikeState *s, const MemMapEntry *memmap,
47
uint32_t cpu_phandle, intc_phandle, phandle = 1;
48
char *name, *mem_name, *clint_name, *clust_name;
49
char *core_name, *cpu_name, *intc_name;
50
+ static const char * const clint_compat[2] = {
51
+ "sifive,clint0", "riscv,clint0"
52
+ };
53
54
fdt = s->fdt = create_device_tree(&s->fdt_size);
55
if (!fdt) {
56
@@ -XXX,XX +XXX,XX @@ static void create_fdt(SpikeState *s, const MemMapEntry *memmap,
57
(memmap[SPIKE_CLINT].size * socket);
58
clint_name = g_strdup_printf("/soc/clint@%lx", clint_addr);
59
qemu_fdt_add_subnode(fdt, clint_name);
60
- qemu_fdt_setprop_string(fdt, clint_name, "compatible", "riscv,clint0");
61
+ qemu_fdt_setprop_string_array(fdt, clint_name, "compatible",
62
+ (char **)&clint_compat, ARRAY_SIZE(clint_compat));
63
qemu_fdt_setprop_cells(fdt, clint_name, "reg",
64
0x0, clint_addr, 0x0, memmap[SPIKE_CLINT].size);
65
qemu_fdt_setprop(fdt, clint_name, "interrupts-extended",
66
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
67
index XXXXXXX..XXXXXXX 100644
68
--- a/hw/riscv/virt.c
69
+++ b/hw/riscv/virt.c
70
@@ -XXX,XX +XXX,XX @@ static void create_fdt(RISCVVirtState *s, const MemMapEntry *memmap,
71
char *name, *clint_name, *plic_name, *clust_name;
72
hwaddr flashsize = virt_memmap[VIRT_FLASH].size / 2;
73
hwaddr flashbase = virt_memmap[VIRT_FLASH].base;
74
+ static const char * const clint_compat[2] = {
75
+ "sifive,clint0", "riscv,clint0"
76
+ };
77
78
if (mc->dtb) {
79
fdt = mc->fdt = load_device_tree(mc->dtb, &s->fdt_size);
80
@@ -XXX,XX +XXX,XX @@ static void create_fdt(RISCVVirtState *s, const MemMapEntry *memmap,
81
(memmap[VIRT_CLINT].size * socket);
82
clint_name = g_strdup_printf("/soc/clint@%lx", clint_addr);
83
qemu_fdt_add_subnode(fdt, clint_name);
84
- qemu_fdt_setprop_string(fdt, clint_name, "compatible", "riscv,clint0");
85
+ qemu_fdt_setprop_string_array(fdt, clint_name, "compatible",
86
+ (char **)&clint_compat, ARRAY_SIZE(clint_compat));
87
qemu_fdt_setprop_cells(fdt, clint_name, "reg",
88
0x0, clint_addr, 0x0, memmap[VIRT_CLINT].size);
89
qemu_fdt_setprop(fdt, clint_name, "interrupts-extended",
90
--
91
2.31.1
92
93
diff view generated by jsdifflib
Deleted patch
1
From: Bin Meng <bin.meng@windriver.com>
2
1
3
The official DT bindings of PLIC uses "sifive,plic-1.0.0" as the
4
compatible string in the upstream Linux kernel. "riscv,plic0" is
5
now legacy and has to be kept for backward compatibility of legacy
6
systems.
7
8
Signed-off-by: Bin Meng <bin.meng@windriver.com>
9
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
10
Message-id: 20210430071302.1489082-4-bmeng.cn@gmail.com
11
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
12
---
13
hw/riscv/sifive_u.c | 6 +++++-
14
hw/riscv/virt.c | 6 +++++-
15
2 files changed, 10 insertions(+), 2 deletions(-)
16
17
diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/riscv/sifive_u.c
20
+++ b/hw/riscv/sifive_u.c
21
@@ -XXX,XX +XXX,XX @@ static void create_fdt(SiFiveUState *s, const MemMapEntry *memmap,
22
static const char * const clint_compat[2] = {
23
"sifive,clint0", "riscv,clint0"
24
};
25
+ static const char * const plic_compat[2] = {
26
+ "sifive,plic-1.0.0", "riscv,plic0"
27
+ };
28
29
if (ms->dtb) {
30
fdt = s->fdt = load_device_tree(ms->dtb, &s->fdt_size);
31
@@ -XXX,XX +XXX,XX @@ static void create_fdt(SiFiveUState *s, const MemMapEntry *memmap,
32
(long)memmap[SIFIVE_U_DEV_PLIC].base);
33
qemu_fdt_add_subnode(fdt, nodename);
34
qemu_fdt_setprop_cell(fdt, nodename, "#interrupt-cells", 1);
35
- qemu_fdt_setprop_string(fdt, nodename, "compatible", "riscv,plic0");
36
+ qemu_fdt_setprop_string_array(fdt, nodename, "compatible",
37
+ (char **)&plic_compat, ARRAY_SIZE(plic_compat));
38
qemu_fdt_setprop(fdt, nodename, "interrupt-controller", NULL, 0);
39
qemu_fdt_setprop(fdt, nodename, "interrupts-extended",
40
cells, (ms->smp.cpus * 4 - 2) * sizeof(uint32_t));
41
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
42
index XXXXXXX..XXXXXXX 100644
43
--- a/hw/riscv/virt.c
44
+++ b/hw/riscv/virt.c
45
@@ -XXX,XX +XXX,XX @@ static void create_fdt(RISCVVirtState *s, const MemMapEntry *memmap,
46
static const char * const clint_compat[2] = {
47
"sifive,clint0", "riscv,clint0"
48
};
49
+ static const char * const plic_compat[2] = {
50
+ "sifive,plic-1.0.0", "riscv,plic0"
51
+ };
52
53
if (mc->dtb) {
54
fdt = mc->fdt = load_device_tree(mc->dtb, &s->fdt_size);
55
@@ -XXX,XX +XXX,XX @@ static void create_fdt(RISCVVirtState *s, const MemMapEntry *memmap,
56
"#address-cells", FDT_PLIC_ADDR_CELLS);
57
qemu_fdt_setprop_cell(fdt, plic_name,
58
"#interrupt-cells", FDT_PLIC_INT_CELLS);
59
- qemu_fdt_setprop_string(fdt, plic_name, "compatible", "riscv,plic0");
60
+ qemu_fdt_setprop_string_array(fdt, plic_name, "compatible",
61
+ (char **)&plic_compat, ARRAY_SIZE(plic_compat));
62
qemu_fdt_setprop(fdt, plic_name, "interrupt-controller", NULL, 0);
63
qemu_fdt_setprop(fdt, plic_name, "interrupts-extended",
64
plic_cells, s->soc[socket].num_harts * sizeof(uint32_t) * 4);
65
--
66
2.31.1
67
68
diff view generated by jsdifflib
Deleted patch
1
From: Bin Meng <bin.meng@windriver.com>
2
1
3
The supported device bullet list has an additional space before each
4
entry, which makes a wrong indentation level. Correct it.
5
6
Signed-off-by: Bin Meng <bin.meng@windriver.com>
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Message-id: 20210430071302.1489082-5-bmeng.cn@gmail.com
9
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
10
---
11
docs/system/riscv/microchip-icicle-kit.rst | 20 +++++++--------
12
docs/system/riscv/sifive_u.rst | 30 +++++++++++-----------
13
2 files changed, 25 insertions(+), 25 deletions(-)
14
15
diff --git a/docs/system/riscv/microchip-icicle-kit.rst b/docs/system/riscv/microchip-icicle-kit.rst
16
index XXXXXXX..XXXXXXX 100644
17
--- a/docs/system/riscv/microchip-icicle-kit.rst
18
+++ b/docs/system/riscv/microchip-icicle-kit.rst
19
@@ -XXX,XX +XXX,XX @@ Supported devices
20
21
The ``microchip-icicle-kit`` machine supports the following devices:
22
23
- * 1 E51 core
24
- * 4 U54 cores
25
- * Core Level Interruptor (CLINT)
26
- * Platform-Level Interrupt Controller (PLIC)
27
- * L2 Loosely Integrated Memory (L2-LIM)
28
- * DDR memory controller
29
- * 5 MMUARTs
30
- * 1 DMA controller
31
- * 2 GEM Ethernet controllers
32
- * 1 SDHC storage controller
33
+* 1 E51 core
34
+* 4 U54 cores
35
+* Core Level Interruptor (CLINT)
36
+* Platform-Level Interrupt Controller (PLIC)
37
+* L2 Loosely Integrated Memory (L2-LIM)
38
+* DDR memory controller
39
+* 5 MMUARTs
40
+* 1 DMA controller
41
+* 2 GEM Ethernet controllers
42
+* 1 SDHC storage controller
43
44
Boot options
45
------------
46
diff --git a/docs/system/riscv/sifive_u.rst b/docs/system/riscv/sifive_u.rst
47
index XXXXXXX..XXXXXXX 100644
48
--- a/docs/system/riscv/sifive_u.rst
49
+++ b/docs/system/riscv/sifive_u.rst
50
@@ -XXX,XX +XXX,XX @@ Supported devices
51
52
The ``sifive_u`` machine supports the following devices:
53
54
- * 1 E51 / E31 core
55
- * Up to 4 U54 / U34 cores
56
- * Core Level Interruptor (CLINT)
57
- * Platform-Level Interrupt Controller (PLIC)
58
- * Power, Reset, Clock, Interrupt (PRCI)
59
- * L2 Loosely Integrated Memory (L2-LIM)
60
- * DDR memory controller
61
- * 2 UARTs
62
- * 1 GEM Ethernet controller
63
- * 1 GPIO controller
64
- * 1 One-Time Programmable (OTP) memory with stored serial number
65
- * 1 DMA controller
66
- * 2 QSPI controllers
67
- * 1 ISSI 25WP256 flash
68
- * 1 SD card in SPI mode
69
+* 1 E51 / E31 core
70
+* Up to 4 U54 / U34 cores
71
+* Core Level Interruptor (CLINT)
72
+* Platform-Level Interrupt Controller (PLIC)
73
+* Power, Reset, Clock, Interrupt (PRCI)
74
+* L2 Loosely Integrated Memory (L2-LIM)
75
+* DDR memory controller
76
+* 2 UARTs
77
+* 1 GEM Ethernet controller
78
+* 1 GPIO controller
79
+* 1 One-Time Programmable (OTP) memory with stored serial number
80
+* 1 DMA controller
81
+* 2 QSPI controllers
82
+* 1 ISSI 25WP256 flash
83
+* 1 SD card in SPI mode
84
85
Please note the real world HiFive Unleashed board has a fixed configuration of
86
1 E51 core and 4 U54 core combination and the RISC-V core boots in 64-bit mode.
87
--
88
2.31.1
89
90
diff view generated by jsdifflib
Deleted patch
1
From: Bin Meng <bin.meng@windriver.com>
2
1
3
Update the 'sifive_u' machine documentation to mention the '-dtb'
4
option that can be used to pass a custom DTB to QEMU.
5
6
Signed-off-by: Bin Meng <bin.meng@windriver.com>
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Message-id: 20210430071302.1489082-6-bmeng.cn@gmail.com
9
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
10
---
11
docs/system/riscv/sifive_u.rst | 47 +++++++++++++++++++++++++++++-----
12
1 file changed, 41 insertions(+), 6 deletions(-)
13
14
diff --git a/docs/system/riscv/sifive_u.rst b/docs/system/riscv/sifive_u.rst
15
index XXXXXXX..XXXXXXX 100644
16
--- a/docs/system/riscv/sifive_u.rst
17
+++ b/docs/system/riscv/sifive_u.rst
18
@@ -XXX,XX +XXX,XX @@ Hardware configuration information
19
----------------------------------
20
21
The ``sifive_u`` machine automatically generates a device tree blob ("dtb")
22
-which it passes to the guest. This provides information about the addresses,
23
-interrupt lines and other configuration of the various devices in the system.
24
-Guest software should discover the devices that are present in the generated
25
-DTB instead of using a DTB for the real hardware, as some of the devices are
26
-not modeled by QEMU and trying to access these devices may cause unexpected
27
-behavior.
28
+which it passes to the guest, if there is no ``-dtb`` option. This provides
29
+information about the addresses, interrupt lines and other configuration of
30
+the various devices in the system. Guest software should discover the devices
31
+that are present in the generated DTB instead of using a DTB for the real
32
+hardware, as some of the devices are not modeled by QEMU and trying to access
33
+these devices may cause unexpected behavior.
34
+
35
+If users want to provide their own DTB, they can use the ``-dtb`` option.
36
+These DTBs should have the following requirements:
37
+
38
+* The /cpus node should contain at least one subnode for E51 and the number
39
+ of subnodes should match QEMU's ``-smp`` option
40
+* The /memory reg size should match QEMU’s selected ram_size via ``-m``
41
+* Should contain a node for the CLINT device with a compatible string
42
+ "riscv,clint0" if using with OpenSBI BIOS images
43
44
Boot options
45
------------
46
@@ -XXX,XX +XXX,XX @@ To boot the newly built Linux kernel in QEMU with the ``sifive_u`` machine:
47
-initrd /path/to/rootfs.ext4 \
48
-append "root=/dev/ram"
49
50
+Alternatively, we can use a custom DTB to boot the machine by inserting a CLINT
51
+node in fu540-c000.dtsi in the Linux kernel,
52
+
53
+.. code-block:: none
54
+
55
+ clint: clint@2000000 {
56
+ compatible = "riscv,clint0";
57
+ interrupts-extended = <&cpu0_intc 3 &cpu0_intc 7
58
+ &cpu1_intc 3 &cpu1_intc 7
59
+ &cpu2_intc 3 &cpu2_intc 7
60
+ &cpu3_intc 3 &cpu3_intc 7
61
+ &cpu4_intc 3 &cpu4_intc 7>;
62
+ reg = <0x00 0x2000000 0x00 0x10000>;
63
+ };
64
+
65
+with the following command line options:
66
+
67
+.. code-block:: bash
68
+
69
+ $ qemu-system-riscv64 -M sifive_u -smp 5 -m 8G \
70
+ -display none -serial stdio \
71
+ -kernel arch/riscv/boot/Image \
72
+ -dtb arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dtb \
73
+ -initrd /path/to/rootfs.ext4 \
74
+ -append "root=/dev/ram"
75
+
76
To build a Linux mainline kernel that can be booted by the ``sifive_u`` machine
77
in 32-bit mode, use the rv32_defconfig configuration. A patch is required to
78
fix the 32-bit boot issue for Linux kernel v5.10.
79
--
80
2.31.1
81
82
diff view generated by jsdifflib
Deleted patch
1
From: Bin Meng <bin.meng@windriver.com>
2
1
3
The OpenSBI BIOS image names are used by many RISC-V machines.
4
Let's define macros for them.
5
6
Signed-off-by: Bin Meng <bin.meng@windriver.com>
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Message-id: 20210430071302.1489082-7-bmeng.cn@gmail.com
9
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
10
---
11
include/hw/riscv/boot.h | 5 +++++
12
hw/riscv/sifive_u.c | 6 ++----
13
hw/riscv/spike.c | 6 ++----
14
hw/riscv/virt.c | 6 ++----
15
4 files changed, 11 insertions(+), 12 deletions(-)
16
17
diff --git a/include/hw/riscv/boot.h b/include/hw/riscv/boot.h
18
index XXXXXXX..XXXXXXX 100644
19
--- a/include/hw/riscv/boot.h
20
+++ b/include/hw/riscv/boot.h
21
@@ -XXX,XX +XXX,XX @@
22
#include "hw/loader.h"
23
#include "hw/riscv/riscv_hart.h"
24
25
+#define RISCV32_BIOS_BIN "opensbi-riscv32-generic-fw_dynamic.bin"
26
+#define RISCV32_BIOS_ELF "opensbi-riscv32-generic-fw_dynamic.elf"
27
+#define RISCV64_BIOS_BIN "opensbi-riscv64-generic-fw_dynamic.bin"
28
+#define RISCV64_BIOS_ELF "opensbi-riscv64-generic-fw_dynamic.elf"
29
+
30
bool riscv_is_32bit(RISCVHartArrayState *harts);
31
32
target_ulong riscv_calc_kernel_start_addr(RISCVHartArrayState *harts,
33
diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
34
index XXXXXXX..XXXXXXX 100644
35
--- a/hw/riscv/sifive_u.c
36
+++ b/hw/riscv/sifive_u.c
37
@@ -XXX,XX +XXX,XX @@ static void sifive_u_machine_init(MachineState *machine)
38
39
if (riscv_is_32bit(&s->soc.u_cpus)) {
40
firmware_end_addr = riscv_find_and_load_firmware(machine,
41
- "opensbi-riscv32-generic-fw_dynamic.bin",
42
- start_addr, NULL);
43
+ RISCV32_BIOS_BIN, start_addr, NULL);
44
} else {
45
firmware_end_addr = riscv_find_and_load_firmware(machine,
46
- "opensbi-riscv64-generic-fw_dynamic.bin",
47
- start_addr, NULL);
48
+ RISCV64_BIOS_BIN, start_addr, NULL);
49
}
50
51
if (machine->kernel_filename) {
52
diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c
53
index XXXXXXX..XXXXXXX 100644
54
--- a/hw/riscv/spike.c
55
+++ b/hw/riscv/spike.c
56
@@ -XXX,XX +XXX,XX @@ static void spike_board_init(MachineState *machine)
57
*/
58
if (riscv_is_32bit(&s->soc[0])) {
59
firmware_end_addr = riscv_find_and_load_firmware(machine,
60
- "opensbi-riscv32-generic-fw_dynamic.elf",
61
- memmap[SPIKE_DRAM].base,
62
+ RISCV32_BIOS_ELF, memmap[SPIKE_DRAM].base,
63
htif_symbol_callback);
64
} else {
65
firmware_end_addr = riscv_find_and_load_firmware(machine,
66
- "opensbi-riscv64-generic-fw_dynamic.elf",
67
- memmap[SPIKE_DRAM].base,
68
+ RISCV64_BIOS_ELF, memmap[SPIKE_DRAM].base,
69
htif_symbol_callback);
70
}
71
72
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
73
index XXXXXXX..XXXXXXX 100644
74
--- a/hw/riscv/virt.c
75
+++ b/hw/riscv/virt.c
76
@@ -XXX,XX +XXX,XX @@ static void virt_machine_init(MachineState *machine)
77
78
if (riscv_is_32bit(&s->soc[0])) {
79
firmware_end_addr = riscv_find_and_load_firmware(machine,
80
- "opensbi-riscv32-generic-fw_dynamic.bin",
81
- start_addr, NULL);
82
+ RISCV32_BIOS_BIN, start_addr, NULL);
83
} else {
84
firmware_end_addr = riscv_find_and_load_firmware(machine,
85
- "opensbi-riscv64-generic-fw_dynamic.bin",
86
- start_addr, NULL);
87
+ RISCV64_BIOS_BIN, start_addr, NULL);
88
}
89
90
if (machine->kernel_filename) {
91
--
92
2.31.1
93
94
diff view generated by jsdifflib
Deleted patch
1
From: Bin Meng <bin.meng@windriver.com>
2
1
3
At present the Microchip Icicle Kit machine only supports using
4
'-bios' to load the HSS, and does not support '-kernel' for direct
5
kernel booting just like other RISC-V machines do. One has to use
6
U-Boot which is chain-loaded by HSS, to load a kernel for testing.
7
This is not so convenient.
8
9
Adding '-kernel' support together with the existing '-bios', we
10
follow the following table to select which payload we execute:
11
12
-bios | -kernel | payload
13
------+------------+--------
14
N | N | HSS
15
Y | don't care | HSS
16
N | Y | kernel
17
18
This ensures backwards compatibility with how we used to expose
19
'-bios' to users. When '-kernel' is used for direct boot, '-dtb'
20
must be present to provide a valid device tree for the board,
21
as we don't generate device tree.
22
23
When direct kernel boot is used, the OpenSBI fw_dynamic BIOS image
24
is used to boot a payload like U-Boot or OS kernel directly.
25
26
Documentation is updated to describe the direct kernel boot. Note
27
as of today there is still no PolarFire SoC support in the upstream
28
Linux kernel hence the document does not include instructions for
29
that. It will be updated in the future.
30
31
Signed-off-by: Bin Meng <bin.meng@windriver.com>
32
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
33
Message-id: 20210430071302.1489082-8-bmeng.cn@gmail.com
34
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
35
---
36
docs/system/riscv/microchip-icicle-kit.rst | 30 ++++++--
37
hw/riscv/microchip_pfsoc.c | 81 +++++++++++++++++++++-
38
2 files changed, 103 insertions(+), 8 deletions(-)
39
40
diff --git a/docs/system/riscv/microchip-icicle-kit.rst b/docs/system/riscv/microchip-icicle-kit.rst
41
index XXXXXXX..XXXXXXX 100644
42
--- a/docs/system/riscv/microchip-icicle-kit.rst
43
+++ b/docs/system/riscv/microchip-icicle-kit.rst
44
@@ -XXX,XX +XXX,XX @@ Boot options
45
46
The ``microchip-icicle-kit`` machine can start using the standard -bios
47
functionality for loading its BIOS image, aka Hart Software Services (HSS_).
48
-HSS loads the second stage bootloader U-Boot from an SD card. It does not
49
-support direct kernel loading via the -kernel option. One has to load kernel
50
-from U-Boot.
51
+HSS loads the second stage bootloader U-Boot from an SD card. Then a kernel
52
+can be loaded from U-Boot. It also supports direct kernel booting via the
53
+-kernel option along with the device tree blob via -dtb. When direct kernel
54
+boot is used, the OpenSBI fw_dynamic BIOS image is used to boot a payload
55
+like U-Boot or OS kernel directly.
56
+
57
+The user provided DTB should have the following requirements:
58
+
59
+* The /cpus node should contain at least one subnode for E51 and the number
60
+ of subnodes should match QEMU's ``-smp`` option
61
+* The /memory reg size should match QEMU’s selected ram_size via ``-m``
62
+* Should contain a node for the CLINT device with a compatible string
63
+ "riscv,clint0"
64
+
65
+QEMU follows below truth table to select which payload to execute:
66
+
67
+===== ========== =======
68
+-bios -kernel payload
69
+===== ========== =======
70
+ N N HSS
71
+ Y don't care HSS
72
+ N Y kernel
73
+===== ========== =======
74
75
The memory is set to 1537 MiB by default which is the minimum required high
76
memory size by HSS. A sanity check on ram size is performed in the machine
77
init routine to prompt user to increase the RAM size to > 1537 MiB when less
78
than 1537 MiB ram is detected.
79
80
-Boot the machine
81
-----------------
82
+Running HSS
83
+-----------
84
85
HSS 2020.12 release is tested at the time of writing. To build an HSS image
86
that can be booted by the ``microchip-icicle-kit`` machine, type the following
87
diff --git a/hw/riscv/microchip_pfsoc.c b/hw/riscv/microchip_pfsoc.c
88
index XXXXXXX..XXXXXXX 100644
89
--- a/hw/riscv/microchip_pfsoc.c
90
+++ b/hw/riscv/microchip_pfsoc.c
91
@@ -XXX,XX +XXX,XX @@
92
#include "hw/riscv/microchip_pfsoc.h"
93
#include "hw/intc/sifive_clint.h"
94
#include "hw/intc/sifive_plic.h"
95
+#include "sysemu/device_tree.h"
96
#include "sysemu/sysemu.h"
97
98
/*
99
@@ -XXX,XX +XXX,XX @@ static void microchip_icicle_kit_machine_init(MachineState *machine)
100
MemoryRegion *mem_high = g_new(MemoryRegion, 1);
101
MemoryRegion *mem_high_alias = g_new(MemoryRegion, 1);
102
uint64_t mem_high_size;
103
+ hwaddr firmware_load_addr;
104
+ const char *firmware_name;
105
+ bool kernel_as_payload = false;
106
+ target_ulong firmware_end_addr, kernel_start_addr;
107
+ uint64_t kernel_entry;
108
+ uint32_t fdt_load_addr;
109
DriveInfo *dinfo = drive_get_next(IF_SD);
110
111
/* Sanity check on RAM size */
112
@@ -XXX,XX +XXX,XX @@ static void microchip_icicle_kit_machine_init(MachineState *machine)
113
memmap[MICROCHIP_PFSOC_DRAM_HI_ALIAS].base,
114
mem_high_alias);
115
116
- /* Load the firmware */
117
- riscv_find_and_load_firmware(machine, BIOS_FILENAME, RESET_VECTOR, NULL);
118
-
119
/* Attach an SD card */
120
if (dinfo) {
121
CadenceSDHCIState *sdhci = &(s->soc.sdhci);
122
@@ -XXX,XX +XXX,XX @@ static void microchip_icicle_kit_machine_init(MachineState *machine)
123
&error_fatal);
124
qdev_realize_and_unref(card, sdhci->bus, &error_fatal);
125
}
126
+
127
+ /*
128
+ * We follow the following table to select which payload we execute.
129
+ *
130
+ * -bios | -kernel | payload
131
+ * -------+------------+--------
132
+ * N | N | HSS
133
+ * Y | don't care | HSS
134
+ * N | Y | kernel
135
+ *
136
+ * This ensures backwards compatibility with how we used to expose -bios
137
+ * to users but allows them to run through direct kernel booting as well.
138
+ *
139
+ * When -kernel is used for direct boot, -dtb must be present to provide
140
+ * a valid device tree for the board, as we don't generate device tree.
141
+ */
142
+
143
+ if (machine->kernel_filename && machine->dtb) {
144
+ int fdt_size;
145
+ machine->fdt = load_device_tree(machine->dtb, &fdt_size);
146
+ if (!machine->fdt) {
147
+ error_report("load_device_tree() failed");
148
+ exit(1);
149
+ }
150
+
151
+ firmware_name = RISCV64_BIOS_BIN;
152
+ firmware_load_addr = memmap[MICROCHIP_PFSOC_DRAM_LO].base;
153
+ kernel_as_payload = true;
154
+ }
155
+
156
+ if (!kernel_as_payload) {
157
+ firmware_name = BIOS_FILENAME;
158
+ firmware_load_addr = RESET_VECTOR;
159
+ }
160
+
161
+ /* Load the firmware */
162
+ firmware_end_addr = riscv_find_and_load_firmware(machine, firmware_name,
163
+ firmware_load_addr, NULL);
164
+
165
+ if (kernel_as_payload) {
166
+ kernel_start_addr = riscv_calc_kernel_start_addr(&s->soc.u_cpus,
167
+ firmware_end_addr);
168
+
169
+ kernel_entry = riscv_load_kernel(machine->kernel_filename,
170
+ kernel_start_addr, NULL);
171
+
172
+ if (machine->initrd_filename) {
173
+ hwaddr start;
174
+ hwaddr end = riscv_load_initrd(machine->initrd_filename,
175
+ machine->ram_size, kernel_entry,
176
+ &start);
177
+ qemu_fdt_setprop_cell(machine->fdt, "/chosen",
178
+ "linux,initrd-start", start);
179
+ qemu_fdt_setprop_cell(machine->fdt, "/chosen",
180
+ "linux,initrd-end", end);
181
+ }
182
+
183
+ if (machine->kernel_cmdline) {
184
+ qemu_fdt_setprop_string(machine->fdt, "/chosen",
185
+ "bootargs", machine->kernel_cmdline);
186
+ }
187
+
188
+ /* Compute the fdt load address in dram */
189
+ fdt_load_addr = riscv_load_fdt(memmap[MICROCHIP_PFSOC_DRAM_LO].base,
190
+ machine->ram_size, machine->fdt);
191
+ /* Load the reset vector */
192
+ riscv_setup_rom_reset_vec(machine, &s->soc.u_cpus, firmware_load_addr,
193
+ memmap[MICROCHIP_PFSOC_ENVM_DATA].base,
194
+ memmap[MICROCHIP_PFSOC_ENVM_DATA].size,
195
+ kernel_entry, fdt_load_addr, machine->fdt);
196
+ }
197
}
198
199
static void microchip_icicle_kit_machine_class_init(ObjectClass *oc, void *data)
200
--
201
2.31.1
202
203
diff view generated by jsdifflib
Deleted patch
1
From: Jose Martins <josemartins90@gmail.com>
2
1
3
The wfi exception trigger behavior should take into account user mode,
4
hstatus.vtw, and the fact the an wfi might raise different types of
5
exceptions depending on various factors:
6
7
If supervisor mode is not present:
8
9
- an illegal instruction exception should be generated if user mode
10
executes and wfi instruction and mstatus.tw = 1.
11
12
If supervisor mode is present:
13
14
- when a wfi instruction is executed, an illegal exception should be triggered
15
if either the current mode is user or the mode is supervisor and mstatus.tw is
16
set.
17
18
Plus, if the hypervisor extensions are enabled:
19
20
- a virtual instruction exception should be raised when a wfi is executed from
21
virtual-user or virtual-supervisor and hstatus.vtw is set.
22
23
Signed-off-by: Jose Martins <josemartins90@gmail.com>
24
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
25
Message-id: 20210420213656.85148-1-josemartins90@gmail.com
26
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
27
---
28
target/riscv/cpu_bits.h | 1 +
29
target/riscv/op_helper.c | 11 ++++++++---
30
2 files changed, 9 insertions(+), 3 deletions(-)
31
32
diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h
33
index XXXXXXX..XXXXXXX 100644
34
--- a/target/riscv/cpu_bits.h
35
+++ b/target/riscv/cpu_bits.h
36
@@ -XXX,XX +XXX,XX @@
37
#define HSTATUS_HU 0x00000200
38
#define HSTATUS_VGEIN 0x0003F000
39
#define HSTATUS_VTVM 0x00100000
40
+#define HSTATUS_VTW 0x00200000
41
#define HSTATUS_VTSR 0x00400000
42
#define HSTATUS_VSXL 0x300000000
43
44
diff --git a/target/riscv/op_helper.c b/target/riscv/op_helper.c
45
index XXXXXXX..XXXXXXX 100644
46
--- a/target/riscv/op_helper.c
47
+++ b/target/riscv/op_helper.c
48
@@ -XXX,XX +XXX,XX @@ target_ulong helper_mret(CPURISCVState *env, target_ulong cpu_pc_deb)
49
void helper_wfi(CPURISCVState *env)
50
{
51
CPUState *cs = env_cpu(env);
52
+ bool rvs = riscv_has_ext(env, RVS);
53
+ bool prv_u = env->priv == PRV_U;
54
+ bool prv_s = env->priv == PRV_S;
55
56
- if ((env->priv == PRV_S &&
57
- get_field(env->mstatus, MSTATUS_TW)) ||
58
- riscv_cpu_virt_enabled(env)) {
59
+ if (((prv_s || (!rvs && prv_u)) && get_field(env->mstatus, MSTATUS_TW)) ||
60
+ (rvs && prv_u && !riscv_cpu_virt_enabled(env))) {
61
+ riscv_raise_exception(env, RISCV_EXCP_ILLEGAL_INST, GETPC());
62
+ } else if (riscv_cpu_virt_enabled(env) && (prv_u ||
63
+ (prv_s && get_field(env->hstatus, HSTATUS_VTW)))) {
64
riscv_raise_exception(env, RISCV_EXCP_VIRT_INSTRUCTION_FAULT, GETPC());
65
} else {
66
cs->halted = 1;
67
--
68
2.31.1
69
70
diff view generated by jsdifflib
1
QEMU 5.1 changed the behaviour of the default boot for the RISC-V virt
1
From: Thomas Huth <thuth@redhat.com>
2
and sifive_u machines. This patch moves that change from the
3
deprecated.rst file to the removed-features.rst file and the
4
target-riscv.rst.
5
2
3
Configuring a drive with "if=none" is meant for creation of a backend
4
only, it should not get automatically assigned to a device frontend.
5
Use "if=pflash" for the One-Time-Programmable device instead (like
6
it is e.g. also done for the efuse device in hw/arm/xlnx-zcu102.c).
7
8
Since the old way of configuring the device has already been published
9
with the previous QEMU versions, we cannot remove this immediately, but
10
have to deprecate it and support it for at least two more releases.
11
12
Signed-off-by: Thomas Huth <thuth@redhat.com>
13
Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
14
Reviewed-by: Markus Armbruster <armbru@redhat.com>
15
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
16
Message-id: 20211119102549.217755-1-thuth@redhat.com
6
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
17
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
7
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
8
Message-id: 4f1c261e7f69045ab8bb8926d85fe1d35e48ea5b.1620081256.git.alistair.francis@wdc.com
9
---
18
---
10
docs/system/deprecated.rst | 19 -------------------
19
docs/about/deprecated.rst | 6 ++++++
11
docs/system/removed-features.rst | 5 +++++
20
hw/misc/sifive_u_otp.c | 9 ++++++++-
12
docs/system/target-riscv.rst | 13 ++++++++++++-
21
2 files changed, 14 insertions(+), 1 deletion(-)
13
3 files changed, 17 insertions(+), 20 deletions(-)
14
22
15
diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
23
diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
16
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
17
--- a/docs/system/deprecated.rst
25
--- a/docs/about/deprecated.rst
18
+++ b/docs/system/deprecated.rst
26
+++ b/docs/about/deprecated.rst
19
@@ -XXX,XX +XXX,XX @@ pcspk-audiodev=<name>``.
27
@@ -XXX,XX +XXX,XX @@ as short-form boolean values, and passed to plugins as ``arg_name=on``.
20
``tty`` and ``parport`` are aliases that will be removed. Instead, the
28
However, short-form booleans are deprecated and full explicit ``arg_name=on``
21
actual backend names ``serial`` and ``parallel`` should be used.
29
form is preferred.
22
30
23
-RISC-V ``-bios`` (since 5.1)
31
+``-drive if=none`` for the sifive_u OTP device (since 6.2)
24
-''''''''''''''''''''''''''''
32
+''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
25
-
26
-QEMU 4.1 introduced support for the -bios option in QEMU for RISC-V for the
27
-RISC-V virt machine and sifive_u machine. QEMU 4.1 had no changes to the
28
-default behaviour to avoid breakages.
29
-
30
-QEMU 5.1 changes the default behaviour from ``-bios none`` to ``-bios default``.
31
-
32
-QEMU 5.1 has three options:
33
- 1. ``-bios default`` - This is the current default behavior if no -bios option
34
- is included. This option will load the default OpenSBI firmware automatically.
35
- The firmware is included with the QEMU release and no user interaction is
36
- required. All a user needs to do is specify the kernel they want to boot
37
- with the -kernel option
38
- 2. ``-bios none`` - QEMU will not automatically load any firmware. It is up
39
- to the user to load all the images they need.
40
- 3. ``-bios <file>`` - Tells QEMU to load the specified file as the firmwrae.
41
-
42
Short-form boolean options (since 6.0)
43
''''''''''''''''''''''''''''''''''''''
44
45
diff --git a/docs/system/removed-features.rst b/docs/system/removed-features.rst
46
index XXXXXXX..XXXXXXX 100644
47
--- a/docs/system/removed-features.rst
48
+++ b/docs/system/removed-features.rst
49
@@ -XXX,XX +XXX,XX @@ devices. Drives the board doesn't pick up can no longer be used with
50
This option was undocumented and not used in the field.
51
Use `-device usb-ccid`` instead.
52
53
+RISC-V firmware not booted by default (removed in 5.1)
54
+''''''''''''''''''''''''''''''''''''''''''''''''''''''
55
+
33
+
56
+QEMU 5.1 changes the default behaviour from ``-bios none`` to ``-bios default``
34
+Using ``-drive if=none`` to configure the OTP device of the sifive_u
57
+for the RISC-V ``virt`` machine and ``sifive_u`` machine.
35
+RISC-V machine is deprecated. Use ``-drive if=pflash`` instead.
36
+
58
37
59
QEMU Machine Protocol (QMP) commands
38
QEMU Machine Protocol (QMP) commands
60
------------------------------------
39
------------------------------------
61
diff --git a/docs/system/target-riscv.rst b/docs/system/target-riscv.rst
40
diff --git a/hw/misc/sifive_u_otp.c b/hw/misc/sifive_u_otp.c
62
index XXXXXXX..XXXXXXX 100644
41
index XXXXXXX..XXXXXXX 100644
63
--- a/docs/system/target-riscv.rst
42
--- a/hw/misc/sifive_u_otp.c
64
+++ b/docs/system/target-riscv.rst
43
+++ b/hw/misc/sifive_u_otp.c
65
@@ -XXX,XX +XXX,XX @@ undocumented; you can get a complete list by running
44
@@ -XXX,XX +XXX,XX @@ static void sifive_u_otp_realize(DeviceState *dev, Error **errp)
66
riscv/shakti-c
45
TYPE_SIFIVE_U_OTP, SIFIVE_U_OTP_REG_SIZE);
67
riscv/sifive_u
46
sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->mmio);
68
47
69
-RISC-V CPU features
48
- dinfo = drive_get_next(IF_NONE);
70
+RISC-V CPU firmware
49
+ dinfo = drive_get_next(IF_PFLASH);
71
-------------------
50
+ if (!dinfo) {
72
+
51
+ dinfo = drive_get_next(IF_NONE);
73
+When using the ``sifive_u`` or ``virt`` machine there are three different
52
+ if (dinfo) {
74
+firmware boot options:
53
+ warn_report("using \"-drive if=none\" for the OTP is deprecated, "
75
+1. ``-bios default`` - This is the default behaviour if no -bios option
54
+ "use \"-drive if=pflash\" instead.");
76
+is included. This option will load the default OpenSBI firmware automatically.
55
+ }
77
+The firmware is included with the QEMU release and no user interaction is
56
+ }
78
+required. All a user needs to do is specify the kernel they want to boot
57
if (dinfo) {
79
+with the -kernel option
58
int ret;
80
+2. ``-bios none`` - QEMU will not automatically load any firmware. It is up
59
uint64_t perm;
81
+to the user to load all the images they need.
82
+3. ``-bios <file>`` - Tells QEMU to load the specified file as the firmware.
83
--
60
--
84
2.31.1
61
2.31.1
85
62
86
63
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
2
3
Physical Memory Protection is a system feature.
3
Once a "One Time Programmable" is programmed, it shouldn't be reset.
4
Avoid polluting the user-mode emulation by its definitions.
5
4
5
Do not re-initialize the OTP content in the DeviceReset handler,
6
initialize it once in the DeviceRealize one.
7
8
Fixes: 9fb45c62ae8 ("riscv: sifive: Implement a model for SiFive FU540 OTP")
6
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
10
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
11
Message-Id: <20211119104757.331579-1-f4bug@amsat.org>
9
Message-id: 20210516205333.696094-1-f4bug@amsat.org
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
12
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
13
---
12
target/riscv/cpu.h | 2 ++
14
hw/misc/sifive_u_otp.c | 13 +++++--------
13
1 file changed, 2 insertions(+)
15
1 file changed, 5 insertions(+), 8 deletions(-)
14
16
15
diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
17
diff --git a/hw/misc/sifive_u_otp.c b/hw/misc/sifive_u_otp.c
16
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
17
--- a/target/riscv/cpu.h
19
--- a/hw/misc/sifive_u_otp.c
18
+++ b/target/riscv/cpu.h
20
+++ b/hw/misc/sifive_u_otp.c
19
@@ -XXX,XX +XXX,XX @@ enum {
21
@@ -XXX,XX +XXX,XX @@ static void sifive_u_otp_realize(DeviceState *dev, Error **errp)
20
22
21
typedef struct CPURISCVState CPURISCVState;
23
if (blk_pread(s->blk, 0, s->fuse, filesize) != filesize) {
22
24
error_setg(errp, "failed to read the initial flash content");
23
+#if !defined(CONFIG_USER_ONLY)
25
+ return;
24
#include "pmp.h"
26
}
25
+#endif
27
}
26
28
}
27
#define RV_VLEN_MAX 256
29
-}
28
30
-
31
-static void sifive_u_otp_reset(DeviceState *dev)
32
-{
33
- SiFiveUOTPState *s = SIFIVE_U_OTP(dev);
34
35
/* Initialize all fuses' initial value to 0xFFs */
36
memset(s->fuse, 0xff, sizeof(s->fuse));
37
@@ -XXX,XX +XXX,XX @@ static void sifive_u_otp_reset(DeviceState *dev)
38
serial_data = s->serial;
39
if (blk_pwrite(s->blk, index * SIFIVE_U_OTP_FUSE_WORD,
40
&serial_data, SIFIVE_U_OTP_FUSE_WORD, 0) < 0) {
41
- error_report("write error index<%d>", index);
42
+ error_setg(errp, "failed to write index<%d>", index);
43
+ return;
44
}
45
46
serial_data = ~(s->serial);
47
if (blk_pwrite(s->blk, (index + 1) * SIFIVE_U_OTP_FUSE_WORD,
48
&serial_data, SIFIVE_U_OTP_FUSE_WORD, 0) < 0) {
49
- error_report("write error index<%d>", index + 1);
50
+ error_setg(errp, "failed to write index<%d>", index + 1);
51
+ return;
52
}
53
}
54
55
@@ -XXX,XX +XXX,XX @@ static void sifive_u_otp_class_init(ObjectClass *klass, void *data)
56
57
device_class_set_props(dc, sifive_u_otp_properties);
58
dc->realize = sifive_u_otp_realize;
59
- dc->reset = sifive_u_otp_reset;
60
}
61
62
static const TypeInfo sifive_u_otp_info = {
29
--
63
--
30
2.31.1
64
2.31.1
31
65
32
66
diff view generated by jsdifflib
Deleted patch
1
From: Bin Meng <bmeng.cn@gmail.com>
2
1
3
riscv_excp_names[] and riscv_intr_names[] are only referenced by
4
target/riscv/cpu.c locally.
5
6
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Message-id: 20210514052435.2203156-1-bmeng.cn@gmail.com
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
12
target/riscv/cpu.h | 2 --
13
target/riscv/cpu.c | 4 ++--
14
2 files changed, 2 insertions(+), 4 deletions(-)
15
16
diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
17
index XXXXXXX..XXXXXXX 100644
18
--- a/target/riscv/cpu.h
19
+++ b/target/riscv/cpu.h
20
@@ -XXX,XX +XXX,XX @@ static inline bool riscv_feature(CPURISCVState *env, int feature)
21
22
extern const char * const riscv_int_regnames[];
23
extern const char * const riscv_fpr_regnames[];
24
-extern const char * const riscv_excp_names[];
25
-extern const char * const riscv_intr_names[];
26
27
const char *riscv_cpu_get_trap_name(target_ulong cause, bool async);
28
void riscv_cpu_do_interrupt(CPUState *cpu);
29
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
30
index XXXXXXX..XXXXXXX 100644
31
--- a/target/riscv/cpu.c
32
+++ b/target/riscv/cpu.c
33
@@ -XXX,XX +XXX,XX @@ const char * const riscv_fpr_regnames[] = {
34
"f30/ft10", "f31/ft11"
35
};
36
37
-const char * const riscv_excp_names[] = {
38
+static const char * const riscv_excp_names[] = {
39
"misaligned_fetch",
40
"fault_fetch",
41
"illegal_instruction",
42
@@ -XXX,XX +XXX,XX @@ const char * const riscv_excp_names[] = {
43
"guest_store_page_fault",
44
};
45
46
-const char * const riscv_intr_names[] = {
47
+static const char * const riscv_intr_names[] = {
48
"u_software",
49
"s_software",
50
"vs_software",
51
--
52
2.31.1
53
54
diff view generated by jsdifflib
Deleted patch
1
From: Changbin Du <changbin.du@gmail.com>
2
1
3
This dumps the CSR mscratch/sscratch/satp and meanwhile aligns
4
the output of CSR mtval/stval.
5
6
Signed-off-by: Changbin Du <changbin.du@gmail.com>
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
9
Message-id: 20210519155738.20486-1-changbin.du@gmail.com
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
12
target/riscv/cpu.c | 7 +++++--
13
1 file changed, 5 insertions(+), 2 deletions(-)
14
15
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/riscv/cpu.c
18
+++ b/target/riscv/cpu.c
19
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags)
20
if (riscv_has_ext(env, RVH)) {
21
qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "vscause ", env->vscause);
22
}
23
- qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mtval ", env->mtval);
24
- qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "stval ", env->stval);
25
+ qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mtval ", env->mtval);
26
+ qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "stval ", env->stval);
27
if (riscv_has_ext(env, RVH)) {
28
qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "htval ", env->htval);
29
qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mtval2 ", env->mtval2);
30
}
31
+ qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mscratch", env->mscratch);
32
+ qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "sscratch", env->sscratch);
33
+ qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "satp ", env->satp);
34
#endif
35
36
for (i = 0; i < 32; i++) {
37
--
38
2.31.1
39
40
diff view generated by jsdifflib
Deleted patch
1
Although we construct epmp_operation in such a way that it can only be
2
between 0 and 15 Coverity complains that we don't handle the other
3
possible cases. To fix Coverity and make it easier for humans to read
4
add a default case to the switch statement that calls
5
g_assert_not_reached().
6
1
7
Fixes: CID 1453108
8
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
9
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
10
Reviewed-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
11
Message-id: ec5f225928eec448278c82fcb1f6805ee61dde82.1621550996.git.alistair.francis@wdc.com
12
---
13
target/riscv/pmp.c | 4 ++++
14
1 file changed, 4 insertions(+)
15
16
diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/target/riscv/pmp.c
19
+++ b/target/riscv/pmp.c
20
@@ -XXX,XX +XXX,XX @@ bool pmp_hart_has_privs(CPURISCVState *env, target_ulong addr,
21
case 15:
22
*allowed_privs = PMP_READ;
23
break;
24
+ default:
25
+ g_assert_not_reached();
26
}
27
} else {
28
switch (epmp_operation) {
29
@@ -XXX,XX +XXX,XX @@ bool pmp_hart_has_privs(CPURISCVState *env, target_ulong addr,
30
case 7:
31
*allowed_privs = PMP_READ | PMP_WRITE | PMP_EXEC;
32
break;
33
+ default:
34
+ g_assert_not_reached();
35
}
36
}
37
}
38
--
39
2.31.1
40
41
diff view generated by jsdifflib
Deleted patch
1
From: LIU Zhiwei <zhiwei_liu@c-sky.com>
2
1
3
Since commit e2e7168a214b0ed98dc357bba96816486a289762, if oprsz
4
is still zero(as we don't use this field), simd_desc will trigger an
5
assert.
6
7
Besides, tcg_gen_gvec_*_ptr calls simd_desc in it's implementation.
8
Here we pass the value to maxsz and oprsz to bypass the assert.
9
10
Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 20210521054816.1784297-1-zhiwei_liu@c-sky.com
13
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
14
---
15
target/riscv/insn_trans/trans_rvv.c.inc | 89 ++++++++++++++-----------
16
1 file changed, 50 insertions(+), 39 deletions(-)
17
18
diff --git a/target/riscv/insn_trans/trans_rvv.c.inc b/target/riscv/insn_trans/trans_rvv.c.inc
19
index XXXXXXX..XXXXXXX 100644
20
--- a/target/riscv/insn_trans/trans_rvv.c.inc
21
+++ b/target/riscv/insn_trans/trans_rvv.c.inc
22
@@ -XXX,XX +XXX,XX @@ static bool ldst_us_trans(uint32_t vd, uint32_t rs1, uint32_t data,
23
* The first part is vlen in bytes, encoded in maxsz of simd_desc.
24
* The second part is lmul, encoded in data of simd_desc.
25
*/
26
- desc = tcg_const_i32(simd_desc(0, s->vlen / 8, data));
27
+ desc = tcg_const_i32(simd_desc(s->vlen / 8, s->vlen / 8, data));
28
29
gen_get_gpr(base, rs1);
30
tcg_gen_addi_ptr(dest, cpu_env, vreg_ofs(s, vd));
31
@@ -XXX,XX +XXX,XX @@ static bool ldst_stride_trans(uint32_t vd, uint32_t rs1, uint32_t rs2,
32
mask = tcg_temp_new_ptr();
33
base = tcg_temp_new();
34
stride = tcg_temp_new();
35
- desc = tcg_const_i32(simd_desc(0, s->vlen / 8, data));
36
+ desc = tcg_const_i32(simd_desc(s->vlen / 8, s->vlen / 8, data));
37
38
gen_get_gpr(base, rs1);
39
gen_get_gpr(stride, rs2);
40
@@ -XXX,XX +XXX,XX @@ static bool ldst_index_trans(uint32_t vd, uint32_t rs1, uint32_t vs2,
41
mask = tcg_temp_new_ptr();
42
index = tcg_temp_new_ptr();
43
base = tcg_temp_new();
44
- desc = tcg_const_i32(simd_desc(0, s->vlen / 8, data));
45
+ desc = tcg_const_i32(simd_desc(s->vlen / 8, s->vlen / 8, data));
46
47
gen_get_gpr(base, rs1);
48
tcg_gen_addi_ptr(dest, cpu_env, vreg_ofs(s, vd));
49
@@ -XXX,XX +XXX,XX @@ static bool ldff_trans(uint32_t vd, uint32_t rs1, uint32_t data,
50
dest = tcg_temp_new_ptr();
51
mask = tcg_temp_new_ptr();
52
base = tcg_temp_new();
53
- desc = tcg_const_i32(simd_desc(0, s->vlen / 8, data));
54
+ desc = tcg_const_i32(simd_desc(s->vlen / 8, s->vlen / 8, data));
55
56
gen_get_gpr(base, rs1);
57
tcg_gen_addi_ptr(dest, cpu_env, vreg_ofs(s, vd));
58
@@ -XXX,XX +XXX,XX @@ static bool amo_trans(uint32_t vd, uint32_t rs1, uint32_t vs2,
59
mask = tcg_temp_new_ptr();
60
index = tcg_temp_new_ptr();
61
base = tcg_temp_new();
62
- desc = tcg_const_i32(simd_desc(0, s->vlen / 8, data));
63
+ desc = tcg_const_i32(simd_desc(s->vlen / 8, s->vlen / 8, data));
64
65
gen_get_gpr(base, rs1);
66
tcg_gen_addi_ptr(dest, cpu_env, vreg_ofs(s, vd));
67
@@ -XXX,XX +XXX,XX @@ do_opivv_gvec(DisasContext *s, arg_rmrr *a, GVecGen3Fn *gvec_fn,
68
data = FIELD_DP32(data, VDATA, LMUL, s->lmul);
69
tcg_gen_gvec_4_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0),
70
vreg_ofs(s, a->rs1), vreg_ofs(s, a->rs2),
71
- cpu_env, 0, s->vlen / 8, data, fn);
72
+ cpu_env, s->vlen / 8, s->vlen / 8, data, fn);
73
}
74
gen_set_label(over);
75
return true;
76
@@ -XXX,XX +XXX,XX @@ static bool opivx_trans(uint32_t vd, uint32_t rs1, uint32_t vs2, uint32_t vm,
77
data = FIELD_DP32(data, VDATA, MLEN, s->mlen);
78
data = FIELD_DP32(data, VDATA, VM, vm);
79
data = FIELD_DP32(data, VDATA, LMUL, s->lmul);
80
- desc = tcg_const_i32(simd_desc(0, s->vlen / 8, data));
81
+ desc = tcg_const_i32(simd_desc(s->vlen / 8, s->vlen / 8, data));
82
83
tcg_gen_addi_ptr(dest, cpu_env, vreg_ofs(s, vd));
84
tcg_gen_addi_ptr(src2, cpu_env, vreg_ofs(s, vs2));
85
@@ -XXX,XX +XXX,XX @@ static bool opivi_trans(uint32_t vd, uint32_t imm, uint32_t vs2, uint32_t vm,
86
data = FIELD_DP32(data, VDATA, MLEN, s->mlen);
87
data = FIELD_DP32(data, VDATA, VM, vm);
88
data = FIELD_DP32(data, VDATA, LMUL, s->lmul);
89
- desc = tcg_const_i32(simd_desc(0, s->vlen / 8, data));
90
+ desc = tcg_const_i32(simd_desc(s->vlen / 8, s->vlen / 8, data));
91
92
tcg_gen_addi_ptr(dest, cpu_env, vreg_ofs(s, vd));
93
tcg_gen_addi_ptr(src2, cpu_env, vreg_ofs(s, vs2));
94
@@ -XXX,XX +XXX,XX @@ static bool do_opivv_widen(DisasContext *s, arg_rmrr *a,
95
tcg_gen_gvec_4_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0),
96
vreg_ofs(s, a->rs1),
97
vreg_ofs(s, a->rs2),
98
- cpu_env, 0, s->vlen / 8,
99
+ cpu_env, s->vlen / 8, s->vlen / 8,
100
data, fn);
101
gen_set_label(over);
102
return true;
103
@@ -XXX,XX +XXX,XX @@ static bool do_opiwv_widen(DisasContext *s, arg_rmrr *a,
104
tcg_gen_gvec_4_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0),
105
vreg_ofs(s, a->rs1),
106
vreg_ofs(s, a->rs2),
107
- cpu_env, 0, s->vlen / 8, data, fn);
108
+ cpu_env, s->vlen / 8, s->vlen / 8, data, fn);
109
gen_set_label(over);
110
return true;
111
}
112
@@ -XXX,XX +XXX,XX @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \
113
data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \
114
tcg_gen_gvec_4_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0), \
115
vreg_ofs(s, a->rs1), \
116
- vreg_ofs(s, a->rs2), cpu_env, 0, \
117
- s->vlen / 8, data, fns[s->sew]); \
118
+ vreg_ofs(s, a->rs2), cpu_env, \
119
+ s->vlen / 8, s->vlen / 8, data, \
120
+ fns[s->sew]); \
121
gen_set_label(over); \
122
return true; \
123
} \
124
@@ -XXX,XX +XXX,XX @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \
125
data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \
126
tcg_gen_gvec_4_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0), \
127
vreg_ofs(s, a->rs1), \
128
- vreg_ofs(s, a->rs2), cpu_env, 0, \
129
- s->vlen / 8, data, fns[s->sew]); \
130
+ vreg_ofs(s, a->rs2), cpu_env, \
131
+ s->vlen / 8, s->vlen / 8, data, \
132
+ fns[s->sew]); \
133
gen_set_label(over); \
134
return true; \
135
} \
136
@@ -XXX,XX +XXX,XX @@ static bool trans_vmv_v_x(DisasContext *s, arg_vmv_v_x *a)
137
};
138
139
tcg_gen_ext_tl_i64(s1_i64, s1);
140
- desc = tcg_const_i32(simd_desc(0, s->vlen / 8, data));
141
+ desc = tcg_const_i32(simd_desc(s->vlen / 8, s->vlen / 8, data));
142
tcg_gen_addi_ptr(dest, cpu_env, vreg_ofs(s, a->rd));
143
fns[s->sew](dest, s1_i64, cpu_env, desc);
144
145
@@ -XXX,XX +XXX,XX @@ static bool trans_vmv_v_i(DisasContext *s, arg_vmv_v_i *a)
146
147
s1 = tcg_const_i64(simm);
148
dest = tcg_temp_new_ptr();
149
- desc = tcg_const_i32(simd_desc(0, s->vlen / 8, data));
150
+ desc = tcg_const_i32(simd_desc(s->vlen / 8, s->vlen / 8, data));
151
tcg_gen_addi_ptr(dest, cpu_env, vreg_ofs(s, a->rd));
152
fns[s->sew](dest, s1, cpu_env, desc);
153
154
@@ -XXX,XX +XXX,XX @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \
155
data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \
156
tcg_gen_gvec_4_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0), \
157
vreg_ofs(s, a->rs1), \
158
- vreg_ofs(s, a->rs2), cpu_env, 0, \
159
- s->vlen / 8, data, fns[s->sew - 1]); \
160
+ vreg_ofs(s, a->rs2), cpu_env, \
161
+ s->vlen / 8, s->vlen / 8, data, \
162
+ fns[s->sew - 1]); \
163
gen_set_label(over); \
164
return true; \
165
} \
166
@@ -XXX,XX +XXX,XX @@ static bool opfvf_trans(uint32_t vd, uint32_t rs1, uint32_t vs2,
167
dest = tcg_temp_new_ptr();
168
mask = tcg_temp_new_ptr();
169
src2 = tcg_temp_new_ptr();
170
- desc = tcg_const_i32(simd_desc(0, s->vlen / 8, data));
171
+ desc = tcg_const_i32(simd_desc(s->vlen / 8, s->vlen / 8, data));
172
173
tcg_gen_addi_ptr(dest, cpu_env, vreg_ofs(s, vd));
174
tcg_gen_addi_ptr(src2, cpu_env, vreg_ofs(s, vs2));
175
@@ -XXX,XX +XXX,XX @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \
176
data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \
177
tcg_gen_gvec_4_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0), \
178
vreg_ofs(s, a->rs1), \
179
- vreg_ofs(s, a->rs2), cpu_env, 0, \
180
- s->vlen / 8, data, fns[s->sew - 1]); \
181
+ vreg_ofs(s, a->rs2), cpu_env, \
182
+ s->vlen / 8, s->vlen / 8, data, \
183
+ fns[s->sew - 1]); \
184
gen_set_label(over); \
185
return true; \
186
} \
187
@@ -XXX,XX +XXX,XX @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \
188
data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \
189
tcg_gen_gvec_4_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0), \
190
vreg_ofs(s, a->rs1), \
191
- vreg_ofs(s, a->rs2), cpu_env, 0, \
192
- s->vlen / 8, data, fns[s->sew - 1]); \
193
+ vreg_ofs(s, a->rs2), cpu_env, \
194
+ s->vlen / 8, s->vlen / 8, data, \
195
+ fns[s->sew - 1]); \
196
gen_set_label(over); \
197
return true; \
198
} \
199
@@ -XXX,XX +XXX,XX @@ static bool trans_##NAME(DisasContext *s, arg_rmr *a) \
200
data = FIELD_DP32(data, VDATA, VM, a->vm); \
201
data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \
202
tcg_gen_gvec_3_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0), \
203
- vreg_ofs(s, a->rs2), cpu_env, 0, \
204
- s->vlen / 8, data, fns[s->sew - 1]); \
205
+ vreg_ofs(s, a->rs2), cpu_env, \
206
+ s->vlen / 8, s->vlen / 8, data, \
207
+ fns[s->sew - 1]); \
208
gen_set_label(over); \
209
return true; \
210
} \
211
@@ -XXX,XX +XXX,XX @@ static bool trans_vfmv_v_f(DisasContext *s, arg_vfmv_v_f *a)
212
tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over);
213
214
dest = tcg_temp_new_ptr();
215
- desc = tcg_const_i32(simd_desc(0, s->vlen / 8, data));
216
+ desc = tcg_const_i32(simd_desc(s->vlen / 8, s->vlen / 8, data));
217
tcg_gen_addi_ptr(dest, cpu_env, vreg_ofs(s, a->rd));
218
fns[s->sew - 1](dest, cpu_fpr[a->rs1], cpu_env, desc);
219
220
@@ -XXX,XX +XXX,XX @@ static bool trans_##NAME(DisasContext *s, arg_rmr *a) \
221
data = FIELD_DP32(data, VDATA, VM, a->vm); \
222
data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \
223
tcg_gen_gvec_3_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0), \
224
- vreg_ofs(s, a->rs2), cpu_env, 0, \
225
- s->vlen / 8, data, fns[s->sew - 1]); \
226
+ vreg_ofs(s, a->rs2), cpu_env, \
227
+ s->vlen / 8, s->vlen / 8, data, \
228
+ fns[s->sew - 1]); \
229
gen_set_label(over); \
230
return true; \
231
} \
232
@@ -XXX,XX +XXX,XX @@ static bool trans_##NAME(DisasContext *s, arg_rmr *a) \
233
data = FIELD_DP32(data, VDATA, VM, a->vm); \
234
data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \
235
tcg_gen_gvec_3_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0), \
236
- vreg_ofs(s, a->rs2), cpu_env, 0, \
237
- s->vlen / 8, data, fns[s->sew - 1]); \
238
+ vreg_ofs(s, a->rs2), cpu_env, \
239
+ s->vlen / 8, s->vlen / 8, data, \
240
+ fns[s->sew - 1]); \
241
gen_set_label(over); \
242
return true; \
243
} \
244
@@ -XXX,XX +XXX,XX @@ static bool trans_##NAME(DisasContext *s, arg_r *a) \
245
data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \
246
tcg_gen_gvec_4_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0), \
247
vreg_ofs(s, a->rs1), \
248
- vreg_ofs(s, a->rs2), cpu_env, 0, \
249
- s->vlen / 8, data, fn); \
250
+ vreg_ofs(s, a->rs2), cpu_env, \
251
+ s->vlen / 8, s->vlen / 8, data, fn); \
252
gen_set_label(over); \
253
return true; \
254
} \
255
@@ -XXX,XX +XXX,XX @@ static bool trans_vmpopc_m(DisasContext *s, arg_rmr *a)
256
mask = tcg_temp_new_ptr();
257
src2 = tcg_temp_new_ptr();
258
dst = tcg_temp_new();
259
- desc = tcg_const_i32(simd_desc(0, s->vlen / 8, data));
260
+ desc = tcg_const_i32(simd_desc(s->vlen / 8, s->vlen / 8, data));
261
262
tcg_gen_addi_ptr(src2, cpu_env, vreg_ofs(s, a->rs2));
263
tcg_gen_addi_ptr(mask, cpu_env, vreg_ofs(s, 0));
264
@@ -XXX,XX +XXX,XX @@ static bool trans_vmfirst_m(DisasContext *s, arg_rmr *a)
265
mask = tcg_temp_new_ptr();
266
src2 = tcg_temp_new_ptr();
267
dst = tcg_temp_new();
268
- desc = tcg_const_i32(simd_desc(0, s->vlen / 8, data));
269
+ desc = tcg_const_i32(simd_desc(s->vlen / 8, s->vlen / 8, data));
270
271
tcg_gen_addi_ptr(src2, cpu_env, vreg_ofs(s, a->rs2));
272
tcg_gen_addi_ptr(mask, cpu_env, vreg_ofs(s, 0));
273
@@ -XXX,XX +XXX,XX @@ static bool trans_##NAME(DisasContext *s, arg_rmr *a) \
274
data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \
275
tcg_gen_gvec_3_ptr(vreg_ofs(s, a->rd), \
276
vreg_ofs(s, 0), vreg_ofs(s, a->rs2), \
277
- cpu_env, 0, s->vlen / 8, data, fn); \
278
+ cpu_env, s->vlen / 8, s->vlen / 8, \
279
+ data, fn); \
280
gen_set_label(over); \
281
return true; \
282
} \
283
@@ -XXX,XX +XXX,XX @@ static bool trans_viota_m(DisasContext *s, arg_viota_m *a)
284
gen_helper_viota_m_w, gen_helper_viota_m_d,
285
};
286
tcg_gen_gvec_3_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0),
287
- vreg_ofs(s, a->rs2), cpu_env, 0,
288
- s->vlen / 8, data, fns[s->sew]);
289
+ vreg_ofs(s, a->rs2), cpu_env,
290
+ s->vlen / 8, s->vlen / 8, data, fns[s->sew]);
291
gen_set_label(over);
292
return true;
293
}
294
@@ -XXX,XX +XXX,XX @@ static bool trans_vid_v(DisasContext *s, arg_vid_v *a)
295
gen_helper_vid_v_w, gen_helper_vid_v_d,
296
};
297
tcg_gen_gvec_2_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0),
298
- cpu_env, 0, s->vlen / 8, data, fns[s->sew]);
299
+ cpu_env, s->vlen / 8, s->vlen / 8,
300
+ data, fns[s->sew]);
301
gen_set_label(over);
302
return true;
303
}
304
@@ -XXX,XX +XXX,XX @@ static bool trans_vcompress_vm(DisasContext *s, arg_r *a)
305
data = FIELD_DP32(data, VDATA, LMUL, s->lmul);
306
tcg_gen_gvec_4_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0),
307
vreg_ofs(s, a->rs1), vreg_ofs(s, a->rs2),
308
- cpu_env, 0, s->vlen / 8, data, fns[s->sew]);
309
+ cpu_env, s->vlen / 8, s->vlen / 8, data,
310
+ fns[s->sew]);
311
gen_set_label(over);
312
return true;
313
}
314
--
315
2.31.1
316
317
diff view generated by jsdifflib
Deleted patch
1
From: Kito Cheng <kito.cheng@sifive.com>
2
1
3
Signed-off-by: Kito Cheng <kito.cheng@sifive.com>
4
Signed-off-by: Frank Chang <frank.chang@sifive.com>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
7
Message-id: 20210505160620.15723-2-frank.chang@sifive.com
8
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
9
---
10
target/riscv/insn32.decode | 10 +++++-----
11
1 file changed, 5 insertions(+), 5 deletions(-)
12
13
diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/riscv/insn32.decode
16
+++ b/target/riscv/insn32.decode
17
@@ -XXX,XX +XXX,XX @@
18
%rd 7:5
19
%sh5 20:5
20
21
-%sh10 20:10
22
+%sh7 20:7
23
%csr 20:12
24
%rm 12:3
25
%nf 29:3 !function=ex_plus_1
26
@@ -XXX,XX +XXX,XX @@
27
@u .................... ..... ....... &u imm=%imm_u %rd
28
@j .................... ..... ....... &j imm=%imm_j %rd
29
30
-@sh ...... ...... ..... ... ..... ....... &shift shamt=%sh10 %rs1 %rd
31
+@sh ...... ...... ..... ... ..... ....... &shift shamt=%sh7 %rs1 %rd
32
@csr ............ ..... ... ..... ....... %csr %rs1 %rd
33
34
@atom_ld ..... aq:1 rl:1 ..... ........ ..... ....... &atomic rs2=0 %rs1 %rd
35
@@ -XXX,XX +XXX,XX @@ sltiu ............ ..... 011 ..... 0010011 @i
36
xori ............ ..... 100 ..... 0010011 @i
37
ori ............ ..... 110 ..... 0010011 @i
38
andi ............ ..... 111 ..... 0010011 @i
39
-slli 00.... ...... ..... 001 ..... 0010011 @sh
40
-srli 00.... ...... ..... 101 ..... 0010011 @sh
41
-srai 01.... ...... ..... 101 ..... 0010011 @sh
42
+slli 00000. ...... ..... 001 ..... 0010011 @sh
43
+srli 00000. ...... ..... 101 ..... 0010011 @sh
44
+srai 01000. ...... ..... 101 ..... 0010011 @sh
45
add 0000000 ..... ..... 000 ..... 0110011 @r
46
sub 0100000 ..... ..... 000 ..... 0110011 @r
47
sll 0000000 ..... ..... 001 ..... 0110011 @r
48
--
49
2.31.1
50
51
diff view generated by jsdifflib
Deleted patch
1
From: Kito Cheng <kito.cheng@sifive.com>
2
1
3
Signed-off-by: Kito Cheng <kito.cheng@sifive.com>
4
Signed-off-by: Frank Chang <frank.chang@sifive.com>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
7
Message-id: 20210505160620.15723-3-frank.chang@sifive.com
8
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
9
---
10
target/riscv/cpu.h | 1 +
11
target/riscv/insn32.decode | 11 ++++++-
12
target/riscv/translate.c | 38 +++++++++++++++++++++
13
target/riscv/insn_trans/trans_rvb.c.inc | 44 +++++++++++++++++++++++++
14
4 files changed, 93 insertions(+), 1 deletion(-)
15
create mode 100644 target/riscv/insn_trans/trans_rvb.c.inc
16
17
diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
18
index XXXXXXX..XXXXXXX 100644
19
--- a/target/riscv/cpu.h
20
+++ b/target/riscv/cpu.h
21
@@ -XXX,XX +XXX,XX @@
22
#define RVS RV('S')
23
#define RVU RV('U')
24
#define RVH RV('H')
25
+#define RVB RV('B')
26
27
/* S extension denotes that Supervisor mode exists, however it is possible
28
to have a core that support S mode but does not have an MMU and there
29
diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode
30
index XXXXXXX..XXXXXXX 100644
31
--- a/target/riscv/insn32.decode
32
+++ b/target/riscv/insn32.decode
33
@@ -XXX,XX +XXX,XX @@
34
&i imm rs1 rd
35
&j imm rd
36
&r rd rs1 rs2
37
+&r2 rd rs1
38
&s imm rs1 rs2
39
&u imm rd
40
&shift shamt rs1 rd
41
@@ -XXX,XX +XXX,XX @@
42
@r4_rm ..... .. ..... ..... ... ..... ....... %rs3 %rs2 %rs1 %rm %rd
43
@r_rm ....... ..... ..... ... ..... ....... %rs2 %rs1 %rm %rd
44
@r2_rm ....... ..... ..... ... ..... ....... %rs1 %rm %rd
45
-@r2 ....... ..... ..... ... ..... ....... %rs1 %rd
46
+@r2 ....... ..... ..... ... ..... ....... &r2 %rs1 %rd
47
@r2_nfvm ... ... vm:1 ..... ..... ... ..... ....... &r2nfvm %nf %rs1 %rd
48
@r2_vm ...... vm:1 ..... ..... ... ..... ....... &rmr %rs2 %rd
49
@r1_vm ...... vm:1 ..... ..... ... ..... ....... %rd
50
@@ -XXX,XX +XXX,XX @@ vamomind_v 10000 . . ..... ..... 111 ..... 0101111 @r_wdvm
51
vamomaxd_v 10100 . . ..... ..... 111 ..... 0101111 @r_wdvm
52
vamominud_v 11000 . . ..... ..... 111 ..... 0101111 @r_wdvm
53
vamomaxud_v 11100 . . ..... ..... 111 ..... 0101111 @r_wdvm
54
+
55
+# *** RV32B Standard Extension ***
56
+clz 011000 000000 ..... 001 ..... 0010011 @r2
57
+ctz 011000 000001 ..... 001 ..... 0010011 @r2
58
+
59
+# *** RV64B Standard Extension (in addition to RV32B) ***
60
+clzw 0110000 00000 ..... 001 ..... 0011011 @r2
61
+ctzw 0110000 00001 ..... 001 ..... 0011011 @r2
62
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
63
index XXXXXXX..XXXXXXX 100644
64
--- a/target/riscv/translate.c
65
+++ b/target/riscv/translate.c
66
@@ -XXX,XX +XXX,XX @@ static bool gen_arith_div_uw(DisasContext *ctx, arg_r *a,
67
return true;
68
}
69
70
+static void gen_ctzw(TCGv ret, TCGv arg1)
71
+{
72
+ tcg_gen_ori_tl(ret, arg1, (target_ulong)MAKE_64BIT_MASK(32, 32));
73
+ tcg_gen_ctzi_tl(ret, ret, 64);
74
+}
75
+
76
+static void gen_clzw(TCGv ret, TCGv arg1)
77
+{
78
+ tcg_gen_ext32u_tl(ret, arg1);
79
+ tcg_gen_clzi_tl(ret, ret, 64);
80
+ tcg_gen_subi_tl(ret, ret, 32);
81
+}
82
+
83
static bool gen_arith(DisasContext *ctx, arg_r *a,
84
void(*func)(TCGv, TCGv, TCGv))
85
{
86
@@ -XXX,XX +XXX,XX @@ static uint32_t opcode_at(DisasContextBase *dcbase, target_ulong pc)
87
return cpu_ldl_code(env, pc);
88
}
89
90
+static void gen_ctz(TCGv ret, TCGv arg1)
91
+{
92
+ tcg_gen_ctzi_tl(ret, arg1, TARGET_LONG_BITS);
93
+}
94
+
95
+static void gen_clz(TCGv ret, TCGv arg1)
96
+{
97
+ tcg_gen_clzi_tl(ret, arg1, TARGET_LONG_BITS);
98
+}
99
+
100
+static bool gen_unary(DisasContext *ctx, arg_r2 *a,
101
+ void(*func)(TCGv, TCGv))
102
+{
103
+ TCGv source = tcg_temp_new();
104
+
105
+ gen_get_gpr(source, a->rs1);
106
+
107
+ (*func)(source, source);
108
+
109
+ gen_set_gpr(a->rd, source);
110
+ tcg_temp_free(source);
111
+ return true;
112
+}
113
+
114
/* Include insn module translation function */
115
#include "insn_trans/trans_rvi.c.inc"
116
#include "insn_trans/trans_rvm.c.inc"
117
@@ -XXX,XX +XXX,XX @@ static uint32_t opcode_at(DisasContextBase *dcbase, target_ulong pc)
118
#include "insn_trans/trans_rvd.c.inc"
119
#include "insn_trans/trans_rvh.c.inc"
120
#include "insn_trans/trans_rvv.c.inc"
121
+#include "insn_trans/trans_rvb.c.inc"
122
#include "insn_trans/trans_privileged.c.inc"
123
124
/* Include the auto-generated decoder for 16 bit insn */
125
diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_trans/trans_rvb.c.inc
126
new file mode 100644
127
index XXXXXXX..XXXXXXX
128
--- /dev/null
129
+++ b/target/riscv/insn_trans/trans_rvb.c.inc
130
@@ -XXX,XX +XXX,XX @@
131
+/*
132
+ * RISC-V translation routines for the RVB Standard Extension.
133
+ *
134
+ * Copyright (c) 2020 Kito Cheng, kito.cheng@sifive.com
135
+ * Copyright (c) 2020 Frank Chang, frank.chang@sifive.com
136
+ *
137
+ * This program is free software; you can redistribute it and/or modify it
138
+ * under the terms and conditions of the GNU General Public License,
139
+ * version 2 or later, as published by the Free Software Foundation.
140
+ *
141
+ * This program is distributed in the hope it will be useful, but WITHOUT
142
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
143
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
144
+ * more details.
145
+ *
146
+ * You should have received a copy of the GNU General Public License along with
147
+ * this program. If not, see <http://www.gnu.org/licenses/>.
148
+ */
149
+
150
+static bool trans_clz(DisasContext *ctx, arg_clz *a)
151
+{
152
+ REQUIRE_EXT(ctx, RVB);
153
+ return gen_unary(ctx, a, gen_clz);
154
+}
155
+
156
+static bool trans_ctz(DisasContext *ctx, arg_ctz *a)
157
+{
158
+ REQUIRE_EXT(ctx, RVB);
159
+ return gen_unary(ctx, a, gen_ctz);
160
+}
161
+
162
+static bool trans_clzw(DisasContext *ctx, arg_clzw *a)
163
+{
164
+ REQUIRE_64BIT(ctx);
165
+ REQUIRE_EXT(ctx, RVB);
166
+ return gen_unary(ctx, a, gen_clzw);
167
+}
168
+
169
+static bool trans_ctzw(DisasContext *ctx, arg_ctzw *a)
170
+{
171
+ REQUIRE_64BIT(ctx);
172
+ REQUIRE_EXT(ctx, RVB);
173
+ return gen_unary(ctx, a, gen_ctzw);
174
+}
175
--
176
2.31.1
177
178
diff view generated by jsdifflib
Deleted patch
1
From: Frank Chang <frank.chang@sifive.com>
2
1
3
Signed-off-by: Kito Cheng <kito.cheng@sifive.com>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
6
Signed-off-by: Frank Chang <frank.chang@sifive.com>
7
Message-id: 20210505160620.15723-4-frank.chang@sifive.com
8
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
9
---
10
target/riscv/insn32.decode | 2 ++
11
target/riscv/translate.c | 6 ++++++
12
target/riscv/insn_trans/trans_rvb.c.inc | 13 +++++++++++++
13
3 files changed, 21 insertions(+)
14
15
diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/riscv/insn32.decode
18
+++ b/target/riscv/insn32.decode
19
@@ -XXX,XX +XXX,XX @@ vamomaxud_v 11100 . . ..... ..... 111 ..... 0101111 @r_wdvm
20
# *** RV32B Standard Extension ***
21
clz 011000 000000 ..... 001 ..... 0010011 @r2
22
ctz 011000 000001 ..... 001 ..... 0010011 @r2
23
+cpop 011000 000010 ..... 001 ..... 0010011 @r2
24
25
# *** RV64B Standard Extension (in addition to RV32B) ***
26
clzw 0110000 00000 ..... 001 ..... 0011011 @r2
27
ctzw 0110000 00001 ..... 001 ..... 0011011 @r2
28
+cpopw 0110000 00010 ..... 001 ..... 0011011 @r2
29
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
30
index XXXXXXX..XXXXXXX 100644
31
--- a/target/riscv/translate.c
32
+++ b/target/riscv/translate.c
33
@@ -XXX,XX +XXX,XX @@ static void gen_clzw(TCGv ret, TCGv arg1)
34
tcg_gen_subi_tl(ret, ret, 32);
35
}
36
37
+static void gen_cpopw(TCGv ret, TCGv arg1)
38
+{
39
+ tcg_gen_ext32u_tl(arg1, arg1);
40
+ tcg_gen_ctpop_tl(ret, arg1);
41
+}
42
+
43
static bool gen_arith(DisasContext *ctx, arg_r *a,
44
void(*func)(TCGv, TCGv, TCGv))
45
{
46
diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_trans/trans_rvb.c.inc
47
index XXXXXXX..XXXXXXX 100644
48
--- a/target/riscv/insn_trans/trans_rvb.c.inc
49
+++ b/target/riscv/insn_trans/trans_rvb.c.inc
50
@@ -XXX,XX +XXX,XX @@ static bool trans_ctz(DisasContext *ctx, arg_ctz *a)
51
return gen_unary(ctx, a, gen_ctz);
52
}
53
54
+static bool trans_cpop(DisasContext *ctx, arg_cpop *a)
55
+{
56
+ REQUIRE_EXT(ctx, RVB);
57
+ return gen_unary(ctx, a, tcg_gen_ctpop_tl);
58
+}
59
+
60
static bool trans_clzw(DisasContext *ctx, arg_clzw *a)
61
{
62
REQUIRE_64BIT(ctx);
63
@@ -XXX,XX +XXX,XX @@ static bool trans_ctzw(DisasContext *ctx, arg_ctzw *a)
64
REQUIRE_EXT(ctx, RVB);
65
return gen_unary(ctx, a, gen_ctzw);
66
}
67
+
68
+static bool trans_cpopw(DisasContext *ctx, arg_cpopw *a)
69
+{
70
+ REQUIRE_64BIT(ctx);
71
+ REQUIRE_EXT(ctx, RVB);
72
+ return gen_unary(ctx, a, gen_cpopw);
73
+}
74
--
75
2.31.1
76
77
diff view generated by jsdifflib
Deleted patch
1
From: Kito Cheng <kito.cheng@sifive.com>
2
1
3
Signed-off-by: Kito Cheng <kito.cheng@sifive.com>
4
Signed-off-by: Frank Chang <frank.chang@sifive.com>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
7
Message-id: 20210505160620.15723-5-frank.chang@sifive.com
8
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
9
---
10
target/riscv/insn32.decode | 3 +++
11
target/riscv/insn_trans/trans_rvb.c.inc | 18 ++++++++++++++++++
12
2 files changed, 21 insertions(+)
13
14
diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/riscv/insn32.decode
17
+++ b/target/riscv/insn32.decode
18
@@ -XXX,XX +XXX,XX @@ vamomaxud_v 11100 . . ..... ..... 111 ..... 0101111 @r_wdvm
19
clz 011000 000000 ..... 001 ..... 0010011 @r2
20
ctz 011000 000001 ..... 001 ..... 0010011 @r2
21
cpop 011000 000010 ..... 001 ..... 0010011 @r2
22
+andn 0100000 .......... 111 ..... 0110011 @r
23
+orn 0100000 .......... 110 ..... 0110011 @r
24
+xnor 0100000 .......... 100 ..... 0110011 @r
25
26
# *** RV64B Standard Extension (in addition to RV32B) ***
27
clzw 0110000 00000 ..... 001 ..... 0011011 @r2
28
diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_trans/trans_rvb.c.inc
29
index XXXXXXX..XXXXXXX 100644
30
--- a/target/riscv/insn_trans/trans_rvb.c.inc
31
+++ b/target/riscv/insn_trans/trans_rvb.c.inc
32
@@ -XXX,XX +XXX,XX @@ static bool trans_cpop(DisasContext *ctx, arg_cpop *a)
33
return gen_unary(ctx, a, tcg_gen_ctpop_tl);
34
}
35
36
+static bool trans_andn(DisasContext *ctx, arg_andn *a)
37
+{
38
+ REQUIRE_EXT(ctx, RVB);
39
+ return gen_arith(ctx, a, tcg_gen_andc_tl);
40
+}
41
+
42
+static bool trans_orn(DisasContext *ctx, arg_orn *a)
43
+{
44
+ REQUIRE_EXT(ctx, RVB);
45
+ return gen_arith(ctx, a, tcg_gen_orc_tl);
46
+}
47
+
48
+static bool trans_xnor(DisasContext *ctx, arg_xnor *a)
49
+{
50
+ REQUIRE_EXT(ctx, RVB);
51
+ return gen_arith(ctx, a, tcg_gen_eqv_tl);
52
+}
53
+
54
static bool trans_clzw(DisasContext *ctx, arg_clzw *a)
55
{
56
REQUIRE_64BIT(ctx);
57
--
58
2.31.1
59
60
diff view generated by jsdifflib
Deleted patch
1
From: Kito Cheng <kito.cheng@sifive.com>
2
1
3
Signed-off-by: Kito Cheng <kito.cheng@sifive.com>
4
Signed-off-by: Frank Chang <frank.chang@sifive.com>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
7
Message-id: 20210505160620.15723-6-frank.chang@sifive.com
8
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
9
---
10
target/riscv/insn32.decode | 6 ++++
11
target/riscv/translate.c | 40 +++++++++++++++++++++++++
12
target/riscv/insn_trans/trans_rvb.c.inc | 32 ++++++++++++++++++++
13
3 files changed, 78 insertions(+)
14
15
diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/riscv/insn32.decode
18
+++ b/target/riscv/insn32.decode
19
@@ -XXX,XX +XXX,XX @@ cpop 011000 000010 ..... 001 ..... 0010011 @r2
20
andn 0100000 .......... 111 ..... 0110011 @r
21
orn 0100000 .......... 110 ..... 0110011 @r
22
xnor 0100000 .......... 100 ..... 0110011 @r
23
+pack 0000100 .......... 100 ..... 0110011 @r
24
+packu 0100100 .......... 100 ..... 0110011 @r
25
+packh 0000100 .......... 111 ..... 0110011 @r
26
27
# *** RV64B Standard Extension (in addition to RV32B) ***
28
clzw 0110000 00000 ..... 001 ..... 0011011 @r2
29
ctzw 0110000 00001 ..... 001 ..... 0011011 @r2
30
cpopw 0110000 00010 ..... 001 ..... 0011011 @r2
31
+
32
+packw 0000100 .......... 100 ..... 0111011 @r
33
+packuw 0100100 .......... 100 ..... 0111011 @r
34
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
35
index XXXXXXX..XXXXXXX 100644
36
--- a/target/riscv/translate.c
37
+++ b/target/riscv/translate.c
38
@@ -XXX,XX +XXX,XX @@ static bool gen_arith_div_uw(DisasContext *ctx, arg_r *a,
39
return true;
40
}
41
42
+static void gen_pack(TCGv ret, TCGv arg1, TCGv arg2)
43
+{
44
+ tcg_gen_deposit_tl(ret, arg1, arg2,
45
+ TARGET_LONG_BITS / 2,
46
+ TARGET_LONG_BITS / 2);
47
+}
48
+
49
+static void gen_packu(TCGv ret, TCGv arg1, TCGv arg2)
50
+{
51
+ TCGv t = tcg_temp_new();
52
+ tcg_gen_shri_tl(t, arg1, TARGET_LONG_BITS / 2);
53
+ tcg_gen_deposit_tl(ret, arg2, t, 0, TARGET_LONG_BITS / 2);
54
+ tcg_temp_free(t);
55
+}
56
+
57
+static void gen_packh(TCGv ret, TCGv arg1, TCGv arg2)
58
+{
59
+ TCGv t = tcg_temp_new();
60
+ tcg_gen_ext8u_tl(t, arg2);
61
+ tcg_gen_deposit_tl(ret, arg1, t, 8, TARGET_LONG_BITS - 8);
62
+ tcg_temp_free(t);
63
+}
64
+
65
static void gen_ctzw(TCGv ret, TCGv arg1)
66
{
67
tcg_gen_ori_tl(ret, arg1, (target_ulong)MAKE_64BIT_MASK(32, 32));
68
@@ -XXX,XX +XXX,XX @@ static void gen_cpopw(TCGv ret, TCGv arg1)
69
tcg_gen_ctpop_tl(ret, arg1);
70
}
71
72
+static void gen_packw(TCGv ret, TCGv arg1, TCGv arg2)
73
+{
74
+ TCGv t = tcg_temp_new();
75
+ tcg_gen_ext16s_tl(t, arg2);
76
+ tcg_gen_deposit_tl(ret, arg1, t, 16, 48);
77
+ tcg_temp_free(t);
78
+}
79
+
80
+static void gen_packuw(TCGv ret, TCGv arg1, TCGv arg2)
81
+{
82
+ TCGv t = tcg_temp_new();
83
+ tcg_gen_shri_tl(t, arg1, 16);
84
+ tcg_gen_deposit_tl(ret, arg2, t, 0, 16);
85
+ tcg_gen_ext32s_tl(ret, ret);
86
+ tcg_temp_free(t);
87
+}
88
+
89
static bool gen_arith(DisasContext *ctx, arg_r *a,
90
void(*func)(TCGv, TCGv, TCGv))
91
{
92
diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_trans/trans_rvb.c.inc
93
index XXXXXXX..XXXXXXX 100644
94
--- a/target/riscv/insn_trans/trans_rvb.c.inc
95
+++ b/target/riscv/insn_trans/trans_rvb.c.inc
96
@@ -XXX,XX +XXX,XX @@ static bool trans_xnor(DisasContext *ctx, arg_xnor *a)
97
return gen_arith(ctx, a, tcg_gen_eqv_tl);
98
}
99
100
+static bool trans_pack(DisasContext *ctx, arg_pack *a)
101
+{
102
+ REQUIRE_EXT(ctx, RVB);
103
+ return gen_arith(ctx, a, gen_pack);
104
+}
105
+
106
+static bool trans_packu(DisasContext *ctx, arg_packu *a)
107
+{
108
+ REQUIRE_EXT(ctx, RVB);
109
+ return gen_arith(ctx, a, gen_packu);
110
+}
111
+
112
+static bool trans_packh(DisasContext *ctx, arg_packh *a)
113
+{
114
+ REQUIRE_EXT(ctx, RVB);
115
+ return gen_arith(ctx, a, gen_packh);
116
+}
117
+
118
static bool trans_clzw(DisasContext *ctx, arg_clzw *a)
119
{
120
REQUIRE_64BIT(ctx);
121
@@ -XXX,XX +XXX,XX @@ static bool trans_cpopw(DisasContext *ctx, arg_cpopw *a)
122
REQUIRE_EXT(ctx, RVB);
123
return gen_unary(ctx, a, gen_cpopw);
124
}
125
+
126
+static bool trans_packw(DisasContext *ctx, arg_packw *a)
127
+{
128
+ REQUIRE_64BIT(ctx);
129
+ REQUIRE_EXT(ctx, RVB);
130
+ return gen_arith(ctx, a, gen_packw);
131
+}
132
+
133
+static bool trans_packuw(DisasContext *ctx, arg_packuw *a)
134
+{
135
+ REQUIRE_64BIT(ctx);
136
+ REQUIRE_EXT(ctx, RVB);
137
+ return gen_arith(ctx, a, gen_packuw);
138
+}
139
--
140
2.31.1
141
142
diff view generated by jsdifflib
Deleted patch
1
From: Kito Cheng <kito.cheng@sifive.com>
2
1
3
Signed-off-by: Kito Cheng <kito.cheng@sifive.com>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
6
Signed-off-by: Frank Chang <frank.chang@sifive.com>
7
Message-id: 20210505160620.15723-7-frank.chang@sifive.com
8
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
9
---
10
target/riscv/insn32.decode | 4 ++++
11
target/riscv/insn_trans/trans_rvb.c.inc | 24 ++++++++++++++++++++++++
12
2 files changed, 28 insertions(+)
13
14
diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/riscv/insn32.decode
17
+++ b/target/riscv/insn32.decode
18
@@ -XXX,XX +XXX,XX @@ xnor 0100000 .......... 100 ..... 0110011 @r
19
pack 0000100 .......... 100 ..... 0110011 @r
20
packu 0100100 .......... 100 ..... 0110011 @r
21
packh 0000100 .......... 111 ..... 0110011 @r
22
+min 0000101 .......... 100 ..... 0110011 @r
23
+minu 0000101 .......... 101 ..... 0110011 @r
24
+max 0000101 .......... 110 ..... 0110011 @r
25
+maxu 0000101 .......... 111 ..... 0110011 @r
26
27
# *** RV64B Standard Extension (in addition to RV32B) ***
28
clzw 0110000 00000 ..... 001 ..... 0011011 @r2
29
diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_trans/trans_rvb.c.inc
30
index XXXXXXX..XXXXXXX 100644
31
--- a/target/riscv/insn_trans/trans_rvb.c.inc
32
+++ b/target/riscv/insn_trans/trans_rvb.c.inc
33
@@ -XXX,XX +XXX,XX @@ static bool trans_packh(DisasContext *ctx, arg_packh *a)
34
return gen_arith(ctx, a, gen_packh);
35
}
36
37
+static bool trans_min(DisasContext *ctx, arg_min *a)
38
+{
39
+ REQUIRE_EXT(ctx, RVB);
40
+ return gen_arith(ctx, a, tcg_gen_smin_tl);
41
+}
42
+
43
+static bool trans_max(DisasContext *ctx, arg_max *a)
44
+{
45
+ REQUIRE_EXT(ctx, RVB);
46
+ return gen_arith(ctx, a, tcg_gen_smax_tl);
47
+}
48
+
49
+static bool trans_minu(DisasContext *ctx, arg_minu *a)
50
+{
51
+ REQUIRE_EXT(ctx, RVB);
52
+ return gen_arith(ctx, a, tcg_gen_umin_tl);
53
+}
54
+
55
+static bool trans_maxu(DisasContext *ctx, arg_maxu *a)
56
+{
57
+ REQUIRE_EXT(ctx, RVB);
58
+ return gen_arith(ctx, a, tcg_gen_umax_tl);
59
+}
60
+
61
static bool trans_clzw(DisasContext *ctx, arg_clzw *a)
62
{
63
REQUIRE_64BIT(ctx);
64
--
65
2.31.1
66
67
diff view generated by jsdifflib
Deleted patch
1
From: Kito Cheng <kito.cheng@sifive.com>
2
1
3
Signed-off-by: Kito Cheng <kito.cheng@sifive.com>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
6
Signed-off-by: Frank Chang <frank.chang@sifive.com>
7
Message-id: 20210505160620.15723-8-frank.chang@sifive.com
8
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
9
---
10
target/riscv/insn32.decode | 3 +++
11
target/riscv/insn_trans/trans_rvb.c.inc | 12 ++++++++++++
12
2 files changed, 15 insertions(+)
13
14
diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/riscv/insn32.decode
17
+++ b/target/riscv/insn32.decode
18
@@ -XXX,XX +XXX,XX @@ vamomaxud_v 11100 . . ..... ..... 111 ..... 0101111 @r_wdvm
19
clz 011000 000000 ..... 001 ..... 0010011 @r2
20
ctz 011000 000001 ..... 001 ..... 0010011 @r2
21
cpop 011000 000010 ..... 001 ..... 0010011 @r2
22
+sext_b 011000 000100 ..... 001 ..... 0010011 @r2
23
+sext_h 011000 000101 ..... 001 ..... 0010011 @r2
24
+
25
andn 0100000 .......... 111 ..... 0110011 @r
26
orn 0100000 .......... 110 ..... 0110011 @r
27
xnor 0100000 .......... 100 ..... 0110011 @r
28
diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_trans/trans_rvb.c.inc
29
index XXXXXXX..XXXXXXX 100644
30
--- a/target/riscv/insn_trans/trans_rvb.c.inc
31
+++ b/target/riscv/insn_trans/trans_rvb.c.inc
32
@@ -XXX,XX +XXX,XX @@ static bool trans_maxu(DisasContext *ctx, arg_maxu *a)
33
return gen_arith(ctx, a, tcg_gen_umax_tl);
34
}
35
36
+static bool trans_sext_b(DisasContext *ctx, arg_sext_b *a)
37
+{
38
+ REQUIRE_EXT(ctx, RVB);
39
+ return gen_unary(ctx, a, tcg_gen_ext8s_tl);
40
+}
41
+
42
+static bool trans_sext_h(DisasContext *ctx, arg_sext_h *a)
43
+{
44
+ REQUIRE_EXT(ctx, RVB);
45
+ return gen_unary(ctx, a, tcg_gen_ext16s_tl);
46
+}
47
+
48
static bool trans_clzw(DisasContext *ctx, arg_clzw *a)
49
{
50
REQUIRE_64BIT(ctx);
51
--
52
2.31.1
53
54
diff view generated by jsdifflib
Deleted patch
1
From: Frank Chang <frank.chang@sifive.com>
2
1
3
Add gen_shifti() and gen_shiftiw() helper functions to reuse the same
4
interfaces for immediate shift instructions.
5
6
Signed-off-by: Frank Chang <frank.chang@sifive.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Message-id: 20210505160620.15723-9-frank.chang@sifive.com
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
12
target/riscv/translate.c | 39 ++++++++++++++++++
13
target/riscv/insn_trans/trans_rvi.c.inc | 54 ++-----------------------
14
2 files changed, 43 insertions(+), 50 deletions(-)
15
16
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/target/riscv/translate.c
19
+++ b/target/riscv/translate.c
20
@@ -XXX,XX +XXX,XX @@ static uint32_t opcode_at(DisasContextBase *dcbase, target_ulong pc)
21
return cpu_ldl_code(env, pc);
22
}
23
24
+static bool gen_shifti(DisasContext *ctx, arg_shift *a,
25
+ void(*func)(TCGv, TCGv, TCGv))
26
+{
27
+ if (a->shamt >= TARGET_LONG_BITS) {
28
+ return false;
29
+ }
30
+
31
+ TCGv source1 = tcg_temp_new();
32
+ TCGv source2 = tcg_temp_new();
33
+
34
+ gen_get_gpr(source1, a->rs1);
35
+
36
+ tcg_gen_movi_tl(source2, a->shamt);
37
+ (*func)(source1, source1, source2);
38
+
39
+ gen_set_gpr(a->rd, source1);
40
+ tcg_temp_free(source1);
41
+ tcg_temp_free(source2);
42
+ return true;
43
+}
44
+
45
+static bool gen_shiftiw(DisasContext *ctx, arg_shift *a,
46
+ void(*func)(TCGv, TCGv, TCGv))
47
+{
48
+ TCGv source1 = tcg_temp_new();
49
+ TCGv source2 = tcg_temp_new();
50
+
51
+ gen_get_gpr(source1, a->rs1);
52
+ tcg_gen_movi_tl(source2, a->shamt);
53
+
54
+ (*func)(source1, source1, source2);
55
+ tcg_gen_ext32s_tl(source1, source1);
56
+
57
+ gen_set_gpr(a->rd, source1);
58
+ tcg_temp_free(source1);
59
+ tcg_temp_free(source2);
60
+ return true;
61
+}
62
+
63
static void gen_ctz(TCGv ret, TCGv arg1)
64
{
65
tcg_gen_ctzi_tl(ret, arg1, TARGET_LONG_BITS);
66
diff --git a/target/riscv/insn_trans/trans_rvi.c.inc b/target/riscv/insn_trans/trans_rvi.c.inc
67
index XXXXXXX..XXXXXXX 100644
68
--- a/target/riscv/insn_trans/trans_rvi.c.inc
69
+++ b/target/riscv/insn_trans/trans_rvi.c.inc
70
@@ -XXX,XX +XXX,XX @@ static bool trans_andi(DisasContext *ctx, arg_andi *a)
71
}
72
static bool trans_slli(DisasContext *ctx, arg_slli *a)
73
{
74
- if (a->shamt >= TARGET_LONG_BITS) {
75
- return false;
76
- }
77
-
78
- if (a->rd != 0) {
79
- TCGv t = tcg_temp_new();
80
- gen_get_gpr(t, a->rs1);
81
-
82
- tcg_gen_shli_tl(t, t, a->shamt);
83
-
84
- gen_set_gpr(a->rd, t);
85
- tcg_temp_free(t);
86
- } /* NOP otherwise */
87
- return true;
88
+ return gen_shifti(ctx, a, tcg_gen_shl_tl);
89
}
90
91
static bool trans_srli(DisasContext *ctx, arg_srli *a)
92
{
93
- if (a->shamt >= TARGET_LONG_BITS) {
94
- return false;
95
- }
96
-
97
- if (a->rd != 0) {
98
- TCGv t = tcg_temp_new();
99
- gen_get_gpr(t, a->rs1);
100
-
101
- tcg_gen_shri_tl(t, t, a->shamt);
102
- gen_set_gpr(a->rd, t);
103
- tcg_temp_free(t);
104
- } /* NOP otherwise */
105
- return true;
106
+ return gen_shifti(ctx, a, tcg_gen_shr_tl);
107
}
108
109
static bool trans_srai(DisasContext *ctx, arg_srai *a)
110
{
111
- if (a->shamt >= TARGET_LONG_BITS) {
112
- return false;
113
- }
114
-
115
- if (a->rd != 0) {
116
- TCGv t = tcg_temp_new();
117
- gen_get_gpr(t, a->rs1);
118
-
119
- tcg_gen_sari_tl(t, t, a->shamt);
120
- gen_set_gpr(a->rd, t);
121
- tcg_temp_free(t);
122
- } /* NOP otherwise */
123
- return true;
124
+ return gen_shifti(ctx, a, tcg_gen_sar_tl);
125
}
126
127
static bool trans_add(DisasContext *ctx, arg_add *a)
128
@@ -XXX,XX +XXX,XX @@ static bool trans_addiw(DisasContext *ctx, arg_addiw *a)
129
static bool trans_slliw(DisasContext *ctx, arg_slliw *a)
130
{
131
REQUIRE_64BIT(ctx);
132
- TCGv source1;
133
- source1 = tcg_temp_new();
134
- gen_get_gpr(source1, a->rs1);
135
-
136
- tcg_gen_shli_tl(source1, source1, a->shamt);
137
- tcg_gen_ext32s_tl(source1, source1);
138
- gen_set_gpr(a->rd, source1);
139
-
140
- tcg_temp_free(source1);
141
- return true;
142
+ return gen_shiftiw(ctx, a, tcg_gen_shl_tl);
143
}
144
145
static bool trans_srliw(DisasContext *ctx, arg_srliw *a)
146
--
147
2.31.1
148
149
diff view generated by jsdifflib
Deleted patch
1
From: Frank Chang <frank.chang@sifive.com>
2
1
3
Signed-off-by: Kito Cheng <kito.cheng@sifive.com>
4
Signed-off-by: Frank Chang <frank.chang@sifive.com>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
7
Message-id: 20210505160620.15723-10-frank.chang@sifive.com
8
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
9
---
10
target/riscv/insn32.decode | 17 +++++
11
target/riscv/translate.c | 61 ++++++++++++++++
12
target/riscv/insn_trans/trans_rvb.c.inc | 97 +++++++++++++++++++++++++
13
3 files changed, 175 insertions(+)
14
15
diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/riscv/insn32.decode
18
+++ b/target/riscv/insn32.decode
19
@@ -XXX,XX +XXX,XX @@ min 0000101 .......... 100 ..... 0110011 @r
20
minu 0000101 .......... 101 ..... 0110011 @r
21
max 0000101 .......... 110 ..... 0110011 @r
22
maxu 0000101 .......... 111 ..... 0110011 @r
23
+bset 0010100 .......... 001 ..... 0110011 @r
24
+bclr 0100100 .......... 001 ..... 0110011 @r
25
+binv 0110100 .......... 001 ..... 0110011 @r
26
+bext 0100100 .......... 101 ..... 0110011 @r
27
+
28
+bseti 00101. ........... 001 ..... 0010011 @sh
29
+bclri 01001. ........... 001 ..... 0010011 @sh
30
+binvi 01101. ........... 001 ..... 0010011 @sh
31
+bexti 01001. ........... 101 ..... 0010011 @sh
32
33
# *** RV64B Standard Extension (in addition to RV32B) ***
34
clzw 0110000 00000 ..... 001 ..... 0011011 @r2
35
@@ -XXX,XX +XXX,XX @@ cpopw 0110000 00010 ..... 001 ..... 0011011 @r2
36
37
packw 0000100 .......... 100 ..... 0111011 @r
38
packuw 0100100 .......... 100 ..... 0111011 @r
39
+bsetw 0010100 .......... 001 ..... 0111011 @r
40
+bclrw 0100100 .......... 001 ..... 0111011 @r
41
+binvw 0110100 .......... 001 ..... 0111011 @r
42
+bextw 0100100 .......... 101 ..... 0111011 @r
43
+
44
+bsetiw 0010100 .......... 001 ..... 0011011 @sh5
45
+bclriw 0100100 .......... 001 ..... 0011011 @sh5
46
+binviw 0110100 .......... 001 ..... 0011011 @sh5
47
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
48
index XXXXXXX..XXXXXXX 100644
49
--- a/target/riscv/translate.c
50
+++ b/target/riscv/translate.c
51
@@ -XXX,XX +XXX,XX @@ static void gen_packh(TCGv ret, TCGv arg1, TCGv arg2)
52
tcg_temp_free(t);
53
}
54
55
+static void gen_sbop_mask(TCGv ret, TCGv shamt)
56
+{
57
+ tcg_gen_movi_tl(ret, 1);
58
+ tcg_gen_shl_tl(ret, ret, shamt);
59
+}
60
+
61
+static void gen_bset(TCGv ret, TCGv arg1, TCGv shamt)
62
+{
63
+ TCGv t = tcg_temp_new();
64
+
65
+ gen_sbop_mask(t, shamt);
66
+ tcg_gen_or_tl(ret, arg1, t);
67
+
68
+ tcg_temp_free(t);
69
+}
70
+
71
+static void gen_bclr(TCGv ret, TCGv arg1, TCGv shamt)
72
+{
73
+ TCGv t = tcg_temp_new();
74
+
75
+ gen_sbop_mask(t, shamt);
76
+ tcg_gen_andc_tl(ret, arg1, t);
77
+
78
+ tcg_temp_free(t);
79
+}
80
+
81
+static void gen_binv(TCGv ret, TCGv arg1, TCGv shamt)
82
+{
83
+ TCGv t = tcg_temp_new();
84
+
85
+ gen_sbop_mask(t, shamt);
86
+ tcg_gen_xor_tl(ret, arg1, t);
87
+
88
+ tcg_temp_free(t);
89
+}
90
+
91
+static void gen_bext(TCGv ret, TCGv arg1, TCGv shamt)
92
+{
93
+ tcg_gen_shr_tl(ret, arg1, shamt);
94
+ tcg_gen_andi_tl(ret, ret, 1);
95
+}
96
+
97
static void gen_ctzw(TCGv ret, TCGv arg1)
98
{
99
tcg_gen_ori_tl(ret, arg1, (target_ulong)MAKE_64BIT_MASK(32, 32));
100
@@ -XXX,XX +XXX,XX @@ static bool gen_shifti(DisasContext *ctx, arg_shift *a,
101
return true;
102
}
103
104
+static bool gen_shiftw(DisasContext *ctx, arg_r *a,
105
+ void(*func)(TCGv, TCGv, TCGv))
106
+{
107
+ TCGv source1 = tcg_temp_new();
108
+ TCGv source2 = tcg_temp_new();
109
+
110
+ gen_get_gpr(source1, a->rs1);
111
+ gen_get_gpr(source2, a->rs2);
112
+
113
+ tcg_gen_andi_tl(source2, source2, 31);
114
+ (*func)(source1, source1, source2);
115
+ tcg_gen_ext32s_tl(source1, source1);
116
+
117
+ gen_set_gpr(a->rd, source1);
118
+ tcg_temp_free(source1);
119
+ tcg_temp_free(source2);
120
+ return true;
121
+}
122
+
123
static bool gen_shiftiw(DisasContext *ctx, arg_shift *a,
124
void(*func)(TCGv, TCGv, TCGv))
125
{
126
diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_trans/trans_rvb.c.inc
127
index XXXXXXX..XXXXXXX 100644
128
--- a/target/riscv/insn_trans/trans_rvb.c.inc
129
+++ b/target/riscv/insn_trans/trans_rvb.c.inc
130
@@ -XXX,XX +XXX,XX @@ static bool trans_sext_h(DisasContext *ctx, arg_sext_h *a)
131
return gen_unary(ctx, a, tcg_gen_ext16s_tl);
132
}
133
134
+static bool trans_bset(DisasContext *ctx, arg_bset *a)
135
+{
136
+ REQUIRE_EXT(ctx, RVB);
137
+ return gen_shift(ctx, a, gen_bset);
138
+}
139
+
140
+static bool trans_bseti(DisasContext *ctx, arg_bseti *a)
141
+{
142
+ REQUIRE_EXT(ctx, RVB);
143
+ return gen_shifti(ctx, a, gen_bset);
144
+}
145
+
146
+static bool trans_bclr(DisasContext *ctx, arg_bclr *a)
147
+{
148
+ REQUIRE_EXT(ctx, RVB);
149
+ return gen_shift(ctx, a, gen_bclr);
150
+}
151
+
152
+static bool trans_bclri(DisasContext *ctx, arg_bclri *a)
153
+{
154
+ REQUIRE_EXT(ctx, RVB);
155
+ return gen_shifti(ctx, a, gen_bclr);
156
+}
157
+
158
+static bool trans_binv(DisasContext *ctx, arg_binv *a)
159
+{
160
+ REQUIRE_EXT(ctx, RVB);
161
+ return gen_shift(ctx, a, gen_binv);
162
+}
163
+
164
+static bool trans_binvi(DisasContext *ctx, arg_binvi *a)
165
+{
166
+ REQUIRE_EXT(ctx, RVB);
167
+ return gen_shifti(ctx, a, gen_binv);
168
+}
169
+
170
+static bool trans_bext(DisasContext *ctx, arg_bext *a)
171
+{
172
+ REQUIRE_EXT(ctx, RVB);
173
+ return gen_shift(ctx, a, gen_bext);
174
+}
175
+
176
+static bool trans_bexti(DisasContext *ctx, arg_bexti *a)
177
+{
178
+ REQUIRE_EXT(ctx, RVB);
179
+ return gen_shifti(ctx, a, gen_bext);
180
+}
181
+
182
static bool trans_clzw(DisasContext *ctx, arg_clzw *a)
183
{
184
REQUIRE_64BIT(ctx);
185
@@ -XXX,XX +XXX,XX @@ static bool trans_packuw(DisasContext *ctx, arg_packuw *a)
186
REQUIRE_EXT(ctx, RVB);
187
return gen_arith(ctx, a, gen_packuw);
188
}
189
+
190
+static bool trans_bsetw(DisasContext *ctx, arg_bsetw *a)
191
+{
192
+ REQUIRE_64BIT(ctx);
193
+ REQUIRE_EXT(ctx, RVB);
194
+ return gen_shiftw(ctx, a, gen_bset);
195
+}
196
+
197
+static bool trans_bsetiw(DisasContext *ctx, arg_bsetiw *a)
198
+{
199
+ REQUIRE_64BIT(ctx);
200
+ REQUIRE_EXT(ctx, RVB);
201
+ return gen_shiftiw(ctx, a, gen_bset);
202
+}
203
+
204
+static bool trans_bclrw(DisasContext *ctx, arg_bclrw *a)
205
+{
206
+ REQUIRE_64BIT(ctx);
207
+ REQUIRE_EXT(ctx, RVB);
208
+ return gen_shiftw(ctx, a, gen_bclr);
209
+}
210
+
211
+static bool trans_bclriw(DisasContext *ctx, arg_bclriw *a)
212
+{
213
+ REQUIRE_64BIT(ctx);
214
+ REQUIRE_EXT(ctx, RVB);
215
+ return gen_shiftiw(ctx, a, gen_bclr);
216
+}
217
+
218
+static bool trans_binvw(DisasContext *ctx, arg_binvw *a)
219
+{
220
+ REQUIRE_64BIT(ctx);
221
+ REQUIRE_EXT(ctx, RVB);
222
+ return gen_shiftw(ctx, a, gen_binv);
223
+}
224
+
225
+static bool trans_binviw(DisasContext *ctx, arg_binviw *a)
226
+{
227
+ REQUIRE_64BIT(ctx);
228
+ REQUIRE_EXT(ctx, RVB);
229
+ return gen_shiftiw(ctx, a, gen_binv);
230
+}
231
+
232
+static bool trans_bextw(DisasContext *ctx, arg_bextw *a)
233
+{
234
+ REQUIRE_64BIT(ctx);
235
+ REQUIRE_EXT(ctx, RVB);
236
+ return gen_shiftw(ctx, a, gen_bext);
237
+}
238
--
239
2.31.1
240
241
diff view generated by jsdifflib
Deleted patch
1
From: Kito Cheng <kito.cheng@sifive.com>
2
1
3
Signed-off-by: Kito Cheng <kito.cheng@sifive.com>
4
Signed-off-by: Frank Chang <frank.chang@sifive.com>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
7
Message-id: 20210505160620.15723-11-frank.chang@sifive.com
8
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
9
---
10
target/riscv/insn32.decode | 8 ++++
11
target/riscv/translate.c | 14 +++++++
12
target/riscv/insn_trans/trans_rvb.c.inc | 52 +++++++++++++++++++++++++
13
3 files changed, 74 insertions(+)
14
15
diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/riscv/insn32.decode
18
+++ b/target/riscv/insn32.decode
19
@@ -XXX,XX +XXX,XX @@ bset 0010100 .......... 001 ..... 0110011 @r
20
bclr 0100100 .......... 001 ..... 0110011 @r
21
binv 0110100 .......... 001 ..... 0110011 @r
22
bext 0100100 .......... 101 ..... 0110011 @r
23
+slo 0010000 .......... 001 ..... 0110011 @r
24
+sro 0010000 .......... 101 ..... 0110011 @r
25
26
bseti 00101. ........... 001 ..... 0010011 @sh
27
bclri 01001. ........... 001 ..... 0010011 @sh
28
binvi 01101. ........... 001 ..... 0010011 @sh
29
bexti 01001. ........... 101 ..... 0010011 @sh
30
+sloi 00100. ........... 001 ..... 0010011 @sh
31
+sroi 00100. ........... 101 ..... 0010011 @sh
32
33
# *** RV64B Standard Extension (in addition to RV32B) ***
34
clzw 0110000 00000 ..... 001 ..... 0011011 @r2
35
@@ -XXX,XX +XXX,XX @@ bsetw 0010100 .......... 001 ..... 0111011 @r
36
bclrw 0100100 .......... 001 ..... 0111011 @r
37
binvw 0110100 .......... 001 ..... 0111011 @r
38
bextw 0100100 .......... 101 ..... 0111011 @r
39
+slow 0010000 .......... 001 ..... 0111011 @r
40
+srow 0010000 .......... 101 ..... 0111011 @r
41
42
bsetiw 0010100 .......... 001 ..... 0011011 @sh5
43
bclriw 0100100 .......... 001 ..... 0011011 @sh5
44
binviw 0110100 .......... 001 ..... 0011011 @sh5
45
+sloiw 0010000 .......... 001 ..... 0011011 @sh5
46
+sroiw 0010000 .......... 101 ..... 0011011 @sh5
47
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
48
index XXXXXXX..XXXXXXX 100644
49
--- a/target/riscv/translate.c
50
+++ b/target/riscv/translate.c
51
@@ -XXX,XX +XXX,XX @@ static void gen_bext(TCGv ret, TCGv arg1, TCGv shamt)
52
tcg_gen_andi_tl(ret, ret, 1);
53
}
54
55
+static void gen_slo(TCGv ret, TCGv arg1, TCGv arg2)
56
+{
57
+ tcg_gen_not_tl(ret, arg1);
58
+ tcg_gen_shl_tl(ret, ret, arg2);
59
+ tcg_gen_not_tl(ret, ret);
60
+}
61
+
62
+static void gen_sro(TCGv ret, TCGv arg1, TCGv arg2)
63
+{
64
+ tcg_gen_not_tl(ret, arg1);
65
+ tcg_gen_shr_tl(ret, ret, arg2);
66
+ tcg_gen_not_tl(ret, ret);
67
+}
68
+
69
static void gen_ctzw(TCGv ret, TCGv arg1)
70
{
71
tcg_gen_ori_tl(ret, arg1, (target_ulong)MAKE_64BIT_MASK(32, 32));
72
diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_trans/trans_rvb.c.inc
73
index XXXXXXX..XXXXXXX 100644
74
--- a/target/riscv/insn_trans/trans_rvb.c.inc
75
+++ b/target/riscv/insn_trans/trans_rvb.c.inc
76
@@ -XXX,XX +XXX,XX @@ static bool trans_bexti(DisasContext *ctx, arg_bexti *a)
77
return gen_shifti(ctx, a, gen_bext);
78
}
79
80
+static bool trans_slo(DisasContext *ctx, arg_slo *a)
81
+{
82
+ REQUIRE_EXT(ctx, RVB);
83
+ return gen_shift(ctx, a, gen_slo);
84
+}
85
+
86
+static bool trans_sloi(DisasContext *ctx, arg_sloi *a)
87
+{
88
+ REQUIRE_EXT(ctx, RVB);
89
+ return gen_shifti(ctx, a, gen_slo);
90
+}
91
+
92
+static bool trans_sro(DisasContext *ctx, arg_sro *a)
93
+{
94
+ REQUIRE_EXT(ctx, RVB);
95
+ return gen_shift(ctx, a, gen_sro);
96
+}
97
+
98
+static bool trans_sroi(DisasContext *ctx, arg_sroi *a)
99
+{
100
+ REQUIRE_EXT(ctx, RVB);
101
+ return gen_shifti(ctx, a, gen_sro);
102
+}
103
+
104
static bool trans_clzw(DisasContext *ctx, arg_clzw *a)
105
{
106
REQUIRE_64BIT(ctx);
107
@@ -XXX,XX +XXX,XX @@ static bool trans_bextw(DisasContext *ctx, arg_bextw *a)
108
REQUIRE_EXT(ctx, RVB);
109
return gen_shiftw(ctx, a, gen_bext);
110
}
111
+
112
+static bool trans_slow(DisasContext *ctx, arg_slow *a)
113
+{
114
+ REQUIRE_64BIT(ctx);
115
+ REQUIRE_EXT(ctx, RVB);
116
+ return gen_shiftw(ctx, a, gen_slo);
117
+}
118
+
119
+static bool trans_sloiw(DisasContext *ctx, arg_sloiw *a)
120
+{
121
+ REQUIRE_64BIT(ctx);
122
+ REQUIRE_EXT(ctx, RVB);
123
+ return gen_shiftiw(ctx, a, gen_slo);
124
+}
125
+
126
+static bool trans_srow(DisasContext *ctx, arg_srow *a)
127
+{
128
+ REQUIRE_64BIT(ctx);
129
+ REQUIRE_EXT(ctx, RVB);
130
+ return gen_shiftw(ctx, a, gen_sro);
131
+}
132
+
133
+static bool trans_sroiw(DisasContext *ctx, arg_sroiw *a)
134
+{
135
+ REQUIRE_64BIT(ctx);
136
+ REQUIRE_EXT(ctx, RVB);
137
+ return gen_shiftiw(ctx, a, gen_sro);
138
+}
139
--
140
2.31.1
141
142
diff view generated by jsdifflib
Deleted patch
1
From: Kito Cheng <kito.cheng@sifive.com>
2
1
3
Signed-off-by: Kito Cheng <kito.cheng@sifive.com>
4
Signed-off-by: Frank Chang <frank.chang@sifive.com>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
7
Message-id: 20210505160620.15723-12-frank.chang@sifive.com
8
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
9
---
10
target/riscv/insn32.decode | 6 ++++
11
target/riscv/translate.c | 36 +++++++++++++++++++++++
12
target/riscv/insn_trans/trans_rvb.c.inc | 39 +++++++++++++++++++++++++
13
3 files changed, 81 insertions(+)
14
15
diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/riscv/insn32.decode
18
+++ b/target/riscv/insn32.decode
19
@@ -XXX,XX +XXX,XX @@ binv 0110100 .......... 001 ..... 0110011 @r
20
bext 0100100 .......... 101 ..... 0110011 @r
21
slo 0010000 .......... 001 ..... 0110011 @r
22
sro 0010000 .......... 101 ..... 0110011 @r
23
+ror 0110000 .......... 101 ..... 0110011 @r
24
+rol 0110000 .......... 001 ..... 0110011 @r
25
26
bseti 00101. ........... 001 ..... 0010011 @sh
27
bclri 01001. ........... 001 ..... 0010011 @sh
28
@@ -XXX,XX +XXX,XX @@ binvi 01101. ........... 001 ..... 0010011 @sh
29
bexti 01001. ........... 101 ..... 0010011 @sh
30
sloi 00100. ........... 001 ..... 0010011 @sh
31
sroi 00100. ........... 101 ..... 0010011 @sh
32
+rori 01100. ........... 101 ..... 0010011 @sh
33
34
# *** RV64B Standard Extension (in addition to RV32B) ***
35
clzw 0110000 00000 ..... 001 ..... 0011011 @r2
36
@@ -XXX,XX +XXX,XX @@ binvw 0110100 .......... 001 ..... 0111011 @r
37
bextw 0100100 .......... 101 ..... 0111011 @r
38
slow 0010000 .......... 001 ..... 0111011 @r
39
srow 0010000 .......... 101 ..... 0111011 @r
40
+rorw 0110000 .......... 101 ..... 0111011 @r
41
+rolw 0110000 .......... 001 ..... 0111011 @r
42
43
bsetiw 0010100 .......... 001 ..... 0011011 @sh5
44
bclriw 0100100 .......... 001 ..... 0011011 @sh5
45
binviw 0110100 .......... 001 ..... 0011011 @sh5
46
sloiw 0010000 .......... 001 ..... 0011011 @sh5
47
sroiw 0010000 .......... 101 ..... 0011011 @sh5
48
+roriw 0110000 .......... 101 ..... 0011011 @sh5
49
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
50
index XXXXXXX..XXXXXXX 100644
51
--- a/target/riscv/translate.c
52
+++ b/target/riscv/translate.c
53
@@ -XXX,XX +XXX,XX @@ static void gen_packuw(TCGv ret, TCGv arg1, TCGv arg2)
54
tcg_temp_free(t);
55
}
56
57
+static void gen_rorw(TCGv ret, TCGv arg1, TCGv arg2)
58
+{
59
+ TCGv_i32 t1 = tcg_temp_new_i32();
60
+ TCGv_i32 t2 = tcg_temp_new_i32();
61
+
62
+ /* truncate to 32-bits */
63
+ tcg_gen_trunc_tl_i32(t1, arg1);
64
+ tcg_gen_trunc_tl_i32(t2, arg2);
65
+
66
+ tcg_gen_rotr_i32(t1, t1, t2);
67
+
68
+ /* sign-extend 64-bits */
69
+ tcg_gen_ext_i32_tl(ret, t1);
70
+
71
+ tcg_temp_free_i32(t1);
72
+ tcg_temp_free_i32(t2);
73
+}
74
+
75
+static void gen_rolw(TCGv ret, TCGv arg1, TCGv arg2)
76
+{
77
+ TCGv_i32 t1 = tcg_temp_new_i32();
78
+ TCGv_i32 t2 = tcg_temp_new_i32();
79
+
80
+ /* truncate to 32-bits */
81
+ tcg_gen_trunc_tl_i32(t1, arg1);
82
+ tcg_gen_trunc_tl_i32(t2, arg2);
83
+
84
+ tcg_gen_rotl_i32(t1, t1, t2);
85
+
86
+ /* sign-extend 64-bits */
87
+ tcg_gen_ext_i32_tl(ret, t1);
88
+
89
+ tcg_temp_free_i32(t1);
90
+ tcg_temp_free_i32(t2);
91
+}
92
+
93
static bool gen_arith(DisasContext *ctx, arg_r *a,
94
void(*func)(TCGv, TCGv, TCGv))
95
{
96
diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_trans/trans_rvb.c.inc
97
index XXXXXXX..XXXXXXX 100644
98
--- a/target/riscv/insn_trans/trans_rvb.c.inc
99
+++ b/target/riscv/insn_trans/trans_rvb.c.inc
100
@@ -XXX,XX +XXX,XX @@ static bool trans_sroi(DisasContext *ctx, arg_sroi *a)
101
return gen_shifti(ctx, a, gen_sro);
102
}
103
104
+static bool trans_ror(DisasContext *ctx, arg_ror *a)
105
+{
106
+ REQUIRE_EXT(ctx, RVB);
107
+ return gen_shift(ctx, a, tcg_gen_rotr_tl);
108
+}
109
+
110
+static bool trans_rori(DisasContext *ctx, arg_rori *a)
111
+{
112
+ REQUIRE_EXT(ctx, RVB);
113
+ return gen_shifti(ctx, a, tcg_gen_rotr_tl);
114
+}
115
+
116
+static bool trans_rol(DisasContext *ctx, arg_rol *a)
117
+{
118
+ REQUIRE_EXT(ctx, RVB);
119
+ return gen_shift(ctx, a, tcg_gen_rotl_tl);
120
+}
121
+
122
static bool trans_clzw(DisasContext *ctx, arg_clzw *a)
123
{
124
REQUIRE_64BIT(ctx);
125
@@ -XXX,XX +XXX,XX @@ static bool trans_sroiw(DisasContext *ctx, arg_sroiw *a)
126
REQUIRE_EXT(ctx, RVB);
127
return gen_shiftiw(ctx, a, gen_sro);
128
}
129
+
130
+static bool trans_rorw(DisasContext *ctx, arg_rorw *a)
131
+{
132
+ REQUIRE_64BIT(ctx);
133
+ REQUIRE_EXT(ctx, RVB);
134
+ return gen_shiftw(ctx, a, gen_rorw);
135
+}
136
+
137
+static bool trans_roriw(DisasContext *ctx, arg_roriw *a)
138
+{
139
+ REQUIRE_64BIT(ctx);
140
+ REQUIRE_EXT(ctx, RVB);
141
+ return gen_shiftiw(ctx, a, gen_rorw);
142
+}
143
+
144
+static bool trans_rolw(DisasContext *ctx, arg_rolw *a)
145
+{
146
+ REQUIRE_64BIT(ctx);
147
+ REQUIRE_EXT(ctx, RVB);
148
+ return gen_shiftw(ctx, a, gen_rolw);
149
+}
150
--
151
2.31.1
152
153
diff view generated by jsdifflib
Deleted patch
1
From: Frank Chang <frank.chang@sifive.com>
2
1
3
Signed-off-by: Frank Chang <frank.chang@sifive.com>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20210505160620.15723-13-frank.chang@sifive.com
6
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
7
---
8
target/riscv/helper.h | 4 ++
9
target/riscv/insn32.decode | 4 ++
10
target/riscv/bitmanip_helper.c | 64 +++++++++++++++++++++++++
11
target/riscv/translate.c | 28 +++++++++++
12
target/riscv/insn_trans/trans_rvb.c.inc | 31 ++++++++++++
13
target/riscv/meson.build | 1 +
14
6 files changed, 132 insertions(+)
15
create mode 100644 target/riscv/bitmanip_helper.c
16
17
diff --git a/target/riscv/helper.h b/target/riscv/helper.h
18
index XXXXXXX..XXXXXXX 100644
19
--- a/target/riscv/helper.h
20
+++ b/target/riscv/helper.h
21
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_2(fcvt_d_l, TCG_CALL_NO_RWG, i64, env, tl)
22
DEF_HELPER_FLAGS_2(fcvt_d_lu, TCG_CALL_NO_RWG, i64, env, tl)
23
DEF_HELPER_FLAGS_1(fclass_d, TCG_CALL_NO_RWG_SE, tl, i64)
24
25
+/* Bitmanip */
26
+DEF_HELPER_FLAGS_2(grev, TCG_CALL_NO_RWG_SE, tl, tl, tl)
27
+DEF_HELPER_FLAGS_2(grevw, TCG_CALL_NO_RWG_SE, tl, tl, tl)
28
+
29
/* Special functions */
30
DEF_HELPER_3(csrrw, tl, env, tl, tl)
31
DEF_HELPER_4(csrrs, tl, env, tl, tl, tl)
32
diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode
33
index XXXXXXX..XXXXXXX 100644
34
--- a/target/riscv/insn32.decode
35
+++ b/target/riscv/insn32.decode
36
@@ -XXX,XX +XXX,XX @@ slo 0010000 .......... 001 ..... 0110011 @r
37
sro 0010000 .......... 101 ..... 0110011 @r
38
ror 0110000 .......... 101 ..... 0110011 @r
39
rol 0110000 .......... 001 ..... 0110011 @r
40
+grev 0110100 .......... 101 ..... 0110011 @r
41
42
bseti 00101. ........... 001 ..... 0010011 @sh
43
bclri 01001. ........... 001 ..... 0010011 @sh
44
@@ -XXX,XX +XXX,XX @@ bexti 01001. ........... 101 ..... 0010011 @sh
45
sloi 00100. ........... 001 ..... 0010011 @sh
46
sroi 00100. ........... 101 ..... 0010011 @sh
47
rori 01100. ........... 101 ..... 0010011 @sh
48
+grevi 01101. ........... 101 ..... 0010011 @sh
49
50
# *** RV64B Standard Extension (in addition to RV32B) ***
51
clzw 0110000 00000 ..... 001 ..... 0011011 @r2
52
@@ -XXX,XX +XXX,XX @@ slow 0010000 .......... 001 ..... 0111011 @r
53
srow 0010000 .......... 101 ..... 0111011 @r
54
rorw 0110000 .......... 101 ..... 0111011 @r
55
rolw 0110000 .......... 001 ..... 0111011 @r
56
+grevw 0110100 .......... 101 ..... 0111011 @r
57
58
bsetiw 0010100 .......... 001 ..... 0011011 @sh5
59
bclriw 0100100 .......... 001 ..... 0011011 @sh5
60
@@ -XXX,XX +XXX,XX @@ binviw 0110100 .......... 001 ..... 0011011 @sh5
61
sloiw 0010000 .......... 001 ..... 0011011 @sh5
62
sroiw 0010000 .......... 101 ..... 0011011 @sh5
63
roriw 0110000 .......... 101 ..... 0011011 @sh5
64
+greviw 0110100 .......... 101 ..... 0011011 @sh5
65
diff --git a/target/riscv/bitmanip_helper.c b/target/riscv/bitmanip_helper.c
66
new file mode 100644
67
index XXXXXXX..XXXXXXX
68
--- /dev/null
69
+++ b/target/riscv/bitmanip_helper.c
70
@@ -XXX,XX +XXX,XX @@
71
+/*
72
+ * RISC-V Bitmanip Extension Helpers for QEMU.
73
+ *
74
+ * Copyright (c) 2020 Kito Cheng, kito.cheng@sifive.com
75
+ * Copyright (c) 2020 Frank Chang, frank.chang@sifive.com
76
+ *
77
+ * This program is free software; you can redistribute it and/or modify it
78
+ * under the terms and conditions of the GNU General Public License,
79
+ * version 2 or later, as published by the Free Software Foundation.
80
+ *
81
+ * This program is distributed in the hope it will be useful, but WITHOUT
82
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
83
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
84
+ * more details.
85
+ *
86
+ * You should have received a copy of the GNU General Public License along with
87
+ * this program. If not, see <http://www.gnu.org/licenses/>.
88
+ */
89
+
90
+#include "qemu/osdep.h"
91
+#include "qemu/host-utils.h"
92
+#include "exec/exec-all.h"
93
+#include "exec/helper-proto.h"
94
+#include "tcg/tcg.h"
95
+
96
+static const uint64_t adjacent_masks[] = {
97
+ dup_const(MO_8, 0x55),
98
+ dup_const(MO_8, 0x33),
99
+ dup_const(MO_8, 0x0f),
100
+ dup_const(MO_16, 0xff),
101
+ dup_const(MO_32, 0xffff),
102
+ UINT32_MAX
103
+};
104
+
105
+static inline target_ulong do_swap(target_ulong x, uint64_t mask, int shift)
106
+{
107
+ return ((x & mask) << shift) | ((x & ~mask) >> shift);
108
+}
109
+
110
+static target_ulong do_grev(target_ulong rs1,
111
+ target_ulong rs2,
112
+ int bits)
113
+{
114
+ target_ulong x = rs1;
115
+ int i, shift;
116
+
117
+ for (i = 0, shift = 1; shift < bits; i++, shift <<= 1) {
118
+ if (rs2 & shift) {
119
+ x = do_swap(x, adjacent_masks[i], shift);
120
+ }
121
+ }
122
+
123
+ return x;
124
+}
125
+
126
+target_ulong HELPER(grev)(target_ulong rs1, target_ulong rs2)
127
+{
128
+ return do_grev(rs1, rs2, TARGET_LONG_BITS);
129
+}
130
+
131
+target_ulong HELPER(grevw)(target_ulong rs1, target_ulong rs2)
132
+{
133
+ return do_grev(rs1, rs2, 32);
134
+}
135
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
136
index XXXXXXX..XXXXXXX 100644
137
--- a/target/riscv/translate.c
138
+++ b/target/riscv/translate.c
139
@@ -XXX,XX +XXX,XX @@ static void gen_sro(TCGv ret, TCGv arg1, TCGv arg2)
140
tcg_gen_not_tl(ret, ret);
141
}
142
143
+static bool gen_grevi(DisasContext *ctx, arg_grevi *a)
144
+{
145
+ TCGv source1 = tcg_temp_new();
146
+ TCGv source2;
147
+
148
+ gen_get_gpr(source1, a->rs1);
149
+
150
+ if (a->shamt == (TARGET_LONG_BITS - 8)) {
151
+ /* rev8, byte swaps */
152
+ tcg_gen_bswap_tl(source1, source1);
153
+ } else {
154
+ source2 = tcg_temp_new();
155
+ tcg_gen_movi_tl(source2, a->shamt);
156
+ gen_helper_grev(source1, source1, source2);
157
+ tcg_temp_free(source2);
158
+ }
159
+
160
+ gen_set_gpr(a->rd, source1);
161
+ tcg_temp_free(source1);
162
+ return true;
163
+}
164
+
165
static void gen_ctzw(TCGv ret, TCGv arg1)
166
{
167
tcg_gen_ori_tl(ret, arg1, (target_ulong)MAKE_64BIT_MASK(32, 32));
168
@@ -XXX,XX +XXX,XX @@ static void gen_rolw(TCGv ret, TCGv arg1, TCGv arg2)
169
tcg_temp_free_i32(t2);
170
}
171
172
+static void gen_grevw(TCGv ret, TCGv arg1, TCGv arg2)
173
+{
174
+ tcg_gen_ext32u_tl(arg1, arg1);
175
+ gen_helper_grev(ret, arg1, arg2);
176
+}
177
+
178
static bool gen_arith(DisasContext *ctx, arg_r *a,
179
void(*func)(TCGv, TCGv, TCGv))
180
{
181
diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_trans/trans_rvb.c.inc
182
index XXXXXXX..XXXXXXX 100644
183
--- a/target/riscv/insn_trans/trans_rvb.c.inc
184
+++ b/target/riscv/insn_trans/trans_rvb.c.inc
185
@@ -XXX,XX +XXX,XX @@ static bool trans_rol(DisasContext *ctx, arg_rol *a)
186
return gen_shift(ctx, a, tcg_gen_rotl_tl);
187
}
188
189
+static bool trans_grev(DisasContext *ctx, arg_grev *a)
190
+{
191
+ REQUIRE_EXT(ctx, RVB);
192
+ return gen_shift(ctx, a, gen_helper_grev);
193
+}
194
+
195
+static bool trans_grevi(DisasContext *ctx, arg_grevi *a)
196
+{
197
+ REQUIRE_EXT(ctx, RVB);
198
+
199
+ if (a->shamt >= TARGET_LONG_BITS) {
200
+ return false;
201
+ }
202
+
203
+ return gen_grevi(ctx, a);
204
+}
205
+
206
static bool trans_clzw(DisasContext *ctx, arg_clzw *a)
207
{
208
REQUIRE_64BIT(ctx);
209
@@ -XXX,XX +XXX,XX @@ static bool trans_rolw(DisasContext *ctx, arg_rolw *a)
210
REQUIRE_EXT(ctx, RVB);
211
return gen_shiftw(ctx, a, gen_rolw);
212
}
213
+
214
+static bool trans_grevw(DisasContext *ctx, arg_grevw *a)
215
+{
216
+ REQUIRE_64BIT(ctx);
217
+ REQUIRE_EXT(ctx, RVB);
218
+ return gen_shiftw(ctx, a, gen_grevw);
219
+}
220
+
221
+static bool trans_greviw(DisasContext *ctx, arg_greviw *a)
222
+{
223
+ REQUIRE_64BIT(ctx);
224
+ REQUIRE_EXT(ctx, RVB);
225
+ return gen_shiftiw(ctx, a, gen_grevw);
226
+}
227
diff --git a/target/riscv/meson.build b/target/riscv/meson.build
228
index XXXXXXX..XXXXXXX 100644
229
--- a/target/riscv/meson.build
230
+++ b/target/riscv/meson.build
231
@@ -XXX,XX +XXX,XX @@ riscv_ss.add(files(
232
'gdbstub.c',
233
'op_helper.c',
234
'vector_helper.c',
235
+ 'bitmanip_helper.c',
236
'translate.c',
237
))
238
239
--
240
2.31.1
241
242
diff view generated by jsdifflib
Deleted patch
1
From: Frank Chang <frank.chang@sifive.com>
2
1
3
Signed-off-by: Frank Chang <frank.chang@sifive.com>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20210505160620.15723-14-frank.chang@sifive.com
6
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
7
---
8
target/riscv/helper.h | 2 ++
9
target/riscv/insn32.decode | 4 ++++
10
target/riscv/bitmanip_helper.c | 26 +++++++++++++++++++++++++
11
target/riscv/translate.c | 6 ++++++
12
target/riscv/insn_trans/trans_rvb.c.inc | 26 +++++++++++++++++++++++++
13
5 files changed, 64 insertions(+)
14
15
diff --git a/target/riscv/helper.h b/target/riscv/helper.h
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/riscv/helper.h
18
+++ b/target/riscv/helper.h
19
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_1(fclass_d, TCG_CALL_NO_RWG_SE, tl, i64)
20
/* Bitmanip */
21
DEF_HELPER_FLAGS_2(grev, TCG_CALL_NO_RWG_SE, tl, tl, tl)
22
DEF_HELPER_FLAGS_2(grevw, TCG_CALL_NO_RWG_SE, tl, tl, tl)
23
+DEF_HELPER_FLAGS_2(gorc, TCG_CALL_NO_RWG_SE, tl, tl, tl)
24
+DEF_HELPER_FLAGS_2(gorcw, TCG_CALL_NO_RWG_SE, tl, tl, tl)
25
26
/* Special functions */
27
DEF_HELPER_3(csrrw, tl, env, tl, tl)
28
diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode
29
index XXXXXXX..XXXXXXX 100644
30
--- a/target/riscv/insn32.decode
31
+++ b/target/riscv/insn32.decode
32
@@ -XXX,XX +XXX,XX @@ sro 0010000 .......... 101 ..... 0110011 @r
33
ror 0110000 .......... 101 ..... 0110011 @r
34
rol 0110000 .......... 001 ..... 0110011 @r
35
grev 0110100 .......... 101 ..... 0110011 @r
36
+gorc 0010100 .......... 101 ..... 0110011 @r
37
38
bseti 00101. ........... 001 ..... 0010011 @sh
39
bclri 01001. ........... 001 ..... 0010011 @sh
40
@@ -XXX,XX +XXX,XX @@ sloi 00100. ........... 001 ..... 0010011 @sh
41
sroi 00100. ........... 101 ..... 0010011 @sh
42
rori 01100. ........... 101 ..... 0010011 @sh
43
grevi 01101. ........... 101 ..... 0010011 @sh
44
+gorci 00101. ........... 101 ..... 0010011 @sh
45
46
# *** RV64B Standard Extension (in addition to RV32B) ***
47
clzw 0110000 00000 ..... 001 ..... 0011011 @r2
48
@@ -XXX,XX +XXX,XX @@ srow 0010000 .......... 101 ..... 0111011 @r
49
rorw 0110000 .......... 101 ..... 0111011 @r
50
rolw 0110000 .......... 001 ..... 0111011 @r
51
grevw 0110100 .......... 101 ..... 0111011 @r
52
+gorcw 0010100 .......... 101 ..... 0111011 @r
53
54
bsetiw 0010100 .......... 001 ..... 0011011 @sh5
55
bclriw 0100100 .......... 001 ..... 0011011 @sh5
56
@@ -XXX,XX +XXX,XX @@ sloiw 0010000 .......... 001 ..... 0011011 @sh5
57
sroiw 0010000 .......... 101 ..... 0011011 @sh5
58
roriw 0110000 .......... 101 ..... 0011011 @sh5
59
greviw 0110100 .......... 101 ..... 0011011 @sh5
60
+gorciw 0010100 .......... 101 ..... 0011011 @sh5
61
diff --git a/target/riscv/bitmanip_helper.c b/target/riscv/bitmanip_helper.c
62
index XXXXXXX..XXXXXXX 100644
63
--- a/target/riscv/bitmanip_helper.c
64
+++ b/target/riscv/bitmanip_helper.c
65
@@ -XXX,XX +XXX,XX @@ target_ulong HELPER(grevw)(target_ulong rs1, target_ulong rs2)
66
{
67
return do_grev(rs1, rs2, 32);
68
}
69
+
70
+static target_ulong do_gorc(target_ulong rs1,
71
+ target_ulong rs2,
72
+ int bits)
73
+{
74
+ target_ulong x = rs1;
75
+ int i, shift;
76
+
77
+ for (i = 0, shift = 1; shift < bits; i++, shift <<= 1) {
78
+ if (rs2 & shift) {
79
+ x |= do_swap(x, adjacent_masks[i], shift);
80
+ }
81
+ }
82
+
83
+ return x;
84
+}
85
+
86
+target_ulong HELPER(gorc)(target_ulong rs1, target_ulong rs2)
87
+{
88
+ return do_gorc(rs1, rs2, TARGET_LONG_BITS);
89
+}
90
+
91
+target_ulong HELPER(gorcw)(target_ulong rs1, target_ulong rs2)
92
+{
93
+ return do_gorc(rs1, rs2, 32);
94
+}
95
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
96
index XXXXXXX..XXXXXXX 100644
97
--- a/target/riscv/translate.c
98
+++ b/target/riscv/translate.c
99
@@ -XXX,XX +XXX,XX @@ static void gen_grevw(TCGv ret, TCGv arg1, TCGv arg2)
100
gen_helper_grev(ret, arg1, arg2);
101
}
102
103
+static void gen_gorcw(TCGv ret, TCGv arg1, TCGv arg2)
104
+{
105
+ tcg_gen_ext32u_tl(arg1, arg1);
106
+ gen_helper_gorcw(ret, arg1, arg2);
107
+}
108
+
109
static bool gen_arith(DisasContext *ctx, arg_r *a,
110
void(*func)(TCGv, TCGv, TCGv))
111
{
112
diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_trans/trans_rvb.c.inc
113
index XXXXXXX..XXXXXXX 100644
114
--- a/target/riscv/insn_trans/trans_rvb.c.inc
115
+++ b/target/riscv/insn_trans/trans_rvb.c.inc
116
@@ -XXX,XX +XXX,XX @@ static bool trans_grevi(DisasContext *ctx, arg_grevi *a)
117
return gen_grevi(ctx, a);
118
}
119
120
+static bool trans_gorc(DisasContext *ctx, arg_gorc *a)
121
+{
122
+ REQUIRE_EXT(ctx, RVB);
123
+ return gen_shift(ctx, a, gen_helper_gorc);
124
+}
125
+
126
+static bool trans_gorci(DisasContext *ctx, arg_gorci *a)
127
+{
128
+ REQUIRE_EXT(ctx, RVB);
129
+ return gen_shifti(ctx, a, gen_helper_gorc);
130
+}
131
+
132
static bool trans_clzw(DisasContext *ctx, arg_clzw *a)
133
{
134
REQUIRE_64BIT(ctx);
135
@@ -XXX,XX +XXX,XX @@ static bool trans_greviw(DisasContext *ctx, arg_greviw *a)
136
REQUIRE_EXT(ctx, RVB);
137
return gen_shiftiw(ctx, a, gen_grevw);
138
}
139
+
140
+static bool trans_gorcw(DisasContext *ctx, arg_gorcw *a)
141
+{
142
+ REQUIRE_64BIT(ctx);
143
+ REQUIRE_EXT(ctx, RVB);
144
+ return gen_shiftw(ctx, a, gen_gorcw);
145
+}
146
+
147
+static bool trans_gorciw(DisasContext *ctx, arg_gorciw *a)
148
+{
149
+ REQUIRE_64BIT(ctx);
150
+ REQUIRE_EXT(ctx, RVB);
151
+ return gen_shiftiw(ctx, a, gen_gorcw);
152
+}
153
--
154
2.31.1
155
156
diff view generated by jsdifflib
Deleted patch
1
From: Kito Cheng <kito.cheng@sifive.com>
2
1
3
Signed-off-by: Kito Cheng <kito.cheng@sifive.com>
4
Signed-off-by: Frank Chang <frank.chang@sifive.com>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20210505160620.15723-15-frank.chang@sifive.com
7
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
8
---
9
target/riscv/insn32.decode | 6 +++++
10
target/riscv/translate.c | 32 +++++++++++++++++++++++++
11
target/riscv/insn_trans/trans_rvb.c.inc | 24 +++++++++++++++++++
12
3 files changed, 62 insertions(+)
13
14
diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/riscv/insn32.decode
17
+++ b/target/riscv/insn32.decode
18
@@ -XXX,XX +XXX,XX @@ ror 0110000 .......... 101 ..... 0110011 @r
19
rol 0110000 .......... 001 ..... 0110011 @r
20
grev 0110100 .......... 101 ..... 0110011 @r
21
gorc 0010100 .......... 101 ..... 0110011 @r
22
+sh1add 0010000 .......... 010 ..... 0110011 @r
23
+sh2add 0010000 .......... 100 ..... 0110011 @r
24
+sh3add 0010000 .......... 110 ..... 0110011 @r
25
26
bseti 00101. ........... 001 ..... 0010011 @sh
27
bclri 01001. ........... 001 ..... 0010011 @sh
28
@@ -XXX,XX +XXX,XX @@ rorw 0110000 .......... 101 ..... 0111011 @r
29
rolw 0110000 .......... 001 ..... 0111011 @r
30
grevw 0110100 .......... 101 ..... 0111011 @r
31
gorcw 0010100 .......... 101 ..... 0111011 @r
32
+sh1add_uw 0010000 .......... 010 ..... 0111011 @r
33
+sh2add_uw 0010000 .......... 100 ..... 0111011 @r
34
+sh3add_uw 0010000 .......... 110 ..... 0111011 @r
35
36
bsetiw 0010100 .......... 001 ..... 0011011 @sh5
37
bclriw 0100100 .......... 001 ..... 0011011 @sh5
38
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
39
index XXXXXXX..XXXXXXX 100644
40
--- a/target/riscv/translate.c
41
+++ b/target/riscv/translate.c
42
@@ -XXX,XX +XXX,XX @@ static bool gen_grevi(DisasContext *ctx, arg_grevi *a)
43
return true;
44
}
45
46
+#define GEN_SHADD(SHAMT) \
47
+static void gen_sh##SHAMT##add(TCGv ret, TCGv arg1, TCGv arg2) \
48
+{ \
49
+ TCGv t = tcg_temp_new(); \
50
+ \
51
+ tcg_gen_shli_tl(t, arg1, SHAMT); \
52
+ tcg_gen_add_tl(ret, t, arg2); \
53
+ \
54
+ tcg_temp_free(t); \
55
+}
56
+
57
+GEN_SHADD(1)
58
+GEN_SHADD(2)
59
+GEN_SHADD(3)
60
+
61
static void gen_ctzw(TCGv ret, TCGv arg1)
62
{
63
tcg_gen_ori_tl(ret, arg1, (target_ulong)MAKE_64BIT_MASK(32, 32));
64
@@ -XXX,XX +XXX,XX @@ static void gen_gorcw(TCGv ret, TCGv arg1, TCGv arg2)
65
gen_helper_gorcw(ret, arg1, arg2);
66
}
67
68
+#define GEN_SHADD_UW(SHAMT) \
69
+static void gen_sh##SHAMT##add_uw(TCGv ret, TCGv arg1, TCGv arg2) \
70
+{ \
71
+ TCGv t = tcg_temp_new(); \
72
+ \
73
+ tcg_gen_ext32u_tl(t, arg1); \
74
+ \
75
+ tcg_gen_shli_tl(t, t, SHAMT); \
76
+ tcg_gen_add_tl(ret, t, arg2); \
77
+ \
78
+ tcg_temp_free(t); \
79
+}
80
+
81
+GEN_SHADD_UW(1)
82
+GEN_SHADD_UW(2)
83
+GEN_SHADD_UW(3)
84
+
85
static bool gen_arith(DisasContext *ctx, arg_r *a,
86
void(*func)(TCGv, TCGv, TCGv))
87
{
88
diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_trans/trans_rvb.c.inc
89
index XXXXXXX..XXXXXXX 100644
90
--- a/target/riscv/insn_trans/trans_rvb.c.inc
91
+++ b/target/riscv/insn_trans/trans_rvb.c.inc
92
@@ -XXX,XX +XXX,XX @@ static bool trans_gorci(DisasContext *ctx, arg_gorci *a)
93
return gen_shifti(ctx, a, gen_helper_gorc);
94
}
95
96
+#define GEN_TRANS_SHADD(SHAMT) \
97
+static bool trans_sh##SHAMT##add(DisasContext *ctx, arg_sh##SHAMT##add *a) \
98
+{ \
99
+ REQUIRE_EXT(ctx, RVB); \
100
+ return gen_arith(ctx, a, gen_sh##SHAMT##add); \
101
+}
102
+
103
+GEN_TRANS_SHADD(1)
104
+GEN_TRANS_SHADD(2)
105
+GEN_TRANS_SHADD(3)
106
+
107
static bool trans_clzw(DisasContext *ctx, arg_clzw *a)
108
{
109
REQUIRE_64BIT(ctx);
110
@@ -XXX,XX +XXX,XX @@ static bool trans_gorciw(DisasContext *ctx, arg_gorciw *a)
111
REQUIRE_EXT(ctx, RVB);
112
return gen_shiftiw(ctx, a, gen_gorcw);
113
}
114
+
115
+#define GEN_TRANS_SHADD_UW(SHAMT) \
116
+static bool trans_sh##SHAMT##add_uw(DisasContext *ctx, \
117
+ arg_sh##SHAMT##add_uw *a) \
118
+{ \
119
+ REQUIRE_64BIT(ctx); \
120
+ REQUIRE_EXT(ctx, RVB); \
121
+ return gen_arith(ctx, a, gen_sh##SHAMT##add_uw); \
122
+}
123
+
124
+GEN_TRANS_SHADD_UW(1)
125
+GEN_TRANS_SHADD_UW(2)
126
+GEN_TRANS_SHADD_UW(3)
127
--
128
2.31.1
129
130
diff view generated by jsdifflib
Deleted patch
1
From: Kito Cheng <kito.cheng@sifive.com>
2
1
3
Signed-off-by: Kito Cheng <kito.cheng@sifive.com>
4
Signed-off-by: Frank Chang <frank.chang@sifive.com>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20210505160620.15723-16-frank.chang@sifive.com
7
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
8
---
9
target/riscv/insn32.decode | 3 +++
10
target/riscv/translate.c | 6 ++++++
11
target/riscv/insn_trans/trans_rvb.c.inc | 26 +++++++++++++++++++++++++
12
3 files changed, 35 insertions(+)
13
14
diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/riscv/insn32.decode
17
+++ b/target/riscv/insn32.decode
18
@@ -XXX,XX +XXX,XX @@ gorcw 0010100 .......... 101 ..... 0111011 @r
19
sh1add_uw 0010000 .......... 010 ..... 0111011 @r
20
sh2add_uw 0010000 .......... 100 ..... 0111011 @r
21
sh3add_uw 0010000 .......... 110 ..... 0111011 @r
22
+add_uw 0000100 .......... 000 ..... 0111011 @r
23
24
bsetiw 0010100 .......... 001 ..... 0011011 @sh5
25
bclriw 0100100 .......... 001 ..... 0011011 @sh5
26
@@ -XXX,XX +XXX,XX @@ sroiw 0010000 .......... 101 ..... 0011011 @sh5
27
roriw 0110000 .......... 101 ..... 0011011 @sh5
28
greviw 0110100 .......... 101 ..... 0011011 @sh5
29
gorciw 0010100 .......... 101 ..... 0011011 @sh5
30
+
31
+slli_uw 00001. ........... 001 ..... 0011011 @sh
32
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
33
index XXXXXXX..XXXXXXX 100644
34
--- a/target/riscv/translate.c
35
+++ b/target/riscv/translate.c
36
@@ -XXX,XX +XXX,XX @@ GEN_SHADD_UW(1)
37
GEN_SHADD_UW(2)
38
GEN_SHADD_UW(3)
39
40
+static void gen_add_uw(TCGv ret, TCGv arg1, TCGv arg2)
41
+{
42
+ tcg_gen_ext32u_tl(arg1, arg1);
43
+ tcg_gen_add_tl(ret, arg1, arg2);
44
+}
45
+
46
static bool gen_arith(DisasContext *ctx, arg_r *a,
47
void(*func)(TCGv, TCGv, TCGv))
48
{
49
diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_trans/trans_rvb.c.inc
50
index XXXXXXX..XXXXXXX 100644
51
--- a/target/riscv/insn_trans/trans_rvb.c.inc
52
+++ b/target/riscv/insn_trans/trans_rvb.c.inc
53
@@ -XXX,XX +XXX,XX @@ static bool trans_sh##SHAMT##add_uw(DisasContext *ctx, \
54
GEN_TRANS_SHADD_UW(1)
55
GEN_TRANS_SHADD_UW(2)
56
GEN_TRANS_SHADD_UW(3)
57
+
58
+static bool trans_add_uw(DisasContext *ctx, arg_add_uw *a)
59
+{
60
+ REQUIRE_64BIT(ctx);
61
+ REQUIRE_EXT(ctx, RVB);
62
+ return gen_arith(ctx, a, gen_add_uw);
63
+}
64
+
65
+static bool trans_slli_uw(DisasContext *ctx, arg_slli_uw *a)
66
+{
67
+ REQUIRE_64BIT(ctx);
68
+ REQUIRE_EXT(ctx, RVB);
69
+
70
+ TCGv source1 = tcg_temp_new();
71
+ gen_get_gpr(source1, a->rs1);
72
+
73
+ if (a->shamt < 32) {
74
+ tcg_gen_deposit_z_tl(source1, source1, a->shamt, 32);
75
+ } else {
76
+ tcg_gen_shli_tl(source1, source1, a->shamt);
77
+ }
78
+
79
+ gen_set_gpr(a->rd, source1);
80
+ tcg_temp_free(source1);
81
+ return true;
82
+}
83
--
84
2.31.1
85
86
diff view generated by jsdifflib
Deleted patch
1
From: Kito Cheng <kito.cheng@sifive.com>
2
1
3
B-extension is default off, use cpu rv32 or rv64 with x-b=true to
4
enable B-extension.
5
6
Signed-off-by: Kito Cheng <kito.cheng@sifive.com>
7
Signed-off-by: Frank Chang <frank.chang@sifive.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20210505160620.15723-17-frank.chang@sifive.com
11
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
12
---
13
target/riscv/cpu.h | 1 +
14
target/riscv/cpu.c | 4 ++++
15
2 files changed, 5 insertions(+)
16
17
diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
18
index XXXXXXX..XXXXXXX 100644
19
--- a/target/riscv/cpu.h
20
+++ b/target/riscv/cpu.h
21
@@ -XXX,XX +XXX,XX @@ struct RISCVCPU {
22
bool ext_f;
23
bool ext_d;
24
bool ext_c;
25
+ bool ext_b;
26
bool ext_s;
27
bool ext_u;
28
bool ext_h;
29
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
30
index XXXXXXX..XXXXXXX 100644
31
--- a/target/riscv/cpu.c
32
+++ b/target/riscv/cpu.c
33
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)
34
if (cpu->cfg.ext_h) {
35
target_misa |= RVH;
36
}
37
+ if (cpu->cfg.ext_b) {
38
+ target_misa |= RVB;
39
+ }
40
if (cpu->cfg.ext_v) {
41
target_misa |= RVV;
42
if (!is_power_of_2(cpu->cfg.vlen)) {
43
@@ -XXX,XX +XXX,XX @@ static Property riscv_cpu_properties[] = {
44
DEFINE_PROP_BOOL("s", RISCVCPU, cfg.ext_s, true),
45
DEFINE_PROP_BOOL("u", RISCVCPU, cfg.ext_u, true),
46
/* This is experimental so mark with 'x-' */
47
+ DEFINE_PROP_BOOL("x-b", RISCVCPU, cfg.ext_b, false),
48
DEFINE_PROP_BOOL("x-h", RISCVCPU, cfg.ext_h, false),
49
DEFINE_PROP_BOOL("x-v", RISCVCPU, cfg.ext_v, false),
50
DEFINE_PROP_BOOL("Counters", RISCVCPU, cfg.ext_counters, true),
51
--
52
2.31.1
53
54
diff view generated by jsdifflib
Deleted patch
1
From: Frank Chang <frank.chang@sifive.com>
2
1
3
Default b-ext version is v0.93.
4
5
Signed-off-by: Frank Chang <frank.chang@sifive.com>
6
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
7
Message-id: 20210505160620.15723-18-frank.chang@sifive.com
8
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
9
---
10
target/riscv/cpu.h | 3 +++
11
target/riscv/cpu.c | 23 +++++++++++++++++++++++
12
2 files changed, 26 insertions(+)
13
14
diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/riscv/cpu.h
17
+++ b/target/riscv/cpu.h
18
@@ -XXX,XX +XXX,XX @@ enum {
19
#define PRIV_VERSION_1_10_0 0x00011000
20
#define PRIV_VERSION_1_11_0 0x00011100
21
22
+#define BEXT_VERSION_0_93_0 0x00009300
23
#define VEXT_VERSION_0_07_1 0x00000701
24
25
enum {
26
@@ -XXX,XX +XXX,XX @@ struct CPURISCVState {
27
target_ulong guest_phys_fault_addr;
28
29
target_ulong priv_ver;
30
+ target_ulong bext_ver;
31
target_ulong vext_ver;
32
target_ulong misa;
33
target_ulong misa_mask;
34
@@ -XXX,XX +XXX,XX @@ struct RISCVCPU {
35
36
char *priv_spec;
37
char *user_spec;
38
+ char *bext_spec;
39
char *vext_spec;
40
uint16_t vlen;
41
uint16_t elen;
42
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
43
index XXXXXXX..XXXXXXX 100644
44
--- a/target/riscv/cpu.c
45
+++ b/target/riscv/cpu.c
46
@@ -XXX,XX +XXX,XX @@ static void set_priv_version(CPURISCVState *env, int priv_ver)
47
env->priv_ver = priv_ver;
48
}
49
50
+static void set_bext_version(CPURISCVState *env, int bext_ver)
51
+{
52
+ env->bext_ver = bext_ver;
53
+}
54
+
55
static void set_vext_version(CPURISCVState *env, int vext_ver)
56
{
57
env->vext_ver = vext_ver;
58
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)
59
CPURISCVState *env = &cpu->env;
60
RISCVCPUClass *mcc = RISCV_CPU_GET_CLASS(dev);
61
int priv_version = PRIV_VERSION_1_11_0;
62
+ int bext_version = BEXT_VERSION_0_93_0;
63
int vext_version = VEXT_VERSION_0_07_1;
64
target_ulong target_misa = env->misa;
65
Error *local_err = NULL;
66
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)
67
}
68
69
set_priv_version(env, priv_version);
70
+ set_bext_version(env, bext_version);
71
set_vext_version(env, vext_version);
72
73
if (cpu->cfg.mmu) {
74
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)
75
}
76
if (cpu->cfg.ext_b) {
77
target_misa |= RVB;
78
+
79
+ if (cpu->cfg.bext_spec) {
80
+ if (!g_strcmp0(cpu->cfg.bext_spec, "v0.93")) {
81
+ bext_version = BEXT_VERSION_0_93_0;
82
+ } else {
83
+ error_setg(errp,
84
+ "Unsupported bitmanip spec version '%s'",
85
+ cpu->cfg.bext_spec);
86
+ return;
87
+ }
88
+ } else {
89
+ qemu_log("bitmanip version is not specified, "
90
+ "use the default value v0.93\n");
91
+ }
92
+ set_bext_version(env, bext_version);
93
}
94
if (cpu->cfg.ext_v) {
95
target_misa |= RVV;
96
@@ -XXX,XX +XXX,XX @@ static Property riscv_cpu_properties[] = {
97
DEFINE_PROP_BOOL("Zifencei", RISCVCPU, cfg.ext_ifencei, true),
98
DEFINE_PROP_BOOL("Zicsr", RISCVCPU, cfg.ext_icsr, true),
99
DEFINE_PROP_STRING("priv_spec", RISCVCPU, cfg.priv_spec),
100
+ DEFINE_PROP_STRING("bext_spec", RISCVCPU, cfg.bext_spec),
101
DEFINE_PROP_STRING("vext_spec", RISCVCPU, cfg.vext_spec),
102
DEFINE_PROP_UINT16("vlen", RISCVCPU, cfg.vlen, 128),
103
DEFINE_PROP_UINT16("elen", RISCVCPU, cfg.elen, 64),
104
--
105
2.31.1
106
107
diff view generated by jsdifflib