[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 13:09:59 PST 2021
craig.topper created this revision.
craig.topper added reviewers: kito-cheng, asb, jrtc27, eopXD, HsiangKai, frasercrmck.
Herald added subscribers: VincentWu, luke957, achieveartificialintelligence, StephenFan, vkmr, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya.
craig.topper requested review of this revision.
Herald added a subscriber: MaskRay.
Herald added a project: LLVM.
This a proof of concept for a suggestion I proposed in D108694 <https://reviews.llvm.org/D108694>.
Repository:
rG LLVM Github Monorepo
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,22 @@
return Error::success();
}
+static const char *ImpliedExts_v[] = {"zvlsseg"};
+static const char *ImpliedExts_zfh[] = {"zfhmin"};
+
+struct ImpliedExtsEntry {
+ StringLiteral Name;
+ ArrayRef<const char *> Exts;
+};
+
+static constexpr ImpliedExtsEntry ImpliedExts[] = {
+ {"v", ImpliedExts_v},
+ {"zfh", ImpliedExts_zfh},
+};
+
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 +719,16 @@
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);
+ for (auto &Ext : Exts) {
+ auto I = llvm::lower_bound(ImpliedExts, Ext.first,
+ [](const ImpliedExtsEntry &Entry,
+ StringRef Ext) { return Entry.Name < Ext; });
+ 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.394022.patch
Type: text/x-patch
Size: 1668 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211213/9c912614/attachment.bin>
More information about the llvm-commits
mailing list