1 //===- llvm/CodeGen/MachineDominanceFrontier.h ------------------*- C++ -*-===//
2 //
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
6 //
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 
19 namespace llvm {
20 
21 class MachineDominanceFrontier : public MachineFunctionPass {
22   ForwardDominanceFrontierBase<MachineBasicBlock> Base;
23 
24 public:
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 
getBase()39  ForwardDominanceFrontierBase<MachineBasicBlock> &getBase() { return Base; }
40 
getRoots()41  const SmallVectorImpl<MachineBasicBlock *> &getRoots() const {
42    return Base.getRoots();
43   }
44 
getRoot()45   MachineBasicBlock *getRoot() const {
46     return Base.getRoot();
47   }
48 
isPostDominator()49   bool isPostDominator() const {
50     return Base.isPostDominator();
51   }
52 
begin()53   iterator begin() {
54     return Base.begin();
55   }
56 
begin()57   const_iterator begin() const {
58     return Base.begin();
59   }
60 
end()61   iterator end() {
62     return Base.end();
63   }
64 
end()65   const_iterator end() const {
66     return Base.end();
67   }
68 
find(MachineBasicBlock * B)69   iterator find(MachineBasicBlock *B) {
70     return Base.find(B);
71   }
72 
find(MachineBasicBlock * B)73   const_iterator find(MachineBasicBlock *B) const {
74     return Base.find(B);
75   }
76 
addBasicBlock(MachineBasicBlock * BB,const DomSetType & frontier)77   iterator addBasicBlock(MachineBasicBlock *BB, const DomSetType &frontier) {
78     return Base.addBasicBlock(BB, frontier);
79   }
80 
removeBlock(MachineBasicBlock * BB)81   void removeBlock(MachineBasicBlock *BB) {
82     return Base.removeBlock(BB);
83   }
84 
addToFrontier(iterator I,MachineBasicBlock * Node)85   void addToFrontier(iterator I, MachineBasicBlock *Node) {
86     return Base.addToFrontier(I, Node);
87   }
88 
removeFromFrontier(iterator I,MachineBasicBlock * Node)89   void removeFromFrontier(iterator I, MachineBasicBlock *Node) {
90     return Base.removeFromFrontier(I, Node);
91   }
92 
compareDomSet(DomSetType & DS1,const DomSetType & DS2)93   bool compareDomSet(DomSetType &DS1, const DomSetType &DS2) const {
94     return Base.compareDomSet(DS1, DS2);
95   }
96 
compare(DominanceFrontierBase<MachineBasicBlock,false> & Other)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
111