Convert this code from using annotations to using a local map
[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/CodeGen/ValueSet.h"
12 #include "Support/hash_map"
13 class BasicBlock;
14 class Value;
15 class MachineBasicBlock;
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 {
27   const BasicBlock &BB;         // pointer to BasicBlock
28   MachineBasicBlock &MBB;       // Pointer to MachineBasicBlock
29   unsigned POID;                // Post-Order ID
30
31   ValueSet DefSet;           // Def set (with no preceding uses) for LV analysis
32   ValueSet InSet, OutSet;       // In & Out for LV analysis
33   bool InSetChanged, OutSetChanged;   // set if the InSet/OutSet is modified
34
35                                 // map that contains PredBB -> Phi arguments
36                                 // coming in on that edge.  such uses have to be
37                                 // treated differently from ordinary uses.
38   hash_map<const BasicBlock *, ValueSet> PredToEdgeInSetMap;
39   
40   // method to propagate an InSet to OutSet of a predecessor
41   bool setPropagate(ValueSet *OutSetOfPred, 
42                     const ValueSet *InSetOfThisBB,
43                     const BasicBlock *PredBB);
44
45   // To add an operand which is a def
46   void addDef(const Value *Op); 
47
48   // To add an operand which is a use
49   void addUse(const Value *Op);
50
51   void calcDefUseSets();         // calculates the Def & Use sets for this BB
52 public:
53
54   BBLiveVar(const BasicBlock &BB, MachineBasicBlock &MBB, unsigned POID);
55
56   inline bool isInSetChanged() const  { return InSetChanged; }    
57   inline bool isOutSetChanged() const { return OutSetChanged; }
58
59   MachineBasicBlock &getMachineBasicBlock() const { return MBB; }
60
61   inline unsigned getPOId() const { return POID; }
62
63   bool applyTransferFunc();      // calcultes the In in terms of Out 
64
65   // calculates Out set using In sets of the predecessors
66   bool applyFlowFunc(hash_map<const BasicBlock*, BBLiveVar*> &BBLiveVarInfo);
67
68   inline const ValueSet &getOutSet() const { return OutSet; }
69   inline       ValueSet &getOutSet()       { return OutSet; }
70
71   inline const ValueSet  &getInSet() const { return InSet; }
72   inline       ValueSet  &getInSet()       { return InSet; }
73
74   void printAllSets() const;      // for printing Def/In/Out sets
75   void printInOutSets() const;    // for printing In/Out sets
76 };
77
78 #endif