Skip to content

Commit 4a7dbed

Browse files
authored
[RISCV] Support svukte extension (#115657)
This is the extension for "Address-Independent Latency of User-Mode Faults to Supervisor Addresses". Spec: riscv/riscv-isa-manual#1564, https://lf-riscv.atlassian.net/browse/RVS-2977 The spec states that the `svukte` depends on `sv39`, but we don't have `sv39` yet, so I didn't add it to the implied list.
1 parent 74449ab commit 4a7dbed

File tree

7 files changed

+24
-0
lines changed

7 files changed

+24
-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
@@ -187,6 +187,7 @@
187187
// CHECK-NEXT: zvkgs 0.7 'Zvkgs' (Vector-Scalar GCM instructions for Cryptography)
188188
// CHECK-NEXT: smctr 1.0 'Smctr' (Control Transfer Records Machine Level)
189189
// CHECK-NEXT: ssctr 1.0 'Ssctr' (Control Transfer Records Supervisor Level)
190+
// CHECK-NEXT: svukte 0.3 'Svukte' (Address-Independent Latency of User-Mode Faults to Supervisor Addresses)
190191
// CHECK-EMPTY:
191192
// CHECK-NEXT: Supported Profiles
192193
// CHECK-NEXT: rva20s64

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1811,6 +1811,14 @@
18111811
// RUN: -o - | FileCheck --check-prefix=CHECK-SSCTR-EXT %s
18121812
// CHECK-SSCTR-EXT: __riscv_ssctr 1000000{{$}}
18131813

1814+
// RUN: %clang --target=riscv32 -menable-experimental-extensions \
1815+
// RUN: -march=rv32i_svukte0p3 -E -dM %s \
1816+
// RUN: -o - | FileCheck --check-prefix=CHECK-SVUKTE-EXT %s
1817+
// RUN: %clang --target=riscv64 -menable-experimental-extensions \
1818+
// RUN: -march=rv64i_svukte0p3 -E -dM %s \
1819+
// RUN: -o - | FileCheck --check-prefix=CHECK-SVUKTE-EXT %s
1820+
// CHECK-SVUKTE-EXT: __riscv_svukte 3000{{$}}
1821+
18141822
// Misaligned
18151823

18161824
// RUN: %clang --target=riscv32-unknown-linux-gnu -march=rv32i -E -dM %s \

llvm/docs/RISCVUsage.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,9 @@ The primary goal of experimental support is to assist in the process of ratifica
329329
``experimental-smctr``, ``experimental-ssctr``
330330
LLVM implements the `1.0-rc3 specification <https://github.com/riscv/riscv-control-transfer-records/releases/tag/v1.0_rc3>`__.
331331

332+
``experimental-svukte``
333+
LLVM implements the `0.3 draft specification <https://github.com/riscv/riscv-isa-manual/pull/1564>`__.
334+
332335
To use an experimental extension from `clang`, you must add `-menable-experimental-extensions` to the command line, and specify the exact version of the experimental extension you are using. To use an experimental extension with LLVM's internal developer tools (e.g. `llc`, `llvm-objdump`, `llvm-mc`), you must prefix the extension name with `experimental-`. Note that you don't need to specify the version with internal tools, and shouldn't include the `experimental-` prefix with `clang`.
333336

334337
Vendor Extensions

llvm/lib/Target/RISCV/RISCVFeatures.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,10 @@ def FeatureStdExtSha
10591059
FeatureStdExtShvstvala, FeatureStdExtShtvala, FeatureStdExtShvstvecd,
10601060
FeatureStdExtShvsatpa, FeatureStdExtShgatpa]>;
10611061

1062+
def FeatureStdExtSvukte
1063+
: RISCVExperimentalExtension<"svukte", 0, 3,
1064+
"'Svukte' (Address-Independent Latency of User-Mode Faults to Supervisor Addresses)">;
1065+
10621066
// Pointer Masking extensions
10631067

10641068
// A supervisor-level extension that provides pointer masking for the next lower

