Chris Lattner | 85015a0 | 2004-08-16 21:55:02 +0000 | [diff] [blame^] | 1 | //===-- MachineFunctionInfo.h -----------------------------------*- C++ -*-===// |
Chris Lattner | 1951c5b | 2002-12-28 20:07:33 +0000 | [diff] [blame] | 2 | // |
John Criswell | 6fbcc26 | 2003-10-20 20:19:47 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 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. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
Chris Lattner | 1951c5b | 2002-12-28 20:07:33 +0000 | [diff] [blame] | 10 | // This class keeps track of information about the stack frame and about the |
| 11 | // per-function constant pool. |
Chris Lattner | 4aa5b2a | 2004-06-27 18:50:30 +0000 | [diff] [blame] | 12 | // |
| 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. |
Chris Lattner | 1951c5b | 2002-12-28 20:07:33 +0000 | [diff] [blame] | 15 | // |
| 16 | //===----------------------------------------------------------------------===// |
| 17 | |
Chris Lattner | 85015a0 | 2004-08-16 21:55:02 +0000 | [diff] [blame^] | 18 | #ifndef MACHINEFUNCTIONINFO_H |
| 19 | #define MACHINEFUNCTIONINFO_H |
Chris Lattner | 1951c5b | 2002-12-28 20:07:33 +0000 | [diff] [blame] | 20 | |
Chris Lattner | 85015a0 | 2004-08-16 21:55:02 +0000 | [diff] [blame^] | 21 | #include "MachineCodeForInstruction.h" |
Chris Lattner | 1951c5b | 2002-12-28 20:07:33 +0000 | [diff] [blame] | 22 | #include "Support/HashExtras.h" |
| 23 | #include "Support/hash_set" |
Brian Gaeke | d0fde30 | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 24 | |
| 25 | namespace llvm { |
| 26 | |
Chris Lattner | 1951c5b | 2002-12-28 20:07:33 +0000 | [diff] [blame] | 27 | class MachineFunction; |
Chris Lattner | 1951c5b | 2002-12-28 20:07:33 +0000 | [diff] [blame] | 28 | class Constant; |
| 29 | class Type; |
| 30 | |
| 31 | class MachineFunctionInfo { |
| 32 | hash_set<const Constant*> constantsForConstPool; |
| 33 | hash_map<const Value*, int> offsets; |
Chris Lattner | 4aa5b2a | 2004-06-27 18:50:30 +0000 | [diff] [blame] | 34 | |
Chris Lattner | 1951c5b | 2002-12-28 20:07:33 +0000 | [diff] [blame] | 35 | unsigned staticStackSize; |
| 36 | unsigned automaticVarsSize; |
| 37 | unsigned regSpillsSize; |
| 38 | unsigned maxOptionalArgsSize; |
| 39 | unsigned maxOptionalNumArgs; |
| 40 | unsigned currentTmpValuesSize; |
| 41 | unsigned maxTmpValuesSize; |
| 42 | bool compiledAsLeaf; |
| 43 | bool spillsAreaFrozen; |
| 44 | bool automaticVarsAreaFrozen; |
| 45 | |
| 46 | MachineFunction &MF; |
| 47 | public: |
Chris Lattner | 4aa5b2a | 2004-06-27 18:50:30 +0000 | [diff] [blame] | 48 | hash_map<const Instruction*, MachineCodeForInstruction> MCFIEntries; |
| 49 | |
Chris Lattner | 1951c5b | 2002-12-28 20:07:33 +0000 | [diff] [blame] | 50 | MachineFunctionInfo(MachineFunction &mf) : MF(mf) { |
| 51 | staticStackSize = automaticVarsSize = regSpillsSize = 0; |
| 52 | maxOptionalArgsSize = maxOptionalNumArgs = currentTmpValuesSize = 0; |
| 53 | maxTmpValuesSize = 0; |
| 54 | compiledAsLeaf = spillsAreaFrozen = automaticVarsAreaFrozen = false; |
| 55 | } |
| 56 | |
| 57 | /// CalculateArgSize - Call this method to fill in the maxOptionalArgsSize & |
| 58 | /// staticStackSize fields... |
| 59 | /// |
| 60 | void CalculateArgSize(); |
| 61 | |
| 62 | // |
| 63 | // Accessors for global information about generated code for a method. |
| 64 | // |
| 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; |
| 73 | } |
| 74 | |
| 75 | // |
| 76 | // Modifiers used during code generation |
| 77 | // |
| 78 | void initializeFrameLayout (); |
| 79 | |
| 80 | void addToConstantPool (const Constant* constVal) { |
| 81 | constantsForConstPool.insert(constVal); |
| 82 | } |
| 83 | |
| 84 | void markAsLeafMethod() { compiledAsLeaf = true; } |
| 85 | |
| 86 | int computeOffsetforLocalVar (const Value* local, |
| 87 | unsigned& getPaddedSize, |
| 88 | unsigned sizeToUse = 0); |
| 89 | int allocateLocalVar (const Value* local, |
| 90 | unsigned sizeToUse = 0); |
| 91 | |
| 92 | int allocateSpilledValue (const Type* type); |
| 93 | int pushTempValue (unsigned size); |
| 94 | void popAllTempValues (); |
| 95 | |
| 96 | void freezeSpillsArea () { spillsAreaFrozen = true; } |
| 97 | void freezeAutomaticVarsArea () { automaticVarsAreaFrozen=true; } |
| 98 | |
Chris Lattner | 1951c5b | 2002-12-28 20:07:33 +0000 | [diff] [blame] | 99 | private: |
| 100 | void incrementAutomaticVarsSize(int incr) { |
| 101 | automaticVarsSize+= incr; |
| 102 | staticStackSize += incr; |
| 103 | } |
| 104 | void incrementRegSpillsSize(int incr) { |
| 105 | regSpillsSize+= incr; |
| 106 | staticStackSize += incr; |
| 107 | } |
| 108 | void incrementTmpAreaSize(int incr) { |
| 109 | currentTmpValuesSize += incr; |
| 110 | if (maxTmpValuesSize < currentTmpValuesSize) |
| 111 | { |
| 112 | staticStackSize += currentTmpValuesSize - maxTmpValuesSize; |
| 113 | maxTmpValuesSize = currentTmpValuesSize; |
| 114 | } |
| 115 | } |
| 116 | void resetTmpAreaSize() { |
| 117 | currentTmpValuesSize = 0; |
| 118 | } |
| 119 | int allocateOptionalArg(const Type* type); |
| 120 | }; |
| 121 | |
Brian Gaeke | d0fde30 | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 122 | } // End llvm namespace |
| 123 | |
Chris Lattner | 1951c5b | 2002-12-28 20:07:33 +0000 | [diff] [blame] | 124 | #endif |