LLVM 24.0.0git
PPCMachineFunctionInfo.h
Go to the documentation of this file.
1//===-- PPCMachineFunctionInfo.h - Private data used for PowerPC --*- C++ -*-=//
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//
9// This file declares the PowerPC specific subclass of MachineFunctionInfo.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_LIB_TARGET_POWERPC_PPCMACHINEFUNCTIONINFO_H
14#define LLVM_LIB_TARGET_POWERPC_PPCMACHINEFUNCTIONINFO_H
15
19
20namespace llvm {
21
22class PPCSubtarget;
23
24/// PPCFunctionInfo - This class is derived from MachineFunction private
25/// PowerPC target-specific information for each MachineFunction.
27public:
37
38private:
39 virtual void anchor();
40
41 /// FramePointerSaveIndex - Frame index of where the old frame pointer is
42 /// stored. Also used as an anchor for instructions that need to be altered
43 /// when using frame pointers (dyna_add, dyna_sub.)
44 int FramePointerSaveIndex = 0;
45
46 /// ReturnAddrSaveIndex - Frame index of where the return address is stored.
47 ///
48 int ReturnAddrSaveIndex = 0;
49
50 /// Frame index where the old base pointer is stored.
51 int BasePointerSaveIndex = 0;
52
53 /// Frame index where the old PIC base pointer is stored.
54 int PICBasePointerSaveIndex = 0;
55
56 /// Frame index where the ROP Protection Hash is stored.
57 int ROPProtectionHashSaveIndex = 0;
58
59 /// MustSaveLR - Indicates whether LR is defined (or clobbered) in the current
60 /// function. This is only valid after the initial scan of the function by
61 /// PEI.
62 bool MustSaveLR = false;
63
64 /// MustSaveTOC - Indicates that the TOC save needs to be performed in the
65 /// prologue of the function. This is typically the case when there are
66 /// indirect calls in the function and it is more profitable to save the
67 /// TOC pointer in the prologue than in the block(s) containing the call(s).
68 bool MustSaveTOC = false;
69
70 /// Do we have to disable shrink-wrapping? This has to be set if we emit any
71 /// instructions that clobber LR in the entry block because discovering this
72 /// in PEI is too late (happens after shrink-wrapping);
73 bool ShrinkWrapDisabled = false;
74
75 /// Does this function have any stack spills.
76 bool HasSpills = false;
77
78 /// Does this function spill using instructions with only r+r (not r+i)
79 /// forms.
80 bool HasNonRISpills = false;
81
82 /// SpillsCR - Indicates whether CR is spilled in the current function.
83 bool SpillsCR = false;
84
85 /// DisableNonVolatileCR - Indicates whether non-volatile CR fields would be
86 /// disabled.
87 bool DisableNonVolatileCR = false;
88
89 /// LRStoreRequired - The bool indicates whether there is some explicit use of
90 /// the LR/LR8 stack slot that is not obvious from scanning the code. This
91 /// requires that the code generator produce a store of LR to the stack on
92 /// entry, even though LR may otherwise apparently not be used.
93 bool LRStoreRequired = false;
94
95 /// This function makes use of the PPC64 ELF TOC base pointer (register r2).
96 bool UsesTOCBasePtr = false;
97
98 /// MinReservedArea - This is the frame size that is at least reserved in a
99 /// potential caller (parameter+linkage area).
100 unsigned MinReservedArea = 0;
101
102 /// TailCallSPDelta - Stack pointer delta used when tail calling. Maximum
103 /// amount the stack pointer is adjusted to make the frame bigger for tail
104 /// calls. Used for creating an area before the register spill area.
105 int TailCallSPDelta = 0;
106
107 /// HasFastCall - Does this function contain a fast call. Used to determine
108 /// how the caller's stack pointer should be calculated (epilog/dynamicalloc).
109 bool HasFastCall = false;
110
111 /// VarArgsFrameIndex - FrameIndex for start of varargs area.
112 int VarArgsFrameIndex = 0;
113
114 /// VarArgsStackOffset - StackOffset for start of stack
115 /// arguments.
116
117 int VarArgsStackOffset = 0;
118
119 /// VarArgsNumGPR - Index of the first unused integer
120 /// register for parameter passing.
121 unsigned VarArgsNumGPR = 0;
122
123 /// VarArgsNumFPR - Index of the first unused double
124 /// register for parameter passing.
125 unsigned VarArgsNumFPR = 0;
126
127 /// FixedParmsNum - The number of fixed parameters.
128 unsigned FixedParmsNum = 0;
129
130 /// FloatingParmsNum - The number of floating parameters.
131 unsigned FloatingParmsNum = 0;
132
133 /// VectorParmsNum - The number of vector parameters.
134 unsigned VectorParmsNum = 0;
135
136 /// ParamtersType - Store all the parameter's type that are saved on
137 /// registers.
138 SmallVector<ParamType, 32> ParamtersType;
139
140 /// CRSpillFrameIndex - FrameIndex for CR spill slot for 32-bit SVR4.
141 int CRSpillFrameIndex = 0;
142
143 /// If any of CR[2-4] need to be saved in the prologue and restored in the
144 /// epilogue then they are added to this array. This is used for the
145 /// 64-bit SVR4 ABI.
146 SmallVector<Register, 3> MustSaveCRs;
147
148 /// Whether this uses the PIC Base register or not.
149 bool UsesPICBase = false;
150
151 /// We keep track attributes for each live-in virtual registers
152 /// to use SExt/ZExt flags in later optimization.
153 std::vector<std::pair<Register, ISD::ArgFlagsTy>> LiveInAttrs;
154
155 /// Flags for aix-shared-lib-tls-model-opt, will be lazily initialized for
156 /// each function.
157 bool AIXFuncUseTLSIEForLD = false;
158 bool AIXFuncTLSModelOptInitDone = false;
159
160public:
161 explicit PPCFunctionInfo(const Function &F, const PPCSubtarget *STI);
162
166 const override;
167
168 int getFramePointerSaveIndex() const { return FramePointerSaveIndex; }
169 void setFramePointerSaveIndex(int Idx) { FramePointerSaveIndex = Idx; }
170
171 int getReturnAddrSaveIndex() const { return ReturnAddrSaveIndex; }
172 void setReturnAddrSaveIndex(int idx) { ReturnAddrSaveIndex = idx; }
173
174 int getBasePointerSaveIndex() const { return BasePointerSaveIndex; }
175 void setBasePointerSaveIndex(int Idx) { BasePointerSaveIndex = Idx; }
176
177 int getPICBasePointerSaveIndex() const { return PICBasePointerSaveIndex; }
178 void setPICBasePointerSaveIndex(int Idx) { PICBasePointerSaveIndex = Idx; }
179
181 return ROPProtectionHashSaveIndex;
182 }
184 ROPProtectionHashSaveIndex = Idx;
185 }
186
187 unsigned getMinReservedArea() const { return MinReservedArea; }
188 void setMinReservedArea(unsigned size) { MinReservedArea = size; }
189
190 int getTailCallSPDelta() const { return TailCallSPDelta; }
191 void setTailCallSPDelta(int size) { TailCallSPDelta = size; }
192
193 /// MustSaveLR - This is set when the prolog/epilog inserter does its initial
194 /// scan of the function. It is true if the LR/LR8 register is ever explicitly
195 /// defined/clobbered in the machine function (e.g. by calls and movpctolr,
196 /// which is used in PIC generation), or if the LR stack slot is explicitly
197 /// referenced by builtin_return_address.
198 void setMustSaveLR(bool U) { MustSaveLR = U; }
199 bool mustSaveLR() const { return MustSaveLR; }
200
201 void setMustSaveTOC(bool U) { MustSaveTOC = U; }
202 bool mustSaveTOC() const { return MustSaveTOC; }
203
204 /// We certainly don't want to shrink wrap functions if we've emitted a
205 /// MovePCtoLR8 as that has to go into the entry, so the prologue definitely
206 /// has to go into the entry block.
207 void setShrinkWrapDisabled(bool U) { ShrinkWrapDisabled = U; }
208 bool shrinkWrapDisabled() const { return ShrinkWrapDisabled; }
209
210 void setHasSpills() { HasSpills = true; }
211 bool hasSpills() const { return HasSpills; }
212
213 void setHasNonRISpills() { HasNonRISpills = true; }
214 bool hasNonRISpills() const { return HasNonRISpills; }
215
216 void setSpillsCR() { SpillsCR = true; }
217 bool isCRSpilled() const { return SpillsCR; }
218
219 void setDisableNonVolatileCR() { DisableNonVolatileCR = true; }
220 bool isNonVolatileCRDisabled() const { return DisableNonVolatileCR; }
221
222 void setLRStoreRequired() { LRStoreRequired = true; }
223 bool isLRStoreRequired() const { return LRStoreRequired; }
224
225 void setUsesTOCBasePtr() { UsesTOCBasePtr = true; }
226 bool usesTOCBasePtr() const { return UsesTOCBasePtr; }
227
228 void setHasFastCall() { HasFastCall = true; }
229 bool hasFastCall() const { return HasFastCall;}
230
231 void setAIXFuncTLSModelOptInitDone() { AIXFuncTLSModelOptInitDone = true; }
233 return AIXFuncTLSModelOptInitDone;
234 }
235 void setAIXFuncUseTLSIEForLD() { AIXFuncUseTLSIEForLD = true; }
236 bool isAIXFuncUseTLSIEForLD() const { return AIXFuncUseTLSIEForLD; }
237
238 int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
239 void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; }
240
241 int getVarArgsStackOffset() const { return VarArgsStackOffset; }
242 void setVarArgsStackOffset(int Offset) { VarArgsStackOffset = Offset; }
243
244 unsigned getVarArgsNumGPR() const { return VarArgsNumGPR; }
245 void setVarArgsNumGPR(unsigned Num) { VarArgsNumGPR = Num; }
246
247 unsigned getFixedParmsNum() const { return FixedParmsNum; }
248 unsigned getFloatingPointParmsNum() const { return FloatingParmsNum; }
249 unsigned getVectorParmsNum() const { return VectorParmsNum; }
250 bool hasVectorParms() const { return VectorParmsNum != 0; }
251
252 uint32_t getParmsType() const;
253
255
257
258 unsigned getVarArgsNumFPR() const { return VarArgsNumFPR; }
259 void setVarArgsNumFPR(unsigned Num) { VarArgsNumFPR = Num; }
260
261 /// This function associates attributes for each live-in virtual register.
263 LiveInAttrs.push_back(std::make_pair(VReg, Flags));
264 }
265
266 /// This function returns true if the specified vreg is
267 /// a live-in register and sign-extended.
268 bool isLiveInSExt(Register VReg) const;
269
270 /// This function returns true if the specified vreg is
271 /// a live-in register and zero-extended.
272 bool isLiveInZExt(Register VReg) const;
273
274 int getCRSpillFrameIndex() const { return CRSpillFrameIndex; }
275 void setCRSpillFrameIndex(int idx) { CRSpillFrameIndex = idx; }
276
278 getMustSaveCRs() const { return MustSaveCRs; }
279 void addMustSaveCR(Register Reg) { MustSaveCRs.push_back(Reg); }
280
281 void setUsesPICBase(bool uses) { UsesPICBase = uses; }
282 bool usesPICBase() const { return UsesPICBase; }
283
285
289};
290
291} // end namespace llvm
292
293#endif // LLVM_LIB_TARGET_POWERPC_PPCMACHINEFUNCTIONINFO_H
#define F(x, y, z)
Definition MD5.cpp:54
Register Reg
static bool MustSaveLR(const MachineFunction &MF, MCRegister LR)
MustSaveLR - Return true if this function requires that we save the LR register onto the stack in the...
Basic Register Allocator
This file defines the SmallVector class.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition MCSymbol.h:42
void setVarArgsNumFPR(unsigned Num)
MCSymbol * getPICOffsetSymbol(MachineFunction &MF) const
const SmallVectorImpl< Register > & getMustSaveCRs() const
unsigned getFloatingPointParmsNum() const
bool isLiveInSExt(Register VReg) const
This function returns true if the specified vreg is a live-in register and sign-extended.
MCSymbol * getGlobalEPSymbol(MachineFunction &MF) const
MCSymbol * getLocalEPSymbol(MachineFunction &MF) const
bool isLiveInZExt(Register VReg) const
This function returns true if the specified vreg is a live-in register and zero-extended.
void setShrinkWrapDisabled(bool U)
We certainly don't want to shrink wrap functions if we've emitted a MovePCtoLR8 as that has to go int...
void setVarArgsNumGPR(unsigned Num)
void appendParameterType(ParamType Type)
void addMustSaveCR(Register Reg)
PPCFunctionInfo(const Function &F, const PPCSubtarget *STI)
void setMinReservedArea(unsigned size)
MCSymbol * getTOCOffsetSymbol(MachineFunction &MF) const
unsigned getMinReservedArea() const
void setMustSaveLR(bool U)
MustSaveLR - This is set when the prolog/epilog inserter does its initial scan of the function.
void setVarArgsStackOffset(int Offset)
void addLiveInAttr(Register VReg, ISD::ArgFlagsTy Flags)
This function associates attributes for each live-in virtual register.
void setROPProtectionHashSaveIndex(int Idx)
MachineFunctionInfo * clone(BumpPtrAllocator &Allocator, MachineFunction &DestMF, const DenseMap< MachineBasicBlock *, MachineBasicBlock * > &Src2DstMBB) const override
Make a functionally equivalent copy of this MachineFunctionInfo in MF.
Wrapper class representing virtual and physical registers.
Definition Register.h:20
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:577
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
Definition STLExtras.h:1685
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Definition Allocator.h:391
MachineFunctionInfo - This class can be derived from and used by targets to hold private target-speci...