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/CodeGen/ValueSet.h"
12 #include "Support/hash_map"
15 class MachineBasicBlock;
17 enum LiveVarDebugLevel_t {
24 extern LiveVarDebugLevel_t DEBUG_LV;
27 const BasicBlock &BB; // pointer to BasicBlock
28 MachineBasicBlock &MBB; // Pointer to MachineBasicBlock
29 unsigned POID; // Post-Order ID
31 ValueSet DefSet; // Def set (with no preceding uses) for LV analysis
32 ValueSet InSet, OutSet; // In & Out for LV analysis
33 bool InSetChanged, OutSetChanged; // set if the InSet/OutSet is modified
35 // map that contains PredBB -> Phi arguments
36 // coming in on that edge. such uses have to be
37 // treated differently from ordinary uses.
38 hash_map<const BasicBlock *, ValueSet> PredToEdgeInSetMap;
40 // method to propagate an InSet to OutSet of a predecessor
41 bool setPropagate(ValueSet *OutSetOfPred,
42 const ValueSet *InSetOfThisBB,
43 const BasicBlock *PredBB);
45 // To add an operand which is a def
46 void addDef(const Value *Op);
48 // To add an operand which is a use
49 void addUse(const Value *Op);
51 void calcDefUseSets(); // calculates the Def & Use sets for this BB
54 BBLiveVar(const BasicBlock &BB, MachineBasicBlock &MBB, unsigned POID);
56 inline bool isInSetChanged() const { return InSetChanged; }
57 inline bool isOutSetChanged() const { return OutSetChanged; }
59 MachineBasicBlock &getMachineBasicBlock() const { return MBB; }
61 inline unsigned getPOId() const { return POID; }
63 bool applyTransferFunc(); // calcultes the In in terms of Out
65 // calculates Out set using In sets of the predecessors
66 bool applyFlowFunc(hash_map<const BasicBlock*, BBLiveVar*> &BBLiveVarInfo);
68 inline const ValueSet &getOutSet() const { return OutSet; }
69 inline ValueSet &getOutSet() { return OutSet; }
71 inline const ValueSet &getInSet() const { return InSet; }
72 inline ValueSet &getInSet() { return InSet; }
74 void printAllSets() const; // for printing Def/In/Out sets
75 void printInOutSets() const; // for printing In/Out sets