Update comments to remove obsolete references.
[oota-llvm.git] / lib / Target / ARM / ARMMachineFunctionInfo.h
1 //====- ARMMachineFuctionInfo.h - ARM machine function info -----*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares ARM-specific per-machine-function information.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef ARMMACHINEFUNCTIONINFO_H
15 #define ARMMACHINEFUNCTIONINFO_H
16
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"
22
23 namespace llvm {
24
25 /// ARMFunctionInfo - This class is derived from MachineFunction private
26 /// ARM target-specific information for each MachineFunction.
27 class ARMFunctionInfo : public MachineFunctionInfo {
28
29   /// isThumb - True if this function is compiled under Thumb mode.
30   /// Used to initialized Align, so must precede it.
31   bool isThumb;
32
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
35   /// 'isThumb'.
36   bool hasThumb2;
37
38   /// VarArgsRegSaveSize - Size of the register save area for vararg functions.
39   ///
40   unsigned VarArgsRegSaveSize;
41
42   /// HasStackFrame - True if this function has a stack frame. Set by
43   /// processFunctionBeforeCalleeSavedScan().
44   bool HasStackFrame;
45
46   /// RestoreSPFromFP - True if epilogue should restore SP from FP. Set by
47   /// emitPrologue.
48   bool RestoreSPFromFP;
49
50   /// LRSpilledForFarJump - True if the LR register has been for spilled to
51   /// enable far jump.
52   bool LRSpilledForFarJump;
53
54   /// FramePtrSpillOffset - If HasStackFrame, this records the frame pointer
55   /// spill stack offset.
56   unsigned FramePtrSpillOffset;
57
58   /// GPRCSOffset, DPRCSOffset - Starting offset of callee saved register
59   /// spills areas (excluding R9 for Mac OS X):
60   ///
61   /// GPR callee-saved (1) : r4, r5, r6, r7, r8, r9, r10, r11, lr
62   /// --------------------------------------------
63   /// DPR callee-saved : d8 - d15
64   unsigned GPRCSOffset;
65   unsigned DPRCSOffset;
66
67   /// GPRCSSize, DPRCSSize - Sizes of callee saved register spills areas.
68   unsigned GPRCSSize;
69   unsigned DPRCSSize;
70
71   /// GPRCSFrames, DPRCSFrames - Keeps track of frame indices which belong
72   /// to these spill areas.
73   BitVector GPRCSFrames;
74   BitVector DPRCSFrames;
75
76   /// SpilledCSRegs - A BitVector mask of all spilled callee-saved registers.
77   ///
78   BitVector SpilledCSRegs;
79
80   /// JumpTableUId - Unique id for jumptables.
81   ///
82   unsigned JumpTableUId;
83
84   unsigned ConstPoolEntryUId;
85
86   /// VarArgsFrameIndex - FrameIndex for start of varargs area.
87   int VarArgsFrameIndex;
88
89   /// HasITBlocks - True if IT blocks have been inserted.
90   bool HasITBlocks;
91
92 public:
93   ARMFunctionInfo() :
94     isThumb(false),
95     hasThumb2(false),
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) {}
103
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) {}
115
116   bool isThumbFunction() const { return isThumb; }
117   bool isThumb1OnlyFunction() const { return isThumb && !hasThumb2; }
118   bool isThumb2Function() const { return isThumb && hasThumb2; }
119
120   unsigned getVarArgsRegSaveSize() const { return VarArgsRegSaveSize; }
121   void setVarArgsRegSaveSize(unsigned s) { VarArgsRegSaveSize = s; }
122
123   bool hasStackFrame() const { return HasStackFrame; }
124   void setHasStackFrame(bool s) { HasStackFrame = s; }
125
126   bool shouldRestoreSPFromFP() const { return RestoreSPFromFP; }
127   void setShouldRestoreSPFromFP(bool s) { RestoreSPFromFP = s; }
128
129   bool isLRSpilledForFarJump() const { return LRSpilledForFarJump; }
130   void setLRIsSpilledForFarJump(bool s) { LRSpilledForFarJump = s; }
131
132   unsigned getFramePtrSpillOffset() const { return FramePtrSpillOffset; }
133   void setFramePtrSpillOffset(unsigned o) { FramePtrSpillOffset = o; }
134
135   unsigned getGPRCalleeSavedAreaOffset() const { return GPRCSOffset; }
136   unsigned getDPRCalleeSavedAreaOffset()  const { return DPRCSOffset; }
137
138   void setGPRCalleeSavedAreaOffset(unsigned o) { GPRCSOffset = o; }
139   void setDPRCalleeSavedAreaOffset(unsigned o)  { DPRCSOffset = o; }
140
141   unsigned getGPRCalleeSavedAreaSize() const { return GPRCSSize; }
142   unsigned getDPRCalleeSavedAreaSize()  const { return DPRCSSize; }
143
144   void setGPRCalleeSavedAreaSize(unsigned s) { GPRCSSize = s; }
145   void setDPRCalleeSavedAreaSize(unsigned s)  { DPRCSSize = s; }
146
147   bool isGPRCalleeSavedAreaFrame(int fi) const {
148     if (fi < 0 || fi >= (int)GPRCSFrames.size())
149       return false;
150     return GPRCSFrames[fi];
151   }
152   bool isDPRCalleeSavedAreaFrame(int fi) const {
153     if (fi < 0 || fi >= (int)DPRCSFrames.size())
154       return false;
155     return DPRCSFrames[fi];
156   }
157
158   void addGPRCalleeSavedAreaFrame(int fi) {
159     if (fi >= 0) {
160       int Size = GPRCSFrames.size();
161       if (fi >= Size) {
162         Size *= 2;
163         if (fi >= Size)
164           Size = fi+1;
165         GPRCSFrames.resize(Size);
166       }
167       GPRCSFrames[fi] = true;
168     }
169   }
170   void addDPRCalleeSavedAreaFrame(int fi) {
171     if (fi >= 0) {
172       int Size = DPRCSFrames.size();
173       if (fi >= Size) {
174         Size *= 2;
175         if (fi >= Size)
176           Size = fi+1;
177         DPRCSFrames.resize(Size);
178       }
179       DPRCSFrames[fi] = true;
180     }
181   }
182
183   void setCSRegisterIsSpilled(unsigned Reg) {
184     SpilledCSRegs.set(Reg);
185   }
186
187   bool isCSRegisterSpilled(unsigned Reg) const {
188     return SpilledCSRegs[Reg];
189   }
190
191   const BitVector &getSpilledCSRegisters() const {
192     return SpilledCSRegs;
193   }
194
195   unsigned createJumpTableUId() {
196     return JumpTableUId++;
197   }
198
199   unsigned getNumJumpTables() const {
200     return JumpTableUId;
201   }
202
203   void initConstPoolEntryUId(unsigned UId) {
204     ConstPoolEntryUId = UId;
205   }
206
207   unsigned getNumConstPoolEntries() const {
208     return ConstPoolEntryUId;
209   }
210
211   unsigned createConstPoolEntryUId() {
212     return ConstPoolEntryUId++;
213   }
214
215   int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
216   void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; }
217
218   bool hasITBlocks() const { return HasITBlocks; }
219   void setHasITBlocks(bool h) { HasITBlocks = h; }
220 };
221 } // End llvm namespace
222
223 #endif // ARMMACHINEFUNCTIONINFO_H