Rename llvm/Analysis/LiveVar/FunctionLiveVarInfo.h -> llvm/CodeGen/FunctionLiveVarInfo.h
[oota-llvm.git] / include / llvm / Analysis / LiveVar / FunctionLiveVarInfo.h
index 9e44be4642a80b39a78bfd772a77d94b07755e2e..0bdd7f92b9cb66931c50b6398e0438671476a088 100644 (file)
@@ -1,15 +1,15 @@
-/* Title:   MethodLiveVarInfo.h             -*- C++ -*-
+/* Title:   FunctionLiveVarInfo.h             -*- C++ -*-
    Author:  Ruchira Sasanka
    Date:    Jun 30, 01
    Purpose: 
 
-   This is the interface for live variable info of a method that is required 
+   This is the interface for live variable info of a function that is required 
    by any other part of the compiler
 
    It must be called like:
 
-       MethodLiveVarInfo MLVI( Mehtod *);  // initializes data structures
-       MLVI.analyze();                     // do the actural live variable anal
+       FunctionLiveVarInfo FLVI(Function *);  // initializes data structures
+       FLVI.analyze();                     // do the actural live variable anal
 
  After the analysis, getInSetOfBB or getOutSetofBB can be called to get 
  live var info of a BB.
 */
 
 
-#ifndef METH_LIVE_VAR_INFO_H
-#define METH_LIVE_VAR_INFO_H
+#ifndef FUNCTION_LIVE_VAR_INFO_H
+#define FUNCTION_LIVE_VAR_INFO_H
 
-// set DEBUG_LV for printing out debug messages
-// if DEBUG_LV is 1 normal output messages
-// if DEBUG_LV is 2 extensive debug info for each instr
-
-static const int DEBUG_LV = 0;
-
-#include "llvm/Analysis/LiveVar/BBLiveVar.h"
 #include "llvm/Pass.h"
+#include "llvm/CodeGen/ValueSet.h"
 
-class MethodLiveVarInfo : public MethodPass {
-
-  // Live var anal is done on this method - set by constructor
-  const Method *Meth;   
-
-  // A map betwn the BasicBlock and BBLiveVar
-  BBToBBLiveVarMapType BB2BBLVMap;  
+class BBLiveVar;
+class MachineInstr;
 
+class FunctionLiveVarInfo : public FunctionPass {
   // Machine Instr to LiveVarSet Map for providing LVset BEFORE each inst
-  MInstToLiveVarSetMapType MInst2LVSetBI; 
+  std::map<const MachineInstr *, const ValueSet *> MInst2LVSetBI; 
 
   // Machine Instr to LiveVarSet Map for providing LVset AFTER each inst
-  MInstToLiveVarSetMapType MInst2LVSetAI; 
+  std::map<const MachineInstr *, const ValueSet *> MInst2LVSetAI; 
 
+  // Stored Function that the data is computed with respect to
+  const Function *M;
 
   // --------- private methods -----------------------------------------
 
   // constructs BBLiveVars and init Def and In sets
-  void constructBBs();      
+  void constructBBs(const Function *F);
     
   // do one backward pass over the CFG
-  bool  doSingleBackwardPass(); 
+  bool doSingleBackwardPass(const Function *F, unsigned int iter); 
 
   // calculates live var sets for instructions in a BB
   void calcLiveVarSetsForBB(const BasicBlock *BB);
   
-
 public:
-  static AnalysisID ID;    // We are an analysis, we must have an ID
+  // --------- Implement the FunctionPass interface ----------------------
 
-  MethodLiveVarInfo(AnalysisID id = ID) : Meth(0) { assert(id == ID); }
-  ~MethodLiveVarInfo() { releaseMemory(); }
-
-  // --------- Implement the MethodPass interface ----------------------
-
-  // runOnMethod - Perform analysis, update internal data structures.
-  virtual bool runOnMethod(Method *M);
+  // runOnFunction - Perform analysis, update internal data structures.
+  virtual bool runOnFunction(Function &F);
 
   // releaseMemory - After LiveVariable analysis has been used, forget!
   virtual void releaseMemory();
 
-  // getAnalysisUsageInfo - Provide self!
-  virtual void getAnalysisUsageInfo(AnalysisSet &Required,
-                                    AnalysisSet &Destroyed,
-                                    AnalysisSet &Provided) {
-    Provided.push_back(ID);
+  // getAnalysisUsage - Provide self!
+  virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+    AU.setPreservesAll();
   }
 
   // --------- Functions to access analysis results -------------------
 
   // gets OutSet of a BB
-  inline const LiveVarSet *getOutSetOfBB( const BasicBlock *BB) const { 
-    return BB2BBLVMap.find(BB)->second->getOutSet();
-  }
+  const ValueSet &getOutSetOfBB(const BasicBlock *BB) const;
 
   // gets InSet of a BB
-  inline const LiveVarSet *getInSetOfBB( const BasicBlock *BB)  const { 
-    return BB2BBLVMap.find(BB)->second->getInSet();
-  }
+  const ValueSet &getInSetOfBB(const BasicBlock *BB) const;
 
   // gets the Live var set BEFORE an instruction
-  const LiveVarSet * getLiveVarSetBeforeMInst(const MachineInstr *Inst,
-                                             const BasicBlock *CurBB);
+  const ValueSet &getLiveVarSetBeforeMInst(const MachineInstr *MI,
+                                           const BasicBlock *BB);
 
   // gets the Live var set AFTER an instruction
-  const LiveVarSet * getLiveVarSetAfterMInst(const MachineInstr *MInst,
-                                            const BasicBlock *CurBB);
+  const ValueSet &getLiveVarSetAfterMInst(const MachineInstr *MI,
+                                          const BasicBlock *BB);
 };
 
 #endif