diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp --- a/clang/lib/Basic/Targets/AArch64.cpp +++ b/clang/lib/Basic/Targets/AArch64.cpp @@ -692,10 +692,8 @@ Features[OtherArch->getSubArch()] = Enabled; // Set any features implied by the architecture - uint64_t Extensions = - llvm::AArch64::getDefaultExtensions("generic", *ArchInfo); std::vector CPUFeats; - if (llvm::AArch64::getExtensionFeatures(Extensions, CPUFeats)) { + if (llvm::AArch64::getExtensionFeatures(ArchInfo->DefaultExts, CPUFeats)) { for (auto F : CPUFeats) { assert(F[0] == '+' && "Expected + in target feature!"); Features[F.drop_front(1)] = true; @@ -951,7 +949,7 @@ // Parse the CPU and add any implied features. std::optional CpuInfo = llvm::AArch64::parseCpu(CPU); if (CpuInfo) { - uint64_t Exts = llvm::AArch64::getDefaultExtensions(CPU, CpuInfo->Arch); + uint64_t Exts = CpuInfo->getImpliedExtensions(); std::vector CPUFeats; llvm::AArch64::getExtensionFeatures(Exts, CPUFeats); for (auto F : CPUFeats) { diff --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp --- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp +++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp @@ -140,7 +140,7 @@ Features.push_back(ArchInfo->ArchFeature); - uint64_t Extension = llvm::AArch64::getDefaultExtensions(CPU, *ArchInfo); + uint64_t Extension = CpuInfo->getImpliedExtensions(); if (!llvm::AArch64::getExtensionFeatures(Extension, Features)) return false; } diff --git a/llvm/include/llvm/TargetParser/AArch64TargetParser.h b/llvm/include/llvm/TargetParser/AArch64TargetParser.h --- a/llvm/include/llvm/TargetParser/AArch64TargetParser.h +++ b/llvm/include/llvm/TargetParser/AArch64TargetParser.h @@ -334,6 +334,10 @@ const ArchInfo &Arch; uint64_t DefaultExtensions; // Default extensions for this CPU. These will be // ORd with the architecture defaults. + + uint64_t getImpliedExtensions() const { + return DefaultExtensions | Arch.DefaultExts; + } }; inline constexpr CpuInfo CpuInfos[] = { @@ -509,7 +513,6 @@ StringRef resolveCPUAlias(StringRef CPU); // Information by Name -uint64_t getDefaultExtensions(StringRef CPU, const ArchInfo &AI); void getFeatureOption(StringRef Name, std::string &Feature); std::optional getArchForCpu(StringRef CPU); diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp --- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp @@ -6891,8 +6891,7 @@ // Get the architecture and extension features. std::vector AArch64Features; AArch64Features.push_back(ArchInfo->ArchFeature); - AArch64::getExtensionFeatures( - AArch64::getDefaultExtensions("generic", *ArchInfo), AArch64Features); + AArch64::getExtensionFeatures(ArchInfo->DefaultExts, AArch64Features); MCSubtargetInfo &STI = copySTI(); std::vector ArchFeatures(AArch64Features.begin(), AArch64Features.end()); diff --git a/llvm/lib/TargetParser/AArch64TargetParser.cpp b/llvm/lib/TargetParser/AArch64TargetParser.cpp --- a/llvm/lib/TargetParser/AArch64TargetParser.cpp +++ b/llvm/lib/TargetParser/AArch64TargetParser.cpp @@ -25,19 +25,6 @@ return 0; } -uint64_t AArch64::getDefaultExtensions(StringRef CPU, - const AArch64::ArchInfo &AI) { - if (CPU == "generic") - return AI.DefaultExts; - - // Note: this now takes cpu aliases into account - std::optional Cpu = parseCpu(CPU); - if (!Cpu) - return AI.DefaultExts; - - return Cpu->Arch.DefaultExts | Cpu->DefaultExtensions; -} - void AArch64::getFeatureOption(StringRef Name, std::string &Feature) { for (const auto &E : llvm::AArch64::Extensions) { if (Name == E.Name) { diff --git a/llvm/unittests/TargetParser/TargetParserTest.cpp b/llvm/unittests/TargetParser/TargetParserTest.cpp --- a/llvm/unittests/TargetParser/TargetParserTest.cpp +++ b/llvm/unittests/TargetParser/TargetParserTest.cpp @@ -966,11 +966,9 @@ EXPECT_TRUE(Cpu); EXPECT_EQ(params.ExpectedArch, Cpu->Arch.Name); - uint64_t default_extensions = - AArch64::getDefaultExtensions(params.CPUName, Cpu->Arch); EXPECT_PRED_FORMAT2( AssertSameExtensionFlags(params.CPUName), - params.ExpectedFlags, default_extensions); + params.ExpectedFlags, Cpu->getImpliedExtensions()); } INSTANTIATE_TEST_SUITE_P( @@ -1472,7 +1470,7 @@ if (!Extension) return false; std::optional CpuInfo = AArch64::parseCpu(CPUName); - return (CpuInfo->Arch.DefaultExts | CpuInfo->DefaultExtensions) & Extension->ID; + return CpuInfo->getImpliedExtensions() & Extension->ID; } bool testAArch64Extension(const AArch64::ArchInfo &AI, StringRef ArchExt) {