53430a572ebf1b18704b98d9de12e1bf0d8706b4
[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 class TargetFrameInfo {
31 public:
32   enum StackDirection {
33     StackGrowsUp,        // Adding to the stack increases the stack address
34     StackGrowsDown       // Adding to the stack decreases the stack address
35   };
36 private:
37   StackDirection StackDir;
38   unsigned StackAlignment;
39   int LocalAreaOffset;
40 public:
41   TargetFrameInfo(StackDirection D, unsigned StackAl, int LAO)
42     : StackDir(D), StackAlignment(StackAl), LocalAreaOffset(LAO) {}
43
44   virtual ~TargetFrameInfo();
45
46   // These methods return information that describes the abstract stack layout
47   // of the target machine.
48
49   /// getStackGrowthDirection - Return the direction the stack grows
50   ///
51   StackDirection getStackGrowthDirection() const { return StackDir; }
52
53   /// getStackAlignment - This method returns the number of bytes that the stack
54   /// pointer must be aligned to.  Typically, this is the largest alignment for
55   /// any data object in the target.
56   ///
57   unsigned getStackAlignment() const { return StackAlignment; }
58
59   /// getOffsetOfLocalArea - This method returns the offset of the local area
60   /// from the stack pointer on entrance to a function.
61   ///
62   int getOffsetOfLocalArea() const { return LocalAreaOffset; }
63
64   /// getCalleeSavedSpillSlots - This method returns a pointer to an array of
65   /// pairs, that contains an entry for each callee saved register that must be
66   /// spilled to a particular stack location if it is spilled.
67   ///
68   /// Each entry in this array contains a <register,offset> pair, indicating the
69   /// fixed offset from the incoming stack pointer that each register should be
70   /// spilled at.  If a register is not listed here, the code generator is
71   /// allowed to spill it anywhere it chooses.
72   ///
73   virtual const std::pair<unsigned, int> *
74   getCalleeSavedSpillSlots(unsigned &NumEntries) const {
75     NumEntries = 0;
76     return 0;
77   }
78 };
79
80 } // End llvm namespace
81
82 #endif