Chris Lattner | a1e51ff | 2004-08-18 18:13:37 +0000 | [diff] [blame] | 1 | //===-- SparcV9FunctionInfo.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 | 6b9a5e6 | 2004-08-16 22:37:18 +0000 | [diff] [blame] | 22 | #include "llvm/CodeGen/MachineFunction.h" |
Reid Spencer | 551ccae | 2004-09-01 22:55:40 +0000 | [diff] [blame] | 23 | #include "llvm/ADT/HashExtras.h" |
| 24 | #include "llvm/ADT/hash_set" |
Brian Gaeke | d0fde30 | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 25 | |
| 26 | namespace llvm { |
| 27 | |
Chris Lattner | 1951c5b | 2002-12-28 20:07:33 +0000 | [diff] [blame] | 28 | class MachineFunction; |
Chris Lattner | 1951c5b | 2002-12-28 20:07:33 +0000 | [diff] [blame] | 29 | class Constant; |
| 30 | class Type; |
| 31 | |
Chris Lattner | a1e51ff | 2004-08-18 18:13:37 +0000 | [diff] [blame] | 32 | class SparcV9FunctionInfo : public MachineFunctionInfo { |
Chris Lattner | 1951c5b | 2002-12-28 20:07:33 +0000 | [diff] [blame] | 33 | hash_set<const Constant*> constantsForConstPool; |
| 34 | hash_map<const Value*, int> offsets; |
Chris Lattner | 4aa5b2a | 2004-06-27 18:50:30 +0000 | [diff] [blame] | 35 | |
Chris Lattner | 1951c5b | 2002-12-28 20:07:33 +0000 | [diff] [blame] | 36 | unsigned staticStackSize; |
| 37 | unsigned automaticVarsSize; |
| 38 | unsigned regSpillsSize; |
| 39 | unsigned maxOptionalArgsSize; |
| 40 | unsigned maxOptionalNumArgs; |
| 41 | unsigned currentTmpValuesSize; |
| 42 | unsigned maxTmpValuesSize; |
| 43 | bool compiledAsLeaf; |
| 44 | bool spillsAreaFrozen; |
| 45 | bool automaticVarsAreaFrozen; |
| 46 | |
| 47 | MachineFunction &MF; |
| 48 | public: |
Chris Lattner | 4aa5b2a | 2004-06-27 18:50:30 +0000 | [diff] [blame] | 49 | hash_map<const Instruction*, MachineCodeForInstruction> MCFIEntries; |
| 50 | |
Chris Lattner | a1e51ff | 2004-08-18 18:13:37 +0000 | [diff] [blame] | 51 | SparcV9FunctionInfo(MachineFunction &mf) : MF(mf) { |
Chris Lattner | 1951c5b | 2002-12-28 20:07:33 +0000 | [diff] [blame] | 52 | staticStackSize = automaticVarsSize = regSpillsSize = 0; |
| 53 | maxOptionalArgsSize = maxOptionalNumArgs = currentTmpValuesSize = 0; |
| 54 | maxTmpValuesSize = 0; |
| 55 | compiledAsLeaf = spillsAreaFrozen = automaticVarsAreaFrozen = false; |
| 56 | } |
| 57 | |
| 58 | /// CalculateArgSize - Call this method to fill in the maxOptionalArgsSize & |
| 59 | /// staticStackSize fields... |
| 60 | /// |
| 61 | void CalculateArgSize(); |
| 62 | |
| 63 | // |
| 64 | // Accessors for global information about generated code for a method. |
| 65 | // |
| 66 | bool isCompiledAsLeafMethod() const { return compiledAsLeaf; } |
| 67 | unsigned getStaticStackSize() const { return staticStackSize; } |
| 68 | unsigned getAutomaticVarsSize() const { return automaticVarsSize; } |
| 69 | unsigned getRegSpillsSize() const { return regSpillsSize; } |
| 70 | unsigned getMaxOptionalArgsSize() const { return maxOptionalArgsSize;} |
| 71 | unsigned getMaxOptionalNumArgs() const { return maxOptionalNumArgs;} |
| 72 | const hash_set<const Constant*> &getConstantPoolValues() const { |
| 73 | return constantsForConstPool; |
| 74 | } |
| 75 | |
| 76 | // |
| 77 | // Modifiers used during code generation |
| 78 | // |
| 79 | void initializeFrameLayout (); |
| 80 | |
| 81 | void addToConstantPool (const Constant* constVal) { |
| 82 | constantsForConstPool.insert(constVal); |
| 83 | } |
| 84 | |
| 85 | void markAsLeafMethod() { compiledAsLeaf = true; } |
| 86 | |
| 87 | int computeOffsetforLocalVar (const Value* local, |
| 88 | unsigned& getPaddedSize, |
| 89 | unsigned sizeToUse = 0); |
| 90 | int allocateLocalVar (const Value* local, |
| 91 | unsigned sizeToUse = 0); |
| 92 | |
| 93 | int allocateSpilledValue (const Type* type); |
| 94 | int pushTempValue (unsigned size); |
| 95 | void popAllTempValues (); |
| 96 | |
| 97 | void freezeSpillsArea () { spillsAreaFrozen = true; } |
| 98 | void freezeAutomaticVarsArea () { automaticVarsAreaFrozen=true; } |
| 99 | |
Chris Lattner | 1951c5b | 2002-12-28 20:07:33 +0000 | [diff] [blame] | 100 | private: |
| 101 | void incrementAutomaticVarsSize(int incr) { |
| 102 | automaticVarsSize+= incr; |
| 103 | staticStackSize += incr; |
| 104 | } |
| 105 | void incrementRegSpillsSize(int incr) { |
| 106 | regSpillsSize+= incr; |
| 107 | staticStackSize += incr; |
| 108 | } |
| 109 | void incrementTmpAreaSize(int incr) { |
| 110 | currentTmpValuesSize += incr; |
| 111 | if (maxTmpValuesSize < currentTmpValuesSize) |
| 112 | { |
| 113 | staticStackSize += currentTmpValuesSize - maxTmpValuesSize; |
| 114 | maxTmpValuesSize = currentTmpValuesSize; |
| 115 | } |
| 116 | } |
| 117 | void resetTmpAreaSize() { |
| 118 | currentTmpValuesSize = 0; |
| 119 | } |
| 120 | int allocateOptionalArg(const Type* type); |
| 121 | }; |
| 122 | |
Brian Gaeke | d0fde30 | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 123 | } // End llvm namespace |
| 124 | |
Chris Lattner | 1951c5b | 2002-12-28 20:07:33 +0000 | [diff] [blame] | 125 | #endif |