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 "Support/hash_map"
22 class MachineBasicBlock;
24 enum LiveVarDebugLevel_t {
31 extern LiveVarDebugLevel_t DEBUG_LV;
34 const BasicBlock &BB; // pointer to BasicBlock
35 MachineBasicBlock &MBB; // Pointer to MachineBasicBlock
36 unsigned POID; // Post-Order ID
38 ValueSet DefSet; // Def set (with no preceding uses) for LV analysis
39 ValueSet InSet, OutSet; // In & Out for LV analysis
40 bool InSetChanged, OutSetChanged; // set if the InSet/OutSet is modified
42 // map that contains PredBB -> Phi arguments
43 // coming in on that edge. such uses have to be
44 // treated differently from ordinary uses.
45 hash_map<const BasicBlock *, ValueSet> PredToEdgeInSetMap;
47 // method to propagate an InSet to OutSet of a predecessor
48 bool setPropagate(ValueSet *OutSetOfPred,
49 const ValueSet *InSetOfThisBB,
50 const BasicBlock *PredBB);
52 // To add an operand which is a def
53 void addDef(const Value *Op);
55 // To add an operand which is a use
56 void addUse(const Value *Op);
58 void calcDefUseSets(); // calculates the Def & Use sets for this BB
61 BBLiveVar(const BasicBlock &BB, MachineBasicBlock &MBB, unsigned POID);
63 inline bool isInSetChanged() const { return InSetChanged; }
64 inline bool isOutSetChanged() const { return OutSetChanged; }
66 MachineBasicBlock &getMachineBasicBlock() const { return MBB; }
68 inline unsigned getPOId() const { return POID; }
70 bool applyTransferFunc(); // calcultes the In in terms of Out
72 // calculates Out set using In sets of the predecessors
73 bool applyFlowFunc(hash_map<const BasicBlock*, BBLiveVar*> &BBLiveVarInfo);
75 inline const ValueSet &getOutSet() const { return OutSet; }
76 inline ValueSet &getOutSet() { return OutSet; }
78 inline const ValueSet &getInSet() const { return InSet; }
79 inline ValueSet &getInSet() { return InSet; }
81 void printAllSets() const; // for printing Def/In/Out sets
82 void printInOutSets() const; // for printing In/Out sets