Be consistent with our naming
[oota-llvm.git] / include / llvm / Target / TargetFrameInfo.h
1 //===-- llvm/Target/TargetFrameInfo.h ---------------------------*- C++ -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 // Interface to describe the layout of a stack frame on the target machine.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_TARGET_TARGETFRAMEINFO_H
15 #define LLVM_TARGET_TARGETFRAMEINFO_H
16
17 #include <utility>
18
19 namespace llvm {
20
21 class MachineFunction;
22
23 /// Information about stack frame layout on the target.  It holds the direction
24 /// of stack growth, the known stack alignment on entry to each function, and
25 /// the offset to the locals area.
26 ///
27 /// The offset to the local area is the offset from the stack pointer on
28 /// function entry to the first location where function data (local variables,
29 /// spill locations) can be stored.
30 struct TargetFrameInfo {
31   enum StackDirection {
32     StackGrowsUp,        // Adding to the stack increases the stack address
33     StackGrowsDown       // Adding to the stack decreases the stack address
34   };
35 private:
36   StackDirection StackDir;
37   unsigned StackAlignment;
38   int LocalAreaOffset;
39 public:
40   TargetFrameInfo(StackDirection D, unsigned StackAl, int LAO)
41     : StackDir(D), StackAlignment(StackAl), LocalAreaOffset(LAO) {}
42
43   // These methods return information that describes the abstract stack layout
44   // of the target machine.
45
46   /// getStackGrowthDirection - Return the direction the stack grows
47   ///
48   StackDirection getStackGrowthDirection() const { return StackDir; }
49
50   /// getStackAlignment - This method returns the number of bytes that the stack
51   /// pointer must be aligned to.  Typically, this is the largest alignment for
52   /// any data object in the target.
53   ///
54   unsigned getStackAlignment() const { return StackAlignment; }
55
56   /// getOffsetOfLocalArea - This method returns the offset of the local area
57   /// from the stack pointer on entrance to a function.
58   ///
59   int getOffsetOfLocalArea() const { return LocalAreaOffset; }
60
61   /// getCalleeSaveSpillSlots - This method returns a pointer to an array of
62   /// pairs, that contains an entry for each callee save register that must be
63   /// spilled to a particular stack location if it is spilled.
64   ///
65   /// Each entry in this array contains a <register,offset> pair, indicating the
66   /// fixed offset from the incoming stack pointer that each register should be
67   /// spilled at.  If a register is not listed here, the code generator is
68   /// allowed to spill it anywhere it chooses.
69   /// 
70   virtual const std::pair<unsigned, int> *
71   getCalleeSaveSpillSlots(unsigned &NumEntries) const {
72     NumEntries = 0;
73     return 0;
74   }
75   
76   //===--------------------------------------------------------------------===//
77   // These methods provide details of the stack frame used by Sparc, thus they
78   // are Sparc specific.
79   //===--------------------------------------------------------------------===//
80
81   // This method adjusts a stack offset to meet alignment rules of target.
82   virtual int adjustAlignment(int unalignedOffset, bool growUp,
83                               unsigned align) const;
84
85   // These methods compute offsets using the frame contents for a particular
86   // function.  The frame contents are obtained from the MachineFunction object
87   // for the given function.  The rest must be implemented by the
88   // machine-specific subclass.
89   // 
90   virtual int getIncomingArgOffset              (MachineFunction& mcInfo,
91                                                  unsigned argNum) const;
92   virtual int getOutgoingArgOffset              (MachineFunction& mcInfo,
93                                                  unsigned argNum) const;
94   
95   virtual int getFirstAutomaticVarOffset        (MachineFunction& mcInfo,
96                                                  bool& growUp) const;
97   virtual int getRegSpillAreaOffset             (MachineFunction& mcInfo,
98                                                  bool& growUp) const;
99   virtual int getTmpAreaOffset                  (MachineFunction& mcInfo,
100                                                  bool& growUp) const;
101   virtual int getDynamicAreaOffset              (MachineFunction& mcInfo,
102                                                  bool& growUp) const;
103 };
104
105 } // End llvm namespace
106
107 #endif