Skip to content

Commit 87de497

Browse files
authored
[RISCV] Remove IgnoreUnknown from RISCVISAInfo::parseArchString. (#97372)
This isn't used in tree, and thus I don't know what the expectations for its behavior really are. The original usage of this feature has been replaced by parseNormalizedArchString.
1 parent 7359edb commit 87de497

File tree

3 files changed

+9
-78
lines changed

3 files changed

+9
-78
lines changed

llvm/include/llvm/TargetParser/RISCVISAInfo.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ class RISCVISAInfo {
3636
/// default version will be used (as ignoring the base is not possible).
3737
static llvm::Expected<std::unique_ptr<RISCVISAInfo>>
3838
parseArchString(StringRef Arch, bool EnableExperimentalExtension,
39-
bool ExperimentalExtensionVersionCheck = true,
40-
bool IgnoreUnknown = false);
39+
bool ExperimentalExtensionVersionCheck = true);
4140

4241
/// Parse RISC-V ISA info from an arch string that is already in normalized
4342
/// form (as defined in the psABI). Unlike parseArchString, this function

llvm/lib/TargetParser/RISCVISAInfo.cpp

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -522,8 +522,7 @@ RISCVISAInfo::parseNormalizedArchString(StringRef Arch) {
522522

523523
llvm::Expected<std::unique_ptr<RISCVISAInfo>>
524524
RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
525-
bool ExperimentalExtensionVersionCheck,
526-
bool IgnoreUnknown) {
525+
bool ExperimentalExtensionVersionCheck) {
527526
// RISC-V ISA strings must be [a-z0-9_]
528527
if (!llvm::all_of(
529528
Arch, [](char C) { return isDigit(C) || isLower(C) || C == '_'; }))
@@ -567,7 +566,7 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
567566
NewArch += ArchWithoutProfile.str();
568567
}
569568
return parseArchString(NewArch, EnableExperimentalExtension,
570-
ExperimentalExtensionVersionCheck, IgnoreUnknown);
569+
ExperimentalExtensionVersionCheck);
571570
}
572571
}
573572

@@ -601,16 +600,8 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
601600
// Baseline is `i` or `e`
602601
if (auto E = getExtensionVersion(
603602
StringRef(&Baseline, 1), Exts, Major, Minor, ConsumeLength,
604-
EnableExperimentalExtension, ExperimentalExtensionVersionCheck)) {
605-
if (!IgnoreUnknown)
606-
return std::move(E);
607-
// If IgnoreUnknown, then ignore an unrecognised version of the baseline
608-
// ISA and just use the default supported version.
609-
consumeError(std::move(E));
610-
auto Version = findDefaultVersion(StringRef(&Baseline, 1));
611-
Major = Version->Major;
612-
Minor = Version->Minor;
613-
}
603+
EnableExperimentalExtension, ExperimentalExtensionVersionCheck))
604+
return std::move(E);
614605

615606
// Postpone AddExtension until end of this function
616607
SeenExtMap[StringRef(&Baseline, 1).str()] = {Major, Minor};
@@ -677,11 +668,10 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
677668
Ext = StringRef();
678669

679670
assert(!Type.empty() && "Empty type?");
680-
if (!IgnoreUnknown && Name.size() == Type.size())
671+
if (Name.size() == Type.size())
681672
return createStringError(errc::invalid_argument,
682673
Desc + " name missing after '" + Type + "'");
683674
} else {
684-
// FIXME: Could it be ignored by IgnoreUnknown?
685675
return createStringError(errc::invalid_argument,
686676
"invalid standard user-level extension '" +
687677
Twine(Ext.front()) + "'");
@@ -690,27 +680,17 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
690680
unsigned Major, Minor, ConsumeLength;
691681
if (auto E = getExtensionVersion(Name, Vers, Major, Minor, ConsumeLength,
692682
EnableExperimentalExtension,
693-
ExperimentalExtensionVersionCheck)) {
694-
if (!IgnoreUnknown)
695-
return E;
696-
697-
consumeError(std::move(E));
698-
if (Name.size() == 1)
699-
Ext = Ext.substr(ConsumeLength);
700-
continue;
701-
}
683+
ExperimentalExtensionVersionCheck))
684+
return E;
702685

703686
if (Name.size() == 1)
704687
Ext = Ext.substr(ConsumeLength);
705688

706689
// Check if duplicated extension.
707-
if (!IgnoreUnknown && SeenExtMap.contains(Name.str()))
690+
if (SeenExtMap.contains(Name.str()))
708691
return createStringError(errc::invalid_argument,
709692
"duplicated " + Desc + " '" + Name + "'");
710693

711-
if (IgnoreUnknown && !RISCVISAInfo::isSupportedExtension(Name))
712-
continue;
713-
714694
SeenExtMap[Name.str()] = {Major, Minor};
715695
} while (!Ext.empty());
716696
}

