Skip to content

Commit 8e16b31

Browse files
committed
merge main into amd-staging
Change-Id: I11c898e352a0ddc2caec15619aa816e4a52edc27
2 parents 39f7b9d + acbd822 commit 8e16b31

30 files changed

+954
-88
lines changed

clang/include/clang/AST/Type.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4593,9 +4593,14 @@ class FunctionType : public Type {
45934593
SME_ZT0Shift = 5,
45944594
SME_ZT0Mask = 0b111 << SME_ZT0Shift,
45954595

4596+
// A bit to tell whether a function is agnostic about sme ZA state.
4597+
SME_AgnosticZAStateShift = 8,
4598+
SME_AgnosticZAStateMask = 1 << SME_AgnosticZAStateShift,
4599+
45964600
SME_AttributeMask =
4597-
0b111'111'11 // We can't support more than 8 bits because of
4598-
// the bitmask in FunctionTypeExtraBitfields.
4601+
0b1'111'111'11 // We can't support more than 9 bits because of
4602+
// the bitmask in FunctionTypeArmAttributes
4603+
// and ExtProtoInfo.
45994604
};
46004605

46014606
enum ArmStateValue : unsigned {
@@ -4620,7 +4625,7 @@ class FunctionType : public Type {
46204625
struct alignas(void *) FunctionTypeArmAttributes {
46214626
/// Any AArch64 SME ACLE type attributes that need to be propagated
46224627
/// on declarations and function pointers.
4623-
unsigned AArch64SMEAttributes : 8;
4628+
unsigned AArch64SMEAttributes : 9;
46244629

46254630
FunctionTypeArmAttributes() : AArch64SMEAttributes(SME_NormalFunction) {}
46264631
};
@@ -5188,7 +5193,7 @@ class FunctionProtoType final
51885193
FunctionType::ExtInfo ExtInfo;
51895194
unsigned Variadic : 1;
51905195
unsigned HasTrailingReturn : 1;
5191-
unsigned AArch64SMEAttributes : 8;
5196+
unsigned AArch64SMEAttributes : 9;
51925197
Qualifiers TypeQuals;
51935198
RefQualifierKind RefQualifier = RQ_None;
51945199
ExceptionSpecInfo ExceptionSpec;

clang/include/clang/Basic/Attr.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2877,6 +2877,13 @@ def ArmPreserves : TypeAttr, TargetSpecificAttr<TargetAArch64> {
28772877
let Documentation = [ArmPreservesDocs];
28782878
}
28792879

2880+
def ArmAgnostic : TypeAttr, TargetSpecificAttr<TargetAArch64> {
2881+
let Spellings = [RegularKeyword<"__arm_agnostic">];
2882+
let Args = [VariadicStringArgument<"AgnosticArgs">];
2883+
let Subjects = SubjectList<[HasFunctionProto], ErrorDiag>;
2884+
let Documentation = [ArmAgnosticDocs];
2885+
}
2886+
28802887
def ArmLocallyStreaming : InheritableAttr, TargetSpecificAttr<TargetAArch64> {
28812888
let Spellings = [RegularKeyword<"__arm_locally_streaming">];
28822889
let Subjects = SubjectList<[Function], ErrorDiag>;

clang/include/clang/Basic/AttrDocs.td

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7635,6 +7635,32 @@ The attributes ``__arm_in(S)``, ``__arm_out(S)``, ``__arm_inout(S)`` and
76357635
}];
76367636
}
76377637

