-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[RISCV] Fix Enum for Custom Vendor CSR encodings #125172
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
Conversation
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/pr-subscribers-backend-risc-v Author: Sudharsan Veeravalli (svs-quic) ChangesThe 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. Full diff: https://github.com/llvm/llvm-project/pull/125172.diff 1 Files Affected:
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";
}
|
|
There are no tests for this right now since there aren't any vendor CSRs in the codebase. I have pushed this in preparation for upstreaming the Qualcomm Xqci custom CSRs. |
topperc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/50/builds/9672 Here is the relevant piece of the build log for the reference |
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.