blob: 8f3e6baf5c57596f06ec714dfcb8928a71aed996 [file] [log] [blame]
Andreas Bolka306b5b22009-06-24 21:29:13 +00001//===- LoopDependenceAnalysis.cpp - LDA Implementation ----------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This is the (beginning) of an implementation of a loop dependence analysis
11// framework, which is used to detect dependences in memory accesses in loops.
12//
13// Please note that this is work in progress and the interface is subject to
14// change.
15//
16// TODO: adapt as implementation progresses.
17//
18//===----------------------------------------------------------------------===//
19
20#define DEBUG_TYPE "lda"
21#include "llvm/Analysis/LoopDependenceAnalysis.h"
22#include "llvm/Analysis/LoopPass.h"
23#include "llvm/Analysis/ScalarEvolution.h"
24using namespace llvm;
25
26LoopPass *llvm::createLoopDependenceAnalysisPass() {
27 return new LoopDependenceAnalysis();
28}
29
30static RegisterPass<LoopDependenceAnalysis>
31R("lda", "Loop Dependence Analysis", false, true);
32char LoopDependenceAnalysis::ID = 0;
33
34//===----------------------------------------------------------------------===//
35// LoopDependenceAnalysis Implementation
36//===----------------------------------------------------------------------===//
37
38bool LoopDependenceAnalysis::runOnLoop(Loop *L, LPPassManager &) {
39 this->L = L;
40 SE = &getAnalysis<ScalarEvolution>();
41 return false;
42}
43
44void LoopDependenceAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
45 AU.setPreservesAll();
Andreas Bolkab88ee912009-06-28 00:16:08 +000046 AU.addRequiredTransitive<ScalarEvolution>();
47}
48
49static void PrintLoopInfo(
50 raw_ostream &OS, const LoopDependenceAnalysis *LDA, const Loop *L) {
51 if (!L->empty()) return; // ignore non-innermost loops
52
53 OS << "Loop at depth " << L->getLoopDepth() << ", header block: ";
54 WriteAsOperand(OS, L->getHeader(), false);
55 OS << "\n";
56}
57
58void LoopDependenceAnalysis::print(raw_ostream &OS, const Module*) const {
59 PrintLoopInfo(OS, this, this->L);
60}
61
62void LoopDependenceAnalysis::print(std::ostream &OS, const Module *M) const {
63 raw_os_ostream os(OS);
64 print(os, M);
Andreas Bolka306b5b22009-06-24 21:29:13 +000065}