Minor change: Methods that return ValueSet's that are guaranteed to be valid
[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/ValueSet.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   ValueSet DefSet;            // Def set for LV analysis
21   ValueSet 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(ValueSet *OutSetOfPred, 
30                     const ValueSet *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   void calcDefUseSets();         // calculates the Def & Use sets for this BB
40  public:
41   BBLiveVar(const BasicBlock *BB, unsigned POID);
42
43   inline bool isInSetChanged() const  { return InSetChanged; }    
44   inline bool isOutSetChanged() const { return OutSetChanged; }
45
46   inline unsigned getPOId() const { return POID; }
47
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 ValueSet &getOutSet() const { return OutSet; }
54   inline const ValueSet  &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