blob: 7e57a1ca557629fdf696358c3ad8786ea246d08a [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//====- ARMMachineFuctionInfo.h - ARM machine function info -----*- C++ -*-===//
Jim Grosbach770d7182009-08-11 15:33:49 +00002//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Jim Grosbach770d7182009-08-11 15:33:49 +00007//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00008//===----------------------------------------------------------------------===//
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"
Dan Gohman1e57df32008-02-10 18:45:23 +000019#include "llvm/Target/TargetRegisterInfo.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000020#include "llvm/Target/TargetMachine.h"
21#include "llvm/ADT/BitVector.h"
22
23namespace llvm {
24
25/// ARMFunctionInfo - This class is derived from MachineFunction private
26/// ARM target-specific information for each MachineFunction.
27class 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
David Goodwinf6154702009-06-30 18:04:13 +000033 /// 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
Dan Gohmanf17a25c2007-07-18 16:29:46 +000038 /// 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 /// LRSpilledForFarJump - True if the LR register has been for spilled to
47 /// enable far jump.
48 bool LRSpilledForFarJump;
49
Dan Gohmanf17a25c2007-07-18 16:29:46 +000050 /// FramePtrSpillOffset - If HasStackFrame, this records the frame pointer
51 /// spill stack offset.
52 unsigned FramePtrSpillOffset;
53
54 /// GPRCS1Offset, GPRCS2Offset, DPRCSOffset - Starting offset of callee saved
55 /// register spills areas. For Mac OS X:
56 ///
57 /// GPR callee-saved (1) : r4, r5, r6, r7, lr
58 /// --------------------------------------------
59 /// GPR callee-saved (2) : r8, r10, r11
60 /// --------------------------------------------
61 /// DPR callee-saved : d8 - d15
62 unsigned GPRCS1Offset;
63 unsigned GPRCS2Offset;
64 unsigned DPRCSOffset;
65
66 /// GPRCS1Size, GPRCS2Size, DPRCSSize - Sizes of callee saved register spills
67 /// areas.
68 unsigned GPRCS1Size;
69 unsigned GPRCS2Size;
70 unsigned DPRCSSize;
71
72 /// GPRCS1Frames, GPRCS2Frames, DPRCSFrames - Keeps track of frame indices
73 /// which belong to these spill areas.
74 BitVector GPRCS1Frames;
75 BitVector GPRCS2Frames;
76 BitVector DPRCSFrames;
77
78 /// SpilledCSRegs - A BitVector mask of all spilled callee-saved registers.
79 ///
80 BitVector SpilledCSRegs;
81
82 /// JumpTableUId - Unique id for jumptables.
83 ///
84 unsigned JumpTableUId;
85
Evan Chengd3c573a2008-11-08 00:51:41 +000086 unsigned ConstPoolEntryUId;
87
Dan Gohmand80404c2010-04-17 14:41:14 +000088 /// VarArgsFrameIndex - FrameIndex for start of varargs area.
89 int VarArgsFrameIndex;
90
Evan Cheng24ff0562010-06-18 23:09:54 +000091 /// HasITBlocks - True if IT blocks have been inserted.
92 bool HasITBlocks;
93
Dan Gohmanf17a25c2007-07-18 16:29:46 +000094public:
95 ARMFunctionInfo() :
David Goodwinf6154702009-06-30 18:04:13 +000096 isThumb(false),
97 hasThumb2(false),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000098 VarArgsRegSaveSize(0), HasStackFrame(false),
Jim Grosbach508ceee2009-10-08 01:50:26 +000099 LRSpilledForFarJump(false),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000100 FramePtrSpillOffset(0), GPRCS1Offset(0), GPRCS2Offset(0), DPRCSOffset(0),
101 GPRCS1Size(0), GPRCS2Size(0), DPRCSSize(0),
102 GPRCS1Frames(0), GPRCS2Frames(0), DPRCSFrames(0),
Evan Cheng24ff0562010-06-18 23:09:54 +0000103 JumpTableUId(0), ConstPoolEntryUId(0), VarArgsFrameIndex(0),
104 HasITBlocks(false) {}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000105
Dan Gohman54eb1222009-06-05 23:05:51 +0000106 explicit ARMFunctionInfo(MachineFunction &MF) :
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000107 isThumb(MF.getTarget().getSubtarget<ARMSubtarget>().isThumb()),
David Goodwinf6154702009-06-30 18:04:13 +0000108 hasThumb2(MF.getTarget().getSubtarget<ARMSubtarget>().hasThumb2()),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000109 VarArgsRegSaveSize(0), HasStackFrame(false),
Jim Grosbach508ceee2009-10-08 01:50:26 +0000110 LRSpilledForFarJump(false),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000111 FramePtrSpillOffset(0), GPRCS1Offset(0), GPRCS2Offset(0), DPRCSOffset(0),
112 GPRCS1Size(0), GPRCS2Size(0), DPRCSSize(0),
113 GPRCS1Frames(32), GPRCS2Frames(32), DPRCSFrames(32),
114 SpilledCSRegs(MF.getTarget().getRegisterInfo()->getNumRegs()),
Evan Cheng24ff0562010-06-18 23:09:54 +0000115 JumpTableUId(0), ConstPoolEntryUId(0), VarArgsFrameIndex(0),
116 HasITBlocks(false) {}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000117
118 bool isThumbFunction() const { return isThumb; }
David Goodwin4a897932009-07-08 23:10:31 +0000119 bool isThumb1OnlyFunction() const { return isThumb && !hasThumb2; }
David Goodwinf6154702009-06-30 18:04:13 +0000120 bool isThumb2Function() const { return isThumb && hasThumb2; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000121
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000122 unsigned getVarArgsRegSaveSize() const { return VarArgsRegSaveSize; }
123 void setVarArgsRegSaveSize(unsigned s) { VarArgsRegSaveSize = s; }
124
125 bool hasStackFrame() const { return HasStackFrame; }
126 void setHasStackFrame(bool s) { HasStackFrame = s; }
127
128 bool isLRSpilledForFarJump() const { return LRSpilledForFarJump; }
129 void setLRIsSpilledForFarJump(bool s) { LRSpilledForFarJump = s; }
130
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000131 unsigned getFramePtrSpillOffset() const { return FramePtrSpillOffset; }
132 void setFramePtrSpillOffset(unsigned o) { FramePtrSpillOffset = o; }
Jim Grosbach770d7182009-08-11 15:33:49 +0000133
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000134 unsigned getGPRCalleeSavedArea1Offset() const { return GPRCS1Offset; }
135 unsigned getGPRCalleeSavedArea2Offset() const { return GPRCS2Offset; }
136 unsigned getDPRCalleeSavedAreaOffset() const { return DPRCSOffset; }
137
138 void setGPRCalleeSavedArea1Offset(unsigned o) { GPRCS1Offset = o; }
139 void setGPRCalleeSavedArea2Offset(unsigned o) { GPRCS2Offset = o; }
140 void setDPRCalleeSavedAreaOffset(unsigned o) { DPRCSOffset = o; }
141
142 unsigned getGPRCalleeSavedArea1Size() const { return GPRCS1Size; }
143 unsigned getGPRCalleeSavedArea2Size() const { return GPRCS2Size; }
144 unsigned getDPRCalleeSavedAreaSize() const { return DPRCSSize; }
145
146 void setGPRCalleeSavedArea1Size(unsigned s) { GPRCS1Size = s; }
147 void setGPRCalleeSavedArea2Size(unsigned s) { GPRCS2Size = s; }
148 void setDPRCalleeSavedAreaSize(unsigned s) { DPRCSSize = s; }
149
150 bool isGPRCalleeSavedArea1Frame(int fi) const {
151 if (fi < 0 || fi >= (int)GPRCS1Frames.size())
152 return false;
153 return GPRCS1Frames[fi];
154 }
155 bool isGPRCalleeSavedArea2Frame(int fi) const {
156 if (fi < 0 || fi >= (int)GPRCS2Frames.size())
157 return false;
158 return GPRCS2Frames[fi];
159 }
160 bool isDPRCalleeSavedAreaFrame(int fi) const {
161 if (fi < 0 || fi >= (int)DPRCSFrames.size())
162 return false;
163 return DPRCSFrames[fi];
164 }
165
166 void addGPRCalleeSavedArea1Frame(int fi) {
167 if (fi >= 0) {
168 int Size = GPRCS1Frames.size();
169 if (fi >= Size) {
170 Size *= 2;
171 if (fi >= Size)
172 Size = fi+1;
173 GPRCS1Frames.resize(Size);
174 }
175 GPRCS1Frames[fi] = true;
176 }
177 }
178 void addGPRCalleeSavedArea2Frame(int fi) {
179 if (fi >= 0) {
180 int Size = GPRCS2Frames.size();
181 if (fi >= Size) {
182 Size *= 2;
183 if (fi >= Size)
184 Size = fi+1;
185 GPRCS2Frames.resize(Size);
186 }
187 GPRCS2Frames[fi] = true;
188 }
189 }
190 void addDPRCalleeSavedAreaFrame(int fi) {
191 if (fi >= 0) {
192 int Size = DPRCSFrames.size();
193 if (fi >= Size) {
194 Size *= 2;
195 if (fi >= Size)
196 Size = fi+1;
197 DPRCSFrames.resize(Size);
198 }
199 DPRCSFrames[fi] = true;
200 }
201 }
202
203 void setCSRegisterIsSpilled(unsigned Reg) {
204 SpilledCSRegs.set(Reg);
205 }
206
Evan Chengd3c573a2008-11-08 00:51:41 +0000207 bool isCSRegisterSpilled(unsigned Reg) const {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000208 return SpilledCSRegs[Reg];
209 }
210
211 const BitVector &getSpilledCSRegisters() const {
212 return SpilledCSRegs;
213 }
214
215 unsigned createJumpTableUId() {
216 return JumpTableUId++;
217 }
Evan Chengd3c573a2008-11-08 00:51:41 +0000218
219 unsigned getNumJumpTables() const {
220 return JumpTableUId;
221 }
222
223 void initConstPoolEntryUId(unsigned UId) {
224 ConstPoolEntryUId = UId;
225 }
226
227 unsigned getNumConstPoolEntries() const {
228 return ConstPoolEntryUId;
229 }
230
231 unsigned createConstPoolEntryUId() {
232 return ConstPoolEntryUId++;
233 }
Dan Gohmand80404c2010-04-17 14:41:14 +0000234
235 int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
236 void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; }
Evan Cheng24ff0562010-06-18 23:09:54 +0000237
238 bool hasITBlocks() const { return HasITBlocks; }
239 void setHasITBlocks(bool h) { HasITBlocks = h; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000240};
241} // End llvm namespace
242
243#endif // ARMMACHINEFUNCTIONINFO_H