1 //===-- llvm/CodeGen/MachineFunctionInfo.h ----------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
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.
8 //===----------------------------------------------------------------------===//
10 // This class keeps track of information about the stack frame and about the
11 // per-function constant pool.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CODEGEN_MACHINEFUNCTIONINFO_H
16 #define LLVM_CODEGEN_MACHINEFUNCTIONINFO_H
18 #include "Support/HashExtras.h"
19 #include "Support/hash_set"
23 class MachineFunction;
28 class MachineFunctionInfo {
29 hash_set<const Constant*> constantsForConstPool;
30 hash_map<const Value*, int> offsets;
31 unsigned staticStackSize;
32 unsigned automaticVarsSize;
33 unsigned regSpillsSize;
34 unsigned maxOptionalArgsSize;
35 unsigned maxOptionalNumArgs;
36 unsigned currentTmpValuesSize;
37 unsigned maxTmpValuesSize;
39 bool spillsAreaFrozen;
40 bool automaticVarsAreaFrozen;
44 MachineFunctionInfo(MachineFunction &mf) : MF(mf) {
45 staticStackSize = automaticVarsSize = regSpillsSize = 0;
46 maxOptionalArgsSize = maxOptionalNumArgs = currentTmpValuesSize = 0;
48 compiledAsLeaf = spillsAreaFrozen = automaticVarsAreaFrozen = false;
51 /// CalculateArgSize - Call this method to fill in the maxOptionalArgsSize &
52 /// staticStackSize fields...
54 void CalculateArgSize();
57 // Accessors for global information about generated code for a method.
59 bool isCompiledAsLeafMethod() const { return compiledAsLeaf; }
60 unsigned getStaticStackSize() const { return staticStackSize; }
61 unsigned getAutomaticVarsSize() const { return automaticVarsSize; }
62 unsigned getRegSpillsSize() const { return regSpillsSize; }
63 unsigned getMaxOptionalArgsSize() const { return maxOptionalArgsSize;}
64 unsigned getMaxOptionalNumArgs() const { return maxOptionalNumArgs;}
65 const hash_set<const Constant*> &getConstantPoolValues() const {
66 return constantsForConstPool;
70 // Modifiers used during code generation
72 void initializeFrameLayout ();
74 void addToConstantPool (const Constant* constVal) {
75 constantsForConstPool.insert(constVal);
78 void markAsLeafMethod() { compiledAsLeaf = true; }
80 int computeOffsetforLocalVar (const Value* local,
81 unsigned& getPaddedSize,
82 unsigned sizeToUse = 0);
83 int allocateLocalVar (const Value* local,
84 unsigned sizeToUse = 0);
86 int allocateSpilledValue (const Type* type);
87 int pushTempValue (unsigned size);
88 void popAllTempValues ();
90 void freezeSpillsArea () { spillsAreaFrozen = true; }
91 void freezeAutomaticVarsArea () { automaticVarsAreaFrozen=true; }
94 void incrementAutomaticVarsSize(int incr) {
95 automaticVarsSize+= incr;
96 staticStackSize += incr;
98 void incrementRegSpillsSize(int incr) {
100 staticStackSize += incr;
102 void incrementTmpAreaSize(int incr) {
103 currentTmpValuesSize += incr;
104 if (maxTmpValuesSize < currentTmpValuesSize)
106 staticStackSize += currentTmpValuesSize - maxTmpValuesSize;
107 maxTmpValuesSize = currentTmpValuesSize;
110 void resetTmpAreaSize() {
111 currentTmpValuesSize = 0;
113 int allocateOptionalArg(const Type* type);
116 } // End llvm namespace