blob: 3c674789244a2dbe71ba3d4b66118e1a98d87fc4 [file] [log] [blame]
Owen Anderson9b8f34f2007-10-31 03:30:14 +00001//===- MachineDominators.cpp - Machine Dominator Calculation --------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-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 Anderson9b8f34f2007-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 Wendling0c209432008-01-04 20:54:55 +000016#include "llvm/CodeGen/Passes.h"
Owen Anderson9b8f34f2007-10-31 03:30:14 +000017
18using namespace llvm;
19
John McCall323c30c2009-12-16 00:13:24 +000020namespace llvm {
Owen Anderson9b8f34f2007-10-31 03:30:14 +000021TEMPLATE_INSTANTIATION(class DomTreeNodeBase<MachineBasicBlock>);
22TEMPLATE_INSTANTIATION(class DominatorTreeBase<MachineBasicBlock>);
John McCall323c30c2009-12-16 00:13:24 +000023}
Owen Anderson9b8f34f2007-10-31 03:30:14 +000024
Chris Lattner647e61a2008-01-05 20:15:42 +000025char MachineDominatorTree::ID = 0;
26
Owen Andersond31d82d2010-08-23 17:52:01 +000027INITIALIZE_PASS(MachineDominatorTree, "machinedomtree",
28 "MachineDominator Tree Construction", true, true);
Bill Wendling0c209432008-01-04 20:54:55 +000029
Owen Andersona7aed182010-08-06 18:33:48 +000030char &llvm::MachineDominatorsID = MachineDominatorTree::ID;
Dan Gohman906152a2009-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 Andersona7aed182010-08-06 18:33:48 +000044 : MachineFunctionPass(ID) {
Dan Gohman906152a2009-01-05 17:59:02 +000045 DT = new DominatorTreeBase<MachineBasicBlock>(false);
46}
47
48MachineDominatorTree::~MachineDominatorTree() {
Dan Gohman906152a2009-01-05 17:59:02 +000049 delete DT;
50}
51
52void MachineDominatorTree::releaseMemory() {
53 DT->releaseMemory();
54}
Chris Lattnerb1d782b2009-08-23 05:17:37 +000055
Chris Lattner13626022009-08-23 06:03:38 +000056void MachineDominatorTree::print(raw_ostream &OS, const Module*) const {
57 DT->print(OS);
Chris Lattnerb1d782b2009-08-23 05:17:37 +000058}