LLVM API Documentation

TargetFrameInfo.h

Go to the documentation of this file.
00001 //===-- llvm/Target/TargetFrameInfo.h ---------------------------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file was developed by the LLVM research group and is distributed under
00006 // the University of Illinois Open Source License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // Interface to describe the layout of a stack frame on the target machine.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef LLVM_TARGET_TARGETFRAMEINFO_H
00015 #define LLVM_TARGET_TARGETFRAMEINFO_H
00016 
00017 #include <utility>
00018 
00019 namespace llvm {
00020 
00021 class MachineFunction;
00022 
00023 /// Information about stack frame layout on the target.  It holds the direction
00024 /// of stack growth, the known stack alignment on entry to each function, and
00025 /// the offset to the locals area.
00026 ///
00027 /// The offset to the local area is the offset from the stack pointer on
00028 /// function entry to the first location where function data (local variables,
00029 /// spill locations) can be stored.
00030 class TargetFrameInfo {
00031 public:
00032   enum StackDirection {
00033     StackGrowsUp,        // Adding to the stack increases the stack address
00034     StackGrowsDown       // Adding to the stack decreases the stack address
00035   };
00036 private:
00037   StackDirection StackDir;
00038   unsigned StackAlignment;
00039   int LocalAreaOffset;
00040 public:
00041   TargetFrameInfo(StackDirection D, unsigned StackAl, int LAO)
00042     : StackDir(D), StackAlignment(StackAl), LocalAreaOffset(LAO) {}
00043 
00044   virtual ~TargetFrameInfo();
00045 
00046   // These methods return information that describes the abstract stack layout
00047   // of the target machine.
00048 
00049   /// getStackGrowthDirection - Return the direction the stack grows
00050   ///
00051   StackDirection getStackGrowthDirection() const { return StackDir; }
00052 
00053   /// getStackAlignment - This method returns the number of bytes that the stack
00054   /// pointer must be aligned to.  Typically, this is the largest alignment for
00055   /// any data object in the target.
00056   ///
00057   unsigned getStackAlignment() const { return StackAlignment; }
00058 
00059   /// getOffsetOfLocalArea - This method returns the offset of the local area
00060   /// from the stack pointer on entrance to a function.
00061   ///
00062   int getOffsetOfLocalArea() const { return LocalAreaOffset; }
00063 
00064   /// getCalleeSaveSpillSlots - This method returns a pointer to an array of
00065   /// pairs, that contains an entry for each callee save register that must be
00066   /// spilled to a particular stack location if it is spilled.
00067   ///
00068   /// Each entry in this array contains a <register,offset> pair, indicating the
00069   /// fixed offset from the incoming stack pointer that each register should be
00070   /// spilled at.  If a register is not listed here, the code generator is
00071   /// allowed to spill it anywhere it chooses.
00072   ///
00073   virtual const std::pair<unsigned, int> *
00074   getCalleeSaveSpillSlots(unsigned &NumEntries) const {
00075     NumEntries = 0;
00076     return 0;
00077   }
00078 
00079   //===--------------------------------------------------------------------===//
00080   // These methods provide details of the stack frame used by Sparc, thus they
00081   // are Sparc specific.
00082   //===--------------------------------------------------------------------===//
00083 
00084   // This method adjusts a stack offset to meet alignment rules of target.
00085   virtual int adjustAlignment(int unalignedOffset, bool growUp,
00086                               unsigned align) const;
00087 
00088   // These methods compute offsets using the frame contents for a particular
00089   // function.  The frame contents are obtained from the MachineFunction object
00090   // for the given function.  The rest must be implemented by the
00091   // machine-specific subclass.
00092   //
00093   virtual int getIncomingArgOffset(MachineFunction& mcInfo,
00094                                    unsigned argNum) const;
00095   virtual int getOutgoingArgOffset(MachineFunction& mcInfo,
00096                                    unsigned argNum) const;
00097   virtual int getFirstAutomaticVarOffset(MachineFunction& mcInfo,
00098                                          bool& growUp) const;
00099   virtual int getRegSpillAreaOffset(MachineFunction& mcInfo,
00100                                     bool& growUp) const;
00101   virtual int getTmpAreaOffset(MachineFunction& mcInfo, bool& growUp) const;
00102   virtual int getDynamicAreaOffset(MachineFunction& mcInfo, bool& growUp) const;
00103 };
00104 
00105 } // End llvm namespace
00106 
00107 #endif