186af62c1STom Stellard //===- MachinePostDominators.cpp -Machine Post Dominator Calculation ------===//
286af62c1STom Stellard //
386af62c1STom Stellard //                     The LLVM Compiler Infrastructure
486af62c1STom Stellard //
586af62c1STom Stellard // This file is distributed under the University of Illinois Open Source
686af62c1STom Stellard // License. See LICENSE.TXT for details.
786af62c1STom Stellard //
886af62c1STom Stellard //===----------------------------------------------------------------------===//
986af62c1STom Stellard //
1086af62c1STom Stellard // This file implements simple dominator construction algorithms for finding
1186af62c1STom Stellard // post dominators on machine functions.
1286af62c1STom Stellard //
1386af62c1STom Stellard //===----------------------------------------------------------------------===//
1486af62c1STom Stellard 
1586af62c1STom Stellard #include "llvm/CodeGen/MachinePostDominators.h"
1686af62c1STom Stellard 
1786af62c1STom Stellard using namespace llvm;
1886af62c1STom Stellard 
19*b292c22cSJakub Kuderski namespace llvm {
20*b292c22cSJakub Kuderski template class DominatorTreeBase<MachineBasicBlock, true>; // PostDomTreeBase
21*b292c22cSJakub Kuderski }
22*b292c22cSJakub Kuderski 
2386af62c1STom Stellard char MachinePostDominatorTree::ID = 0;
2486af62c1STom Stellard 
2586af62c1STom Stellard //declare initializeMachinePostDominatorTreePass
2686af62c1STom Stellard INITIALIZE_PASS(MachinePostDominatorTree, "machinepostdomtree",
2786af62c1STom Stellard                 "MachinePostDominator Tree Construction", true, true)
2886af62c1STom Stellard 
2986af62c1STom Stellard MachinePostDominatorTree::MachinePostDominatorTree() : MachineFunctionPass(ID) {
3086af62c1STom Stellard   initializeMachinePostDominatorTreePass(*PassRegistry::getPassRegistry());
31*b292c22cSJakub Kuderski   DT = new PostDomTreeBase<MachineBasicBlock>();
3286af62c1STom Stellard }
3386af62c1STom Stellard 
3486af62c1STom Stellard FunctionPass *
3586af62c1STom Stellard MachinePostDominatorTree::createMachinePostDominatorTreePass() {
3686af62c1STom Stellard   return new MachinePostDominatorTree();
3786af62c1STom Stellard }
3886af62c1STom Stellard 
3986af62c1STom Stellard bool
4086af62c1STom Stellard MachinePostDominatorTree::runOnMachineFunction(MachineFunction &F) {
4186af62c1STom Stellard   DT->recalculate(F);
4286af62c1STom Stellard   return false;
4386af62c1STom Stellard }
4486af62c1STom Stellard 
4586af62c1STom Stellard MachinePostDominatorTree::~MachinePostDominatorTree() {
4686af62c1STom Stellard   delete DT;
4786af62c1STom Stellard }
4886af62c1STom Stellard 
4986af62c1STom Stellard void
5086af62c1STom Stellard MachinePostDominatorTree::getAnalysisUsage(AnalysisUsage &AU) const {
5186af62c1STom Stellard   AU.setPreservesAll();
5286af62c1STom Stellard   MachineFunctionPass::getAnalysisUsage(AU);
5386af62c1STom Stellard }
5486af62c1STom Stellard 
5586af62c1STom Stellard void
5686af62c1STom Stellard MachinePostDominatorTree::print(llvm::raw_ostream &OS, const Module *M) const {
5786af62c1STom Stellard   DT->print(OS);
5886af62c1STom Stellard }
59