MC: Change RelaxInstruction to only take the input and output instructions.
[oota-llvm.git] / include / llvm / Target / TargetFrameInfo.h
1 //===-- llvm/Target/TargetFrameInfo.h ---------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // 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 /// 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 class TargetFrameInfo {
29 public:
30   enum StackDirection {
31     StackGrowsUp,        // Adding to the stack increases the stack address
32     StackGrowsDown       // Adding to the stack decreases the stack address
33   };
34
35   // Maps a callee saved register to a stack slot with a fixed offset.
36   struct SpillSlot {
37     unsigned Reg;
38     int Offset; // Offset relative to stack pointer on function entry.
39   };
40 private:
41   StackDirection StackDir;
42   unsigned StackAlignment;
43   unsigned TransientStackAlignment;
44   int LocalAreaOffset;
45 public:
46   TargetFrameInfo(StackDirection D, unsigned StackAl, int LAO,
47                   unsigned TransAl = 1)
48     : StackDir(D), StackAlignment(StackAl), TransientStackAlignment(TransAl),
49       LocalAreaOffset(LAO) {}
50
51   virtual ~TargetFrameInfo();
52
53   // These methods return information that describes the abstract stack layout
54   // of the target machine.
55
56   /// getStackGrowthDirection - Return the direction the stack grows
57   ///
58   StackDirection getStackGrowthDirection() const { return StackDir; }
59
60   /// getStackAlignment - This method returns the number of bytes to which the
61   /// stack pointer must be aligned on entry to a function.  Typically, this
62   /// is the largest alignment for any data object in the target.
63   ///
64   unsigned getStackAlignment() const { return StackAlignment; }
65
66   /// getTransientStackAlignment - This method returns the number of bytes to
67   /// which the stack pointer must be aligned at all times, even between
68   /// calls.
69   ///
70   unsigned getTransientStackAlignment() const {
71     return TransientStackAlignment;
72   }
73
74   /// getOffsetOfLocalArea - This method returns the offset of the local area
75   /// from the stack pointer on entrance to a function.
76   ///
77   int getOffsetOfLocalArea() const { return LocalAreaOffset; }
78
79   /// getCalleeSavedSpillSlots - This method returns a pointer to an array of
80   /// pairs, that contains an entry for each callee saved register that must be
81   /// spilled to a particular stack location if it is spilled.
82   ///
83   /// Each entry in this array contains a <register,offset> pair, indicating the
84   /// fixed offset from the incoming stack pointer that each register should be
85   /// spilled at. If a register is not listed here, the code generator is
86   /// allowed to spill it anywhere it chooses.
87   ///
88   virtual const SpillSlot *
89   getCalleeSavedSpillSlots(unsigned &NumEntries) const {
90     NumEntries = 0;
91     return 0;
92   }
93 };
94
95 } // End llvm namespace
96
97 #endif