Skip to content

Commit 5439560

Browse files
committed
UNRATIFIED RISC-V: Add 'Zjpm' extension and its TENTATIVE CSRs
[DO NOT MERGE] Until 'Zjpm' extension is frozen/ratified and final version number is determined, this patch should not be merged upstream. This commit uses unratified version 0.3 as in the latest PDF documentation (instead of possible 1.0 after ratification). This commit adds pointer masking proposal (Zjpm) and its CSRs based on the latest commit of the 'Zjpm' extension documentation. <https://github.com/riscv/riscv-j-extension/tree/2f8b10484851dd03f8d607833633efee7e73cff0/zjpm> Note that, this "zjpm" directory does not contain version numbers and "zjpm-spec.pdf" on the root directory slightly differs from this directory. ***Note*** Because CSR addresses are not fixed yet, this commit uses tentative addresses (a part of custom CSR space). bfd/ChangeLog: * elfxx-riscv.c (riscv_implicit_subsets) Add implication 'Zjpm' -> 'Zicsr'. (riscv_supported_std_z_ext): Add 'Zjpm' extension to valid 'Z' extension list. gas/ChangeLog: * config/tc-riscv.c (enum riscv_csr_class): Add CSR classes for the 'Zjpm' extension. (riscv_csr_address): Add handling for new CSR classes. * testsuite/gas/riscv/csr-dw-regnums.d: Add new CSRs. * testsuite/gas/riscv/csr-dw-regnums.s: Likewise. * testsuite/gas/riscv/csr.s: Add new CSRs. * testsuite/gas/riscv/csr-version-1p9p1.d: Likewise. * testsuite/gas/riscv/csr-version-1p9p1.l: Likewise. * testsuite/gas/riscv/csr-version-1p10.d: Likewise. * testsuite/gas/riscv/csr-version-1p10.l: Likewise. * testsuite/gas/riscv/csr-version-1p11.d: Likewise. * testsuite/gas/riscv/csr-version-1p11.l: Likewise. * testsuite/gas/riscv/csr-version-1p12.d: Likewise. * testsuite/gas/riscv/csr-version-1p12.l: Likewise. include/ChangeLog: * opcode/riscv-opc.h (CSR_MPM, CSR_HSPM, CSR_SPM, CSR_UPM): New CSR macros.
1 parent 0961e63 commit 5439560

File tree

14 files changed

+147
-0
lines changed

14 files changed

+147
-0
lines changed

