Skip to content

Commit 30aa49c

Browse files
committed
[RISCV] Remove the pre-split from RISCVISAInfo::parseArchString. NFCI
We can extract each extension as we process them without much complexity.
1 parent 3dcd604 commit 30aa49c

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

llvm/lib/TargetParser/RISCVISAInfo.cpp

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -660,10 +660,6 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
660660
break;
661661
}
662662

663-
if (Arch.back() == '_')
664-
return createStringError(errc::invalid_argument,
665-
"extension name missing after separator '_'");
666-
667663
// Skip baseline.
668664
StringRef Exts = Arch.drop_front(1);
669665

@@ -703,18 +699,18 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
703699
// Consume the base ISA version number and any '_' between rvxxx and the
704700
// first extension
705701
Exts = Exts.drop_front(ConsumeLength);
706-
Exts.consume_front("_");
707702

708-
SmallVector<StringRef, 8> SplitExts;
709-
// Only split if the string is not empty. Otherwise the split will push an
710-
// empty string into the vector.
711-
if (!Exts.empty())
712-
Exts.split(SplitExts, '_');
703+
while (!Exts.empty()) {
704+
if (Exts.front() == '_') {
705+
if (Exts.size() == 1 || Exts[1] == '_')
706+
return createStringError(errc::invalid_argument,
707+
"extension name missing after separator '_'");
708+
Exts = Exts.drop_front();
709+
}
713710

714-
for (auto Ext : SplitExts) {
715-
if (Ext.empty())
716-
return createStringError(errc::invalid_argument,
717-
"extension name missing after separator '_'");
711+
size_t Idx = Exts.find('_');
712+
StringRef Ext = Exts.slice(0, Idx);
713+
Exts = Exts.slice(Idx, StringRef::npos);
718714

719715
do {
720716
if (RISCVISAUtils::AllStdExts.contains(Ext.front())) {

0 commit comments

Comments
 (0)