1 //====- ARMMachineFuctionInfo.h - ARM machine function info -----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the Evan Cheng and is distributed under
6 // the University of Illinois Open Source 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/MRegisterInfo.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.
33 /// VarArgsRegSaveSize - Size of the register save area for vararg functions.
35 unsigned VarArgsRegSaveSize;
37 /// HasStackFrame - True if this function has a stack frame. Set by
38 /// processFunctionBeforeCalleeSavedScan().
41 /// LRSpilledForFarJump - True if the LR register has been for spilled to
43 bool LRSpilledForFarJump;
45 /// R3IsLiveIn - True if R3 is live in to this function.
46 /// FIXME: Remove when register scavenger for Thumb is done.
49 /// FramePtrSpillOffset - If HasStackFrame, this records the frame pointer
50 /// spill stack offset.
51 unsigned FramePtrSpillOffset;
53 /// GPRCS1Offset, GPRCS2Offset, DPRCSOffset - Starting offset of callee saved
54 /// register spills areas. For Mac OS X:
56 /// GPR callee-saved (1) : r4, r5, r6, r7, lr
57 /// --------------------------------------------
58 /// GPR callee-saved (2) : r8, r10, r11
59 /// --------------------------------------------
60 /// DPR callee-saved : d8 - d15
61 unsigned GPRCS1Offset;
62 unsigned GPRCS2Offset;
65 /// GPRCS1Size, GPRCS2Size, DPRCSSize - Sizes of callee saved register spills
71 /// GPRCS1Frames, GPRCS2Frames, DPRCSFrames - Keeps track of frame indices
72 /// which belong to these spill areas.
73 BitVector GPRCS1Frames;
74 BitVector GPRCS2Frames;
75 BitVector DPRCSFrames;
77 /// SpilledCSRegs - A BitVector mask of all spilled callee-saved registers.
79 BitVector SpilledCSRegs;
81 /// JumpTableUId - Unique id for jumptables.
83 unsigned JumpTableUId;
88 VarArgsRegSaveSize(0), HasStackFrame(false),
89 LRSpilledForFarJump(false), R3IsLiveIn(false),
90 FramePtrSpillOffset(0), GPRCS1Offset(0), GPRCS2Offset(0), DPRCSOffset(0),
91 GPRCS1Size(0), GPRCS2Size(0), DPRCSSize(0),
92 GPRCS1Frames(0), GPRCS2Frames(0), DPRCSFrames(0),
95 ARMFunctionInfo(MachineFunction &MF) :
96 isThumb(MF.getTarget().getSubtarget<ARMSubtarget>().isThumb()),
97 VarArgsRegSaveSize(0), HasStackFrame(false),
98 LRSpilledForFarJump(false), R3IsLiveIn(false),
99 FramePtrSpillOffset(0), GPRCS1Offset(0), GPRCS2Offset(0), DPRCSOffset(0),
100 GPRCS1Size(0), GPRCS2Size(0), DPRCSSize(0),
101 GPRCS1Frames(32), GPRCS2Frames(32), DPRCSFrames(32),
102 SpilledCSRegs(MF.getTarget().getRegisterInfo()->getNumRegs()),
105 bool isThumbFunction() const { return isThumb; }
107 unsigned getVarArgsRegSaveSize() const { return VarArgsRegSaveSize; }
108 void setVarArgsRegSaveSize(unsigned s) { VarArgsRegSaveSize = s; }
110 bool hasStackFrame() const { return HasStackFrame; }
111 void setHasStackFrame(bool s) { HasStackFrame = s; }
113 bool isLRSpilledForFarJump() const { return LRSpilledForFarJump; }
114 void setLRIsSpilledForFarJump(bool s) { LRSpilledForFarJump = s; }
116 // FIXME: Remove when register scavenger for Thumb is done.
117 bool isR3LiveIn() const { return R3IsLiveIn; }
118 void setR3IsLiveIn(bool l) { R3IsLiveIn = l; }
120 unsigned getFramePtrSpillOffset() const { return FramePtrSpillOffset; }
121 void setFramePtrSpillOffset(unsigned o) { FramePtrSpillOffset = o; }
123 unsigned getGPRCalleeSavedArea1Offset() const { return GPRCS1Offset; }
124 unsigned getGPRCalleeSavedArea2Offset() const { return GPRCS2Offset; }
125 unsigned getDPRCalleeSavedAreaOffset() const { return DPRCSOffset; }
127 void setGPRCalleeSavedArea1Offset(unsigned o) { GPRCS1Offset = o; }
128 void setGPRCalleeSavedArea2Offset(unsigned o) { GPRCS2Offset = o; }
129 void setDPRCalleeSavedAreaOffset(unsigned o) { DPRCSOffset = o; }
131 unsigned getGPRCalleeSavedArea1Size() const { return GPRCS1Size; }
132 unsigned getGPRCalleeSavedArea2Size() const { return GPRCS2Size; }
133 unsigned getDPRCalleeSavedAreaSize() const { return DPRCSSize; }
135 void setGPRCalleeSavedArea1Size(unsigned s) { GPRCS1Size = s; }
136 void setGPRCalleeSavedArea2Size(unsigned s) { GPRCS2Size = s; }
137 void setDPRCalleeSavedAreaSize(unsigned s) { DPRCSSize = s; }
139 bool isGPRCalleeSavedArea1Frame(int fi) const {
140 if (fi < 0 || fi >= (int)GPRCS1Frames.size())
142 return GPRCS1Frames[fi];
144 bool isGPRCalleeSavedArea2Frame(int fi) const {
145 if (fi < 0 || fi >= (int)GPRCS2Frames.size())
147 return GPRCS2Frames[fi];
149 bool isDPRCalleeSavedAreaFrame(int fi) const {
150 if (fi < 0 || fi >= (int)DPRCSFrames.size())
152 return DPRCSFrames[fi];
155 void addGPRCalleeSavedArea1Frame(int fi) {
157 int Size = GPRCS1Frames.size();
162 GPRCS1Frames.resize(Size);
164 GPRCS1Frames[fi] = true;
167 void addGPRCalleeSavedArea2Frame(int fi) {
169 int Size = GPRCS2Frames.size();
174 GPRCS2Frames.resize(Size);
176 GPRCS2Frames[fi] = true;
179 void addDPRCalleeSavedAreaFrame(int fi) {
181 int Size = DPRCSFrames.size();
186 DPRCSFrames.resize(Size);
188 DPRCSFrames[fi] = true;
192 void setCSRegisterIsSpilled(unsigned Reg) {
193 SpilledCSRegs.set(Reg);
196 bool isCSRegisterSpilled(unsigned Reg) {
197 return SpilledCSRegs[Reg];
200 const BitVector &getSpilledCSRegisters() const {
201 return SpilledCSRegs;
204 unsigned createJumpTableUId() {
205 return JumpTableUId++;
208 } // End llvm namespace
210 #endif // ARMMACHINEFUNCTIONINFO_H