Move the DEBUG_LV option out of the public header file into a private header.
[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 BasicBlock;
15 class Value;
16
17 enum LiveVarDebugLevel_t {
18   LV_DEBUG_None,
19   LV_DEBUG_Normal,
20   LV_DEBUG_Instr,
21   LV_DEBUG_Verbose
22 };
23
24 extern LiveVarDebugLevel_t DEBUG_LV;
25
26 class BBLiveVar : public Annotation {
27   const BasicBlock *BB;         // pointer to BasicBlock
28   unsigned POID;                // Post-Order ID
29
30   ValueSet DefSet;              // Def set (with no preceding uses) for LV analysis
31   ValueSet InSet, OutSet;       // In & Out for LV analysis
32   bool InSetChanged, OutSetChanged;   // set if the InSet/OutSet is modified
33
34                                 // map that contains PredBB -> Phi arguments
35                                 // coming in on that edge.  such uses have to be
36                                 // treated differently from ordinary uses.
37   std::map<const BasicBlock *, ValueSet> PredToEdgeInSetMap;
38   
39   // method to propogate an InSet to OutSet of a predecessor
40   bool setPropagate(ValueSet *OutSetOfPred, 
41                     const ValueSet *InSetOfThisBB,
42                     const BasicBlock *PredBB);
43
44   // To add an operand which is a def
45   void addDef(const Value *Op); 
46
47   // To add an operand which is a use
48   void addUse(const Value *Op);
49
50   void calcDefUseSets();         // calculates the Def & Use sets for this BB
51
52   BBLiveVar(const BasicBlock *BB, unsigned POID);
53   ~BBLiveVar() {}                // make dtor private
54  public:
55   static BBLiveVar *CreateOnBB(const BasicBlock *BB, unsigned POID);
56   static BBLiveVar *GetFromBB(const BasicBlock *BB);
57   static void RemoveFromBB(const BasicBlock *BB);
58
59   inline bool isInSetChanged() const  { return InSetChanged; }    
60   inline bool isOutSetChanged() const { return OutSetChanged; }
61
62   inline unsigned getPOId() const { return POID; }
63
64   bool applyTransferFunc();      // calcultes the In in terms of Out 
65
66   // calculates Out set using In sets of the predecessors
67   bool applyFlowFunc();
68
69   inline const ValueSet &getOutSet() const { return OutSet; }
70   inline const ValueSet  &getInSet() const { return InSet; }
71
72   void printAllSets() const;      // for printing Def/In/Out sets
73   void printInOutSets() const;    // for printing In/Out sets
74 };
75
76 #endif