Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RISC-V: Fix CSR accessibility and implications #44

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions bfd/elfxx-riscv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,7 @@ static struct riscv_implicit_subset riscv_implicit_subsets[] =
{"g", "d", check_implicit_always},
{"g", "zicsr", check_implicit_always},
{"g", "zifencei", check_implicit_always},
{"h", "zicsr", check_implicit_always},
{"q", "d", check_implicit_always},
{"v", "d", check_implicit_always},
{"v", "zve64d", check_implicit_always},
Expand All @@ -1062,6 +1063,7 @@ static struct riscv_implicit_subset riscv_implicit_subsets[] =
{"zve64x", "zve32x", check_implicit_always},
{"zve64x", "zvl64b", check_implicit_always},
{"zve32x", "zvl32b", check_implicit_always},
{"zve32x", "zicsr", check_implicit_always},
{"zvl65536b", "zvl32768b", check_implicit_always},
{"zvl32768b", "zvl16384b", check_implicit_always},
{"zvl16384b", "zvl8192b", check_implicit_always},
Expand Down Expand Up @@ -1091,11 +1093,15 @@ static struct riscv_implicit_subset riscv_implicit_subsets[] =
{"zkn", "zkne", check_implicit_always},
{"zkn", "zknd", check_implicit_always},
{"zkn", "zknh", check_implicit_always},
{"zkr", "zicsr", check_implicit_always},
{"zks", "zbkb", check_implicit_always},
{"zks", "zbkc", check_implicit_always},
{"zks", "zbkx", check_implicit_always},
{"zks", "zksed", check_implicit_always},
{"zks", "zksh", check_implicit_always},
{"smstateen", "zicsr", check_implicit_always},
{"sscofpmf", "zicsr", check_implicit_always},
{"sstc", "zicsr", check_implicit_always},
{NULL, NULL, NULL}
};

Expand Down
6 changes: 6 additions & 0 deletions gas/testsuite/gas/riscv/march-imply-h.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#as: -march=rv32ih -march-attr -misa-spec=20191213 -mpriv-spec=1.12
#readelf: -A
#source: empty.s
Attribute Section: riscv
File Attributes
Tag_RISCV_arch: "rv32i2p1_h1p0_zicsr2p0"
21 changes: 21 additions & 0 deletions gas/testsuite/gas/riscv/vector-csrs-zve32f.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#as: -march=rv32i_zve32f -mcsr-check
#source: vector-csrs.s
#objdump: -d

.*:[ ]+file format .*


Disassembly of section .text:

0+000 <target>:
[ ]+[0-9a-f]+:[ ]+00802573[ ]+csrr[ ]+a0,vstart
[ ]+[0-9a-f]+:[ ]+00801073[ ]+csrw[ ]+vstart,zero
[ ]+[0-9a-f]+:[ ]+00902573[ ]+csrr[ ]+a0,vxsat
[ ]+[0-9a-f]+:[ ]+0090d073[ ]+csrwi[ ]+vxsat,1
[ ]+[0-9a-f]+:[ ]+00a02573[ ]+csrr[ ]+a0,vxrm
[ ]+[0-9a-f]+:[ ]+00a1d073[ ]+csrwi[ ]+vxrm,3
[ ]+[0-9a-f]+:[ ]+00f02573[ ]+csrr[ ]+a0,vcsr
[ ]+[0-9a-f]+:[ ]+00f3d073[ ]+csrwi[ ]+vcsr,7
[ ]+[0-9a-f]+:[ ]+c2002573[ ]+csrr[ ]+a0,vl
[ ]+[0-9a-f]+:[ ]+c2102573[ ]+csrr[ ]+a0,vtype
[ ]+[0-9a-f]+:[ ]+c2202573[ ]+csrr[ ]+a0,vlenb
21 changes: 21 additions & 0 deletions gas/testsuite/gas/riscv/vector-csrs-zve32x.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#as: -march=rv32i_zve32x -mcsr-check
#source: vector-csrs.s
#objdump: -d

.*:[ ]+file format .*


Disassembly of section .text:

