blob: 04c8ecbf9bdc1e1e236faef8c456d50a1517fa9e [file] [log] [blame]
Owen Anderson5d32ec42007-10-31 03:30:14 +00001//===- MachineDominators.cpp - Machine Dominator Calculation --------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Owen Anderson5d32ec42007-10-31 03:30:14 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file implements simple dominator construction algorithms for finding
11// forward dominators on machine functions.
12//
13//===----------------------------------------------------------------------===//
14
15#include "llvm/CodeGen/MachineDominators.h"
Bill Wendling67d65bb2008-01-04 20:54:55 +000016#include "llvm/CodeGen/Passes.h"
Owen Anderson5d32ec42007-10-31 03:30:14 +000017
18using namespace llvm;
19
John McCallf32616e2009-12-16 00:13:24 +000020namespace llvm {
Owen Anderson5d32ec42007-10-31 03:30:14 +000021TEMPLATE_INSTANTIATION(class DomTreeNodeBase<MachineBasicBlock>);
22TEMPLATE_INSTANTIATION(class DominatorTreeBase<MachineBasicBlock>);
John McCallf32616e2009-12-16 00:13:24 +000023}
Owen Anderson5d32ec42007-10-31 03:30:14 +000024
Chris Lattner54b62f32008-01-05 20:15:42 +000025char MachineDominatorTree::ID = 0;
26
Owen Anderson02dd53e2010-08-23 17:52:01 +000027INITIALIZE_PASS(MachineDominatorTree, "machinedomtree",
Owen Andersonce665bd2010-10-07 22:25:06 +000028 "MachineDominator Tree Construction", true, true)
Bill Wendling67d65bb2008-01-04 20:54:55 +000029
Owen Anderson90c579d2010-08-06 18:33:48 +000030char &llvm::MachineDominatorsID = MachineDominatorTree::ID;
Dan Gohmand68a0762009-01-05 17:59:02 +000031
32void MachineDominatorTree::getAnalysisUsage(AnalysisUsage &AU) const {
33 AU.setPreservesAll();
34 MachineFunctionPass::getAnalysisUsage(AU);
35}
36
37bool MachineDominatorTree::runOnMachineFunction(MachineFunction &F) {
38 DT->recalculate(F);
39
40 return false;
41}
42
43MachineDominatorTree::MachineDominatorTree()
Owen Anderson90c579d2010-08-06 18:33:48 +000044 : MachineFunctionPass(ID) {
Owen Anderson081c34b2010-10-19 17:21:58 +000045 initializeMachineDominatorTreePass(*PassRegistry::getPassRegistry());
Dan Gohmand68a0762009-01-05 17:59:02 +000046 DT = new DominatorTreeBase<MachineBasicBlock>(false);
47}
48
49MachineDominatorTree::~MachineDominatorTree() {
Dan Gohmand68a0762009-01-05 17:59:02 +000050 delete DT;
51}
52
53void MachineDominatorTree::releaseMemory() {
54 DT->releaseMemory();
55}
Chris Lattner791102f2009-08-23 05:17:37 +000056
Chris Lattner45cfe542009-08-23 06:03:38 +000057void MachineDominatorTree::print(raw_ostream &OS, const Module*) const {
58 DT->print(OS);
Chris Lattner791102f2009-08-23 05:17:37 +000059}