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 /// 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.
43 /// VarArgsRegSaveSize - Size of the register save area for vararg functions.
45 unsigned VarArgsRegSaveSize
;
47 /// HasStackFrame - True if this function has a stack frame. Set by
48 /// processFunctionBeforeCalleeSavedScan().
51 /// LRSpilledForFarJump - True if the LR register has been for spilled to
53 bool LRSpilledForFarJump
;
55 /// R3IsLiveIn - True if R3 is live in to this function.
56 /// FIXME: Remove when register scavenger for Thumb is done.
59 /// FramePtrSpillOffset - If HasStackFrame, this records the frame pointer
60 /// spill stack offset.
61 unsigned FramePtrSpillOffset
;
63 /// GPRCS1Offset, GPRCS2Offset, DPRCSOffset - Starting offset of callee saved
64 /// register spills areas. For Mac OS X:
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
;
75 /// GPRCS1Size, GPRCS2Size, DPRCSSize - Sizes of callee saved register spills
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
;
87 /// SpilledCSRegs - A BitVector mask of all spilled callee-saved registers.
89 BitVector SpilledCSRegs
;
91 /// JumpTableUId - Unique id for jumptables.
93 unsigned JumpTableUId
;
95 unsigned ConstPoolEntryUId
;
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),
107 JumpTableUId(0), ConstPoolEntryUId(0) {}
109 explicit ARMFunctionInfo(MachineFunction
&MF
) :
110 isThumb(MF
.getTarget().getSubtarget
<ARMSubtarget
>().isThumb()),
111 hasThumb2(MF
.getTarget().getSubtarget
<ARMSubtarget
>().hasThumb2()),
112 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()),
119 JumpTableUId(0), ConstPoolEntryUId(0) {}
121 bool isThumbFunction() const { return isThumb
; }
122 bool isThumb1OnlyFunction() const { return isThumb
&& !hasThumb2
; }
123 bool isThumb2Function() const { return isThumb
&& hasThumb2
; }
125 unsigned getAlign() const { return Align
; }
126 void setAlign(unsigned a
) { Align
= a
; }
128 unsigned getVarArgsRegSaveSize() const { return VarArgsRegSaveSize
; }
129 void setVarArgsRegSaveSize(unsigned s
) { VarArgsRegSaveSize
= s
; }
131 bool hasStackFrame() const { return HasStackFrame
; }
132 void setHasStackFrame(bool s
) { HasStackFrame
= s
; }
134 bool isLRSpilledForFarJump() const { return LRSpilledForFarJump
; }
135 void setLRIsSpilledForFarJump(bool s
) { LRSpilledForFarJump
= s
; }
137 // FIXME: Remove when register scavenger for Thumb is done.
138 bool isR3LiveIn() const { return R3IsLiveIn
; }
139 void setR3IsLiveIn(bool l
) { R3IsLiveIn
= l
; }
141 unsigned getFramePtrSpillOffset() const { return FramePtrSpillOffset
; }
142 void setFramePtrSpillOffset(unsigned o
) { FramePtrSpillOffset
= o
; }
144 unsigned getGPRCalleeSavedArea1Offset() const { return GPRCS1Offset
; }
145 unsigned getGPRCalleeSavedArea2Offset() const { return GPRCS2Offset
; }
146 unsigned getDPRCalleeSavedAreaOffset() const { return DPRCSOffset
; }
148 void setGPRCalleeSavedArea1Offset(unsigned o
) { GPRCS1Offset
= o
; }
149 void setGPRCalleeSavedArea2Offset(unsigned o
) { GPRCS2Offset
= o
; }
150 void setDPRCalleeSavedAreaOffset(unsigned o
) { DPRCSOffset
= o
; }
152 unsigned getGPRCalleeSavedArea1Size() const { return GPRCS1Size
; }
153 unsigned getGPRCalleeSavedArea2Size() const { return GPRCS2Size
; }
154 unsigned getDPRCalleeSavedAreaSize() const { return DPRCSSize
; }
156 void setGPRCalleeSavedArea1Size(unsigned s
) { GPRCS1Size
= s
; }
157 void setGPRCalleeSavedArea2Size(unsigned s
) { GPRCS2Size
= s
; }
158 void setDPRCalleeSavedAreaSize(unsigned s
) { DPRCSSize
= s
; }
160 bool isGPRCalleeSavedArea1Frame(int fi
) const {
161 if (fi
< 0 || fi
>= (int)GPRCS1Frames
.size())
163 return GPRCS1Frames
[fi
];
165 bool isGPRCalleeSavedArea2Frame(int fi
) const {
166 if (fi
< 0 || fi
>= (int)GPRCS2Frames
.size())
168 return GPRCS2Frames
[fi
];
170 bool isDPRCalleeSavedAreaFrame(int fi
) const {
171 if (fi
< 0 || fi
>= (int)DPRCSFrames
.size())
173 return DPRCSFrames
[fi
];
176 void addGPRCalleeSavedArea1Frame(int fi
) {
178 int Size
= GPRCS1Frames
.size();
183 GPRCS1Frames
.resize(Size
);
185 GPRCS1Frames
[fi
] = true;
188 void addGPRCalleeSavedArea2Frame(int fi
) {
190 int Size
= GPRCS2Frames
.size();
195 GPRCS2Frames
.resize(Size
);
197 GPRCS2Frames
[fi
] = true;
200 void addDPRCalleeSavedAreaFrame(int fi
) {
202 int Size
= DPRCSFrames
.size();
207 DPRCSFrames
.resize(Size
);
209 DPRCSFrames
[fi
] = true;
213 void setCSRegisterIsSpilled(unsigned Reg
) {
214 SpilledCSRegs
.set(Reg
);
217 bool isCSRegisterSpilled(unsigned Reg
) const {
218 return SpilledCSRegs
[Reg
];
221 const BitVector
&getSpilledCSRegisters() const {
222 return SpilledCSRegs
;
225 unsigned createJumpTableUId() {
226 return JumpTableUId
++;
229 unsigned getNumJumpTables() const {
233 void initConstPoolEntryUId(unsigned UId
) {
234 ConstPoolEntryUId
= UId
;
237 unsigned getNumConstPoolEntries() const {
238 return ConstPoolEntryUId
;
241 unsigned createConstPoolEntryUId() {
242 return ConstPoolEntryUId
++;
245 } // End llvm namespace
247 #endif // ARMMACHINEFUNCTIONINFO_H