1aa09b75d2257545c4583265c7ce10f2d0e3be72bChris Lattner//===-- CodeGen/MachineFrameInfo.h - Abstract Stack Frame Rep. --*- C++ -*-===//
2ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman//
36fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell//                     The LLVM Compiler Infrastructure
46fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell//
57ed47a13356daed2a34cd2209a31f92552e3bdd8Chris Lattner// This file is distributed under the University of Illinois Open Source
67ed47a13356daed2a34cd2209a31f92552e3bdd8Chris Lattner// License. See LICENSE.TXT for details.
7ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman//
86fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell//===----------------------------------------------------------------------===//
988d480b552bef3a89762a28e06abf823ac6707c0Chris Lattner//
1088d480b552bef3a89762a28e06abf823ac6707c0Chris Lattner// The file defines the MachineFrameInfo class.
1188d480b552bef3a89762a28e06abf823ac6707c0Chris Lattner//
1288d480b552bef3a89762a28e06abf823ac6707c0Chris Lattner//===----------------------------------------------------------------------===//
137fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner
1409a5b0b6a351aa5c12fdd1f076fcf0943f5382acChris Lattner#ifndef LLVM_CODEGEN_MACHINEFRAMEINFO_H
1509a5b0b6a351aa5c12fdd1f076fcf0943f5382acChris Lattner#define LLVM_CODEGEN_MACHINEFRAMEINFO_H
1609a5b0b6a351aa5c12fdd1f076fcf0943f5382acChris Lattner
173f2bf85d14759cc4b28a86805f566ac805a54d00David Greene#include "llvm/ADT/SmallVector.h"
181f6efa3996dd1929fbc129203ce5009b620e6969Michael J. Spencer#include "llvm/Support/DataTypes.h"
19922b3d2e67063532c3a2620aba84ef29d08c3f75Dan Gohman#include <cassert>
2046ccf6d382568183a2fbbefabd5904bc45b8da2fChris Lattner#include <vector>
21d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke
2246ccf6d382568183a2fbbefabd5904bc45b8da2fChris Lattnernamespace llvm {
23d74c556e9aaad81a188158b7ba12d7ccffb30936Chris Lattnerclass raw_ostream;
243574eca1b02600bac4e625297f4ecf745f4c4f32Micah Villmowclass DataLayout;
2509a5b0b6a351aa5c12fdd1f076fcf0943f5382acChris Lattnerclass TargetRegisterClass;
26185a7ab2ed2f6e34f5045a1c1e507a7444380260Alkis Evlogimenosclass Type;
279085d8a9a9000eeaa7cf337ccbdca41d528c99c2Chris Lattnerclass MachineFunction;
284a0f08c5fc14d840e4e411fade036f1cd815b795Jakob Stoklund Olesenclass MachineBasicBlock;
2916c29b5f285f375be53dabaa73e3e91107485fe4Anton Korobeynikovclass TargetFrameLowering;
30d10fa8b1caf010fe4943ae5526c2c3b921339f72Bill Wendlingclass TargetMachine;
31655d82820cf0c86e162ab9b702333c1607734676Chris Lattnerclass BitVector;
32c05d30601ced172b55be81bb529df6be91d6ae15Nadav Rotemclass Value;
33bf0683f0f75dfb92e73b09718ed278eeab8ba9d2Sebastian Popclass AllocaInst;
34d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke
35f3e4f0e615bb2c36c4a9d60bb908e08b76025c75Jim Laskey/// The CalleeSavedInfo class tracks the information need to locate where a
36b5b21e5672bde8dd3fd05c56f5aac3817575fe40Eric Christopher/// callee saved register is in the current frame.
37f3e4f0e615bb2c36c4a9d60bb908e08b76025c75Jim Laskeyclass CalleeSavedInfo {
38f3e4f0e615bb2c36c4a9d60bb908e08b76025c75Jim Laskey  unsigned Reg;
39f3e4f0e615bb2c36c4a9d60bb908e08b76025c75Jim Laskey  int FrameIdx;
4031529c7b6c2c4c7c5c440fc0c93a43ccc7b14989Jim Grosbach
41f3e4f0e615bb2c36c4a9d60bb908e08b76025c75Jim Laskeypublic:
425af58d885e5f8348505ce8d87b61fe2549d32501Dan Gohman  explicit CalleeSavedInfo(unsigned R, int FI = 0)
4342d075c4fb21995265961501cec9ff6e3fb497ceRafael Espindola  : Reg(R), FrameIdx(FI) {}
4431529c7b6c2c4c7c5c440fc0c93a43ccc7b14989Jim Grosbach
45f3e4f0e615bb2c36c4a9d60bb908e08b76025c75Jim Laskey  // Accessors.
46f3e4f0e615bb2c36c4a9d60bb908e08b76025c75Jim Laskey  unsigned getReg()                        const { return Reg; }
47f3e4f0e615bb2c36c4a9d60bb908e08b76025c75Jim Laskey  int getFrameIdx()                        const { return FrameIdx; }
48f3e4f0e615bb2c36c4a9d60bb908e08b76025c75Jim Laskey  void setFrameIdx(int FI)                       { FrameIdx = FI; }
49f3e4f0e615bb2c36c4a9d60bb908e08b76025c75Jim Laskey};
501fd8a4f65da140e5f340ccb79a33ed86fd82d169Vladimir Prus
511fd8a4f65da140e5f340ccb79a33ed86fd82d169Vladimir Prus/// The MachineFrameInfo class represents an abstract stack frame until
521fd8a4f65da140e5f340ccb79a33ed86fd82d169Vladimir Prus/// prolog/epilog code is inserted.  This class is key to allowing stack frame
531fd8a4f65da140e5f340ccb79a33ed86fd82d169Vladimir Prus/// representation optimizations, such as frame pointer elimination.  It also
541fd8a4f65da140e5f340ccb79a33ed86fd82d169Vladimir Prus/// allows more mundane (but still important) optimizations, such as reordering
551fd8a4f65da140e5f340ccb79a33ed86fd82d169Vladimir Prus/// of abstract objects on the stack frame.
561fd8a4f65da140e5f340ccb79a33ed86fd82d169Vladimir Prus///
571fd8a4f65da140e5f340ccb79a33ed86fd82d169Vladimir Prus/// To support this, the class assigns unique integer identifiers to stack
581fd8a4f65da140e5f340ccb79a33ed86fd82d169Vladimir Prus/// objects requested clients.  These identifiers are negative integers for
5946e7730c81a3aae2e94d1e0689762bb73649e223Dan Gohman/// fixed stack objects (such as arguments passed on the stack) or nonnegative
601fd8a4f65da140e5f340ccb79a33ed86fd82d169Vladimir Prus/// for objects that may be reordered.  Instructions which refer to stack
611fd8a4f65da140e5f340ccb79a33ed86fd82d169Vladimir Prus/// objects use a special MO_FrameIndex operand to represent these frame
621fd8a4f65da140e5f340ccb79a33ed86fd82d169Vladimir Prus/// indexes.
631fd8a4f65da140e5f340ccb79a33ed86fd82d169Vladimir Prus///
641fd8a4f65da140e5f340ccb79a33ed86fd82d169Vladimir Prus/// Because this class keeps track of all references to the stack frame, it
651fd8a4f65da140e5f340ccb79a33ed86fd82d169Vladimir Prus/// knows when a variable sized object is allocated on the stack.  This is the
661fd8a4f65da140e5f340ccb79a33ed86fd82d169Vladimir Prus/// sole condition which prevents frame pointer elimination, which is an
671fd8a4f65da140e5f340ccb79a33ed86fd82d169Vladimir Prus/// important optimization on register-poor architectures.  Because original
681fd8a4f65da140e5f340ccb79a33ed86fd82d169Vladimir Prus/// variable sized alloca's in the source program are the only source of
691fd8a4f65da140e5f340ccb79a33ed86fd82d169Vladimir Prus/// variable sized stack objects, it is safe to decide whether there will be
701fd8a4f65da140e5f340ccb79a33ed86fd82d169Vladimir Prus/// any variable sized objects before all stack objects are known (for
711fd8a4f65da140e5f340ccb79a33ed86fd82d169Vladimir Prus/// example, register allocator spill code never needs variable sized
721fd8a4f65da140e5f340ccb79a33ed86fd82d169Vladimir Prus/// objects).
731fd8a4f65da140e5f340ccb79a33ed86fd82d169Vladimir Prus///
741fd8a4f65da140e5f340ccb79a33ed86fd82d169Vladimir Prus/// When prolog/epilog code emission is performed, the final stack frame is
751fd8a4f65da140e5f340ccb79a33ed86fd82d169Vladimir Prus/// built and the machine instructions are modified to refer to the actual
761fd8a4f65da140e5f340ccb79a33ed86fd82d169Vladimir Prus/// stack offsets of the object, eliminating all MO_FrameIndex operands from
771fd8a4f65da140e5f340ccb79a33ed86fd82d169Vladimir Prus/// the program.
781fd8a4f65da140e5f340ccb79a33ed86fd82d169Vladimir Prus///
791fd8a4f65da140e5f340ccb79a33ed86fd82d169Vladimir Prus/// @brief Abstract Stack Frame Information
80aa09b75d2257545c4583265c7ce10f2d0e3be72bChris Lattnerclass MachineFrameInfo {
817fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner
827fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  // StackObject - Represent a single object allocated on the stack.
837fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  struct StackObject {
84a8e65426107be9c04e09ba29b3d7b54e168236d6Evan Cheng    // SPOffset - The offset of this object from the stack pointer on entry to
85a8e65426107be9c04e09ba29b3d7b54e168236d6Evan Cheng    // the function.  This field has no meaning for a variable sized element.
86a8e65426107be9c04e09ba29b3d7b54e168236d6Evan Cheng    int64_t SPOffset;
8731529c7b6c2c4c7c5c440fc0c93a43ccc7b14989Jim Grosbach
88d36531249a9a9500e516148e7e72d4c0a7a4d0eeEvan Cheng    // The size of this object on the stack. 0 means a variable sized object,
89d36531249a9a9500e516148e7e72d4c0a7a4d0eeEvan Cheng    // ~0ULL means a dead object.
90be7d83ec0ea9d4890f13174b9200db1b97d04598Chris Lattner    uint64_t Size;
917fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner
927fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner    // Alignment - The required alignment of this stack slot.
937fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner    unsigned Alignment;
947fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner
951778a1590125dbef01b8d85128a11b6fb212b26fEvan Cheng    // isImmutable - If true, the value of the stack object is set before
961778a1590125dbef01b8d85128a11b6fb212b26fEvan Cheng    // entering the function and is not modified inside the function. By
971778a1590125dbef01b8d85128a11b6fb212b26fEvan Cheng    // default, fixed objects are immutable unless marked otherwise.
980d0e1b58cb800fc838b5752e10f3a261ca8e5e09Evan Cheng    bool isImmutable;
9988d480b552bef3a89762a28e06abf823ac6707c0Chris Lattner
100dfc2c51d12fd53822279b6e564cdd5cef5c00b46Bill Wendling    // isSpillSlot - If true the stack object is used as spill slot. It
101491f54f1fd700204db0a19efde0cc2627641d711Evan Cheng    // cannot alias any other memory objects.
102491f54f1fd700204db0a19efde0cc2627641d711Evan Cheng    bool isSpillSlot;
103491f54f1fd700204db0a19efde0cc2627641d711Evan Cheng
104c05d30601ced172b55be81bb529df6be91d6ae15Nadav Rotem    /// Alloca - If this stack object is originated from an Alloca instruction
105c05d30601ced172b55be81bb529df6be91d6ae15Nadav Rotem    /// this value saves the original IR allocation. Can be NULL.
106bf0683f0f75dfb92e73b09718ed278eeab8ba9d2Sebastian Pop    const AllocaInst *Alloca;
107c05d30601ced172b55be81bb529df6be91d6ae15Nadav Rotem
1083d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach    // PreAllocated - If true, the object was mapped into the local frame
1093d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach    // block and doesn't need additional handling for allocation beyond that.
1103d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach    bool PreAllocated;
1113d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach
11237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    // If true, an LLVM IR value might point to this object.
11337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    // Normally, spill slots and fixed-offset objects don't alias IR-accessible
11437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    // objects, but there are exceptions (on PowerPC, for example, some byval
11537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    // arguments have ABI-prescribed offsets).
11637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    bool isAliased;
11737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
118dfc2c51d12fd53822279b6e564cdd5cef5c00b46Bill Wendling    StackObject(uint64_t Sz, unsigned Al, int64_t SP, bool IM,
11937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines                bool isSS, const AllocaInst *Val, bool A)
120491f54f1fd700204db0a19efde0cc2627641d711Evan Cheng      : SPOffset(SP), Size(Sz), Alignment(Al), isImmutable(IM),
12137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines        isSpillSlot(isSS), Alloca(Val), PreAllocated(false), isAliased(A) {}
1227fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  };
1237fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner
12437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// StackAlignment - The alignment of the stack.
12537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  unsigned StackAlignment;
12637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
12737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// StackRealignable - Can the stack be realigned.
12837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  bool StackRealignable;
129d10fa8b1caf010fe4943ae5526c2c3b921339f72Bill Wendling
1307fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// Objects - The list of stack objects allocated...
1317fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  ///
1327fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  std::vector<StackObject> Objects;
1337fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner
1347fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// NumFixedObjects - This contains the number of fixed objects contained on
1357fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// the stack.  Because fixed objects are stored at a negative index in the
1367fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// Objects list, this is also the index to the 0th object in the list.
1377fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  ///
1387fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  unsigned NumFixedObjects;
1397fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner
1407fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// HasVarSizedObjects - This boolean keeps track of whether any variable
1417fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// sized objects have been allocated yet.
1427fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  ///
1437fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  bool HasVarSizedObjects;
1447fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner
145184793fc8a9cf6ecc9147468bbcc068f472b8517Evan Cheng  /// FrameAddressTaken - This boolean keeps track of whether there is a call
1460f8b53f19d29013ab18f3d444cea1e6305405611Dan Gohman  /// to builtin \@llvm.frameaddress.
147184793fc8a9cf6ecc9147468bbcc068f472b8517Evan Cheng  bool FrameAddressTaken;
148184793fc8a9cf6ecc9147468bbcc068f472b8517Evan Cheng
1492457f2c66184e978d4ed8fa9e2128effff26cb0bEvan Cheng  /// ReturnAddressTaken - This boolean keeps track of whether there is a call
1502457f2c66184e978d4ed8fa9e2128effff26cb0bEvan Cheng  /// to builtin \@llvm.returnaddress.
1512457f2c66184e978d4ed8fa9e2128effff26cb0bEvan Cheng  bool ReturnAddressTaken;
1522457f2c66184e978d4ed8fa9e2128effff26cb0bEvan Cheng
15336b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  /// HasStackMap - This boolean keeps track of whether there is a call
15436b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  /// to builtin \@llvm.experimental.stackmap.
15536b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  bool HasStackMap;
15636b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines
15736b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  /// HasPatchPoint - This boolean keeps track of whether there is a call
15836b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  /// to builtin \@llvm.experimental.patchpoint.
15936b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  bool HasPatchPoint;
16036b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines
1617fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// StackSize - The prolog/epilog code inserter calculates the final stack
1627fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// offsets for all of the fixed size objects, updating the Objects list
1637fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// above.  It then updates StackSize to contain the number of bytes that need
1647fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// to be allocated on entry to the function.
1657fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  ///
166be7d83ec0ea9d4890f13174b9200db1b97d04598Chris Lattner  uint64_t StackSize;
16731529c7b6c2c4c7c5c440fc0c93a43ccc7b14989Jim Grosbach
1689dea41d9e1c9e288630db503668468560aa4286eJim Laskey  /// OffsetAdjustment - The amount that a frame offset needs to be adjusted to
1696263778d2cf4afb6e71ccab5bd5f1c3c2e42c65aBob Wilson  /// have the actual offset from the stack/frame pointer.  The exact usage of
1706263778d2cf4afb6e71ccab5bd5f1c3c2e42c65aBob Wilson  /// this is target-dependent, but it is typically used to adjust between
1716263778d2cf4afb6e71ccab5bd5f1c3c2e42c65aBob Wilson  /// SP-relative and FP-relative offsets.  E.G., if objects are accessed via
1726263778d2cf4afb6e71ccab5bd5f1c3c2e42c65aBob Wilson  /// SP then OffsetAdjustment is zero; if FP is used, OffsetAdjustment is set
1736263778d2cf4afb6e71ccab5bd5f1c3c2e42c65aBob Wilson  /// to the distance between the initial SP and the value in FP.  For many
1746263778d2cf4afb6e71ccab5bd5f1c3c2e42c65aBob Wilson  /// targets, this value is only used when generating debug info (via
1756263778d2cf4afb6e71ccab5bd5f1c3c2e42c65aBob Wilson  /// TargetRegisterInfo::getFrameIndexOffset); when generating code, the
1766263778d2cf4afb6e71ccab5bd5f1c3c2e42c65aBob Wilson  /// corresponding adjustments are performed directly.
1779dea41d9e1c9e288630db503668468560aa4286eJim Laskey  int OffsetAdjustment;
17831529c7b6c2c4c7c5c440fc0c93a43ccc7b14989Jim Grosbach
17931529c7b6c2c4c7c5c440fc0c93a43ccc7b14989Jim Grosbach  /// MaxAlignment - The prolog/epilog code inserter may process objects
180ae232e7a1055033436370c0b3aecf054fa44d5e7Nate Begeman  /// that require greater alignment than the default alignment the target
18131529c7b6c2c4c7c5c440fc0c93a43ccc7b14989Jim Grosbach  /// provides. To handle this, MaxAlignment is set to the maximum alignment
182cb982916f7795c0ad4f6e1a2d5c504c236a80f15Chris Lattner  /// needed by the objects on the current frame.  If this is greater than the
183cb982916f7795c0ad4f6e1a2d5c504c236a80f15Chris Lattner  /// native alignment maintained by the compiler, dynamic alignment code will
184cb982916f7795c0ad4f6e1a2d5c504c236a80f15Chris Lattner  /// be needed.
185ae232e7a1055033436370c0b3aecf054fa44d5e7Nate Begeman  ///
186ae232e7a1055033436370c0b3aecf054fa44d5e7Nate Begeman  unsigned MaxAlignment;
1877fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner
188b92187a4103dca24c3767c380f63593d1f6161a7Bill Wendling  /// AdjustsStack - Set to true if this function adjusts the stack -- e.g.,
189b92187a4103dca24c3767c380f63593d1f6161a7Bill Wendling  /// when calling another function. This is only valid during and after
190b92187a4103dca24c3767c380f63593d1f6161a7Bill Wendling  /// prolog/epilog code insertion.
191b92187a4103dca24c3767c380f63593d1f6161a7Bill Wendling  bool AdjustsStack;
192b92187a4103dca24c3767c380f63593d1f6161a7Bill Wendling
193b92187a4103dca24c3767c380f63593d1f6161a7Bill Wendling  /// HasCalls - Set to true if this function has any function calls.
1947fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  bool HasCalls;
1957fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner
196b2a4298ce41e7ef80cd75a3c1dfa6433f0759a1aBill Wendling  /// StackProtectorIdx - The frame index for the stack protector.
197b2a4298ce41e7ef80cd75a3c1dfa6433f0759a1aBill Wendling  int StackProtectorIdx;
198b2a4298ce41e7ef80cd75a3c1dfa6433f0759a1aBill Wendling
1996ef94175d1bbab95f195770bb3c559b3ab38c4e5Bill Wendling  /// FunctionContextIdx - The frame index for the function context. Used for
2006ef94175d1bbab95f195770bb3c559b3ab38c4e5Bill Wendling  /// SjLj exceptions.
2016ef94175d1bbab95f195770bb3c559b3ab38c4e5Bill Wendling  int FunctionContextIdx;
2026ef94175d1bbab95f195770bb3c559b3ab38c4e5Bill Wendling
2037fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// MaxCallFrameSize - This contains the size of the largest call frame if the
2047fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// target uses frame setup/destroy pseudo instructions (as defined in the
2057fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// TargetFrameInfo class).  This information is important for frame pointer
2067fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// elimination.  If is only valid during and after prolog/epilog code
2077fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// insertion.
2087fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  ///
2097fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  unsigned MaxCallFrameSize;
21031529c7b6c2c4c7c5c440fc0c93a43ccc7b14989Jim Grosbach
211f3e4f0e615bb2c36c4a9d60bb908e08b76025c75Jim Laskey  /// CSInfo - The prolog/epilog code inserter fills in this vector with each
21208ede262a744f99429658fadb43662441bdcb42dJim Laskey  /// callee saved register saved in the frame.  Beyond its use by the prolog/
213f3e4f0e615bb2c36c4a9d60bb908e08b76025c75Jim Laskey  /// epilog code inserter, this data used for debug info and exception
214f3e4f0e615bb2c36c4a9d60bb908e08b76025c75Jim Laskey  /// handling.
215f3e4f0e615bb2c36c4a9d60bb908e08b76025c75Jim Laskey  std::vector<CalleeSavedInfo> CSInfo;
2164a0f08c5fc14d840e4e411fade036f1cd815b795Jakob Stoklund Olesen
2174a0f08c5fc14d840e4e411fade036f1cd815b795Jakob Stoklund Olesen  /// CSIValid - Has CSInfo been set yet?
2184a0f08c5fc14d840e4e411fade036f1cd815b795Jakob Stoklund Olesen  bool CSIValid;
2194a0f08c5fc14d840e4e411fade036f1cd815b795Jakob Stoklund Olesen
2203d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach  /// LocalFrameObjects - References to frame indices which are mapped
2213d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach  /// into the local frame allocation block. <FrameIdx, LocalOffset>
2223d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach  SmallVector<std::pair<int, int64_t>, 32> LocalFrameObjects;
2233d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach
2243d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach  /// LocalFrameSize - Size of the pre-allocated local frame block.
2253d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach  int64_t LocalFrameSize;
2263d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach
2274861ed60ac68a543d1b88e631e9fe2c55583b24bJim Grosbach  /// Required alignment of the local object blob, which is the strictest
2284861ed60ac68a543d1b88e631e9fe2c55583b24bJim Grosbach  /// alignment of any object in it.
2294861ed60ac68a543d1b88e631e9fe2c55583b24bJim Grosbach  unsigned LocalFrameMaxAlign;
2304861ed60ac68a543d1b88e631e9fe2c55583b24bJim Grosbach
231a0fc005321ac163f10ebc5216a85068a496969dfJim Grosbach  /// Whether the local object blob needs to be allocated together. If not,
232a0fc005321ac163f10ebc5216a85068a496969dfJim Grosbach  /// PEI should ignore the isPreAllocated flags on the stack objects and
233a0fc005321ac163f10ebc5216a85068a496969dfJim Grosbach  /// just allocate them normally.
234a0fc005321ac163f10ebc5216a85068a496969dfJim Grosbach  bool UseLocalStackAllocationBlock;
235a0fc005321ac163f10ebc5216a85068a496969dfJim Grosbach
23669261a644298bff1497d46c8cd38d688670f307bManman Ren  /// Whether the "realign-stack" option is on.
23769261a644298bff1497d46c8cd38d688670f307bManman Ren  bool RealignOption;
238d10fa8b1caf010fe4943ae5526c2c3b921339f72Bill Wendling
23936b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  /// True if the function includes inline assembly that adjusts the stack
24036b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  /// pointer.
24136b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  bool HasInlineAsmWithSPAdjust;
24236b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines
24337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// True if the function contains a call to the llvm.vastart intrinsic.
24437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  bool HasVAStart;
24537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
24637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// True if this is a varargs function that contains a musttail call.
24737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  bool HasMustTailInVarArgFunc;
24837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
2497fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattnerpublic:
25037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  explicit MachineFrameInfo(unsigned StackAlign, bool isStackRealign,
25137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines                            bool RealignOpt)
25237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines      : StackAlignment(StackAlign), StackRealignable(isStackRealign),
25337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines        RealignOption(RealignOpt) {
254b35417c607afc5d12f2facedf19afd0d68669f64Jeff Cohen    StackSize = NumFixedObjects = OffsetAdjustment = MaxAlignment = 0;
2557fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner    HasVarSizedObjects = false;
256184793fc8a9cf6ecc9147468bbcc068f472b8517Evan Cheng    FrameAddressTaken = false;
2572457f2c66184e978d4ed8fa9e2128effff26cb0bEvan Cheng    ReturnAddressTaken = false;
25836b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines    HasStackMap = false;
25936b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines    HasPatchPoint = false;
260b92187a4103dca24c3767c380f63593d1f6161a7Bill Wendling    AdjustsStack = false;
2617fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner    HasCalls = false;
262b2a4298ce41e7ef80cd75a3c1dfa6433f0759a1aBill Wendling    StackProtectorIdx = -1;
2636ef94175d1bbab95f195770bb3c559b3ab38c4e5Bill Wendling    FunctionContextIdx = -1;
2647fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner    MaxCallFrameSize = 0;
2654a0f08c5fc14d840e4e411fade036f1cd815b795Jakob Stoklund Olesen    CSIValid = false;
2663d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach    LocalFrameSize = 0;
2674861ed60ac68a543d1b88e631e9fe2c55583b24bJim Grosbach    LocalFrameMaxAlign = 0;
2687e75cabba0a55972c8353b449f20159eb38abeb9Jim Grosbach    UseLocalStackAllocationBlock = false;
26936b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines    HasInlineAsmWithSPAdjust = false;
27037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    HasVAStart = false;
27137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    HasMustTailInVarArgFunc = false;
2727fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  }
2737fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner
2747fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// hasStackObjects - Return true if there are any stack objects in this
2757fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// function.
2767fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  ///
2777fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  bool hasStackObjects() const { return !Objects.empty(); }
2787fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner
2797fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// hasVarSizedObjects - This method may be called any time after instruction
2807fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// selection is complete to determine if the stack frame for this function
2817fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// contains any variable sized objects.
2827fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  ///
2837fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  bool hasVarSizedObjects() const { return HasVarSizedObjects; }
2847fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner
285b2a4298ce41e7ef80cd75a3c1dfa6433f0759a1aBill Wendling  /// getStackProtectorIndex/setStackProtectorIndex - Return the index for the
286b2a4298ce41e7ef80cd75a3c1dfa6433f0759a1aBill Wendling  /// stack protector object.
287b2a4298ce41e7ef80cd75a3c1dfa6433f0759a1aBill Wendling  ///
288b2a4298ce41e7ef80cd75a3c1dfa6433f0759a1aBill Wendling  int getStackProtectorIndex() const { return StackProtectorIdx; }
289b2a4298ce41e7ef80cd75a3c1dfa6433f0759a1aBill Wendling  void setStackProtectorIndex(int I) { StackProtectorIdx = I; }
290b2a4298ce41e7ef80cd75a3c1dfa6433f0759a1aBill Wendling
2916ef94175d1bbab95f195770bb3c559b3ab38c4e5Bill Wendling  /// getFunctionContextIndex/setFunctionContextIndex - Return the index for the
2926ef94175d1bbab95f195770bb3c559b3ab38c4e5Bill Wendling  /// function context object. This object is used for SjLj exceptions.
2936ef94175d1bbab95f195770bb3c559b3ab38c4e5Bill Wendling  int getFunctionContextIndex() const { return FunctionContextIdx; }
2946ef94175d1bbab95f195770bb3c559b3ab38c4e5Bill Wendling  void setFunctionContextIndex(int I) { FunctionContextIdx = I; }
2956ef94175d1bbab95f195770bb3c559b3ab38c4e5Bill Wendling
296184793fc8a9cf6ecc9147468bbcc068f472b8517Evan Cheng  /// isFrameAddressTaken - This method may be called any time after instruction
297184793fc8a9cf6ecc9147468bbcc068f472b8517Evan Cheng  /// selection is complete to determine if there is a call to
2980f8b53f19d29013ab18f3d444cea1e6305405611Dan Gohman  /// \@llvm.frameaddress in this function.
299184793fc8a9cf6ecc9147468bbcc068f472b8517Evan Cheng  bool isFrameAddressTaken() const { return FrameAddressTaken; }
300184793fc8a9cf6ecc9147468bbcc068f472b8517Evan Cheng  void setFrameAddressIsTaken(bool T) { FrameAddressTaken = T; }
301184793fc8a9cf6ecc9147468bbcc068f472b8517Evan Cheng
30231529c7b6c2c4c7c5c440fc0c93a43ccc7b14989Jim Grosbach  /// isReturnAddressTaken - This method may be called any time after
30331529c7b6c2c4c7c5c440fc0c93a43ccc7b14989Jim Grosbach  /// instruction selection is complete to determine if there is a call to
3042457f2c66184e978d4ed8fa9e2128effff26cb0bEvan Cheng  /// \@llvm.returnaddress in this function.
3052457f2c66184e978d4ed8fa9e2128effff26cb0bEvan Cheng  bool isReturnAddressTaken() const { return ReturnAddressTaken; }
3062457f2c66184e978d4ed8fa9e2128effff26cb0bEvan Cheng  void setReturnAddressIsTaken(bool s) { ReturnAddressTaken = s; }
3072457f2c66184e978d4ed8fa9e2128effff26cb0bEvan Cheng
30836b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  /// hasStackMap - This method may be called any time after instruction
30936b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  /// selection is complete to determine if there is a call to builtin
31036b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  /// \@llvm.experimental.stackmap.
31136b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  bool hasStackMap() const { return HasStackMap; }
31236b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  void setHasStackMap(bool s = true) { HasStackMap = s; }
31336b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines
31436b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  /// hasPatchPoint - This method may be called any time after instruction
31536b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  /// selection is complete to determine if there is a call to builtin
31636b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  /// \@llvm.experimental.patchpoint.
31736b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  bool hasPatchPoint() const { return HasPatchPoint; }
31836b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  void setHasPatchPoint(bool s = true) { HasPatchPoint = s; }
31936b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines
320b3696d865e70c0153f82092d51999e5e55505427Chris Lattner  /// getObjectIndexBegin - Return the minimum frame object index.
3217fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  ///
3227fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  int getObjectIndexBegin() const { return -NumFixedObjects; }
3237fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner
324b3696d865e70c0153f82092d51999e5e55505427Chris Lattner  /// getObjectIndexEnd - Return one past the maximum frame object index.
3257fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  ///
32634cd4a484e532cc463fd5a4bf59b88d13c5467c1Evan Cheng  int getObjectIndexEnd() const { return (int)Objects.size()-NumFixedObjects; }
3277fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner
32873bb0186a5b5fdda5d69950fd474e886103289f5Jim Grosbach  /// getNumFixedObjects - Return the number of fixed objects.
3293f32d65912b4da23793dab618d981be2ce11c331Evan Cheng  unsigned getNumFixedObjects() const { return NumFixedObjects; }
3303f32d65912b4da23793dab618d981be2ce11c331Evan Cheng
33173bb0186a5b5fdda5d69950fd474e886103289f5Jim Grosbach  /// getNumObjects - Return the number of objects.
3323f32d65912b4da23793dab618d981be2ce11c331Evan Cheng  ///
3333f32d65912b4da23793dab618d981be2ce11c331Evan Cheng  unsigned getNumObjects() const { return Objects.size(); }
3343f32d65912b4da23793dab618d981be2ce11c331Evan Cheng
3353d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach  /// mapLocalFrameObject - Map a frame index into the local object block
3363d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach  void mapLocalFrameObject(int ObjectIndex, int64_t Offset) {
3373d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach    LocalFrameObjects.push_back(std::pair<int, int64_t>(ObjectIndex, Offset));
3383d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach    Objects[ObjectIndex + NumFixedObjects].PreAllocated = true;
3393d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach  }
3403d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach
3413d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach  /// getLocalFrameObjectMap - Get the local offset mapping for a for an object
3423d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach  std::pair<int, int64_t> getLocalFrameObjectMap(int i) {
3433d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach    assert (i >= 0 && (unsigned)i < LocalFrameObjects.size() &&
3443d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach            "Invalid local object reference!");
3453d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach    return LocalFrameObjects[i];
3463d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach  }
3473d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach
3483d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach  /// getLocalFrameObjectCount - Return the number of objects allocated into
3493d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach  /// the local object block.
3503d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach  int64_t getLocalFrameObjectCount() { return LocalFrameObjects.size(); }
3513d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach
35263249347c2700fe2481e0bc36caa63f6e2cf6eabJim Grosbach  /// setLocalFrameSize - Set the size of the local object blob.
35363249347c2700fe2481e0bc36caa63f6e2cf6eabJim Grosbach  void setLocalFrameSize(int64_t sz) { LocalFrameSize = sz; }
35463249347c2700fe2481e0bc36caa63f6e2cf6eabJim Grosbach
3553d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach  /// getLocalFrameSize - Get the size of the local object blob.
3563d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach  int64_t getLocalFrameSize() const { return LocalFrameSize; }
3573d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach
3584861ed60ac68a543d1b88e631e9fe2c55583b24bJim Grosbach  /// setLocalFrameMaxAlign - Required alignment of the local object blob,
3594861ed60ac68a543d1b88e631e9fe2c55583b24bJim Grosbach  /// which is the strictest alignment of any object in it.
3604861ed60ac68a543d1b88e631e9fe2c55583b24bJim Grosbach  void setLocalFrameMaxAlign(unsigned Align) { LocalFrameMaxAlign = Align; }
3614861ed60ac68a543d1b88e631e9fe2c55583b24bJim Grosbach
3624861ed60ac68a543d1b88e631e9fe2c55583b24bJim Grosbach  /// getLocalFrameMaxAlign - Return the required alignment of the local
3634861ed60ac68a543d1b88e631e9fe2c55583b24bJim Grosbach  /// object blob.
364260fbf2b57859d513e78acd68a8e122581198e68Jim Grosbach  unsigned getLocalFrameMaxAlign() const { return LocalFrameMaxAlign; }
3654861ed60ac68a543d1b88e631e9fe2c55583b24bJim Grosbach
366a0fc005321ac163f10ebc5216a85068a496969dfJim Grosbach  /// getUseLocalStackAllocationBlock - Get whether the local allocation blob
367a0fc005321ac163f10ebc5216a85068a496969dfJim Grosbach  /// should be allocated together or let PEI allocate the locals in it
368a0fc005321ac163f10ebc5216a85068a496969dfJim Grosbach  /// directly.
369a0fc005321ac163f10ebc5216a85068a496969dfJim Grosbach  bool getUseLocalStackAllocationBlock() {return UseLocalStackAllocationBlock;}
370a0fc005321ac163f10ebc5216a85068a496969dfJim Grosbach
371a0fc005321ac163f10ebc5216a85068a496969dfJim Grosbach  /// setUseLocalStackAllocationBlock - Set whether the local allocation blob
372a0fc005321ac163f10ebc5216a85068a496969dfJim Grosbach  /// should be allocated together or let PEI allocate the locals in it
373a0fc005321ac163f10ebc5216a85068a496969dfJim Grosbach  /// directly.
374a0fc005321ac163f10ebc5216a85068a496969dfJim Grosbach  void setUseLocalStackAllocationBlock(bool v) {
375a0fc005321ac163f10ebc5216a85068a496969dfJim Grosbach    UseLocalStackAllocationBlock = v;
376a0fc005321ac163f10ebc5216a85068a496969dfJim Grosbach  }
3774861ed60ac68a543d1b88e631e9fe2c55583b24bJim Grosbach
3783d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach  /// isObjectPreAllocated - Return true if the object was pre-allocated into
3793d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach  /// the local block.
3803d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach  bool isObjectPreAllocated(int ObjectIdx) const {
3813d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach    assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
3823d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach           "Invalid Object Idx!");
3833d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach    return Objects[ObjectIdx+NumFixedObjects].PreAllocated;
3843d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach  }
3853d72367d30c9ce6f387764a028763f7a366cc443Jim Grosbach
386b3696d865e70c0153f82092d51999e5e55505427Chris Lattner  /// getObjectSize - Return the size of the specified object.
3877fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  ///
388a401b1e1c5eb9563617db8a2477b4c5f8b239521Chris Lattner  int64_t getObjectSize(int ObjectIdx) const {
38988d480b552bef3a89762a28e06abf823ac6707c0Chris Lattner    assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
39088d480b552bef3a89762a28e06abf823ac6707c0Chris Lattner           "Invalid Object Idx!");
3917fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner    return Objects[ObjectIdx+NumFixedObjects].Size;
3927fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  }
3937fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner
394b2ccf8f6076de77192d64790315935db194a7ae6Chris Lattner  /// setObjectSize - Change the size of the specified stack object.
3953f32d65912b4da23793dab618d981be2ce11c331Evan Cheng  void setObjectSize(int ObjectIdx, int64_t Size) {
3963f32d65912b4da23793dab618d981be2ce11c331Evan Cheng    assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
3973f32d65912b4da23793dab618d981be2ce11c331Evan Cheng           "Invalid Object Idx!");
3983f32d65912b4da23793dab618d981be2ce11c331Evan Cheng    Objects[ObjectIdx+NumFixedObjects].Size = Size;
3993f32d65912b4da23793dab618d981be2ce11c331Evan Cheng  }
4003f32d65912b4da23793dab618d981be2ce11c331Evan Cheng
401b2ccf8f6076de77192d64790315935db194a7ae6Chris Lattner  /// getObjectAlignment - Return the alignment of the specified stack object.
402fb8075d03f5c87bd57dcc9c5f2304f6b13c55aadEvan Cheng  unsigned getObjectAlignment(int ObjectIdx) const {
40388d480b552bef3a89762a28e06abf823ac6707c0Chris Lattner    assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
40488d480b552bef3a89762a28e06abf823ac6707c0Chris Lattner           "Invalid Object Idx!");
4057fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner    return Objects[ObjectIdx+NumFixedObjects].Alignment;
4067fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  }
4077fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner
408b2ccf8f6076de77192d64790315935db194a7ae6Chris Lattner  /// setObjectAlignment - Change the alignment of the specified stack object.
409f0df03134e698ea84e9cc1c28a853f83c02560d5Evan Cheng  void setObjectAlignment(int ObjectIdx, unsigned Align) {
410f0df03134e698ea84e9cc1c28a853f83c02560d5Evan Cheng    assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
411f0df03134e698ea84e9cc1c28a853f83c02560d5Evan Cheng           "Invalid Object Idx!");
412f0df03134e698ea84e9cc1c28a853f83c02560d5Evan Cheng    Objects[ObjectIdx+NumFixedObjects].Alignment = Align;
4132531a6415ff9c082bb1c11c27f1b03aa3e1b97dfChad Rosier    ensureMaxAlignment(Align);
414f0df03134e698ea84e9cc1c28a853f83c02560d5Evan Cheng  }
415f0df03134e698ea84e9cc1c28a853f83c02560d5Evan Cheng
416c05d30601ced172b55be81bb529df6be91d6ae15Nadav Rotem  /// getObjectAllocation - Return the underlying Alloca of the specified
417c05d30601ced172b55be81bb529df6be91d6ae15Nadav Rotem  /// stack object if it exists. Returns 0 if none exists.
418bf0683f0f75dfb92e73b09718ed278eeab8ba9d2Sebastian Pop  const AllocaInst* getObjectAllocation(int ObjectIdx) const {
419c05d30601ced172b55be81bb529df6be91d6ae15Nadav Rotem    assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
420c05d30601ced172b55be81bb529df6be91d6ae15Nadav Rotem           "Invalid Object Idx!");
421c05d30601ced172b55be81bb529df6be91d6ae15Nadav Rotem    return Objects[ObjectIdx+NumFixedObjects].Alloca;
422c05d30601ced172b55be81bb529df6be91d6ae15Nadav Rotem  }
423c05d30601ced172b55be81bb529df6be91d6ae15Nadav Rotem
4247fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// getObjectOffset - Return the assigned stack offset of the specified object
4257fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// from the incoming stack pointer.
4267fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  ///
427a401b1e1c5eb9563617db8a2477b4c5f8b239521Chris Lattner  int64_t getObjectOffset(int ObjectIdx) const {
42888d480b552bef3a89762a28e06abf823ac6707c0Chris Lattner    assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
42988d480b552bef3a89762a28e06abf823ac6707c0Chris Lattner           "Invalid Object Idx!");
43021b3f31f8f7d77b9c3a35012139df92ba40e7c92Evan Cheng    assert(!isDeadObjectIndex(ObjectIdx) &&
43121b3f31f8f7d77b9c3a35012139df92ba40e7c92Evan Cheng           "Getting frame offset for a dead object?");
4327fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner    return Objects[ObjectIdx+NumFixedObjects].SPOffset;
4337fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  }
4347fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner
4357fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// setObjectOffset - Set the stack frame offset of the specified object.  The
4367fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// offset is relative to the stack pointer on entry to the function.
4377fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  ///
438a401b1e1c5eb9563617db8a2477b4c5f8b239521Chris Lattner  void setObjectOffset(int ObjectIdx, int64_t SPOffset) {
43988d480b552bef3a89762a28e06abf823ac6707c0Chris Lattner    assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
44088d480b552bef3a89762a28e06abf823ac6707c0Chris Lattner           "Invalid Object Idx!");
44121b3f31f8f7d77b9c3a35012139df92ba40e7c92Evan Cheng    assert(!isDeadObjectIndex(ObjectIdx) &&
44221b3f31f8f7d77b9c3a35012139df92ba40e7c92Evan Cheng           "Setting frame offset for a dead object?");
4437fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner    Objects[ObjectIdx+NumFixedObjects].SPOffset = SPOffset;
4447fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  }
4457fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner
4467fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// getStackSize - Return the number of bytes that must be allocated to hold
4477fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// all of the fixed size frame objects.  This is only valid after
4487fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// Prolog/Epilog code insertion has finalized the stack frame layout.
4497fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  ///
450e47b1446d8f072107c45168aa77fd9c6e0327c32Chris Lattner  uint64_t getStackSize() const { return StackSize; }
4517fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner
4527fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// setStackSize - Set the size of the stack...
4537fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  ///
454e47b1446d8f072107c45168aa77fd9c6e0327c32Chris Lattner  void setStackSize(uint64_t Size) { StackSize = Size; }
45531529c7b6c2c4c7c5c440fc0c93a43ccc7b14989Jim Grosbach
4560cc52c67dbc2e073e3f7f34e05e3e7cd17ba9745Hal Finkel  /// Estimate and return the size of the stack frame.
4570cc52c67dbc2e073e3f7f34e05e3e7cd17ba9745Hal Finkel  unsigned estimateStackSize(const MachineFunction &MF) const;
4580cc52c67dbc2e073e3f7f34e05e3e7cd17ba9745Hal Finkel
4599dea41d9e1c9e288630db503668468560aa4286eJim Laskey  /// getOffsetAdjustment - Return the correction for frame offsets.
4609dea41d9e1c9e288630db503668468560aa4286eJim Laskey  ///
4619dea41d9e1c9e288630db503668468560aa4286eJim Laskey  int getOffsetAdjustment() const { return OffsetAdjustment; }
46231529c7b6c2c4c7c5c440fc0c93a43ccc7b14989Jim Grosbach
4639dea41d9e1c9e288630db503668468560aa4286eJim Laskey  /// setOffsetAdjustment - Set the correction for frame offsets.
4649dea41d9e1c9e288630db503668468560aa4286eJim Laskey  ///
4659dea41d9e1c9e288630db503668468560aa4286eJim Laskey  void setOffsetAdjustment(int Adj) { OffsetAdjustment = Adj; }
4667fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner
46731529c7b6c2c4c7c5c440fc0c93a43ccc7b14989Jim Grosbach  /// getMaxAlignment - Return the alignment in bytes that this function must be
46831529c7b6c2c4c7c5c440fc0c93a43ccc7b14989Jim Grosbach  /// aligned to, which is greater than the default stack alignment provided by
469ae232e7a1055033436370c0b3aecf054fa44d5e7Nate Begeman  /// the target.
470ae232e7a1055033436370c0b3aecf054fa44d5e7Nate Begeman  ///
471ae232e7a1055033436370c0b3aecf054fa44d5e7Nate Begeman  unsigned getMaxAlignment() const { return MaxAlignment; }
47231529c7b6c2c4c7c5c440fc0c93a43ccc7b14989Jim Grosbach
4732531a6415ff9c082bb1c11c27f1b03aa3e1b97dfChad Rosier  /// ensureMaxAlignment - Make sure the function is at least Align bytes
4742531a6415ff9c082bb1c11c27f1b03aa3e1b97dfChad Rosier  /// aligned.
475dc8126bbb89cda8c87bf324e3495ceb3164ae7cbManman Ren  void ensureMaxAlignment(unsigned Align);
476e27d205d5d4d53cceabcd6325533fbdf9c0cee42Jim Grosbach
477b92187a4103dca24c3767c380f63593d1f6161a7Bill Wendling  /// AdjustsStack - Return true if this function adjusts the stack -- e.g.,
478b92187a4103dca24c3767c380f63593d1f6161a7Bill Wendling  /// when calling another function. This is only valid during and after
479b92187a4103dca24c3767c380f63593d1f6161a7Bill Wendling  /// prolog/epilog code insertion.
480b92187a4103dca24c3767c380f63593d1f6161a7Bill Wendling  bool adjustsStack() const { return AdjustsStack; }
481b92187a4103dca24c3767c380f63593d1f6161a7Bill Wendling  void setAdjustsStack(bool V) { AdjustsStack = V; }
482b92187a4103dca24c3767c380f63593d1f6161a7Bill Wendling
483b92187a4103dca24c3767c380f63593d1f6161a7Bill Wendling  /// hasCalls - Return true if the current function has any function calls.
4847fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  bool hasCalls() const { return HasCalls; }
4857fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  void setHasCalls(bool V) { HasCalls = V; }
486ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman
48736b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  /// Returns true if the function contains any stack-adjusting inline assembly.
48836b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  bool hasInlineAsmWithSPAdjust() const { return HasInlineAsmWithSPAdjust; }
48936b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  void setHasInlineAsmWithSPAdjust(bool B) { HasInlineAsmWithSPAdjust = B; }
49036b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines
49137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// Returns true if the function calls the llvm.va_start intrinsic.
49237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  bool hasVAStart() const { return HasVAStart; }
49337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  void setHasVAStart(bool B) { HasVAStart = B; }
49437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
49537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// Returns true if the function is variadic and contains a musttail call.
49637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  bool hasMustTailInVarArgFunc() const { return HasMustTailInVarArgFunc; }
49737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  void setHasMustTailInVarArgFunc(bool B) { HasMustTailInVarArgFunc = B; }
49837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
4997fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// getMaxCallFrameSize - Return the maximum size of a call frame that must be
5007fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// allocated for an outgoing function call.  This is only available if
5017fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// CallFrameSetup/Destroy pseudo instructions are used by the target, and
5027fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// then only during or after prolog/epilog code insertion.
5037fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  ///
5047fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  unsigned getMaxCallFrameSize() const { return MaxCallFrameSize; }
5057fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  void setMaxCallFrameSize(unsigned S) { MaxCallFrameSize = S; }
5067fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner
5077fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// CreateFixedObject - Create a new object at a fixed location on the stack.
5087fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// All fixed objects should be created before other objects are created for
50937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// efficiency. By default, fixed objects are not pointed to by LLVM IR
51037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// values. This returns an index with a negative value.
5117fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  ///
51237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool Immutable,
51337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines                        bool isAliased = false);
51431529c7b6c2c4c7c5c440fc0c93a43ccc7b14989Jim Grosbach
515c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines  /// CreateFixedSpillStackObject - Create a spill slot at a fixed location
516c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines  /// on the stack.  Returns an index with a negative value.
517c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines  int CreateFixedSpillStackObject(uint64_t Size, int64_t SPOffset);
51831529c7b6c2c4c7c5c440fc0c93a43ccc7b14989Jim Grosbach
519a96c5b30408a42cd6b8f335bd0816f2b2e58bdf5Evan Cheng  /// isFixedObjectIndex - Returns true if the specified index corresponds to a
520a96c5b30408a42cd6b8f335bd0816f2b2e58bdf5Evan Cheng  /// fixed stack object.
521a96c5b30408a42cd6b8f335bd0816f2b2e58bdf5Evan Cheng  bool isFixedObjectIndex(int ObjectIdx) const {
522a96c5b30408a42cd6b8f335bd0816f2b2e58bdf5Evan Cheng    return ObjectIdx < 0 && (ObjectIdx >= -(int)NumFixedObjects);
523a96c5b30408a42cd6b8f335bd0816f2b2e58bdf5Evan Cheng  }
524a96c5b30408a42cd6b8f335bd0816f2b2e58bdf5Evan Cheng
52537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// isAliasedObjectIndex - Returns true if the specified index corresponds
52637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  /// to an object that might be pointed to by an LLVM IR value.
52737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  bool isAliasedObjectIndex(int ObjectIdx) const {
52837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
52937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines           "Invalid Object Idx!");
53037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    return Objects[ObjectIdx+NumFixedObjects].isAliased;
53137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  }
53237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
5330d0e1b58cb800fc838b5752e10f3a261ca8e5e09Evan Cheng  /// isImmutableObjectIndex - Returns true if the specified index corresponds
5340d0e1b58cb800fc838b5752e10f3a261ca8e5e09Evan Cheng  /// to an immutable object.
5350d0e1b58cb800fc838b5752e10f3a261ca8e5e09Evan Cheng  bool isImmutableObjectIndex(int ObjectIdx) const {
53688d480b552bef3a89762a28e06abf823ac6707c0Chris Lattner    assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
53788d480b552bef3a89762a28e06abf823ac6707c0Chris Lattner           "Invalid Object Idx!");
5380d0e1b58cb800fc838b5752e10f3a261ca8e5e09Evan Cheng    return Objects[ObjectIdx+NumFixedObjects].isImmutable;
5390d0e1b58cb800fc838b5752e10f3a261ca8e5e09Evan Cheng  }
5400d0e1b58cb800fc838b5752e10f3a261ca8e5e09Evan Cheng
541491f54f1fd700204db0a19efde0cc2627641d711Evan Cheng  /// isSpillSlotObjectIndex - Returns true if the specified index corresponds
542491f54f1fd700204db0a19efde0cc2627641d711Evan Cheng  /// to a spill slot..
543491f54f1fd700204db0a19efde0cc2627641d711Evan Cheng  bool isSpillSlotObjectIndex(int ObjectIdx) const {
544491f54f1fd700204db0a19efde0cc2627641d711Evan Cheng    assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
545491f54f1fd700204db0a19efde0cc2627641d711Evan Cheng           "Invalid Object Idx!");
54646c313fb5a027c59163dd2295bdc473d58096510Nick Lewycky    return Objects[ObjectIdx+NumFixedObjects].isSpillSlot;
547491f54f1fd700204db0a19efde0cc2627641d711Evan Cheng  }
548491f54f1fd700204db0a19efde0cc2627641d711Evan Cheng
549d36531249a9a9500e516148e7e72d4c0a7a4d0eeEvan Cheng  /// isDeadObjectIndex - Returns true if the specified index corresponds to
550d36531249a9a9500e516148e7e72d4c0a7a4d0eeEvan Cheng  /// a dead object.
551d36531249a9a9500e516148e7e72d4c0a7a4d0eeEvan Cheng  bool isDeadObjectIndex(int ObjectIdx) const {
552d36531249a9a9500e516148e7e72d4c0a7a4d0eeEvan Cheng    assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
553d36531249a9a9500e516148e7e72d4c0a7a4d0eeEvan Cheng           "Invalid Object Idx!");
554d36531249a9a9500e516148e7e72d4c0a7a4d0eeEvan Cheng    return Objects[ObjectIdx+NumFixedObjects].Size == ~0ULL;
555d36531249a9a9500e516148e7e72d4c0a7a4d0eeEvan Cheng  }
556d36531249a9a9500e516148e7e72d4c0a7a4d0eeEvan Cheng
557dfc2c51d12fd53822279b6e564cdd5cef5c00b46Bill Wendling  /// CreateStackObject - Create a new statically sized stack object, returning
5588f637adbd383afc2defb5d3f75433b6f2c25d527Bob Wilson  /// a nonnegative identifier to represent it.
5597fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  ///
560dfc2c51d12fd53822279b6e564cdd5cef5c00b46Bill Wendling  int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSS,
561dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines                        const AllocaInst *Alloca = nullptr);
5623f2bf85d14759cc4b28a86805f566ac805a54d00David Greene
563dfc2c51d12fd53822279b6e564cdd5cef5c00b46Bill Wendling  /// CreateSpillStackObject - Create a new statically sized stack object that
564dfc2c51d12fd53822279b6e564cdd5cef5c00b46Bill Wendling  /// represents a spill slot, returning a nonnegative identifier to represent
565dfc2c51d12fd53822279b6e564cdd5cef5c00b46Bill Wendling  /// it.
5663f2bf85d14759cc4b28a86805f566ac805a54d00David Greene  ///
567dc8126bbb89cda8c87bf324e3495ceb3164ae7cbManman Ren  int CreateSpillStackObject(uint64_t Size, unsigned Alignment);
5687fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner
569d36531249a9a9500e516148e7e72d4c0a7a4d0eeEvan Cheng  /// RemoveStackObject - Remove or mark dead a statically sized stack object.
570d36531249a9a9500e516148e7e72d4c0a7a4d0eeEvan Cheng  ///
571d36531249a9a9500e516148e7e72d4c0a7a4d0eeEvan Cheng  void RemoveStackObject(int ObjectIdx) {
5723f32d65912b4da23793dab618d981be2ce11c331Evan Cheng    // Mark it dead.
5733f32d65912b4da23793dab618d981be2ce11c331Evan Cheng    Objects[ObjectIdx+NumFixedObjects].Size = ~0ULL;
574d36531249a9a9500e516148e7e72d4c0a7a4d0eeEvan Cheng  }
575d36531249a9a9500e516148e7e72d4c0a7a4d0eeEvan Cheng
576aa09b75d2257545c4583265c7ce10f2d0e3be72bChris Lattner  /// CreateVariableSizedObject - Notify the MachineFrameInfo object that a
5777fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// variable sized object has been created.  This must be created whenever a
5787fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// variable sized object is created, whether or not the index returned is
5797fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// actually used.
5807fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  ///
58136b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  int CreateVariableSizedObject(unsigned Alignment, const AllocaInst *Alloca);
5823f2bf85d14759cc4b28a86805f566ac805a54d00David Greene
583f3e4f0e615bb2c36c4a9d60bb908e08b76025c75Jim Laskey  /// getCalleeSavedInfo - Returns a reference to call saved info vector for the
584f3e4f0e615bb2c36c4a9d60bb908e08b76025c75Jim Laskey  /// current function.
58508ede262a744f99429658fadb43662441bdcb42dJim Laskey  const std::vector<CalleeSavedInfo> &getCalleeSavedInfo() const {
58608ede262a744f99429658fadb43662441bdcb42dJim Laskey    return CSInfo;
58708ede262a744f99429658fadb43662441bdcb42dJim Laskey  }
58808ede262a744f99429658fadb43662441bdcb42dJim Laskey
58908ede262a744f99429658fadb43662441bdcb42dJim Laskey  /// setCalleeSavedInfo - Used by prolog/epilog inserter to set the function's
59008ede262a744f99429658fadb43662441bdcb42dJim Laskey  /// callee saved information.
5917fdeab3e7c45c8b1cc17e27f13d5cccd9a05d564Eric Christopher  void setCalleeSavedInfo(const std::vector<CalleeSavedInfo> &CSI) {
59208ede262a744f99429658fadb43662441bdcb42dJim Laskey    CSInfo = CSI;
59308ede262a744f99429658fadb43662441bdcb42dJim Laskey  }
5947fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner
5954a0f08c5fc14d840e4e411fade036f1cd815b795Jakob Stoklund Olesen  /// isCalleeSavedInfoValid - Has the callee saved info been calculated yet?
5964a0f08c5fc14d840e4e411fade036f1cd815b795Jakob Stoklund Olesen  bool isCalleeSavedInfoValid() const { return CSIValid; }
5974a0f08c5fc14d840e4e411fade036f1cd815b795Jakob Stoklund Olesen
5984a0f08c5fc14d840e4e411fade036f1cd815b795Jakob Stoklund Olesen  void setCalleeSavedInfoValid(bool v) { CSIValid = v; }
5994a0f08c5fc14d840e4e411fade036f1cd815b795Jakob Stoklund Olesen
6004a0f08c5fc14d840e4e411fade036f1cd815b795Jakob Stoklund Olesen  /// getPristineRegs - Return a set of physical registers that are pristine on
6014a0f08c5fc14d840e4e411fade036f1cd815b795Jakob Stoklund Olesen  /// entry to the MBB.
6024a0f08c5fc14d840e4e411fade036f1cd815b795Jakob Stoklund Olesen  ///
6034a0f08c5fc14d840e4e411fade036f1cd815b795Jakob Stoklund Olesen  /// Pristine registers hold a value that is useless to the current function,
6044a0f08c5fc14d840e4e411fade036f1cd815b795Jakob Stoklund Olesen  /// but that must be preserved - they are callee saved registers that have not
6054a0f08c5fc14d840e4e411fade036f1cd815b795Jakob Stoklund Olesen  /// been saved yet.
6064a0f08c5fc14d840e4e411fade036f1cd815b795Jakob Stoklund Olesen  ///
6074a0f08c5fc14d840e4e411fade036f1cd815b795Jakob Stoklund Olesen  /// Before the PrologueEpilogueInserter has placed the CSR spill code, this
6084a0f08c5fc14d840e4e411fade036f1cd815b795Jakob Stoklund Olesen  /// method always returns an empty set.
6094a0f08c5fc14d840e4e411fade036f1cd815b795Jakob Stoklund Olesen  BitVector getPristineRegs(const MachineBasicBlock *MBB) const;
6104a0f08c5fc14d840e4e411fade036f1cd815b795Jakob Stoklund Olesen
6117fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  /// print - Used by the MachineFunction printer to print information about
6127fdeab3e7c45c8b1cc17e27f13d5cccd9a05d564Eric Christopher  /// stack objects. Implemented in MachineFunction.cpp
6137fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner  ///
614d74c556e9aaad81a188158b7ba12d7ccffb30936Chris Lattner  void print(const MachineFunction &MF, raw_ostream &OS) const;
6157fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner
616275872e79950dafc6699f6502cee52f74b84a22aDaniel Dunbar  /// dump - Print the function to stderr.
6179085d8a9a9000eeaa7cf337ccbdca41d528c99c2Chris Lattner  void dump(const MachineFunction &MF) const;
6187fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner};
6197fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner
620d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke} // End llvm namespace
621d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke
6227fd4040274b6682d6d871c831ce3228e5c99f423Chris Lattner#endif
623