1 //===- llvm/CodeGen/MachineDominanceFrontier.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 #ifndef LLVM_CODEGEN_MACHINEDOMINANCEFRONTIER_H
10 #define LLVM_CODEGEN_MACHINEDOMINANCEFRONTIER_H
12 #include "llvm/Analysis/DominanceFrontier.h"
13 #include "llvm/Analysis/DominanceFrontierImpl.h"
14 #include "llvm/CodeGen/MachineBasicBlock.h"
15 #include "llvm/CodeGen/MachineFunctionPass.h"
16 #include "llvm/Support/GenericDomTree.h"
21 class MachineDominanceFrontier
: public MachineFunctionPass
{
22 ForwardDominanceFrontierBase
<MachineBasicBlock
> Base
;
25 using DomTreeT
= DomTreeBase
<MachineBasicBlock
>;
26 using DomTreeNodeT
= DomTreeNodeBase
<MachineBasicBlock
>;
27 using DomSetType
= DominanceFrontierBase
<MachineBasicBlock
, false>::DomSetType
;
28 using iterator
= DominanceFrontierBase
<MachineBasicBlock
, false>::iterator
;
29 using const_iterator
=
30 DominanceFrontierBase
<MachineBasicBlock
, false>::const_iterator
;
32 MachineDominanceFrontier(const MachineDominanceFrontier
&) = delete;
33 MachineDominanceFrontier
&operator=(const MachineDominanceFrontier
&) = delete;
37 MachineDominanceFrontier();
39 ForwardDominanceFrontierBase
<MachineBasicBlock
> &getBase() { return Base
; }
41 const SmallVectorImpl
<MachineBasicBlock
*> &getRoots() const {
42 return Base
.getRoots();
45 MachineBasicBlock
*getRoot() const {
46 return Base
.getRoot();
49 bool isPostDominator() const {
50 return Base
.isPostDominator();
57 const_iterator
begin() const {
65 const_iterator
end() const {
69 iterator
find(MachineBasicBlock
*B
) {
73 const_iterator
find(MachineBasicBlock
*B
) const {
77 iterator
addBasicBlock(MachineBasicBlock
*BB
, const DomSetType
&frontier
) {
78 return Base
.addBasicBlock(BB
, frontier
);
81 void removeBlock(MachineBasicBlock
*BB
) {
82 return Base
.removeBlock(BB
);
85 void addToFrontier(iterator I
, MachineBasicBlock
*Node
) {
86 return Base
.addToFrontier(I
, Node
);
89 void removeFromFrontier(iterator I
, MachineBasicBlock
*Node
) {
90 return Base
.removeFromFrontier(I
, Node
);
93 bool compareDomSet(DomSetType
&DS1
, const DomSetType
&DS2
) const {
94 return Base
.compareDomSet(DS1
, DS2
);
97 bool compare(DominanceFrontierBase
<MachineBasicBlock
, false> &Other
) const {
98 return Base
.compare(Other
);
101 bool runOnMachineFunction(MachineFunction
&F
) override
;
103 void releaseMemory() override
;
105 void getAnalysisUsage(AnalysisUsage
&AU
) const override
;
108 } // end namespace llvm
110 #endif // LLVM_CODEGEN_MACHINEDOMINANCEFRONTIER_H