1 //===- llvm/CodeGen/MachinePostDominators.h ----------------------*- C++ -*-==//
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
7 //===----------------------------------------------------------------------===//
9 // This file exposes interfaces to post dominance information for
10 // target-specific code.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CODEGEN_MACHINEPOSTDOMINATORS_H
15 #define LLVM_CODEGEN_MACHINEPOSTDOMINATORS_H
17 #include "llvm/CodeGen/MachineDominators.h"
18 #include "llvm/CodeGen/MachineFunctionPass.h"
23 /// PostDominatorTree Class - Concrete subclass of DominatorTree that is used
24 /// to compute the post-dominator tree.
26 struct MachinePostDominatorTree
: public MachineFunctionPass
{
28 PostDomTreeBase
<MachineBasicBlock
> *DT
;
33 MachinePostDominatorTree();
35 ~MachinePostDominatorTree() override
;
37 FunctionPass
*createMachinePostDominatorTreePass();
39 const SmallVectorImpl
<MachineBasicBlock
*> &getRoots() const {
40 return DT
->getRoots();
43 MachineDomTreeNode
*getRootNode() const {
44 return DT
->getRootNode();
47 MachineDomTreeNode
*operator[](MachineBasicBlock
*BB
) const {
48 return DT
->getNode(BB
);
51 MachineDomTreeNode
*getNode(MachineBasicBlock
*BB
) const {
52 return DT
->getNode(BB
);
55 bool dominates(const MachineDomTreeNode
*A
,
56 const MachineDomTreeNode
*B
) const {
57 return DT
->dominates(A
, B
);
60 bool dominates(const MachineBasicBlock
*A
, const MachineBasicBlock
*B
) const {
61 return DT
->dominates(A
, B
);
64 bool properlyDominates(const MachineDomTreeNode
*A
,
65 const MachineDomTreeNode
*B
) const {
66 return DT
->properlyDominates(A
, B
);
69 bool properlyDominates(const MachineBasicBlock
*A
,
70 const MachineBasicBlock
*B
) const {
71 return DT
->properlyDominates(A
, B
);
74 MachineBasicBlock
*findNearestCommonDominator(MachineBasicBlock
*A
,
75 MachineBasicBlock
*B
) {
76 return DT
->findNearestCommonDominator(A
, B
);
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
;
83 } //end of namespace llvm