1 //===-- BBLiveVar.h - Live Variable Analysis for a BasicBlock ----*- C++ -*--=//
3 // This is a wrapper class for BasicBlock which is used by live var analysis.
5 //===----------------------------------------------------------------------===//
10 #include "llvm/Analysis/LiveVar/ValueSet.h"
17 const BasicBlock *BB; // pointer to BasicBlock
18 unsigned POID; // Post-Order ID
20 ValueSet DefSet; // Def set for LV analysis
21 ValueSet InSet, OutSet; // In & Out for LV analysis
22 bool InSetChanged, OutSetChanged; // set if the InSet/OutSet is modified
24 // map that contains phi args->BB they came
25 // set by calcDefUseSets & used by setPropagate
26 std::map<const Value *, const BasicBlock *> PhiArgMap;
28 // method to propogate an InSet to OutSet of a predecessor
29 bool setPropagate(ValueSet *OutSetOfPred,
30 const ValueSet *InSetOfThisBB,
31 const BasicBlock *PredBB);
33 // To add an operand which is a def
34 void addDef(const Value *Op);
36 // To add an operand which is a use
37 void addUse(const Value *Op);
39 void calcDefUseSets(); // calculates the Def & Use sets for this BB
41 BBLiveVar(const BasicBlock *BB, unsigned POID);
43 inline bool isInSetChanged() const { return InSetChanged; }
44 inline bool isOutSetChanged() const { return OutSetChanged; }
46 inline unsigned getPOId() const { return POID; }
48 bool applyTransferFunc(); // calcultes the In in terms of Out
50 // calculates Out set using In sets of the predecessors
51 bool applyFlowFunc(std::map<const BasicBlock *, BBLiveVar *> &LVMap);
53 inline const ValueSet &getOutSet() const { return OutSet; }
54 inline const ValueSet &getInSet() const { return InSet; }
56 void printAllSets() const; // for printing Def/In/Out sets
57 void printInOutSets() const; // for printing In/Out sets