Skip to content

Commit 5483190

Browse files
authored
[RISCV] Add shlcofideleg extension (#141572)
This is for `shlcofideleg` extension, that supports delegating LCOFI interrupts to VS-mode. Spec: https://github.com/riscv/riscv-isa-manual/blob/main/src/hypervisor.adoc
1 parent 3f0a530 commit 5483190

File tree

9 files changed

+25
-0
lines changed

9 files changed

+25
-0
lines changed

clang/test/Driver/print-supported-extensions-riscv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119
// CHECK-NEXT: sha 1.0 'Sha' (Augmented Hypervisor)
120120
// CHECK-NEXT: shcounterenw 1.0 'Shcounterenw' (Support writeable hcounteren enable bit for any hpmcounter that is not read-only zero)
121121
// CHECK-NEXT: shgatpa 1.0 'Shgatpa' (SvNNx4 mode supported for all modes supported by satp, as well as Bare)
122+
// CHECK-NEXT: shlcofideleg 1.0 'Shlcofideleg' (Delegating LCOFI Interrupts to VS-mode)
122123
// CHECK-NEXT: shtvala 1.0 'Shtvala' (htval provides all needed values)
123124
// CHECK-NEXT: shvsatpa 1.0 'Shvsatpa' (vsatp supports all modes supported by satp)
124125
// CHECK-NEXT: shvstvala 1.0 'Shvstvala' (vstval provides all needed values)

clang/test/Preprocessor/riscv-target-features.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
// CHECK-NOT: __riscv_sha {{.*$}}
2525
// CHECK-NOT: __riscv_shcounterenw {{.*$}}
2626
// CHECK-NOT: __riscv_shgatpa {{.*$}}
27+
// CHECK-NOT: __riscv_shlcofideleg {{.*$}}
2728
// CHECK-NOT: __riscv_shtvala {{.*$}}
2829
// CHECK-NOT: __riscv_shvsatpa {{.*$}}
2930
// CHECK-NOT: __riscv_shvstvala {{.*$}}
@@ -370,6 +371,14 @@
370371
// RUN: -o - | FileCheck --check-prefix=CHECK-SHGATPA-EXT %s
371372
// CHECK-SHGATPA-EXT: __riscv_shgatpa 1000000{{$}}
372373

374+
// RUN: %clang --target=riscv32-unknown-linux-gnu \
375+
// RUN: -march=rv32ishlcofideleg -E -dM %s \
376+
// RUN: -o - | FileCheck --check-prefix=CHECK-SHLCOFIDELEG-EXT %s
377+
// RUN: %clang --target=riscv64-unknown-linux-gnu \
378+
// RUN: -march=rv64ishlcofideleg -E -dM %s \
379+
// RUN: -o - | FileCheck --check-prefix=CHECK-SHLCOFIDELEG-EXT %s
380+
// CHECK-SHLCOFIDELEG-EXT: __riscv_shlcofideleg 1000000{{$}}
381+
373382
// RUN: %clang --target=riscv32-unknown-linux-gnu \
374383
// RUN: -march=rv32ishtvala -E -dM %s \
375384
// RUN: -o - | FileCheck --check-prefix=CHECK-SHTVALA-EXT %s

llvm/docs/RISCVUsage.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ on support follow.
123123
``Sha`` Supported
124124
``Shcounterenw`` Assembly Support (`See note <#riscv-profiles-extensions-note>`__)
125125
``Shgatpa`` Assembly Support (`See note <#riscv-profiles-extensions-note>`__)
126+
``Shlcofideleg`` Supported
126127
``Shtvala`` Assembly Support (`See note <#riscv-profiles-extensions-note>`__)
127128
``Shvsatpa`` Assembly Support (`See note <#riscv-profiles-extensions-note>`__)
128129
``Shvstvala`` Assembly Support (`See note <#riscv-profiles-extensions-note>`__)

llvm/docs/ReleaseNotes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ Changes to the RISC-V Backend
201201
* Adds experimental assembler support for the SiFive Xsfmm* Attached Matrix
202202
Extensions.
203203
* `-mcpu=andes-a25` and `-mcpu=andes-ax25` were added.
204+
* The `Shlcofideleg` extension was added.
204205

205206
Changes to the WebAssembly Backend
206207
----------------------------------

llvm/lib/Target/RISCV/RISCVFeatures.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,10 @@ def FeatureStdExtShvsatpa
906906
: RISCVExtension<1, 0,
907907
"vsatp supports all modes supported by satp">;
908908

909+
def FeatureStdExtShlcofideleg
910+
: RISCVExtension<1, 0,
911+
"Delegating LCOFI Interrupts to VS-mode">;
912+
909913
def FeatureStdExtSmaia
910914
: RISCVExtension<1, 0,
911915
"Advanced Interrupt Architecture Machine Level">;

llvm/test/CodeGen/RISCV/attributes.ll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
; RUN: llc -mtriple=riscv32 -mattr=+shcounterenw %s -o - | FileCheck --check-prefixes=CHECK,RV32SHCOUNTERENW %s
4848
; RUN: llc -mtriple=riscv32 -mattr=+shgatpa %s -o - | FileCheck --check-prefixes=CHECK,RV32SHGATPA %s
4949
; RUN: llc -mtriple=riscv32 -mattr=+shvsatpa %s -o - | FileCheck --check-prefixes=CHECK,RV32SHVSATPA %s
50+
; RUN: llc -mtriple=riscv32 -mattr=+shlcofideleg %s -o - | FileCheck --check-prefixes=CHECK,RV32SHLCOFIDELEG %s
5051
; RUN: llc -mtriple=riscv32 -mattr=+ssccfg %s -o - | FileCheck --check-prefixes=CHECK,RV32SSCCFG %s
5152
; RUN: llc -mtriple=riscv32 -mattr=+ssccptr %s -o - | FileCheck --check-prefixes=CHECK,RV32SSCCPTR %s
5253
; RUN: llc -mtriple=riscv32 -mattr=+sscofpmf %s -o - | FileCheck --check-prefixes=CHECK,RV32SSCOFPMF %s
@@ -222,6 +223,7 @@
222223
; RUN: llc -mtriple=riscv64 -mattr=+shcounterenw %s -o - | FileCheck --check-prefixes=CHECK,RV64SHCOUNTERENW %s
223224
; RUN: llc -mtriple=riscv64 -mattr=+shgatpa %s -o - | FileCheck --check-prefixes=CHECK,RV64SHGATPA %s
224225
; RUN: llc -mtriple=riscv64 -mattr=+shvsatpa %s -o - | FileCheck --check-prefixes=CHECK,RV64SHVSATPA %s
226+
; RUN: llc -mtriple=riscv64 -mattr=+shlcofideleg %s -o - | FileCheck --check-prefixes=CHECK,RV64SHLCOFIDELEG %s
225227
; RUN: llc -mtriple=riscv64 -mattr=+ssccfg %s -o - | FileCheck --check-prefixes=CHECK,RV64SSCCFG %s
226228
; RUN: llc -mtriple=riscv64 -mattr=+ssccptr %s -o - | FileCheck --check-prefixes=CHECK,RV64SSCCPTR %s
227229
; RUN: llc -mtriple=riscv64 -mattr=+sscofpmf %s -o - | FileCheck --check-prefixes=CHECK,RV64SSCOFPMF %s
@@ -396,6 +398,7 @@
396398
; RV32SHCOUNTERENW: .attribute 5, "rv32i2p1_shcounterenw1p0"
397399
; RV32SHGATPA: .attribute 5, "rv32i2p1_shgatpa1p0"
398400
; RV32SHVSATPA: .attribute 5, "rv32i2p1_shvsatpa1p0"
401+
; RV32SHLCOFIDELEG: .attribute 5, "rv32i2p1_shlcofideleg1p0"
399402
; RV32SSCCFG: .attribute 5, "rv32i2p1_ssccfg1p0"
400403
; RV32SSCCPTR: .attribute 5, "rv32i2p1_ssccptr1p0"
401404
; RV32SSCOFPMF: .attribute 5, "rv32i2p1_sscofpmf1p0"
@@ -572,6 +575,7 @@
572575
; RV64SHCOUNTERENW: .attribute 5, "rv64i2p1_shcounterenw1p0"
573576
; RV64SHGATPA: .attribute 5, "rv64i2p1_shgatpa1p0"
574577
; RV64SHVSATPA: .attribute 5, "rv64i2p1_shvsatpa1p0"
578+
; RV64SHLCOFIDELEG: .attribute 5, "rv64i2p1_shlcofideleg1p0"
575579
; RV64SSCCFG: .attribute 5, "rv64i2p1_ssccfg1p0"
576580
; RV64SSCCPTR: .attribute 5, "rv64i2p1_ssccptr1p0"
577581
; RV64SSCOFPMF: .attribute 5, "rv64i2p1_sscofpmf1p0"

llvm/test/CodeGen/RISCV/features-info.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124
; CHECK-NEXT: shcounterenw - 'Shcounterenw' (Support writeable hcounteren enable bit for any hpmcounter that is not read-only zero).
125125
; CHECK-NEXT: shgatpa - 'Shgatpa' (SvNNx4 mode supported for all modes supported by satp, as well as Bare).
126126
; CHECK-NEXT: shifted-zextw-fusion - Enable SLLI+SRLI to be fused when computing (shifted) word zero extension.
127+
; CHECK-NEXT: shlcofideleg - 'Shlcofideleg' (Delegating LCOFI Interrupts to VS-mode).
127128
; CHECK-NEXT: short-forward-branch-opt - Enable short forward branch optimization.
128129
; CHECK-NEXT: shtvala - 'Shtvala' (htval provides all needed values).
129130
; CHECK-NEXT: shvsatpa - 'Shvsatpa' (vsatp supports all modes supported by satp).

llvm/test/MC/RISCV/attribute-arch.s

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,9 @@
309309
.attribute arch, "rv32i_shvsatpa1p0"
310310
# CHECK: attribute 5, "rv32i2p1_shvsatpa1p0"
311311

312+
.attribute arch, "rv32i_shlcofideleg1p0"
313+
# CHECK: attribute 5, "rv32i2p1_shlcofideleg1p0"
314+
312315
.attribute arch, "rv32i_shtvala1p0"
313316
# CHECK: attribute 5, "rv32i2p1_shtvala1p0"
314317

llvm/unittests/TargetParser/RISCVISAInfoTest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,7 @@ R"(All available -march extensions for RISC-V
10901090
sha 1.0
10911091
shcounterenw 1.0
10921092
shgatpa 1.0
1093+
shlcofideleg 1.0
10931094
shtvala 1.0
10941095
shvsatpa 1.0
10951096
shvstvala 1.0

0 commit comments

Comments
 (0)