2003-10-13 05:32:08 +02:00
|
|
|
//===- LoopInfo.cpp - Natural Loop Calculator -----------------------------===//
|
2005-04-21 23:13:18 +02:00
|
|
|
//
|
2003-10-20 21:43:21 +02:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 21:36:04 +01:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 23:13:18 +02:00
|
|
|
//
|
2003-10-20 21:43:21 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
2001-11-26 19:41:20 +01:00
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2004-01-30 18:26:24 +01:00
|
|
|
#include "llvm/Analysis/LoopInfo.h"
|
2004-04-15 17:16:02 +02:00
|
|
|
#include "llvm/Constants.h"
|
|
|
|
#include "llvm/Instructions.h"
|
|
|
|
#include "llvm/Analysis/Dominators.h"
|
2002-07-27 03:12:17 +02:00
|
|
|
#include "llvm/Assembly/Writer.h"
|
2004-01-30 18:26:24 +01:00
|
|
|
#include "llvm/Support/CFG.h"
|
2006-11-28 23:46:12 +01:00
|
|
|
#include "llvm/Support/Streams.h"
|
2004-09-02 00:55:40 +02:00
|
|
|
#include "llvm/ADT/DepthFirstIterator.h"
|
2007-03-04 05:06:39 +01:00
|
|
|
#include "llvm/ADT/SmallPtrSet.h"
|
2001-11-26 19:41:20 +01:00
|
|
|
#include <algorithm>
|
2006-11-28 23:46:12 +01:00
|
|
|
#include <ostream>
|
2004-04-12 22:26:17 +02:00
|
|
|
using namespace llvm;
|
2003-11-11 23:41:34 +01:00
|
|
|
|
2007-05-03 03:11:54 +02:00
|
|
|
char LoopInfo::ID = 0;
|
2006-08-28 00:30:17 +02:00
|
|
|
static RegisterPass<LoopInfo>
|
2002-07-30 18:27:52 +02:00
|
|
|
X("loops", "Natural Loop Construction", true);
|
2002-01-31 01:42:27 +01:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
2002-04-28 18:21:30 +02:00
|
|
|
// Loop implementation
|
2002-01-31 01:42:27 +01:00
|
|
|
//
|
2002-10-11 07:31:10 +02:00
|
|
|
|
2003-10-13 00:14:27 +02:00
|
|
|
/// getNumBackEdges - Calculate the number of back edges to the loop header.
|
|
|
|
///
|
2003-02-22 22:33:11 +01:00
|
|
|
|
2002-01-31 01:42:27 +01:00
|
|
|
//===----------------------------------------------------------------------===//
|
2002-04-28 18:21:30 +02:00
|
|
|
// LoopInfo implementation
|
2002-01-31 01:42:27 +01:00
|
|
|
//
|
2002-06-25 18:13:24 +02:00
|
|
|
bool LoopInfo::runOnFunction(Function &) {
|
2002-04-09 07:43:19 +02:00
|
|
|
releaseMemory();
|
2007-11-27 04:43:35 +01:00
|
|
|
LI->Calculate(getAnalysis<DominatorTree>().getBase()); // Update
|
2002-01-31 01:42:27 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2002-04-28 18:21:30 +02:00
|
|
|
void LoopInfo::getAnalysisUsage(AnalysisUsage &AU) const {
|
2002-04-27 08:56:12 +02:00
|
|
|
AU.setPreservesAll();
|
2007-06-08 02:17:13 +02:00
|
|
|
AU.addRequired<DominatorTree>();
|
2002-01-31 01:42:27 +01:00
|
|
|
}
|
|
|
|
|
2006-06-08 00:00:26 +02:00
|
|
|
// Ensure this file gets linked when LoopInfo.h is used.
|
|
|
|
DEFINING_FILE_FOR(LoopInfo)
|