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