1 //===- llvm/CodeGen/MachineDominanceFrontier.h ------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef LLVM_CODEGEN_MACHINEDOMINANCEFRONTIER_H 11 #define LLVM_CODEGEN_MACHINEDOMINANCEFRONTIER_H 12 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" 18 #include <vector> 19 20 namespace llvm { 21 22 class MachineDominanceFrontier : public MachineFunctionPass { 23 ForwardDominanceFrontierBase<MachineBasicBlock> Base; 24 25 public: 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; 32 33 MachineDominanceFrontier(const MachineDominanceFrontier &) = delete; 34 MachineDominanceFrontier &operator=(const MachineDominanceFrontier &) = delete; 35 36 static char ID; 37 38 MachineDominanceFrontier(); 39 getBase()40 ForwardDominanceFrontierBase<MachineBasicBlock> &getBase() { return Base; } 41 getRoots()42 const SmallVectorImpl<MachineBasicBlock *> &getRoots() const { 43 return Base.getRoots(); 44 } 45 getRoot()46 MachineBasicBlock *getRoot() const { 47 return Base.getRoot(); 48 } 49 isPostDominator()50 bool isPostDominator() const { 51 return Base.isPostDominator(); 52 } 53 begin()54 iterator begin() { 55 return Base.begin(); 56 } 57 begin()58 const_iterator begin() const { 59 return Base.begin(); 60 } 61 end()62 iterator end() { 63 return Base.end(); 64 } 65 end()66 const_iterator end() const { 67 return Base.end(); 68 } 69 find(MachineBasicBlock * B)70 iterator find(MachineBasicBlock *B) { 71 return Base.find(B); 72 } 73 find(MachineBasicBlock * B)74 const_iterator find(MachineBasicBlock *B) const { 75 return Base.find(B); 76 } 77 addBasicBlock(MachineBasicBlock * BB,const DomSetType & frontier)78 iterator addBasicBlock(MachineBasicBlock *BB, const DomSetType &frontier) { 79 return Base.addBasicBlock(BB, frontier); 80 } 81 removeBlock(MachineBasicBlock * BB)82 void removeBlock(MachineBasicBlock *BB) { 83 return Base.removeBlock(BB); 84 } 85 addToFrontier(iterator I,MachineBasicBlock * Node)86 void addToFrontier(iterator I, MachineBasicBlock *Node) { 87 return Base.addToFrontier(I, Node); 88 } 89 removeFromFrontier(iterator I,MachineBasicBlock * Node)90 void removeFromFrontier(iterator I, MachineBasicBlock *Node) { 91 return Base.removeFromFrontier(I, Node); 92 } 93 compareDomSet(DomSetType & DS1,const DomSetType & DS2)94 bool compareDomSet(DomSetType &DS1, const DomSetType &DS2) const { 95 return Base.compareDomSet(DS1, DS2); 96 } 97 compare(DominanceFrontierBase<MachineBasicBlock,false> & Other)98 bool compare(DominanceFrontierBase<MachineBasicBlock, false> &Other) const { 99 return Base.compare(Other); 100 } 101 102 bool runOnMachineFunction(MachineFunction &F) override; 103 104 void releaseMemory() override; 105 106 void getAnalysisUsage(AnalysisUsage &AU) const override; 107 }; 108 109 } // end namespace llvm 110 111 #endif // LLVM_CODEGEN_MACHINEDOMINANCEFRONTIER_H 112