[PATCH] D112987: [RISCV] Bump rvv-related extensions from 0.10 to 1.0
Yueh-Ting Chen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 20 01:28:48 PST 2022
eopXD updated this revision to Diff 401546.
eopXD added a comment.
Rebase.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D112987/new/
https://reviews.llvm.org/D112987
Files:
clang/lib/Basic/Targets/RISCV.cpp
clang/utils/TableGen/RISCVVEmitter.cpp
llvm/include/llvm/Support/RISCVISAInfo.h
llvm/lib/Support/RISCVISAInfo.cpp
Index: llvm/lib/Support/RISCVISAInfo.cpp
===================================================================
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -881,3 +881,17 @@
return Arch.str();
}
+
+std::vector<std::string> RISCVISAInfo::toFeatureVector() const {
+ std::vector<std::string> FeatureVector;
+ for (auto Ext : Exts) {
+ std::string ExtName = Ext.first;
+ if (ExtName == "i") // i is not recognized in clang -cc1
+ continue;
+ std::string Feature = isExperimentalExtension(ExtName)
+ ? "+experimental-" + ExtName
+ : "+" + ExtName;
+ FeatureVector.push_back(Feature);
+ }
+ return FeatureVector;
+}
Index: llvm/include/llvm/Support/RISCVISAInfo.h
===================================================================
--- llvm/include/llvm/Support/RISCVISAInfo.h
+++ llvm/include/llvm/Support/RISCVISAInfo.h
@@ -67,6 +67,7 @@
bool hasExtension(StringRef Ext) const;
std::string toString() const;
+ std::vector<std::string> toFeatureVector() const;
static bool isSupportedExtensionFeature(StringRef Ext);
static bool isSupportedExtension(StringRef Ext);
Index: clang/utils/TableGen/RISCVVEmitter.cpp
===================================================================
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -1027,7 +1027,7 @@
OS << "#if defined(TARGET_BUILTIN) && !defined(RISCVV_BUILTIN)\n";
OS << "#define RISCVV_BUILTIN(ID, TYPE, ATTRS) TARGET_BUILTIN(ID, TYPE, "
- "ATTRS, \"experimental-v\")\n";
+ "ATTRS, \"experimental-zve32x\")\n";
OS << "#endif\n";
for (auto &Def : Defs) {
auto P =
Index: clang/lib/Basic/Targets/RISCV.cpp
===================================================================
--- clang/lib/Basic/Targets/RISCV.cpp
+++ clang/lib/Basic/Targets/RISCV.cpp
@@ -214,10 +214,26 @@
llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags, StringRef CPU,
const std::vector<std::string> &FeaturesVec) const {
- if (getTriple().getArch() == llvm::Triple::riscv64)
+ unsigned XLen = 32;
+
+ if (getTriple().getArch() == llvm::Triple::riscv64) {
Features["64bit"] = true;
+ XLen = 64;
+ }
+
+ auto ParseResult = llvm::RISCVISAInfo::parseFeatures(XLen, FeaturesVec);
+ if (!ParseResult) {
+ std::string Buffer;
+ llvm::raw_string_ostream OutputErrMsg(Buffer);
+ handleAllErrors(ParseResult.takeError(), [&](llvm::StringError &ErrMsg) {
+ OutputErrMsg << ErrMsg.getMessage();
+ });
+ Diags.Report(diag::err_invalid_feature_combination) << OutputErrMsg.str();
+ return false;
+ }
- return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
+ return TargetInfo::initFeatureMap(Features, Diags, CPU,
+ (*ParseResult)->toFeatureVector());
}
/// Return true if has this feature, need to sync with handleTargetFeatures.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112987.401546.patch
Type: text/x-patch
Size: 2956 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220120/badc7145/attachment.bin>
More information about the llvm-commits
mailing list