Skip to content

Commit 7817045

Browse files
authored
[RISCV] Support [mh]edelegh CSRs (llvm#121634)
These RV32-only CSRs are defined in privileged spec v1.13.
1 parent f75126e commit 7817045

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed

llvm/lib/Target/RISCV/RISCVSystemOperands.td

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ def : SysReg<"hideleg", 0x603>;
157157
def : SysReg<"hie", 0x604>;
158158
def : SysReg<"hcounteren", 0x606>;
159159
def : SysReg<"hgeie", 0x607>;
160+
let isRV32Only = 1 in
161+
def : SysReg<"hedelegh", 0x612>;
160162

161163
//===----------------------------------------------------------------------===//
162164
// Hypervisor Trap Handling
@@ -233,8 +235,10 @@ def : SysReg<"mideleg", 0x303>;
233235
def : SysReg<"mie", 0x304>;
234236
def : SysReg<"mtvec", 0x305>;
235237
def : SysReg<"mcounteren", 0x306>;
236-
let isRV32Only = 1 in
238+
let isRV32Only = 1 in {
237239
def : SysReg<"mstatush", 0x310>;
240+
def : SysReg<"medelegh", 0x312>;
241+
} // isRV32Only
238242

239243
//===----------------------------------------------------------------------===//
240244
// Machine Trap Handling

llvm/test/MC/RISCV/rv32-hypervisor-csr-names.s

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,21 @@ csrrs t2, 0x214, zero
219219
csrrs t1, vsiph, zero
220220
# uimm12
221221
csrrs t2, 0x254, zero
222+
223+
##################################
224+
# Hypervisor Trap Setup
225+
##################################
226+
227+
# hedelegh
228+
# name
229+
# CHECK-INST: csrrs t1, hedelegh, zero
230+
# CHECK-ENC: encoding: [0x73,0x23,0x20,0x61]
231+
# CHECK-INST-ALIAS: csrr t1, hedelegh
232+
# uimm12
233+
# CHECK-INST: csrrs t2, hedelegh, zero
234+
# CHECK-ENC: encoding: [0xf3,0x23,0x20,0x61]
235+
# CHECK-INST-ALIAS: csrr t2, hedelegh
236+
# name
237+
csrrs t1, hedelegh, zero
238+
# uimm12
239+
csrrs t2, 0x612, zero

llvm/test/MC/RISCV/rv32-machine-csr-names.s

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,20 @@ csrrs t1, mstatush, zero
2222
# uimm12
2323
csrrs t2, 0x310, zero
2424

25+
# medelegh
26+
# name
27+
# CHECK-INST: csrrs t1, medelegh, zero
28+
# CHECK-ENC: encoding: [0x73,0x23,0x20,0x31]
29+
# CHECK-INST-ALIAS: csrr t1, medelegh
30+
# uimm12
31+
# CHECK-INST: csrrs t2, medelegh, zero
32+
# CHECK-ENC: encoding: [0xf3,0x23,0x20,0x31]
33+
# CHECK-INST-ALIAS: csrr t2, medelegh
34+
# name
35+
csrrs t1, medelegh, zero
36+
# uimm12
37+
csrrs t2, 0x312, zero
38+
2539
#########################
2640
# Machine Configuration
2741
#########################

llvm/test/MC/RISCV/rv32-only-csr-names.s

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,16 @@ csrrs t1, henvcfgh, zero # CHECK-NEED-RV32: :[[@LINE]]:11: error: system registe
4141

4242
csrrs t1, htimedeltah, zero # CHECK-NEED-RV32: :[[@LINE]]:11: error: system register 'htimedeltah' is RV32 only
4343

44+
csrrs t1, hedelegh, zero # CHECK-NEED-RV32: :[[@LINE]]:11: error: system register 'hedelegh' is RV32 only
45+
4446
csrrs t1, mstatush, zero # CHECK-NEED-RV32: :[[@LINE]]:11: error: system register 'mstatush' is RV32 only
4547

4648
csrrs t1, menvcfgh, zero # CHECK-NEED-RV32: :[[@LINE]]:11: error: system register 'menvcfgh' is RV32 only
4749

4850
csrrs t1, mseccfgh, zero # CHECK-NEED-RV32: :[[@LINE]]:11: error: system register 'mseccfgh' is RV32 only
4951

52+
csrrs t1, medelegh, zero # CHECK-NEED-RV32: :[[@LINE]]:11: error: system register 'medelegh' is RV32 only
53+
5054
csrrs t1, pmpcfg1, zero # CHECK-NEED-RV32: :[[@LINE]]:11: error: system register 'pmpcfg1' is RV32 only
5155
csrrs t1, pmpcfg3, zero # CHECK-NEED-RV32: :[[@LINE]]:11: error: system register 'pmpcfg3' is RV32 only
5256
csrrs t1, pmpcfg5, zero # CHECK-NEED-RV32: :[[@LINE]]:11: error: system register 'pmpcfg5' is RV32 only

0 commit comments

Comments
 (0)