Skip to content
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

[RISCV] Add the CSR names from Smrnmi. #83370

Merged
merged 1 commit into from
Mar 20, 2024
Merged

[RISCV] Add the CSR names from Smrnmi. #83370

merged 1 commit into from
Mar 20, 2024

Conversation

topperc
Copy link
Collaborator

@topperc topperc commented Feb 29, 2024

Specification is here
https://github.com/riscv/riscv-isa-manual/blob/main/src/rnmi.adoc

CSRs numbers defined here
https://github.com/riscv/riscv-isa-manual/blob/main/src/priv-csrs.adoc

SiFive has hardware that implements this extension.

I'm not sure where it is in the ratifcation process. It doesn't look to have recent progress.

@llvmbot llvmbot added backend:RISC-V mc Machine (object) code labels Feb 29, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Feb 29, 2024

@llvm/pr-subscribers-backend-risc-v

@llvm/pr-subscribers-mc

Author: Craig Topper (topperc)

Changes

Specification is here
https://github.com/riscv/riscv-isa-manual/blob/main/src/rnmi.adoc

CSRs numbers defined here
https://github.com/riscv/riscv-isa-manual/blob/main/src/priv-csrs.adoc

SiFive has hardware that implements this extension.

I'm not sure where it is in the ratifcation process. It doesn't look to have recent progress.


Full diff: https://github.com/llvm/llvm-project/pull/83370.diff

3 Files Affected:

  • (modified) llvm/docs/ReleaseNotes.rst (+1)
  • (modified) llvm/lib/Target/RISCV/RISCVSystemOperands.td (+9)
  • (modified) llvm/test/MC/RISCV/rv32-machine-csr-names.s (+56)
diff --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index 51b6527f65bb04..d7f075f5c5b3dd 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -103,6 +103,7 @@ Changes to the RISC-V Backend
 * Codegen support was added for the Zimop (May-Be-Operations) extension.
 * The experimental Ssnpm, Smnpm, Smmpm, Sspm, and Supm 0.8.1 Pointer Masking extensions are supported.
 * The experimental Ssqosid extension is supported.
+* Added the CSR names from the draft specification of Resumable Non-Maskable Interrupts (Smrnmi).
 
 Changes to the WebAssembly Backend
 ----------------------------------
diff --git a/llvm/lib/Target/RISCV/RISCVSystemOperands.td b/llvm/lib/Target/RISCV/RISCVSystemOperands.td
index 79f977e5b32266..01c2767119502c 100644
--- a/llvm/lib/Target/RISCV/RISCVSystemOperands.td
+++ b/llvm/lib/Target/RISCV/RISCVSystemOperands.td
@@ -418,7 +418,16 @@ def : SysReg<"vsieh", 0x214>;
 def : SysReg<"vsiph", 0x254>;
 } // isRV32Only
 
+//===-----------------------------------------------
 // Jump Vector Table CSR
 //===-----------------------------------------------
 
 def : SysReg<"jvt", 0x017>;
+
+//===-----------------------------------------------
+// Resumable Non-Maskable Interrupts(Smrnmi) CSRs
+//===-----------------------------------------------
+def : SysReg<"mnscratch", 0x740>;
+def : SysReg<"mnepc", 0x741>;
+def : SysReg<"mncause", 0x742>;
+def : SysReg<"mnstatus", 0x744>;
diff --git a/llvm/test/MC/RISCV/rv32-machine-csr-names.s b/llvm/test/MC/RISCV/rv32-machine-csr-names.s
index e7a6d9ce718f2c..016f448d8dac63 100644
--- a/llvm/test/MC/RISCV/rv32-machine-csr-names.s
+++ b/llvm/test/MC/RISCV/rv32-machine-csr-names.s
@@ -1149,3 +1149,59 @@ csrrs t2, 0x319, zero
 csrrs t1, miph, zero
 # uimm12
 csrrs t2, 0x354, zero
+
+################################################
+# Resumable Non-Maskable Interrupts(Smrnmi) CSRs
+################################################
+
+# mnscratch
+# name
+# CHECK-INST: csrrs t1, mnscratch, zero
+# CHECK-ENC: encoding: [0x73,0x23,0x00,0x74]
+# CHECK-INST-ALIAS: csrr t1, mnscratch
+# uimm12
+# CHECK-INST: csrrs t2, mnscratch, zero
+# CHECK-ENC: encoding: [0xf3,0x23,0x00,0x74]
+# CHECK-INST-ALIAS: csrr t2, mnscratch
+csrrs t1, mnscratch, zero
+# uimm12
+csrrs t2, 0x740, zero
+
+# mnepc
+# name
+# CHECK-INST: csrrs t1, mnepc, zero
+# CHECK-ENC: encoding: [0x73,0x23,0x10,0x74]
+# CHECK-INST-ALIAS: csrr t1, mnepc
+# uimm12
+# CHECK-INST: csrrs t2, mnepc, zero
+# CHECK-ENC: encoding: [0xf3,0x23,0x10,0x74]
+# CHECK-INST-ALIAS: csrr t2, mnepc
+csrrs t1, mnepc, zero
+# uimm12
+csrrs t2, 0x741, zero
+
+# mncause
+# name
+# CHECK-INST: csrrs t1, mncause, zero
+# CHECK-ENC: encoding: [0x73,0x23,0x20,0x74]
+# CHECK-INST-ALIAS: csrr t1, mncause
+# uimm12
+# CHECK-INST: csrrs t2, mncause, zero
+# CHECK-ENC: encoding: [0xf3,0x23,0x20,0x74]
+# CHECK-INST-ALIAS: csrr t2, mncause
+csrrs t1, mncause, zero
+# uimm12
+csrrs t2, 0x742, zero
+
+# mnstatus
+# name
+# CHECK-INST: csrrs t1, mnstatus, zero
+# CHECK-ENC: encoding: [0x73,0x23,0x40,0x74]
+# CHECK-INST-ALIAS: csrr t1, mnstatus
+# uimm12
+# CHECK-INST: csrrs t2, mnstatus, zero
+# CHECK-ENC: encoding: [0xf3,0x23,0x40,0x74]
+# CHECK-INST-ALIAS: csrr t2, mnstatus
+csrrs t1, mnstatus, zero
+# uimm12
+csrrs t2, 0x744, zero

@topperc
Copy link
Collaborator Author

topperc commented Feb 29, 2024

CC @garvitgupta08

@quic-garvgupt
Copy link
Contributor

CC: @apazos @quic-garvgupt

@topperc
Copy link
Collaborator Author

topperc commented Mar 8, 2024

Ping

1 similar comment
@topperc
Copy link
Collaborator Author

topperc commented Mar 19, 2024

Ping

Copy link
Contributor

@wangpc-pp wangpc-pp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Smrnmi is frozen just now: riscv/riscv-isa-manual@a4382e9

Specification is here
https://github.com/riscv/riscv-isa-manual/blob/main/src/rnmi.adoc

CSRs numbers defined here
https://github.com/riscv/riscv-isa-manual/blob/main/src/priv-csrs.adoc

SiFive has hardware that implements this extension.

I'm not sure where it is in the ratifcation process. It doesn't
look to have recent progress.
@topperc topperc merged commit f375aff into llvm:main Mar 20, 2024
4 of 5 checks passed
@topperc topperc deleted the pr/rnmi branch March 20, 2024 04:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:RISC-V mc Machine (object) code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants