blob: 1f8c58f01abbda1c31fafd21ad707e51148c0b72 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//====- ARMMachineFuctionInfo.h - ARM machine function info -----*- C++ -*-===//
2//
3// 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.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
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"
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
55 /// R3IsLiveIn - True if R3 is live in to this function.
56 /// FIXME: Remove when register scavenger for Thumb is done.
57 bool R3IsLiveIn;
58
59 /// FramePtrSpillOffset - If HasStackFrame, this records the frame pointer
60 /// spill stack offset.
61 unsigned FramePtrSpillOffset;
62
63 /// GPRCS1Offset, GPRCS2Offset, DPRCSOffset - Starting offset of callee saved
64 /// register spills areas. For Mac OS X:
65 ///
66 /// GPR callee-saved (1) : r4, r5, r6, r7, lr
67 /// --------------------------------------------
68 /// GPR callee-saved (2) : r8, r10, r11
69 /// --------------------------------------------
70 /// DPR callee-saved : d8 - d15
71 unsigned GPRCS1Offset;
72 unsigned GPRCS2Offset;
73 unsigned DPRCSOffset;
74
75 /// GPRCS1Size, GPRCS2Size, DPRCSSize - Sizes of callee saved register spills
76 /// areas.
77 unsigned GPRCS1Size;
78 unsigned GPRCS2Size;
79 unsigned DPRCSSize;
80
81 /// GPRCS1Frames, GPRCS2Frames, DPRCSFrames - Keeps track of frame indices
82 /// which belong to these spill areas.
83 BitVector GPRCS1Frames;
84 BitVector GPRCS2Frames;
85 BitVector DPRCSFrames;
86
87 /// SpilledCSRegs - A BitVector mask of all spilled callee-saved registers.
88 ///
89 BitVector SpilledCSRegs;
90
91 /// JumpTableUId - Unique id for jumptables.
92 ///
93 unsigned JumpTableUId;
94
Evan Chengd3c573a2008-11-08 00:51:41 +000095 unsigned ConstPoolEntryUId;
96
Dan Gohmanf17a25c2007-07-18 16:29:46 +000097public:
98 ARMFunctionInfo() :
David Goodwinf6154702009-06-30 18:04:13 +000099 isThumb(false),
100 hasThumb2(false),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000101 Align(2U),
102 VarArgsRegSaveSize(0), HasStackFrame(false),
103 LRSpilledForFarJump(false), R3IsLiveIn(false),
104 FramePtrSpillOffset(0), GPRCS1Offset(0), GPRCS2Offset(0), DPRCSOffset(0),
105 GPRCS1Size(0), GPRCS2Size(0), DPRCSSize(0),
106 GPRCS1Frames(0), GPRCS2Frames(0), DPRCSFrames(0),
Evan Chengd3c573a2008-11-08 00:51:41 +0000107 JumpTableUId(0), ConstPoolEntryUId(0) {}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000108
Dan Gohman54eb1222009-06-05 23:05:51 +0000109 explicit ARMFunctionInfo(MachineFunction &MF) :
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000110 isThumb(MF.getTarget().getSubtarget<ARMSubtarget>().isThumb()),
David Goodwinf6154702009-06-30 18:04:13 +0000111 hasThumb2(MF.getTarget().getSubtarget<ARMSubtarget>().hasThumb2()),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000112 Align(isThumb ? 1U : 2U),
113 VarArgsRegSaveSize(0), HasStackFrame(false),
114 LRSpilledForFarJump(false), R3IsLiveIn(false),
115 FramePtrSpillOffset(0), GPRCS1Offset(0), GPRCS2Offset(0), DPRCSOffset(0),
116 GPRCS1Size(0), GPRCS2Size(0), DPRCSSize(0),
117 GPRCS1Frames(32), GPRCS2Frames(32), DPRCSFrames(32),
118 SpilledCSRegs(MF.getTarget().getRegisterInfo()->getNumRegs()),
Evan Chengd3c573a2008-11-08 00:51:41 +0000119 JumpTableUId(0), ConstPoolEntryUId(0) {}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000120
121 bool isThumbFunction() const { return isThumb; }
David Goodwin4a897932009-07-08 23:10:31 +0000122 bool isThumb1OnlyFunction() const { return isThumb && !hasThumb2; }
David Goodwinf6154702009-06-30 18:04:13 +0000123 bool isThumb2Function() const { return isThumb && hasThumb2; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000124
125 unsigned getAlign() const { return Align; }
126 void setAlign(unsigned a) { Align = a; }
127
128 unsigned getVarArgsRegSaveSize() const { return VarArgsRegSaveSize; }
129 void setVarArgsRegSaveSize(unsigned s) { VarArgsRegSaveSize = s; }
130
131 bool hasStackFrame() const { return HasStackFrame; }
132 void setHasStackFrame(bool s) { HasStackFrame = s; }
133
134 bool isLRSpilledForFarJump() const { return LRSpilledForFarJump; }
135 void setLRIsSpilledForFarJump(bool s) { LRSpilledForFarJump = s; }
136
137 // FIXME: Remove when register scavenger for Thumb is done.
138 bool isR3LiveIn() const { return R3IsLiveIn; }
139 void setR3IsLiveIn(bool l) { R3IsLiveIn = l; }
140
141 unsigned getFramePtrSpillOffset() const { return FramePtrSpillOffset; }
142 void setFramePtrSpillOffset(unsigned o) { FramePtrSpillOffset = o; }
143
144 unsigned getGPRCalleeSavedArea1Offset() const { return GPRCS1Offset; }
145 unsigned getGPRCalleeSavedArea2Offset() const { return GPRCS2Offset; }
146 unsigned getDPRCalleeSavedAreaOffset() const { return DPRCSOffset; }
147
148 void setGPRCalleeSavedArea1Offset(unsigned o) { GPRCS1Offset = o; }
149 void setGPRCalleeSavedArea2Offset(unsigned o) { GPRCS2Offset = o; }
150 void setDPRCalleeSavedAreaOffset(unsigned o) { DPRCSOffset = o; }
151
152 unsigned getGPRCalleeSavedArea1Size() const { return GPRCS1Size; }
153 unsigned getGPRCalleeSavedArea2Size() const { return GPRCS2Size; }
154 unsigned getDPRCalleeSavedAreaSize() const { return DPRCSSize; }
155
156 void setGPRCalleeSavedArea1Size(unsigned s) { GPRCS1Size = s; }
157 void setGPRCalleeSavedArea2Size(unsigned s) { GPRCS2Size = s; }
158 void setDPRCalleeSavedAreaSize(unsigned s) { DPRCSSize = s; }
159
160 bool isGPRCalleeSavedArea1Frame(int fi) const {
161 if (fi < 0 || fi >= (int)GPRCS1Frames.size())
162 return false;
163 return GPRCS1Frames[fi];
164 }
165 bool isGPRCalleeSavedArea2Frame(int fi) const {
166 if (fi < 0 || fi >= (int)GPRCS2Frames.size())
167 return false;
168 return GPRCS2Frames[fi];
169 }
170 bool isDPRCalleeSavedAreaFrame(int fi) const {
171 if (fi < 0 || fi >= (int)DPRCSFrames.size())
172 return false;
173 return DPRCSFrames[fi];
174 }
175
176 void addGPRCalleeSavedArea1Frame(int fi) {
177 if (fi >= 0) {
178 int Size = GPRCS1Frames.size();
179 if (fi >= Size) {
180 Size *= 2;
181 if (fi >= Size)
182 Size = fi+1;
183 GPRCS1Frames.resize(Size);
184 }
185 GPRCS1Frames[fi] = true;
186 }
187 }
188 void addGPRCalleeSavedArea2Frame(int fi) {
189 if (fi >= 0) {
190 int Size = GPRCS2Frames.size();
191 if (fi >= Size) {
192 Size *= 2;
193 if (fi >= Size)
194 Size = fi+1;
195 GPRCS2Frames.resize(Size);
196 }
197 GPRCS2Frames[fi] = true;
198 }
199 }
200 void addDPRCalleeSavedAreaFrame(int fi) {
201 if (fi >= 0) {
202 int Size = DPRCSFrames.size();
203 if (fi >= Size) {
204 Size *= 2;
205 if (fi >= Size)
206 Size = fi+1;
207 DPRCSFrames.resize(Size);
208 }
209 DPRCSFrames[fi] = true;
210 }
211 }
212
213 void setCSRegisterIsSpilled(unsigned Reg) {
214 SpilledCSRegs.set(Reg);
215 }
216
Evan Chengd3c573a2008-11-08 00:51:41 +0000217 bool isCSRegisterSpilled(unsigned Reg) const {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000218 return SpilledCSRegs[Reg];
219 }
220
221 const BitVector &getSpilledCSRegisters() const {
222 return SpilledCSRegs;
223 }
224
225 unsigned createJumpTableUId() {
226 return JumpTableUId++;
227 }
Evan Chengd3c573a2008-11-08 00:51:41 +0000228
229 unsigned getNumJumpTables() const {
230 return JumpTableUId;
231 }
232
233 void initConstPoolEntryUId(unsigned UId) {
234 ConstPoolEntryUId = UId;
235 }
236
237 unsigned getNumConstPoolEntries() const {
238 return ConstPoolEntryUId;
239 }
240
241 unsigned createConstPoolEntryUId() {
242 return ConstPoolEntryUId++;
243 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000244};
245} // End llvm namespace
246
247#endif // ARMMACHINEFUNCTIONINFO_H