0+000 <target>:
[ ]+[0-9a-f]+:[ ]+00802573[ ]+csrr[ ]+a0,vstart
[ ]+[0-9a-f]+:[ ]+00801073[ ]+csrw[ ]+vstart,zero
[ ]+[0-9a-f]+:[ ]+00902573[ ]+csrr[ ]+a0,vxsat
[ ]+[0-9a-f]+:[ ]+0090d073[ ]+csrwi[ ]+vxsat,1
[ ]+[0-9a-f]+:[ ]+00a02573[ ]+csrr[ ]+a0,vxrm
[ ]+[0-9a-f]+:[ ]+00a1d073[ ]+csrwi[ ]+vxrm,3
[ ]+[0-9a-f]+:[ ]+00f02573[ ]+csrr[ ]+a0,vcsr
[ ]+[0-9a-f]+:[ ]+00f3d073[ ]+csrwi[ ]+vcsr,7
[ ]+[0-9a-f]+:[ ]+c2002573[ ]+csrr[ ]+a0,vl
[ ]+[0-9a-f]+:[ ]+c2102573[ ]+csrr[ ]+a0,vtype
[ ]+[0-9a-f]+:[ ]+c2202573[ ]+csrr[ ]+a0,vlenb
21 changes: 21 additions & 0 deletions gas/testsuite/gas/riscv/vector-csrs-zve64d.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#as: -march=rv32i_zve64d -mcsr-check
#source: vector-csrs.s
#objdump: -d

.*:[ ]+file format .*


Disassembly of section .text:

0+000 <target>:
[ ]+[0-9a-f]+:[ ]+00802573[ ]+csrr[ ]+a0,vstart
[ ]+[0-9a-f]+:[ ]+00801073[ ]+csrw[ ]+vstart,zero
[ ]+[0-9a-f]+:[ ]+00902573[ ]+csrr[ ]+a0,vxsat
[ ]+[0-9a-f]+:[ ]+0090d073[ ]+csrwi[ ]+vxsat,1
[ ]+[0-9a-f]+:[ ]+00a02573[ ]+csrr[ ]+a0,vxrm
[ ]+[0-9a-f]+:[ ]+00a1d073[ ]+csrwi[ ]+vxrm,3
[ ]+[0-9a-f]+:[ ]+00f02573[ ]+csrr[ ]+a0,vcsr
[ ]+[0-9a-f]+:[ ]+00f3d073[ ]+csrwi[ ]+vcsr,7
[ ]+[0-9a-f]+:[ ]+c2002573[ ]+csrr[ ]+a0,vl
[ ]+[0-9a-f]+:[ ]+c2102573[ ]+csrr[ ]+a0,vtype
[ ]+[0-9a-f]+:[ ]+c2202573[ ]+csrr[ ]+a0,vlenb
21 changes: 21 additions & 0 deletions gas/testsuite/gas/riscv/vector-csrs-zve64f.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#as: -march=rv32i_zve64f -mcsr-check
#source: vector-csrs.s
#objdump: -d

.*:[ ]+file format .*


Disassembly of section .text:

0+000 <target>:
[ ]+[0-9a-f]+:[ ]+00802573[ ]+csrr[ ]+a0,vstart
[ ]+[0-9a-f]+:[ ]+00801073[ ]+csrw[ ]+vstart,zero
[ ]+[0-9a-f]+:[ ]+00902573[ ]+csrr[ ]+a0,vxsat
[ ]+[0-9a-f]+:[ ]+0090d073[ ]+csrwi[ ]+vxsat,1
[ ]+[0-9a-f]+:[ ]+00a02573[ ]+csrr[ ]+a0,vxrm
[ ]+[0-9a-f]+:[ ]+00a1d073[ ]+csrwi[ ]+vxrm,3
[ ]+[0-9a-f]+:[ ]+00f02573[ ]+csrr[ ]+a0,vcsr
[ ]+[0-9a-f]+:[ ]+00f3d073[ ]+csrwi[ ]+vcsr,7
[ ]+[0-9a-f]+:[ ]+c2002573[ ]+csrr[ ]+a0,vl
[ ]+[0-9a-f]+:[ ]+c2102573[ ]+csrr[ ]+a0,vtype
[ ]+[0-9a-f]+:[ ]+c2202573[ ]+csrr[ ]+a0,vlenb
21 changes: 21 additions & 0 deletions gas/testsuite/gas/riscv/vector-csrs-zve64x.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#as: -march=rv32i_zve64x -mcsr-check
#source: vector-csrs.s
#objdump: -d

