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 "llvm/Annotation.h"
17 class BBLiveVar : public Annotation {
18 const BasicBlock *BB; // pointer to BasicBlock
19 unsigned POID; // Post-Order ID
21 ValueSet DefSet; // Def set (with no preceding uses) for LV analysis
22 ValueSet InSet, OutSet; // In & Out for LV analysis
23 bool InSetChanged, OutSetChanged; // set if the InSet/OutSet is modified
25 // map that contains PredBB -> Phi arguments
26 // coming in on that edge. such uses have to be
27 // treated differently from ordinary uses.
28 std::map<const BasicBlock *, ValueSet> PredToEdgeInSetMap;
30 // method to propogate an InSet to OutSet of a predecessor
31 bool setPropagate(ValueSet *OutSetOfPred,
32 const ValueSet *InSetOfThisBB,
33 const BasicBlock *PredBB);
35 // To add an operand which is a def
36 void addDef(const Value *Op);
38 // To add an operand which is a use
39 void addUse(const Value *Op);
41 void calcDefUseSets(); // calculates the Def & Use sets for this BB
43 BBLiveVar(const BasicBlock *BB, unsigned POID);
44 ~BBLiveVar() {} // make dtor private
46 static BBLiveVar *CreateOnBB(const BasicBlock *BB, unsigned POID);
47 static BBLiveVar *GetFromBB(const BasicBlock *BB);
48 static void RemoveFromBB(const BasicBlock *BB);
50 inline bool isInSetChanged() const { return InSetChanged; }
51 inline bool isOutSetChanged() const { return OutSetChanged; }
53 inline unsigned getPOId() const { return POID; }
55 bool applyTransferFunc(); // calcultes the In in terms of Out
57 // calculates Out set using In sets of the predecessors
60 inline const ValueSet &getOutSet() const { return OutSet; }
61 inline const ValueSet &getInSet() const { return InSet; }
63 void printAllSets() const; // for printing Def/In/Out sets
64 void printInOutSets() const; // for printing In/Out sets