1//=- llvm/CodeGen/MachineDominators.h ----------------------------*- 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 for 11// target-specific code. 12// 13//===----------------------------------------------------------------------===// 14 15#ifndef LLVM_CODEGEN_MACHINEPOSTDOMINATORS_H 16#define LLVM_CODEGEN_MACHINEPOSTDOMINATORS_H 17 18#include "llvm/CodeGen/MachineDominators.h" 19#include "llvm/CodeGen/MachineFunctionPass.h" 20 21namespace llvm { 22 23/// 24/// PostDominatorTree Class - Concrete subclass of DominatorTree that is used 25/// to compute the post-dominator tree. 26/// 27struct MachinePostDominatorTree : public MachineFunctionPass { 28private: 29 DominatorTreeBase<MachineBasicBlock> *DT; 30 31public: 32 static char ID; 33 34 MachinePostDominatorTree(); 35 36 ~MachinePostDominatorTree() override; 37 38 FunctionPass *createMachinePostDominatorTreePass(); 39 40 const std::vector<MachineBasicBlock *> &getRoots() const { 41 return DT->getRoots(); 42 } 43 44 MachineDomTreeNode *getRootNode() const { 45 return DT->getRootNode(); 46 } 47 48 MachineDomTreeNode *operator[](MachineBasicBlock *BB) const { 49 return DT->getNode(BB); 50 } 51 52 MachineDomTreeNode *getNode(MachineBasicBlock *BB) const { 53 return DT->getNode(BB); 54 } 55 56 bool dominates(const MachineDomTreeNode *A, 57 const MachineDomTreeNode *B) const { 58 return DT->dominates(A, B); 59 } 60 61 bool dominates(const MachineBasicBlock *A, const MachineBasicBlock *B) const { 62 return DT->dominates(A, B); 63 } 64 65 bool properlyDominates(const MachineDomTreeNode *A, 66 const MachineDomTreeNode *B) const { 67 return DT->properlyDominates(A, B); 68 } 69 70 bool properlyDominates(const MachineBasicBlock *A, 71 const MachineBasicBlock *B) const { 72 return DT->properlyDominates(A, B); 73 } 74 75 MachineBasicBlock *findNearestCommonDominator(MachineBasicBlock *A, 76 MachineBasicBlock *B) { 77 return DT->findNearestCommonDominator(A, B); 78 } 79 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; 83}; 84} //end of namespace llvm 85 86#endif 87