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 #define MLB class LoopBase<MachineBasicBlock, MachineLoop> 00023 TEMPLATE_INSTANTIATION(MLB); 00024 #undef MLB 00025 #define MLIB class LoopInfoBase<MachineBasicBlock, MachineLoop> 00026 TEMPLATE_INSTANTIATION(MLIB); 00027 #undef MLIB 00028 00029 char MachineLoopInfo::ID = 0; 00030 static RegisterPass<MachineLoopInfo> 00031 X("machine-loops", "Machine Natural Loop Construction", true); 00032 00033 const PassInfo *const llvm::MachineLoopInfoID = &X; 00034 00035 bool MachineLoopInfo::runOnMachineFunction(MachineFunction &) { 00036 releaseMemory(); 00037 LI.Calculate(getAnalysis<MachineDominatorTree>().getBase()); // Update 00038 return false; 00039 } 00040 00041 void MachineLoopInfo::getAnalysisUsage(AnalysisUsage &AU) const { 00042 AU.setPreservesAll(); 00043 AU.addRequired<MachineDominatorTree>(); 00044 MachineFunctionPass::getAnalysisUsage(AU); 00045 }