1 //===-- llvm/CodeGen/MachineFunctionInfo.h ----------------------*- C++ -*-===//
3 // This class keeps track of information about the stack frame and about the
4 // per-function constant pool.
6 //===----------------------------------------------------------------------===//
8 #ifndef LLVM_CODEGEN_MACHINEFUNCTIONINFO_H
9 #define LLVM_CODEGEN_MACHINEFUNCTIONINFO_H
11 #include "Support/HashExtras.h"
12 #include "Support/hash_set"
13 class MachineFunction;
18 class MachineFunctionInfo {
19 hash_set<const Constant*> constantsForConstPool;
20 hash_map<const Value*, int> offsets;
21 unsigned staticStackSize;
22 unsigned automaticVarsSize;
23 unsigned regSpillsSize;
24 unsigned maxOptionalArgsSize;
25 unsigned maxOptionalNumArgs;
26 unsigned currentTmpValuesSize;
27 unsigned maxTmpValuesSize;
29 bool spillsAreaFrozen;
30 bool automaticVarsAreaFrozen;
34 MachineFunctionInfo(MachineFunction &mf) : MF(mf) {
35 staticStackSize = automaticVarsSize = regSpillsSize = 0;
36 maxOptionalArgsSize = maxOptionalNumArgs = currentTmpValuesSize = 0;
38 compiledAsLeaf = spillsAreaFrozen = automaticVarsAreaFrozen = false;
41 /// CalculateArgSize - Call this method to fill in the maxOptionalArgsSize &
42 /// staticStackSize fields...
44 void CalculateArgSize();
47 // Accessors for global information about generated code for a method.
49 bool isCompiledAsLeafMethod() const { return compiledAsLeaf; }
50 unsigned getStaticStackSize() const { return staticStackSize; }
51 unsigned getAutomaticVarsSize() const { return automaticVarsSize; }
52 unsigned getRegSpillsSize() const { return regSpillsSize; }
53 unsigned getMaxOptionalArgsSize() const { return maxOptionalArgsSize;}
54 unsigned getMaxOptionalNumArgs() const { return maxOptionalNumArgs;}
55 const hash_set<const Constant*> &getConstantPoolValues() const {
56 return constantsForConstPool;
60 // Modifiers used during code generation
62 void initializeFrameLayout ();
64 void addToConstantPool (const Constant* constVal) {
65 constantsForConstPool.insert(constVal);
68 void markAsLeafMethod() { compiledAsLeaf = true; }
70 int computeOffsetforLocalVar (const Value* local,
71 unsigned& getPaddedSize,
72 unsigned sizeToUse = 0);
73 int allocateLocalVar (const Value* local,
74 unsigned sizeToUse = 0);
76 int allocateSpilledValue (const Type* type);
77 int pushTempValue (unsigned size);
78 void popAllTempValues ();
80 void freezeSpillsArea () { spillsAreaFrozen = true; }
81 void freezeAutomaticVarsArea () { automaticVarsAreaFrozen=true; }
83 int getOffset (const Value* val) const;
86 void incrementAutomaticVarsSize(int incr) {
87 automaticVarsSize+= incr;
88 staticStackSize += incr;
90 void incrementRegSpillsSize(int incr) {
92 staticStackSize += incr;
94 void incrementTmpAreaSize(int incr) {
95 currentTmpValuesSize += incr;
96 if (maxTmpValuesSize < currentTmpValuesSize)
98 staticStackSize += currentTmpValuesSize - maxTmpValuesSize;
99 maxTmpValuesSize = currentTmpValuesSize;
102 void resetTmpAreaSize() {
103 currentTmpValuesSize = 0;
105 int allocateOptionalArg(const Type* type);