Andreas Bolka | 306b5b2 | 2009-06-24 21:29:13 +0000 | [diff] [blame] | 1 | //===- 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" |
| 24 | using namespace llvm; |
| 25 | |
| 26 | LoopPass *llvm::createLoopDependenceAnalysisPass() { |
| 27 | return new LoopDependenceAnalysis(); |
| 28 | } |
| 29 | |
| 30 | static RegisterPass<LoopDependenceAnalysis> |
| 31 | R("lda", "Loop Dependence Analysis", false, true); |
| 32 | char LoopDependenceAnalysis::ID = 0; |
| 33 | |
| 34 | //===----------------------------------------------------------------------===// |
| 35 | // LoopDependenceAnalysis Implementation |
| 36 | //===----------------------------------------------------------------------===// |
| 37 | |
| 38 | bool LoopDependenceAnalysis::runOnLoop(Loop *L, LPPassManager &) { |
| 39 | this->L = L; |
| 40 | SE = &getAnalysis<ScalarEvolution>(); |
| 41 | return false; |
| 42 | } |
| 43 | |
| 44 | void LoopDependenceAnalysis::getAnalysisUsage(AnalysisUsage &AU) const { |
| 45 | AU.setPreservesAll(); |
Andreas Bolka | b88ee91 | 2009-06-28 00:16:08 +0000 | [diff] [blame^] | 46 | AU.addRequiredTransitive<ScalarEvolution>(); |
| 47 | } |
| 48 | |
| 49 | static 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 | |
| 58 | void LoopDependenceAnalysis::print(raw_ostream &OS, const Module*) const { |
| 59 | PrintLoopInfo(OS, this, this->L); |
| 60 | } |
| 61 | |
| 62 | void LoopDependenceAnalysis::print(std::ostream &OS, const Module *M) const { |
| 63 | raw_os_ostream os(OS); |
| 64 | print(os, M); |
Andreas Bolka | 306b5b2 | 2009-06-24 21:29:13 +0000 | [diff] [blame] | 65 | } |