diff options
author | Sander de Smalen <sander.desmalen@arm.com> | 2024-01-15 09:41:32 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-15 09:41:32 +0000 |
commit | 8e7f073eb42c92aa7a2b651ca314d7fcebf296e3 (patch) | |
tree | 1b6b5ddd8c7c88a0228b65dcdb4f0ffec8639e1f /clang/lib/Sema/SemaChecking.cpp | |
parent | 06e3abcb54f339edc2ba757cfa947e024677b21e (diff) | |
download | llvm-8e7f073eb42c92aa7a2b651ca314d7fcebf296e3.zip llvm-8e7f073eb42c92aa7a2b651ca314d7fcebf296e3.tar.gz llvm-8e7f073eb42c92aa7a2b651ca314d7fcebf296e3.tar.bz2 |
[Clang][AArch64] Change SME attributes for shared/new/preserved state. (#76971)
This patch replaces the `__arm_new_za`, `__arm_shared_za` and
`__arm_preserves_za` attributes in favour of:
* `__arm_new("za")`
* `__arm_in("za")`
* `__arm_out("za")`
* `__arm_inout("za")`
* `__arm_preserves("za")`
As described in https://github.com/ARM-software/acle/pull/276.
One change is that `__arm_in/out/inout/preserves(S)` are all mutually
exclusive, whereas previously it was fine to write `__arm_shared_za
__arm_preserves_za`. This case is now represented with `__arm_in("za")`.
The current implementation uses the same LLVM attributes under the hood,
since `__arm_in/out/inout` are all variations of "shared ZA", so can use
the existing `aarch64_pstate_za_shared` attribute in LLVM.
#77941 will add support for the new "zt0" state as introduced
with SME2.
Diffstat (limited to 'clang/lib/Sema/SemaChecking.cpp')
-rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 74f8f62..ace3e38 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -3190,11 +3190,15 @@ static void checkArmStreamingBuiltin(Sema &S, CallExpr *TheCall, } static bool hasSMEZAState(const FunctionDecl *FD) { - if (FD->hasAttr<ArmNewZAAttr>()) - return true; - if (const auto *T = FD->getType()->getAs<FunctionProtoType>()) - if (T->getAArch64SMEAttributes() & FunctionType::SME_PStateZASharedMask) + if (auto *Attr = FD->getAttr<ArmNewAttr>()) + if (Attr->isNewZA()) + return true; + if (const auto *T = FD->getType()->getAs<FunctionProtoType>()) { + FunctionType::ArmStateValue State = + FunctionType::getArmZAState(T->getAArch64SMEAttributes()); + if (State != FunctionType::ARM_None) return true; + } return false; } @@ -7522,14 +7526,19 @@ void Sema::checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto, // If the callee uses AArch64 SME ZA state but the caller doesn't define // any, then this is an error. - if (ExtInfo.AArch64SMEAttributes & FunctionType::SME_PStateZASharedMask) { + FunctionType::ArmStateValue ArmZAState = + FunctionType::getArmZAState(ExtInfo.AArch64SMEAttributes); + if (ArmZAState != FunctionType::ARM_None) { bool CallerHasZAState = false; if (const auto *CallerFD = dyn_cast<FunctionDecl>(CurContext)) { - if (CallerFD->hasAttr<ArmNewZAAttr>()) + auto *Attr = CallerFD->getAttr<ArmNewAttr>(); + if (Attr && Attr->isNewZA()) CallerHasZAState = true; - else if (const auto *FPT = CallerFD->getType()->getAs<FunctionProtoType>()) - CallerHasZAState = FPT->getExtProtoInfo().AArch64SMEAttributes & - FunctionType::SME_PStateZASharedMask; + else if (const auto *FPT = + CallerFD->getType()->getAs<FunctionProtoType>()) + CallerHasZAState = FunctionType::getArmZAState( + FPT->getExtProtoInfo().AArch64SMEAttributes) != + FunctionType::ARM_None; } if (!CallerHasZAState) |