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>
|
2002-02-04 16:31:03 +00:00
|
|
|
class Method;
|
2002-02-05 00:33:19 +00:00
|
|
|
class BasicBlock;
|
|
|
|
class Value;
|
2001-07-24 17:14:13 +00:00
|
|
|
|
2002-02-05 06:52:25 +00:00
|
|
|
class BBLiveVar : public Annotation {
|
2002-02-05 00:33:19 +00:00
|
|
|
const BasicBlock *BB; // pointer to BasicBlock
|
|
|
|
unsigned POID; // Post-Order ID
|
2001-07-24 17:14:13 +00:00
|
|
|
|
2002-02-05 06:52:25 +00:00
|
|
|
ValueSet DefSet; // Def set for LV analysis
|
|
|
|
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
|
|
|
|
|
|
|
|
// map that contains phi args->BB they came
|
2001-08-20 21:11:01 +00:00
|
|
|
// set by calcDefUseSets & used by setPropagate
|
2002-02-05 00:33:19 +00:00
|
|
|
std::map<const Value *, const BasicBlock *> PhiArgMap;
|
2001-07-24 17:14:13 +00:00
|
|
|
|
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-02-05 00:33:19 +00:00
|
|
|
BBLiveVar(const BasicBlock *BB, unsigned POID);
|
2002-02-05 06:52:25 +00:00
|
|
|
~BBLiveVar() {} // make dtor private
|
|
|
|
public:
|
|
|
|
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
|