[PATCH] D109215: [RISCV] Fix arch string parsing for multi-character extensions
Yueh-Ting Chen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 22 22:26:09 PDT 2021
eopXD updated this revision to Diff 381711.
eopXD added a comment.
Herald added a subscriber: achieveartificialintelligence.
Rebase.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109215/new/
https://reviews.llvm.org/D109215
Files:
llvm/lib/Support/RISCVISAInfo.cpp
Index: llvm/lib/Support/RISCVISAInfo.cpp
===================================================================
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -71,6 +71,18 @@
return Ext.consume_front("experimental-");
}
+static size_t findFirstNonVersionCharacter(const StringRef &Ext) {
+ int Pos = Ext.size() - 1;
+ while (Pos >= 0 && isDigit(Ext[Pos]))
+ Pos--;
+ if (Pos > 0 && Ext[Pos] == 'p' && isDigit(Ext[Pos - 1])) {
+ Pos--;
+ while (Pos >= 0 && isDigit(Ext[Pos]))
+ Pos--;
+ }
+ return Pos;
+}
+
struct FindByName {
FindByName(StringRef Ext) : Ext(Ext){};
StringRef Ext;
@@ -637,7 +649,7 @@
StringRef Type = getExtensionType(Ext);
StringRef Desc = getExtensionTypeDesc(Ext);
- auto Pos = Ext.find_if(isDigit);
+ auto Pos = findFirstNonVersionCharacter(Ext) + 1;
StringRef Name(Ext.substr(0, Pos));
StringRef Vers(Ext.substr(Pos));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109215.381711.patch
Type: text/x-patch
Size: 933 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211023/c5360e7e/attachment.bin>
More information about the llvm-commits
mailing list