blob: f7bbd07a63ab5a82e33a070f1836c5c5fac3581b [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001//===- llvm/CodeGen/MachineDominanceFrontier.h ------------------*- C++ -*-===//
2//
Andrew Walbran16937d02019-10-22 13:54:20 +01003// 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 Scull5e1ddfa2018-08-14 10:06:54 +01006//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_CODEGEN_MACHINEDOMINANCEFRONTIER_H
10#define LLVM_CODEGEN_MACHINEDOMINANCEFRONTIER_H
11
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"
17#include <vector>
18
19namespace llvm {
20
21class MachineDominanceFrontier : public MachineFunctionPass {
22 ForwardDominanceFrontierBase<MachineBasicBlock> Base;
23
24public:
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;
31
32 MachineDominanceFrontier(const MachineDominanceFrontier &) = delete;
33 MachineDominanceFrontier &operator=(const MachineDominanceFrontier &) = delete;
34
35 static char ID;
36
37 MachineDominanceFrontier();
38
Andrew Scullcdfcccc2018-10-05 20:58:37 +010039 ForwardDominanceFrontierBase<MachineBasicBlock> &getBase() { return Base; }
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010040
Andrew Scullcdfcccc2018-10-05 20:58:37 +010041 const SmallVectorImpl<MachineBasicBlock *> &getRoots() const {
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010042 return Base.getRoots();
43 }
44
45 MachineBasicBlock *getRoot() const {
46 return Base.getRoot();
47 }
48
49 bool isPostDominator() const {
50 return Base.isPostDominator();
51 }
52
53 iterator begin() {
54 return Base.begin();
55 }
56
57 const_iterator begin() const {
58 return Base.begin();
59 }
60
61 iterator end() {
62 return Base.end();
63 }
64
65 const_iterator end() const {
66 return Base.end();
67 }
68
69 iterator find(MachineBasicBlock *B) {
70 return Base.find(B);
71 }
72
73 const_iterator find(MachineBasicBlock *B) const {
74 return Base.find(B);
75 }
76
77 iterator addBasicBlock(MachineBasicBlock *BB, const DomSetType &frontier) {
78 return Base.addBasicBlock(BB, frontier);
79 }
80
81 void removeBlock(MachineBasicBlock *BB) {
82 return Base.removeBlock(BB);
83 }
84
85 void addToFrontier(iterator I, MachineBasicBlock *Node) {
86 return Base.addToFrontier(I, Node);
87 }
88
89 void removeFromFrontier(iterator I, MachineBasicBlock *Node) {
90 return Base.removeFromFrontier(I, Node);
91 }
92
93 bool compareDomSet(DomSetType &DS1, const DomSetType &DS2) const {
94 return Base.compareDomSet(DS1, DS2);
95 }
96
97 bool compare(DominanceFrontierBase<MachineBasicBlock, false> &Other) const {
98 return Base.compare(Other);
99 }
100
101 bool runOnMachineFunction(MachineFunction &F) override;
102
103 void releaseMemory() override;
104
105 void getAnalysisUsage(AnalysisUsage &AU) const override;
106};
107
108} // end namespace llvm
109
110#endif // LLVM_CODEGEN_MACHINEDOMINANCEFRONTIER_H