[llvm] 3b2f4f4 - [RISCV] Fix Enum for Custom Vendor CSR encodings (#125172)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 30 22:23:05 PST 2025
Author: Sudharsan Veeravalli
Date: 2025-01-31T11:53:02+05:30
New Revision: 3b2f4f4ab2d7a2008a3b0dcc46526429f7e29101
URL: https://github.com/llvm/llvm-project/commit/3b2f4f4ab2d7a2008a3b0dcc46526429f7e29101
DIFF: https://github.com/llvm/llvm-project/commit/3b2f4f4ab2d7a2008a3b0dcc46526429f7e29101.diff
LOG: [RISCV] Fix Enum for Custom Vendor CSR encodings (#125172)
The enum added in 1401703fe42003745e6937efa13078b462a9d706 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.
Added:
Modified:
llvm/lib/Target/RISCV/RISCVSystemOperands.td
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVSystemOperands.td b/llvm/lib/Target/RISCV/RISCVSystemOperands.td
index 4c86103db99d26..cabcb9eda06b19 100644
--- a/llvm/lib/Target/RISCV/RISCVSystemOperands.td
+++ b/llvm/lib/Target/RISCV/RISCVSystemOperands.td
@@ -19,6 +19,9 @@ include "llvm/TableGen/SearchableTable.td"
class SysReg<string name, bits<12> op> {
string Name = name;
+ // Custom vendor CSRs have a "<vendor>." prefix. Convert these to "<vendor>_"
+ // before passing it to the SysRegEncodings GenericEnum below.
+ string EnumName = !subst(".", "_", name);
bits<12> Encoding = op;
// FIXME: add these additional fields when needed.
// Privilege Access: Read and Write = 0, 1, 2; Read-Only = 3.
@@ -50,7 +53,7 @@ def SysRegsList : GenericTable {
def SysRegEncodings : GenericEnum {
let FilterClass = "SysReg";
- let NameField = "Name";
+ let NameField = "EnumName";
let ValueField = "Encoding";
}
More information about the llvm-commits
mailing list