Skip to content

Commit 21d3c26

Browse files
committed
1 parent 27653bd commit 21d3c26

File tree

10 files changed

+78
-0
lines changed

10 files changed

+78
-0
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@
123123
// CHECK-NEXT: shvstvecd 1.0 'Shvstvecd' (vstvec supports Direct mode)
124124
// CHECK-NEXT: smaia 1.0 'Smaia' (Advanced Interrupt Architecture Machine Level)
125125
// CHECK-NEXT: smcdeleg 1.0 'Smcdeleg' (Counter Delegation Machine Level)
126+
// CHECK-NEXT: smcntrpmf 1.0 'Smcntrpmf' (Cycle and instret privilege mode mode filtering)
126127
// CHECK-NEXT: smcsrind 1.0 'Smcsrind' (Indirect CSR Access Machine Level)
127128
// CHECK-NEXT: smdbltrp 1.0 'Smdbltrp' (Double Trap Machine Level)
128129
// CHECK-NEXT: smepmp 1.0 'Smepmp' (Enhanced Physical Memory Protection)

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

+9
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
// CHECK-NOT: __riscv_shvstvecd {{.*$}}
3030
// CHECK-NOT: __riscv_smaia {{.*$}}
3131
// CHECK-NOT: __riscv_smcdeleg {{.*$}}
32+
// CHECK-NOT: __riscv_smcntrpmf {{.*$}}
3233
// CHECK-NOT: __riscv_smcsrind {{.*$}}
3334
// CHECK-NOT: __riscv_smdbltrp {{.*$}}
3435
// CHECK-NOT: __riscv_smepmp {{.*$}}
@@ -1453,6 +1454,14 @@
14531454
// RUN: -o - | FileCheck --check-prefix=CHECK-SMCSRIND-EXT %s
14541455
// CHECK-SMCSRIND-EXT: __riscv_smcsrind 1000000{{$}}
14551456

1457+
// RUN: %clang --target=riscv32 \
1458+
// RUN: -march=rv32ismcntrpmf1p0 -E -dM %s \
1459+
// RUN: -o - | FileCheck --check-prefix=CHECK-SMCNTRPMF-EXT %s
1460+
// RUN: %clang --target=riscv64 \
1461+
// RUN: -march=rv64ismcntrpmf1p0 -E -dM %s \
1462+
// RUN: -o - | FileCheck --check-prefix=CHECK-SMCNTRPMF-EXT %s
1463+
// CHECK-SMCNTRPMF-EXT: __riscv_smcntrpmf 1000000{{$}}
1464+
14561465
// RUN: %clang --target=riscv32 \
14571466
// RUN: -march=rv32isscsrind1p0 -E -dM %s \
14581467
// RUN: -o - | FileCheck --check-prefix=CHECK-SSCSRIND-EXT %s

llvm/docs/RISCVUsage.rst

+1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ on support follow.
128128
``Shvstvecd`` Assembly Support (`See note <#riscv-profiles-extensions-note>`__)
129129
``Smaia`` Supported
130130
``Smcdeleg`` Supported
131+
``Smcntrpmf`` Supported
131132
``Smcsrind`` Supported
132133
``Smdbltrp`` Supported
133134
``Smepmp`` Supported

llvm/lib/Target/RISCV/RISCVFeatures.td

+2
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ def FeatureStdExtZilsd
183183
def HasStdExtZilsd : Predicate<"Subtarget->hasStdExtZilsd()">,
184184
AssemblerPredicate<(all_of FeatureStdExtZilsd),
185185
"'Zilsd' (Load/Store pair instructions)">;
186+
def FeatureStdExtSmcntrpmf
187+
: RISCVExtension<1, 0, "Cycle and instret privilege mode mode filtering">;
186188

187189
// Multiply Extensions
188190

llvm/lib/Target/RISCV/RISCVSystemOperands.td

+8
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,14 @@ def : SysReg<"sctrdepth", 0x15f>;
482482
def : SysReg<"vsctrctl", 0x24e>;
483483
def : SysReg<"mctrctl", 0x34e>;
484484

485+
//===-----------------------------------------------
486+
// Cycle and Instret privilege mode filtering (Smcntrpmf)
487+
//===-----------------------------------------------
488+
def : SysReg<"mcyclecfg", 0x321>;
489+
def : SysReg<"minstretcfg", 0x322>;
490+
def : SysReg<"mcyclecfgh", 0x721>;
491+
def : SysReg<"minstretcfgh", 0x722>;
492+
485493
//===-----------------------------------------------
486494
// Vendor CSRs
487495
//===-----------------------------------------------

