Skip to content

Commit c59b1d3

Browse files
Merge branch 'main' of https://github.com/llvm/llvm-project
2 parents 59c609c + 4cb2a51 commit c59b1d3

File tree

350 files changed

+14122
-2475
lines changed

Some content is hidden

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

350 files changed

+14122
-2475
lines changed

clang/docs/LanguageExtensions.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -736,9 +736,10 @@ at the end to the next power of 2.
736736

737737
These reductions support both fixed-sized and scalable vector types.
738738

739-
The integer reduction intrinsics, including ``__builtin_reduce_add``,
740-
``__builtin_reduce_mul``, ``__builtin_reduce_and``, ``__builtin_reduce_or``,
741-
and ``__builtin_reduce_xor``, can be called in a ``constexpr`` context.
739+
The integer reduction intrinsics, including ``__builtin_reduce_max``,
740+
``__builtin_reduce_min``, ``__builtin_reduce_add``, ``__builtin_reduce_mul``,
741+
``__builtin_reduce_and``, ``__builtin_reduce_or``, and ``__builtin_reduce_xor``,
742+
can be called in a ``constexpr`` context.
742743

743744
Example:
744745

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,8 @@ Non-comprehensive list of changes in this release
421421
``__builtin_reduce_mul``, ``__builtin_reduce_and``, ``__builtin_reduce_or``,
422422
``__builtin_reduce_xor``, ``__builtin_elementwise_popcount``,
423423
``__builtin_elementwise_bitreverse``, ``__builtin_elementwise_add_sat``,
424-
``__builtin_elementwise_sub_sat``.
424+
``__builtin_elementwise_sub_sat``, ``__builtin_reduce_min`` (For integral element type),
425+
``__builtin_reduce_max`` (For integral element type).
425426

426427
- Clang now rejects ``_BitInt`` matrix element types if the bit width is less than ``CHAR_WIDTH`` or
427428
not a power of two, matching preexisting behaviour for vector types.