llvm/unittests/TargetParser/RISCVISAInfoTest.cpp

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -341,25 +341,6 @@ TEST(ParseArchString, RejectsUnrecognizedExtensionNamesByDefault) {
341341
"unsupported non-standard user-level extension 'xmadeup'");
342342
}
343343

344-
TEST(ParseArchString, IgnoresUnrecognizedExtensionNamesWithIgnoreUnknown) {
345-
for (StringRef Input : {"rv32i_zmadeup", "rv64i_smadeup", "rv64i_xmadeup"}) {
346-
auto MaybeISAInfo = RISCVISAInfo::parseArchString(Input, true, false, true);
347-
ASSERT_THAT_EXPECTED(MaybeISAInfo, Succeeded());
348-
RISCVISAInfo &Info = **MaybeISAInfo;
349-
const auto &Exts = Info.getExtensions();
350-
EXPECT_EQ(Exts.size(), 1UL);
351-
EXPECT_TRUE(Exts.at("i") == (RISCVISAUtils::ExtensionVersion{2, 1}));
352-
}
353-
354-
// Checks that supported extensions aren't incorrectly ignored when a
355-
// version is present (an early version of the patch had this mistake).
356-
auto MaybeISAInfo =
357-
RISCVISAInfo::parseArchString("rv32i_zbc1p0_xmadeup", true, false, true);
358-
ASSERT_THAT_EXPECTED(MaybeISAInfo, Succeeded());
359-
const auto &Exts = (*MaybeISAInfo)->getExtensions();
360-
EXPECT_TRUE(Exts.at("zbc") == (RISCVISAUtils::ExtensionVersion{1, 0}));
361-
}
362-
363344
TEST(ParseArchString, AcceptsVersionInLongOrShortForm) {
364345
for (StringRef Input : {"rv64i2p1"}) {
365346
auto MaybeISAInfo = RISCVISAInfo::parseArchString(Input, true);
@@ -393,35 +374,6 @@ TEST(ParseArchString, RejectsUnrecognizedExtensionVersionsByDefault) {
393374
"unsupported version number 10.10 for extension 'zifencei'");
394375
}
395376

396-
TEST(ParseArchString,
397-
UsesDefaultVersionForUnrecognisedBaseISAVersionWithIgnoreUnknown) {
398-
for (StringRef Input : {"rv32i0p1", "rv32i99p99", "rv64i0p1", "rv64i99p99"}) {
399-
auto MaybeISAInfo = RISCVISAInfo::parseArchString(Input, true, false, true);
400-
ASSERT_THAT_EXPECTED(MaybeISAInfo, Succeeded());
401-
const auto &Exts = (*MaybeISAInfo)->getExtensions();
402-
EXPECT_EQ(Exts.size(), 1UL);
403-
EXPECT_TRUE(Exts.at("i") == (RISCVISAUtils::ExtensionVersion{2, 1}));
404-
}
405-
for (StringRef Input : {"rv32e0p1", "rv32e99p99", "rv64e0p1", "rv64e99p99"}) {
406-
auto MaybeISAInfo = RISCVISAInfo::parseArchString(Input, true, false, true);
407-
ASSERT_THAT_EXPECTED(MaybeISAInfo, Succeeded());
408-
const auto &Exts = (*MaybeISAInfo)->getExtensions();
409-
EXPECT_EQ(Exts.size(), 1UL);
410-
EXPECT_TRUE(Exts.at("e") == (RISCVISAUtils::ExtensionVersion{2, 0}));
411-
}
412-
}
413-
414-
TEST(ParseArchString,
415-
IgnoresExtensionsWithUnrecognizedVersionsWithIgnoreUnknown) {
416-
for (StringRef Input : {"rv32im1p1", "rv64i_svnapot10p9", "rv32i_zicsr0p5"}) {
417-
auto MaybeISAInfo = RISCVISAInfo::parseArchString(Input, true, false, true);
418-
ASSERT_THAT_EXPECTED(MaybeISAInfo, Succeeded());
419-
const auto &Exts = (*MaybeISAInfo)->getExtensions();
420-
EXPECT_EQ(Exts.size(), 1UL);
421-
EXPECT_TRUE(Exts.at("i") == (RISCVISAUtils::ExtensionVersion{2, 1}));
422-
}
423-
}
424-
425377
TEST(ParseArchString, AcceptsUnderscoreSplittingExtensions) {
426378
for (StringRef Input : {"rv32imafdczifencei", "rv32i_m_a_f_d_c_zifencei"}) {
427379
auto MaybeISAInfo = RISCVISAInfo::parseArchString(Input, true);

0 commit comments

Comments
 (0)