blob: 37c86019d4a22182a629d34c7144b748dbe64361 [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
20TEMPLATE_INSTANTIATION(class DomTreeNodeBase<MachineBasicBlock>);
21TEMPLATE_INSTANTIATION(class DominatorTreeBase<MachineBasicBlock>);
22
Chris Lattner54b62f32008-01-05 20:15:42 +000023char MachineDominatorTree::ID = 0;
24
Dan Gohman844731a2008-05-13 00:00:25 +000025static RegisterPass<MachineDominatorTree>
26E("machinedomtree", "MachineDominator Tree Construction", true);
Bill Wendling67d65bb2008-01-04 20:54:55 +000027
Dan Gohman6ddba2b2008-05-13 02:05:11 +000028const PassInfo *const llvm::MachineDominatorsID = &E;
Dan Gohmand68a0762009-01-05 17:59:02 +000029
30void MachineDominatorTree::getAnalysisUsage(AnalysisUsage &AU) const {
31 AU.setPreservesAll();
32 MachineFunctionPass::getAnalysisUsage(AU);
33}
34
35bool MachineDominatorTree::runOnMachineFunction(MachineFunction &F) {
36 DT->recalculate(F);
37
38 return false;
39}
40
41MachineDominatorTree::MachineDominatorTree()
Dan Gohman865f0062009-02-18 05:09:16 +000042 : MachineFunctionPass(&ID) {
Dan Gohmand68a0762009-01-05 17:59:02 +000043 DT = new DominatorTreeBase<MachineBasicBlock>(false);
44}
45
46MachineDominatorTree::~MachineDominatorTree() {
47 DT->releaseMemory();
48 delete DT;
49}
50
51void MachineDominatorTree::releaseMemory() {
52 DT->releaseMemory();
53}