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
|
|
|
|
|
2003-01-14 22:56:37 +00:00
|
|
|
#include "llvm/CodeGen/ValueSet.h"
|
2003-01-14 21:31:39 +00:00
|
|
|
#include "Support/Annotation.h"
|
2002-02-05 00:33:19 +00:00
|
|
|
#include <map>
|
|
|
|
class BasicBlock;
|
|
|
|
class Value;
|
2002-10-28 18:01:21 +00:00
|
|
|
class MachineBasicBlock;
|
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-10-28 18:01:21 +00:00
|
|
|
MachineBasicBlock &MBB; // Pointer to MachineBasicBlock
|
2002-02-05 00:33:19 +00:00
|
|
|
unsigned POID; // Post-Order ID
|
2001-07-24 17:14:13 +00:00
|
|
|
|
2002-10-28 18:01:21 +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;
|
|
|
|
|
2002-10-29 23:06:16 +00:00
|
|
|
// method to propagate 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-10-28 18:01:21 +00:00
|
|
|
BBLiveVar(const BasicBlock &BB, MachineBasicBlock &MBB, unsigned POID);
|
2002-02-05 06:52:25 +00:00
|
|
|
~BBLiveVar() {} // make dtor private
|
|
|
|
public:
|
2002-10-28 18:01:21 +00:00
|
|
|
static BBLiveVar *CreateOnBB(const BasicBlock &BB, MachineBasicBlock &MBB,
|
|
|
|
unsigned POID);
|
2002-06-25 16:12:52 +00:00
|
|
|
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-10-28 18:01:21 +00:00
|
|
|
MachineBasicBlock &getMachineBasicBlock() const { return MBB; }
|
|
|
|
|
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; }
|
2003-08-12 22:19:59 +00:00
|
|
|
inline ValueSet &getOutSet() { return OutSet; }
|
|
|
|
|
2002-02-05 04:20:12 +00:00
|
|
|
inline const ValueSet &getInSet() const { return InSet; }
|
2003-08-12 22:19:59 +00:00
|
|
|
inline ValueSet &getInSet() { 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
|