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 // FIXME: This class is completely SparcV9 specific. Do not use it for future
14 // targets. This file will be eliminated in future versions of LLVM.
16 //===----------------------------------------------------------------------===//
18 #ifndef LLVM_CODEGEN_MACHINEFUNCTIONINFO_H
19 #define LLVM_CODEGEN_MACHINEFUNCTIONINFO_H
21 #include "llvm/CodeGen/MachineCodeForInstruction.h"
22 #include "Support/HashExtras.h"
23 #include "Support/hash_set"
27 class MachineFunction;
31 class MachineFunctionInfo {
32 hash_set<const Constant*> constantsForConstPool;
33 hash_map<const Value*, int> offsets;
35 unsigned staticStackSize;
36 unsigned automaticVarsSize;
37 unsigned regSpillsSize;
38 unsigned maxOptionalArgsSize;
39 unsigned maxOptionalNumArgs;
40 unsigned currentTmpValuesSize;
41 unsigned maxTmpValuesSize;
43 bool spillsAreaFrozen;
44 bool automaticVarsAreaFrozen;
48 hash_map<const Instruction*, MachineCodeForInstruction> MCFIEntries;
50 MachineFunctionInfo(MachineFunction &mf) : MF(mf) {
51 staticStackSize = automaticVarsSize = regSpillsSize = 0;
52 maxOptionalArgsSize = maxOptionalNumArgs = currentTmpValuesSize = 0;
54 compiledAsLeaf = spillsAreaFrozen = automaticVarsAreaFrozen = false;
57 /// CalculateArgSize - Call this method to fill in the maxOptionalArgsSize &
58 /// staticStackSize fields...
60 void CalculateArgSize();
63 // Accessors for global information about generated code for a method.
65 bool isCompiledAsLeafMethod() const { return compiledAsLeaf; }
66 unsigned getStaticStackSize() const { return staticStackSize; }
67 unsigned getAutomaticVarsSize() const { return automaticVarsSize; }
68 unsigned getRegSpillsSize() const { return regSpillsSize; }
69 unsigned getMaxOptionalArgsSize() const { return maxOptionalArgsSize;}
70 unsigned getMaxOptionalNumArgs() const { return maxOptionalNumArgs;}
71 const hash_set<const Constant*> &getConstantPoolValues() const {
72 return constantsForConstPool;
76 // Modifiers used during code generation
78 void initializeFrameLayout ();
80 void addToConstantPool (const Constant* constVal) {
81 constantsForConstPool.insert(constVal);
84 void markAsLeafMethod() { compiledAsLeaf = true; }
86 int computeOffsetforLocalVar (const Value* local,
87 unsigned& getPaddedSize,
88 unsigned sizeToUse = 0);
89 int allocateLocalVar (const Value* local,
90 unsigned sizeToUse = 0);
92 int allocateSpilledValue (const Type* type);
93 int pushTempValue (unsigned size);
94 void popAllTempValues ();
96 void freezeSpillsArea () { spillsAreaFrozen = true; }
97 void freezeAutomaticVarsArea () { automaticVarsAreaFrozen=true; }
100 void incrementAutomaticVarsSize(int incr) {
101 automaticVarsSize+= incr;
102 staticStackSize += incr;
104 void incrementRegSpillsSize(int incr) {
105 regSpillsSize+= incr;
106 staticStackSize += incr;
108 void incrementTmpAreaSize(int incr) {
109 currentTmpValuesSize += incr;
110 if (maxTmpValuesSize < currentTmpValuesSize)
112 staticStackSize += currentTmpValuesSize - maxTmpValuesSize;
113 maxTmpValuesSize = currentTmpValuesSize;
116 void resetTmpAreaSize() {
117 currentTmpValuesSize = 0;
119 int allocateOptionalArg(const Type* type);
122 } // End llvm namespace