LLVM API Documentation

MachineFunctionInfo.h

Go to the documentation of this file.
00001 //===-- SparcV9FunctionInfo.h -----------------------------------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file was developed by the LLVM research group and is distributed under
00006 // the University of Illinois Open Source License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This class keeps track of information about the stack frame and about the
00011 // per-function constant pool.
00012 //
00013 // FIXME: This class is completely SparcV9 specific.  Do not use it for future
00014 // targets.  This file will be eliminated in future versions of LLVM.
00015 //
00016 //===----------------------------------------------------------------------===//
00017 
00018 #ifndef MACHINEFUNCTIONINFO_H
00019 #define MACHINEFUNCTIONINFO_H
00020 
00021 #include "MachineCodeForInstruction.h"
00022 #include "llvm/CodeGen/MachineFunction.h"
00023 #include "llvm/ADT/HashExtras.h"
00024 #include "llvm/ADT/hash_set"
00025 
00026 namespace llvm {
00027 
00028 class MachineFunction;
00029 class Constant;
00030 class Type;
00031 
00032 class SparcV9FunctionInfo : public MachineFunctionInfo {
00033   hash_set<const Constant*> constantsForConstPool;
00034   hash_map<const Value*, int> offsets;
00035 
00036   unsigned      staticStackSize;
00037   unsigned      automaticVarsSize;
00038   unsigned      regSpillsSize;
00039   unsigned      maxOptionalArgsSize;
00040   unsigned      maxOptionalNumArgs;
00041   unsigned      currentTmpValuesSize;
00042   unsigned      maxTmpValuesSize;
00043   bool          compiledAsLeaf;
00044   bool          spillsAreaFrozen;
00045   bool          automaticVarsAreaFrozen;
00046 
00047   MachineFunction &MF;
00048 public:
00049   hash_map<const Instruction*, MachineCodeForInstruction> MCFIEntries;
00050 
00051   SparcV9FunctionInfo(MachineFunction &mf) : MF(mf) {
00052     staticStackSize = automaticVarsSize = regSpillsSize = 0;
00053     maxOptionalArgsSize = maxOptionalNumArgs = currentTmpValuesSize = 0;
00054     maxTmpValuesSize = 0;
00055     compiledAsLeaf = spillsAreaFrozen = automaticVarsAreaFrozen = false;
00056   }
00057 
00058   /// CalculateArgSize - Call this method to fill in the maxOptionalArgsSize &
00059   /// staticStackSize fields...
00060   ///
00061   void CalculateArgSize();
00062 
00063   //
00064   // Accessors for global information about generated code for a method.
00065   //
00066   bool     isCompiledAsLeafMethod() const { return compiledAsLeaf; }
00067   unsigned getStaticStackSize()     const { return staticStackSize; }
00068   unsigned getAutomaticVarsSize()   const { return automaticVarsSize; }
00069   unsigned getRegSpillsSize()       const { return regSpillsSize; }
00070   unsigned getMaxOptionalArgsSize() const { return maxOptionalArgsSize;}
00071   unsigned getMaxOptionalNumArgs()  const { return maxOptionalNumArgs;}
00072   const hash_set<const Constant*> &getConstantPoolValues() const {
00073     return constantsForConstPool;
00074   }
00075 
00076   //
00077   // Modifiers used during code generation
00078   //
00079   void            initializeFrameLayout    ();
00080 
00081   void            addToConstantPool        (const Constant* constVal) {
00082     constantsForConstPool.insert(constVal);
00083   }
00084 
00085   void markAsLeafMethod() { compiledAsLeaf = true; }
00086 
00087   int             computeOffsetforLocalVar (const Value*  local,
00088                                             unsigned& getPaddedSize,
00089                                             unsigned  sizeToUse = 0);
00090   int             allocateLocalVar         (const Value* local,
00091                                             unsigned sizeToUse = 0);
00092 
00093   int             allocateSpilledValue     (const Type* type);
00094   int             pushTempValue            (unsigned size);
00095   void            popAllTempValues         ();
00096 
00097   void            freezeSpillsArea         () { spillsAreaFrozen = true; }
00098   void            freezeAutomaticVarsArea  () { automaticVarsAreaFrozen=true; }
00099 
00100 private:
00101   void incrementAutomaticVarsSize(int incr) {
00102     automaticVarsSize+= incr;
00103     staticStackSize += incr;
00104   }
00105   void incrementRegSpillsSize(int incr) {
00106     regSpillsSize+= incr;
00107     staticStackSize += incr;
00108   }
00109   void incrementTmpAreaSize(int incr) {
00110     currentTmpValuesSize += incr;
00111     if (maxTmpValuesSize < currentTmpValuesSize)
00112       {
00113         staticStackSize += currentTmpValuesSize - maxTmpValuesSize;
00114         maxTmpValuesSize = currentTmpValuesSize;
00115       }
00116   }
00117   void resetTmpAreaSize() {
00118     currentTmpValuesSize = 0;
00119   }
00120   int allocateOptionalArg(const Type* type);
00121 };
00122 
00123 } // End llvm namespace
00124 
00125 #endif