xref: /freebsd/contrib/llvm-project/llvm/lib/CodeGen/MachinePostDominators.cpp (revision 0b57cec536236d46e3dba9bd041533462f33dbb7)
1*0b57cec5SDimitry Andric //===- MachinePostDominators.cpp -Machine Post Dominator Calculation ------===//
2*0b57cec5SDimitry Andric //
3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*0b57cec5SDimitry Andric //
7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
8*0b57cec5SDimitry Andric //
9*0b57cec5SDimitry Andric // This file implements simple dominator construction algorithms for finding
10*0b57cec5SDimitry Andric // post dominators on machine functions.
11*0b57cec5SDimitry Andric //
12*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
13*0b57cec5SDimitry Andric 
14*0b57cec5SDimitry Andric #include "llvm/CodeGen/MachinePostDominators.h"
15*0b57cec5SDimitry Andric 
16*0b57cec5SDimitry Andric using namespace llvm;
17*0b57cec5SDimitry Andric 
18*0b57cec5SDimitry Andric namespace llvm {
19*0b57cec5SDimitry Andric template class DominatorTreeBase<MachineBasicBlock, true>; // PostDomTreeBase
20*0b57cec5SDimitry Andric }
21*0b57cec5SDimitry Andric 
22*0b57cec5SDimitry Andric char MachinePostDominatorTree::ID = 0;
23*0b57cec5SDimitry Andric 
24*0b57cec5SDimitry Andric //declare initializeMachinePostDominatorTreePass
25*0b57cec5SDimitry Andric INITIALIZE_PASS(MachinePostDominatorTree, "machinepostdomtree",
26*0b57cec5SDimitry Andric                 "MachinePostDominator Tree Construction", true, true)
27*0b57cec5SDimitry Andric 
28*0b57cec5SDimitry Andric MachinePostDominatorTree::MachinePostDominatorTree() : MachineFunctionPass(ID) {
29*0b57cec5SDimitry Andric   initializeMachinePostDominatorTreePass(*PassRegistry::getPassRegistry());
30*0b57cec5SDimitry Andric   DT = new PostDomTreeBase<MachineBasicBlock>();
31*0b57cec5SDimitry Andric }
32*0b57cec5SDimitry Andric 
33*0b57cec5SDimitry Andric FunctionPass *
34*0b57cec5SDimitry Andric MachinePostDominatorTree::createMachinePostDominatorTreePass() {
35*0b57cec5SDimitry Andric   return new MachinePostDominatorTree();
36*0b57cec5SDimitry Andric }
37*0b57cec5SDimitry Andric 
38*0b57cec5SDimitry Andric bool
39*0b57cec5SDimitry Andric MachinePostDominatorTree::runOnMachineFunction(MachineFunction &F) {
40*0b57cec5SDimitry Andric   DT->recalculate(F);
41*0b57cec5SDimitry Andric   return false;
42*0b57cec5SDimitry Andric }
43*0b57cec5SDimitry Andric 
44*0b57cec5SDimitry Andric MachinePostDominatorTree::~MachinePostDominatorTree() {
45*0b57cec5SDimitry Andric   delete DT;
46*0b57cec5SDimitry Andric }
47*0b57cec5SDimitry Andric 
48*0b57cec5SDimitry Andric void
49*0b57cec5SDimitry Andric MachinePostDominatorTree::getAnalysisUsage(AnalysisUsage &AU) const {
50*0b57cec5SDimitry Andric   AU.setPreservesAll();
51*0b57cec5SDimitry Andric   MachineFunctionPass::getAnalysisUsage(AU);
52*0b57cec5SDimitry Andric }
53*0b57cec5SDimitry Andric 
54*0b57cec5SDimitry Andric void
55*0b57cec5SDimitry Andric MachinePostDominatorTree::print(llvm::raw_ostream &OS, const Module *M) const {
56*0b57cec5SDimitry Andric   DT->print(OS);
57*0b57cec5SDimitry Andric }
58