[RISCV] Allow Zicsr/Zifencei to duplicate with g (#136842)
This matches GCC and we supported it in LLVM 17/18. Fixes #136803 (cherry picked from commit 6c3373534305a2ce23dd939344dd0a387a09fe88)
This commit is contained in:
parent
1c0368417f
commit
a708fb737a
@ -1267,6 +1267,8 @@ RISC-V Support
|
||||
- The option ``-mcmodel=large`` for the large code model is supported.
|
||||
- Bump RVV intrinsic to version 1.0, the spec: https://github.com/riscv-non-isa/rvv-intrinsic-doc/releases/tag/v1.0.0-rc4
|
||||
|
||||
- `Zicsr` / `Zifencei` are allowed to be duplicated in the presence of `g` in `-march`.
|
||||
|
||||
CUDA/HIP Language Changes
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
- Fixed a bug about overriding a constexpr pure-virtual member function with a non-constexpr virtual member function which causes compilation failure when including standard C++ header `format`.
|
||||
|
||||
@ -45,9 +45,8 @@ struct RISCVProfile {
|
||||
|
||||
} // end anonymous namespace
|
||||
|
||||
static const char *RISCVGImplications[] = {
|
||||
"i", "m", "a", "f", "d", "zicsr", "zifencei"
|
||||
};
|
||||
static const char *RISCVGImplications[] = {"i", "m", "a", "f", "d"};
|
||||
static const char *RISCVGImplicationsZi[] = {"zicsr", "zifencei"};
|
||||
|
||||
#define GET_SUPPORTED_EXTENSIONS
|
||||
#include "llvm/TargetParser/RISCVTargetParserDef.inc"
|
||||
@ -718,6 +717,19 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
|
||||
} while (!Ext.empty());
|
||||
}
|
||||
|
||||
// We add Zicsr/Zifenci as final to allow duplicated "zicsr"/"zifencei" like
|
||||
// "rv64g_zicsr_zifencei".
|
||||
if (Baseline == 'g') {
|
||||
for (const char *Ext : RISCVGImplicationsZi) {
|
||||
if (ISAInfo->Exts.count(Ext))
|
||||
continue;
|
||||
|
||||
auto Version = findDefaultVersion(Ext);
|
||||
assert(Version && "Default extension version not found?");
|
||||
ISAInfo->Exts[std::string(Ext)] = {Version->Major, Version->Minor};
|
||||
}
|
||||
}
|
||||
|
||||
return RISCVISAInfo::postProcessAndChecking(std::move(ISAInfo));
|
||||
}
|
||||
|
||||
|
||||
@ -507,6 +507,14 @@ TEST(ParseArchString, RejectsDoubleOrTrailingUnderscore) {
|
||||
}
|
||||
|
||||
TEST(ParseArchString, RejectsDuplicateExtensionNames) {
|
||||
// Zicsr/Zifencei are allowed to duplicate with "g".
|
||||
ASSERT_THAT_EXPECTED(RISCVISAInfo::parseArchString("rv64g_zicsr", true),
|
||||
Succeeded());
|
||||
ASSERT_THAT_EXPECTED(RISCVISAInfo::parseArchString("rv64g_zifencei", true),
|
||||
Succeeded());
|
||||
ASSERT_THAT_EXPECTED(
|
||||
RISCVISAInfo::parseArchString("rv64g_zicsr_zifencei", true), Succeeded());
|
||||
|
||||
EXPECT_EQ(toString(RISCVISAInfo::parseArchString("rv64ii", true).takeError()),
|
||||
"invalid standard user-level extension 'i'");
|
||||
EXPECT_EQ(toString(RISCVISAInfo::parseArchString("rv32ee", true).takeError()),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user