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/CodeGen/MachineFunction.h"
19 #include "llvm/Target/TargetRegisterInfo.h"
20 #include "llvm/Target/TargetMachine.h"
21 #include "llvm/ADT/BitVector.h"
25 /// ARMFunctionInfo - This class is derived from MachineFunction private
26 /// ARM target-specific information for each MachineFunction.
27 class ARMFunctionInfo : public MachineFunctionInfo {
29 /// isThumb - True if this function is compiled under Thumb mode.
30 /// Used to initialized Align, so must precede it.
33 /// hasThumb2 - True if the target architecture supports Thumb2. Do not use
34 /// to determine if function is compiled under Thumb mode, for that use
38 /// VarArgsRegSaveSize - Size of the register save area for vararg functions.
40 unsigned VarArgsRegSaveSize;
42 /// HasStackFrame - True if this function has a stack frame. Set by
43 /// processFunctionBeforeCalleeSavedScan().
46 /// RestoreSPFromFP - True if epilogue should restore SP from FP. Set by
50 /// LRSpilledForFarJump - True if the LR register has been for spilled to
52 bool LRSpilledForFarJump;
54 /// FramePtrSpillOffset - If HasStackFrame, this records the frame pointer
55 /// spill stack offset.
56 unsigned FramePtrSpillOffset;
58 /// GPRCSOffset, DPRCSOffset - Starting offset of callee saved register
59 /// spills areas (excluding R9 for Mac OS X):
61 /// GPR callee-saved (1) : r4, r5, r6, r7, r8, r9, r10, r11, lr
62 /// --------------------------------------------
63 /// DPR callee-saved : d8 - d15
67 /// GPRCSSize, DPRCSSize - Sizes of callee saved register spills areas.
71 /// GPRCSFrames, DPRCSFrames - Keeps track of frame indices which belong
72 /// to these spill areas.
73 BitVector GPRCSFrames;
74 BitVector DPRCSFrames;
76 /// SpilledCSRegs - A BitVector mask of all spilled callee-saved registers.
78 BitVector SpilledCSRegs;
80 /// JumpTableUId - Unique id for jumptables.
82 unsigned JumpTableUId;
84 unsigned ConstPoolEntryUId;
86 /// VarArgsFrameIndex - FrameIndex for start of varargs area.
87 int VarArgsFrameIndex;
89 /// HasITBlocks - True if IT blocks have been inserted.
96 VarArgsRegSaveSize(0), HasStackFrame(false), RestoreSPFromFP(false),
97 LRSpilledForFarJump(false),
98 FramePtrSpillOffset(0), GPRCSOffset(0), DPRCSOffset(0),
99 GPRCSSize(0), DPRCSSize(0),
100 GPRCSFrames(0), DPRCSFrames(0),
101 JumpTableUId(0), ConstPoolEntryUId(0), VarArgsFrameIndex(0),
102 HasITBlocks(false) {}
104 explicit ARMFunctionInfo(MachineFunction &MF) :
105 isThumb(MF.getTarget().getSubtarget<ARMSubtarget>().isThumb()),
106 hasThumb2(MF.getTarget().getSubtarget<ARMSubtarget>().hasThumb2()),
107 VarArgsRegSaveSize(0), HasStackFrame(false), RestoreSPFromFP(false),
108 LRSpilledForFarJump(false),
109 FramePtrSpillOffset(0), GPRCSOffset(0), DPRCSOffset(0),
110 GPRCSSize(0), DPRCSSize(0),
111 GPRCSFrames(32), DPRCSFrames(32),
112 SpilledCSRegs(MF.getTarget().getRegisterInfo()->getNumRegs()),
113 JumpTableUId(0), ConstPoolEntryUId(0), VarArgsFrameIndex(0),
114 HasITBlocks(false) {}
116 bool isThumbFunction() const { return isThumb; }
117 bool isThumb1OnlyFunction() const { return isThumb && !hasThumb2; }
118 bool isThumb2Function() const { return isThumb && hasThumb2; }
120 unsigned getVarArgsRegSaveSize() const { return VarArgsRegSaveSize; }
121 void setVarArgsRegSaveSize(unsigned s) { VarArgsRegSaveSize = s; }
123 bool hasStackFrame() const { return HasStackFrame; }
124 void setHasStackFrame(bool s) { HasStackFrame = s; }
126 bool shouldRestoreSPFromFP() const { return RestoreSPFromFP; }
127 void setShouldRestoreSPFromFP(bool s) { RestoreSPFromFP = s; }
129 bool isLRSpilledForFarJump() const { return LRSpilledForFarJump; }
130 void setLRIsSpilledForFarJump(bool s) { LRSpilledForFarJump = s; }
132 unsigned getFramePtrSpillOffset() const { return FramePtrSpillOffset; }
133 void setFramePtrSpillOffset(unsigned o) { FramePtrSpillOffset = o; }
135 unsigned getGPRCalleeSavedAreaOffset() const { return GPRCSOffset; }
136 unsigned getDPRCalleeSavedAreaOffset() const { return DPRCSOffset; }
138 void setGPRCalleeSavedAreaOffset(unsigned o) { GPRCSOffset = o; }
139 void setDPRCalleeSavedAreaOffset(unsigned o) { DPRCSOffset = o; }
141 unsigned getGPRCalleeSavedAreaSize() const { return GPRCSSize; }
142 unsigned getDPRCalleeSavedAreaSize() const { return DPRCSSize; }
144 void setGPRCalleeSavedAreaSize(unsigned s) { GPRCSSize = s; }
145 void setDPRCalleeSavedAreaSize(unsigned s) { DPRCSSize = s; }
147 bool isGPRCalleeSavedAreaFrame(int fi) const {
148 if (fi < 0 || fi >= (int)GPRCSFrames.size())
150 return GPRCSFrames[fi];
152 bool isDPRCalleeSavedAreaFrame(int fi) const {
153 if (fi < 0 || fi >= (int)DPRCSFrames.size())
155 return DPRCSFrames[fi];
158 void addGPRCalleeSavedAreaFrame(int fi) {
160 int Size = GPRCSFrames.size();
165 GPRCSFrames.resize(Size);
167 GPRCSFrames[fi] = true;
170 void addDPRCalleeSavedAreaFrame(int fi) {
172 int Size = DPRCSFrames.size();
177 DPRCSFrames.resize(Size);
179 DPRCSFrames[fi] = true;
183 void setCSRegisterIsSpilled(unsigned Reg) {
184 SpilledCSRegs.set(Reg);
187 bool isCSRegisterSpilled(unsigned Reg) const {
188 return SpilledCSRegs[Reg];
191 const BitVector &getSpilledCSRegisters() const {
192 return SpilledCSRegs;
195 unsigned createJumpTableUId() {
196 return JumpTableUId++;
199 unsigned getNumJumpTables() const {
203 void initConstPoolEntryUId(unsigned UId) {
204 ConstPoolEntryUId = UId;
207 unsigned getNumConstPoolEntries() const {
208 return ConstPoolEntryUId;
211 unsigned createConstPoolEntryUId() {
212 return ConstPoolEntryUId++;
215 int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
216 void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; }
218 bool hasITBlocks() const { return HasITBlocks; }
219 void setHasITBlocks(bool h) { HasITBlocks = h; }
221 } // End llvm namespace
223 #endif // ARMMACHINEFUNCTIONINFO_H