LLVM API Documentation
00001 //====- ARMMachineFuctionInfo.h - ARM machine function info -----*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file declares ARM-specific per-machine-function information. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef ARMMACHINEFUNCTIONINFO_H 00015 #define ARMMACHINEFUNCTIONINFO_H 00016 00017 #include "ARMSubtarget.h" 00018 #include "llvm/CodeGen/MachineFunction.h" 00019 #include "llvm/Target/TargetRegisterInfo.h" 00020 #include "llvm/Target/TargetMachine.h" 00021 #include "llvm/ADT/BitVector.h" 00022 00023 namespace llvm { 00024 00025 /// ARMFunctionInfo - This class is derived from MachineFunction private 00026 /// ARM target-specific information for each MachineFunction. 00027 class ARMFunctionInfo : public MachineFunctionInfo { 00028 00029 /// isThumb - True if this function is compiled under Thumb mode. 00030 /// Used to initialized Align, so must precede it. 00031 bool isThumb; 00032 00033 /// hasThumb2 - True if the target architecture supports Thumb2. Do not use 00034 /// to determine if function is compiled under Thumb mode, for that use 00035 /// 'isThumb'. 00036 bool hasThumb2; 00037 00038 /// Align - required alignment. ARM functions and Thumb functions with 00039 /// constant pools require 4-byte alignment; other Thumb functions 00040 /// require only 2-byte alignment. 00041 unsigned Align; 00042 00043 /// VarArgsRegSaveSize - Size of the register save area for vararg functions. 00044 /// 00045 unsigned VarArgsRegSaveSize; 00046 00047 /// HasStackFrame - True if this function has a stack frame. Set by 00048 /// processFunctionBeforeCalleeSavedScan(). 00049 bool HasStackFrame; 00050 00051 /// LRSpilledForFarJump - True if the LR register has been for spilled to 00052 /// enable far jump. 00053 bool LRSpilledForFarJump; 00054 00055 /// R3IsLiveIn - True if R3 is live in to this function. 00056 /// FIXME: Remove when register scavenger for Thumb is done. 00057 bool R3IsLiveIn; 00058 00059 /// FramePtrSpillOffset - If HasStackFrame, this records the frame pointer 00060 /// spill stack offset. 00061 unsigned FramePtrSpillOffset; 00062 00063 /// GPRCS1Offset, GPRCS2Offset, DPRCSOffset - Starting offset of callee saved 00064 /// register spills areas. For Mac OS X: 00065 /// 00066 /// GPR callee-saved (1) : r4, r5, r6, r7, lr 00067 /// -------------------------------------------- 00068 /// GPR callee-saved (2) : r8, r10, r11 00069 /// -------------------------------------------- 00070 /// DPR callee-saved : d8 - d15 00071 unsigned GPRCS1Offset; 00072 unsigned GPRCS2Offset; 00073 unsigned DPRCSOffset; 00074 00075 /// GPRCS1Size, GPRCS2Size, DPRCSSize - Sizes of callee saved register spills 00076 /// areas. 00077 unsigned GPRCS1Size; 00078 unsigned GPRCS2Size; 00079 unsigned DPRCSSize; 00080 00081 /// GPRCS1Frames, GPRCS2Frames, DPRCSFrames - Keeps track of frame indices 00082 /// which belong to these spill areas. 00083 BitVector GPRCS1Frames; 00084 BitVector GPRCS2Frames; 00085 BitVector DPRCSFrames; 00086 00087 /// SpilledCSRegs - A BitVector mask of all spilled callee-saved registers. 00088 /// 00089 BitVector SpilledCSRegs; 00090 00091 /// JumpTableUId - Unique id for jumptables. 00092 /// 00093 unsigned JumpTableUId; 00094 00095 unsigned ConstPoolEntryUId; 00096 00097 public: 00098 ARMFunctionInfo() : 00099 isThumb(false), 00100 hasThumb2(false), 00101 Align(2U), 00102 VarArgsRegSaveSize(0), HasStackFrame(false), 00103 LRSpilledForFarJump(false), R3IsLiveIn(false), 00104 FramePtrSpillOffset(0), GPRCS1Offset(0), GPRCS2Offset(0), DPRCSOffset(0), 00105 GPRCS1Size(0), GPRCS2Size(0), DPRCSSize(0), 00106 GPRCS1Frames(0), GPRCS2Frames(0), DPRCSFrames(0), 00107 JumpTableUId(0), ConstPoolEntryUId(0) {} 00108 00109 explicit ARMFunctionInfo(MachineFunction &MF) : 00110 isThumb(MF.getTarget().getSubtarget<ARMSubtarget>().isThumb()), 00111 hasThumb2(MF.getTarget().getSubtarget<ARMSubtarget>().hasThumb2()), 00112 Align(isThumb ? 1U : 2U), 00113 VarArgsRegSaveSize(0), HasStackFrame(false), 00114 LRSpilledForFarJump(false), R3IsLiveIn(false), 00115 FramePtrSpillOffset(0), GPRCS1Offset(0), GPRCS2Offset(0), DPRCSOffset(0), 00116 GPRCS1Size(0), GPRCS2Size(0), DPRCSSize(0), 00117 GPRCS1Frames(32), GPRCS2Frames(32), DPRCSFrames(32), 00118 SpilledCSRegs(MF.getTarget().getRegisterInfo()->getNumRegs()), 00119 JumpTableUId(0), ConstPoolEntryUId(0) {} 00120 00121 bool isThumbFunction() const { return isThumb; } 00122 bool isThumb1OnlyFunction() const { return isThumb && !hasThumb2; } 00123 bool isThumb2Function() const { return isThumb && hasThumb2; } 00124 00125 unsigned getAlign() const { return Align; } 00126 void setAlign(unsigned a) { Align = a; } 00127 00128 unsigned getVarArgsRegSaveSize() const { return VarArgsRegSaveSize; } 00129 void setVarArgsRegSaveSize(unsigned s) { VarArgsRegSaveSize = s; } 00130 00131 bool hasStackFrame() const { return HasStackFrame; } 00132 void setHasStackFrame(bool s) { HasStackFrame = s; } 00133 00134 bool isLRSpilledForFarJump() const { return LRSpilledForFarJump; } 00135 void setLRIsSpilledForFarJump(bool s) { LRSpilledForFarJump = s; } 00136 00137 // FIXME: Remove when register scavenger for Thumb is done. 00138 bool isR3LiveIn() const { return R3IsLiveIn; } 00139 void setR3IsLiveIn(bool l) { R3IsLiveIn = l; } 00140 00141 unsigned getFramePtrSpillOffset() const { return FramePtrSpillOffset; } 00142 void setFramePtrSpillOffset(unsigned o) { FramePtrSpillOffset = o; } 00143 00144 unsigned getGPRCalleeSavedArea1Offset() const { return GPRCS1Offset; } 00145 unsigned getGPRCalleeSavedArea2Offset() const { return GPRCS2Offset; } 00146 unsigned getDPRCalleeSavedAreaOffset() const { return DPRCSOffset; } 00147 00148 void setGPRCalleeSavedArea1Offset(unsigned o) { GPRCS1Offset = o; } 00149 void setGPRCalleeSavedArea2Offset(unsigned o) { GPRCS2Offset = o; } 00150 void setDPRCalleeSavedAreaOffset(unsigned o) { DPRCSOffset = o; } 00151 00152 unsigned getGPRCalleeSavedArea1Size() const { return GPRCS1Size; } 00153 unsigned getGPRCalleeSavedArea2Size() const { return GPRCS2Size; } 00154 unsigned getDPRCalleeSavedAreaSize() const { return DPRCSSize; } 00155 00156 void setGPRCalleeSavedArea1Size(unsigned s) { GPRCS1Size = s; } 00157 void setGPRCalleeSavedArea2Size(unsigned s) { GPRCS2Size = s; } 00158 void setDPRCalleeSavedAreaSize(unsigned s) { DPRCSSize = s; } 00159 00160 bool isGPRCalleeSavedArea1Frame(int fi) const { 00161 if (fi < 0 || fi >= (int)GPRCS1Frames.size()) 00162 return false; 00163 return GPRCS1Frames[fi]; 00164 } 00165 bool isGPRCalleeSavedArea2Frame(int fi) const { 00166 if (fi < 0 || fi >= (int)GPRCS2Frames.size()) 00167 return false; 00168 return GPRCS2Frames[fi]; 00169 } 00170 bool isDPRCalleeSavedAreaFrame(int fi) const { 00171 if (fi < 0 || fi >= (int)DPRCSFrames.size()) 00172 return false; 00173 return DPRCSFrames[fi]; 00174 } 00175 00176 void addGPRCalleeSavedArea1Frame(int fi) { 00177 if (fi >= 0) { 00178 int Size = GPRCS1Frames.size(); 00179 if (fi >= Size) { 00180 Size *= 2; 00181 if (fi >= Size) 00182 Size = fi+1; 00183 GPRCS1Frames.resize(Size); 00184 } 00185 GPRCS1Frames[fi] = true; 00186 } 00187 } 00188 void addGPRCalleeSavedArea2Frame(int fi) { 00189 if (fi >= 0) { 00190 int Size = GPRCS2Frames.size(); 00191 if (fi >= Size) { 00192 Size *= 2; 00193 if (fi >= Size) 00194 Size = fi+1; 00195 GPRCS2Frames.resize(Size); 00196 } 00197 GPRCS2Frames[fi] = true; 00198 } 00199 } 00200 void addDPRCalleeSavedAreaFrame(int fi) { 00201 if (fi >= 0) { 00202 int Size = DPRCSFrames.size(); 00203 if (fi >= Size) { 00204 Size *= 2; 00205 if (fi >= Size) 00206 Size = fi+1; 00207 DPRCSFrames.resize(Size); 00208 } 00209 DPRCSFrames[fi] = true; 00210 } 00211 } 00212 00213 void setCSRegisterIsSpilled(unsigned Reg) { 00214 SpilledCSRegs.set(Reg); 00215 } 00216 00217 bool isCSRegisterSpilled(unsigned Reg) const { 00218 return SpilledCSRegs[Reg]; 00219 } 00220 00221 const BitVector &getSpilledCSRegisters() const { 00222 return SpilledCSRegs; 00223 } 00224 00225 unsigned createJumpTableUId() { 00226 return JumpTableUId++; 00227 } 00228 00229 unsigned getNumJumpTables() const { 00230 return JumpTableUId; 00231 } 00232 00233 void initConstPoolEntryUId(unsigned UId) { 00234 ConstPoolEntryUId = UId; 00235 } 00236 00237 unsigned getNumConstPoolEntries() const { 00238 return ConstPoolEntryUId; 00239 } 00240 00241 unsigned createConstPoolEntryUId() { 00242 return ConstPoolEntryUId++; 00243 } 00244 }; 00245 } // End llvm namespace 00246 00247 #endif // ARMMACHINEFUNCTIONINFO_H