blob: 7f220ed1fd8f33c98158ce6636f2b8178adf20dc [file] [log] [blame]
Tom Stellard86af62c2012-09-17 14:08:37 +00001//===- MachinePostDominators.cpp -Machine Post Dominator Calculation ------===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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 Stellard86af62c2012-09-17 14:08:37 +00006//
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
16using namespace llvm;
17
Jakub Kuderskib292c222017-07-14 18:26:09 +000018namespace llvm {
19template class DominatorTreeBase<MachineBasicBlock, true>; // PostDomTreeBase
20}
21
Tom Stellard86af62c2012-09-17 14:08:37 +000022char MachinePostDominatorTree::ID = 0;
23
24//declare initializeMachinePostDominatorTreePass
25INITIALIZE_PASS(MachinePostDominatorTree, "machinepostdomtree",
26 "MachinePostDominator Tree Construction", true, true)
27
28MachinePostDominatorTree::MachinePostDominatorTree() : MachineFunctionPass(ID) {
29 initializeMachinePostDominatorTreePass(*PassRegistry::getPassRegistry());
Jakub Kuderskib292c222017-07-14 18:26:09 +000030 DT = new PostDomTreeBase<MachineBasicBlock>();
Tom Stellard86af62c2012-09-17 14:08:37 +000031}
32
33FunctionPass *
34MachinePostDominatorTree::createMachinePostDominatorTreePass() {
35 return new MachinePostDominatorTree();
36}
37
38bool
39MachinePostDominatorTree::runOnMachineFunction(MachineFunction &F) {
40 DT->recalculate(F);
41 return false;
42}
43
44MachinePostDominatorTree::~MachinePostDominatorTree() {
45 delete DT;
46}
47
48void
49MachinePostDominatorTree::getAnalysisUsage(AnalysisUsage &AU) const {
50 AU.setPreservesAll();
51 MachineFunctionPass::getAnalysisUsage(AU);
52}
53
54void
55MachinePostDominatorTree::print(llvm::raw_ostream &OS, const Module *M) const {
56 DT->print(OS);
57}