1 //===-- ARMMachineFuctionInfo.h - ARM machine function info -----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares ARM-specific per-machine-function information.
12 //===----------------------------------------------------------------------===//
14 #ifndef ARMMACHINEFUNCTIONINFO_H
15 #define ARMMACHINEFUNCTIONINFO_H
17 #include "ARMSubtarget.h"
18 #include "llvm/ADT/BitVector.h"
19 #include "llvm/CodeGen/MachineFunction.h"
20 #include "llvm/Target/TargetMachine.h"
21 #include "llvm/Target/TargetRegisterInfo.h"
25 /// ARMFunctionInfo - This class is derived from MachineFunctionInfo and
26 /// contains private ARM-specific information for each MachineFunction.
27 class ARMFunctionInfo : public MachineFunctionInfo {
28 virtual void anchor();
30 /// isThumb - True if this function is compiled under Thumb mode.
31 /// Used to initialized Align, so must precede it.
34 /// hasThumb2 - True if the target architecture supports Thumb2. Do not use
35 /// to determine if function is compiled under Thumb mode, for that use
39 /// StByValParamsPadding - For parameter that is split between
40 /// GPRs and memory; while recovering GPRs part, when
41 /// StackAlignment == 8, and GPRs-part-size mod 8 != 0,
42 /// we need to insert gap before parameter start address. It allows to
43 /// "attach" GPR-part to the part that was passed via stack.
44 unsigned StByValParamsPadding;
46 /// VarArgsRegSaveSize - Size of the register save area for vararg functions.
48 unsigned ArgRegsSaveSize;
50 /// HasStackFrame - True if this function has a stack frame. Set by
51 /// processFunctionBeforeCalleeSavedScan().
54 /// RestoreSPFromFP - True if epilogue should restore SP from FP. Set by
58 /// LRSpilledForFarJump - True if the LR register has been for spilled to
60 bool LRSpilledForFarJump;
62 /// FramePtrSpillOffset - If HasStackFrame, this records the frame pointer
63 /// spill stack offset.
64 unsigned FramePtrSpillOffset;
66 /// GPRCS1Offset, GPRCS2Offset, DPRCSOffset - Starting offset of callee saved
67 /// register spills areas. For Mac OS X:
69 /// GPR callee-saved (1) : r4, r5, r6, r7, lr
70 /// --------------------------------------------
71 /// GPR callee-saved (2) : r8, r10, r11
72 /// --------------------------------------------
73 /// DPR callee-saved : d8 - d15
75 /// Also see AlignedDPRCSRegs below. Not all D-regs need to go in area 3.
76 /// Some may be spilled after the stack has been realigned.
77 unsigned GPRCS1Offset;
78 unsigned GPRCS2Offset;
81 /// GPRCS1Size, GPRCS2Size, DPRCSSize - Sizes of callee saved register spills
87 /// NumAlignedDPRCS2Regs - The number of callee-saved DPRs that are saved in
88 /// the aligned portion of the stack frame. This is always a contiguous
89 /// sequence of D-registers starting from d8.
91 /// We do not keep track of the frame indices used for these registers - they
92 /// behave like any other frame index in the aligned stack frame. These
93 /// registers also aren't included in DPRCSSize above.
94 unsigned NumAlignedDPRCS2Regs;
96 /// JumpTableUId - Unique id for jumptables.
98 unsigned JumpTableUId;
100 unsigned PICLabelUId;
102 /// VarArgsFrameIndex - FrameIndex for start of varargs area.
103 int VarArgsFrameIndex;
105 /// HasITBlocks - True if IT blocks have been inserted.
108 /// CPEClones - Track constant pool entries clones created by Constant Island
110 DenseMap<unsigned, unsigned> CPEClones;
112 /// GlobalBaseReg - keeps track of the virtual register initialized for
113 /// use as the global base register. This is used for PIC in some PIC
114 /// relocation models.
115 unsigned GlobalBaseReg;
121 ArgRegsSaveSize(0), HasStackFrame(false), RestoreSPFromFP(false),
122 LRSpilledForFarJump(false),
123 FramePtrSpillOffset(0), GPRCS1Offset(0), GPRCS2Offset(0), DPRCSOffset(0),
124 GPRCS1Size(0), GPRCS2Size(0), DPRCSSize(0),
125 NumAlignedDPRCS2Regs(0),
126 JumpTableUId(0), PICLabelUId(0),
127 VarArgsFrameIndex(0), HasITBlocks(false), GlobalBaseReg(0) {}
129 explicit ARMFunctionInfo(MachineFunction &MF) :
130 isThumb(MF.getTarget().getSubtarget<ARMSubtarget>().isThumb()),
131 hasThumb2(MF.getTarget().getSubtarget<ARMSubtarget>().hasThumb2()),
132 StByValParamsPadding(0),
133 ArgRegsSaveSize(0), HasStackFrame(false), RestoreSPFromFP(false),
134 LRSpilledForFarJump(false),
135 FramePtrSpillOffset(0), GPRCS1Offset(0), GPRCS2Offset(0), DPRCSOffset(0),
136 GPRCS1Size(0), GPRCS2Size(0), DPRCSSize(0),
137 JumpTableUId(0), PICLabelUId(0),
138 VarArgsFrameIndex(0), HasITBlocks(false), GlobalBaseReg(0) {}
140 bool isThumbFunction() const { return isThumb; }
141 bool isThumb1OnlyFunction() const { return isThumb && !hasThumb2; }
142 bool isThumb2Function() const { return isThumb && hasThumb2; }
144 unsigned getStoredByValParamsPadding() const { return StByValParamsPadding; }
145 void setStoredByValParamsPadding(unsigned p) { StByValParamsPadding = p; }
147 unsigned getArgRegsSaveSize(unsigned Align = 0) const {
149 return ArgRegsSaveSize;
150 return (ArgRegsSaveSize + Align - 1) & ~(Align - 1);
152 void setArgRegsSaveSize(unsigned s) { ArgRegsSaveSize = s; }
154 bool hasStackFrame() const { return HasStackFrame; }
155 void setHasStackFrame(bool s) { HasStackFrame = s; }
157 bool shouldRestoreSPFromFP() const { return RestoreSPFromFP; }
158 void setShouldRestoreSPFromFP(bool s) { RestoreSPFromFP = s; }
160 bool isLRSpilledForFarJump() const { return LRSpilledForFarJump; }
161 void setLRIsSpilledForFarJump(bool s) { LRSpilledForFarJump = s; }
163 unsigned getFramePtrSpillOffset() const { return FramePtrSpillOffset; }
164 void setFramePtrSpillOffset(unsigned o) { FramePtrSpillOffset = o; }
166 unsigned getNumAlignedDPRCS2Regs() const { return NumAlignedDPRCS2Regs; }
167 void setNumAlignedDPRCS2Regs(unsigned n) { NumAlignedDPRCS2Regs = n; }
169 unsigned getGPRCalleeSavedArea1Offset() const { return GPRCS1Offset; }
170 unsigned getGPRCalleeSavedArea2Offset() const { return GPRCS2Offset; }
171 unsigned getDPRCalleeSavedAreaOffset() const { return DPRCSOffset; }
173 void setGPRCalleeSavedArea1Offset(unsigned o) { GPRCS1Offset = o; }
174 void setGPRCalleeSavedArea2Offset(unsigned o) { GPRCS2Offset = o; }
175 void setDPRCalleeSavedAreaOffset(unsigned o) { DPRCSOffset = o; }
177 unsigned getGPRCalleeSavedArea1Size() const { return GPRCS1Size; }
178 unsigned getGPRCalleeSavedArea2Size() const { return GPRCS2Size; }
179 unsigned getDPRCalleeSavedAreaSize() const { return DPRCSSize; }
181 void setGPRCalleeSavedArea1Size(unsigned s) { GPRCS1Size = s; }
182 void setGPRCalleeSavedArea2Size(unsigned s) { GPRCS2Size = s; }
183 void setDPRCalleeSavedAreaSize(unsigned s) { DPRCSSize = s; }
185 unsigned createJumpTableUId() {
186 return JumpTableUId++;
189 unsigned getNumJumpTables() const {
193 void initPICLabelUId(unsigned UId) {
197 unsigned getNumPICLabels() const {
201 unsigned createPICLabelUId() {
202 return PICLabelUId++;
205 int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
206 void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; }
208 bool hasITBlocks() const { return HasITBlocks; }
209 void setHasITBlocks(bool h) { HasITBlocks = h; }
211 unsigned getGlobalBaseReg() const { return GlobalBaseReg; }
212 void setGlobalBaseReg(unsigned Reg) { GlobalBaseReg = Reg; }
214 void recordCPEClone(unsigned CPIdx, unsigned CPCloneIdx) {
215 if (!CPEClones.insert(std::make_pair(CPCloneIdx, CPIdx)).second)
216 assert(0 && "Duplicate entries!");
219 unsigned getOriginalCPIdx(unsigned CloneIdx) const {
220 DenseMap<unsigned, unsigned>::const_iterator I = CPEClones.find(CloneIdx);
221 if (I != CPEClones.end())
227 } // End llvm namespace
229 #endif // ARMMACHINEFUNCTIONINFO_H