1 //===-- SparcV9FunctionInfo.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 MACHINEFUNCTIONINFO_H
19 #define MACHINEFUNCTIONINFO_H
21 #include "MachineCodeForInstruction.h"
22 #include "llvm/CodeGen/MachineFunction.h"
23 #include "llvm/ADT/HashExtras.h"
24 #include "llvm/ADT/hash_set"
28 class MachineFunction;
32 class SparcV9FunctionInfo : public MachineFunctionInfo {
33 hash_set<const Constant*> constantsForConstPool;
34 hash_map<const Value*, int> offsets;
36 unsigned staticStackSize;
37 unsigned automaticVarsSize;
38 unsigned regSpillsSize;
39 unsigned maxOptionalArgsSize;
40 unsigned maxOptionalNumArgs;
41 unsigned currentTmpValuesSize;
42 unsigned maxTmpValuesSize;
44 bool spillsAreaFrozen;
45 bool automaticVarsAreaFrozen;
49 hash_map<const Instruction*, MachineCodeForInstruction> MCFIEntries;
51 SparcV9FunctionInfo(MachineFunction &mf) : MF(mf) {
52 staticStackSize = automaticVarsSize = regSpillsSize = 0;
53 maxOptionalArgsSize = maxOptionalNumArgs = currentTmpValuesSize = 0;
55 compiledAsLeaf = spillsAreaFrozen = automaticVarsAreaFrozen = false;
58 /// CalculateArgSize - Call this method to fill in the maxOptionalArgsSize &
59 /// staticStackSize fields...
61 void CalculateArgSize();
64 // Accessors for global information about generated code for a method.
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;
77 // Modifiers used during code generation
79 void initializeFrameLayout ();
81 void addToConstantPool (const Constant* constVal) {
82 constantsForConstPool.insert(constVal);
85 void markAsLeafMethod() { compiledAsLeaf = true; }
87 int computeOffsetforLocalVar (const Value* local,
88 unsigned& getPaddedSize,
89 unsigned sizeToUse = 0);
90 int allocateLocalVar (const Value* local,
91 unsigned sizeToUse = 0);
93 int allocateSpilledValue (const Type* type);
94 int pushTempValue (unsigned size);
95 void popAllTempValues ();
97 void freezeSpillsArea () { spillsAreaFrozen = true; }
98 void freezeAutomaticVarsArea () { automaticVarsAreaFrozen=true; }
101 void incrementAutomaticVarsSize(int incr) {
102 automaticVarsSize+= incr;
103 staticStackSize += incr;
105 void incrementRegSpillsSize(int incr) {
106 regSpillsSize+= incr;
107 staticStackSize += incr;
109 void incrementTmpAreaSize(int incr) {
110 currentTmpValuesSize += incr;
111 if (maxTmpValuesSize < currentTmpValuesSize)
113 staticStackSize += currentTmpValuesSize - maxTmpValuesSize;
114 maxTmpValuesSize = currentTmpValuesSize;
117 void resetTmpAreaSize() {
118 currentTmpValuesSize = 0;
120 int allocateOptionalArg(const Type* type);
123 } // End llvm namespace