[llvm] 30aa49c - [RISCV] Remove the pre-split from RISCVISAInfo::parseArchString. NFCI
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Fri May 10 15:31:57 PDT 2024
Author: Craig Topper
Date: 2024-05-10T15:31:44-07:00
New Revision: 30aa49cbc2ece32bebcb06cc9e64f1daeb1dbbcb
URL: https://github.com/llvm/llvm-project/commit/30aa49cbc2ece32bebcb06cc9e64f1daeb1dbbcb
DIFF: https://github.com/llvm/llvm-project/commit/30aa49cbc2ece32bebcb06cc9e64f1daeb1dbbcb.diff
LOG: [RISCV] Remove the pre-split from RISCVISAInfo::parseArchString. NFCI
We can extract each extension as we process them without much
complexity.
Added:
Modified:
llvm/lib/TargetParser/RISCVISAInfo.cpp
Removed:
################################################################################
diff --git a/llvm/lib/TargetParser/RISCVISAInfo.cpp b/llvm/lib/TargetParser/RISCVISAInfo.cpp
index 931c2aa41ac74..e22dd6032cb0c 100644
--- a/llvm/lib/TargetParser/RISCVISAInfo.cpp
+++ b/llvm/lib/TargetParser/RISCVISAInfo.cpp
@@ -660,10 +660,6 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
break;
}
- if (Arch.back() == '_')
- return createStringError(errc::invalid_argument,
- "extension name missing after separator '_'");
-
// Skip baseline.
StringRef Exts = Arch.drop_front(1);
@@ -703,18 +699,18 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
// Consume the base ISA version number and any '_' between rvxxx and the
// first extension
Exts = Exts.drop_front(ConsumeLength);
- Exts.consume_front("_");
- SmallVector<StringRef, 8> SplitExts;
- // Only split if the string is not empty. Otherwise the split will push an
- // empty string into the vector.
- if (!Exts.empty())
- Exts.split(SplitExts, '_');
+ while (!Exts.empty()) {
+ if (Exts.front() == '_') {
+ if (Exts.size() == 1 || Exts[1] == '_')
+ return createStringError(errc::invalid_argument,
+ "extension name missing after separator '_'");
+ Exts = Exts.drop_front();
+ }
- for (auto Ext : SplitExts) {
- if (Ext.empty())
- return createStringError(errc::invalid_argument,
- "extension name missing after separator '_'");
+ size_t Idx = Exts.find('_');
+ StringRef Ext = Exts.slice(0, Idx);
+ Exts = Exts.slice(Idx, StringRef::npos);
do {
if (RISCVISAUtils::AllStdExts.contains(Ext.front())) {
More information about the llvm-commits
mailing list