[llvm] [RISCV] Fix Enum for Custom Vendor CSR encodings (PR #125172)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 30 21:40:02 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-risc-v
Author: Sudharsan Veeravalli (svs-quic)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/125172.diff
1 Files Affected:
- (modified) llvm/lib/Target/RISCV/RISCVSystemOperands.td (+4-1)
``````````diff
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";
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/125172
More information about the llvm-commits
mailing list