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 /// FramePtrSpillOffset - If HasStackFrame, this records the frame pointer
56 /// spill stack offset.
57 unsigned FramePtrSpillOffset;
59 /// GPRCS1Offset, GPRCS2Offset, DPRCSOffset - Starting offset of callee saved
60 /// register spills areas. For Mac OS X:
62 /// GPR callee-saved (1) : r4, r5, r6, r7, lr
63 /// --------------------------------------------
64 /// GPR callee-saved (2) : r8, r10, r11
65 /// --------------------------------------------
66 /// DPR callee-saved : d8 - d15
67 unsigned GPRCS1Offset;
68 unsigned GPRCS2Offset;
71 /// GPRCS1Size, GPRCS2Size, DPRCSSize - Sizes of callee saved register spills
77 /// GPRCS1Frames, GPRCS2Frames, DPRCSFrames - Keeps track of frame indices
78 /// which belong to these spill areas.
79 BitVector GPRCS1Frames;
80 BitVector GPRCS2Frames;
81 BitVector DPRCSFrames;
83 /// SpilledCSRegs - A BitVector mask of all spilled callee-saved registers.
85 BitVector SpilledCSRegs;
87 /// JumpTableUId - Unique id for jumptables.
89 unsigned JumpTableUId;
91 unsigned ConstPoolEntryUId;
98 VarArgsRegSaveSize(0), HasStackFrame(false),
99 LRSpilledForFarJump(false),
100 FramePtrSpillOffset(0), GPRCS1Offset(0), GPRCS2Offset(0), DPRCSOffset(0),
101 GPRCS1Size(0), GPRCS2Size(0), DPRCSSize(0),
102 GPRCS1Frames(0), GPRCS2Frames(0), DPRCSFrames(0),
103 JumpTableUId(0), ConstPoolEntryUId(0) {}
105 explicit ARMFunctionInfo(MachineFunction &MF) :
106 isThumb(MF.getTarget().getSubtarget<ARMSubtarget>().isThumb()),
107 hasThumb2(MF.getTarget().getSubtarget<ARMSubtarget>().hasThumb2()),
108 Align(isThumb ? 1U : 2U),
109 VarArgsRegSaveSize(0), HasStackFrame(false),
110 LRSpilledForFarJump(false),
111 FramePtrSpillOffset(0), GPRCS1Offset(0), GPRCS2Offset(0), DPRCSOffset(0),
112 GPRCS1Size(0), GPRCS2Size(0), DPRCSSize(0),
113 GPRCS1Frames(32), GPRCS2Frames(32), DPRCSFrames(32),
114 SpilledCSRegs(MF.getTarget().getRegisterInfo()->getNumRegs()),
115 JumpTableUId(0), ConstPoolEntryUId(0) {}
117 bool isThumbFunction() const { return isThumb; }
118 bool isThumb1OnlyFunction() const { return isThumb && !hasThumb2; }
119 bool isThumb2Function() const { return isThumb && hasThumb2; }
121 unsigned getAlign() const { return Align; }
122 void setAlign(unsigned a) { Align = a; }
124 unsigned getVarArgsRegSaveSize() const { return VarArgsRegSaveSize; }
125 void setVarArgsRegSaveSize(unsigned s) { VarArgsRegSaveSize = s; }
127 bool hasStackFrame() const { return HasStackFrame; }
128 void setHasStackFrame(bool s) { HasStackFrame = s; }
130 bool isLRSpilledForFarJump() const { return LRSpilledForFarJump; }
131 void setLRIsSpilledForFarJump(bool s) { LRSpilledForFarJump = s; }
133 unsigned getFramePtrSpillOffset() const { return FramePtrSpillOffset; }
134 void setFramePtrSpillOffset(unsigned o) { FramePtrSpillOffset = o; }
136 unsigned getGPRCalleeSavedArea1Offset() const { return GPRCS1Offset; }
137 unsigned getGPRCalleeSavedArea2Offset() const { return GPRCS2Offset; }
138 unsigned getDPRCalleeSavedAreaOffset() const { return DPRCSOffset; }
140 void setGPRCalleeSavedArea1Offset(unsigned o) { GPRCS1Offset = o; }
141 void setGPRCalleeSavedArea2Offset(unsigned o) { GPRCS2Offset = o; }
142 void setDPRCalleeSavedAreaOffset(unsigned o) { DPRCSOffset = o; }
144 unsigned getGPRCalleeSavedArea1Size() const { return GPRCS1Size; }
145 unsigned getGPRCalleeSavedArea2Size() const { return GPRCS2Size; }
146 unsigned getDPRCalleeSavedAreaSize() const { return DPRCSSize; }
148 void setGPRCalleeSavedArea1Size(unsigned s) { GPRCS1Size = s; }
149 void setGPRCalleeSavedArea2Size(unsigned s) { GPRCS2Size = s; }
150 void setDPRCalleeSavedAreaSize(unsigned s) { DPRCSSize = s; }
152 bool isGPRCalleeSavedArea1Frame(int fi) const {
153 if (fi < 0 || fi >= (int)GPRCS1Frames.size())
155 return GPRCS1Frames[fi];
157 bool isGPRCalleeSavedArea2Frame(int fi) const {
158 if (fi < 0 || fi >= (int)GPRCS2Frames.size())
160 return GPRCS2Frames[fi];
162 bool isDPRCalleeSavedAreaFrame(int fi) const {
163 if (fi < 0 || fi >= (int)DPRCSFrames.size())
165 return DPRCSFrames[fi];
168 void addGPRCalleeSavedArea1Frame(int fi) {
170 int Size = GPRCS1Frames.size();
175 GPRCS1Frames.resize(Size);
177 GPRCS1Frames[fi] = true;
180 void addGPRCalleeSavedArea2Frame(int fi) {
182 int Size = GPRCS2Frames.size();
187 GPRCS2Frames.resize(Size);
189 GPRCS2Frames[fi] = true;
192 void addDPRCalleeSavedAreaFrame(int fi) {
194 int Size = DPRCSFrames.size();
199 DPRCSFrames.resize(Size);
201 DPRCSFrames[fi] = true;
205 void setCSRegisterIsSpilled(unsigned Reg) {
206 SpilledCSRegs.set(Reg);
209 bool isCSRegisterSpilled(unsigned Reg) const {
210 return SpilledCSRegs[Reg];
213 const BitVector &getSpilledCSRegisters() const {
214 return SpilledCSRegs;
217 unsigned createJumpTableUId() {
218 return JumpTableUId++;
221 unsigned getNumJumpTables() const {
225 void initConstPoolEntryUId(unsigned UId) {
226 ConstPoolEntryUId = UId;
229 unsigned getNumConstPoolEntries() const {
230 return ConstPoolEntryUId;
233 unsigned createConstPoolEntryUId() {
234 return ConstPoolEntryUId++;
237 } // End llvm namespace
239 #endif // ARMMACHINEFUNCTIONINFO_H