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 /// LRSpilledForFarJump - True if the LR register has been for spilled to
48 bool LRSpilledForFarJump;
50 /// FramePtrSpillOffset - If HasStackFrame, this records the frame pointer
51 /// spill stack offset.
52 unsigned FramePtrSpillOffset;
54 /// GPRCS1Offset, GPRCS2Offset, DPRCSOffset - Starting offset of callee saved
55 /// register spills areas. For Mac OS X:
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;
66 /// GPRCS1Size, GPRCS2Size, DPRCSSize - Sizes of callee saved register spills
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;
78 /// SpilledCSRegs - A BitVector mask of all spilled callee-saved registers.
80 BitVector SpilledCSRegs;
82 /// JumpTableUId - Unique id for jumptables.
84 unsigned JumpTableUId;
86 unsigned ConstPoolEntryUId;
92 VarArgsRegSaveSize(0), HasStackFrame(false),
93 LRSpilledForFarJump(false),
94 FramePtrSpillOffset(0), GPRCS1Offset(0), GPRCS2Offset(0), DPRCSOffset(0),
95 GPRCS1Size(0), GPRCS2Size(0), DPRCSSize(0),
96 GPRCS1Frames(0), GPRCS2Frames(0), DPRCSFrames(0),
97 JumpTableUId(0), ConstPoolEntryUId(0) {}
99 explicit ARMFunctionInfo(MachineFunction &MF) :
100 isThumb(MF.getTarget().getSubtarget<ARMSubtarget>().isThumb()),
101 hasThumb2(MF.getTarget().getSubtarget<ARMSubtarget>().hasThumb2()),
102 VarArgsRegSaveSize(0), HasStackFrame(false),
103 LRSpilledForFarJump(false),
104 FramePtrSpillOffset(0), GPRCS1Offset(0), GPRCS2Offset(0), DPRCSOffset(0),
105 GPRCS1Size(0), GPRCS2Size(0), DPRCSSize(0),
106 GPRCS1Frames(32), GPRCS2Frames(32), DPRCSFrames(32),
107 SpilledCSRegs(MF.getTarget().getRegisterInfo()->getNumRegs()),
108 JumpTableUId(0), ConstPoolEntryUId(0) {}
110 bool isThumbFunction() const { return isThumb; }
111 bool isThumb1OnlyFunction() const { return isThumb && !hasThumb2; }
112 bool isThumb2Function() const { return isThumb && hasThumb2; }
114 unsigned getVarArgsRegSaveSize() const { return VarArgsRegSaveSize; }
115 void setVarArgsRegSaveSize(unsigned s) { VarArgsRegSaveSize = s; }
117 bool hasStackFrame() const { return HasStackFrame; }
118 void setHasStackFrame(bool s) { HasStackFrame = s; }
120 bool isLRSpilledForFarJump() const { return LRSpilledForFarJump; }
121 void setLRIsSpilledForFarJump(bool s) { LRSpilledForFarJump = s; }
123 unsigned getFramePtrSpillOffset() const { return FramePtrSpillOffset; }
124 void setFramePtrSpillOffset(unsigned o) { FramePtrSpillOffset = o; }
126 unsigned getGPRCalleeSavedArea1Offset() const { return GPRCS1Offset; }
127 unsigned getGPRCalleeSavedArea2Offset() const { return GPRCS2Offset; }
128 unsigned getDPRCalleeSavedAreaOffset() const { return DPRCSOffset; }
130 void setGPRCalleeSavedArea1Offset(unsigned o) { GPRCS1Offset = o; }
131 void setGPRCalleeSavedArea2Offset(unsigned o) { GPRCS2Offset = o; }
132 void setDPRCalleeSavedAreaOffset(unsigned o) { DPRCSOffset = o; }
134 unsigned getGPRCalleeSavedArea1Size() const { return GPRCS1Size; }
135 unsigned getGPRCalleeSavedArea2Size() const { return GPRCS2Size; }
136 unsigned getDPRCalleeSavedAreaSize() const { return DPRCSSize; }
138 void setGPRCalleeSavedArea1Size(unsigned s) { GPRCS1Size = s; }
139 void setGPRCalleeSavedArea2Size(unsigned s) { GPRCS2Size = s; }
140 void setDPRCalleeSavedAreaSize(unsigned s) { DPRCSSize = s; }
142 bool isGPRCalleeSavedArea1Frame(int fi) const {
143 if (fi < 0 || fi >= (int)GPRCS1Frames.size())
145 return GPRCS1Frames[fi];
147 bool isGPRCalleeSavedArea2Frame(int fi) const {
148 if (fi < 0 || fi >= (int)GPRCS2Frames.size())
150 return GPRCS2Frames[fi];
152 bool isDPRCalleeSavedAreaFrame(int fi) const {
153 if (fi < 0 || fi >= (int)DPRCSFrames.size())
155 return DPRCSFrames[fi];
158 void addGPRCalleeSavedArea1Frame(int fi) {
160 int Size = GPRCS1Frames.size();
165 GPRCS1Frames.resize(Size);
167 GPRCS1Frames[fi] = true;
170 void addGPRCalleeSavedArea2Frame(int fi) {
172 int Size = GPRCS2Frames.size();
177 GPRCS2Frames.resize(Size);
179 GPRCS2Frames[fi] = true;
182 void addDPRCalleeSavedAreaFrame(int fi) {
184 int Size = DPRCSFrames.size();
189 DPRCSFrames.resize(Size);
191 DPRCSFrames[fi] = true;
195 void setCSRegisterIsSpilled(unsigned Reg) {
196 SpilledCSRegs.set(Reg);
199 bool isCSRegisterSpilled(unsigned Reg) const {
200 return SpilledCSRegs[Reg];
203 const BitVector &getSpilledCSRegisters() const {
204 return SpilledCSRegs;
207 unsigned createJumpTableUId() {
208 return JumpTableUId++;
211 unsigned getNumJumpTables() const {
215 void initConstPoolEntryUId(unsigned UId) {
216 ConstPoolEntryUId = UId;
219 unsigned getNumConstPoolEntries() const {
220 return ConstPoolEntryUId;
223 unsigned createConstPoolEntryUId() {
224 return ConstPoolEntryUId++;
227 } // End llvm namespace
229 #endif // ARMMACHINEFUNCTIONINFO_H