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 LLVM_LIB_TARGET_ARM_ARMMACHINEFUNCTIONINFO_H 00015 #define LLVM_LIB_TARGET_ARM_ARMMACHINEFUNCTIONINFO_H 00016 00017 #include "ARMSubtarget.h" 00018 #include "llvm/ADT/BitVector.h" 00019 #include "llvm/CodeGen/MachineFunction.h" 00020 #include "llvm/Target/TargetMachine.h" 00021 #include "llvm/Target/TargetRegisterInfo.h" 00022 #include "llvm/ADT/DenseMap.h" 00023 00024 namespace llvm { 00025 00026 /// ARMFunctionInfo - This class is derived from MachineFunctionInfo and 00027 /// contains private ARM-specific information for each MachineFunction. 00028 class ARMFunctionInfo : public MachineFunctionInfo { 00029 virtual void anchor(); 00030 00031 /// isThumb - True if this function is compiled under Thumb mode. 00032 /// Used to initialized Align, so must precede it. 00033 bool isThumb; 00034 00035 /// hasThumb2 - True if the target architecture supports Thumb2. Do not use 00036 /// to determine if function is compiled under Thumb mode, for that use 00037 /// 'isThumb'. 00038 bool hasThumb2; 00039 00040 /// StByValParamsPadding - For parameter that is split between 00041 /// GPRs and memory; while recovering GPRs part, when 00042 /// StackAlignment > 4, and GPRs-part-size mod StackAlignment != 0, 00043 /// we need to insert gap before parameter start address. It allows to 00044 /// "attach" GPR-part to the part that was passed via stack. 00045 unsigned StByValParamsPadding; 00046 00047 /// VarArgsRegSaveSize - Size of the register save area for vararg functions. 00048 /// 00049 unsigned ArgRegsSaveSize; 00050 00051 /// ReturnRegsCount - Number of registers used up in the return. 00052 unsigned ReturnRegsCount; 00053 00054 /// HasStackFrame - True if this function has a stack frame. Set by 00055 /// processFunctionBeforeCalleeSavedScan(). 00056 bool HasStackFrame; 00057 00058 /// RestoreSPFromFP - True if epilogue should restore SP from FP. Set by 00059 /// emitPrologue. 00060 bool RestoreSPFromFP; 00061 00062 /// LRSpilledForFarJump - True if the LR register has been for spilled to 00063 /// enable far jump. 00064 bool LRSpilledForFarJump; 00065 00066 /// FramePtrSpillOffset - If HasStackFrame, this records the frame pointer 00067 /// spill stack offset. 00068 unsigned FramePtrSpillOffset; 00069 00070 /// GPRCS1Offset, GPRCS2Offset, DPRCSOffset - Starting offset of callee saved 00071 /// register spills areas. For Mac OS X: 00072 /// 00073 /// GPR callee-saved (1) : r4, r5, r6, r7, lr 00074 /// -------------------------------------------- 00075 /// GPR callee-saved (2) : r8, r10, r11 00076 /// -------------------------------------------- 00077 /// DPR callee-saved : d8 - d15 00078 /// 00079 /// Also see AlignedDPRCSRegs below. Not all D-regs need to go in area 3. 00080 /// Some may be spilled after the stack has been realigned. 00081 unsigned GPRCS1Offset; 00082 unsigned GPRCS2Offset; 00083 unsigned DPRCSOffset; 00084 00085 /// GPRCS1Size, GPRCS2Size, DPRCSSize - Sizes of callee saved register spills 00086 /// areas. 00087 unsigned GPRCS1Size; 00088 unsigned GPRCS2Size; 00089 unsigned DPRCSSize; 00090 00091 /// NumAlignedDPRCS2Regs - The number of callee-saved DPRs that are saved in 00092 /// the aligned portion of the stack frame. This is always a contiguous 00093 /// sequence of D-registers starting from d8. 00094 /// 00095 /// We do not keep track of the frame indices used for these registers - they 00096 /// behave like any other frame index in the aligned stack frame. These 00097 /// registers also aren't included in DPRCSSize above. 00098 unsigned NumAlignedDPRCS2Regs; 00099 00100 /// JumpTableUId - Unique id for jumptables. 00101 /// 00102 unsigned JumpTableUId; 00103 00104 unsigned PICLabelUId; 00105 00106 /// VarArgsFrameIndex - FrameIndex for start of varargs area. 00107 int VarArgsFrameIndex; 00108 00109 /// HasITBlocks - True if IT blocks have been inserted. 00110 bool HasITBlocks; 00111 00112 /// CPEClones - Track constant pool entries clones created by Constant Island 00113 /// pass. 00114 DenseMap<unsigned, unsigned> CPEClones; 00115 00116 /// GlobalBaseReg - keeps track of the virtual register initialized for 00117 /// use as the global base register. This is used for PIC in some PIC 00118 /// relocation models. 00119 unsigned GlobalBaseReg; 00120 00121 /// ArgumentStackSize - amount of bytes on stack consumed by the arguments 00122 /// being passed on the stack 00123 unsigned ArgumentStackSize; 00124 00125 /// CoalescedWeights - mapping of basic blocks to the rolling counter of 00126 /// coalesced weights. 00127 DenseMap<const MachineBasicBlock*, unsigned> CoalescedWeights; 00128 00129 public: 00130 ARMFunctionInfo() : 00131 isThumb(false), 00132 hasThumb2(false), 00133 ArgRegsSaveSize(0), ReturnRegsCount(0), HasStackFrame(false), 00134 RestoreSPFromFP(false), 00135 LRSpilledForFarJump(false), 00136 FramePtrSpillOffset(0), GPRCS1Offset(0), GPRCS2Offset(0), DPRCSOffset(0), 00137 GPRCS1Size(0), GPRCS2Size(0), DPRCSSize(0), 00138 NumAlignedDPRCS2Regs(0), 00139 JumpTableUId(0), PICLabelUId(0), 00140 VarArgsFrameIndex(0), HasITBlocks(false), GlobalBaseReg(0) {} 00141 00142 explicit ARMFunctionInfo(MachineFunction &MF); 00143 00144 bool isThumbFunction() const { return isThumb; } 00145 bool isThumb1OnlyFunction() const { return isThumb && !hasThumb2; } 00146 bool isThumb2Function() const { return isThumb && hasThumb2; } 00147 00148 unsigned getStoredByValParamsPadding() const { return StByValParamsPadding; } 00149 void setStoredByValParamsPadding(unsigned p) { StByValParamsPadding = p; } 00150 00151 unsigned getArgRegsSaveSize(unsigned Align = 0) const { 00152 if (!Align) 00153 return ArgRegsSaveSize; 00154 return (ArgRegsSaveSize + Align - 1) & ~(Align - 1); 00155 } 00156 void setArgRegsSaveSize(unsigned s) { ArgRegsSaveSize = s; } 00157 00158 unsigned getReturnRegsCount() const { return ReturnRegsCount; } 00159 void setReturnRegsCount(unsigned s) { ReturnRegsCount = s; } 00160 00161 bool hasStackFrame() const { return HasStackFrame; } 00162 void setHasStackFrame(bool s) { HasStackFrame = s; } 00163 00164 bool shouldRestoreSPFromFP() const { return RestoreSPFromFP; } 00165 void setShouldRestoreSPFromFP(bool s) { RestoreSPFromFP = s; } 00166 00167 bool isLRSpilledForFarJump() const { return LRSpilledForFarJump; } 00168 void setLRIsSpilledForFarJump(bool s) { LRSpilledForFarJump = s; } 00169 00170 unsigned getFramePtrSpillOffset() const { return FramePtrSpillOffset; } 00171 void setFramePtrSpillOffset(unsigned o) { FramePtrSpillOffset = o; } 00172 00173 unsigned getNumAlignedDPRCS2Regs() const { return NumAlignedDPRCS2Regs; } 00174 void setNumAlignedDPRCS2Regs(unsigned n) { NumAlignedDPRCS2Regs = n; } 00175 00176 unsigned getGPRCalleeSavedArea1Offset() const { return GPRCS1Offset; } 00177 unsigned getGPRCalleeSavedArea2Offset() const { return GPRCS2Offset; } 00178 unsigned getDPRCalleeSavedAreaOffset() const { return DPRCSOffset; } 00179 00180 void setGPRCalleeSavedArea1Offset(unsigned o) { GPRCS1Offset = o; } 00181 void setGPRCalleeSavedArea2Offset(unsigned o) { GPRCS2Offset = o; } 00182 void setDPRCalleeSavedAreaOffset(unsigned o) { DPRCSOffset = o; } 00183 00184 unsigned getGPRCalleeSavedArea1Size() const { return GPRCS1Size; } 00185 unsigned getGPRCalleeSavedArea2Size() const { return GPRCS2Size; } 00186 unsigned getDPRCalleeSavedAreaSize() const { return DPRCSSize; } 00187 00188 void setGPRCalleeSavedArea1Size(unsigned s) { GPRCS1Size = s; } 00189 void setGPRCalleeSavedArea2Size(unsigned s) { GPRCS2Size = s; } 00190 void setDPRCalleeSavedAreaSize(unsigned s) { DPRCSSize = s; } 00191 00192 unsigned getArgumentStackSize() const { return ArgumentStackSize; } 00193 void setArgumentStackSize(unsigned size) { ArgumentStackSize = size; } 00194 00195 unsigned createJumpTableUId() { 00196 return JumpTableUId++; 00197 } 00198 00199 unsigned getNumJumpTables() const { 00200 return JumpTableUId; 00201 } 00202 00203 void initPICLabelUId(unsigned UId) { 00204 PICLabelUId = UId; 00205 } 00206 00207 unsigned getNumPICLabels() const { 00208 return PICLabelUId; 00209 } 00210 00211 unsigned createPICLabelUId() { 00212 return PICLabelUId++; 00213 } 00214 00215 int getVarArgsFrameIndex() const { return VarArgsFrameIndex; } 00216 void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; } 00217 00218 bool hasITBlocks() const { return HasITBlocks; } 00219 void setHasITBlocks(bool h) { HasITBlocks = h; } 00220 00221 unsigned getGlobalBaseReg() const { return GlobalBaseReg; } 00222 void setGlobalBaseReg(unsigned Reg) { GlobalBaseReg = Reg; } 00223 00224 void recordCPEClone(unsigned CPIdx, unsigned CPCloneIdx) { 00225 if (!CPEClones.insert(std::make_pair(CPCloneIdx, CPIdx)).second) 00226 llvm_unreachable("Duplicate entries!"); 00227 } 00228 00229 unsigned getOriginalCPIdx(unsigned CloneIdx) const { 00230 DenseMap<unsigned, unsigned>::const_iterator I = CPEClones.find(CloneIdx); 00231 if (I != CPEClones.end()) 00232 return I->second; 00233 else 00234 return -1U; 00235 } 00236 00237 DenseMap<const MachineBasicBlock*, unsigned>::iterator getCoalescedWeight( 00238 MachineBasicBlock* MBB) { 00239 auto It = CoalescedWeights.find(MBB); 00240 if (It == CoalescedWeights.end()) { 00241 It = CoalescedWeights.insert(std::make_pair(MBB, 0)).first; 00242 } 00243 return It; 00244 } 00245 }; 00246 } // End llvm namespace 00247 00248 #endif