LLVM: lib/Target/AArch64/SMEABIPass.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
20#include "llvm/IR/IntrinsicsAArch64.h"
25
26using namespace llvm;
27
28#define DEBUG_TYPE "aarch64-sme-abi"
29
30namespace {
32 static char ID;
35 }
36
38
39private:
42};
43}
44
45char SMEABI::ID = 0;
46static const char *name = "SME ABI Pass";
49
51
52
53
54
55
56
58 auto *TPIDR2SaveTy =
59 FunctionType::get(Builder.getVoidTy(), {}, false);
61 "aarch64_pstate_sm_compatible");
63 M->getOrInsertFunction("__arm_tpidr2_save", TPIDR2SaveTy, Attrs);
65 Call->setCallingConv(
67
68
73}
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95bool SMEABI::updateNewStateFunctions(Module *M, Function *F,
100
101
102
103
104
106
109
110
115 {}, "tpidr2");
116 auto *Cmp = Builder.CreateCmp(ICmpInst::ICMP_NE, TPIDR2,
119
120
123
124
129 }
130
136 }
137
142 {Builder.getInt32(0)});
143 }
144
146
149 if ( || !isa(T))
150 continue;
153 M, Intrinsic::aarch64_sme_za_disable);
155 }
156 }
157
158 F->addFnAttr("aarch64_expanded_pstate_za");
159 return true;
160}
161
162bool SMEABI::runOnFunction(Function &F) {
166
167 if (F.isDeclaration() || F.hasFnAttribute("aarch64_expanded_pstate_za"))
168 return false;
169
170 bool Changed = false;
173 Changed |= updateNewStateFunctions(M, &F, Builder, FnAttrs);
174
175 return Changed;
176}
Module.h This file contains the declarations for the Module class.
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
void emitTPIDR2Save(Module *M, IRBuilder<> &Builder)
AttributeList addFnAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Add a function attribute to the list.
LLVM Basic Block Representation.
iterator begin()
Instruction iterator methods.
const Instruction & front() const
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
BasicBlock * splitBasicBlock(iterator I, const Twine &BBName="", bool Before=false)
Split the basic block into two basic blocks at the specified instruction.
This class represents a function call, abstracting a target machine's calling convention.
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
FunctionPass class - This class is used to implement most global optimizations.
virtual bool runOnFunction(Function &F)=0
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
FunctionType * getFunctionType() const
Returns the FunctionType for me.
ConstantInt * getInt64(uint64_t C)
Get a constant 64-bit value.
ConstantInt * getInt32(uint32_t C)
Get a constant 32-bit value.
Value * CreateCmp(CmpInst::Predicate Pred, Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
BranchInst * CreateCondBr(Value *Cond, BasicBlock *True, BasicBlock *False, MDNode *BranchWeights=nullptr, MDNode *Unpredictable=nullptr)
Create a conditional 'br Cond, TrueDest, FalseDest' instruction.
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value * > Args={}, const Twine &Name="", MDNode *FPMathTag=nullptr)
void SetInsertPoint(BasicBlock *TheBB)
This specifies that created instructions should be appended to the end of the specified block.
Type * getVoidTy()
Fetch the type representing void.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
This is an important class for using LLVM in a threaded context.
A Module instance is used to store all the information related to an LLVM module.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
SMEAttrs is a utility class to parse the SME ACLE attributes on functions.
bool hasPrivateZAInterface() const
@ AArch64_SME_ABI_Support_Routines_PreserveMost_From_X0
Preserve X0-X13, X19-X29, SP, Z0-Z31, P0-P15.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Function * getOrInsertDeclaration(Module *M, ID id, ArrayRef< Type * > Tys={})
Look up the Function declaration of the intrinsic id in the Module M.
This is an optimization pass for GlobalISel generic memory operations.
FunctionPass * createSMEABIPass()
void initializeSMEABIPass(PassRegistry &)