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"
14 #include "llvm/BasicBlock.h"
15 #include "llvm/Instruction.h"
16 #include "llvm/Type.h"
17 #include "llvm/iOther.h"
22 const BasicBlock* BaseBB; // pointer to BasicBlock
23 unsigned int POId; // Post-Order ID
25 LiveVarSet DefSet; // Def set for LV analysis
26 LiveVarSet InSet, OutSet; // In & Out for LV analysis
27 bool InSetChanged, OutSetChanged; // set if the InSet/OutSet is modified
29 // map that contains phi args->BB they came
30 // set by calcDefUseSets & used by setPropagate
31 hash_map<const Value *, const BasicBlock *, hashFuncValue> PhiArgMap;
33 // method to propogate an InSet to OutSet of a predecessor
34 bool setPropagate( LiveVarSet *const OutSetOfPred,
35 const LiveVarSet *const InSetOfThisBB,
36 const BasicBlock *const PredBB);
38 // To add an operand which is a def
39 void addDef(const Value *Op);
41 // To add an operand which is a use
42 void addUse(const Value *Op);
46 BBLiveVar( const BasicBlock* baseBB, unsigned int POId);
48 inline bool isInSetChanged() const { return InSetChanged; }
49 inline bool isOutSetChanged() const { return OutSetChanged; }
51 inline unsigned int getPOId() const { return POId; }
53 void calcDefUseSets() ; // calculates the Def & Use sets for this BB
54 bool applyTransferFunc(); // calcultes the In in terms of Out
56 // calculates Out set using In sets of the predecessors
57 bool applyFlowFunc(BBToBBLiveVarMapType LVMap);
59 inline const LiveVarSet* getOutSet() const { return &OutSet; }
60 inline const LiveVarSet* getInSet() const { return &InSet; }
62 void printAllSets() const; // for printing Def/In/Out sets
63 void printInOutSets() const; // for printing In/Out sets
65 ~BBLiveVar() { } // nothing to do since only composite objects