2003-09-30 20:37:50 +02:00
|
|
|
//=- llvm/Analysis/PostDominators.h - Post Dominator Calculation-*- C++ -*-===//
|
2005-04-21 22:19:05 +02:00
|
|
|
//
|
2003-10-20 22:19:47 +02:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:59:42 +01:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 22:19:05 +02:00
|
|
|
//
|
2003-10-20 22:19:47 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
2002-08-22 01:43:50 +02:00
|
|
|
//
|
|
|
|
// This file exposes interfaces to post dominance information.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_ANALYSIS_POST_DOMINATORS_H
|
|
|
|
#define LLVM_ANALYSIS_POST_DOMINATORS_H
|
|
|
|
|
|
|
|
#include "llvm/Analysis/Dominators.h"
|
|
|
|
|
2003-11-11 23:41:34 +01:00
|
|
|
namespace llvm {
|
|
|
|
|
2004-03-01 00:55:11 +01:00
|
|
|
/// PostDominatorTree Class - Concrete subclass of DominatorTree that is used to
|
|
|
|
/// compute the a post-dominator tree.
|
|
|
|
///
|
2007-10-23 22:58:37 +02:00
|
|
|
struct PostDominatorTree : public FunctionPass {
|
2007-05-06 15:37:16 +02:00
|
|
|
static char ID; // Pass identification, replacement for typeid
|
2007-10-23 22:58:37 +02:00
|
|
|
DominatorTreeBase<BasicBlock>* DT;
|
2007-05-01 23:15:47 +02:00
|
|
|
|
2008-03-19 22:56:59 +01:00
|
|
|
PostDominatorTree() : FunctionPass((intptr_t)&ID) {
|
2007-10-23 23:42:49 +02:00
|
|
|
DT = new DominatorTreeBase<BasicBlock>(true);
|
2007-10-23 22:58:37 +02:00
|
|
|
}
|
2002-08-22 01:43:50 +02:00
|
|
|
|
2008-05-03 22:25:26 +02:00
|
|
|
~PostDominatorTree();
|
|
|
|
|
2007-10-03 05:20:17 +02:00
|
|
|
virtual bool runOnFunction(Function &F);
|
2002-08-22 01:43:50 +02:00
|
|
|
|
|
|
|
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
|
|
|
AU.setPreservesAll();
|
|
|
|
}
|
2007-10-23 22:58:37 +02:00
|
|
|
|
|
|
|
inline const std::vector<BasicBlock*> &getRoots() const {
|
|
|
|
return DT->getRoots();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline DomTreeNode *getRootNode() const {
|
|
|
|
return DT->getRootNode();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline DomTreeNode *operator[](BasicBlock *BB) const {
|
|
|
|
return DT->getNode(BB);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool properlyDominates(const DomTreeNode* A, DomTreeNode* B) const {
|
|
|
|
return DT->properlyDominates(A, B);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool properlyDominates(BasicBlock* A, BasicBlock* B) const {
|
|
|
|
return DT->properlyDominates(A, B);
|
|
|
|
}
|
2008-02-27 19:38:29 +01:00
|
|
|
|
|
|
|
virtual void print(std::ostream &OS, const Module* M= 0) const {
|
|
|
|
DT->print(OS, M);
|
|
|
|
}
|
2002-08-22 01:43:50 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2004-03-01 00:55:11 +01:00
|
|
|
/// PostDominanceFrontier Class - Concrete subclass of DominanceFrontier that is
|
|
|
|
/// used to compute the a post-dominance frontier.
|
|
|
|
///
|
2002-08-22 01:43:50 +02:00
|
|
|
struct PostDominanceFrontier : public DominanceFrontierBase {
|
2007-05-03 03:11:54 +02:00
|
|
|
static char ID;
|
2007-05-01 23:15:47 +02:00
|
|
|
PostDominanceFrontier()
|
|
|
|
: DominanceFrontierBase((intptr_t) &ID, true) {}
|
2002-08-22 01:43:50 +02:00
|
|
|
|
|
|
|
virtual bool runOnFunction(Function &) {
|
|
|
|
Frontiers.clear();
|
|
|
|
PostDominatorTree &DT = getAnalysis<PostDominatorTree>();
|
2003-09-10 22:36:51 +02:00
|
|
|
Roots = DT.getRoots();
|
2007-06-04 02:32:22 +02:00
|
|
|
if (const DomTreeNode *Root = DT.getRootNode())
|
2003-09-15 17:47:40 +02:00
|
|
|
calculate(DT, Root);
|
2002-08-22 01:43:50 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
|
|
|
AU.setPreservesAll();
|
|
|
|
AU.addRequired<PostDominatorTree>();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const DomSetType &calculate(const PostDominatorTree &DT,
|
2007-06-04 02:32:22 +02:00
|
|
|
const DomTreeNode *Node);
|
2002-08-22 01:43:50 +02:00
|
|
|
};
|
|
|
|
|
2003-11-11 23:41:34 +01:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2006-06-08 00:00:26 +02:00
|
|
|
// Make sure that any clients of this file link in PostDominators.cpp
|
|
|
|
FORCE_DEFINING_FILE_TO_BE_LINKED(PostDominanceFrontier)
|
|
|
|
|
2002-08-22 01:43:50 +02:00
|
|
|
#endif
|