llvm/test/CodeGen/RISCV/attributes.ll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
; RUN: llc -mtriple=riscv32 -mattr=+svbare %s -o - | FileCheck --check-prefixes=CHECK,RV32SVBARE %s
6363
; RUN: llc -mtriple=riscv32 -mattr=+svnapot %s -o - | FileCheck --check-prefixes=CHECK,RV32SVNAPOT %s
6464
; RUN: llc -mtriple=riscv32 -mattr=+svpbmt %s -o - | FileCheck --check-prefixes=CHECK,RV32SVPBMT %s
65+
; RUN: llc -mtriple=riscv32 -mattr=+experimental-svukte %s -o - | FileCheck --check-prefixes=CHECK,RV32SVUKTE %s
6566
; RUN: llc -mtriple=riscv32 -mattr=+svvptc %s -o - | FileCheck --check-prefixes=CHECK,RV32SVVPTC %s
6667
; RUN: llc -mtriple=riscv32 -mattr=+svinval %s -o - | FileCheck --check-prefixes=CHECK,RV32SVINVAL %s
6768
; RUN: llc -mtriple=riscv32 -mattr=+xcvalu %s -o - | FileCheck --check-prefix=RV32XCVALU %s
@@ -205,6 +206,7 @@
205206
; RUN: llc -mtriple=riscv64 -mattr=+svbare %s -o - | FileCheck --check-prefixes=CHECK,RV64SVBARE %s
206207
; RUN: llc -mtriple=riscv64 -mattr=+svnapot %s -o - | FileCheck --check-prefixes=CHECK,RV64SVNAPOT %s
207208
; RUN: llc -mtriple=riscv64 -mattr=+svpbmt %s -o - | FileCheck --check-prefixes=CHECK,RV64SVPBMT %s
209+
; RUN: llc -mtriple=riscv64 -mattr=+experimental-svukte %s -o - | FileCheck --check-prefixes=CHECK,RV64SVUKTE %s
208210
; RUN: llc -mtriple=riscv64 -mattr=+svvptc %s -o - | FileCheck --check-prefixes=CHECK,RV64SVVPTC %s
209211
; RUN: llc -mtriple=riscv64 -mattr=+svinval %s -o - | FileCheck --check-prefixes=CHECK,RV64SVINVAL %s
210212
; RUN: llc -mtriple=riscv64 -mattr=+xventanacondops %s -o - | FileCheck --check-prefixes=CHECK,RV64XVENTANACONDOPS %s
@@ -364,6 +366,7 @@
364366
; RV32SVBARE: .attribute 5, "rv32i2p1_svbare1p0"
365367
; RV32SVNAPOT: .attribute 5, "rv32i2p1_svnapot1p0"
366368
; RV32SVPBMT: .attribute 5, "rv32i2p1_svpbmt1p0"
369+
; RV32SVUKTE: .attribute 5, "rv32i2p1_svukte0p3"
367370
; RV32SVVPTC: .attribute 5, "rv32i2p1_svvptc1p0"
368371
; RV32SVINVAL: .attribute 5, "rv32i2p1_svinval1p0"
369372
; RV32XCVALU: .attribute 5, "rv32i2p1_xcvalu1p0"
@@ -509,6 +512,7 @@
509512
; RV64SVBARE: .attribute 5, "rv64i2p1_svbare1p0"
510513
; RV64SVNAPOT: .attribute 5, "rv64i2p1_svnapot1p0"
511514
; RV64SVPBMT: .attribute 5, "rv64i2p1_svpbmt1p0"
515+
; RV64SVUKTE: .attribute 5, "rv64i2p1_svukte0p3"
512516
; RV64SVVPTC: .attribute 5, "rv64i2p1_svvptc1p0"
513517
; RV64SVINVAL: .attribute 5, "rv64i2p1_svinval1p0"
514518
; RV64XVENTANACONDOPS: .attribute 5, "rv64i2p1_xventanacondops1p0"

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,9 @@
381381
.attribute arch, "rv32i_svbare1p0"
382382
# CHECK: attribute 5, "rv32i2p1_svbare1p0"
383383

384+
.attribute arch, "rv32i_svukte0p3"
385+
# CHECK: attribute 5, "rv32i2p1_svukte0p3"
386+
384387
.attribute arch, "rv32i_svvptc1p0"
385388
# CHECK: attribute 5, "rv32i2p1_svvptc1p0"
386389

llvm/unittests/TargetParser/RISCVISAInfoTest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,7 @@ Experimental extensions
11031103
zvkgs 0.7
11041104
smctr 1.0
11051105
ssctr 1.0
1106+
svukte 0.3
11061107
11071108
Supported Profiles
11081109
rva20s64

0 commit comments

Comments
 (0)