blob: 408873903b0d96b17ca7495a844a3fda47c424c3 [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
Dan Gohman6ddba2b2008-05-13 02:05:11 +000030const PassInfo *const llvm::MachineDominatorsID = &E;
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()
Dan Gohman865f0062009-02-18 05:09:16 +000044 : MachineFunctionPass(&ID) {
Dan Gohmand68a0762009-01-05 17:59:02 +000045 DT = new DominatorTreeBase<MachineBasicBlock>(false);
46}
47
48MachineDominatorTree::~MachineDominatorTree() {
49 DT->releaseMemory();
50 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}