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/CodeGen/MachineDominators.h"
19 #include "llvm/CodeGen/MachineFunctionPass.h"
24 /// PostDominatorTree Class - Concrete subclass of DominatorTree that is used
25 /// to compute the post-dominator tree.
27 struct MachinePostDominatorTree : public MachineFunctionPass {
29 DominatorTreeBase<MachineBasicBlock> *DT;
34 MachinePostDominatorTree();
36 ~MachinePostDominatorTree();
38 FunctionPass *createMachinePostDominatorTreePass();
40 const std::vector<MachineBasicBlock *> &getRoots() const {
41 return DT->getRoots();
44 MachineDomTreeNode *getRootNode() const {
45 return DT->getRootNode();
48 MachineDomTreeNode *operator[](MachineBasicBlock *BB) const {
49 return DT->getNode(BB);
52 MachineDomTreeNode *getNode(MachineBasicBlock *BB) const {
53 return DT->getNode(BB);
56 bool dominates(const MachineDomTreeNode *A,
57 const MachineDomTreeNode *B) const {
58 return DT->dominates(A, B);
61 bool dominates(const MachineBasicBlock *A, const MachineBasicBlock *B) const {
62 return DT->dominates(A, B);
65 bool properlyDominates(const MachineDomTreeNode *A,
66 const MachineDomTreeNode *B) const {
67 return DT->properlyDominates(A, B);
70 bool properlyDominates(const MachineBasicBlock *A,
71 const MachineBasicBlock *B) const {
72 return DT->properlyDominates(A, B);
75 MachineBasicBlock *findNearestCommonDominator(MachineBasicBlock *A,
76 MachineBasicBlock *B) {
77 return DT->findNearestCommonDominator(A, B);
80 bool runOnMachineFunction(MachineFunction &MF) override;
81 void getAnalysisUsage(AnalysisUsage &AU) const override;
82 void print(llvm::raw_ostream &OS, const Module *M = nullptr) const override;
84 } //end of namespace llvm