7638+
def ArmAgnosticDocs : Documentation {
7639+
let Category = DocCatArmSmeAttributes;
7640+
let Content = [{
7641+
The ``__arm_agnostic`` keyword applies to prototyped function types and
7642+
affects the function's calling convention for a given state S. This
7643+
attribute allows the user to describe a function that preserves S, without
7644+
requiring the function to share S with its callers and without making
7645+
the assumption that S exists.
7646+
7647+
If a function has the ``__arm_agnostic(S)`` attribute and calls a function
7648+
without this attribute, then the function's object code will contain code
7649+
to preserve state S. Otherwise, the function's object code will be the same
7650+
as if it did not have the attribute.
7651+
7652+
The attribute takes string arguments to describe state S. The supported
7653+
states are:
7654+
7655+
* ``"sme_za_state"`` for state enabled by PSTATE.ZA, such as ZA and ZT0.
7656+
7657+
The attribute ``__arm_agnostic("sme_za_state")`` cannot be used in conjunction
7658+
with ``__arm_in(S)``, ``__arm_out(S)``, ``__arm_inout(S)`` or
7659+
``__arm_preserves(S)`` where state S describes state enabled by PSTATE.ZA,
7660+
such as "za" or "zt0".
7661+
}];
7662+
}
7663+
76387664
def ArmSmeLocallyStreamingDocs : Documentation {
76397665
let Category = DocCatArmSmeAttributes;
76407666
let Content = [{

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3835,6 +3835,9 @@ def err_sme_unimplemented_za_save_restore : Error<
38353835
"call to a function that shares state other than 'za' from a "
38363836
"function that has live 'za' state requires a spill/fill of ZA, which is not yet "
38373837
"implemented">;
3838+
def err_sme_unsupported_agnostic_new : Error<
3839+
"__arm_agnostic(\"sme_za_state\") is not supported together with "
3840+
"__arm_new(\"za\") or __arm_new(\"zt0\")">;
38383841
def note_sme_use_preserves_za : Note<
38393842
"add '__arm_preserves(\"za\")' to the callee if it preserves ZA">;
38403843
def err_sme_definition_using_sm_in_non_sme_target : Error<
@@ -3851,6 +3854,8 @@ def warn_sme_locally_streaming_has_vl_args_returns : Warning<
38513854
"%select{returning|passing}0 a VL-dependent argument %select{from|to}0 a locally streaming function is undefined"
38523855
" behaviour when the streaming and non-streaming vector lengths are different at runtime">,
38533856
InGroup<AArch64SMEAttributes>, DefaultIgnore;
3857+
def err_conflicting_attributes_arm_agnostic : Error<
3858+
"__arm_agnostic(\"sme_za_state\") cannot share ZA state with its caller">;
38543859
def err_conflicting_attributes_arm_state : Error<
38553860
"conflicting attributes for state '%0'">;
38563861
def err_unknown_arm_state : Error<

clang/include/clang/Frontend/CompilerInstance.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,8 +632,6 @@ class CompilerInstance : public ModuleLoader {
632632

633633
llvm::TimerGroup &getTimerGroup() const { return *timerGroup; }
634634

635-
bool hasFrontendTimer() const { return (bool)FrontendTimer; }
636-
637635
llvm::Timer &getFrontendTimer() const {
638636
assert(FrontendTimer && "Compiler instance has no frontend timer!");
639637
return *FrontendTimer;

clang/lib/AST/ItaniumMangle.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3585,13 +3585,15 @@ void CXXNameMangler::mangleSMEAttrs(unsigned SMEAttrs) {
35853585
else if (SMEAttrs & FunctionType::SME_PStateSMCompatibleMask)
35863586
Bitmask |= AAPCSBitmaskSME::ArmStreamingCompatibleBit;
35873587

3588-
// TODO: Must represent __arm_agnostic("sme_za_state")
3589-
3590-
Bitmask |= encodeAAPCSZAState(FunctionType::getArmZAState(SMEAttrs))
3591-
<< AAPCSBitmaskSME::ZA_Shift;
3588+
if (SMEAttrs & FunctionType::SME_AgnosticZAStateMask)
3589+
Bitmask |= AAPCSBitmaskSME::ArmAgnosticSMEZAStateBit;
3590+
else {
3591+
Bitmask |= encodeAAPCSZAState(FunctionType::getArmZAState(SMEAttrs))
3592+
<< AAPCSBitmaskSME::ZA_Shift;
35923593

3593-
Bitmask |= encodeAAPCSZAState(FunctionType::getArmZT0State(SMEAttrs))
3594-
<< AAPCSBitmaskSME::ZT0_Shift;
3594+
Bitmask |= encodeAAPCSZAState(FunctionType::getArmZT0State(SMEAttrs))
3595+
<< AAPCSBitmaskSME::ZT0_Shift;
3596+
}
35953597

35963598
Out << "Lj" << static_cast<unsigned>(Bitmask) << "EE";
35973599
}

clang/lib/AST/TypePrinter.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,8 @@ void TypePrinter::printFunctionProtoAfter(const FunctionProtoType *T,
10001000
OS << " __arm_streaming_compatible";
10011001
if (SMEBits & FunctionType::SME_PStateSMEnabledMask)
10021002
OS << " __arm_streaming";
1003+
if (SMEBits & FunctionType::SME_AgnosticZAStateMask)
1004+
OS << "__arm_agnostic(\"sme_za_state\")";
10031005
if (FunctionType::getArmZAState(SMEBits) == FunctionType::ARM_Preserves)
10041006
OS << " __arm_preserves(\"za\")";
10051007
if (FunctionType::getArmZAState(SMEBits) == FunctionType::ARM_In)
@@ -2000,6 +2002,7 @@ void TypePrinter::printAttributedAfter(const AttributedType *T,
20002002
case attr::CmseNSCall:
20012003
case attr::AnnotateType:
20022004
case attr::WebAssemblyFuncref:
2005+
case attr::ArmAgnostic:
20032006
case attr::ArmStreaming:
20042007
case attr::ArmStreamingCompatible:
20052008
case attr::ArmIn:

clang/lib/CodeGen/CGCall.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1780,6 +1780,8 @@ static void AddAttributesFromFunctionProtoType(ASTContext &Ctx,
17801780
FuncAttrs.addAttribute("aarch64_pstate_sm_enabled");
17811781
if (SMEBits & FunctionType::SME_PStateSMCompatibleMask)
17821782
FuncAttrs.addAttribute("aarch64_pstate_sm_compatible");
1783+
if (SMEBits & FunctionType::SME_AgnosticZAStateMask)
1784+
FuncAttrs.addAttribute("aarch64_za_state_agnostic");
17831785

17841786
// ZA
17851787
if (FunctionType::getArmZAState(SMEBits) == FunctionType::ARM_Preserves)

clang/lib/Driver/Driver.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6459,6 +6459,11 @@ std::string Driver::GetFilePath(StringRef Name, const ToolChain &TC) const {
64596459
if (auto P = SearchPaths(TC.getFilePaths()))
64606460
return *P;
64616461

6462+
SmallString<128> R2(ResourceDir);
6463+
llvm::sys::path::append(R2, "..", "..", Name);
6464+
if (llvm::sys::fs::exists(Twine(R2)))
6465+
return std::string(R2);
6466+
64626467
return std::string(Name);
64636468
}
64646469

clang/lib/Frontend/CompilerInstance.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,9 +1038,6 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) {
10381038
<< LLVM_VERSION_STRING << " default target "
10391039
<< llvm::sys::getDefaultTargetTriple() << "\n";
10401040

1041-
if (getCodeGenOpts().TimePasses)
1042-
createFrontendTimer();
1043-
10441041
if (getFrontendOpts().ShowStats || !getFrontendOpts().StatsFile.empty())
10451042
llvm::EnableStatistics(false);
10461043

0 commit comments

Comments
 (0)