1 //===- llvm/CodeGen/MachineDominanceFrontier.h ------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_CODEGEN_MACHINEDOMINANCEFRONTIER_H
11 #define LLVM_CODEGEN_MACHINEDOMINANCEFRONTIER_H
13 #include "llvm/Analysis/DominanceFrontier.h"
14 #include "llvm/Analysis/DominanceFrontierImpl.h"
15 #include "llvm/CodeGen/MachineBasicBlock.h"
16 #include "llvm/CodeGen/MachineFunctionPass.h"
17 #include "llvm/Support/GenericDomTree.h"
22 class MachineDominanceFrontier : public MachineFunctionPass {
23 ForwardDominanceFrontierBase<MachineBasicBlock> Base;
26 using DomTreeT = DomTreeBase<MachineBasicBlock>;
27 using DomTreeNodeT = DomTreeNodeBase<MachineBasicBlock>;
28 using DomSetType = DominanceFrontierBase<MachineBasicBlock, false>::DomSetType;
29 using iterator = DominanceFrontierBase<MachineBasicBlock, false>::iterator;
30 using const_iterator =
31 DominanceFrontierBase<MachineBasicBlock, false>::const_iterator;
33 MachineDominanceFrontier(const MachineDominanceFrontier &) = delete;
34 MachineDominanceFrontier &operator=(const MachineDominanceFrontier &) = delete;
38 MachineDominanceFrontier();
40 ForwardDominanceFrontierBase<MachineBasicBlock> &getBase() { return Base; }
42 const SmallVectorImpl<MachineBasicBlock *> &getRoots() const {
43 return Base.getRoots();
46 MachineBasicBlock *getRoot() const {
47 return Base.getRoot();
50 bool isPostDominator() const {
51 return Base.isPostDominator();
58 const_iterator begin() const {
66 const_iterator end() const {
70 iterator find(MachineBasicBlock *B) {
74 const_iterator find(MachineBasicBlock *B) const {
78 iterator addBasicBlock(MachineBasicBlock *BB, const DomSetType &frontier) {
79 return Base.addBasicBlock(BB, frontier);
82 void removeBlock(MachineBasicBlock *BB) {
83 return Base.removeBlock(BB);
86 void addToFrontier(iterator I, MachineBasicBlock *Node) {
87 return Base.addToFrontier(I, Node);
90 void removeFromFrontier(iterator I, MachineBasicBlock *Node) {
91 return Base.removeFromFrontier(I, Node);
94 bool compareDomSet(DomSetType &DS1, const DomSetType &DS2) const {
95 return Base.compareDomSet(DS1, DS2);
98 bool compare(DominanceFrontierBase<MachineBasicBlock, false> &Other) const {
99 return Base.compare(Other);
102 bool runOnMachineFunction(MachineFunction &F) override;
104 void releaseMemory() override;
106 void getAnalysisUsage(AnalysisUsage &AU) const override;
109 } // end namespace llvm
111 #endif // LLVM_CODEGEN_MACHINEDOMINANCEFRONTIER_H