llvm.org GIT mirror llvm / f08b891
TargetParserTest.ARMExtensionFeatures run out of memory on 32-bit (PR42316) Nothing of these tests made much sense. Loops were iterating too much, and I also don't think it was actually testing anything. I think we simply want to check that AEK_SOME_EXT returns "+some_ext". I've given the AArch64 tests the same treatment as they very similarly didn't made any sense either. This fixes PR42316. Differential Revision: https://reviews.llvm.org/D63569 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363913 91177308-0d34-0410-b5e6-96231b3b80d8 Sjoerd Meijer 2 months ago
1 changed file(s) with 69 addition(s) and 22 deletion(s). Raw diff Collapse all Expand all
568568 }
569569
570570 TEST(TargetParserTest, ARMExtensionFeatures) {
571 std::map> Extensions;
572
573 Extensions[ARM::AEK_CRC] = { "+crc", "-crc" };
574 Extensions[ARM::AEK_DSP] = { "+dsp", "-dsp" };
575 Extensions[ARM::AEK_HWDIVARM] = { "+hwdiv-arm", "-hwdiv-arm" };
576 Extensions[ARM::AEK_HWDIVTHUMB] = { "+hwdiv", "-hwdiv" };
577 Extensions[ARM::AEK_RAS] = { "+ras", "-ras" };
578 Extensions[ARM::AEK_FP16FML] = { "+fp16fml", "-fp16fml" };
579 Extensions[ARM::AEK_DOTPROD] = { "+dotprod", "-dotprod" };
580
571581 std::vector Features;
572 unsigned Extensions = ARM::AEK_CRC | ARM::AEK_CRYPTO | ARM::AEK_DSP |
573 ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB | ARM::AEK_MP |
574 ARM::AEK_SEC | ARM::AEK_VIRT | ARM::AEK_RAS | ARM::AEK_FP16 |
575 ARM::AEK_FP16FML | ARM::AEK_FP_DP;
576
577 for (unsigned i = 0; i <= Extensions; i++) {
582
583 EXPECT_FALSE(AArch64::getExtensionFeatures(ARM::AEK_INVALID, Features));
584
585 for (auto &E : Extensions) {
586 // test +extension
578587 Features.clear();
579 EXPECT_TRUE(i == 0 ? !ARM::getExtensionFeatures(i, Features)
580 : ARM::getExtensionFeatures(i, Features));
581 }
588 ARM::getExtensionFeatures(E.first, Features);
589 auto Found =
590 std::find(std::begin(Features), std::end(Features), E.second.at(0));
591 EXPECT_TRUE(Found != std::end(Features));
592 EXPECT_TRUE(Extensions.size() == Features.size());
593
594 // test -extension
595 Features.clear();
596 ARM::getExtensionFeatures(~E.first, Features);
597 Found = std::find(std::begin(Features), std::end(Features), E.second.at(1));
598 EXPECT_TRUE(Found != std::end(Features));
599 EXPECT_TRUE(Extensions.size() == Features.size());
600 }
582601 }
583602
584603 TEST(TargetParserTest, ARMFPUFeatures) {
10191038 }
10201039
10211040 TEST(TargetParserTest, AArch64ExtensionFeatures) {
1041 std::vector Extensions = {
1042 AArch64::AEK_CRC, AArch64::AEK_CRYPTO,
1043 AArch64::AEK_FP, AArch64::AEK_SIMD,
1044 AArch64::AEK_FP16, AArch64::AEK_PROFILE,
1045 AArch64::AEK_RAS, AArch64::AEK_LSE,
1046 AArch64::AEK_RDM, AArch64::AEK_DOTPROD,
1047 AArch64::AEK_SVE, AArch64::AEK_SVE2,
1048 AArch64::AEK_SVE2AES, AArch64::AEK_SVE2SM4,
1049 AArch64::AEK_SVE2SHA3, AArch64::AEK_BITPERM,
1050 AArch64::AEK_RCPC, AArch64::AEK_FP16FML };
1051
10221052 std::vector Features;
1023 unsigned Extensions = AArch64::AEK_CRC | AArch64::AEK_CRYPTO |
1024 AArch64::AEK_FP | AArch64::AEK_SIMD |
1025 AArch64::AEK_FP16 | AArch64::AEK_PROFILE |
1026 AArch64::AEK_RAS | AArch64::AEK_LSE |
1027 AArch64::AEK_RDM | AArch64::AEK_SVE |
1028 AArch64::AEK_SVE2 | AArch64::AEK_DOTPROD |
1029 AArch64::AEK_RCPC | AArch64::AEK_FP16FML;
1030
1031 for (unsigned i = 0; i <= Extensions; i++) {
1032 Features.clear();
1033 EXPECT_TRUE(i == 0 ? !AArch64::getExtensionFeatures(i, Features)
1034 : AArch64::getExtensionFeatures(i, Features));
1035 }
1053
1054 unsigned ExtVal = 0;
1055 for (auto E : Extensions)
1056 ExtVal |= E;
1057
1058 AArch64::getExtensionFeatures(ExtVal, Features);
1059 auto B = std::begin(Features);
1060 auto E = std::end(Features);
1061
1062 EXPECT_FALSE(AArch64::getExtensionFeatures(AArch64::AEK_INVALID, Features));
1063 EXPECT_TRUE(Extensions.size() == Features.size());
1064
1065 EXPECT_TRUE(std::find(B, E, "+crc") != E);
1066 EXPECT_TRUE(std::find(B, E, "+crypto") != E);
1067 EXPECT_TRUE(std::find(B, E, "+fp-armv8") != E);
1068 EXPECT_TRUE(std::find(B, E, "+neon") != E);
1069 EXPECT_TRUE(std::find(B, E, "+fullfp16") != E);
1070 EXPECT_TRUE(std::find(B, E, "+spe") != E);
1071 EXPECT_TRUE(std::find(B, E, "+ras") != E);
1072 EXPECT_TRUE(std::find(B, E, "+lse") != E);
1073 EXPECT_TRUE(std::find(B, E, "+rdm") != E);
1074 EXPECT_TRUE(std::find(B, E, "+dotprod") != E);
1075 EXPECT_TRUE(std::find(B, E, "+rcpc") != E);
1076 EXPECT_TRUE(std::find(B, E, "+fp16fml") != E);
1077 EXPECT_TRUE(std::find(B, E, "+sve") != E);
1078 EXPECT_TRUE(std::find(B, E, "+sve2") != E);
1079 EXPECT_TRUE(std::find(B, E, "+sve2-aes") != E);
1080 EXPECT_TRUE(std::find(B, E, "+sve2-sm4") != E);
1081 EXPECT_TRUE(std::find(B, E, "+sve2-sha3") != E);
1082 EXPECT_TRUE(std::find(B, E, "+bitperm") != E);
10361083 }
10371084
10381085 TEST(TargetParserTest, AArch64ArchFeatures) {