llvm.org GIT mirror llvm / cd0d1d1
* Pull a bunch of frame and constant pool state out into a new MachineFunctionInfo class * Add a new FunctionFrameInfo object git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5163 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 17 years ago
1 changed file(s) with 30 addition(s) and 106 deletion(s). Raw diff Collapse all Expand all
0 //===-- llvm/CodeGen/MachineFunction.h --------------------------*- C++ -*-===//
11 //
2 // Collect native machine code information for a method. This allows
3 // target-specific information about the generated code to be stored with each
4 // method.
2 // Collect native machine code for a function. This class contains a list of
3 // MachineBasicBlock instances that make up the current compiled function.
4 //
5 // This class also contains pointers to various classes which hold
6 // target-specific information about the generated code.
57 //
68 //===----------------------------------------------------------------------===//
79
1012
1113 #include "llvm/CodeGen/MachineBasicBlock.h"
1214 #include "llvm/Annotation.h"
13 #include "Support/HashExtras.h"
14 #include "Support/hash_set"
1515 #include "Support/ilist"
1616
17 class Value;
1817 class Function;
19 class Constant;
20 class Type;
2118 class TargetMachine;
2219 class Pass;
2320 class SSARegMap;
21 class MachineFunctionInfo;
22 class FunctionFrameInfo;
2423
2524 Pass *createMachineCodeConstructionPass(TargetMachine &Target);
2625 Pass *createMachineCodeDestructionPass();
3635 // Keeping track of mapping from SSA values to registers
3736 SSARegMap *SSARegMapping;
3837
39 // FIXME: State should be held elsewhere...
40 hash_set constantsForConstPool;
41 hash_map offsets;
42 unsigned staticStackSize;
43 unsigned automaticVarsSize;
44 unsigned regSpillsSize;
45 unsigned maxOptionalArgsSize;
46 unsigned maxOptionalNumArgs;
47 unsigned currentTmpValuesSize;
48 unsigned maxTmpValuesSize;
49 bool compiledAsLeaf;
50 bool spillsAreaFrozen;
51 bool automaticVarsAreaFrozen;
38 // Used to keep track of frame and constant area information for sparc be
39 MachineFunctionInfo *MFInfo;
40
41 // Keep track of objects allocated on the stack.
42 FunctionFrameInfo *FrameInfo;
5243
5344 public:
5445 MachineFunction(const Function *Fn, const TargetMachine& target);
6152 /// getTarget - Return the target machine this machine code is compiled with
6253 ///
6354 const TargetMachine &getTarget() const { return Target; }
55
56 /// SSARegMap Interface... Keep track of information about each SSA virtual
57 /// register, such as which register class it belongs to.
58 ///
59 SSARegMap *getSSARegMap() const { return SSARegMapping; }
60 void clearSSARegMap();
61
62 /// getFrameInfo - Return the frame info object for the current function.
63 /// This object contains information about objects allocated on the stack
64 /// frame of the current function in an abstract way.
65 ///
66 FunctionFrameInfo *getFrameInfo() const { return FrameInfo; }
67
68 /// MachineFunctionInfo - Keep track of various per-function pieces of
69 /// information for the sparc backend.
70 ///
71 MachineFunctionInfo *getInfo() const { return MFInfo; }
72
6473
6574 /// print - Print out the MachineFunction in a format suitable for debugging
6675 /// to the specified stream.
115124 MachineBasicBlock &front() { return BasicBlocks.front(); }
116125 const MachineBasicBlock & back() const { return BasicBlocks.back(); }
117126 MachineBasicBlock & back() { return BasicBlocks.back(); }
118
119 //===--------------------------------------------------------------------===//
120 // SSARegMap Interface... Keep track of information about each SSA virtual
121 // register, such as which register class it belongs to.
122 //
123
124 SSARegMap *getSSARegMap() const { return SSARegMapping; }
125 void clearSSARegMap();
126
127
128 //===--------------------------------------------------------------------===//
129 //
130 // FIXME: Most of the following state should be moved into another class!
131 //
132
133 /// CalculateArgSize - Call this method to fill in the maxOptionalArgsSize &
134 /// staticStackSize fields...
135 ///
136 void CalculateArgSize();
137
138 //
139 // Accessors for global information about generated code for a method.
140 //
141 inline bool isCompiledAsLeafMethod() const { return compiledAsLeaf; }
142 inline unsigned getStaticStackSize() const { return staticStackSize; }
143 inline unsigned getAutomaticVarsSize() const { return automaticVarsSize; }
144 inline unsigned getRegSpillsSize() const { return regSpillsSize; }
145 inline unsigned getMaxOptionalArgsSize() const { return maxOptionalArgsSize;}
146 inline unsigned getMaxOptionalNumArgs() const { return maxOptionalNumArgs;}
147 inline const hash_set&
148 getConstantPoolValues() const {return constantsForConstPool;}
149
150 //
151 // Modifiers used during code generation
152 //
153 void initializeFrameLayout (const TargetMachine& target);
154
155 void addToConstantPool (const Constant* constVal)
156 { constantsForConstPool.insert(constVal); }
157
158 inline void markAsLeafMethod() { compiledAsLeaf = true; }
159
160 int computeOffsetforLocalVar (const TargetMachine& target,
161 const Value* local,
162 unsigned int& getPaddedSize,
163 unsigned int sizeToUse = 0);
164 int allocateLocalVar (const TargetMachine& target,
165 const Value* local,
166 unsigned int sizeToUse = 0);
167
168 int allocateSpilledValue (const TargetMachine& target,
169 const Type* type);
170
171 int pushTempValue (const TargetMachine& target,
172 unsigned int size);
173
174 void popAllTempValues (const TargetMachine& target);
175
176 void freezeSpillsArea () { spillsAreaFrozen = true; }
177 void freezeAutomaticVarsArea () { automaticVarsAreaFrozen=true; }
178
179 int getOffset (const Value* val) const;
180
181 private:
182 inline void incrementAutomaticVarsSize(int incr) {
183 automaticVarsSize+= incr;
184 staticStackSize += incr;
185 }
186 inline void incrementRegSpillsSize(int incr) {
187 regSpillsSize+= incr;
188 staticStackSize += incr;
189 }
190 inline void incrementTmpAreaSize(int incr) {
191 currentTmpValuesSize += incr;
192 if (maxTmpValuesSize < currentTmpValuesSize)
193 {
194 staticStackSize += currentTmpValuesSize - maxTmpValuesSize;
195 maxTmpValuesSize = currentTmpValuesSize;
196 }
197 }
198 inline void resetTmpAreaSize() {
199 currentTmpValuesSize = 0;
200 }
201 int allocateOptionalArg (const TargetMachine& target,
202 const Type* type);
203127 };
204128
205129 #endif