2002-02-05 00:33:19 +00:00
|
|
|
//===-- BBLiveVar.h - Live Variable Analysis for a BasicBlock ----*- C++ -*--=//
|
|
|
|
//
|
|
|
|
// This is a wrapper class for BasicBlock which is used by live var analysis.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2001-07-24 17:14:13 +00:00
|
|
|
|
|
|
|
#ifndef LIVE_VAR_BB_H
|
|
|
|
#define LIVE_VAR_BB_H
|
|
|
|
|
|
|
|
#include "LiveVarSet.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-04 16:31:03 +00:00
|
|
|
class BBLiveVar {
|
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
|
|
|
|
|
|
|
LiveVarSet DefSet; // Def set for LV analysis
|
|
|
|
LiveVarSet 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
|
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 00:33:19 +00:00
|
|
|
bool setPropagate(LiveVarSet *OutSetOfPred,
|
|
|
|
const LiveVarSet *InSetOfThisBB,
|
|
|
|
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
|
|
|
|
void addDef(const Value *Op);
|
|
|
|
|
|
|
|
// To add an operand which is a use
|
|
|
|
void addUse(const Value *Op);
|
|
|
|
|
2001-07-24 17:14:13 +00:00
|
|
|
public:
|
2002-02-05 00:33:19 +00:00
|
|
|
BBLiveVar(const BasicBlock *BB, unsigned POID);
|
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
|
|
|
void calcDefUseSets(); // calculates the Def & Use sets for this BB
|
|
|
|
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 00:33:19 +00:00
|
|
|
bool applyFlowFunc(std::map<const BasicBlock *, BBLiveVar *> &LVMap);
|
2001-07-24 17:14:13 +00:00
|
|
|
|
2002-02-05 00:33:19 +00:00
|
|
|
inline const LiveVarSet *getOutSet() const { return &OutSet; }
|
|
|
|
inline const LiveVarSet *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
|
|
|
|
|