14a98a0163406ad94819f90b389569a92e15b8e9
[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 namespace llvm {
18
19 class MachineFunction;
20
21 /// Information about stack frame layout on the target.  It holds the direction
22 /// of stack growth, the known stack alignment on entry to each function, and
23 /// the offset to the locals area.
24 ///
25 /// The offset to the local area is the offset from the stack pointer on
26 /// function entry to the first location where function data (local variables,
27 /// spill locations) can be stored.
28 struct TargetFrameInfo {
29   enum StackDirection {
30     StackGrowsUp,        // Adding to the stack increases the stack address
31     StackGrowsDown       // Adding to the stack decreases the stack address
32   };
33 private:
34   StackDirection StackDir;
35   unsigned StackAlignment;
36   int LocalAreaOffset;
37 public:
38   TargetFrameInfo(StackDirection D, unsigned StackAl, int LAO)
39     : StackDir(D), StackAlignment(StackAl), LocalAreaOffset(LAO) {}
40
41   // These methods return information that describes the abstract stack layout
42   // of the target machine.
43
44   /// getStackGrowthDirection - Return the direction the stack grows
45   ///
46   StackDirection getStackGrowthDirection() const { return StackDir; }
47
48   /// getStackAlignment - This method returns the number of bytes that the stack
49   /// pointer must be aligned to.  Typically, this is the largest alignment for
50   /// any data object in the target.
51   ///
52   unsigned getStackAlignment() const { return StackAlignment; }
53
54   /// getOffsetOfLocalArea - This method returns the offset of the local area
55   /// from the stack pointer on entrance to a function.
56   ///
57   int getOffsetOfLocalArea() const { return LocalAreaOffset; }
58
59   //===--------------------------------------------------------------------===//
60   // These methods provide details of the stack frame used by Sparc, thus they
61   // are Sparc specific.
62   //===--------------------------------------------------------------------===//
63
64   virtual int  getStackFrameSizeAlignment       () const;
65   virtual int  getMinStackFrameSize             () const;
66   virtual int  getNumFixedOutgoingArgs          () const;
67   virtual int  getSizeOfEachArgOnStack          () const;
68   virtual bool argsOnStackHaveFixedSize         () const;
69
70   // This method adjusts a stack offset to meet alignment rules of target.
71   virtual int adjustAlignment(int unalignedOffset, bool growUp,
72                               unsigned align) const;
73
74   // These methods compute offsets using the frame contents for a particular
75   // function.  The frame contents are obtained from the MachineFunction object
76   // for the given function.  The rest must be implemented by the
77   // machine-specific subclass.
78   // 
79   virtual int getIncomingArgOffset              (MachineFunction& mcInfo,
80                                                  unsigned argNum) const;
81   virtual int getOutgoingArgOffset              (MachineFunction& mcInfo,
82                                                  unsigned argNum) const;
83   
84   virtual int getFirstIncomingArgOffset         (MachineFunction& mcInfo,
85                                                  bool& growUp) const;
86   virtual int getFirstOutgoingArgOffset         (MachineFunction& mcInfo,
87                                                  bool& growUp) const;
88   virtual int getFirstOptionalOutgoingArgOffset (MachineFunction&,
89                                                  bool& growUp) const;
90   virtual int getFirstAutomaticVarOffset        (MachineFunction& mcInfo,
91                                                  bool& growUp) const;
92   virtual int getRegSpillAreaOffset             (MachineFunction& mcInfo,
93                                                  bool& growUp) const;
94   virtual int getTmpAreaOffset                  (MachineFunction& mcInfo,
95                                                  bool& growUp) const;
96   virtual int getDynamicAreaOffset              (MachineFunction& mcInfo,
97                                                  bool& growUp) const;
98 };
99
100 } // End llvm namespace
101
102 #endif