[llvm] [RISCV] Fix Enum for Custom Vendor CSR encodings (PR #125172)
Sudharsan Veeravalli via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 30 21:38:34 PST 2025
https://github.com/svs-quic created https://github.com/llvm/llvm-project/pull/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.
>From f90761067fe1d05335eea7eec94e0f1720fc7197 Mon Sep 17 00:00:00 2001
From: Sudharsan Veeravalli <quic_svs at quicinc.com>
Date: Fri, 31 Jan 2025 10:55:19 +0530
Subject: [PATCH] [RISCV] Fix Enum for Custom Vendor CSR encodings
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.
---
llvm/lib/Target/RISCV/RISCVSystemOperands.td | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
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