1 //===- MachinePostDominators.cpp -Machine Post Dominator Calculation ------===// 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 // This file implements simple dominator construction algorithms for finding 10 // post dominators on machine functions. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #include "llvm/CodeGen/MachinePostDominators.h" 15 16 using namespace llvm; 17 18 namespace llvm { 19 template class DominatorTreeBase<MachineBasicBlock, true>; // PostDomTreeBase 20 } 21 22 char MachinePostDominatorTree::ID = 0; 23 24 //declare initializeMachinePostDominatorTreePass 25 INITIALIZE_PASS(MachinePostDominatorTree, "machinepostdomtree", 26 "MachinePostDominator Tree Construction", true, true) 27 28 MachinePostDominatorTree::MachinePostDominatorTree() : MachineFunctionPass(ID) { 29 initializeMachinePostDominatorTreePass(*PassRegistry::getPassRegistry()); 30 DT = new PostDomTreeBase<MachineBasicBlock>(); 31 } 32 33 FunctionPass * 34 MachinePostDominatorTree::createMachinePostDominatorTreePass() { 35 return new MachinePostDominatorTree(); 36 } 37 38 bool 39 MachinePostDominatorTree::runOnMachineFunction(MachineFunction &F) { 40 DT->recalculate(F); 41 return false; 42 } 43 44 MachinePostDominatorTree::~MachinePostDominatorTree() { 45 delete DT; 46 } 47 48 void 49 MachinePostDominatorTree::getAnalysisUsage(AnalysisUsage &AU) const { 50 AU.setPreservesAll(); 51 MachineFunctionPass::getAnalysisUsage(AU); 52 } 53 54 void 55 MachinePostDominatorTree::print(llvm::raw_ostream &OS, const Module *M) const { 56 DT->print(OS); 57 } 58