blob: 2176b2735a2b976ca55f8b94d7ffa9662553ef53 [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 /// Align - required alignment. ARM functions and Thumb functions with
39 /// constant pools require 4-byte alignment; other Thumb functions
40 /// require only 2-byte alignment.
41 unsigned Align;
42
43 /// VarArgsRegSaveSize - Size of the register save area for vararg functions.
44 ///
45 unsigned VarArgsRegSaveSize;
46
47 /// HasStackFrame - True if this function has a stack frame. Set by
48 /// processFunctionBeforeCalleeSavedScan().
49 bool HasStackFrame;
50
51 /// LRSpilledForFarJump - True if the LR register has been for spilled to
52 /// enable far jump.
53 bool LRSpilledForFarJump;
54
Dan Gohmanf17a25c2007-07-18 16:29:46 +000055 /// FramePtrSpillOffset - If HasStackFrame, this records the frame pointer
56 /// spill stack offset.
57 unsigned FramePtrSpillOffset;
58
59 /// GPRCS1Offset, GPRCS2Offset, DPRCSOffset - Starting offset of callee saved
60 /// register spills areas. For Mac OS X:
61 ///
62 /// GPR callee-saved (1) : r4, r5, r6, r7, lr
63 /// --------------------------------------------
64 /// GPR callee-saved (2) : r8, r10, r11
65 /// --------------------------------------------
66 /// DPR callee-saved : d8 - d15
67 unsigned GPRCS1Offset;
68 unsigned GPRCS2Offset;
69 unsigned DPRCSOffset;
70
71 /// GPRCS1Size, GPRCS2Size, DPRCSSize - Sizes of callee saved register spills
72 /// areas.
73 unsigned GPRCS1Size;
74 unsigned GPRCS2Size;
75 unsigned DPRCSSize;
76
77 /// GPRCS1Frames, GPRCS2Frames, DPRCSFrames - Keeps track of frame indices
78 /// which belong to these spill areas.
79 BitVector GPRCS1Frames;
80 BitVector GPRCS2Frames;
81 BitVector DPRCSFrames;
82
83 /// SpilledCSRegs - A BitVector mask of all spilled callee-saved registers.
84 ///
85 BitVector SpilledCSRegs;
86
87 /// JumpTableUId - Unique id for jumptables.
88 ///
89 unsigned JumpTableUId;
90
Evan Chengd3c573a2008-11-08 00:51:41 +000091 unsigned ConstPoolEntryUId;
92
Dan Gohmanf17a25c2007-07-18 16:29:46 +000093public:
94 ARMFunctionInfo() :
David Goodwinf6154702009-06-30 18:04:13 +000095 isThumb(false),
96 hasThumb2(false),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000097 Align(2U),
98 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 Chengd3c573a2008-11-08 00:51:41 +0000103 JumpTableUId(0), ConstPoolEntryUId(0) {}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000104
Dan Gohman54eb1222009-06-05 23:05:51 +0000105 explicit ARMFunctionInfo(MachineFunction &MF) :
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000106 isThumb(MF.getTarget().getSubtarget<ARMSubtarget>().isThumb()),
David Goodwinf6154702009-06-30 18:04:13 +0000107 hasThumb2(MF.getTarget().getSubtarget<ARMSubtarget>().hasThumb2()),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000108 Align(isThumb ? 1U : 2U),
109 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 Chengd3c573a2008-11-08 00:51:41 +0000115 JumpTableUId(0), ConstPoolEntryUId(0) {}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000116
117 bool isThumbFunction() const { return isThumb; }
David Goodwin4a897932009-07-08 23:10:31 +0000118 bool isThumb1OnlyFunction() const { return isThumb && !hasThumb2; }
David Goodwinf6154702009-06-30 18:04:13 +0000119 bool isThumb2Function() const { return isThumb && hasThumb2; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000120
121 unsigned getAlign() const { return Align; }
122 void setAlign(unsigned a) { Align = a; }
123
124 unsigned getVarArgsRegSaveSize() const { return VarArgsRegSaveSize; }
125 void setVarArgsRegSaveSize(unsigned s) { VarArgsRegSaveSize = s; }
126
127 bool hasStackFrame() const { return HasStackFrame; }
128 void setHasStackFrame(bool s) { HasStackFrame = s; }
129
130 bool isLRSpilledForFarJump() const { return LRSpilledForFarJump; }
131 void setLRIsSpilledForFarJump(bool s) { LRSpilledForFarJump = s; }
132
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000133 unsigned getFramePtrSpillOffset() const { return FramePtrSpillOffset; }
134 void setFramePtrSpillOffset(unsigned o) { FramePtrSpillOffset = o; }
Jim Grosbach770d7182009-08-11 15:33:49 +0000135
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000136 unsigned getGPRCalleeSavedArea1Offset() const { return GPRCS1Offset; }
137 unsigned getGPRCalleeSavedArea2Offset() const { return GPRCS2Offset; }
138 unsigned getDPRCalleeSavedAreaOffset() const { return DPRCSOffset; }
139
140 void setGPRCalleeSavedArea1Offset(unsigned o) { GPRCS1Offset = o; }
141 void setGPRCalleeSavedArea2Offset(unsigned o) { GPRCS2Offset = o; }
142 void setDPRCalleeSavedAreaOffset(unsigned o) { DPRCSOffset = o; }
143
144 unsigned getGPRCalleeSavedArea1Size() const { return GPRCS1Size; }
145 unsigned getGPRCalleeSavedArea2Size() const { return GPRCS2Size; }
146 unsigned getDPRCalleeSavedAreaSize() const { return DPRCSSize; }
147
148 void setGPRCalleeSavedArea1Size(unsigned s) { GPRCS1Size = s; }
149 void setGPRCalleeSavedArea2Size(unsigned s) { GPRCS2Size = s; }
150 void setDPRCalleeSavedAreaSize(unsigned s) { DPRCSSize = s; }
151
152 bool isGPRCalleeSavedArea1Frame(int fi) const {
153 if (fi < 0 || fi >= (int)GPRCS1Frames.size())
154 return false;
155 return GPRCS1Frames[fi];
156 }
157 bool isGPRCalleeSavedArea2Frame(int fi) const {
158 if (fi < 0 || fi >= (int)GPRCS2Frames.size())
159 return false;
160 return GPRCS2Frames[fi];
161 }
162 bool isDPRCalleeSavedAreaFrame(int fi) const {
163 if (fi < 0 || fi >= (int)DPRCSFrames.size())
164 return false;
165 return DPRCSFrames[fi];
166 }
167
168 void addGPRCalleeSavedArea1Frame(int fi) {
169 if (fi >= 0) {
170 int Size = GPRCS1Frames.size();
171 if (fi >= Size) {
172 Size *= 2;
173 if (fi >= Size)
174 Size = fi+1;
175 GPRCS1Frames.resize(Size);
176 }
177 GPRCS1Frames[fi] = true;
178 }
179 }
180 void addGPRCalleeSavedArea2Frame(int fi) {
181 if (fi >= 0) {
182 int Size = GPRCS2Frames.size();
183 if (fi >= Size) {
184 Size *= 2;
185 if (fi >= Size)
186 Size = fi+1;
187 GPRCS2Frames.resize(Size);
188 }
189 GPRCS2Frames[fi] = true;
190 }
191 }
192 void addDPRCalleeSavedAreaFrame(int fi) {
193 if (fi >= 0) {
194 int Size = DPRCSFrames.size();
195 if (fi >= Size) {
196 Size *= 2;
197 if (fi >= Size)
198 Size = fi+1;
199 DPRCSFrames.resize(Size);
200 }
201 DPRCSFrames[fi] = true;
202 }
203 }
204
205 void setCSRegisterIsSpilled(unsigned Reg) {
206 SpilledCSRegs.set(Reg);
207 }
208
Evan Chengd3c573a2008-11-08 00:51:41 +0000209 bool isCSRegisterSpilled(unsigned Reg) const {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000210 return SpilledCSRegs[Reg];
211 }
212
213 const BitVector &getSpilledCSRegisters() const {
214 return SpilledCSRegs;
215 }
216
217 unsigned createJumpTableUId() {
218 return JumpTableUId++;
219 }
Evan Chengd3c573a2008-11-08 00:51:41 +0000220
221 unsigned getNumJumpTables() const {
222 return JumpTableUId;
223 }
224
225 void initConstPoolEntryUId(unsigned UId) {
226 ConstPoolEntryUId = UId;
227 }
228
229 unsigned getNumConstPoolEntries() const {
230 return ConstPoolEntryUId;
231 }
232
233 unsigned createConstPoolEntryUId() {
234 return ConstPoolEntryUId++;
235 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000236};
237} // End llvm namespace
238
239#endif // ARMMACHINEFUNCTIONINFO_H