[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:16:30 PDT 2021
eopXD created this revision.
eopXD added a reviewer: kito.cheng.
Herald added subscribers: vkmr, frasercrmck, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya.
eopXD requested review of this revision.
Herald added subscribers: llvm-commits, MaskRay.
Herald added a project: LLVM.
Current implementation can't parse extension names that contains digits
correctly (e.g. `zvl128b`). This patch fixes it.
Repository:
rG LLVM Github Monorepo
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
@@ -15,6 +15,7 @@
#include "llvm/Support/raw_ostream.h"
#include <array>
+#include <iostream>
#include <string>
#include <vector>
@@ -64,6 +65,7 @@
{"zvamo", RISCVExtensionVersion{0, 10}},
{"zvlsseg", RISCVExtensionVersion{0, 10}},
+ {"zvl128b", RISCVExtensionVersion{0, 10}},
{"zfh", RISCVExtensionVersion{0, 1}},
};
@@ -72,6 +74,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 +626,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.370510.patch
Type: text/x-patch
Size: 1353 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210903/01f98732/attachment.bin>
More information about the llvm-commits
mailing list