2002-02-05 00:33:19 +00:00
|
|
|
//===-- BBLiveVar.h - Live Variable Analysis for a BasicBlock ----*- C++ -*--=//
|
|
|
|
//
|
2002-02-05 06:52:25 +00:00
|
|
|
// This is a BasicBlock annotation class that is used by live var analysis to
|
|
|
|
// hold data flow information for a basic block.
|
2002-02-05 00:33:19 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2001-07-24 17:14:13 +00:00
|
|
|
|
|
|
|
#ifndef LIVE_VAR_BB_H
|
|
|
|
#define LIVE_VAR_BB_H
|
|
|
|
|
2002-02-05 02:51:01 +00:00
|
|
|
#include "llvm/Analysis/LiveVar/ValueSet.h"
|
2002-02-05 06:52:25 +00:00
|
|
|
#include "llvm/Annotation.h"
|
2002-02-05 00:33:19 +00:00
|
|
|
#include <map>
|
|
|
|
class BasicBlock;
|
|
|
|
class Value;
|
2001-07-24 17:14:13 +00:00
|
|
|
|
2002-05-22 17:07:26 +00:00
|
|
|
enum LiveVarDebugLevel_t {
|
|
|
|
LV_DEBUG_None,
|
|
|
|
LV_DEBUG_Normal,
|
|
|
|
LV_DEBUG_Instr,
|
|
|
|
LV_DEBUG_Verbose
|
|
|
|
};
|
|
|
|
|
|
|
|
extern LiveVarDebugLevel_t DEBUG_LV;
|
|
|
|
|
2002-02-05 06:52:25 +00:00
|
|
|
class BBLiveVar : public Annotation {
|
2002-06-25 16:12:52 +00:00
|
|
|
const BasicBlock &BB; // pointer to BasicBlock
|
2002-02-05 00:33:19 +00:00
|
|
|
unsigned POID; // Post-Order ID
|
2001-07-24 17:14:13 +00:00
|
|
|
|
2002-03-18 03:47:26 +00:00
|
|
|
ValueSet DefSet; // Def set (with no preceding uses) for LV analysis
|
2002-02-05 06:52:25 +00:00
|
|
|
ValueSet InSet, OutSet; // In & Out for LV analysis
|
2001-07-24 17:14:13 +00:00
|
|
|
bool InSetChanged, OutSetChanged; // set if the InSet/OutSet is modified
|
|
|
|
|
2002-03-18 03:47:26 +00:00
|
|
|
// 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;
|
|
|
|
|
2001-08-20 21:11:01 +00:00
|
|
|
// method to propogate an InSet to OutSet of a predecessor
|
2002-02-05 02:51:01 +00:00
|
|
|
bool setPropagate(ValueSet *OutSetOfPred,
|
|
|
|
const ValueSet *InSetOfThisBB,
|
2002-02-05 00:33:19 +00:00
|
|
|
const BasicBlock *PredBB);
|
2001-07-24 17:14:13 +00:00
|
|
|
|
2001-10-12 17:46:27 +00:00
|
|
|
// To add an operand which is a def
|
2002-02-05 04:20:12 +00:00
|
|
|
void addDef(const Value *Op);
|
2001-10-12 17:46:27 +00:00
|
|
|
|
|
|
|
// To add an operand which is a use
|
2002-02-05 04:20:12 +00:00
|
|
|
void addUse(const Value *Op);
|
2001-10-12 17:46:27 +00:00
|
|
|
|
2002-02-05 04:20:12 +00:00
|
|
|
void calcDefUseSets(); // calculates the Def & Use sets for this BB
|
2002-02-05 06:52:25 +00:00
|
|
|
|
2002-06-25 16:12:52 +00:00
|
|
|
BBLiveVar(const BasicBlock &BB, unsigned POID);
|
2002-02-05 06:52:25 +00:00
|
|
|
~BBLiveVar() {} // make dtor private
|
|
|
|
public:
|
2002-06-25 16:12:52 +00:00
|
|
|
static BBLiveVar *CreateOnBB(const BasicBlock &BB, unsigned POID);
|
|
|
|
static BBLiveVar *GetFromBB(const BasicBlock &BB);
|
|
|
|
static void RemoveFromBB(const BasicBlock &BB);
|
2001-07-24 17:14:13 +00:00
|
|
|
|
2002-02-05 00:33:19 +00:00
|
|
|
inline bool isInSetChanged() const { return InSetChanged; }
|
2001-07-24 17:14:13 +00:00
|
|
|
inline bool isOutSetChanged() const { return OutSetChanged; }
|
|
|
|
|
2002-02-05 00:33:19 +00:00
|
|
|
inline unsigned getPOId() const { return POID; }
|
2001-07-24 17:14:13 +00:00
|
|
|
|
2002-02-05 00:33:19 +00:00
|
|
|
bool applyTransferFunc(); // calcultes the In in terms of Out
|
2001-07-24 17:14:13 +00:00
|
|
|
|
2001-08-20 21:11:01 +00:00
|
|
|
// calculates Out set using In sets of the predecessors
|
2002-02-05 06:52:25 +00:00
|
|
|
bool applyFlowFunc();
|
2001-07-24 17:14:13 +00:00
|
|
|
|
2002-02-05 04:20:12 +00:00
|
|
|
inline const ValueSet &getOutSet() const { return OutSet; }
|
|
|
|
inline const ValueSet &getInSet() const { return InSet; }
|
2001-07-24 17:14:13 +00:00
|
|
|
|
2001-08-20 21:11:01 +00:00
|
|
|
void printAllSets() const; // for printing Def/In/Out sets
|
|
|
|
void printInOutSets() const; // for printing In/Out sets
|
2001-07-24 17:14:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|