Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 1 | //===- llvm/CodeGen/MachinePostDominators.h ----------------------*- C++ -*-==// |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 2 | // |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This file exposes interfaces to post dominance information for |
| 10 | // target-specific code. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef LLVM_CODEGEN_MACHINEPOSTDOMINATORS_H |
| 15 | #define LLVM_CODEGEN_MACHINEPOSTDOMINATORS_H |
| 16 | |
| 17 | #include "llvm/CodeGen/MachineDominators.h" |
| 18 | #include "llvm/CodeGen/MachineFunctionPass.h" |
| 19 | |
| 20 | namespace llvm { |
| 21 | |
| 22 | /// |
| 23 | /// PostDominatorTree Class - Concrete subclass of DominatorTree that is used |
| 24 | /// to compute the post-dominator tree. |
| 25 | /// |
| 26 | struct MachinePostDominatorTree : public MachineFunctionPass { |
| 27 | private: |
| 28 | PostDomTreeBase<MachineBasicBlock> *DT; |
| 29 | |
| 30 | public: |
| 31 | static char ID; |
| 32 | |
| 33 | MachinePostDominatorTree(); |
| 34 | |
| 35 | ~MachinePostDominatorTree() override; |
| 36 | |
| 37 | FunctionPass *createMachinePostDominatorTreePass(); |
| 38 | |
| 39 | const SmallVectorImpl<MachineBasicBlock *> &getRoots() const { |
| 40 | return DT->getRoots(); |
| 41 | } |
| 42 | |
| 43 | MachineDomTreeNode *getRootNode() const { |
| 44 | return DT->getRootNode(); |
| 45 | } |
| 46 | |
| 47 | MachineDomTreeNode *operator[](MachineBasicBlock *BB) const { |
| 48 | return DT->getNode(BB); |
| 49 | } |
| 50 | |
| 51 | MachineDomTreeNode *getNode(MachineBasicBlock *BB) const { |
| 52 | return DT->getNode(BB); |
| 53 | } |
| 54 | |
| 55 | bool dominates(const MachineDomTreeNode *A, |
| 56 | const MachineDomTreeNode *B) const { |
| 57 | return DT->dominates(A, B); |
| 58 | } |
| 59 | |
| 60 | bool dominates(const MachineBasicBlock *A, const MachineBasicBlock *B) const { |
| 61 | return DT->dominates(A, B); |
| 62 | } |
| 63 | |
| 64 | bool properlyDominates(const MachineDomTreeNode *A, |
| 65 | const MachineDomTreeNode *B) const { |
| 66 | return DT->properlyDominates(A, B); |
| 67 | } |
| 68 | |
| 69 | bool properlyDominates(const MachineBasicBlock *A, |
| 70 | const MachineBasicBlock *B) const { |
| 71 | return DT->properlyDominates(A, B); |
| 72 | } |
| 73 | |
| 74 | MachineBasicBlock *findNearestCommonDominator(MachineBasicBlock *A, |
| 75 | MachineBasicBlock *B) { |
| 76 | return DT->findNearestCommonDominator(A, B); |
| 77 | } |
| 78 | |
| 79 | bool runOnMachineFunction(MachineFunction &MF) override; |
| 80 | void getAnalysisUsage(AnalysisUsage &AU) const override; |
| 81 | void print(llvm::raw_ostream &OS, const Module *M = nullptr) const override; |
| 82 | }; |
| 83 | } //end of namespace llvm |
| 84 | |
| 85 | #endif |