-/* Title: BBLiveVar.h -*- C++ -*-
- Author: Ruchira Sasanka
- Date: Jun 30, 01
- Purpose: This is a wrapper class for BasicBlock which is used by live
- variable anaysis.
-*/
+//===-- BBLiveVar.h - Live Variable Analysis for a BasicBlock ----*- C++ -*--=//
+//
+// This is a BasicBlock annotation class that is used by live var analysis to
+// hold data flow information for a basic block.
+//
+//===----------------------------------------------------------------------===//
#ifndef LIVE_VAR_BB_H
#define LIVE_VAR_BB_H
-#include "LiveVarSet.h"
-#include "LiveVarMap.h"
-
-#include "llvm/BasicBlock.h"
-#include "llvm/Instruction.h"
-#include "llvm/Type.h"
-#include "llvm/iOther.h"
+#include "llvm/Analysis/LiveVar/ValueSet.h"
+#include "llvm/Annotation.h"
+#include <map>
+class BasicBlock;
+class Value;
+class MachineBasicBlock;
+
+enum LiveVarDebugLevel_t {
+ LV_DEBUG_None,
+ LV_DEBUG_Normal,
+ LV_DEBUG_Instr,
+ LV_DEBUG_Verbose
+};
+extern LiveVarDebugLevel_t DEBUG_LV;
-class BBLiveVar
-{
- const BasicBlock* BaseBB; // pointer to BasicBlock
- unsigned int POId; // Post-Order ID
+class BBLiveVar : public Annotation {
+ const BasicBlock &BB; // pointer to BasicBlock
+ MachineBasicBlock &MBB; // Pointer to MachineBasicBlock
+ unsigned POID; // Post-Order ID
- LiveVarSet DefSet; // Def set for LV analysis
- LiveVarSet InSet, OutSet; // In & Out for LV analysis
+ ValueSet DefSet; // Def set (with no preceding uses) for LV analysis
+ ValueSet InSet, OutSet; // In & Out for LV analysis
bool InSetChanged, OutSetChanged; // set if the InSet/OutSet is modified
- // map that contains phi args->BB they came
- // set by calcDefUseSets & used by setPropagate
- hash_map<const Value *, const BasicBlock *, hashFuncValue> PhiArgMap;
-
+ // map that contains PredBB -> Phi arguments
+ // coming in on that edge. such uses have to be
+ // treated differently from ordinary uses.
+ std::map<const BasicBlock *, ValueSet> PredToEdgeInSetMap;
+
// method to propogate an InSet to OutSet of a predecessor
- bool setPropagate( LiveVarSet *const OutSetOfPred,
- const LiveVarSet *const InSetOfThisBB,
- const BasicBlock *const PredBB);
+ bool setPropagate(ValueSet *OutSetOfPred,
+ const ValueSet *InSetOfThisBB,
+ const BasicBlock *PredBB);
// To add an operand which is a def
- void addDef(const Value *Op);
+ void addDef(const Value *Op);
// To add an operand which is a use
- void addUse(const Value *Op);
+ void addUse(const Value *Op);
- public:
+ void calcDefUseSets(); // calculates the Def & Use sets for this BB
- BBLiveVar( const BasicBlock* baseBB, unsigned int POId);
+ BBLiveVar(const BasicBlock &BB, MachineBasicBlock &MBB, unsigned POID);
+ ~BBLiveVar() {} // make dtor private
+ public:
+ static BBLiveVar *CreateOnBB(const BasicBlock &BB, MachineBasicBlock &MBB,
+ unsigned POID);
+ static BBLiveVar *GetFromBB(const BasicBlock &BB);
+ static void RemoveFromBB(const BasicBlock &BB);
- inline bool isInSetChanged() const { return InSetChanged; }
+ inline bool isInSetChanged() const { return InSetChanged; }
inline bool isOutSetChanged() const { return OutSetChanged; }
- inline unsigned int getPOId() const { return POId; }
+ MachineBasicBlock &getMachineBasicBlock() const { return MBB; }
- void calcDefUseSets() ; // calculates the Def & Use sets for this BB
- bool applyTransferFunc(); // calcultes the In in terms of Out
+ inline unsigned getPOId() const { return POID; }
+
+ bool applyTransferFunc(); // calcultes the In in terms of Out
// calculates Out set using In sets of the predecessors
- bool applyFlowFunc(BBToBBLiveVarMapType LVMap);
+ bool applyFlowFunc();
- inline const LiveVarSet* getOutSet() const { return &OutSet; }
- inline const LiveVarSet* getInSet() const { return &InSet; }
+ inline const ValueSet &getOutSet() const { return OutSet; }
+ inline const ValueSet &getInSet() const { return InSet; }
void printAllSets() const; // for printing Def/In/Out sets
void printInOutSets() const; // for printing In/Out sets
-
- ~BBLiveVar() { } // nothing to do since only composite objects
-
-
-
};
-
-
-
-
-
-
#endif
-