clang/include/clang/Basic/Builtins.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,13 +1462,13 @@ def ElementwiseSubSat : Builtin {
14621462

14631463
def ReduceMax : Builtin {
14641464
let Spellings = ["__builtin_reduce_max"];
1465-
let Attributes = [NoThrow, Const, CustomTypeChecking];
1465+
let Attributes = [NoThrow, Const, CustomTypeChecking, Constexpr];
14661466
let Prototype = "void(...)";
14671467
}
14681468

14691469
def ReduceMin : Builtin {
14701470
let Spellings = ["__builtin_reduce_min"];
1471-
let Attributes = [NoThrow, Const, CustomTypeChecking];
1471+
let Attributes = [NoThrow, Const, CustomTypeChecking, Constexpr];
14721472
let Prototype = "void(...)";
14731473
}
14741474

clang/include/clang/Basic/BuiltinsHexagon.def

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
# define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS)
1818
#endif
1919

20+
#pragma push_macro("V79")
21+
#define V79 "v79"
2022
#pragma push_macro("V75")
21-
#define V75 "v75"
23+
#define V75 "v75|" V79
2224
#pragma push_macro("V73")
2325
#define V73 "v73|" V75
2426
#pragma push_macro("V71")
@@ -42,8 +44,10 @@
4244
#pragma push_macro("V5")
4345
#define V5 "v5|" V55
4446

47+
#pragma push_macro("HVXV79")
48+
#define HVXV79 "hvxv79"
4549
#pragma push_macro("HVXV75")
46-
#define HVXV75 "hvxv75"
50+
#define HVXV75 "hvxv75|" HVXV79
4751
#pragma push_macro("HVXV73")
4852
#define HVXV73 "hvxv73|" HVXV75
4953
#pragma push_macro("HVXV71")
@@ -148,6 +152,7 @@ TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyub_rtt_acc_128B,"V64iV64iV32iLLi","", "
148152
#pragma pop_macro("HVXV71")
149153
#pragma pop_macro("HVXV73")
150154
#pragma pop_macro("HVXV75")
155+
#pragma pop_macro("HVXV79")
151156

152157
#pragma pop_macro("V5")
153158
#pragma pop_macro("V55")
@@ -161,6 +166,7 @@ TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyub_rtt_acc_128B,"V64iV64iV32iLLi","", "
161166
#pragma pop_macro("V71")
162167
#pragma pop_macro("V73")
163168
#pragma pop_macro("V75")
169+
#pragma pop_macro("V79")
164170

165171
#undef BUILTIN
166172
#undef TARGET_BUILTIN

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6226,6 +6226,8 @@ def mv73 : Flag<["-"], "mv73">, Group<m_hexagon_Features_Group>,
62266226
Alias<mcpu_EQ>, AliasArgs<["hexagonv73"]>;
62276227
def mv75 : Flag<["-"], "mv75">, Group<m_hexagon_Features_Group>,
62286228
Alias<mcpu_EQ>, AliasArgs<["hexagonv75"]>;
6229+
def mv79 : Flag<["-"], "mv79">, Group<m_hexagon_Features_Group>,
6230+
Alias<mcpu_EQ>, AliasArgs<["hexagonv79"]>;
62296231
def mhexagon_hvx : Flag<["-"], "mhvx">, Group<m_hexagon_Features_HVX_Group>,
62306232
HelpText<"Enable Hexagon Vector eXtensions">;
62316233
def mhexagon_hvx_EQ : Joined<["-"], "mhvx=">,

clang/lib/AST/ExprConstant.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13604,7 +13604,9 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
1360413604
case Builtin::BI__builtin_reduce_mul:
1360513605
case Builtin::BI__builtin_reduce_and:
1360613606
case Builtin::BI__builtin_reduce_or:
13607-
case Builtin::BI__builtin_reduce_xor: {
13607+
case Builtin::BI__builtin_reduce_xor:
13608+
case Builtin::BI__builtin_reduce_min:
13609+
case Builtin::BI__builtin_reduce_max: {
1360813610
APValue Source;
1360913611
if (!EvaluateAsRValue(Info, E->getArg(0), Source))
1361013612
return false;
@@ -13641,6 +13643,14 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
1364113643
Reduced ^= Source.getVectorElt(EltNum).getInt();
1364213644
break;
1364313645
}
13646+
case Builtin::BI__builtin_reduce_min: {
13647+
Reduced = std::min(Reduced, Source.getVectorElt(EltNum).getInt());
13648+
break;
13649+
}
13650+
case Builtin::BI__builtin_reduce_max: {
13651+
Reduced = std::max(Reduced, Source.getVectorElt(EltNum).getInt());
13652+
break;
13653+
}
1364413654
}
1364513655
}
1364613656

clang/lib/Basic/Targets/Hexagon.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ void HexagonTargetInfo::getTargetDefines(const LangOptions &Opts,
8181
} else if (CPU == "hexagonv75") {
8282
Builder.defineMacro("__HEXAGON_V75__");
8383
Builder.defineMacro("__HEXAGON_ARCH__", "75");
84+
} else if (CPU == "hexagonv79") {
85+
Builder.defineMacro("__HEXAGON_V79__");
86+
Builder.defineMacro("__HEXAGON_ARCH__", "79");
8487
}
8588

8689
if (hasFeature("hvx-length64b")) {
@@ -239,6 +242,7 @@ static constexpr CPUSuffix Suffixes[] = {
239242
{{"hexagonv68"}, {"68"}}, {{"hexagonv69"}, {"69"}},
240243
{{"hexagonv71"}, {"71"}}, {{"hexagonv71t"}, {"71t"}},
241244
{{"hexagonv73"}, {"73"}}, {{"hexagonv75"}, {"75"}},
245+
{{"hexagonv79"}, {"79"}},
242246
};
243247

244248
std::optional<unsigned> HexagonTargetInfo::getHexagonCPURev(StringRef Name) {

clang/lib/Basic/Targets/OSTargets.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,9 @@ template <typename Target>
790790
class LLVM_LIBRARY_VISIBILITY UEFITargetInfo : public OSTargetInfo<Target> {
791791
protected:
792792
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
793-
MacroBuilder &Builder) const override {}
793+
MacroBuilder &Builder) const override {
794+
Builder.defineMacro("__UEFI__");
795+
}
794796

795797
public:
796798
UEFITargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)

clang/lib/CodeGen/Targets/AArch64.cpp

