ARMMachineFunctionInfo.h revision 207618
1//====- ARMMachineFuctionInfo.h - ARM machine function info -----*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file declares ARM-specific per-machine-function information. 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef ARMMACHINEFUNCTIONINFO_H 15#define ARMMACHINEFUNCTIONINFO_H 16 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" 22 23namespace llvm { 24 25/// ARMFunctionInfo - This class is derived from MachineFunction private 26/// ARM target-specific information for each MachineFunction. 27class ARMFunctionInfo : public MachineFunctionInfo { 28 29 /// isThumb - True if this function is compiled under Thumb mode. 30 /// Used to initialized Align, so must precede it. 31 bool isThumb; 32 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 35 /// 'isThumb'. 36 bool hasThumb2; 37 38 /// VarArgsRegSaveSize - Size of the register save area for vararg functions. 39 /// 40 unsigned VarArgsRegSaveSize; 41 42 /// HasStackFrame - True if this function has a stack frame. Set by 43 /// processFunctionBeforeCalleeSavedScan(). 44 bool HasStackFrame; 45 46 /// LRSpilledForFarJump - True if the LR register has been for spilled to 47 /// enable far jump. 48 bool LRSpilledForFarJump; 49 50 /// FramePtrSpillOffset - If HasStackFrame, this records the frame pointer 51 /// spill stack offset. 52 unsigned FramePtrSpillOffset; 53 54 /// GPRCS1Offset, GPRCS2Offset, DPRCSOffset - Starting offset of callee saved 55 /// register spills areas. For Mac OS X: 56 /// 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; 64 unsigned DPRCSOffset; 65 66 /// GPRCS1Size, GPRCS2Size, DPRCSSize - Sizes of callee saved register spills 67 /// areas. 68 unsigned GPRCS1Size; 69 unsigned GPRCS2Size; 70 unsigned DPRCSSize; 71 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; 77 78 /// SpilledCSRegs - A BitVector mask of all spilled callee-saved registers. 79 /// 80 BitVector SpilledCSRegs; 81 82 /// JumpTableUId - Unique id for jumptables. 83 /// 84 unsigned JumpTableUId; 85 86 unsigned ConstPoolEntryUId; 87 88 /// VarArgsFrameIndex - FrameIndex for start of varargs area. 89 int VarArgsFrameIndex; 90 91public: 92 ARMFunctionInfo() : 93 isThumb(false), 94 hasThumb2(false), 95 VarArgsRegSaveSize(0), HasStackFrame(false), 96 LRSpilledForFarJump(false), 97 FramePtrSpillOffset(0), GPRCS1Offset(0), GPRCS2Offset(0), DPRCSOffset(0), 98 GPRCS1Size(0), GPRCS2Size(0), DPRCSSize(0), 99 GPRCS1Frames(0), GPRCS2Frames(0), DPRCSFrames(0), 100 JumpTableUId(0), ConstPoolEntryUId(0), VarArgsFrameIndex(0) {} 101 102 explicit ARMFunctionInfo(MachineFunction &MF) : 103 isThumb(MF.getTarget().getSubtarget<ARMSubtarget>().isThumb()), 104 hasThumb2(MF.getTarget().getSubtarget<ARMSubtarget>().hasThumb2()), 105 VarArgsRegSaveSize(0), HasStackFrame(false), 106 LRSpilledForFarJump(false), 107 FramePtrSpillOffset(0), GPRCS1Offset(0), GPRCS2Offset(0), DPRCSOffset(0), 108 GPRCS1Size(0), GPRCS2Size(0), DPRCSSize(0), 109 GPRCS1Frames(32), GPRCS2Frames(32), DPRCSFrames(32), 110 SpilledCSRegs(MF.getTarget().getRegisterInfo()->getNumRegs()), 111 JumpTableUId(0), ConstPoolEntryUId(0), VarArgsFrameIndex(0) {} 112 113 bool isThumbFunction() const { return isThumb; } 114 bool isThumb1OnlyFunction() const { return isThumb && !hasThumb2; } 115 bool isThumb2Function() const { return isThumb && hasThumb2; } 116 117 unsigned getVarArgsRegSaveSize() const { return VarArgsRegSaveSize; } 118 void setVarArgsRegSaveSize(unsigned s) { VarArgsRegSaveSize = s; } 119 120 bool hasStackFrame() const { return HasStackFrame; } 121 void setHasStackFrame(bool s) { HasStackFrame = s; } 122 123 bool isLRSpilledForFarJump() const { return LRSpilledForFarJump; } 124 void setLRIsSpilledForFarJump(bool s) { LRSpilledForFarJump = s; } 125 126 unsigned getFramePtrSpillOffset() const { return FramePtrSpillOffset; } 127 void setFramePtrSpillOffset(unsigned o) { FramePtrSpillOffset = o; } 128 129 unsigned getGPRCalleeSavedArea1Offset() const { return GPRCS1Offset; } 130 unsigned getGPRCalleeSavedArea2Offset() const { return GPRCS2Offset; } 131 unsigned getDPRCalleeSavedAreaOffset() const { return DPRCSOffset; } 132 133 void setGPRCalleeSavedArea1Offset(unsigned o) { GPRCS1Offset = o; } 134 void setGPRCalleeSavedArea2Offset(unsigned o) { GPRCS2Offset = o; } 135 void setDPRCalleeSavedAreaOffset(unsigned o) { DPRCSOffset = o; } 136 137 unsigned getGPRCalleeSavedArea1Size() const { return GPRCS1Size; } 138 unsigned getGPRCalleeSavedArea2Size() const { return GPRCS2Size; } 139 unsigned getDPRCalleeSavedAreaSize() const { return DPRCSSize; } 140 141 void setGPRCalleeSavedArea1Size(unsigned s) { GPRCS1Size = s; } 142 void setGPRCalleeSavedArea2Size(unsigned s) { GPRCS2Size = s; } 143 void setDPRCalleeSavedAreaSize(unsigned s) { DPRCSSize = s; } 144 145 bool isGPRCalleeSavedArea1Frame(int fi) const { 146 if (fi < 0 || fi >= (int)GPRCS1Frames.size()) 147 return false; 148 return GPRCS1Frames[fi]; 149 } 150 bool isGPRCalleeSavedArea2Frame(int fi) const { 151 if (fi < 0 || fi >= (int)GPRCS2Frames.size()) 152 return false; 153 return GPRCS2Frames[fi]; 154 } 155 bool isDPRCalleeSavedAreaFrame(int fi) const { 156 if (fi < 0 || fi >= (int)DPRCSFrames.size()) 157 return false; 158 return DPRCSFrames[fi]; 159 } 160 161 void addGPRCalleeSavedArea1Frame(int fi) { 162 if (fi >= 0) { 163 int Size = GPRCS1Frames.size(); 164 if (fi >= Size) { 165 Size *= 2; 166 if (fi >= Size) 167 Size = fi+1; 168 GPRCS1Frames.resize(Size); 169 } 170 GPRCS1Frames[fi] = true; 171 } 172 } 173 void addGPRCalleeSavedArea2Frame(int fi) { 174 if (fi >= 0) { 175 int Size = GPRCS2Frames.size(); 176 if (fi >= Size) { 177 Size *= 2; 178 if (fi >= Size) 179 Size = fi+1; 180 GPRCS2Frames.resize(Size); 181 } 182 GPRCS2Frames[fi] = true; 183 } 184 } 185 void addDPRCalleeSavedAreaFrame(int fi) { 186 if (fi >= 0) { 187 int Size = DPRCSFrames.size(); 188 if (fi >= Size) { 189 Size *= 2; 190 if (fi >= Size) 191 Size = fi+1; 192 DPRCSFrames.resize(Size); 193 } 194 DPRCSFrames[fi] = true; 195 } 196 } 197 198 void setCSRegisterIsSpilled(unsigned Reg) { 199 SpilledCSRegs.set(Reg); 200 } 201 202 bool isCSRegisterSpilled(unsigned Reg) const { 203 return SpilledCSRegs[Reg]; 204 } 205 206 const BitVector &getSpilledCSRegisters() const { 207 return SpilledCSRegs; 208 } 209 210 unsigned createJumpTableUId() { 211 return JumpTableUId++; 212 } 213 214 unsigned getNumJumpTables() const { 215 return JumpTableUId; 216 } 217 218 void initConstPoolEntryUId(unsigned UId) { 219 ConstPoolEntryUId = UId; 220 } 221 222 unsigned getNumConstPoolEntries() const { 223 return ConstPoolEntryUId; 224 } 225 226 unsigned createConstPoolEntryUId() { 227 return ConstPoolEntryUId++; 228 } 229 230 int getVarArgsFrameIndex() const { return VarArgsFrameIndex; } 231 void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; } 232}; 233} // End llvm namespace 234 235#endif // ARMMACHINEFUNCTIONINFO_H 236