llvm/test/CodeGen/RISCV/attributes.ll

+4
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@
147147
; RUN: llc -mtriple=riscv32 -mattr=+ssdbltrp %s -o - | FileCheck --check-prefixes=CHECK,RV32SSDBLTRP %s
148148
; RUN: llc -mtriple=riscv32 -mattr=+ssqosid %s -o - | FileCheck --check-prefix=RV32SSQOSID %s
149149
; RUN: llc -mtriple=riscv32 -mattr=+smcdeleg %s -o - | FileCheck --check-prefixes=CHECK,RV32SMCDELEG %s
150+
; RUN: llc -mtriple=riscv32 -mattr=+smcntrpmf %s -o - | FileCheck --check-prefixes=CHECK,RV32SMCNTRPMF %s
150151
; RUN: llc -mtriple=riscv32 -mattr=+smepmp %s -o - | FileCheck --check-prefixes=CHECK,RV32SMEPMP %s
151152
; RUN: llc -mtriple=riscv32 -mattr=+smrnmi %s -o - | FileCheck --check-prefixes=CHECK,RV32SMRNMI %s
152153
; RUN: llc -mtriple=riscv32 -mattr=+zfbfmin %s -o - | FileCheck --check-prefixes=CHECK,RV32ZFBFMIN %s
@@ -301,6 +302,7 @@
301302
; RUN: llc -mtriple=riscv64 -mattr=+ssdbltrp %s -o - | FileCheck --check-prefixes=CHECK,RV64SSDBLTRP %s
302303
; RUN: llc -mtriple=riscv64 -mattr=+ssqosid %s -o - | FileCheck --check-prefix=RV64SSQOSID %s
303304
; RUN: llc -mtriple=riscv64 -mattr=+smcdeleg %s -o - | FileCheck --check-prefixes=CHECK,RV64SMCDELEG %s
305+
; RUN: llc -mtriple=riscv64 -mattr=+smcntrpmf %s -o - | FileCheck --check-prefixes=CHECK,RV64SMCNTRPMF %s
304306
; RUN: llc -mtriple=riscv64 -mattr=+smepmp %s -o - | FileCheck --check-prefixes=CHECK,RV64SMEPMP %s
305307
; RUN: llc -mtriple=riscv64 -mattr=+smrnmi %s -o - | FileCheck --check-prefixes=CHECK,RV64SMRNMI %s
306308
; RUN: llc -mtriple=riscv64 -mattr=+zfbfmin %s -o - | FileCheck --check-prefixes=CHECK,RV64ZFBFMIN %s
@@ -485,6 +487,7 @@
485487
; RV32SSDBLTRP: .attribute 5, "rv32i2p1_ssdbltrp1p0"
486488
; RV32SSQOSID: .attribute 5, "rv32i2p1_ssqosid1p0"
487489
; RV32SMCDELEG: .attribute 5, "rv32i2p1_smcdeleg1p0"
490+
; RV32SMCNTRPMF: .attribute 5, "rv32i2p1_smcntrpmf1p0"
488491
; RV32SMEPMP: .attribute 5, "rv32i2p1_smepmp1p0"
489492
; RV32SMRNMI: .attribute 5, "rv32i2p1_smrnmi1p0"
490493
; RV32ZFBFMIN: .attribute 5, "rv32i2p1_f2p2_zicsr2p0_zfbfmin1p0"
@@ -636,6 +639,7 @@
636639
; RV64SSDBLTRP: .attribute 5, "rv64i2p1_ssdbltrp1p0"
637640
; RV64SSQOSID: .attribute 5, "rv64i2p1_ssqosid1p0"
638641
; RV64SMCDELEG: .attribute 5, "rv64i2p1_smcdeleg1p0"
642+
; RV64SMCNTRPMF: .attribute 5, "rv64i2p1_smcntrpmf1p0"
639643
; RV64SMEPMP: .attribute 5, "rv64i2p1_smepmp1p0"
640644
; RV64SMRNMI: .attribute 5, "rv64i2p1_smrnmi1p0"
641645
; RV64ZFBFMIN: .attribute 5, "rv64i2p1_f2p2_zicsr2p0_zfbfmin1p0"

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