Lines changed: 44 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class AArch64ABIInfo : public ABIInfo {
5252

5353
bool isIllegalVectorType(QualType Ty) const;
5454

55+
bool passAsAggregateType(QualType Ty) const;
5556
bool passAsPureScalableType(QualType Ty, unsigned &NV, unsigned &NP,
5657
SmallVectorImpl<llvm::Type *> &CoerceToSeq) const;
5758

@@ -337,6 +338,10 @@ ABIArgInfo AArch64ABIInfo::coerceAndExpandPureScalableAggregate(
337338
NSRN += NVec;
338339
NPRN += NPred;
339340

341+
// Handle SVE vector tuples.
342+
if (Ty->isSVESizelessBuiltinType())
343+
return ABIArgInfo::getDirect();
344+
340345
llvm::Type *UnpaddedCoerceToType =
341346
UnpaddedCoerceToSeq.size() == 1
342347
? UnpaddedCoerceToSeq[0]
@@ -362,7 +367,7 @@ ABIArgInfo AArch64ABIInfo::classifyArgumentType(QualType Ty, bool IsVariadicFn,
362367
if (isIllegalVectorType(Ty))
363368
return coerceIllegalVector(Ty, NSRN, NPRN);
364369

365-
if (!isAggregateTypeForABI(Ty)) {
370+
if (!passAsAggregateType(Ty)) {
366371
// Treat an enum type as its underlying type.
367372
if (const EnumType *EnumTy = Ty->getAs<EnumType>())
368373
Ty = EnumTy->getDecl()->getIntegerType();
@@ -417,7 +422,7 @@ ABIArgInfo AArch64ABIInfo::classifyArgumentType(QualType Ty, bool IsVariadicFn,
417422
// elsewhere for GNU compatibility.
418423
uint64_t Size = getContext().getTypeSize(Ty);
419424
bool IsEmpty = isEmptyRecord(getContext(), Ty, true);
420-
if (IsEmpty || Size == 0) {
425+
if (!Ty->isSVESizelessBuiltinType() && (IsEmpty || Size == 0)) {
421426
if (!getContext().getLangOpts().CPlusPlus || isDarwinPCS())
422427
return ABIArgInfo::getIgnore();
423428

@@ -504,7 +509,7 @@ ABIArgInfo AArch64ABIInfo::classifyReturnType(QualType RetTy,
504509
if (RetTy->isVectorType() && getContext().getTypeSize(RetTy) > 128)
505510
return getNaturalAlignIndirect(RetTy);
506511

507-
if (!isAggregateTypeForABI(RetTy)) {
512+
if (!passAsAggregateType(RetTy)) {
508513
// Treat an enum type as its underlying type.
509514
if (const EnumType *EnumTy = RetTy->getAs<EnumType>())
510515
RetTy = EnumTy->getDecl()->getIntegerType();
@@ -519,7 +524,8 @@ ABIArgInfo AArch64ABIInfo::classifyReturnType(QualType RetTy,
519524
}
520525

521526
uint64_t Size = getContext().getTypeSize(RetTy);
522-
if (isEmptyRecord(getContext(), RetTy, true) || Size == 0)
527+
if (!RetTy->isSVESizelessBuiltinType() &&
528+
(isEmptyRecord(getContext(), RetTy, true) || Size == 0))
523529
return ABIArgInfo::getIgnore();
524530

525531
const Type *Base = nullptr;
@@ -654,6 +660,15 @@ bool AArch64ABIInfo::isZeroLengthBitfieldPermittedInHomogeneousAggregate()
654660
return true;
655661
}
656662

663+
bool AArch64ABIInfo::passAsAggregateType(QualType Ty) const {
664+
if (Kind == AArch64ABIKind::AAPCS && Ty->isSVESizelessBuiltinType()) {
665+
const auto *BT = Ty->getAs<BuiltinType>();
666+
return !BT->isSVECount() &&
667+
getContext().getBuiltinVectorTypeInfo(BT).NumVectors > 1;
668+
}
669+
return isAggregateTypeForABI(Ty);
670+
}
671+
657672
// Check if a type needs to be passed in registers as a Pure Scalable Type (as
658673
// defined by AAPCS64). Return the number of data vectors and the number of
659674
// predicate vectors in the type, into `NVec` and `NPred`, respectively. Upon
@@ -719,37 +734,38 @@ bool AArch64ABIInfo::passAsPureScalableType(
719734
return true;
720735
}
721736

722-
const auto *VT = Ty->getAs<VectorType>();
723-
if (!VT)
724-
return false;
737+
if (const auto *VT = Ty->getAs<VectorType>()) {
738+
if (VT->getVectorKind() == VectorKind::SveFixedLengthPredicate) {
739+
++NPred;
740+
if (CoerceToSeq.size() + 1 > 12)
741+
return false;
742+
CoerceToSeq.push_back(convertFixedToScalableVectorType(VT));
743+
return true;
744+
}
725745

726-
if (VT->getVectorKind() == VectorKind::SveFixedLengthPredicate) {
727-
++NPred;
728-
if (CoerceToSeq.size() + 1 > 12)
729-
return false;
730-
CoerceToSeq.push_back(convertFixedToScalableVectorType(VT));
731-
return true;
732-
}
746+
if (VT->getVectorKind() == VectorKind::SveFixedLengthData) {
747+
++NVec;
748+
if (CoerceToSeq.size() + 1 > 12)
749+
return false;
750+
CoerceToSeq.push_back(convertFixedToScalableVectorType(VT));
751+
return true;
752+
}
733753

734-
if (VT->getVectorKind() == VectorKind::SveFixedLengthData) {
735-
++NVec;
736-
if (CoerceToSeq.size() + 1 > 12)
737-
return false;
738-
CoerceToSeq.push_back(convertFixedToScalableVectorType(VT));
739-
return true;
754+
return false;
740755
}
741756

742-
if (!VT->isBuiltinType())
757+
if (!Ty->isBuiltinType())
743758
return false;
744759

745-
switch (cast<BuiltinType>(VT)->getKind()) {
760+
bool isPredicate;
761+
switch (Ty->getAs<BuiltinType>()->getKind()) {
746762
#define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
747763
case BuiltinType::Id: \
748-
++NVec; \
764+
isPredicate = false; \
749765
break;
750766
#define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId) \
751767
case BuiltinType::Id: \
752-
++NPred; \
768+
isPredicate = true; \
753769
break;
754770
#define SVE_TYPE(Name, Id, SingletonId)
755771
#include "clang/Basic/AArch64SVEACLETypes.def"
@@ -761,6 +777,10 @@ bool AArch64ABIInfo::passAsPureScalableType(
761777
getContext().getBuiltinVectorTypeInfo(cast<BuiltinType>(Ty));
762778
assert(Info.NumVectors > 0 && Info.NumVectors <= 4 &&
763779
"Expected 1, 2, 3 or 4 vectors!");
780+
if (isPredicate)
781+
NPred += Info.NumVectors;
782+
else
783+
NVec += Info.NumVectors;
764784
auto VTy = llvm::ScalableVectorType::get(CGT.ConvertType(Info.ElementType),
765785
Info.EC.getKnownMinValue());
766786

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,8 +1561,6 @@ collectSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
15611561
StaticRuntimes.push_back("ubsan_minimal");
15621562
} else {
15631563
StaticRuntimes.push_back("ubsan_standalone");
1564-
if (SanArgs.linkCXXRuntimes())
1565-
StaticRuntimes.push_back("ubsan_standalone_cxx");
15661564
}
15671565
}
15681566
if (SanArgs.needsSafeStackRt()) {
@@ -1572,11 +1570,13 @@ collectSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
15721570
if (!(SanArgs.needsSharedRt() && SanArgs.needsUbsanRt())) {
15731571
if (SanArgs.needsCfiRt())
15741572
StaticRuntimes.push_back("cfi");
1575-
if (SanArgs.needsCfiDiagRt()) {
1573+
if (SanArgs.needsCfiDiagRt())
15761574
StaticRuntimes.push_back("cfi_diag");
1577-
if (SanArgs.linkCXXRuntimes())
1578-
StaticRuntimes.push_back("ubsan_standalone_cxx");
1579-
}
1575+
}
1576+
if (SanArgs.linkCXXRuntimes() && !SanArgs.requiresMinimalRuntime() &&
1577+
((!SanArgs.needsSharedRt() && SanArgs.needsUbsanRt()) ||
1578+
SanArgs.needsCfiDiagRt())) {
1579+
StaticRuntimes.push_back("ubsan_standalone_cxx");
15801580
}
15811581
if (SanArgs.needsStatsRt()) {
15821582
NonWholeStaticRuntimes.push_back("stats");

0 commit comments

Comments
 (0)