1 //=- llvm/CodeGen/MachineDominators.h ----------------------------*- C++ -*-==//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file exposes interfaces to post dominance information for
11 // target-specific code.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CODEGEN_MACHINEPOSTDOMINATORS_H
16 #define LLVM_CODEGEN_MACHINEPOSTDOMINATORS_H
18 #include "llvm/Analysis/DominatorInternals.h"
19 #include "llvm/Analysis/Dominators.h"
20 #include "llvm/CodeGen/MachineDominators.h"
21 #include "llvm/CodeGen/MachineFunctionPass.h"
26 /// PostDominatorTree Class - Concrete subclass of DominatorTree that is used
27 /// to compute the a post-dominator tree.
29 struct MachinePostDominatorTree : public MachineFunctionPass {
31 DominatorTreeBase<MachineBasicBlock> *DT;
36 MachinePostDominatorTree();
38 ~MachinePostDominatorTree();
40 FunctionPass *createMachinePostDominatorTreePass();
42 const std::vector<MachineBasicBlock *> &getRoots() const {
43 return DT->getRoots();
46 MachineDomTreeNode *getRootNode() const {
47 return DT->getRootNode();
50 MachineDomTreeNode *operator[](MachineBasicBlock *BB) const {
51 return DT->getNode(BB);
54 MachineDomTreeNode *getNode(MachineBasicBlock *BB) const {
55 return DT->getNode(BB);
58 bool dominates(const MachineDomTreeNode *A,
59 const MachineDomTreeNode *B) const {
60 return DT->dominates(A, B);
63 bool dominates(const MachineBasicBlock *A, const MachineBasicBlock *B) const {
64 return DT->dominates(A, B);
67 bool properlyDominates(const MachineDomTreeNode *A,
68 const MachineDomTreeNode *B) const {
69 return DT->properlyDominates(A, B);
72 bool properlyDominates(const MachineBasicBlock *A,
73 const MachineBasicBlock *B) const {
74 return DT->properlyDominates(A, B);
77 MachineBasicBlock *findNearestCommonDominator(MachineBasicBlock *A,
78 MachineBasicBlock *B) {
79 return DT->findNearestCommonDominator(A, B);
82 virtual bool runOnMachineFunction(MachineFunction &MF);
83 virtual void getAnalysisUsage(AnalysisUsage &AU) const;
84 virtual void print(llvm::raw_ostream &OS, const Module *M = 0) const;
86 } //end of namespace llvm