LLVM API Documentation

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

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   // These methods return information that describes the abstract stack layout
00045   // of the target machine.
00046 
00047   /// getStackGrowthDirection - Return the direction the stack grows
00048   ///
00049   StackDirection getStackGrowthDirection() const { return StackDir; }
00050 
00051   /// getStackAlignment - This method returns the number of bytes that the stack
00052   /// pointer must be aligned to.  Typically, this is the largest alignment for
00053   /// any data object in the target.
00054   ///
00055   unsigned getStackAlignment() const { return StackAlignment; }
00056 
00057   /// getOffsetOfLocalArea - This method returns the offset of the local area
00058   /// from the stack pointer on entrance to a function.
00059   ///
00060   int getOffsetOfLocalArea() const { return LocalAreaOffset; }
00061 
00062   /// getCalleeSaveSpillSlots - This method returns a pointer to an array of
00063   /// pairs, that contains an entry for each callee save register that must be
00064   /// spilled to a particular stack location if it is spilled.
00065   ///
00066   /// Each entry in this array contains a <register,offset> pair, indicating the
00067   /// fixed offset from the incoming stack pointer that each register should be
00068   /// spilled at.  If a register is not listed here, the code generator is
00069   /// allowed to spill it anywhere it chooses.
00070   /// 
00071   virtual const std::pair<unsigned, int> *
00072   getCalleeSaveSpillSlots(unsigned &NumEntries) const {
00073     NumEntries = 0;
00074     return 0;
00075   }
00076   
00077   //===--------------------------------------------------------------------===//
00078   // These methods provide details of the stack frame used by Sparc, thus they
00079   // are Sparc specific.
00080   //===--------------------------------------------------------------------===//
00081 
00082   // This method adjusts a stack offset to meet alignment rules of target.
00083   virtual int adjustAlignment(int unalignedOffset, bool growUp,
00084             unsigned align) const;
00085 
00086   // These methods compute offsets using the frame contents for a particular
00087   // function.  The frame contents are obtained from the MachineFunction object
00088   // for the given function.  The rest must be implemented by the
00089   // machine-specific subclass.
00090   // 
00091   virtual int getIncomingArgOffset              (MachineFunction& mcInfo,
00092              unsigned argNum) const;
00093   virtual int getOutgoingArgOffset              (MachineFunction& mcInfo,
00094              unsigned argNum) const;
00095   
00096   virtual int getFirstAutomaticVarOffset        (MachineFunction& mcInfo,
00097                                                  bool& growUp) const;
00098   virtual int getRegSpillAreaOffset             (MachineFunction& mcInfo,
00099                                                  bool& growUp) const;
00100   virtual int getTmpAreaOffset                  (MachineFunction& mcInfo,
00101                                                  bool& growUp) const;
00102   virtual int getDynamicAreaOffset              (MachineFunction& mcInfo,
00103                                                  bool& growUp) const;
00104 };
00105 
00106 } // End llvm namespace
00107 
00108 #endif