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 /// Align - required alignment. ARM functions and Thumb functions with 00034 /// constant pools require 4-byte alignment; other Thumb functions 00035 /// require only 2-byte alignment. 00036 unsigned Align; 00037 00038 /// VarArgsRegSaveSize - Size of the register save area for vararg functions. 00039 /// 00040 unsigned VarArgsRegSaveSize; 00041 00042 /// HasStackFrame - True if this function has a stack frame. Set by 00043 /// processFunctionBeforeCalleeSavedScan(). 00044 bool HasStackFrame; 00045 00046 /// LRSpilledForFarJump - True if the LR register has been for spilled to 00047 /// enable far jump. 00048 bool LRSpilledForFarJump; 00049 00050 /// R3IsLiveIn - True if R3 is live in to this function. 00051 /// FIXME: Remove when register scavenger for Thumb is done. 00052 bool R3IsLiveIn; 00053 00054 /// FramePtrSpillOffset - If HasStackFrame, this records the frame pointer 00055 /// spill stack offset. 00056 unsigned FramePtrSpillOffset; 00057 00058 /// GPRCS1Offset, GPRCS2Offset, DPRCSOffset - Starting offset of callee saved 00059 /// register spills areas. For Mac OS X: 00060 /// 00061 /// GPR callee-saved (1) : r4, r5, r6, r7, lr 00062 /// -------------------------------------------- 00063 /// GPR callee-saved (2) : r8, r10, r11 00064 /// -------------------------------------------- 00065 /// DPR callee-saved : d8 - d15 00066 unsigned GPRCS1Offset; 00067 unsigned GPRCS2Offset; 00068 unsigned DPRCSOffset; 00069 00070 /// GPRCS1Size, GPRCS2Size, DPRCSSize - Sizes of callee saved register spills 00071 /// areas. 00072 unsigned GPRCS1Size; 00073 unsigned GPRCS2Size; 00074 unsigned DPRCSSize; 00075 00076 /// GPRCS1Frames, GPRCS2Frames, DPRCSFrames - Keeps track of frame indices 00077 /// which belong to these spill areas. 00078 BitVector GPRCS1Frames; 00079 BitVector GPRCS2Frames; 00080 BitVector DPRCSFrames; 00081 00082 /// SpilledCSRegs - A BitVector mask of all spilled callee-saved registers. 00083 /// 00084 BitVector SpilledCSRegs; 00085 00086 /// JumpTableUId - Unique id for jumptables. 00087 /// 00088 unsigned JumpTableUId; 00089 00090 unsigned ConstPoolEntryUId; 00091 00092 public: 00093 ARMFunctionInfo() : 00094 isThumb(false), 00095 Align(2U), 00096 VarArgsRegSaveSize(0), HasStackFrame(false), 00097 LRSpilledForFarJump(false), R3IsLiveIn(false), 00098 FramePtrSpillOffset(0), GPRCS1Offset(0), GPRCS2Offset(0), DPRCSOffset(0), 00099 GPRCS1Size(0), GPRCS2Size(0), DPRCSSize(0), 00100 GPRCS1Frames(0), GPRCS2Frames(0), DPRCSFrames(0), 00101 JumpTableUId(0), ConstPoolEntryUId(0) {} 00102 00103 ARMFunctionInfo(MachineFunction &MF) : 00104 isThumb(MF.getTarget().getSubtarget<ARMSubtarget>().isThumb()), 00105 Align(isThumb ? 1U : 2U), 00106 VarArgsRegSaveSize(0), HasStackFrame(false), 00107 LRSpilledForFarJump(false), R3IsLiveIn(false), 00108 FramePtrSpillOffset(0), GPRCS1Offset(0), GPRCS2Offset(0), DPRCSOffset(0), 00109 GPRCS1Size(0), GPRCS2Size(0), DPRCSSize(0), 00110 GPRCS1Frames(32), GPRCS2Frames(32), DPRCSFrames(32), 00111 SpilledCSRegs(MF.getTarget().getRegisterInfo()->getNumRegs()), 00112 JumpTableUId(0), ConstPoolEntryUId(0) {} 00113 00114 bool isThumbFunction() const { return isThumb; } 00115 00116 unsigned getAlign() const { return Align; } 00117 void setAlign(unsigned a) { Align = a; } 00118 00119 unsigned getVarArgsRegSaveSize() const { return VarArgsRegSaveSize; } 00120 void setVarArgsRegSaveSize(unsigned s) { VarArgsRegSaveSize = s; } 00121 00122 bool hasStackFrame() const { return HasStackFrame; } 00123 void setHasStackFrame(bool s) { HasStackFrame = s; } 00124 00125 bool isLRSpilledForFarJump() const { return LRSpilledForFarJump; } 00126 void setLRIsSpilledForFarJump(bool s) { LRSpilledForFarJump = s; } 00127 00128 // FIXME: Remove when register scavenger for Thumb is done. 00129 bool isR3LiveIn() const { return R3IsLiveIn; } 00130 void setR3IsLiveIn(bool l) { R3IsLiveIn = l; } 00131 00132 unsigned getFramePtrSpillOffset() const { return FramePtrSpillOffset; } 00133 void setFramePtrSpillOffset(unsigned o) { FramePtrSpillOffset = o; } 00134 00135 unsigned getGPRCalleeSavedArea1Offset() const { return GPRCS1Offset; } 00136 unsigned getGPRCalleeSavedArea2Offset() const { return GPRCS2Offset; } 00137 unsigned getDPRCalleeSavedAreaOffset() const { return DPRCSOffset; } 00138 00139 void setGPRCalleeSavedArea1Offset(unsigned o) { GPRCS1Offset = o; } 00140 void setGPRCalleeSavedArea2Offset(unsigned o) { GPRCS2Offset = o; } 00141 void setDPRCalleeSavedAreaOffset(unsigned o) { DPRCSOffset = o; } 00142 00143 unsigned getGPRCalleeSavedArea1Size() const { return GPRCS1Size; } 00144 unsigned getGPRCalleeSavedArea2Size() const { return GPRCS2Size; } 00145 unsigned getDPRCalleeSavedAreaSize() const { return DPRCSSize; } 00146 00147 void setGPRCalleeSavedArea1Size(unsigned s) { GPRCS1Size = s; } 00148 void setGPRCalleeSavedArea2Size(unsigned s) { GPRCS2Size = s; } 00149 void setDPRCalleeSavedAreaSize(unsigned s) { DPRCSSize = s; } 00150 00151 bool isGPRCalleeSavedArea1Frame(int fi) const { 00152 if (fi < 0 || fi >= (int)GPRCS1Frames.size()) 00153 return false; 00154 return GPRCS1Frames[fi]; 00155 } 00156 bool isGPRCalleeSavedArea2Frame(int fi) const { 00157 if (fi < 0 || fi >= (int)GPRCS2Frames.size()) 00158 return false; 00159 return GPRCS2Frames[fi]; 00160 } 00161 bool isDPRCalleeSavedAreaFrame(int fi) const { 00162 if (fi < 0 || fi >= (int)DPRCSFrames.size()) 00163 return false; 00164 return DPRCSFrames[fi]; 00165 } 00166 00167 void addGPRCalleeSavedArea1Frame(int fi) { 00168 if (fi >= 0) { 00169 int Size = GPRCS1Frames.size(); 00170 if (fi >= Size) { 00171 Size *= 2; 00172 if (fi >= Size) 00173 Size = fi+1; 00174 GPRCS1Frames.resize(Size); 00175 } 00176 GPRCS1Frames[fi] = true; 00177 } 00178 } 00179 void addGPRCalleeSavedArea2Frame(int fi) { 00180 if (fi >= 0) { 00181 int Size = GPRCS2Frames.size(); 00182 if (fi >= Size) { 00183 Size *= 2; 00184 if (fi >= Size) 00185 Size = fi+1; 00186 GPRCS2Frames.resize(Size); 00187 } 00188 GPRCS2Frames[fi] = true; 00189 } 00190 } 00191 void addDPRCalleeSavedAreaFrame(int fi) { 00192 if (fi >= 0) { 00193 int Size = DPRCSFrames.size(); 00194 if (fi >= Size) { 00195 Size *= 2; 00196 if (fi >= Size) 00197 Size = fi+1; 00198 DPRCSFrames.resize(Size); 00199 } 00200 DPRCSFrames[fi] = true; 00201 } 00202 } 00203 00204 void setCSRegisterIsSpilled(unsigned Reg) { 00205 SpilledCSRegs.set(Reg); 00206 } 00207 00208 bool isCSRegisterSpilled(unsigned Reg) const { 00209 return SpilledCSRegs[Reg]; 00210 } 00211 00212 const BitVector &getSpilledCSRegisters() const { 00213 return SpilledCSRegs; 00214 } 00215 00216 unsigned createJumpTableUId() { 00217 return JumpTableUId++; 00218 } 00219 00220 unsigned getNumJumpTables() const { 00221 return JumpTableUId; 00222 } 00223 00224 void initConstPoolEntryUId(unsigned UId) { 00225 ConstPoolEntryUId = UId; 00226 } 00227 00228 unsigned getNumConstPoolEntries() const { 00229 return ConstPoolEntryUId; 00230 } 00231 00232 unsigned createConstPoolEntryUId() { 00233 return ConstPoolEntryUId++; 00234 } 00235 }; 00236 } // End llvm namespace 00237 00238 #endif // ARMMACHINEFUNCTIONINFO_H