blob: f7820484376c0eb3c6855bf17375e0b3d5f7821b [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
20TEMPLATE_INSTANTIATION(class DomTreeNodeBase<MachineBasicBlock>);
21TEMPLATE_INSTANTIATION(class DominatorTreeBase<MachineBasicBlock>);
22
Chris Lattnercd8a3842008-01-05 20:15:42 +000023char MachineDominatorTree::ID = 0;
24
Dan Gohman089efff2008-05-13 00:00:25 +000025static RegisterPass<MachineDominatorTree>
26E("machinedomtree", "MachineDominator Tree Construction", true);
Bill Wendling62264362008-01-04 20:54:55 +000027
Dan Gohman66a636e2008-05-13 02:05:11 +000028const PassInfo *const llvm::MachineDominatorsID = &E;
Dan Gohmanc24a3f82009-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()
42 : MachineFunctionPass(intptr_t(&ID)) {
43 DT = new DominatorTreeBase<MachineBasicBlock>(false);
44}
45
46MachineDominatorTree::~MachineDominatorTree() {
47 DT->releaseMemory();
48 delete DT;
49}
50
51void MachineDominatorTree::releaseMemory() {
52 DT->releaseMemory();
53}