[PATCH] D115668: [RISCV] Add a table for extension implications.
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 13 20:39:10 PST 2021
craig.topper updated this revision to Diff 394126.
craig.topper added a comment.
Add is_sorted check. Add operator< to the ImpliedFeatures struct
Remove underscore from array names.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D115668/new/
https://reviews.llvm.org/D115668
Files:
llvm/lib/Support/RISCVISAInfo.cpp
Index: llvm/lib/Support/RISCVISAInfo.cpp
===================================================================
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -695,11 +695,30 @@
return Error::success();
}
+static const char *ImpliedExtsV[] = {"zvlsseg"};
+static const char *ImpliedExtsZfh[] = {"zfhmin"};
+
+struct ImpliedExtsEntry {
+ StringLiteral Name;
+ ArrayRef<const char *> Exts;
+
+ bool operator<(const ImpliedExtsEntry &Other) const {
+ return Name < Other.Name;
+ }
+
+ bool operator<(StringRef Other) const {
+ return Name < Other;
+ }
+};
+
+static constexpr ImpliedExtsEntry ImpliedExts[] = {
+ {"v", ImpliedExtsV},
+ {"zfh", ImpliedExtsZfh},
+};
+
void RISCVISAInfo::updateImplication() {
bool HasE = Exts.count("e") == 1;
bool HasI = Exts.count("i") == 1;
- bool HasV = Exts.count("v") == 1;
- bool HasZfh = Exts.count("zfh") == 1;
// If not in e extension and i extension does not exist, i extension is
// implied
@@ -708,14 +727,15 @@
addExtension("i", Version->Major, Version->Minor);
}
- if (HasV) {
- auto Version = findDefaultVersion("zvlsseg");
- addExtension("zvlsseg", Version->Major, Version->Minor);
- }
-
- if (HasZfh) {
- auto Version = findDefaultVersion("zfhmin");
- addExtension("zfhmin", Version->Major, Version->Minor);
+ assert(llvm::is_sorted(ImpliedExts) && "Table not sorted by Name");
+ for (auto &Ext : Exts) {
+ auto I = llvm::lower_bound(ImpliedExts, Ext.first);
+ if (I != std::end(ImpliedExts) && I->Name == Ext.first) {
+ for (auto &ImpliedExt : I->Exts) {
+ auto Version = findDefaultVersion(ImpliedExt);
+ addExtension(ImpliedExt, Version->Major, Version->Minor);
+ }
+ }
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115668.394126.patch
Type: text/x-patch
Size: 1760 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211214/4f9b03e2/attachment.bin>
More information about the llvm-commits
mailing list