LLVM API Documentation
00001 //===-- CodeGen/MachineFrameInfo.h - Abstract Stack Frame Rep. --*- 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 // The file defines the MachineFrameInfo class. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef LLVM_CODEGEN_MACHINEFRAMEINFO_H 00015 #define LLVM_CODEGEN_MACHINEFRAMEINFO_H 00016 00017 #include "llvm/ADT/SmallVector.h" 00018 #include "llvm/Support/DataTypes.h" 00019 #include <cassert> 00020 #include <vector> 00021 00022 namespace llvm { 00023 class raw_ostream; 00024 class DataLayout; 00025 class TargetRegisterClass; 00026 class Type; 00027 class MachineFunction; 00028 class MachineBasicBlock; 00029 class TargetFrameLowering; 00030 class TargetMachine; 00031 class BitVector; 00032 class Value; 00033 class AllocaInst; 00034 00035 /// The CalleeSavedInfo class tracks the information need to locate where a 00036 /// callee saved register is in the current frame. 00037 class CalleeSavedInfo { 00038 unsigned Reg; 00039 int FrameIdx; 00040 00041 public: 00042 explicit CalleeSavedInfo(unsigned R, int FI = 0) 00043 : Reg(R), FrameIdx(FI) {} 00044 00045 // Accessors. 00046 unsigned getReg() const { return Reg; } 00047 int getFrameIdx() const { return FrameIdx; } 00048 void setFrameIdx(int FI) { FrameIdx = FI; } 00049 }; 00050 00051 /// The MachineFrameInfo class represents an abstract stack frame until 00052 /// prolog/epilog code is inserted. This class is key to allowing stack frame 00053 /// representation optimizations, such as frame pointer elimination. It also 00054 /// allows more mundane (but still important) optimizations, such as reordering 00055 /// of abstract objects on the stack frame. 00056 /// 00057 /// To support this, the class assigns unique integer identifiers to stack 00058 /// objects requested clients. These identifiers are negative integers for 00059 /// fixed stack objects (such as arguments passed on the stack) or nonnegative 00060 /// for objects that may be reordered. Instructions which refer to stack 00061 /// objects use a special MO_FrameIndex operand to represent these frame 00062 /// indexes. 00063 /// 00064 /// Because this class keeps track of all references to the stack frame, it 00065 /// knows when a variable sized object is allocated on the stack. This is the 00066 /// sole condition which prevents frame pointer elimination, which is an 00067 /// important optimization on register-poor architectures. Because original 00068 /// variable sized alloca's in the source program are the only source of 00069 /// variable sized stack objects, it is safe to decide whether there will be 00070 /// any variable sized objects before all stack objects are known (for 00071 /// example, register allocator spill code never needs variable sized 00072 /// objects). 00073 /// 00074 /// When prolog/epilog code emission is performed, the final stack frame is 00075 /// built and the machine instructions are modified to refer to the actual 00076 /// stack offsets of the object, eliminating all MO_FrameIndex operands from 00077 /// the program. 00078 /// 00079 /// @brief Abstract Stack Frame Information 00080 class MachineFrameInfo { 00081 00082 // StackObject - Represent a single object allocated on the stack. 00083 struct StackObject { 00084 // SPOffset - The offset of this object from the stack pointer on entry to 00085 // the function. This field has no meaning for a variable sized element. 00086 int64_t SPOffset; 00087 00088 // The size of this object on the stack. 0 means a variable sized object, 00089 // ~0ULL means a dead object. 00090 uint64_t Size; 00091 00092 // Alignment - The required alignment of this stack slot. 00093 unsigned Alignment; 00094 00095 // isImmutable - If true, the value of the stack object is set before 00096 // entering the function and is not modified inside the function. By 00097 // default, fixed objects are immutable unless marked otherwise. 00098 bool isImmutable; 00099 00100 // isSpillSlot - If true the stack object is used as spill slot. It 00101 // cannot alias any other memory objects. 00102 bool isSpillSlot; 00103 00104 /// Alloca - If this stack object is originated from an Alloca instruction 00105 /// this value saves the original IR allocation. Can be NULL. 00106 const AllocaInst *Alloca; 00107 00108 // PreAllocated - If true, the object was mapped into the local frame 00109 // block and doesn't need additional handling for allocation beyond that. 00110 bool PreAllocated; 00111 00112 // If true, an LLVM IR value might point to this object. 00113 // Normally, spill slots and fixed-offset objects don't alias IR-accessible 00114 // objects, but there are exceptions (on PowerPC, for example, some byval 00115 // arguments have ABI-prescribed offsets). 00116 bool isAliased; 00117 00118 StackObject(uint64_t Sz, unsigned Al, int64_t SP, bool IM, 00119 bool isSS, const AllocaInst *Val, bool A) 00120 : SPOffset(SP), Size(Sz), Alignment(Al), isImmutable(IM), 00121 isSpillSlot(isSS), Alloca(Val), PreAllocated(false), isAliased(A) {} 00122 }; 00123 00124 const TargetMachine &TM; 00125 00126 /// Objects - The list of stack objects allocated... 00127 /// 00128 std::vector<StackObject> Objects; 00129 00130 /// NumFixedObjects - This contains the number of fixed objects contained on 00131 /// the stack. Because fixed objects are stored at a negative index in the 00132 /// Objects list, this is also the index to the 0th object in the list. 00133 /// 00134 unsigned NumFixedObjects; 00135 00136 /// HasVarSizedObjects - This boolean keeps track of whether any variable 00137 /// sized objects have been allocated yet. 00138 /// 00139 bool HasVarSizedObjects; 00140 00141 /// FrameAddressTaken - This boolean keeps track of whether there is a call 00142 /// to builtin \@llvm.frameaddress. 00143 bool FrameAddressTaken; 00144 00145 /// ReturnAddressTaken - This boolean keeps track of whether there is a call 00146 /// to builtin \@llvm.returnaddress. 00147 bool ReturnAddressTaken; 00148 00149 /// HasStackMap - This boolean keeps track of whether there is a call 00150 /// to builtin \@llvm.experimental.stackmap. 00151 bool HasStackMap; 00152 00153 /// HasPatchPoint - This boolean keeps track of whether there is a call 00154 /// to builtin \@llvm.experimental.patchpoint. 00155 bool HasPatchPoint; 00156 00157 /// StackSize - The prolog/epilog code inserter calculates the final stack 00158 /// offsets for all of the fixed size objects, updating the Objects list 00159 /// above. It then updates StackSize to contain the number of bytes that need 00160 /// to be allocated on entry to the function. 00161 /// 00162 uint64_t StackSize; 00163 00164 /// OffsetAdjustment - The amount that a frame offset needs to be adjusted to 00165 /// have the actual offset from the stack/frame pointer. The exact usage of 00166 /// this is target-dependent, but it is typically used to adjust between 00167 /// SP-relative and FP-relative offsets. E.G., if objects are accessed via 00168 /// SP then OffsetAdjustment is zero; if FP is used, OffsetAdjustment is set 00169 /// to the distance between the initial SP and the value in FP. For many 00170 /// targets, this value is only used when generating debug info (via 00171 /// TargetRegisterInfo::getFrameIndexOffset); when generating code, the 00172 /// corresponding adjustments are performed directly. 00173 int OffsetAdjustment; 00174 00175 /// MaxAlignment - The prolog/epilog code inserter may process objects 00176 /// that require greater alignment than the default alignment the target 00177 /// provides. To handle this, MaxAlignment is set to the maximum alignment 00178 /// needed by the objects on the current frame. If this is greater than the 00179 /// native alignment maintained by the compiler, dynamic alignment code will 00180 /// be needed. 00181 /// 00182 unsigned MaxAlignment; 00183 00184 /// AdjustsStack - Set to true if this function adjusts the stack -- e.g., 00185 /// when calling another function. This is only valid during and after 00186 /// prolog/epilog code insertion. 00187 bool AdjustsStack; 00188 00189 /// HasCalls - Set to true if this function has any function calls. 00190 bool HasCalls; 00191 00192 /// StackProtectorIdx - The frame index for the stack protector. 00193 int StackProtectorIdx; 00194 00195 /// FunctionContextIdx - The frame index for the function context. Used for 00196 /// SjLj exceptions. 00197 int FunctionContextIdx; 00198 00199 /// MaxCallFrameSize - This contains the size of the largest call frame if the 00200 /// target uses frame setup/destroy pseudo instructions (as defined in the 00201 /// TargetFrameInfo class). This information is important for frame pointer 00202 /// elimination. If is only valid during and after prolog/epilog code 00203 /// insertion. 00204 /// 00205 unsigned MaxCallFrameSize; 00206 00207 /// CSInfo - The prolog/epilog code inserter fills in this vector with each 00208 /// callee saved register saved in the frame. Beyond its use by the prolog/ 00209 /// epilog code inserter, this data used for debug info and exception 00210 /// handling. 00211 std::vector<CalleeSavedInfo> CSInfo; 00212 00213 /// CSIValid - Has CSInfo been set yet? 00214 bool CSIValid; 00215 00216 /// LocalFrameObjects - References to frame indices which are mapped 00217 /// into the local frame allocation block. <FrameIdx, LocalOffset> 00218 SmallVector<std::pair<int, int64_t>, 32> LocalFrameObjects; 00219 00220 /// LocalFrameSize - Size of the pre-allocated local frame block. 00221 int64_t LocalFrameSize; 00222 00223 /// Required alignment of the local object blob, which is the strictest 00224 /// alignment of any object in it. 00225 unsigned LocalFrameMaxAlign; 00226 00227 /// Whether the local object blob needs to be allocated together. If not, 00228 /// PEI should ignore the isPreAllocated flags on the stack objects and 00229 /// just allocate them normally. 00230 bool UseLocalStackAllocationBlock; 00231 00232 /// Whether the "realign-stack" option is on. 00233 bool RealignOption; 00234 00235 /// True if the function includes inline assembly that adjusts the stack 00236 /// pointer. 00237 bool HasInlineAsmWithSPAdjust; 00238 00239 /// True if the function contains a call to the llvm.vastart intrinsic. 00240 bool HasVAStart; 00241 00242 /// True if this is a varargs function that contains a musttail call. 00243 bool HasMustTailInVarArgFunc; 00244 00245 const TargetFrameLowering *getFrameLowering() const; 00246 public: 00247 explicit MachineFrameInfo(const TargetMachine &TM, bool RealignOpt) 00248 : TM(TM), RealignOption(RealignOpt) { 00249 StackSize = NumFixedObjects = OffsetAdjustment = MaxAlignment = 0; 00250 HasVarSizedObjects = false; 00251 FrameAddressTaken = false; 00252 ReturnAddressTaken = false; 00253 HasStackMap = false; 00254 HasPatchPoint = false; 00255 AdjustsStack = false; 00256 HasCalls = false; 00257 StackProtectorIdx = -1; 00258 FunctionContextIdx = -1; 00259 MaxCallFrameSize = 0; 00260 CSIValid = false; 00261 LocalFrameSize = 0; 00262 LocalFrameMaxAlign = 0; 00263 UseLocalStackAllocationBlock = false; 00264 HasInlineAsmWithSPAdjust = false; 00265 HasVAStart = false; 00266 HasMustTailInVarArgFunc = false; 00267 } 00268 00269 /// hasStackObjects - Return true if there are any stack objects in this 00270 /// function. 00271 /// 00272 bool hasStackObjects() const { return !Objects.empty(); } 00273 00274 /// hasVarSizedObjects - This method may be called any time after instruction 00275 /// selection is complete to determine if the stack frame for this function 00276 /// contains any variable sized objects. 00277 /// 00278 bool hasVarSizedObjects() const { return HasVarSizedObjects; } 00279 00280 /// getStackProtectorIndex/setStackProtectorIndex - Return the index for the 00281 /// stack protector object. 00282 /// 00283 int getStackProtectorIndex() const { return StackProtectorIdx; } 00284 void setStackProtectorIndex(int I) { StackProtectorIdx = I; } 00285 00286 /// getFunctionContextIndex/setFunctionContextIndex - Return the index for the 00287 /// function context object. This object is used for SjLj exceptions. 00288 int getFunctionContextIndex() const { return FunctionContextIdx; } 00289 void setFunctionContextIndex(int I) { FunctionContextIdx = I; } 00290 00291 /// isFrameAddressTaken - This method may be called any time after instruction 00292 /// selection is complete to determine if there is a call to 00293 /// \@llvm.frameaddress in this function. 00294 bool isFrameAddressTaken() const { return FrameAddressTaken; } 00295 void setFrameAddressIsTaken(bool T) { FrameAddressTaken = T; } 00296 00297 /// isReturnAddressTaken - This method may be called any time after 00298 /// instruction selection is complete to determine if there is a call to 00299 /// \@llvm.returnaddress in this function. 00300 bool isReturnAddressTaken() const { return ReturnAddressTaken; } 00301 void setReturnAddressIsTaken(bool s) { ReturnAddressTaken = s; } 00302 00303 /// hasStackMap - This method may be called any time after instruction 00304 /// selection is complete to determine if there is a call to builtin 00305 /// \@llvm.experimental.stackmap. 00306 bool hasStackMap() const { return HasStackMap; } 00307 void setHasStackMap(bool s = true) { HasStackMap = s; } 00308 00309 /// hasPatchPoint - This method may be called any time after instruction 00310 /// selection is complete to determine if there is a call to builtin 00311 /// \@llvm.experimental.patchpoint. 00312 bool hasPatchPoint() const { return HasPatchPoint; } 00313 void setHasPatchPoint(bool s = true) { HasPatchPoint = s; } 00314 00315 /// getObjectIndexBegin - Return the minimum frame object index. 00316 /// 00317 int getObjectIndexBegin() const { return -NumFixedObjects; } 00318 00319 /// getObjectIndexEnd - Return one past the maximum frame object index. 00320 /// 00321 int getObjectIndexEnd() const { return (int)Objects.size()-NumFixedObjects; } 00322 00323 /// getNumFixedObjects - Return the number of fixed objects. 00324 unsigned getNumFixedObjects() const { return NumFixedObjects; } 00325 00326 /// getNumObjects - Return the number of objects. 00327 /// 00328 unsigned getNumObjects() const { return Objects.size(); } 00329 00330 /// mapLocalFrameObject - Map a frame index into the local object block 00331 void mapLocalFrameObject(int ObjectIndex, int64_t Offset) { 00332 LocalFrameObjects.push_back(std::pair<int, int64_t>(ObjectIndex, Offset)); 00333 Objects[ObjectIndex + NumFixedObjects].PreAllocated = true; 00334 } 00335 00336 /// getLocalFrameObjectMap - Get the local offset mapping for a for an object 00337 std::pair<int, int64_t> getLocalFrameObjectMap(int i) { 00338 assert (i >= 0 && (unsigned)i < LocalFrameObjects.size() && 00339 "Invalid local object reference!"); 00340 return LocalFrameObjects[i]; 00341 } 00342 00343 /// getLocalFrameObjectCount - Return the number of objects allocated into 00344 /// the local object block. 00345 int64_t getLocalFrameObjectCount() { return LocalFrameObjects.size(); } 00346 00347 /// setLocalFrameSize - Set the size of the local object blob. 00348 void setLocalFrameSize(int64_t sz) { LocalFrameSize = sz; } 00349 00350 /// getLocalFrameSize - Get the size of the local object blob. 00351 int64_t getLocalFrameSize() const { return LocalFrameSize; } 00352 00353 /// setLocalFrameMaxAlign - Required alignment of the local object blob, 00354 /// which is the strictest alignment of any object in it. 00355 void setLocalFrameMaxAlign(unsigned Align) { LocalFrameMaxAlign = Align; } 00356 00357 /// getLocalFrameMaxAlign - Return the required alignment of the local 00358 /// object blob. 00359 unsigned getLocalFrameMaxAlign() const { return LocalFrameMaxAlign; } 00360 00361 /// getUseLocalStackAllocationBlock - Get whether the local allocation blob 00362 /// should be allocated together or let PEI allocate the locals in it 00363 /// directly. 00364 bool getUseLocalStackAllocationBlock() {return UseLocalStackAllocationBlock;} 00365 00366 /// setUseLocalStackAllocationBlock - Set whether the local allocation blob 00367 /// should be allocated together or let PEI allocate the locals in it 00368 /// directly. 00369 void setUseLocalStackAllocationBlock(bool v) { 00370 UseLocalStackAllocationBlock = v; 00371 } 00372 00373 /// isObjectPreAllocated - Return true if the object was pre-allocated into 00374 /// the local block. 00375 bool isObjectPreAllocated(int ObjectIdx) const { 00376 assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() && 00377 "Invalid Object Idx!"); 00378 return Objects[ObjectIdx+NumFixedObjects].PreAllocated; 00379 } 00380 00381 /// getObjectSize - Return the size of the specified object. 00382 /// 00383 int64_t getObjectSize(int ObjectIdx) const { 00384 assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() && 00385 "Invalid Object Idx!"); 00386 return Objects[ObjectIdx+NumFixedObjects].Size; 00387 } 00388 00389 /// setObjectSize - Change the size of the specified stack object. 00390 void setObjectSize(int ObjectIdx, int64_t Size) { 00391 assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() && 00392 "Invalid Object Idx!"); 00393 Objects[ObjectIdx+NumFixedObjects].Size = Size; 00394 } 00395 00396 /// getObjectAlignment - Return the alignment of the specified stack object. 00397 unsigned getObjectAlignment(int ObjectIdx) const { 00398 assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() && 00399 "Invalid Object Idx!"); 00400 return Objects[ObjectIdx+NumFixedObjects].Alignment; 00401 } 00402 00403 /// setObjectAlignment - Change the alignment of the specified stack object. 00404 void setObjectAlignment(int ObjectIdx, unsigned Align) { 00405 assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() && 00406 "Invalid Object Idx!"); 00407 Objects[ObjectIdx+NumFixedObjects].Alignment = Align; 00408 ensureMaxAlignment(Align); 00409 } 00410 00411 /// getObjectAllocation - Return the underlying Alloca of the specified 00412 /// stack object if it exists. Returns 0 if none exists. 00413 const AllocaInst* getObjectAllocation(int ObjectIdx) const { 00414 assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() && 00415 "Invalid Object Idx!"); 00416 return Objects[ObjectIdx+NumFixedObjects].Alloca; 00417 } 00418 00419 /// getObjectOffset - Return the assigned stack offset of the specified object 00420 /// from the incoming stack pointer. 00421 /// 00422 int64_t getObjectOffset(int ObjectIdx) const { 00423 assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() && 00424 "Invalid Object Idx!"); 00425 assert(!isDeadObjectIndex(ObjectIdx) && 00426 "Getting frame offset for a dead object?"); 00427 return Objects[ObjectIdx+NumFixedObjects].SPOffset; 00428 } 00429 00430 /// setObjectOffset - Set the stack frame offset of the specified object. The 00431 /// offset is relative to the stack pointer on entry to the function. 00432 /// 00433 void setObjectOffset(int ObjectIdx, int64_t SPOffset) { 00434 assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() && 00435 "Invalid Object Idx!"); 00436 assert(!isDeadObjectIndex(ObjectIdx) && 00437 "Setting frame offset for a dead object?"); 00438 Objects[ObjectIdx+NumFixedObjects].SPOffset = SPOffset; 00439 } 00440 00441 /// getStackSize - Return the number of bytes that must be allocated to hold 00442 /// all of the fixed size frame objects. This is only valid after 00443 /// Prolog/Epilog code insertion has finalized the stack frame layout. 00444 /// 00445 uint64_t getStackSize() const { return StackSize; } 00446 00447 /// setStackSize - Set the size of the stack... 00448 /// 00449 void setStackSize(uint64_t Size) { StackSize = Size; } 00450 00451 /// Estimate and return the size of the stack frame. 00452 unsigned estimateStackSize(const MachineFunction &MF) const; 00453 00454 /// getOffsetAdjustment - Return the correction for frame offsets. 00455 /// 00456 int getOffsetAdjustment() const { return OffsetAdjustment; } 00457 00458 /// setOffsetAdjustment - Set the correction for frame offsets. 00459 /// 00460 void setOffsetAdjustment(int Adj) { OffsetAdjustment = Adj; } 00461 00462 /// getMaxAlignment - Return the alignment in bytes that this function must be 00463 /// aligned to, which is greater than the default stack alignment provided by 00464 /// the target. 00465 /// 00466 unsigned getMaxAlignment() const { return MaxAlignment; } 00467 00468 /// ensureMaxAlignment - Make sure the function is at least Align bytes 00469 /// aligned. 00470 void ensureMaxAlignment(unsigned Align); 00471 00472 /// AdjustsStack - Return true if this function adjusts the stack -- e.g., 00473 /// when calling another function. This is only valid during and after 00474 /// prolog/epilog code insertion. 00475 bool adjustsStack() const { return AdjustsStack; } 00476 void setAdjustsStack(bool V) { AdjustsStack = V; } 00477 00478 /// hasCalls - Return true if the current function has any function calls. 00479 bool hasCalls() const { return HasCalls; } 00480 void setHasCalls(bool V) { HasCalls = V; } 00481 00482 /// Returns true if the function contains any stack-adjusting inline assembly. 00483 bool hasInlineAsmWithSPAdjust() const { return HasInlineAsmWithSPAdjust; } 00484 void setHasInlineAsmWithSPAdjust(bool B) { HasInlineAsmWithSPAdjust = B; } 00485 00486 /// Returns true if the function calls the llvm.va_start intrinsic. 00487 bool hasVAStart() const { return HasVAStart; } 00488 void setHasVAStart(bool B) { HasVAStart = B; } 00489 00490 /// Returns true if the function is variadic and contains a musttail call. 00491 bool hasMustTailInVarArgFunc() const { return HasMustTailInVarArgFunc; } 00492 void setHasMustTailInVarArgFunc(bool B) { HasMustTailInVarArgFunc = B; } 00493 00494 /// getMaxCallFrameSize - Return the maximum size of a call frame that must be 00495 /// allocated for an outgoing function call. This is only available if 00496 /// CallFrameSetup/Destroy pseudo instructions are used by the target, and 00497 /// then only during or after prolog/epilog code insertion. 00498 /// 00499 unsigned getMaxCallFrameSize() const { return MaxCallFrameSize; } 00500 void setMaxCallFrameSize(unsigned S) { MaxCallFrameSize = S; } 00501 00502 /// CreateFixedObject - Create a new object at a fixed location on the stack. 00503 /// All fixed objects should be created before other objects are created for 00504 /// efficiency. By default, fixed objects are not pointed to by LLVM IR 00505 /// values. This returns an index with a negative value. 00506 /// 00507 int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool Immutable, 00508 bool isAliased = false); 00509 00510 /// CreateFixedSpillStackObject - Create a spill slot at a fixed location 00511 /// on the stack. Returns an index with a negative value. 00512 int CreateFixedSpillStackObject(uint64_t Size, int64_t SPOffset); 00513 00514 /// isFixedObjectIndex - Returns true if the specified index corresponds to a 00515 /// fixed stack object. 00516 bool isFixedObjectIndex(int ObjectIdx) const { 00517 return ObjectIdx < 0 && (ObjectIdx >= -(int)NumFixedObjects); 00518 } 00519 00520 /// isAliasedObjectIndex - Returns true if the specified index corresponds 00521 /// to an object that might be pointed to by an LLVM IR value. 00522 bool isAliasedObjectIndex(int ObjectIdx) const { 00523 assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() && 00524 "Invalid Object Idx!"); 00525 return Objects[ObjectIdx+NumFixedObjects].isAliased; 00526 } 00527 00528 /// isImmutableObjectIndex - Returns true if the specified index corresponds 00529 /// to an immutable object. 00530 bool isImmutableObjectIndex(int ObjectIdx) const { 00531 assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() && 00532 "Invalid Object Idx!"); 00533 return Objects[ObjectIdx+NumFixedObjects].isImmutable; 00534 } 00535 00536 /// isSpillSlotObjectIndex - Returns true if the specified index corresponds 00537 /// to a spill slot.. 00538 bool isSpillSlotObjectIndex(int ObjectIdx) const { 00539 assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() && 00540 "Invalid Object Idx!"); 00541 return Objects[ObjectIdx+NumFixedObjects].isSpillSlot; 00542 } 00543 00544 /// isDeadObjectIndex - Returns true if the specified index corresponds to 00545 /// a dead object. 00546 bool isDeadObjectIndex(int ObjectIdx) const { 00547 assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() && 00548 "Invalid Object Idx!"); 00549 return Objects[ObjectIdx+NumFixedObjects].Size == ~0ULL; 00550 } 00551 00552 /// CreateStackObject - Create a new statically sized stack object, returning 00553 /// a nonnegative identifier to represent it. 00554 /// 00555 int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSS, 00556 const AllocaInst *Alloca = nullptr); 00557 00558 /// CreateSpillStackObject - Create a new statically sized stack object that 00559 /// represents a spill slot, returning a nonnegative identifier to represent 00560 /// it. 00561 /// 00562 int CreateSpillStackObject(uint64_t Size, unsigned Alignment); 00563 00564 /// RemoveStackObject - Remove or mark dead a statically sized stack object. 00565 /// 00566 void RemoveStackObject(int ObjectIdx) { 00567 // Mark it dead. 00568 Objects[ObjectIdx+NumFixedObjects].Size = ~0ULL; 00569 } 00570 00571 /// CreateVariableSizedObject - Notify the MachineFrameInfo object that a 00572 /// variable sized object has been created. This must be created whenever a 00573 /// variable sized object is created, whether or not the index returned is 00574 /// actually used. 00575 /// 00576 int CreateVariableSizedObject(unsigned Alignment, const AllocaInst *Alloca); 00577 00578 /// getCalleeSavedInfo - Returns a reference to call saved info vector for the 00579 /// current function. 00580 const std::vector<CalleeSavedInfo> &getCalleeSavedInfo() const { 00581 return CSInfo; 00582 } 00583 00584 /// setCalleeSavedInfo - Used by prolog/epilog inserter to set the function's 00585 /// callee saved information. 00586 void setCalleeSavedInfo(const std::vector<CalleeSavedInfo> &CSI) { 00587 CSInfo = CSI; 00588 } 00589 00590 /// isCalleeSavedInfoValid - Has the callee saved info been calculated yet? 00591 bool isCalleeSavedInfoValid() const { return CSIValid; } 00592 00593 void setCalleeSavedInfoValid(bool v) { CSIValid = v; } 00594 00595 /// getPristineRegs - Return a set of physical registers that are pristine on 00596 /// entry to the MBB. 00597 /// 00598 /// Pristine registers hold a value that is useless to the current function, 00599 /// but that must be preserved - they are callee saved registers that have not 00600 /// been saved yet. 00601 /// 00602 /// Before the PrologueEpilogueInserter has placed the CSR spill code, this 00603 /// method always returns an empty set. 00604 BitVector getPristineRegs(const MachineBasicBlock *MBB) const; 00605 00606 /// print - Used by the MachineFunction printer to print information about 00607 /// stack objects. Implemented in MachineFunction.cpp 00608 /// 00609 void print(const MachineFunction &MF, raw_ostream &OS) const; 00610 00611 /// dump - Print the function to stderr. 00612 void dump(const MachineFunction &MF) const; 00613 }; 00614 00615 } // End llvm namespace 00616 00617 #endif