1 //===-- BBLiveVar.h - Live Variable Analysis for a BasicBlock ---*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This is a BasicBlock annotation class that is used by live var analysis to
11 // hold data flow information for a basic block.
13 //===----------------------------------------------------------------------===//
18 #include "llvm/CodeGen/ValueSet.h"
19 #include "llvm/ADT/hash_map"
25 class MachineBasicBlock;
27 enum LiveVarDebugLevel_t {
34 extern LiveVarDebugLevel_t DEBUG_LV;
37 const BasicBlock &BB; // pointer to BasicBlock
38 const MachineBasicBlock &MBB; // Pointer to MachineBasicBlock
39 unsigned POID; // Post-Order ID
41 ValueSet DefSet; // Def set (with no preceding uses) for LV analysis
42 ValueSet InSet, OutSet; // In & Out for LV analysis
43 bool InSetChanged, OutSetChanged; // set if the InSet/OutSet is modified
45 // map that contains PredBB -> Phi arguments
46 // coming in on that edge. such uses have to be
47 // treated differently from ordinary uses.
48 hash_map<const BasicBlock *, ValueSet> PredToEdgeInSetMap;
50 // method to propagate an InSet to OutSet of a predecessor
51 bool setPropagate(ValueSet *OutSetOfPred,
52 const ValueSet *InSetOfThisBB,
53 const BasicBlock *PredBB);
55 // To add an operand which is a def
56 void addDef(const Value *Op);
58 // To add an operand which is a use
59 void addUse(const Value *Op);
61 void calcDefUseSets(); // calculates the Def & Use sets for this BB
64 BBLiveVar(const BasicBlock &BB, const MachineBasicBlock &MBB, unsigned POID);
66 inline bool isInSetChanged() const { return InSetChanged; }
67 inline bool isOutSetChanged() const { return OutSetChanged; }
69 const MachineBasicBlock &getMachineBasicBlock() const { return MBB; }
71 inline unsigned getPOId() const { return POID; }
73 bool applyTransferFunc(); // calcultes the In in terms of Out
75 // calculates Out set using In sets of the predecessors
76 bool applyFlowFunc(hash_map<const BasicBlock*, BBLiveVar*> &BBLiveVarInfo);
78 inline const ValueSet &getOutSet() const { return OutSet; }
79 inline ValueSet &getOutSet() { return OutSet; }
81 inline const ValueSet &getInSet() const { return InSet; }
82 inline ValueSet &getInSet() { return InSet; }
84 void printAllSets() const; // for printing Def/In/Out sets
85 void printInOutSets() const; // for printing In/Out sets
88 } // End llvm namespace