1 //===-- BBLiveVar.h - Live Variable Analysis for a BasicBlock ----*- C++ -*--=//
3 // This is a BasicBlock annotation class that is used by live var analysis to
4 // hold data flow information for a basic block.
6 //===----------------------------------------------------------------------===//
11 #include "llvm/Analysis/LiveVar/ValueSet.h"
12 #include "Support/Annotation.h"
16 class MachineBasicBlock;
18 enum LiveVarDebugLevel_t {
25 extern LiveVarDebugLevel_t DEBUG_LV;
27 class BBLiveVar : public Annotation {
28 const BasicBlock &BB; // pointer to BasicBlock
29 MachineBasicBlock &MBB; // Pointer to MachineBasicBlock
30 unsigned POID; // Post-Order ID
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
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;
41 // method to propagate an InSet to OutSet of a predecessor
42 bool setPropagate(ValueSet *OutSetOfPred,
43 const ValueSet *InSetOfThisBB,
44 const BasicBlock *PredBB);
46 // To add an operand which is a def
47 void addDef(const Value *Op);
49 // To add an operand which is a use
50 void addUse(const Value *Op);
52 void calcDefUseSets(); // calculates the Def & Use sets for this BB
54 BBLiveVar(const BasicBlock &BB, MachineBasicBlock &MBB, unsigned POID);
55 ~BBLiveVar() {} // make dtor private
57 static BBLiveVar *CreateOnBB(const BasicBlock &BB, MachineBasicBlock &MBB,
59 static BBLiveVar *GetFromBB(const BasicBlock &BB);
60 static void RemoveFromBB(const BasicBlock &BB);
62 inline bool isInSetChanged() const { return InSetChanged; }
63 inline bool isOutSetChanged() const { return OutSetChanged; }
65 MachineBasicBlock &getMachineBasicBlock() const { return MBB; }
67 inline unsigned getPOId() const { return POID; }
69 bool applyTransferFunc(); // calcultes the In in terms of Out
71 // calculates Out set using In sets of the predecessors
74 inline const ValueSet &getOutSet() const { return OutSet; }
75 inline const ValueSet &getInSet() const { return InSet; }
77 void printAllSets() const; // for printing Def/In/Out sets
78 void printInOutSets() const; // for printing In/Out sets