1 /* Title: BBLiveVar.h -*- C++ -*-
2 Author: Ruchira Sasanka
4 Purpose: This is a wrapper class for BasicBlock which is used by live
11 #include "LiveVarSet.h"
12 #include "LiveVarMap.h"
16 const BasicBlock* BaseBB; // pointer to BasicBlock
17 unsigned POId; // Post-Order ID
19 LiveVarSet DefSet; // Def set for LV analysis
20 LiveVarSet InSet, OutSet; // In & Out for LV analysis
21 bool InSetChanged, OutSetChanged; // set if the InSet/OutSet is modified
23 // map that contains phi args->BB they came
24 // set by calcDefUseSets & used by setPropagate
25 std::hash_map<const Value *, const BasicBlock *> PhiArgMap;
27 // method to propogate an InSet to OutSet of a predecessor
28 bool setPropagate( LiveVarSet *OutSetOfPred,
29 const LiveVarSet *InSetOfThisBB,
30 const BasicBlock *PredBB);
32 // To add an operand which is a def
33 void addDef(const Value *Op);
35 // To add an operand which is a use
36 void addUse(const Value *Op);
39 BBLiveVar(const BasicBlock* baseBB, unsigned POId);
41 inline bool isInSetChanged() const { return InSetChanged; }
42 inline bool isOutSetChanged() const { return OutSetChanged; }
44 inline unsigned getPOId() const { return POId; }
46 void calcDefUseSets() ; // calculates the Def & Use sets for this BB
47 bool applyTransferFunc(); // calcultes the In in terms of Out
49 // calculates Out set using In sets of the predecessors
50 bool applyFlowFunc(BBToBBLiveVarMapType LVMap);
52 inline const LiveVarSet* getOutSet() const { return &OutSet; }
53 inline const LiveVarSet* getInSet() const { return &InSet; }
55 void printAllSets() const; // for printing Def/In/Out sets
56 void printInOutSets() const; // for printing In/Out sets