[PATCH] D109215: [RISCV] Fix arch sring parsing for multi-character extensions
Yueh-Ting Chen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 3 02:17:47 PDT 2021
eopXD updated this revision to Diff 370511.
eopXD added a comment.
Update: Remove redundant codes added.
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
@@ -72,6 +72,18 @@
return Ext.consume_front("experimental-");
}
+static size_t findFirstNonVersionCharacter(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;
+}
+
void RISCVISAInfo::addExtension(StringRef ExtName, unsigned MajorVersion,
unsigned MinorVersion) {
RISCVExtensionInfo Ext;
@@ -612,7 +624,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.370511.patch
Type: text/x-patch
Size: 1004 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210903/ff893c05/attachment.bin>
More information about the llvm-commits
mailing list