LLVM API Documentation
00001 //===- MachineLoopInfo.cpp - Natural Loop Calculator ----------------------===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file defines the MachineLoopInfo class that is used to identify natural 00011 // loops and determine the loop depth of various nodes of the CFG. Note that 00012 // the loops identified may actually be several natural loops that share the 00013 // same header node... not just a single natural loop. 00014 // 00015 //===----------------------------------------------------------------------===// 00016 00017 #include "llvm/CodeGen/MachineLoopInfo.h" 00018 #include "llvm/CodeGen/MachineDominators.h" 00019 #include "llvm/CodeGen/Passes.h" 00020 using namespace llvm; 00021 00022 TEMPLATE_INSTANTIATION(class LoopBase<MachineBasicBlock>); 00023 TEMPLATE_INSTANTIATION(class LoopInfoBase<MachineBasicBlock>); 00024 00025 char MachineLoopInfo::ID = 0; 00026 static RegisterPass<MachineLoopInfo> 00027 X("machine-loops", "Machine Natural Loop Construction", true); 00028 00029 const PassInfo *const llvm::MachineLoopInfoID = &X; 00030 00031 bool MachineLoopInfo::runOnMachineFunction(MachineFunction &) { 00032 releaseMemory(); 00033 LI->Calculate(getAnalysis<MachineDominatorTree>().getBase()); // Update 00034 return false; 00035 } 00036 00037 void MachineLoopInfo::getAnalysisUsage(AnalysisUsage &AU) const { 00038 AU.setPreservesAll(); 00039 AU.addRequired<MachineDominatorTree>(); 00040 }