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