blob: 408873903b0d96b17ca7495a844a3fda47c424c3 [file] [log] [blame]
Owen Anderson444710d2007-10-31 03:30:14 +00001//===- MachineDominators.cpp - Machine Dominator Calculation --------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-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 Anderson444710d2007-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 Wendling62264362008-01-04 20:54:55 +000016#include "llvm/CodeGen/Passes.h"
Owen Anderson444710d2007-10-31 03:30:14 +000017
18using namespace llvm;
19
John McCall86dd20e2009-12-16 00:13:24 +000020namespace llvm {
Owen Anderson444710d2007-10-31 03:30:14 +000021TEMPLATE_INSTANTIATION(class DomTreeNodeBase<MachineBasicBlock>);
22TEMPLATE_INSTANTIATION(class DominatorTreeBase<MachineBasicBlock>);
John McCall86dd20e2009-12-16 00:13:24 +000023}
Owen Anderson444710d2007-10-31 03:30:14 +000024
Chris Lattnercd8a3842008-01-05 20:15:42 +000025char MachineDominatorTree::ID = 0;
26
Dan Gohman089efff2008-05-13 00:00:25 +000027static RegisterPass<MachineDominatorTree>
28E("machinedomtree", "MachineDominator Tree Construction", true);
Bill Wendling62264362008-01-04 20:54:55 +000029
Dan Gohman66a636e2008-05-13 02:05:11 +000030const PassInfo *const llvm::MachineDominatorsID = &E;
Dan Gohmanc24a3f82009-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 Gohmanc74a1972009-02-18 05:09:16 +000044 : MachineFunctionPass(&ID) {
Dan Gohmanc24a3f82009-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 Lattnera7a9daa2009-08-23 05:17:37 +000056
Chris Lattner397f4562009-08-23 06:03:38 +000057void MachineDominatorTree::print(raw_ostream &OS, const Module*) const {
58 DT->print(OS);
Chris Lattnera7a9daa2009-08-23 05:17:37 +000059}