LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PostDominators.h
Go to the documentation of this file.
1 //=- llvm/Analysis/PostDominators.h - Post Dominator Calculation-*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file exposes interfaces to post dominance information.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_ANALYSIS_POSTDOMINATORS_H
15 #define LLVM_ANALYSIS_POSTDOMINATORS_H
16 
18 
19 namespace llvm {
20 
21 /// PostDominatorTree Class - Concrete subclass of DominatorTree that is used to
22 /// compute the a post-dominator tree.
23 ///
25  static char ID; // Pass identification, replacement for typeid
27 
31  }
32 
34 
35  virtual bool runOnFunction(Function &F);
36 
37  virtual void getAnalysisUsage(AnalysisUsage &AU) const {
38  AU.setPreservesAll();
39  }
40 
41  inline const std::vector<BasicBlock*> &getRoots() const {
42  return DT->getRoots();
43  }
44 
45  inline DomTreeNode *getRootNode() const {
46  return DT->getRootNode();
47  }
48 
49  inline DomTreeNode *operator[](BasicBlock *BB) const {
50  return DT->getNode(BB);
51  }
52 
53  inline DomTreeNode *getNode(BasicBlock *BB) const {
54  return DT->getNode(BB);
55  }
56 
57  inline bool dominates(DomTreeNode* A, DomTreeNode* B) const {
58  return DT->dominates(A, B);
59  }
60 
61  inline bool dominates(const BasicBlock* A, const BasicBlock* B) const {
62  return DT->dominates(A, B);
63  }
64 
65  inline bool properlyDominates(const DomTreeNode* A, DomTreeNode* B) const {
66  return DT->properlyDominates(A, B);
67  }
68 
69  inline bool properlyDominates(BasicBlock* A, BasicBlock* B) const {
70  return DT->properlyDominates(A, B);
71  }
72 
74  return DT->findNearestCommonDominator(A, B);
75  }
76 
78  const BasicBlock *B) {
79  return DT->findNearestCommonDominator(A, B);
80  }
81 
82  virtual void releaseMemory() {
83  DT->releaseMemory();
84  }
85 
86  virtual void print(raw_ostream &OS, const Module*) const;
87 };
88 
89 FunctionPass* createPostDomTree();
90 
91 template <> struct GraphTraits<PostDominatorTree*>
92  : public GraphTraits<DomTreeNode*> {
94  return DT->getRootNode();
95  }
96 
98  if (getEntryNode(N))
99  return df_begin(getEntryNode(N));
100  else
101  return df_end(getEntryNode(N));
102  }
103 
105  return df_end(getEntryNode(N));
106  }
107 };
108 
109 } // End llvm namespace
110 
111 #endif
virtual void getAnalysisUsage(AnalysisUsage &AU) const
static PassRegistry * getPassRegistry()
const BasicBlock * findNearestCommonDominator(const BasicBlock *A, const BasicBlock *B)
The main container class for the LLVM Intermediate Representation.
Definition: Module.h:112
virtual bool runOnFunction(Function &F)
bool properlyDominates(BasicBlock *A, BasicBlock *B) const
F(f)
static NodeType * getEntryNode(PostDominatorTree *DT)
DominatorTreeBase< BasicBlock > * DT
static nodes_iterator nodes_end(PostDominatorTree *N)
const std::vector< BasicBlock * > & getRoots() const
virtual void releaseMemory()
LLVM Basic Block Representation.
Definition: BasicBlock.h:72
df_iterator< T > df_end(const T &G)
static nodes_iterator nodes_begin(PostDominatorTree *N)
DomTreeNode * operator[](BasicBlock *BB) const
bool dominates(const BasicBlock *A, const BasicBlock *B) const
bool dominates(DomTreeNode *A, DomTreeNode *B) const
virtual void print(raw_ostream &OS, const Module *) const
df_iterator< T > df_begin(const T &G)
void initializePostDominatorTreePass(PassRegistry &)
bool properlyDominates(const DomTreeNode *A, DomTreeNode *B) const
BasicBlock * findNearestCommonDominator(BasicBlock *A, BasicBlock *B)
#define N
DomTreeNode * getRootNode() const
FunctionPass * createPostDomTree()
DomTreeNode * getNode(BasicBlock *BB) const