186af62c1STom Stellard //===- MachinePostDominators.cpp -Machine Post Dominator Calculation ------===// 286af62c1STom Stellard // 3*2946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*2946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information. 5*2946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 686af62c1STom Stellard // 786af62c1STom Stellard //===----------------------------------------------------------------------===// 886af62c1STom Stellard // 986af62c1STom Stellard // This file implements simple dominator construction algorithms for finding 1086af62c1STom Stellard // post dominators on machine functions. 1186af62c1STom Stellard // 1286af62c1STom Stellard //===----------------------------------------------------------------------===// 1386af62c1STom Stellard 1486af62c1STom Stellard #include "llvm/CodeGen/MachinePostDominators.h" 1586af62c1STom Stellard 1686af62c1STom Stellard using namespace llvm; 1786af62c1STom Stellard 18b292c22cSJakub Kuderski namespace llvm { 19b292c22cSJakub Kuderski template class DominatorTreeBase<MachineBasicBlock, true>; // PostDomTreeBase 20b292c22cSJakub Kuderski } 21b292c22cSJakub Kuderski 2286af62c1STom Stellard char MachinePostDominatorTree::ID = 0; 2386af62c1STom Stellard 2486af62c1STom Stellard //declare initializeMachinePostDominatorTreePass 2586af62c1STom Stellard INITIALIZE_PASS(MachinePostDominatorTree, "machinepostdomtree", 2686af62c1STom Stellard "MachinePostDominator Tree Construction", true, true) 2786af62c1STom Stellard 2886af62c1STom Stellard MachinePostDominatorTree::MachinePostDominatorTree() : MachineFunctionPass(ID) { 2986af62c1STom Stellard initializeMachinePostDominatorTreePass(*PassRegistry::getPassRegistry()); 30b292c22cSJakub Kuderski DT = new PostDomTreeBase<MachineBasicBlock>(); 3186af62c1STom Stellard } 3286af62c1STom Stellard 3386af62c1STom Stellard FunctionPass * 3486af62c1STom Stellard MachinePostDominatorTree::createMachinePostDominatorTreePass() { 3586af62c1STom Stellard return new MachinePostDominatorTree(); 3686af62c1STom Stellard } 3786af62c1STom Stellard 3886af62c1STom Stellard bool 3986af62c1STom Stellard MachinePostDominatorTree::runOnMachineFunction(MachineFunction &F) { 4086af62c1STom Stellard DT->recalculate(F); 4186af62c1STom Stellard return false; 4286af62c1STom Stellard } 4386af62c1STom Stellard 4486af62c1STom Stellard MachinePostDominatorTree::~MachinePostDominatorTree() { 4586af62c1STom Stellard delete DT; 4686af62c1STom Stellard } 4786af62c1STom Stellard 4886af62c1STom Stellard void 4986af62c1STom Stellard MachinePostDominatorTree::getAnalysisUsage(AnalysisUsage &AU) const { 5086af62c1STom Stellard AU.setPreservesAll(); 5186af62c1STom Stellard MachineFunctionPass::getAnalysisUsage(AU); 5286af62c1STom Stellard } 5386af62c1STom Stellard 5486af62c1STom Stellard void 5586af62c1STom Stellard MachinePostDominatorTree::print(llvm::raw_ostream &OS, const Module *M) const { 5686af62c1STom Stellard DT->print(OS); 5786af62c1STom Stellard } 58