aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/TargetParser/TargetParserTest.cpp
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2025-06-16 12:55:12 -0700
committerGitHub <noreply@github.com>2025-06-16 12:55:12 -0700
commitb0378e7ca953c2390168f352c5a88fd325cde894 (patch)
treee6a9a1ec2291832bffdb34e0fe99eea645a8deca /llvm/unittests/TargetParser/TargetParserTest.cpp
parent25781221d68a700eae679a19f701d4ad67e91dc9 (diff)
downloadllvm-b0378e7ca953c2390168f352c5a88fd325cde894.zip
llvm-b0378e7ca953c2390168f352c5a88fd325cde894.tar.gz
llvm-b0378e7ca953c2390168f352c5a88fd325cde894.tar.bz2
[AArch64TargetParser]Fix reconstructFromParsedFeatures ignoring negative features (#142236)
The `targetFeatureToExtension` function used by reconstructFromParsedFeatures only found positive `+FEATURE` strings, but not negative `-FEATURE` strings. Extend the function to handle both to fix `reconstructFromParsedFeatures`.
Diffstat (limited to 'llvm/unittests/TargetParser/TargetParserTest.cpp')
-rw-r--r--llvm/unittests/TargetParser/TargetParserTest.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/unittests/TargetParser/TargetParserTest.cpp b/llvm/unittests/TargetParser/TargetParserTest.cpp
index f4c9333..c4efb99 100644
--- a/llvm/unittests/TargetParser/TargetParserTest.cpp
+++ b/llvm/unittests/TargetParser/TargetParserTest.cpp
@@ -1831,6 +1831,22 @@ TEST_P(AArch64ExtensionDependenciesBaseCPUTestFixture,
}
}
+TEST(TargetParserTest, testAArch64ReconstructFromParsedFeatures) {
+ AArch64::ExtensionSet Extensions;
+ std::vector<std::string> FeatureOptions = {
+ "-sve2", "-Baz", "+sve", "+FooBar", "+sve2", "+neon", "-sve",
+ };
+ std::vector<std::string> NonExtensions;
+ Extensions.reconstructFromParsedFeatures(FeatureOptions, NonExtensions);
+
+ std::vector<std::string> NonExtensionsExpected = {"-Baz", "+FooBar"};
+ ASSERT_THAT(NonExtensions, testing::ContainerEq(NonExtensionsExpected));
+ std::vector<StringRef> Features;
+ Extensions.toLLVMFeatureList(Features);
+ std::vector<StringRef> FeaturesExpected = {"+neon", "-sve", "+sve2"};
+ ASSERT_THAT(Features, testing::ContainerEq(FeaturesExpected));
+}
+
AArch64ExtensionDependenciesBaseArchTestParams
AArch64ExtensionDependenciesArchData[] = {
// Base architecture features