Rename FunctionFrameInfo to MachineFrameInfo
[oota-llvm.git] / include / llvm / CodeGen / MachineFunction.h
1 //===-- llvm/CodeGen/MachineFunction.h --------------------------*- C++ -*-===//
2 // 
3 // Collect native machine code for a function.  This class contains a list of
4 // MachineBasicBlock instances that make up the current compiled function.
5 //
6 // This class also contains pointers to various classes which hold
7 // target-specific information about the generated code.
8 //   
9 //===----------------------------------------------------------------------===//
10
11 #ifndef LLVM_CODEGEN_MACHINEFUNCTION_H
12 #define LLVM_CODEGEN_MACHINEFUNCTION_H
13
14 #include "llvm/CodeGen/MachineBasicBlock.h"
15 #include "llvm/Annotation.h"
16 #include "Support/ilist"
17
18 class Function;
19 class TargetMachine;
20 class Pass;
21 class SSARegMap;
22 class MachineFunctionInfo;
23 class MachineFrameInfo;
24
25 Pass *createMachineCodeConstructionPass(TargetMachine &Target);
26 Pass *createMachineCodeDestructionPass();
27 Pass *createMachineFunctionPrinterPass();
28
29 class MachineFunction : private Annotation {
30   const Function *Fn;
31   const TargetMachine &Target;
32
33   // List of machine basic blocks in function
34   iplist<MachineBasicBlock> BasicBlocks;
35
36   // Keeping track of mapping from SSA values to registers
37   SSARegMap *SSARegMapping;
38
39   // Used to keep track of frame and constant area information for sparc be
40   MachineFunctionInfo *MFInfo;
41
42   // Keep track of objects allocated on the stack.
43   MachineFrameInfo *FrameInfo;
44
45 public:
46   MachineFunction(const Function *Fn, const TargetMachine& target);
47   ~MachineFunction();
48
49   /// getFunction - Return the LLVM function that this machine code represents
50   ///
51   const Function *getFunction() const { return Fn; }
52
53   /// getTarget - Return the target machine this machine code is compiled with
54   ///
55   const TargetMachine &getTarget() const { return Target; }
56
57   /// SSARegMap Interface... Keep track of information about each SSA virtual
58   /// register, such as which register class it belongs to.
59   ///
60   SSARegMap *getSSARegMap() const { return SSARegMapping; }
61   void clearSSARegMap();
62
63   /// getFrameInfo - Return the frame info object for the current function.
64   /// This object contains information about objects allocated on the stack
65   /// frame of the current function in an abstract way.
66   ///
67   MachineFrameInfo *getFrameInfo() const { return FrameInfo; }
68
69   /// MachineFunctionInfo - Keep track of various per-function pieces of
70   /// information for the sparc backend.
71   ///
72   MachineFunctionInfo *getInfo() const { return MFInfo; }
73
74
75   /// print - Print out the MachineFunction in a format suitable for debugging
76   /// to the specified stream.
77   ///
78   void print(std::ostream &OS) const;
79
80   /// dump - Print the current MachineFunction to cerr, useful for debugger use.
81   ///
82   void dump() const;
83
84   // The next three methods are used to construct, destruct, and retrieve the
85   // MachineFunction object for the given method.
86   //
87   // construct() -- Allocates and initializes for a given method and target
88   // get()       -- Returns a handle to the object.
89   //                This should not be called before "construct()"
90   //                for a given Method.
91   // destruct()  -- Destroy the MachineFunction object
92   // 
93   static MachineFunction& construct(const Function *Fn,
94                                     const TargetMachine &target);
95   static void destruct(const Function *F);
96   static MachineFunction& get(const Function *F);
97
98   // Provide accessors for the MachineBasicBlock list...
99   typedef iplist<MachineBasicBlock> BasicBlockListType;
100   typedef BasicBlockListType::iterator iterator;
101   typedef BasicBlockListType::const_iterator const_iterator;
102   typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
103   typedef std::reverse_iterator<iterator>             reverse_iterator;
104
105   // Provide accessors for basic blocks...
106   const BasicBlockListType &getBasicBlockList() const { return BasicBlocks; }
107         BasicBlockListType &getBasicBlockList()       { return BasicBlocks; }
108  
109   //===--------------------------------------------------------------------===//
110   // BasicBlock iterator forwarding functions
111   //
112   iterator                 begin()       { return BasicBlocks.begin(); }
113   const_iterator           begin() const { return BasicBlocks.begin(); }
114   iterator                 end  ()       { return BasicBlocks.end();   }
115   const_iterator           end  () const { return BasicBlocks.end();   }
116
117   reverse_iterator        rbegin()       { return BasicBlocks.rbegin(); }
118   const_reverse_iterator  rbegin() const { return BasicBlocks.rbegin(); }
119   reverse_iterator        rend  ()       { return BasicBlocks.rend();   }
120   const_reverse_iterator  rend  () const { return BasicBlocks.rend();   }
121
122   unsigned                  size() const { return BasicBlocks.size(); }
123   bool                     empty() const { return BasicBlocks.empty(); }
124   const MachineBasicBlock &front() const { return BasicBlocks.front(); }
125         MachineBasicBlock &front()       { return BasicBlocks.front(); }
126   const MachineBasicBlock & back() const { return BasicBlocks.back(); }
127         MachineBasicBlock & back()       { return BasicBlocks.back(); }
128 };
129
130 #endif