blob: 36c9d66965a3a8cd64d74656dca4570164ab9dd4 [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
Dan Gohman844731a2008-05-13 00:00:25 +000027static RegisterPass<MachineDominatorTree>
28E("machinedomtree", "MachineDominator Tree Construction", 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) {
Dan Gohmand68a0762009-01-05 17:59:02 +000045 DT = new DominatorTreeBase<MachineBasicBlock>(false);
46}
47
48MachineDominatorTree::~MachineDominatorTree() {
Dan Gohmand68a0762009-01-05 17:59:02 +000049 delete DT;
50}
51
52void MachineDominatorTree::releaseMemory() {
53 DT->releaseMemory();
54}
Chris Lattner791102f2009-08-23 05:17:37 +000055
Chris Lattner45cfe542009-08-23 06:03:38 +000056void MachineDominatorTree::print(raw_ostream &OS, const Module*) const {
57 DT->print(OS);
Chris Lattner791102f2009-08-23 05:17:37 +000058}