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 = DominatorTreeBase<MachineBasicBlock>;
27 using DomTreeNodeT = DomTreeNodeBase<MachineBasicBlock>;
28 using DomSetType = DominanceFrontierBase<MachineBasicBlock>::DomSetType;
29 using iterator = DominanceFrontierBase<MachineBasicBlock>::iterator;
30 using const_iterator =
31 DominanceFrontierBase<MachineBasicBlock>::const_iterator;
33 MachineDominanceFrontier(const MachineDominanceFrontier &) = delete;
34 MachineDominanceFrontier &
35 operator=(const MachineDominanceFrontier &) = delete;
39 MachineDominanceFrontier();
41 DominanceFrontierBase<MachineBasicBlock> &getBase() {
45 inline const std::vector<MachineBasicBlock*> &getRoots() const {
46 return Base.getRoots();
49 MachineBasicBlock *getRoot() const {
50 return Base.getRoot();
53 bool isPostDominator() const {
54 return Base.isPostDominator();
61 const_iterator begin() const {
69 const_iterator end() const {
73 iterator find(MachineBasicBlock *B) {
77 const_iterator find(MachineBasicBlock *B) const {
81 iterator addBasicBlock(MachineBasicBlock *BB, const DomSetType &frontier) {
82 return Base.addBasicBlock(BB, frontier);
85 void removeBlock(MachineBasicBlock *BB) {
86 return Base.removeBlock(BB);
89 void addToFrontier(iterator I, MachineBasicBlock *Node) {
90 return Base.addToFrontier(I, Node);
93 void removeFromFrontier(iterator I, MachineBasicBlock *Node) {
94 return Base.removeFromFrontier(I, Node);
97 bool compareDomSet(DomSetType &DS1, const DomSetType &DS2) const {
98 return Base.compareDomSet(DS1, DS2);
101 bool compare(DominanceFrontierBase<MachineBasicBlock> &Other) const {
102 return Base.compare(Other);
105 bool runOnMachineFunction(MachineFunction &F) override;
107 void releaseMemory() override;
109 void getAnalysisUsage(AnalysisUsage &AU) const override;
112 } // end namespace llvm
114 #endif // LLVM_CODEGEN_MACHINEDOMINANCEFRONTIER_H