From 009b1c42aa6266385f2c37e227516b24077e6dd7 Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Tue, 2 Jun 2009 17:52:33 +0000 Subject: Import LLVM, at r72732. --- lib/Analysis/LoopInfo.cpp | 50 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 lib/Analysis/LoopInfo.cpp (limited to 'lib/Analysis/LoopInfo.cpp') diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp new file mode 100644 index 0000000000000..de6480a66d5bf --- /dev/null +++ b/lib/Analysis/LoopInfo.cpp @@ -0,0 +1,50 @@ +//===- LoopInfo.cpp - Natural Loop Calculator -----------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines the LoopInfo class that is used to identify natural loops +// and determine the loop depth of various nodes of the CFG. Note that the +// loops identified may actually be several natural loops that share the same +// header node... not just a single natural loop. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Analysis/LoopInfo.h" +#include "llvm/Constants.h" +#include "llvm/Instructions.h" +#include "llvm/Analysis/Dominators.h" +#include "llvm/Assembly/Writer.h" +#include "llvm/Support/CFG.h" +#include "llvm/Support/Streams.h" +#include "llvm/ADT/DepthFirstIterator.h" +#include "llvm/ADT/SmallPtrSet.h" +#include +#include +using namespace llvm; + +char LoopInfo::ID = 0; +static RegisterPass +X("loops", "Natural Loop Information", true, true); + +//===----------------------------------------------------------------------===// +// Loop implementation +// + +//===----------------------------------------------------------------------===// +// LoopInfo implementation +// +bool LoopInfo::runOnFunction(Function &) { + releaseMemory(); + LI->Calculate(getAnalysis().getBase()); // Update + return false; +} + +void LoopInfo::getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesAll(); + AU.addRequired(); +} -- cgit v1.2.3