+1
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@
129129
; CHECK-NEXT: sifive7 - SiFive 7-Series processors.
130130
; CHECK-NEXT: smaia - 'Smaia' (Advanced Interrupt Architecture Machine Level).
131131
; CHECK-NEXT: smcdeleg - 'Smcdeleg' (Counter Delegation Machine Level).
132+
; CHECK-NEXT: smcntrpmf - 'Smcntrpmf' (Cycle and instret privilege mode mode filtering).
132133
; CHECK-NEXT: smcsrind - 'Smcsrind' (Indirect CSR Access Machine Level).
133134
; CHECK-NEXT: smdbltrp - 'Smdbltrp' (Double Trap Machine Level).
134135
; CHECK-NEXT: smepmp - 'Smepmp' (Enhanced Physical Memory Protection).

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

+3
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,9 @@
336336
.attribute arch, "rv32i_smcdeleg1p0"
337337
# CHECK: attribute 5, "rv32i2p1_smcdeleg1p0"
338338

339+
.attribute arch, "rv32i_smcntrpmf1p0"
340+
# CHECK: attribute 5, "rv32i2p1_smcntrpmf1p0"
341+
339342
.attribute arch, "rv32i_smepmp1p0"
340343
# CHECK: attribute 5, "rv32i2p1_smepmp1p0"
341344

llvm/test/MC/RISCV/user-csr-names.s

+48
Original file line numberDiff line numberDiff line change
@@ -480,3 +480,51 @@ csrrs t2, 0xC1E, zero
480480
csrrs t1, hpmcounter31, zero
481481
# uimm12
482482
csrrs t2, 0xC1F, zero
483+
484+
# mcyclecfg
485+
# name
486+
# CHECK-INST: csrrs t1, mcyclecfg, zero
487+
# CHECK-ENC: encoding: [0x73,0x23,0x10,0x32]
488+
# CHECK-INST-ALIAS: csrr t1, mcyclecfg
489+
csrrs t1, mcyclecfg, zero
490+
# uimm12
491+
# CHECK-INST: csrrs t2, mcyclecfg, zero
492+
# CHECK-ENC: encoding: [0xf3,0x23,0x10,0x32]
493+
# CHECK-INST-ALIAS: csrr t2, mcyclecfg
494+
csrrs t2, 0x321, zero
495+
496+
# minstretcfg
497+
# name
498+
# CHECK-INST: csrrs t1, minstretcfg, zero
499+
# CHECK-ENC: encoding: [0x73,0x23,0x20,0x32]
500+
# CHECK-INST-ALIAS: csrr t1, minstretcfg
501+
csrrs t1, minstretcfg, zero
502+
# uimm12
503+
# CHECK-INST: csrrs t2, minstretcfg, zero
504+
# CHECK-ENC: encoding: [0xf3,0x23,0x20,0x32]
505+
# CHECK-INST-ALIAS: csrr t2, minstretcfg
506+
csrrs t2, 0x322, zero
507+
508+
# mcyclecfgh
509+
# name
510+
# CHECK-INST: csrrs t1, mcyclecfgh, zero
511+
# CHECK-ENC: encoding: [0x73,0x23,0x10,0x72]
512+
# CHECK-INST-ALIAS: csrr t1, mcyclecfgh
513+
csrrs t1, mcyclecfgh, zero
514+
# uimm12
515+
# CHECK-INST: csrrs t2, mcyclecfgh, zero
516+
# CHECK-ENC: encoding: [0xf3,0x23,0x10,0x72]
517+
# CHECK-INST-ALIAS: csrr t2, mcyclecfgh
518+
csrrs t2, 0x721, zero
519+
520+
# minstretcfgh
521+
# name
522+
# CHECK-INST: csrrs t1, minstretcfgh, zero
523+
# CHECK-ENC: encoding: [0x73,0x23,0x20,0x72]
524+
# CHECK-INST-ALIAS: csrr t1, minstretcfgh
525+
csrrs t1, minstretcfgh, zero
526+
# uimm12
527+
# CHECK-INST: csrrs t2, minstretcfgh, zero
528+
# CHECK-ENC: encoding: [0xf3,0x23,0x20,0x72]
529+
# CHECK-INST-ALIAS: csrr t2, minstretcfgh
530+
csrrs t2, 0x722, zero

llvm/unittests/TargetParser/RISCVISAInfoTest.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,7 @@ R"(All available -march extensions for RISC-V
10761076
shvstvecd 1.0
10771077
smaia 1.0
10781078
smcdeleg 1.0
1079+
smcntrpmf 1.0
10791080
smcsrind 1.0
10801081
smdbltrp 1.0
10811082
smepmp 1.0

0 commit comments

Comments
 (0)