Skip to content

Commit 588e1c5

Browse files
authored
Merge branch 'llvm:main' into gh-101657
2 parents b6c1d8d + 0fa59c6 commit 588e1c5

File tree

51 files changed

+944
-492
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+944
-492
lines changed

clang/include/clang/Basic/arm_sme.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,8 @@ let SMETargetGuard = "sme2" in {
716716
def SVZERO_ZT : Inst<"svzero_zt", "vi", "", MergeNone, "aarch64_sme_zero_zt", [IsOverloadNone, IsStreamingCompatible, IsOutZT0], [ImmCheck<0, ImmCheck0_0>]>;
717717
}
718718

719+
def IN_STREAMING_MODE : Inst<"__arm_in_streaming_mode", "sv", "Pc", MergeNone, "aarch64_sme_in_streaming_mode", [IsOverloadNone, IsStreamingCompatible], []>;
720+
719721
//
720722
// lookup table expand four contiguous registers
721723
//

clang/lib/AST/ASTContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14357,7 +14357,7 @@ QualType ASTContext::getCorrespondingSignedFixedPointType(QualType Ty) const {
1435714357
// corresponding backend features (which may contain duplicates).
1435814358
static std::vector<std::string> getFMVBackendFeaturesFor(
1435914359
const llvm::SmallVectorImpl<StringRef> &FMVFeatStrings) {
14360-
std::vector<std::string> BackendFeats{{"+fmv"}};
14360+
std::vector<std::string> BackendFeats;
1436114361
llvm::AArch64::ExtensionSet FeatureBits;
1436214362
for (StringRef F : FMVFeatStrings)
1436314363
if (auto FMVExt = llvm::AArch64::parseFMVExtension(F))

clang/lib/Basic/Targets/OSTargets.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,6 @@ void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts,
114114
assert(OsVersion.getMinor().value_or(0) < 100 &&
115115
OsVersion.getSubminor().value_or(0) < 100 && "Invalid version!");
116116
Builder.defineMacro("__ENVIRONMENT_OS_VERSION_MIN_REQUIRED__", Str);
117-
118-
// Tell users about the kernel if there is one.
119-
Builder.defineMacro("__MACH__");
120117
}
121118

122119
PlatformMinVersion = OsVersion;

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11327,6 +11327,19 @@ Value *CodeGenFunction::EmitAArch64SMEBuiltinExpr(unsigned BuiltinID,
1132711327
if (Builtin->LLVMIntrinsic == 0)
1132811328
return nullptr;
1132911329

11330+
if (BuiltinID == SME::BI__builtin_sme___arm_in_streaming_mode) {
11331+
// If we already know the streaming mode, don't bother with the intrinsic
11332+
// and emit a constant instead
11333+
const auto *FD = cast<FunctionDecl>(CurFuncDecl);
11334+
if (const auto *FPT = FD->getType()->getAs<FunctionProtoType>()) {
11335+
unsigned SMEAttrs = FPT->getAArch64SMEAttributes();
11336+
if (!(SMEAttrs & FunctionType::SME_PStateSMCompatibleMask)) {
11337+
bool IsStreaming = SMEAttrs & FunctionType::SME_PStateSMEnabledMask;
11338+
return ConstantInt::getBool(Builder.getContext(), IsStreaming);
11339+
}
11340+
}
11341+
}
11342+
1133011343
// Predicates must match the main datatype.
1133111344
for (unsigned i = 0, e = Ops.size(); i != e; ++i)
1133211345
if (auto PredTy = dyn_cast<llvm::VectorType>(Ops[i]->getType()))

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2748,7 +2748,21 @@ bool CodeGenModule::GetCPUAndFeaturesAttributes(GlobalDecl GD,
27482748
Attrs.addAttribute("target-features", llvm::join(Features, ","));
27492749
AddedAttr = true;
27502750
}
2751-
2751+
if (getTarget().getTriple().isAArch64()) {
2752+
llvm::SmallVector<StringRef, 8> Feats;
2753+
if (TV)
2754+
TV->getFeatures(Feats);
2755+
else if (TC)
2756+
TC->getFeatures(Feats, GD.getMultiVersionIndex());
2757+
if (!Feats.empty()) {
2758+
llvm::sort(Feats);
2759+
std::string FMVFeatures;
2760+
for (StringRef F : Feats)
2761+
FMVFeatures.append(",+" + F.str());
2762+
Attrs.addAttribute("fmv-features", FMVFeatures.substr(1));
2763+
AddedAttr = true;
2764+
}
2765+
}
27522766
return AddedAttr;
27532767
}
27542768

clang/lib/Driver/Driver.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6686,6 +6686,8 @@ const ToolChain &Driver::getToolChain(const ArgList &Args,
66866686
TC = std::make_unique<toolchains::BareMetal>(*this, Target, Args);
66876687
else if (Target.isOSBinFormatELF())
66886688
TC = std::make_unique<toolchains::Generic_ELF>(*this, Target, Args);
6689+
else if (Target.isAppleMachO())
6690+
TC = std::make_unique<toolchains::AppleMachO>(*this, Target, Args);
66896691
else if (Target.isOSBinFormatMachO())
66906692
TC = std::make_unique<toolchains::MachO>(*this, Target, Args);
66916693
else

clang/lib/Driver/ToolChains/Darwin.cpp

Lines changed: 66 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -966,11 +966,14 @@ MachO::MachO(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
966966
getProgramPaths().push_back(getDriver().Dir);
967967
}
968968

969+
AppleMachO::AppleMachO(const Driver &D, const llvm::Triple &Triple,
970+
const ArgList &Args)
971+
: MachO(D, Triple, Args), CudaInstallation(D, Triple, Args),
972+
RocmInstallation(D, Triple, Args), SYCLInstallation(D, Triple, Args) {}
973+
969974
/// Darwin - Darwin tool chain for i386 and x86_64.
970975
Darwin::Darwin(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
971-
: MachO(D, Triple, Args), TargetInitialized(false),
972-
CudaInstallation(D, Triple, Args), RocmInstallation(D, Triple, Args),
973-
SYCLInstallation(D, Triple, Args) {}
976+
: AppleMachO(D, Triple, Args), TargetInitialized(false) {}
974977

975978
types::ID MachO::LookupTypeForExtension(StringRef Ext) const {
976979
types::ID Ty = ToolChain::LookupTypeForExtension(Ext);
@@ -1019,18 +1022,18 @@ bool Darwin::hasBlocksRuntime() const {
10191022
}
10201023
}
10211024

1022-
void Darwin::AddCudaIncludeArgs(const ArgList &DriverArgs,
1023-
ArgStringList &CC1Args) const {
1025+
void AppleMachO::AddCudaIncludeArgs(const ArgList &DriverArgs,
1026+
ArgStringList &CC1Args) const {
10241027
CudaInstallation->AddCudaIncludeArgs(DriverArgs, CC1Args);
10251028
}
10261029

1027-
void Darwin::AddHIPIncludeArgs(const ArgList &DriverArgs,
1028-
ArgStringList &CC1Args) const {
1030+
void AppleMachO::AddHIPIncludeArgs(const ArgList &DriverArgs,
1031+
ArgStringList &CC1Args) const {
10291032
RocmInstallation->AddHIPIncludeArgs(DriverArgs, CC1Args);
10301033
}
10311034

1032-
void Darwin::addSYCLIncludeArgs(const ArgList &DriverArgs,
1033-
ArgStringList &CC1Args) const {
1035+
void AppleMachO::addSYCLIncludeArgs(const ArgList &DriverArgs,
1036+
ArgStringList &CC1Args) const {
10341037
SYCLInstallation->addSYCLIncludeArgs(DriverArgs, CC1Args);
10351038
}
10361039

@@ -1125,6 +1128,8 @@ VersionTuple MachO::getLinkerVersion(const llvm::opt::ArgList &Args) const {
11251128

11261129
Darwin::~Darwin() {}
11271130

1131+
AppleMachO::~AppleMachO() {}
1132+
11281133
MachO::~MachO() {}
11291134

11301135
std::string Darwin::ComputeEffectiveClangTriple(const ArgList &Args,
@@ -2488,7 +2493,7 @@ static void AppendPlatformPrefix(SmallString<128> &Path,
24882493
// Returns the effective sysroot from either -isysroot or --sysroot, plus the
24892494
// platform prefix (if any).
24902495
llvm::SmallString<128>
2491-
DarwinClang::GetEffectiveSysroot(const llvm::opt::ArgList &DriverArgs) const {
2496+
AppleMachO::GetEffectiveSysroot(const llvm::opt::ArgList &DriverArgs) const {
24922497
llvm::SmallString<128> Path("/");
24932498
if (DriverArgs.hasArg(options::OPT_isysroot))
24942499
Path = DriverArgs.getLastArgValue(options::OPT_isysroot);
@@ -2501,8 +2506,9 @@ DarwinClang::GetEffectiveSysroot(const llvm::opt::ArgList &DriverArgs) const {
25012506
return Path;
25022507
}
25032508

2504-
void DarwinClang::AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
2505-
llvm::opt::ArgStringList &CC1Args) const {
2509+
void AppleMachO::AddClangSystemIncludeArgs(
2510+
const llvm::opt::ArgList &DriverArgs,
2511+
llvm::opt::ArgStringList &CC1Args) const {
25062512
const Driver &D = getDriver();
25072513

25082514
llvm::SmallString<128> Sysroot = GetEffectiveSysroot(DriverArgs);
@@ -2580,7 +2586,7 @@ bool DarwinClang::AddGnuCPlusPlusIncludePaths(const llvm::opt::ArgList &DriverAr
25802586
return getVFS().exists(Base);
25812587
}
25822588

2583-
void DarwinClang::AddClangCXXStdlibIncludeArgs(
2589+
void AppleMachO::AddClangCXXStdlibIncludeArgs(
25842590
const llvm::opt::ArgList &DriverArgs,
25852591
llvm::opt::ArgStringList &CC1Args) const {
25862592
// The implementation from a base class will pass through the -stdlib to
@@ -2637,55 +2643,60 @@ void DarwinClang::AddClangCXXStdlibIncludeArgs(
26372643
}
26382644

26392645
case ToolChain::CST_Libstdcxx:
2640-
llvm::SmallString<128> UsrIncludeCxx = Sysroot;
2641-
llvm::sys::path::append(UsrIncludeCxx, "usr", "include", "c++");
2642-
2643-
llvm::Triple::ArchType arch = getTriple().getArch();
2644-
bool IsBaseFound = true;
2645-
switch (arch) {
2646-
default: break;
2647-
2648-
case llvm::Triple::x86:
2649-
case llvm::Triple::x86_64:
2650-
IsBaseFound = AddGnuCPlusPlusIncludePaths(DriverArgs, CC1Args, UsrIncludeCxx,
2651-
"4.2.1",
2652-
"i686-apple-darwin10",
2653-
arch == llvm::Triple::x86_64 ? "x86_64" : "");
2654-
IsBaseFound |= AddGnuCPlusPlusIncludePaths(DriverArgs, CC1Args, UsrIncludeCxx,
2655-
"4.0.0", "i686-apple-darwin8",
2656-
"");
2657-
break;
2646+
AddGnuCPlusPlusIncludePaths(DriverArgs, CC1Args);
2647+
break;
2648+
}
2649+
}
26582650

2659-
case llvm::Triple::arm:
2660-
case llvm::Triple::thumb:
2661-
IsBaseFound = AddGnuCPlusPlusIncludePaths(DriverArgs, CC1Args, UsrIncludeCxx,
2662-
"4.2.1",
2663-
"arm-apple-darwin10",
2664-
"v7");
2665-
IsBaseFound |= AddGnuCPlusPlusIncludePaths(DriverArgs, CC1Args, UsrIncludeCxx,
2666-
"4.2.1",
2667-
"arm-apple-darwin10",
2668-
"v6");
2669-
break;
2651+
void AppleMachO::AddGnuCPlusPlusIncludePaths(
2652+
const llvm::opt::ArgList &DriverArgs,
2653+
llvm::opt::ArgStringList &CC1Args) const {}
26702654

2671-
case llvm::Triple::aarch64:
2672-
IsBaseFound = AddGnuCPlusPlusIncludePaths(DriverArgs, CC1Args, UsrIncludeCxx,
2673-
"4.2.1",
2674-
"arm64-apple-darwin10",
2675-
"");
2676-
break;
2677-
}
2655+
void DarwinClang::AddGnuCPlusPlusIncludePaths(
2656+
const llvm::opt::ArgList &DriverArgs,
2657+
llvm::opt::ArgStringList &CC1Args) const {
2658+
llvm::SmallString<128> UsrIncludeCxx = GetEffectiveSysroot(DriverArgs);
2659+
llvm::sys::path::append(UsrIncludeCxx, "usr", "include", "c++");
26782660

2679-
if (!IsBaseFound) {
2680-
getDriver().Diag(diag::warn_drv_libstdcxx_not_found);
2681-
}
2661+
llvm::Triple::ArchType arch = getTriple().getArch();
2662+
bool IsBaseFound = true;
2663+
switch (arch) {
2664+
default:
2665+
break;
26822666

2667+
case llvm::Triple::x86:
2668+
case llvm::Triple::x86_64:
2669+
IsBaseFound = AddGnuCPlusPlusIncludePaths(
2670+
DriverArgs, CC1Args, UsrIncludeCxx, "4.2.1", "i686-apple-darwin10",
2671+
arch == llvm::Triple::x86_64 ? "x86_64" : "");
2672+
IsBaseFound |= AddGnuCPlusPlusIncludePaths(
2673+
DriverArgs, CC1Args, UsrIncludeCxx, "4.0.0", "i686-apple-darwin8", "");
2674+
break;
2675+
2676+
case llvm::Triple::arm:
2677+
case llvm::Triple::thumb:
2678+
IsBaseFound =
2679+
AddGnuCPlusPlusIncludePaths(DriverArgs, CC1Args, UsrIncludeCxx, "4.2.1",
2680+
"arm-apple-darwin10", "v7");
2681+
IsBaseFound |=
2682+
AddGnuCPlusPlusIncludePaths(DriverArgs, CC1Args, UsrIncludeCxx, "4.2.1",
2683+
"arm-apple-darwin10", "v6");
2684+
break;
2685+
2686+
case llvm::Triple::aarch64:
2687+
IsBaseFound =
2688+
AddGnuCPlusPlusIncludePaths(DriverArgs, CC1Args, UsrIncludeCxx, "4.2.1",
2689+
"arm64-apple-darwin10", "");
26832690
break;
26842691
}
2692+
2693+
if (!IsBaseFound) {
2694+
getDriver().Diag(diag::warn_drv_libstdcxx_not_found);
2695+
}
26852696
}
26862697

2687-
void DarwinClang::AddCXXStdlibLibArgs(const ArgList &Args,
2688-
ArgStringList &CmdArgs) const {
2698+
void AppleMachO::AddCXXStdlibLibArgs(const ArgList &Args,
2699+
ArgStringList &CmdArgs) const {
26892700
CXXStdlibType Type = GetCXXStdlibType(Args);
26902701

26912702
switch (Type) {
@@ -3621,7 +3632,7 @@ SanitizerMask Darwin::getSupportedSanitizers() const {
36213632
return Res;
36223633
}
36233634

3624-
void Darwin::printVerboseInfo(raw_ostream &OS) const {
3635+
void AppleMachO::printVerboseInfo(raw_ostream &OS) const {
36253636
CudaInstallation->print(OS);
36263637
RocmInstallation->print(OS);
36273638
}

0 commit comments

Comments
 (0)