2003-10-13 03:32:08 +00:00
|
|
|
//===-- BBLiveVar.h - Live Variable Analysis for a BasicBlock ---*- C++ -*-===//
|
2005-04-21 23:30:14 +00:00
|
|
|
//
|
2003-10-21 15:17:13 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by the LLVM research group and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
2005-04-21 23:30:14 +00:00
|
|
|
//
|
2003-10-21 15:17:13 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2002-02-05 00:33:19 +00:00
|
|
|
//
|
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"
|
2004-09-01 22:55:40 +00:00
|
|
|
#include "llvm/ADT/hash_map"
|
2003-11-11 22:41:34 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2002-02-05 00:33:19 +00:00
|
|
|
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;
|
|
|
|
|
2003-10-20 20:52:23 +00:00
|
|
|
class BBLiveVar {
|
2002-06-25 16:12:52 +00:00
|
|
|
const BasicBlock &BB; // pointer to BasicBlock
|
2004-02-11 17:55:09 +00:00
|
|
|
const 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.
|
2003-10-20 20:52:23 +00:00
|
|
|
hash_map<const BasicBlock *, ValueSet> PredToEdgeInSetMap;
|
2005-04-21 23:30:14 +00:00
|
|
|
|
2002-10-29 23:06:16 +00:00
|
|
|
// method to propagate an InSet to OutSet of a predecessor
|
2005-04-21 23:30:14 +00:00
|
|
|
bool setPropagate(ValueSet *OutSetOfPred,
|
2002-02-05 02:51:01 +00:00
|
|
|
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
|
2005-04-21 23:30:14 +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
|
2003-10-20 20:52:23 +00:00
|
|
|
public:
|
2002-02-05 06:52:25 +00:00
|
|
|
|
2004-02-11 17:55:09 +00:00
|
|
|
BBLiveVar(const BasicBlock &BB, const MachineBasicBlock &MBB, unsigned POID);
|
2001-07-24 17:14:13 +00:00
|
|
|
|
2005-04-21 23:30:14 +00:00
|
|
|
inline bool isInSetChanged() const { return InSetChanged; }
|
2001-07-24 17:14:13 +00:00
|
|
|
inline bool isOutSetChanged() const { return OutSetChanged; }
|
|
|
|
|
2004-02-11 17:55:09 +00:00
|
|
|
const MachineBasicBlock &getMachineBasicBlock() const { return MBB; }
|
2002-10-28 18:01:21 +00:00
|
|
|
|
2002-02-05 00:33:19 +00:00
|
|
|
inline unsigned getPOId() const { return POID; }
|
2001-07-24 17:14:13 +00:00
|
|
|
|
2005-04-21 23:30:14 +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
|
2003-10-20 20:52:23 +00:00
|
|
|
bool applyFlowFunc(hash_map<const BasicBlock*, BBLiveVar*> &BBLiveVarInfo);
|
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
|
|
|
};
|
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2001-07-24 17:14:13 +00:00
|
|
|
#endif
|