Cut down include pollution and number of frivolous consts.
[oota-llvm.git] / lib / Analysis / LiveVar / BBLiveVar.h
1 /* Title:   BBLiveVar.h                  -*- C++ -*-
2    Author:  Ruchira Sasanka
3    Date:    Jun 30, 01
4    Purpose: This is a wrapper class for BasicBlock which is used by live 
5             variable anaysis.
6 */
7
8 #ifndef LIVE_VAR_BB_H
9 #define LIVE_VAR_BB_H
10
11 #include "LiveVarSet.h"
12 #include "LiveVarMap.h"
13 class Method;
14
15 class BBLiveVar {
16   const BasicBlock* BaseBB;     // pointer to BasicBlock
17   unsigned POId;                // Post-Order ID
18
19   LiveVarSet DefSet;            // Def set for LV analysis
20   LiveVarSet InSet, OutSet;     // In & Out for LV analysis
21   bool InSetChanged, OutSetChanged;   // set if the InSet/OutSet is modified
22
23                                 // map that contains phi args->BB they came
24                                 // set by calcDefUseSets & used by setPropagate
25   std::hash_map<const Value *, const BasicBlock *> PhiArgMap;  
26
27   // method to propogate an InSet to OutSet of a predecessor
28   bool setPropagate( LiveVarSet *OutSetOfPred, 
29                      const LiveVarSet *InSetOfThisBB,
30                      const BasicBlock *PredBB);
31
32   // To add an operand which is a def
33   void  addDef(const Value *Op); 
34
35   // To add an operand which is a use
36   void  addUse(const Value *Op);
37
38  public:
39   BBLiveVar(const BasicBlock* baseBB, unsigned POId);
40
41   inline bool isInSetChanged() const { return InSetChanged; }    
42   inline bool isOutSetChanged() const { return OutSetChanged; }
43
44   inline unsigned getPOId() const { return POId; }
45
46   void calcDefUseSets() ;         // calculates the Def & Use sets for this BB
47   bool  applyTransferFunc();      // calcultes the In in terms of Out 
48
49   // calculates Out set using In sets of the predecessors
50   bool applyFlowFunc(BBToBBLiveVarMapType LVMap);    
51
52   inline const LiveVarSet* getOutSet()  const { return &OutSet; }
53   inline const LiveVarSet*  getInSet() const { return &InSet; }
54
55   void printAllSets() const;      // for printing Def/In/Out sets
56   void printInOutSets() const;    // for printing In/Out sets
57 };
58
59 #endif
60