llvm.org GIT mirror llvm / 44a57d2
[clang][Driver][ARM] Favor -mfpu over default CPU features When processing the command line options march, mcpu and mfpu, we store the implied target features on a vector. The change D62998 introduced a temporary vector, where the processed features get accumulated. When calling DecodeARMFeaturesFromCPU, which sets the default features for the specified CPU, we certainly don't want to override the features that have been explicitly specified on the command line. Therefore, the default features should appear first in the final vector. This problem became evident once I added the missing (unhandled) target features in ARM::getExtensionFeatures. Differential Revision: https://reviews.llvm.org/D63936 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366027 91177308-0d34-0410-b5e6-96231b3b80d8 Alexandros Lamprineas a month ago
3 changed file(s) with 15 addition(s) and 31 deletion(s). Raw diff Collapse all Expand all
147147 ARM_ARCH_EXT_NAME("dotprod", ARM::AEK_DOTPROD, "+dotprod","-dotprod")
148148 ARM_ARCH_EXT_NAME("dsp", ARM::AEK_DSP, "+dsp", "-dsp")
149149 ARM_ARCH_EXT_NAME("fp", ARM::AEK_FP, nullptr, nullptr)
150 ARM_ARCH_EXT_NAME("fp.dp", ARM::AEK_FP_DP, nullptr, nullptr)
150151 ARM_ARCH_EXT_NAME("mve", ARM::AEK_SIMD, "+mve", "-mve")
151152 ARM_ARCH_EXT_NAME("mve.fp", (ARM::AEK_SIMD | ARM::AEK_FP), "+mve.fp", "-mve.fp")
152153 ARM_ARCH_EXT_NAME("idiv", (ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB), nullptr, nullptr)
408408 if (Extensions == AEK_INVALID)
409409 return false;
410410
411 if (Extensions & AEK_CRC)
412 Features.push_back("+crc");
413 else
414 Features.push_back("-crc");
415
416 if (Extensions & AEK_DSP)
417 Features.push_back("+dsp");
418 else
419 Features.push_back("-dsp");
420
421 if (Extensions & AEK_FP16FML)
422 Features.push_back("+fp16fml");
423 else
424 Features.push_back("-fp16fml");
425
426 if (Extensions & AEK_RAS)
427 Features.push_back("+ras");
428 else
429 Features.push_back("-ras");
430
431 if (Extensions & AEK_DOTPROD)
432 Features.push_back("+dotprod");
433 else
434 Features.push_back("-dotprod");
411 for (const auto AE : ARCHExtNames) {
412 if ((Extensions & AE.ID) == AE.ID && AE.Feature)
413 Features.push_back(AE.Feature);
414 else if (AE.NegFeature)
415 Features.push_back(AE.NegFeature);
416 }
435417
436418 return getHWDivFeatures(Extensions, Features);
437419 }
570570 TEST(TargetParserTest, ARMExtensionFeatures) {
571571 std::map> Extensions;
572572
573 Extensions[ARM::AEK_CRC] = { "+crc", "-crc" };
574 Extensions[ARM::AEK_DSP] = { "+dsp", "-dsp" };
573 for (auto &Ext : ARM::ARCHExtNames) {
574 if (Ext.Feature && Ext.NegFeature)
575 Extensions[Ext.ID] = { StringRef(Ext.Feature),
576 StringRef(Ext.NegFeature) };
577 }
578
575579 Extensions[ARM::AEK_HWDIVARM] = { "+hwdiv-arm", "-hwdiv-arm" };
576580 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" };
580581
581582 std::vector Features;
582583
583 EXPECT_FALSE(AArch64::getExtensionFeatures(ARM::AEK_INVALID, Features));
584 EXPECT_FALSE(ARM::getExtensionFeatures(ARM::AEK_INVALID, Features));
584585
585586 for (auto &E : Extensions) {
586587 // test +extension
597598 Found = std::find(std::begin(Features), std::end(Features), E.second.at(1));
598599 EXPECT_TRUE(Found != std::end(Features));
599600 EXPECT_TRUE(Extensions.size() == Features.size());
600 }
601 }
601602 }
602603
603604 TEST(TargetParserTest, ARMFPUFeatures) {