summaryrefslogtreecommitdiff
path: root/llvm/lib/Support/RISCVISAInfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Support/RISCVISAInfo.cpp')
-rw-r--r--llvm/lib/Support/RISCVISAInfo.cpp61
1 files changed, 27 insertions, 34 deletions
diff --git a/llvm/lib/Support/RISCVISAInfo.cpp b/llvm/lib/Support/RISCVISAInfo.cpp
index 6c59d8a7ef04..2b3395b669b8 100644
--- a/llvm/lib/Support/RISCVISAInfo.cpp
+++ b/llvm/lib/Support/RISCVISAInfo.cpp
@@ -461,15 +461,7 @@ RISCVISAInfo::parseFeatures(unsigned XLen,
ISAInfo->Exts.erase(ExtName.str());
}
- ISAInfo->updateImplication();
- ISAInfo->updateFLen();
- ISAInfo->updateMinVLen();
- ISAInfo->updateMaxELen();
-
- if (Error Result = ISAInfo->checkDependency())
- return std::move(Result);
-
- return std::move(ISAInfo);
+ return RISCVISAInfo::postProcessAndChecking(std::move(ISAInfo));
}
llvm::Expected<std::unique_ptr<RISCVISAInfo>>
@@ -686,26 +678,18 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
}
}
- ISAInfo->updateImplication();
- ISAInfo->updateFLen();
- ISAInfo->updateMinVLen();
- ISAInfo->updateMaxELen();
-
- if (Error Result = ISAInfo->checkDependency())
- return std::move(Result);
-
- return std::move(ISAInfo);
+ return RISCVISAInfo::postProcessAndChecking(std::move(ISAInfo));
}
Error RISCVISAInfo::checkDependency() {
bool IsRv32 = XLen == 32;
- bool HasE = Exts.count("e") == 1;
- bool HasD = Exts.count("d") == 1;
- bool HasF = Exts.count("f") == 1;
- bool HasZve32x = Exts.count("zve32x") == 1;
- bool HasZve32f = Exts.count("zve32f") == 1;
- bool HasZve64d = Exts.count("zve64d") == 1;
- bool HasV = Exts.count("v") == 1;
+ bool HasE = Exts.count("e") != 0;
+ bool HasD = Exts.count("d") != 0;
+ bool HasF = Exts.count("f") != 0;
+ bool HasZve32x = Exts.count("zve32x") != 0;
+ bool HasZve32f = Exts.count("zve32f") != 0;
+ bool HasZve64d = Exts.count("zve64d") != 0;
+ bool HasV = Exts.count("v") != 0;
bool HasVector = HasZve32x || HasV;
bool HasZvl = MinVLen != 0;
@@ -739,12 +723,6 @@ Error RISCVISAInfo::checkDependency() {
errc::invalid_argument,
"zvl*b requires v or zve* extension to also be specified");
- // Could not implement Zve* extension and the V extension at the same time.
- if (HasZve32x && HasV)
- return createStringError(
- errc::invalid_argument,
- "It is illegal to specify the v extension with zve* extensions");
-
// Additional dependency checks.
// TODO: The 'q' extension requires rv64.
// TODO: It is illegal to specify 'e' extensions with 'f' and 'd'.
@@ -753,7 +731,8 @@ Error RISCVISAInfo::checkDependency() {
}
static const char *ImpliedExtsV[] = {"zvl128b", "f", "d"};
-static const char *ImpliedExtsZfh[] = {"zfhmin"};
+static const char *ImpliedExtsZfhmin[] = {"f"};
+static const char *ImpliedExtsZfh[] = {"f"};
static const char *ImpliedExtsZve64d[] = {"zve64f"};
static const char *ImpliedExtsZve64f[] = {"zve64x", "zve32f"};
static const char *ImpliedExtsZve64x[] = {"zve32x", "zvl64b"};
@@ -785,9 +764,11 @@ struct ImpliedExtsEntry {
bool operator<(StringRef Other) const { return Name < Other; }
};
+// Note: The table needs to be sorted by name.
static constexpr ImpliedExtsEntry ImpliedExts[] = {
{{"v"}, {ImpliedExtsV}},
{{"zfh"}, {ImpliedExtsZfh}},
+ {{"zfhmin"}, {ImpliedExtsZfhmin}},
{{"zk"}, {ImpliedExtsZk}},
{{"zkn"}, {ImpliedExtsZkn}},
{{"zks"}, {ImpliedExtsZks}},
@@ -810,8 +791,8 @@ static constexpr ImpliedExtsEntry ImpliedExts[] = {
};
void RISCVISAInfo::updateImplication() {
- bool HasE = Exts.count("e") == 1;
- bool HasI = Exts.count("i") == 1;
+ bool HasE = Exts.count("e") != 0;
+ bool HasI = Exts.count("i") != 0;
// If not in e extension and i extension does not exist, i extension is
// implied
@@ -919,3 +900,15 @@ std::vector<std::string> RISCVISAInfo::toFeatureVector() const {
}
return FeatureVector;
}
+
+llvm::Expected<std::unique_ptr<RISCVISAInfo>>
+RISCVISAInfo::postProcessAndChecking(std::unique_ptr<RISCVISAInfo> &&ISAInfo) {
+ ISAInfo->updateImplication();
+ ISAInfo->updateFLen();
+ ISAInfo->updateMinVLen();
+ ISAInfo->updateMaxELen();
+
+ if (Error Result = ISAInfo->checkDependency())
+ return std::move(Result);
+ return std::move(ISAInfo);
+}