bfd/elfxx-riscv.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,7 @@ static struct riscv_implicit_subset riscv_implicit_subsets[] =
11011101
{"zks", "zbkx", check_implicit_always},
11021102
{"zks", "zksed", check_implicit_always},
11031103
{"zks", "zksh", check_implicit_always},
1104+
{"zjpm", "zicsr", check_implicit_always},
11041105
{"smaia", "ssaia", check_implicit_always},
11051106
{"smstateen", "ssstateen", check_implicit_always},
11061107
{"smepmp", "zicsr", check_implicit_always},
@@ -1199,6 +1200,7 @@ static struct riscv_supported_ext riscv_supported_std_z_ext[] =
11991200
{"zksed", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
12001201
{"zksh", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
12011202
{"zkt", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
1203+
{"zjpm", ISA_SPEC_CLASS_DRAFT, 0, 3, 0 },
12021204
{"zve32x", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
12031205
{"zve32f", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
12041206
{"zve32d", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },

gas/config/tc-riscv.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ enum riscv_csr_class
6868
CSR_CLASS_I_32, /* rv32 only */
6969
CSR_CLASS_F, /* f-ext only */
7070
CSR_CLASS_ZKR, /* zkr only */
71+
CSR_CLASS_ZJPM, /* zjpm only */
72+
CSR_CLASS_ZJPM_AND_H, /* zjpm only (with H) */
7173
CSR_CLASS_V, /* rvv only */
7274
CSR_CLASS_DEBUG, /* debug CSR */
7375
CSR_CLASS_H, /* hypervisor */
@@ -1040,6 +1042,12 @@ riscv_csr_address (const char *csr_name,
10401042
case CSR_CLASS_ZKR:
10411043
extension = "zkr";
10421044
break;
1045+
case CSR_CLASS_ZJPM_AND_H:
1046+
is_h_required = true;
1047+
/* Fall through. */
1048+
case CSR_CLASS_ZJPM:
1049+
extension = "zjpm";
1050+
break;
10431051
case CSR_CLASS_V:
10441052
extension = "zve32x";
10451053
break;

gas/testsuite/gas/riscv/csr-dw-regnums.d

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,4 +456,8 @@ Contents of the .* section:
456456
DW_CFA_offset_extended_sf: r7200 \(vl\) at cfa\+12416
457457
DW_CFA_offset_extended_sf: r7201 \(vtype\) at cfa\+12420
458458
DW_CFA_offset_extended_sf: r7202 \(vlenb\) at cfa\+12424
459+
DW_CFA_offset_extended_sf: r7104 \(mpm\) at cfa\+12032
460+
DW_CFA_offset_extended_sf: r6592 \(spm\) at cfa\+9984
461+
DW_CFA_offset_extended_sf: r6336 \(upm\) at cfa\+8960
462+
DW_CFA_offset_extended_sf: r6848 \(hspm\) at cfa\+11008
459463
#...

gas/testsuite/gas/riscv/csr-dw-regnums.s

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,5 +459,10 @@ _start:
459459
.cfi_offset vl, 12416
460460
.cfi_offset vtype, 12420
461461
.cfi_offset vlenb, 12424
462+
# Zjpm extension (both privileged and unprivileged)
463+
.cfi_offset mpm, 12032
464+
.cfi_offset spm, 9984
465+
.cfi_offset upm, 8960
466+
.cfi_offset hspm, 11008
462467
nop
463468
.cfi_endproc

gas/testsuite/gas/riscv/csr-version-1p10.d

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,3 +887,11 @@ Disassembly of section .text:
887887
[ ]+[0-9a-f]+:[ ]+c2159073[ ]+csrw[ ]+vtype,a1
888888
[ ]+[0-9a-f]+:[ ]+c2202573[ ]+csrr[ ]+a0,vlenb
889889
[ ]+[0-9a-f]+:[ ]+c2259073[ ]+csrw[ ]+vlenb,a1
890+
[ ]+[0-9a-f]+:[ ]+bc002573[ ]+csrr[ ]+a0,mpm
891+
[ ]+[0-9a-f]+:[ ]+bc059073[ ]+csrw[ ]+mpm,a1
892+
[ ]+[0-9a-f]+:[ ]+9c002573[ ]+csrr[ ]+a0,spm
893+
[ ]+[0-9a-f]+:[ ]+9c059073[ ]+csrw[ ]+spm,a1
894+
[ ]+[0-9a-f]+:[ ]+8c002573[ ]+csrr[ ]+a0,upm
895+
[ ]+[0-9a-f]+:[ ]+8c059073[ ]+csrw[ ]+upm,a1
896+
[ ]+[0-9a-f]+:[ ]+ac002573[ ]+csrr[ ]+a0,hspm
897+
[ ]+[0-9a-f]+:[ ]+ac059073[ ]+csrw[ ]+hspm,a1

gas/testsuite/gas/riscv/csr-version-1p10.l

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,3 +1589,23 @@
15891589
.*Info: macro .*
15901590
.*Warning: read-only CSR is written `csrw vlenb,a1'
15911591
.*Info: macro .*
1592+
.*Warning: invalid CSR `mpm', needs `zjpm' extension
1593+
.*Info: macro .*
1594+
.*Warning: invalid CSR `mpm', needs `zjpm' extension
1595+
.*Info: macro .*
1596+
.*Warning: invalid CSR `spm', needs `zjpm' extension
1597+
.*Info: macro .*
1598+
.*Warning: invalid CSR `spm', needs `zjpm' extension
1599+
.*Info: macro .*
1600+
.*Warning: invalid CSR `upm', needs `zjpm' extension
1601+
.*Info: macro .*
1602+
.*Warning: invalid CSR `upm', needs `zjpm' extension
1603+
.*Info: macro .*
1604+
.*Warning: invalid CSR `hspm', needs `h' extension
1605+
.*Info: macro .*
1606+
.*Warning: invalid CSR `hspm', needs `zjpm' extension
1607+
.*Info: macro .*
1608+
.*Warning: invalid CSR `hspm', needs `h' extension
1609+
.*Info: macro .*
1610+
.*Warning: invalid CSR `hspm', needs `zjpm' extension
1611+
.*Info: macro .*

gas/testsuite/gas/riscv/csr-version-1p11.d

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,3 +887,11 @@ Disassembly of section .text:
887887
[ ]+[0-9a-f]+:[ ]+c2159073[ ]+csrw[ ]+vtype,a1
888888
[ ]+[0-9a-f]+:[ ]+c2202573[ ]+csrr[ ]+a0,vlenb
889889
[ ]+[0-9a-f]+:[ ]+c2259073[ ]+csrw[ ]+vlenb,a1
890+
[ ]+[0-9a-f]+:[ ]+bc002573[ ]+csrr[ ]+a0,mpm
891+
[ ]+[0-9a-f]+:[ ]+bc059073[ ]+csrw[ ]+mpm,a1
892+
[ ]+[0-9a-f]+:[ ]+9c002573[ ]+csrr[ ]+a0,spm
893+
[ ]+[0-9a-f]+:[ ]+9c059073[ ]+csrw[ ]+spm,a1
894+
[ ]+[0-9a-f]+:[ ]+8c002573[ ]+csrr[ ]+a0,upm
895+
[ ]+[0-9a-f]+:[ ]+8c059073[ ]+csrw[ ]+upm,a1
896+
[ ]+[0-9a-f]+:[ ]+ac002573[ ]+csrr[ ]+a0,hspm
897+
[ ]+[0-9a-f]+:[ ]+ac059073[ ]+csrw[ ]+hspm,a1

gas/testsuite/gas/riscv/csr-version-1p11.l

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,3 +1585,23 @@
15851585
.*Info: macro .*
15861586
.*Warning: read-only CSR is written `csrw vlenb,a1'
15871587
.*Info: macro .*
1588+
.*Warning: invalid CSR `mpm', needs `zjpm' extension
1589+
.*Info: macro .*
1590+
.*Warning: invalid CSR `mpm', needs `zjpm' extension
1591+
.*Info: macro .*
1592+
.*Warning: invalid CSR `spm', needs `zjpm' extension
1593+
.*Info: macro .*
1594+
.*Warning: invalid CSR `spm', needs `zjpm' extension
1595+
.*Info: macro .*
1596+
.*Warning: invalid CSR `upm', needs `zjpm' extension
1597+
.*Info: macro .*
1598+
.*Warning: invalid CSR `upm', needs `zjpm' extension
1599+
.*Info: macro .*
1600+
.*Warning: invalid CSR `hspm', needs `h' extension
1601+
.*Info: macro .*
1602+
.*Warning: invalid CSR `hspm', needs `zjpm' extension
1603+
.*Info: macro .*
1604+
.*Warning: invalid CSR `hspm', needs `h' extension
1605+
.*Info: macro .*
1606+
.*Warning: invalid CSR `hspm', needs `zjpm' extension
1607+
.*Info: macro .*

gas/testsuite/gas/riscv/csr-version-1p12.d

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,3 +887,11 @@ Disassembly of section .text:
887887
[ ]+[0-9a-f]+:[ ]+c2159073[ ]+csrw[ ]+vtype,a1
888888
[ ]+[0-9a-f]+:[ ]+c2202573[ ]+csrr[ ]+a0,vlenb
889889
[ ]+[0-9a-f]+:[ ]+c2259073[ ]+csrw[ ]+vlenb,a1
890+
[ ]+[0-9a-f]+:[ ]+bc002573[ ]+csrr[ ]+a0,mpm
891+
[ ]+[0-9a-f]+:[ ]+bc059073[ ]+csrw[ ]+mpm,a1
892+
[ ]+[0-9a-f]+:[ ]+9c002573[ ]+csrr[ ]+a0,spm
893+
[ ]+[0-9a-f]+:[ ]+9c059073[ ]+csrw[ ]+spm,a1
894+
[ ]+[0-9a-f]+:[ ]+8c002573[ ]+csrr[ ]+a0,upm
895+
[ ]+[0-9a-f]+:[ ]+8c059073[ ]+csrw[ ]+upm,a1
896+
[ ]+[0-9a-f]+:[ ]+ac002573[ ]+csrr[ ]+a0,hspm
897+
[ ]+[0-9a-f]+:[ ]+ac059073[ ]+csrw[ ]+hspm,a1

gas/testsuite/gas/riscv/csr-version-1p12.l

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,3 +1349,23 @@
13491349
.*Info: macro .*
13501350
.*Warning: read-only CSR is written `csrw vlenb,a1'
13511351
.*Info: macro .*
1352+
.*Warning: invalid CSR `mpm', needs `zjpm' extension
1353+
.*Info: macro .*
1354+
.*Warning: invalid CSR `mpm', needs `zjpm' extension
1355+
.*Info: macro .*
1356+
.*Warning: invalid CSR `spm', needs `zjpm' extension
1357+
.*Info: macro .*
1358+
.*Warning: invalid CSR `spm', needs `zjpm' extension
1359+
.*Info: macro .*
1360+
.*Warning: invalid CSR `upm', needs `zjpm' extension
1361+
.*Info: macro .*
1362+
.*Warning: invalid CSR `upm', needs `zjpm' extension
1363+
.*Info: macro .*
1364+
.*Warning: invalid CSR `hspm', needs `h' extension
1365+
.*Info: macro .*
1366+
.*Warning: invalid CSR `hspm', needs `zjpm' extension
1367+
.*Info: macro .*
1368+
.*Warning: invalid CSR `hspm', needs `h' extension
1369+
.*Info: macro .*
1370+
.*Warning: invalid CSR `hspm', needs `zjpm' extension
1371+
.*Info: macro .*

0 commit comments

Comments
 (0)