LLVM: lib/Target/AArch64/SMEABIPass.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

23#include "llvm/IR/IntrinsicsAArch64.h"

29

30using namespace llvm;

31

32#define DEBUG_TYPE "aarch64-sme-abi"

33

34namespace {

36 static char ID;

38

40

41 void getAnalysisUsage(AnalysisUsage &AU) const override {

43 }

44

45private:

48};

49}

50

51char SMEABI::ID = 0;

52static const char *name = "SME ABI Pass";

54

56

57

58

59

60

61

63 bool ZT0IsUndef = false) {

64 auto &Ctx = M->getContext();

65 auto *TPIDR2SaveTy =

67 auto Attrs =

68 AttributeList().addFnAttribute(Ctx, "aarch64_pstate_sm_compatible");

69 RTLIB::Libcall LC = RTLIB::SMEABI_TPIDR2_SAVE;

71 M->getOrInsertFunction(TLI.getLibcallName(LC), TPIDR2SaveTy, Attrs);

73

74

75

76

77 if (ZT0IsUndef)

79

81

82

85 Builder.CreateCall(WriteIntr->getFunctionType(), WriteIntr,

86 Builder.getInt64(0));

87}

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109bool SMEABI::updateNewStateFunctions(Module *M, Function *F,

112 LLVMContext &Context = F->getContext();

113 BasicBlock *OrigBB = &F->getEntryBlock();

115

116

117

118

119

121

124

125

130 {}, "tpidr2");

131 auto *Cmp = Builder.CreateCmp(ICmpInst::ICMP_NE, TPIDR2,

134

135

138

139

144 }

145

151 }

152

157 {Builder.getInt32(0)});

158 }

159

161

162 for (BasicBlock &BB : *F) {

165 continue;

168 M, Intrinsic::aarch64_sme_za_disable);

170 }

171 }

172

173 F->addFnAttr("aarch64_expanded_pstate_za");

174 return true;

175}

176

177bool SMEABI::runOnFunction(Function &F) {

179 LLVMContext &Context = F.getContext();

181

182 if (F.isDeclaration() || F.hasFnAttribute("aarch64_expanded_pstate_za"))

183 return false;

184

185 const TargetMachine &TM =

186 getAnalysis().getTM();

188

190 SMEAttrs FnAttrs(F);

192 Changed |= updateNewStateFunctions(M, &F, Builder, FnAttrs, TLI);

193

195}

static bool runOnFunction(Function &F, bool PostInlining)

Module.h This file contains the declarations for the Module class.

Machine Check Debug Module

#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)

void emitTPIDR2Save(Module *M, IRBuilder<> &Builder, const TargetLowering &TLI, bool ZT0IsUndef=false)

Definition SMEABIPass.cpp:62

static const char * name

Definition SMEABIPass.cpp:52

This file describes how to lower LLVM code to machine code.

Target-Independent Code Generator Pass Configuration Options pass.

Represent the analysis usage information of a pass.

AnalysisUsage & addRequired()

static LLVM_ABI Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val=0)

Return a uniquified Attribute object.

iterator begin()

Instruction iterator methods.

static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)

Creates a new BasicBlock.

LLVM_ABI BasicBlock * splitBasicBlock(iterator I, const Twine &BBName="", bool Before=false)

Split the basic block into two basic blocks at the specified instruction.

const Instruction & front() const

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.

static LLVM_ABI FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)

This static method is the primary way of constructing a FunctionType.

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.

This provides a uniform API for creating instructions and inserting them into a basic block: either a...

A Module instance is used to store all the information related to an LLVM module.

SMEAttrs is a utility class to parse the SME ACLE attributes on functions.

bool hasPrivateZAInterface() const

CallingConv::ID getLibcallCallingConv(RTLIB::Libcall Call) const

Get the CallingConv that should be used for the specified libcall.

const char * getLibcallName(RTLIB::Libcall Call) const

Get the libcall routine name for the specified libcall.

This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...

virtual const TargetSubtargetInfo * getSubtargetImpl(const Function &) const

Virtual method implemented by subclasses that returns a reference to that target's TargetSubtargetInf...

Target-Independent Code Generator Pass Configuration Options.

virtual const TargetLowering * getTargetLowering() const

unsigned ID

LLVM IR allows to use arbitrary numbers as calling convention identifiers.

@ BasicBlock

Various leaf nodes.

LLVM_ABI Function * getOrInsertDeclaration(Module *M, ID id, ArrayRef< Type * > Tys={})

Look up the Function declaration of the intrinsic id in the Module M.

friend class Instruction

Iterator for Instructions in a `BasicBlock.

This is an optimization pass for GlobalISel generic memory operations.

FunctionPass * createSMEABIPass()

Definition SMEABIPass.cpp:55

bool isa(const From &Val)

isa - Return true if the parameter to the template is an instance of one of the template type argu...

IRBuilder(LLVMContext &, FolderTy, InserterTy, MDNode *, ArrayRef< OperandBundleDef >) -> IRBuilder< FolderTy, InserterTy >