dd17eab88ce62106ab9e70c46765bd785895a6bb
[oota-llvm.git] / include / llvm / Target / TargetFrameInfo.h
1 //===-- llvm/Target/TargetFrameInfo.h ---------------------------*- C++ -*-===//
2 //
3 // Interface to describe the layout of a stack frame on the target machine.
4 //
5 //===----------------------------------------------------------------------===//
6
7 #ifndef LLVM_TARGET_TARGETFRAMEINFO_H
8 #define LLVM_TARGET_TARGETFRAMEINFO_H
9
10 class MachineFunction;
11
12 struct TargetFrameInfo {
13   enum StackDirection {
14     StackGrowsUp,        // Adding to the stack increases the stack address
15     StackGrowsDown       // Adding to the stack decreases the stack address
16   };
17 private:
18   StackDirection StackDir;
19   unsigned StackAlignment;
20   int LocalAreaOffset;
21 public:
22   TargetFrameInfo(StackDirection D, unsigned StackAl, int LAO)
23     : StackDir(D), StackAlignment(StackAl), LocalAreaOffset(LAO) {}
24
25   // These methods return information that describes the abstract stack layout
26   // of the target machine.
27
28   /// getStackGrowthDirection - Return the direction the stack grows
29   ///
30   StackDirection getStackGrowthDirection() const { return StackDir; }
31
32   /// getStackAlignment - This method returns the number of bytes that the stack
33   /// pointer must be aligned to.  Typically, this is the largest alignment for
34   /// any data object in the target.
35   ///
36   unsigned getStackAlignment() const { return StackAlignment; }
37
38   /// getOffsetOfLocalArea - This method returns the offset of the local area
39   /// from the stack pointer on entrance to a function.
40   ///
41   int getOffsetOfLocalArea() const { return LocalAreaOffset; }
42
43   //===--------------------------------------------------------------------===//
44   // These methods provide details of the stack frame used by Sparc, thus they
45   // are Sparc specific.
46   //===--------------------------------------------------------------------===//
47
48   virtual int  getStackFrameSizeAlignment       () const { abort(); }
49   virtual int  getMinStackFrameSize             () const { abort(); }
50   virtual int  getNumFixedOutgoingArgs          () const { abort(); }
51   virtual int  getSizeOfEachArgOnStack          () const { abort(); }
52   virtual bool argsOnStackHaveFixedSize         () const { abort(); }
53
54   // This method adjusts a stack offset to meet alignment rules of target.
55   virtual int adjustAlignment(int unalignedOffset, bool growUp,
56                               unsigned align) const { abort(); }
57
58   // These methods compute offsets using the frame contents for a particular
59   // function.  The frame contents are obtained from the MachineFunction object
60   // for the given function.  The rest must be implemented by the
61   // machine-specific subclass.
62   // 
63   virtual int getIncomingArgOffset              (MachineFunction& mcInfo,
64                                                  unsigned argNum)const{abort();}
65   virtual int getOutgoingArgOffset              (MachineFunction& mcInfo,
66                                                  unsigned argNum)const{abort();}
67   
68   virtual int getFirstIncomingArgOffset         (MachineFunction& mcInfo,
69                                                  bool& growUp) const { abort();}
70   virtual int getFirstOutgoingArgOffset         (MachineFunction& mcInfo,
71                                                  bool& growUp) const {abort();}
72   virtual int getFirstOptionalOutgoingArgOffset (MachineFunction&,
73                                                  bool& growUp) const {abort();}
74   virtual int getFirstAutomaticVarOffset        (MachineFunction& mcInfo,
75                                                  bool& growUp) const {abort();}
76   virtual int getRegSpillAreaOffset             (MachineFunction& mcInfo,
77                                                  bool& growUp) const {abort();}
78   virtual int getTmpAreaOffset                  (MachineFunction& mcInfo,
79                                                  bool& growUp) const {abort();}
80   virtual int getDynamicAreaOffset              (MachineFunction& mcInfo,
81                                                  bool& growUp) const {abort();}
82
83   //
84   // These methods specify the base register used for each stack area
85   // (generally FP or SP)
86   // 
87   virtual int getIncomingArgBaseRegNum()               const { abort(); }
88   virtual int getOutgoingArgBaseRegNum()               const { abort(); }
89   virtual int getOptionalOutgoingArgBaseRegNum()       const { abort(); }
90   virtual int getAutomaticVarBaseRegNum()              const { abort(); }
91   virtual int getRegSpillAreaBaseRegNum()              const { abort(); }
92   virtual int getDynamicAreaBaseRegNum()               const { abort(); }
93 };
94
95 #endif