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