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