Index: unittests/Support/TargetParserTest.cpp =================================================================== --- unittests/Support/TargetParserTest.cpp +++ unittests/Support/TargetParserTest.cpp @@ -569,15 +569,31 @@ } TEST(TargetParserTest, ARMExtensionFeatures) { - unsigned Extensions = ARM::AEK_CRC | ARM::AEK_CRYPTO | ARM::AEK_DSP | - ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB | ARM::AEK_MP | - ARM::AEK_SEC | ARM::AEK_VIRT | ARM::AEK_RAS | ARM::AEK_FP16 | - ARM::AEK_FP16FML | ARM::AEK_FP_DP; + std::map> Extensions; - for (unsigned i = 0; i <= Extensions; i++) { - std::vector Features; - EXPECT_TRUE(i == 0 ? !ARM::getExtensionFeatures(i, Features) - : ARM::getExtensionFeatures(i, Features)); + Extensions[ARM::AEK_CRC] = { "+crc", "-crc" }; + Extensions[ARM::AEK_DSP] = { "+dsp", "-dsp" }; + Extensions[ARM::AEK_HWDIVARM] = { "+hwdiv-arm", "-hwdiv-arm" }; + Extensions[ARM::AEK_HWDIVTHUMB] = { "+hwdiv", "-hwdiv" }; + Extensions[ARM::AEK_RAS] = { "+ras", "-ras" }; + Extensions[ARM::AEK_FP16FML] = { "+fp16fml", "-fp16fml" }; + Extensions[ARM::AEK_DOTPROD] = { "+dotprod", "-dotprod" }; + + std::vector Features; + + for (auto &E : Extensions) { + Features.clear(); + + // test +extension + ARM::getExtensionFeatures(E.first, Features); + auto Found = + std::find(std::begin(Features), std::end(Features), E.second.at(0)); + EXPECT_TRUE(Found != std::end(Features)); + + // test -extension + ARM::getExtensionFeatures(~E.first, Features); + Found = std::find(std::begin(Features), std::end(Features), E.second.at(1)); + EXPECT_TRUE(Found != std::end(Features)); } } @@ -1019,7 +1035,6 @@ } TEST(TargetParserTest, AArch64ExtensionFeatures) { - std::vector Features; unsigned Extensions = AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP | AArch64::AEK_SIMD | AArch64::AEK_FP16 | AArch64::AEK_PROFILE | @@ -1028,9 +1043,26 @@ AArch64::AEK_SVE2 | AArch64::AEK_DOTPROD | AArch64::AEK_RCPC | AArch64::AEK_FP16FML; - for (unsigned i = 0; i <= Extensions; i++) - EXPECT_TRUE(i == 0 ? !AArch64::getExtensionFeatures(i, Features) - : AArch64::getExtensionFeatures(i, Features)); + std::vector Features; + AArch64::getExtensionFeatures(Extensions, Features); + + auto B = std::begin(Features); + auto E = std::end(Features); + + EXPECT_TRUE(std::find(B, E, "+crc") != E); + EXPECT_TRUE(std::find(B, E, "+crypto") != E); + EXPECT_TRUE(std::find(B, E, "+fp-armv8") != E); + EXPECT_TRUE(std::find(B, E, "+neon") != E); + EXPECT_TRUE(std::find(B, E, "+fullfp16") != E); + EXPECT_TRUE(std::find(B, E, "+spe") != E); + EXPECT_TRUE(std::find(B, E, "+ras") != E); + EXPECT_TRUE(std::find(B, E, "+lse") != E); + EXPECT_TRUE(std::find(B, E, "+rdm") != E); + EXPECT_TRUE(std::find(B, E, "+sve") != E); + EXPECT_TRUE(std::find(B, E, "+sve2") != E); + EXPECT_TRUE(std::find(B, E, "+dotprod") != E); + EXPECT_TRUE(std::find(B, E, "+rcpc") != E); + EXPECT_TRUE(std::find(B, E, "+fp16fml") != E); } TEST(TargetParserTest, AArch64ArchFeatures) {