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 20namespace llvm { 21 22class MachineDominanceFrontier : public MachineFunctionPass { 23 ForwardDominanceFrontierBase<MachineBasicBlock> Base; 24 25public: 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; 32 33 MachineDominanceFrontier(const MachineDominanceFrontier &) = delete; 34 MachineDominanceFrontier & 35 operator=(const MachineDominanceFrontier &) = delete; 36 37 static char ID; 38 39 MachineDominanceFrontier(); 40 41 DominanceFrontierBase<MachineBasicBlock> &getBase() { 42 return Base; 43 } 44 45 inline const std::vector<MachineBasicBlock*> &getRoots() const { 46 return Base.getRoots(); 47 } 48 49 MachineBasicBlock *getRoot() const { 50 return Base.getRoot(); 51 } 52 53 bool isPostDominator() const { 54 return Base.isPostDominator(); 55 } 56 57 iterator begin() { 58 return Base.begin(); 59 } 60 61 const_iterator begin() const { 62 return Base.begin(); 63 } 64 65 iterator end() { 66 return Base.end(); 67 } 68 69 const_iterator end() const { 70 return Base.end(); 71 } 72 73 iterator find(MachineBasicBlock *B) { 74 return Base.find(B); 75 } 76 77 const_iterator find(MachineBasicBlock *B) const { 78 return Base.find(B); 79 } 80 81 iterator addBasicBlock(MachineBasicBlock *BB, const DomSetType &frontier) { 82 return Base.addBasicBlock(BB, frontier); 83 } 84 85 void removeBlock(MachineBasicBlock *BB) { 86 return Base.removeBlock(BB); 87 } 88 89 void addToFrontier(iterator I, MachineBasicBlock *Node) { 90 return Base.addToFrontier(I, Node); 91 } 92 93 void removeFromFrontier(iterator I, MachineBasicBlock *Node) { 94 return Base.removeFromFrontier(I, Node); 95 } 96 97 bool compareDomSet(DomSetType &DS1, const DomSetType &DS2) const { 98 return Base.compareDomSet(DS1, DS2); 99 } 100 101 bool compare(DominanceFrontierBase<MachineBasicBlock> &Other) const { 102 return Base.compare(Other); 103 } 104 105 bool runOnMachineFunction(MachineFunction &F) override; 106 107 void releaseMemory() override; 108 109 void getAnalysisUsage(AnalysisUsage &AU) const override; 110}; 111 112} // end namespace llvm 113 114#endif // LLVM_CODEGEN_MACHINEDOMINANCEFRONTIER_H 115