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