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/LiveVarSet.h"
17 const BasicBlock *BB; // pointer to BasicBlock
18 unsigned POID; // Post-Order ID
20 LiveVarSet DefSet; // Def set for LV analysis
21 LiveVarSet 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(LiveVarSet *OutSetOfPred,
30 const LiveVarSet *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);
40 BBLiveVar(const BasicBlock *BB, unsigned POID);
42 inline bool isInSetChanged() const { return InSetChanged; }
43 inline bool isOutSetChanged() const { return OutSetChanged; }
45 inline unsigned getPOId() const { return POID; }
47 void calcDefUseSets(); // calculates the Def & Use sets for this BB
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 LiveVarSet *getOutSet() const { return &OutSet; }
54 inline const LiveVarSet *getInSet() const { return &InSet; }
56 void printAllSets() const; // for printing Def/In/Out sets
57 void printInOutSets() const; // for printing In/Out sets