LLVM 18.0.0git
AArch64SMEAttributes.cpp
Go to the documentation of this file.
1//===-- AArch64SMEAttributes.cpp - Helper for interpreting SME attributes -===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10#include "llvm/IR/InstrTypes.h"
11#include <cassert>
12
13using namespace llvm;
14
15void SMEAttrs::set(unsigned M, bool Enable) {
16 if (Enable)
17 Bitmask |= M;
18 else
19 Bitmask &= ~M;
20
22 "SM_Enabled and SM_Compatible are mutually exclusive");
24 "ZA_New and ZA_Shared are mutually exclusive");
26 "ZA_New and ZA_Preserved are mutually exclusive");
27 assert(!(hasNewZABody() && (Bitmask & ZA_NoLazySave)) &&
28 "ZA_New and ZA_NoLazySave are mutually exclusive");
29 assert(!(hasSharedZAInterface() && (Bitmask & ZA_NoLazySave)) &&
30 "ZA_Shared and ZA_NoLazySave are mutually exclusive");
31}
32
34 *this = SMEAttrs(CB.getAttributes());
35 if (auto *F = CB.getCalledFunction()) {
36 set(SMEAttrs(*F).Bitmask | SMEAttrs(F->getName()).Bitmask);
37 }
38}
39
40SMEAttrs::SMEAttrs(StringRef FuncName) : Bitmask(0) {
41 if (FuncName == "__arm_tpidr2_save" || FuncName == "__arm_sme_state")
44 if (FuncName == "__arm_tpidr2_restore")
47}
48
50 Bitmask = 0;
51 if (Attrs.hasFnAttr("aarch64_pstate_sm_enabled"))
52 Bitmask |= SM_Enabled;
53 if (Attrs.hasFnAttr("aarch64_pstate_sm_compatible"))
54 Bitmask |= SM_Compatible;
55 if (Attrs.hasFnAttr("aarch64_pstate_sm_body"))
56 Bitmask |= SM_Body;
57 if (Attrs.hasFnAttr("aarch64_pstate_za_shared"))
58 Bitmask |= ZA_Shared;
59 if (Attrs.hasFnAttr("aarch64_pstate_za_new"))
60 Bitmask |= ZA_New;
61 if (Attrs.hasFnAttr("aarch64_pstate_za_preserved"))
62 Bitmask |= ZA_Preserved;
63}
64
65std::optional<bool>
67 bool BodyOverridesInterface) const {
68 // If the transition is not through a call (e.g. when considering inlining)
69 // and Callee has a streaming body, then we can ignore the interface of
70 // Callee.
71 if (BodyOverridesInterface && Callee.hasStreamingBody()) {
72 return hasStreamingInterfaceOrBody() ? std::nullopt
73 : std::optional<bool>(true);
74 }
75
76 if (Callee.hasStreamingCompatibleInterface())
77 return std::nullopt;
78
79 // Both non-streaming
80 if (hasNonStreamingInterfaceAndBody() && Callee.hasNonStreamingInterface())
81 return std::nullopt;
82
83 // Both streaming
84 if (hasStreamingInterfaceOrBody() && Callee.hasStreamingInterface())
85 return std::nullopt;
86
87 return Callee.hasStreamingInterface();
88}
@ Enable
Definition: DwarfDebug.cpp:87
#define F(x, y, z)
Definition: MD5.cpp:55
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1227
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
Definition: InstrTypes.h:1449
AttributeList getAttributes() const
Return the parameter attributes for this call.
Definition: InstrTypes.h:1526
SMEAttrs is a utility class to parse the SME ACLE attributes on functions.
bool hasStreamingInterface() const
bool hasNonStreamingInterfaceAndBody() const
SMEAttrs(unsigned Mask=Normal)
bool hasStreamingCompatibleInterface() const
bool hasStreamingInterfaceOrBody() const
void set(unsigned M, bool Enable=true)
std::optional< bool > requiresSMChange(const SMEAttrs &Callee, bool BodyOverridesInterface=false) const
bool hasNewZABody() const
bool hasSharedZAInterface() const
bool preservesZA() const
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Enable
Enable colors.