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 /// Align - required alignment. ARM functions and Thumb functions with
34 /// constant pools require 4-byte alignment; other Thumb functions
35 /// require only 2-byte alignment.
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 /// R3IsLiveIn - True if R3 is live in to this function.
51 /// FIXME: Remove when register scavenger for Thumb is done.
54 /// FramePtrSpillOffset - If HasStackFrame, this records the frame pointer
55 /// spill stack offset.
56 unsigned FramePtrSpillOffset
;
58 /// GPRCS1Offset, GPRCS2Offset, DPRCSOffset - Starting offset of callee saved
59 /// register spills areas. For Mac OS X:
61 /// GPR callee-saved (1) : r4, r5, r6, r7, lr
62 /// --------------------------------------------
63 /// GPR callee-saved (2) : r8, r10, r11
64 /// --------------------------------------------
65 /// DPR callee-saved : d8 - d15
66 unsigned GPRCS1Offset
;
67 unsigned GPRCS2Offset
;
70 /// GPRCS1Size, GPRCS2Size, DPRCSSize - Sizes of callee saved register spills
76 /// GPRCS1Frames, GPRCS2Frames, DPRCSFrames - Keeps track of frame indices
77 /// which belong to these spill areas.
78 BitVector GPRCS1Frames
;
79 BitVector GPRCS2Frames
;
80 BitVector DPRCSFrames
;
82 /// SpilledCSRegs - A BitVector mask of all spilled callee-saved registers.
84 BitVector SpilledCSRegs
;
86 /// JumpTableUId - Unique id for jumptables.
88 unsigned JumpTableUId
;
90 unsigned ConstPoolEntryUId
;
96 VarArgsRegSaveSize(0), HasStackFrame(false),
97 LRSpilledForFarJump(false), R3IsLiveIn(false),
98 FramePtrSpillOffset(0), GPRCS1Offset(0), GPRCS2Offset(0), DPRCSOffset(0),
99 GPRCS1Size(0), GPRCS2Size(0), DPRCSSize(0),
100 GPRCS1Frames(0), GPRCS2Frames(0), DPRCSFrames(0),
101 JumpTableUId(0), ConstPoolEntryUId(0) {}
103 ARMFunctionInfo(MachineFunction
&MF
) :
104 isThumb(MF
.getTarget().getSubtarget
<ARMSubtarget
>().isThumb()),
105 Align(isThumb
? 1U : 2U),
106 VarArgsRegSaveSize(0), HasStackFrame(false),
107 LRSpilledForFarJump(false), R3IsLiveIn(false),
108 FramePtrSpillOffset(0), GPRCS1Offset(0), GPRCS2Offset(0), DPRCSOffset(0),
109 GPRCS1Size(0), GPRCS2Size(0), DPRCSSize(0),
110 GPRCS1Frames(32), GPRCS2Frames(32), DPRCSFrames(32),
111 SpilledCSRegs(MF
.getTarget().getRegisterInfo()->getNumRegs()),
112 JumpTableUId(0), ConstPoolEntryUId(0) {}
114 bool isThumbFunction() const { return isThumb
; }
116 unsigned getAlign() const { return Align
; }
117 void setAlign(unsigned a
) { Align
= a
; }
119 unsigned getVarArgsRegSaveSize() const { return VarArgsRegSaveSize
; }
120 void setVarArgsRegSaveSize(unsigned s
) { VarArgsRegSaveSize
= s
; }
122 bool hasStackFrame() const { return HasStackFrame
; }
123 void setHasStackFrame(bool s
) { HasStackFrame
= s
; }
125 bool isLRSpilledForFarJump() const { return LRSpilledForFarJump
; }
126 void setLRIsSpilledForFarJump(bool s
) { LRSpilledForFarJump
= s
; }
128 // FIXME: Remove when register scavenger for Thumb is done.
129 bool isR3LiveIn() const { return R3IsLiveIn
; }
130 void setR3IsLiveIn(bool l
) { R3IsLiveIn
= l
; }
132 unsigned getFramePtrSpillOffset() const { return FramePtrSpillOffset
; }
133 void setFramePtrSpillOffset(unsigned o
) { FramePtrSpillOffset
= o
; }
135 unsigned getGPRCalleeSavedArea1Offset() const { return GPRCS1Offset
; }
136 unsigned getGPRCalleeSavedArea2Offset() const { return GPRCS2Offset
; }
137 unsigned getDPRCalleeSavedAreaOffset() const { return DPRCSOffset
; }
139 void setGPRCalleeSavedArea1Offset(unsigned o
) { GPRCS1Offset
= o
; }
140 void setGPRCalleeSavedArea2Offset(unsigned o
) { GPRCS2Offset
= o
; }
141 void setDPRCalleeSavedAreaOffset(unsigned o
) { DPRCSOffset
= o
; }
143 unsigned getGPRCalleeSavedArea1Size() const { return GPRCS1Size
; }
144 unsigned getGPRCalleeSavedArea2Size() const { return GPRCS2Size
; }
145 unsigned getDPRCalleeSavedAreaSize() const { return DPRCSSize
; }
147 void setGPRCalleeSavedArea1Size(unsigned s
) { GPRCS1Size
= s
; }
148 void setGPRCalleeSavedArea2Size(unsigned s
) { GPRCS2Size
= s
; }
149 void setDPRCalleeSavedAreaSize(unsigned s
) { DPRCSSize
= s
; }
151 bool isGPRCalleeSavedArea1Frame(int fi
) const {
152 if (fi
< 0 || fi
>= (int)GPRCS1Frames
.size())
154 return GPRCS1Frames
[fi
];
156 bool isGPRCalleeSavedArea2Frame(int fi
) const {
157 if (fi
< 0 || fi
>= (int)GPRCS2Frames
.size())
159 return GPRCS2Frames
[fi
];
161 bool isDPRCalleeSavedAreaFrame(int fi
) const {
162 if (fi
< 0 || fi
>= (int)DPRCSFrames
.size())
164 return DPRCSFrames
[fi
];
167 void addGPRCalleeSavedArea1Frame(int fi
) {
169 int Size
= GPRCS1Frames
.size();
174 GPRCS1Frames
.resize(Size
);
176 GPRCS1Frames
[fi
] = true;
179 void addGPRCalleeSavedArea2Frame(int fi
) {
181 int Size
= GPRCS2Frames
.size();
186 GPRCS2Frames
.resize(Size
);
188 GPRCS2Frames
[fi
] = true;
191 void addDPRCalleeSavedAreaFrame(int fi
) {
193 int Size
= DPRCSFrames
.size();
198 DPRCSFrames
.resize(Size
);
200 DPRCSFrames
[fi
] = true;
204 void setCSRegisterIsSpilled(unsigned Reg
) {
205 SpilledCSRegs
.set(Reg
);
208 bool isCSRegisterSpilled(unsigned Reg
) const {
209 return SpilledCSRegs
[Reg
];
212 const BitVector
&getSpilledCSRegisters() const {
213 return SpilledCSRegs
;
216 unsigned createJumpTableUId() {
217 return JumpTableUId
++;
220 unsigned getNumJumpTables() const {
224 void initConstPoolEntryUId(unsigned UId
) {
225 ConstPoolEntryUId
= UId
;
228 unsigned getNumConstPoolEntries() const {
229 return ConstPoolEntryUId
;
232 unsigned createConstPoolEntryUId() {
233 return ConstPoolEntryUId
++;
236 } // End llvm namespace
238 #endif // ARMMACHINEFUNCTIONINFO_H