Skip to content

Commit 471abce

Browse files
author
Yeting Kuo
committed
Make this pr obey menable-experimental-extensions.
1 parent a43014c commit 471abce

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8449,6 +8449,11 @@ void ClangAs::AddRISCVTargetArgs(const ArgList &Args,
84498449
CmdArgs.push_back("-mllvm");
84508450
CmdArgs.push_back("-riscv-add-build-attributes");
84518451
}
8452+
8453+
if (!Args.hasArg(options::OPT_menable_experimental_extensions)) {
8454+
CmdArgs.push_back("-mllvm");
8455+
CmdArgs.push_back("-riscv-disable-experimental-ext");
8456+
}
84528457
}
84538458

84548459
void ClangAs::ConstructJob(Compilation &C, const JobAction &JA,

clang/test/Driver/riscv-option-arch.s

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# RUN: %clang --target=riscv64 -menable-experimental-extensions -c -o /dev/null %s
2+
# RUN: ! %clang --target=riscv64 -c -o /dev/null %s 2>&1 | FileCheck -check-prefixes=CHECK-ERR %s
3+
4+
.option arch, +zicfiss
5+
# CHECK-ERR: Unexpected experimental extensions.

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ STATISTIC(RISCVNumInstrsCompressed,
5151

5252
static cl::opt<bool> AddBuildAttributes("riscv-add-build-attributes",
5353
cl::init(false));
54+
static cl::opt<bool>
55+
DisableExperimentalExtension("riscv-disable-experimental-ext",
56+
cl::init(false));
5457

5558
namespace llvm {
5659
extern const SubtargetFeatureKV RISCVFeatureKV[RISCV::NumSubtargetFeatures];
@@ -2825,6 +2828,9 @@ bool RISCVAsmParser::parseDirectiveOption() {
28252828
}
28262829

28272830
std::string &&Feature = RISCVISAInfo::getTargetFeatureForExtension(Arch);
2831+
if (DisableExperimentalExtension &&
2832+
StringRef(Feature).starts_with("experimental-"))
2833+
return Error(Loc, "Unexpected experimental extensions.");
28282834
auto Ext = llvm::lower_bound(RISCVFeatureKV, Feature);
28292835
if (Ext == std::end(RISCVFeatureKV) || StringRef(Ext->Key) != Feature ||
28302836
!RISCVISAInfo::isSupportedExtension(Arch)) {

0 commit comments

Comments
 (0)