Owen Anderson | 5d32ec4 | 2007-10-31 03:30:14 +0000 | [diff] [blame] | 1 | //===- MachineDominators.cpp - Machine Dominator Calculation --------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Owen Anderson | 5d32ec4 | 2007-10-31 03:30:14 +0000 | [diff] [blame] | 7 | // |
| 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 Wendling | 67d65bb | 2008-01-04 20:54:55 +0000 | [diff] [blame] | 16 | #include "llvm/CodeGen/Passes.h" |
Owen Anderson | 5d32ec4 | 2007-10-31 03:30:14 +0000 | [diff] [blame] | 17 | |
| 18 | using namespace llvm; |
| 19 | |
| 20 | TEMPLATE_INSTANTIATION(class DomTreeNodeBase<MachineBasicBlock>); |
| 21 | TEMPLATE_INSTANTIATION(class DominatorTreeBase<MachineBasicBlock>); |
| 22 | |
Chris Lattner | 54b62f3 | 2008-01-05 20:15:42 +0000 | [diff] [blame] | 23 | char MachineDominatorTree::ID = 0; |
| 24 | |
Dan Gohman | 844731a | 2008-05-13 00:00:25 +0000 | [diff] [blame] | 25 | static RegisterPass<MachineDominatorTree> |
| 26 | E("machinedomtree", "MachineDominator Tree Construction", true); |
Bill Wendling | 67d65bb | 2008-01-04 20:54:55 +0000 | [diff] [blame] | 27 | |
Dan Gohman | 6ddba2b | 2008-05-13 02:05:11 +0000 | [diff] [blame] | 28 | const PassInfo *const llvm::MachineDominatorsID = &E; |
Dan Gohman | d68a076 | 2009-01-05 17:59:02 +0000 | [diff] [blame] | 29 | |
| 30 | void MachineDominatorTree::getAnalysisUsage(AnalysisUsage &AU) const { |
| 31 | AU.setPreservesAll(); |
| 32 | MachineFunctionPass::getAnalysisUsage(AU); |
| 33 | } |
| 34 | |
| 35 | bool MachineDominatorTree::runOnMachineFunction(MachineFunction &F) { |
| 36 | DT->recalculate(F); |
| 37 | |
| 38 | return false; |
| 39 | } |
| 40 | |
| 41 | MachineDominatorTree::MachineDominatorTree() |
Dan Gohman | 865f006 | 2009-02-18 05:09:16 +0000 | [diff] [blame] | 42 | : MachineFunctionPass(&ID) { |
Dan Gohman | d68a076 | 2009-01-05 17:59:02 +0000 | [diff] [blame] | 43 | DT = new DominatorTreeBase<MachineBasicBlock>(false); |
| 44 | } |
| 45 | |
| 46 | MachineDominatorTree::~MachineDominatorTree() { |
| 47 | DT->releaseMemory(); |
| 48 | delete DT; |
| 49 | } |
| 50 | |
| 51 | void MachineDominatorTree::releaseMemory() { |
| 52 | DT->releaseMemory(); |
| 53 | } |