Skip to content

Commit 3b2f4f4

Browse files
authored
[RISCV] Fix Enum for Custom Vendor CSR encodings (#125172)
The enum added in 1401703 does not work for custom vendor CSRs due to the presence of a "." in the `<vendor>.<csr>` naming scheme required by the toolchain convention. Fix this by adding a new EnumName to the SysReg class which replaces the "." with and "_" before passing it to tablegen.
1 parent a5a2e2f commit 3b2f4f4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

llvm/lib/Target/RISCV/RISCVSystemOperands.td

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ include "llvm/TableGen/SearchableTable.td"
1919

2020
class SysReg<string name, bits<12> op> {
2121
string Name = name;
22+
// Custom vendor CSRs have a "<vendor>." prefix. Convert these to "<vendor>_"
23+
// before passing it to the SysRegEncodings GenericEnum below.
24+
string EnumName = !subst(".", "_", name);
2225
bits<12> Encoding = op;
2326
// FIXME: add these additional fields when needed.
2427
// Privilege Access: Read and Write = 0, 1, 2; Read-Only = 3.
@@ -50,7 +53,7 @@ def SysRegsList : GenericTable {
5053

5154
def SysRegEncodings : GenericEnum {
5255
let FilterClass = "SysReg";
53-
let NameField = "Name";
56+
let NameField = "EnumName";
5457
let ValueField = "Encoding";
5558
}
5659

0 commit comments

Comments
 (0)