Tom Stellard | 86af62c | 2012-09-17 14:08:37 +0000 | [diff] [blame] | 1 | //===- MachinePostDominators.cpp -Machine Post Dominator Calculation ------===// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 |
Tom Stellard | 86af62c | 2012-09-17 14:08:37 +0000 | [diff] [blame] | 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 | |
Jakub Kuderski | b292c22 | 2017-07-14 18:26:09 +0000 | [diff] [blame] | 18 | namespace llvm { |
| 19 | template class DominatorTreeBase<MachineBasicBlock, true>; // PostDomTreeBase |
| 20 | } |
| 21 | |
Tom Stellard | 86af62c | 2012-09-17 14:08:37 +0000 | [diff] [blame] | 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()); |
Jakub Kuderski | b292c22 | 2017-07-14 18:26:09 +0000 | [diff] [blame] | 30 | DT = new PostDomTreeBase<MachineBasicBlock>(); |
Tom Stellard | 86af62c | 2012-09-17 14:08:37 +0000 | [diff] [blame] | 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 | } |