Skip to content

Commit a43014c

Browse files
author
Yeting Kuo
committed
[RISCV] Teach .option arch to support experimental extensions.
Previously .option arch denied extenions are not belongs to RISC-V features. But experimental features have experimental- prefix, so .option arch can not serve for experimental extension. This patch uses the features of extensions to identify extension existance.
1 parent 05c1447 commit a43014c

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2824,8 +2824,9 @@ bool RISCVAsmParser::parseDirectiveOption() {
28242824
break;
28252825
}
28262826

2827-
auto Ext = llvm::lower_bound(RISCVFeatureKV, Arch);
2828-
if (Ext == std::end(RISCVFeatureKV) || StringRef(Ext->Key) != Arch ||
2827+
std::string &&Feature = RISCVISAInfo::getTargetFeatureForExtension(Arch);
2828+
auto Ext = llvm::lower_bound(RISCVFeatureKV, Feature);
2829+
if (Ext == std::end(RISCVFeatureKV) || StringRef(Ext->Key) != Feature ||
28292830
!RISCVISAInfo::isSupportedExtension(Arch)) {
28302831
if (isDigit(Arch.back()))
28312832
return Error(
@@ -2834,7 +2835,7 @@ bool RISCVAsmParser::parseDirectiveOption() {
28342835
return Error(Loc, "unknown extension feature");
28352836
}
28362837

2837-
Args.emplace_back(Type, Ext->Key);
2838+
Args.emplace_back(Type, Arch.str());
28382839

28392840
if (Type == RISCVOptionArchArgType::Plus) {
28402841
FeatureBitset OldFeatureBits = STI->getFeatureBits();

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# RUN: llvm-mc -triple riscv32 -show-encoding < %s \
22
# RUN: | FileCheck -check-prefixes=CHECK %s
33
# RUN: llvm-mc -triple riscv32 -filetype=obj < %s \
4-
# RUN: | llvm-objdump --triple=riscv32 --mattr=+c,+m,+a,+f,+zba -d -M no-aliases - \
4+
# RUN: | llvm-objdump --triple=riscv32 --mattr=+c,+m,+a,+f,+zba,+experimental-zicfiss -d -M no-aliases - \
55
# RUN: | FileCheck -check-prefixes=CHECK-INST %s
66

77
# Test '.option arch, +' and '.option arch, -' directive
@@ -78,6 +78,13 @@ lr.w t0, (t1)
7878
# CHECK: encoding: [0xb3,0x22,0x73,0x20]
7979
sh1add t0, t1, t2
8080

81+
# Test experimental extension
82+
# CHECK: .option arch, +zicfiss
83+
.option arch, +zicfiss
84+
# CHECK-INST: sspopchk ra
85+
# CHECK: encoding: [0x73,0xc0,0xc0,0xcd]
86+
sspopchk ra
87+
8188
# Test '.option arch, <arch-string>' directive
8289
# CHECK: .option arch, rv32i2p1_m2p0_a2p1_c2p0
8390
.option arch, rv32i2p1_m2p0_a2p1_c2p0

0 commit comments

Comments
 (0)