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