1 //===-- CodeGen/MachineFrameInfo.h - Abstract Stack Frame Rep. --*- 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 // The file defines the MachineFrameInfo class. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #ifndef LLVM_CODEGEN_MACHINEFRAMEINFO_H 15 #define LLVM_CODEGEN_MACHINEFRAMEINFO_H 16 17 #include "llvm/ADT/SmallVector.h" 18 #include "llvm/Support/DataTypes.h" 19 #include <cassert> 20 #include <vector> 21 22 namespace llvm { 23 class raw_ostream; 24 class DataLayout; 25 class TargetRegisterClass; 26 class Type; 27 class MachineFunction; 28 class MachineBasicBlock; 29 class TargetFrameLowering; 30 class TargetMachine; 31 class BitVector; 32 class Value; 33 class AllocaInst; 34 35 /// The CalleeSavedInfo class tracks the information need to locate where a 36 /// callee saved register is in the current frame. 37 class CalleeSavedInfo { 38 unsigned Reg; 39 int FrameIdx; 40 41 public: 42 explicit CalleeSavedInfo(unsigned R, int FI = 0) Reg(R)43 : Reg(R), FrameIdx(FI) {} 44 45 // Accessors. getReg()46 unsigned getReg() const { return Reg; } getFrameIdx()47 int getFrameIdx() const { return FrameIdx; } setFrameIdx(int FI)48 void setFrameIdx(int FI) { FrameIdx = FI; } 49 }; 50 51 /// The MachineFrameInfo class represents an abstract stack frame until 52 /// prolog/epilog code is inserted. This class is key to allowing stack frame 53 /// representation optimizations, such as frame pointer elimination. It also 54 /// allows more mundane (but still important) optimizations, such as reordering 55 /// of abstract objects on the stack frame. 56 /// 57 /// To support this, the class assigns unique integer identifiers to stack 58 /// objects requested clients. These identifiers are negative integers for 59 /// fixed stack objects (such as arguments passed on the stack) or nonnegative 60 /// for objects that may be reordered. Instructions which refer to stack 61 /// objects use a special MO_FrameIndex operand to represent these frame 62 /// indexes. 63 /// 64 /// Because this class keeps track of all references to the stack frame, it 65 /// knows when a variable sized object is allocated on the stack. This is the 66 /// sole condition which prevents frame pointer elimination, which is an 67 /// important optimization on register-poor architectures. Because original 68 /// variable sized alloca's in the source program are the only source of 69 /// variable sized stack objects, it is safe to decide whether there will be 70 /// any variable sized objects before all stack objects are known (for 71 /// example, register allocator spill code never needs variable sized 72 /// objects). 73 /// 74 /// When prolog/epilog code emission is performed, the final stack frame is 75 /// built and the machine instructions are modified to refer to the actual 76 /// stack offsets of the object, eliminating all MO_FrameIndex operands from 77 /// the program. 78 /// 79 /// @brief Abstract Stack Frame Information 80 class MachineFrameInfo { 81 82 // StackObject - Represent a single object allocated on the stack. 83 struct StackObject { 84 // SPOffset - The offset of this object from the stack pointer on entry to 85 // the function. This field has no meaning for a variable sized element. 86 int64_t SPOffset; 87 88 // The size of this object on the stack. 0 means a variable sized object, 89 // ~0ULL means a dead object. 90 uint64_t Size; 91 92 // Alignment - The required alignment of this stack slot. 93 unsigned Alignment; 94 95 // isImmutable - If true, the value of the stack object is set before 96 // entering the function and is not modified inside the function. By 97 // default, fixed objects are immutable unless marked otherwise. 98 bool isImmutable; 99 100 // isSpillSlot - If true the stack object is used as spill slot. It 101 // cannot alias any other memory objects. 102 bool isSpillSlot; 103 104 /// Alloca - If this stack object is originated from an Alloca instruction 105 /// this value saves the original IR allocation. Can be NULL. 106 const AllocaInst *Alloca; 107 108 // PreAllocated - If true, the object was mapped into the local frame 109 // block and doesn't need additional handling for allocation beyond that. 110 bool PreAllocated; 111 StackObjectStackObject112 StackObject(uint64_t Sz, unsigned Al, int64_t SP, bool IM, 113 bool isSS, const AllocaInst *Val) 114 : SPOffset(SP), Size(Sz), Alignment(Al), isImmutable(IM), 115 isSpillSlot(isSS), Alloca(Val), PreAllocated(false) {} 116 }; 117 118 const TargetMachine &TM; 119 120 /// Objects - The list of stack objects allocated... 121 /// 122 std::vector<StackObject> Objects; 123 124 /// NumFixedObjects - This contains the number of fixed objects contained on 125 /// the stack. Because fixed objects are stored at a negative index in the 126 /// Objects list, this is also the index to the 0th object in the list. 127 /// 128 unsigned NumFixedObjects; 129 130 /// HasVarSizedObjects - This boolean keeps track of whether any variable 131 /// sized objects have been allocated yet. 132 /// 133 bool HasVarSizedObjects; 134 135 /// FrameAddressTaken - This boolean keeps track of whether there is a call 136 /// to builtin \@llvm.frameaddress. 137 bool FrameAddressTaken; 138 139 /// ReturnAddressTaken - This boolean keeps track of whether there is a call 140 /// to builtin \@llvm.returnaddress. 141 bool ReturnAddressTaken; 142 143 /// HasStackMap - This boolean keeps track of whether there is a call 144 /// to builtin \@llvm.experimental.stackmap. 145 bool HasStackMap; 146 147 /// HasPatchPoint - This boolean keeps track of whether there is a call 148 /// to builtin \@llvm.experimental.patchpoint. 149 bool HasPatchPoint; 150 151 /// StackSize - The prolog/epilog code inserter calculates the final stack 152 /// offsets for all of the fixed size objects, updating the Objects list 153 /// above. It then updates StackSize to contain the number of bytes that need 154 /// to be allocated on entry to the function. 155 /// 156 uint64_t StackSize; 157 158 /// OffsetAdjustment - The amount that a frame offset needs to be adjusted to 159 /// have the actual offset from the stack/frame pointer. The exact usage of 160 /// this is target-dependent, but it is typically used to adjust between 161 /// SP-relative and FP-relative offsets. E.G., if objects are accessed via 162 /// SP then OffsetAdjustment is zero; if FP is used, OffsetAdjustment is set 163 /// to the distance between the initial SP and the value in FP. For many 164 /// targets, this value is only used when generating debug info (via 165 /// TargetRegisterInfo::getFrameIndexOffset); when generating code, the 166 /// corresponding adjustments are performed directly. 167 int OffsetAdjustment; 168 169 /// MaxAlignment - The prolog/epilog code inserter may process objects 170 /// that require greater alignment than the default alignment the target 171 /// provides. To handle this, MaxAlignment is set to the maximum alignment 172 /// needed by the objects on the current frame. If this is greater than the 173 /// native alignment maintained by the compiler, dynamic alignment code will 174 /// be needed. 175 /// 176 unsigned MaxAlignment; 177 178 /// AdjustsStack - Set to true if this function adjusts the stack -- e.g., 179 /// when calling another function. This is only valid during and after 180 /// prolog/epilog code insertion. 181 bool AdjustsStack; 182 183 /// HasCalls - Set to true if this function has any function calls. 184 bool HasCalls; 185 186 /// StackProtectorIdx - The frame index for the stack protector. 187 int StackProtectorIdx; 188 189 /// FunctionContextIdx - The frame index for the function context. Used for 190 /// SjLj exceptions. 191 int FunctionContextIdx; 192 193 /// MaxCallFrameSize - This contains the size of the largest call frame if the 194 /// target uses frame setup/destroy pseudo instructions (as defined in the 195 /// TargetFrameInfo class). This information is important for frame pointer 196 /// elimination. If is only valid during and after prolog/epilog code 197 /// insertion. 198 /// 199 unsigned MaxCallFrameSize; 200 201 /// CSInfo - The prolog/epilog code inserter fills in this vector with each 202 /// callee saved register saved in the frame. Beyond its use by the prolog/ 203 /// epilog code inserter, this data used for debug info and exception 204 /// handling. 205 std::vector<CalleeSavedInfo> CSInfo; 206 207 /// CSIValid - Has CSInfo been set yet? 208 bool CSIValid; 209 210 /// LocalFrameObjects - References to frame indices which are mapped 211 /// into the local frame allocation block. <FrameIdx, LocalOffset> 212 SmallVector<std::pair<int, int64_t>, 32> LocalFrameObjects; 213 214 /// LocalFrameSize - Size of the pre-allocated local frame block. 215 int64_t LocalFrameSize; 216 217 /// Required alignment of the local object blob, which is the strictest 218 /// alignment of any object in it. 219 unsigned LocalFrameMaxAlign; 220 221 /// Whether the local object blob needs to be allocated together. If not, 222 /// PEI should ignore the isPreAllocated flags on the stack objects and 223 /// just allocate them normally. 224 bool UseLocalStackAllocationBlock; 225 226 /// Whether the "realign-stack" option is on. 227 bool RealignOption; 228 229 /// True if the function includes inline assembly that adjusts the stack 230 /// pointer. 231 bool HasInlineAsmWithSPAdjust; 232 233 const TargetFrameLowering *getFrameLowering() const; 234 public: MachineFrameInfo(const TargetMachine & TM,bool RealignOpt)235 explicit MachineFrameInfo(const TargetMachine &TM, bool RealignOpt) 236 : TM(TM), RealignOption(RealignOpt) { 237 StackSize = NumFixedObjects = OffsetAdjustment = MaxAlignment = 0; 238 HasVarSizedObjects = false; 239 FrameAddressTaken = false; 240 ReturnAddressTaken = false; 241 HasStackMap = false; 242 HasPatchPoint = false; 243 AdjustsStack = false; 244 HasCalls = false; 245 StackProtectorIdx = -1; 246 FunctionContextIdx = -1; 247 MaxCallFrameSize = 0; 248 CSIValid = false; 249 LocalFrameSize = 0; 250 LocalFrameMaxAlign = 0; 251 UseLocalStackAllocationBlock = false; 252 HasInlineAsmWithSPAdjust = false; 253 } 254 255 /// hasStackObjects - Return true if there are any stack objects in this 256 /// function. 257 /// hasStackObjects()258 bool hasStackObjects() const { return !Objects.empty(); } 259 260 /// hasVarSizedObjects - This method may be called any time after instruction 261 /// selection is complete to determine if the stack frame for this function 262 /// contains any variable sized objects. 263 /// hasVarSizedObjects()264 bool hasVarSizedObjects() const { return HasVarSizedObjects; } 265 266 /// getStackProtectorIndex/setStackProtectorIndex - Return the index for the 267 /// stack protector object. 268 /// getStackProtectorIndex()269 int getStackProtectorIndex() const { return StackProtectorIdx; } setStackProtectorIndex(int I)270 void setStackProtectorIndex(int I) { StackProtectorIdx = I; } 271 272 /// getFunctionContextIndex/setFunctionContextIndex - Return the index for the 273 /// function context object. This object is used for SjLj exceptions. getFunctionContextIndex()274 int getFunctionContextIndex() const { return FunctionContextIdx; } setFunctionContextIndex(int I)275 void setFunctionContextIndex(int I) { FunctionContextIdx = I; } 276 277 /// isFrameAddressTaken - This method may be called any time after instruction 278 /// selection is complete to determine if there is a call to 279 /// \@llvm.frameaddress in this function. isFrameAddressTaken()280 bool isFrameAddressTaken() const { return FrameAddressTaken; } setFrameAddressIsTaken(bool T)281 void setFrameAddressIsTaken(bool T) { FrameAddressTaken = T; } 282 283 /// isReturnAddressTaken - This method may be called any time after 284 /// instruction selection is complete to determine if there is a call to 285 /// \@llvm.returnaddress in this function. isReturnAddressTaken()286 bool isReturnAddressTaken() const { return ReturnAddressTaken; } setReturnAddressIsTaken(bool s)287 void setReturnAddressIsTaken(bool s) { ReturnAddressTaken = s; } 288 289 /// hasStackMap - This method may be called any time after instruction 290 /// selection is complete to determine if there is a call to builtin 291 /// \@llvm.experimental.stackmap. hasStackMap()292 bool hasStackMap() const { return HasStackMap; } 293 void setHasStackMap(bool s = true) { HasStackMap = s; } 294 295 /// hasPatchPoint - This method may be called any time after instruction 296 /// selection is complete to determine if there is a call to builtin 297 /// \@llvm.experimental.patchpoint. hasPatchPoint()298 bool hasPatchPoint() const { return HasPatchPoint; } 299 void setHasPatchPoint(bool s = true) { HasPatchPoint = s; } 300 301 /// getObjectIndexBegin - Return the minimum frame object index. 302 /// getObjectIndexBegin()303 int getObjectIndexBegin() const { return -NumFixedObjects; } 304 305 /// getObjectIndexEnd - Return one past the maximum frame object index. 306 /// getObjectIndexEnd()307 int getObjectIndexEnd() const { return (int)Objects.size()-NumFixedObjects; } 308 309 /// getNumFixedObjects - Return the number of fixed objects. getNumFixedObjects()310 unsigned getNumFixedObjects() const { return NumFixedObjects; } 311 312 /// getNumObjects - Return the number of objects. 313 /// getNumObjects()314 unsigned getNumObjects() const { return Objects.size(); } 315 316 /// mapLocalFrameObject - Map a frame index into the local object block mapLocalFrameObject(int ObjectIndex,int64_t Offset)317 void mapLocalFrameObject(int ObjectIndex, int64_t Offset) { 318 LocalFrameObjects.push_back(std::pair<int, int64_t>(ObjectIndex, Offset)); 319 Objects[ObjectIndex + NumFixedObjects].PreAllocated = true; 320 } 321 322 /// getLocalFrameObjectMap - Get the local offset mapping for a for an object getLocalFrameObjectMap(int i)323 std::pair<int, int64_t> getLocalFrameObjectMap(int i) { 324 assert (i >= 0 && (unsigned)i < LocalFrameObjects.size() && 325 "Invalid local object reference!"); 326 return LocalFrameObjects[i]; 327 } 328 329 /// getLocalFrameObjectCount - Return the number of objects allocated into 330 /// the local object block. getLocalFrameObjectCount()331 int64_t getLocalFrameObjectCount() { return LocalFrameObjects.size(); } 332 333 /// setLocalFrameSize - Set the size of the local object blob. setLocalFrameSize(int64_t sz)334 void setLocalFrameSize(int64_t sz) { LocalFrameSize = sz; } 335 336 /// getLocalFrameSize - Get the size of the local object blob. getLocalFrameSize()337 int64_t getLocalFrameSize() const { return LocalFrameSize; } 338 339 /// setLocalFrameMaxAlign - Required alignment of the local object blob, 340 /// which is the strictest alignment of any object in it. setLocalFrameMaxAlign(unsigned Align)341 void setLocalFrameMaxAlign(unsigned Align) { LocalFrameMaxAlign = Align; } 342 343 /// getLocalFrameMaxAlign - Return the required alignment of the local 344 /// object blob. getLocalFrameMaxAlign()345 unsigned getLocalFrameMaxAlign() const { return LocalFrameMaxAlign; } 346 347 /// getUseLocalStackAllocationBlock - Get whether the local allocation blob 348 /// should be allocated together or let PEI allocate the locals in it 349 /// directly. getUseLocalStackAllocationBlock()350 bool getUseLocalStackAllocationBlock() {return UseLocalStackAllocationBlock;} 351 352 /// setUseLocalStackAllocationBlock - Set whether the local allocation blob 353 /// should be allocated together or let PEI allocate the locals in it 354 /// directly. setUseLocalStackAllocationBlock(bool v)355 void setUseLocalStackAllocationBlock(bool v) { 356 UseLocalStackAllocationBlock = v; 357 } 358 359 /// isObjectPreAllocated - Return true if the object was pre-allocated into 360 /// the local block. isObjectPreAllocated(int ObjectIdx)361 bool isObjectPreAllocated(int ObjectIdx) const { 362 assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() && 363 "Invalid Object Idx!"); 364 return Objects[ObjectIdx+NumFixedObjects].PreAllocated; 365 } 366 367 /// getObjectSize - Return the size of the specified object. 368 /// getObjectSize(int ObjectIdx)369 int64_t getObjectSize(int ObjectIdx) const { 370 assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() && 371 "Invalid Object Idx!"); 372 return Objects[ObjectIdx+NumFixedObjects].Size; 373 } 374 375 /// setObjectSize - Change the size of the specified stack object. setObjectSize(int ObjectIdx,int64_t Size)376 void setObjectSize(int ObjectIdx, int64_t Size) { 377 assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() && 378 "Invalid Object Idx!"); 379 Objects[ObjectIdx+NumFixedObjects].Size = Size; 380 } 381 382 /// getObjectAlignment - Return the alignment of the specified stack object. getObjectAlignment(int ObjectIdx)383 unsigned getObjectAlignment(int ObjectIdx) const { 384 assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() && 385 "Invalid Object Idx!"); 386 return Objects[ObjectIdx+NumFixedObjects].Alignment; 387 } 388 389 /// setObjectAlignment - Change the alignment of the specified stack object. setObjectAlignment(int ObjectIdx,unsigned Align)390 void setObjectAlignment(int ObjectIdx, unsigned Align) { 391 assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() && 392 "Invalid Object Idx!"); 393 Objects[ObjectIdx+NumFixedObjects].Alignment = Align; 394 ensureMaxAlignment(Align); 395 } 396 397 /// getObjectAllocation - Return the underlying Alloca of the specified 398 /// stack object if it exists. Returns 0 if none exists. getObjectAllocation(int ObjectIdx)399 const AllocaInst* getObjectAllocation(int ObjectIdx) const { 400 assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() && 401 "Invalid Object Idx!"); 402 return Objects[ObjectIdx+NumFixedObjects].Alloca; 403 } 404 405 /// getObjectOffset - Return the assigned stack offset of the specified object 406 /// from the incoming stack pointer. 407 /// getObjectOffset(int ObjectIdx)408 int64_t getObjectOffset(int ObjectIdx) const { 409 assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() && 410 "Invalid Object Idx!"); 411 assert(!isDeadObjectIndex(ObjectIdx) && 412 "Getting frame offset for a dead object?"); 413 return Objects[ObjectIdx+NumFixedObjects].SPOffset; 414 } 415 416 /// setObjectOffset - Set the stack frame offset of the specified object. The 417 /// offset is relative to the stack pointer on entry to the function. 418 /// setObjectOffset(int ObjectIdx,int64_t SPOffset)419 void setObjectOffset(int ObjectIdx, int64_t SPOffset) { 420 assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() && 421 "Invalid Object Idx!"); 422 assert(!isDeadObjectIndex(ObjectIdx) && 423 "Setting frame offset for a dead object?"); 424 Objects[ObjectIdx+NumFixedObjects].SPOffset = SPOffset; 425 } 426 427 /// getStackSize - Return the number of bytes that must be allocated to hold 428 /// all of the fixed size frame objects. This is only valid after 429 /// Prolog/Epilog code insertion has finalized the stack frame layout. 430 /// getStackSize()431 uint64_t getStackSize() const { return StackSize; } 432 433 /// setStackSize - Set the size of the stack... 434 /// setStackSize(uint64_t Size)435 void setStackSize(uint64_t Size) { StackSize = Size; } 436 437 /// Estimate and return the size of the stack frame. 438 unsigned estimateStackSize(const MachineFunction &MF) const; 439 440 /// getOffsetAdjustment - Return the correction for frame offsets. 441 /// getOffsetAdjustment()442 int getOffsetAdjustment() const { return OffsetAdjustment; } 443 444 /// setOffsetAdjustment - Set the correction for frame offsets. 445 /// setOffsetAdjustment(int Adj)446 void setOffsetAdjustment(int Adj) { OffsetAdjustment = Adj; } 447 448 /// getMaxAlignment - Return the alignment in bytes that this function must be 449 /// aligned to, which is greater than the default stack alignment provided by 450 /// the target. 451 /// getMaxAlignment()452 unsigned getMaxAlignment() const { return MaxAlignment; } 453 454 /// ensureMaxAlignment - Make sure the function is at least Align bytes 455 /// aligned. 456 void ensureMaxAlignment(unsigned Align); 457 458 /// AdjustsStack - Return true if this function adjusts the stack -- e.g., 459 /// when calling another function. This is only valid during and after 460 /// prolog/epilog code insertion. adjustsStack()461 bool adjustsStack() const { return AdjustsStack; } setAdjustsStack(bool V)462 void setAdjustsStack(bool V) { AdjustsStack = V; } 463 464 /// hasCalls - Return true if the current function has any function calls. hasCalls()465 bool hasCalls() const { return HasCalls; } setHasCalls(bool V)466 void setHasCalls(bool V) { HasCalls = V; } 467 468 /// Returns true if the function contains any stack-adjusting inline assembly. hasInlineAsmWithSPAdjust()469 bool hasInlineAsmWithSPAdjust() const { return HasInlineAsmWithSPAdjust; } setHasInlineAsmWithSPAdjust(bool B)470 void setHasInlineAsmWithSPAdjust(bool B) { HasInlineAsmWithSPAdjust = B; } 471 472 /// getMaxCallFrameSize - Return the maximum size of a call frame that must be 473 /// allocated for an outgoing function call. This is only available if 474 /// CallFrameSetup/Destroy pseudo instructions are used by the target, and 475 /// then only during or after prolog/epilog code insertion. 476 /// getMaxCallFrameSize()477 unsigned getMaxCallFrameSize() const { return MaxCallFrameSize; } setMaxCallFrameSize(unsigned S)478 void setMaxCallFrameSize(unsigned S) { MaxCallFrameSize = S; } 479 480 /// CreateFixedObject - Create a new object at a fixed location on the stack. 481 /// All fixed objects should be created before other objects are created for 482 /// efficiency. By default, fixed objects are immutable. This returns an 483 /// index with a negative value. 484 /// 485 int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool Immutable); 486 487 /// CreateFixedSpillStackObject - Create a spill slot at a fixed location 488 /// on the stack. Returns an index with a negative value. 489 int CreateFixedSpillStackObject(uint64_t Size, int64_t SPOffset); 490 491 /// isFixedObjectIndex - Returns true if the specified index corresponds to a 492 /// fixed stack object. isFixedObjectIndex(int ObjectIdx)493 bool isFixedObjectIndex(int ObjectIdx) const { 494 return ObjectIdx < 0 && (ObjectIdx >= -(int)NumFixedObjects); 495 } 496 497 /// isImmutableObjectIndex - Returns true if the specified index corresponds 498 /// to an immutable object. isImmutableObjectIndex(int ObjectIdx)499 bool isImmutableObjectIndex(int ObjectIdx) const { 500 assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() && 501 "Invalid Object Idx!"); 502 return Objects[ObjectIdx+NumFixedObjects].isImmutable; 503 } 504 505 /// isSpillSlotObjectIndex - Returns true if the specified index corresponds 506 /// to a spill slot.. isSpillSlotObjectIndex(int ObjectIdx)507 bool isSpillSlotObjectIndex(int ObjectIdx) const { 508 assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() && 509 "Invalid Object Idx!"); 510 return Objects[ObjectIdx+NumFixedObjects].isSpillSlot; 511 } 512 513 /// isDeadObjectIndex - Returns true if the specified index corresponds to 514 /// a dead object. isDeadObjectIndex(int ObjectIdx)515 bool isDeadObjectIndex(int ObjectIdx) const { 516 assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() && 517 "Invalid Object Idx!"); 518 return Objects[ObjectIdx+NumFixedObjects].Size == ~0ULL; 519 } 520 521 /// CreateStackObject - Create a new statically sized stack object, returning 522 /// a nonnegative identifier to represent it. 523 /// 524 int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSS, 525 const AllocaInst *Alloca = nullptr); 526 527 /// CreateSpillStackObject - Create a new statically sized stack object that 528 /// represents a spill slot, returning a nonnegative identifier to represent 529 /// it. 530 /// 531 int CreateSpillStackObject(uint64_t Size, unsigned Alignment); 532 533 /// RemoveStackObject - Remove or mark dead a statically sized stack object. 534 /// RemoveStackObject(int ObjectIdx)535 void RemoveStackObject(int ObjectIdx) { 536 // Mark it dead. 537 Objects[ObjectIdx+NumFixedObjects].Size = ~0ULL; 538 } 539 540 /// CreateVariableSizedObject - Notify the MachineFrameInfo object that a 541 /// variable sized object has been created. This must be created whenever a 542 /// variable sized object is created, whether or not the index returned is 543 /// actually used. 544 /// 545 int CreateVariableSizedObject(unsigned Alignment, const AllocaInst *Alloca); 546 547 /// getCalleeSavedInfo - Returns a reference to call saved info vector for the 548 /// current function. getCalleeSavedInfo()549 const std::vector<CalleeSavedInfo> &getCalleeSavedInfo() const { 550 return CSInfo; 551 } 552 553 /// setCalleeSavedInfo - Used by prolog/epilog inserter to set the function's 554 /// callee saved information. setCalleeSavedInfo(const std::vector<CalleeSavedInfo> & CSI)555 void setCalleeSavedInfo(const std::vector<CalleeSavedInfo> &CSI) { 556 CSInfo = CSI; 557 } 558 559 /// isCalleeSavedInfoValid - Has the callee saved info been calculated yet? isCalleeSavedInfoValid()560 bool isCalleeSavedInfoValid() const { return CSIValid; } 561 setCalleeSavedInfoValid(bool v)562 void setCalleeSavedInfoValid(bool v) { CSIValid = v; } 563 564 /// getPristineRegs - Return a set of physical registers that are pristine on 565 /// entry to the MBB. 566 /// 567 /// Pristine registers hold a value that is useless to the current function, 568 /// but that must be preserved - they are callee saved registers that have not 569 /// been saved yet. 570 /// 571 /// Before the PrologueEpilogueInserter has placed the CSR spill code, this 572 /// method always returns an empty set. 573 BitVector getPristineRegs(const MachineBasicBlock *MBB) const; 574 575 /// print - Used by the MachineFunction printer to print information about 576 /// stack objects. Implemented in MachineFunction.cpp 577 /// 578 void print(const MachineFunction &MF, raw_ostream &OS) const; 579 580 /// dump - Print the function to stderr. 581 void dump(const MachineFunction &MF) const; 582 }; 583 584 } // End llvm namespace 585 586 #endif 587