.*:[ ]+file format .*


Disassembly of section .text:

0+000 <target>:
[ ]+[0-9a-f]+:[ ]+00802573[ ]+csrr[ ]+a0,vstart
[ ]+[0-9a-f]+:[ ]+00801073[ ]+csrw[ ]+vstart,zero
[ ]+[0-9a-f]+:[ ]+00902573[ ]+csrr[ ]+a0,vxsat
[ ]+[0-9a-f]+:[ ]+0090d073[ ]+csrwi[ ]+vxsat,1
[ ]+[0-9a-f]+:[ ]+00a02573[ ]+csrr[ ]+a0,vxrm
[ ]+[0-9a-f]+:[ ]+00a1d073[ ]+csrwi[ ]+vxrm,3
[ ]+[0-9a-f]+:[ ]+00f02573[ ]+csrr[ ]+a0,vcsr
[ ]+[0-9a-f]+:[ ]+00f3d073[ ]+csrwi[ ]+vcsr,7
[ ]+[0-9a-f]+:[ ]+c2002573[ ]+csrr[ ]+a0,vl
[ ]+[0-9a-f]+:[ ]+c2102573[ ]+csrr[ ]+a0,vtype
[ ]+[0-9a-f]+:[ ]+c2202573[ ]+csrr[ ]+a0,vlenb
20 changes: 20 additions & 0 deletions gas/testsuite/gas/riscv/vector-csrs.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#as: -march=rv32iv -mcsr-check
#objdump: -d

.*:[ ]+file format .*


Disassembly of section .text:

0+000 <target>:
[ ]+[0-9a-f]+:[ ]+00802573[ ]+csrr[ ]+a0,vstart
[ ]+[0-9a-f]+:[ ]+00801073[ ]+csrw[ ]+vstart,zero
[ ]+[0-9a-f]+:[ ]+00902573[ ]+csrr[ ]+a0,vxsat
[ ]+[0-9a-f]+:[ ]+0090d073[ ]+csrwi[ ]+vxsat,1
[ ]+[0-9a-f]+:[ ]+00a02573[ ]+csrr[ ]+a0,vxrm
[ ]+[0-9a-f]+:[ ]+00a1d073[ ]+csrwi[ ]+vxrm,3
[ ]+[0-9a-f]+:[ ]+00f02573[ ]+csrr[ ]+a0,vcsr
[ ]+[0-9a-f]+:[ ]+00f3d073[ ]+csrwi[ ]+vcsr,7
[ ]+[0-9a-f]+:[ ]+c2002573[ ]+csrr[ ]+a0,vl
[ ]+[0-9a-f]+:[ ]+c2102573[ ]+csrr[ ]+a0,vtype
[ ]+[0-9a-f]+:[ ]+c2202573[ ]+csrr[ ]+a0,vlenb
12 changes: 12 additions & 0 deletions gas/testsuite/gas/riscv/vector-csrs.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
target:
csrr a0, vstart
csrw vstart, zero
csrr a0, vxsat
csrwi vxsat, 1
csrr a0, vxrm
csrwi vxrm, 3
csrr a0, vcsr
csrwi vcsr, 7
csrr a0, vl
csrr a0, vtype
csrr a0, vlenb
10 changes: 10 additions & 0 deletions gas/testsuite/gas/riscv/zkr.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#as: -march=rv32i_zkr -mcsr-check
#objdump: -d

.*:[ ]+file format .*


Disassembly of section .text:

0+000 <target>:
[ ]+[0-9a-f]+:[ ]+01502573[ ]+csrr[ ]+a0,seed
2 changes: 2 additions & 0 deletions gas/testsuite/gas/riscv/zkr.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target:
csrr a0, seed