2009-06-24 21:29:13 +00:00
|
|
|
//===- llvm/Analysis/LoopDependenceAnalysis.h --------------- -*- C++ -*---===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// LoopDependenceAnalysis is an LLVM pass that analyses dependences in memory
|
|
|
|
// accesses in loops.
|
|
|
|
//
|
|
|
|
// Please note that this is work in progress and the interface is subject to
|
|
|
|
// change.
|
|
|
|
//
|
|
|
|
// TODO: adapt as interface progresses
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_ANALYSIS_LOOP_DEPENDENCE_ANALYSIS_H
|
|
|
|
#define LLVM_ANALYSIS_LOOP_DEPENDENCE_ANALYSIS_H
|
|
|
|
|
2009-07-23 14:32:46 +00:00
|
|
|
#include "llvm/ADT/FoldingSet.h"
|
2009-06-24 21:29:13 +00:00
|
|
|
#include "llvm/Analysis/LoopPass.h"
|
2009-07-23 14:32:46 +00:00
|
|
|
#include "llvm/Support/Allocator.h"
|
2009-06-28 00:16:08 +00:00
|
|
|
#include <iosfwd>
|
2009-06-24 21:29:13 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2009-07-23 01:57:06 +00:00
|
|
|
class AliasAnalysis;
|
|
|
|
class AnalysisUsage;
|
|
|
|
class ScalarEvolution;
|
|
|
|
class Value;
|
2009-07-24 23:19:28 +00:00
|
|
|
class raw_ostream;
|
2009-06-24 21:29:13 +00:00
|
|
|
|
2009-07-23 01:57:06 +00:00
|
|
|
class LoopDependenceAnalysis : public LoopPass {
|
|
|
|
AliasAnalysis *AA;
|
|
|
|
ScalarEvolution *SE;
|
2009-06-24 21:29:13 +00:00
|
|
|
|
2009-07-23 14:32:46 +00:00
|
|
|
/// L - The loop we are currently analysing.
|
|
|
|
Loop *L;
|
|
|
|
|
|
|
|
/// TODO: doc
|
|
|
|
enum DependenceResult { Independent = 0, Dependent = 1, Unknown = 2 };
|
|
|
|
|
|
|
|
/// DependencePair - Represents a data dependence relation between to memory
|
|
|
|
/// reference instructions.
|
|
|
|
///
|
|
|
|
/// TODO: add subscripts vector
|
|
|
|
struct DependencePair : public FastFoldingSetNode {
|
|
|
|
Value *A;
|
|
|
|
Value *B;
|
|
|
|
DependenceResult Result;
|
|
|
|
|
|
|
|
DependencePair(const FoldingSetNodeID &ID, Value *a, Value *b) :
|
|
|
|
FastFoldingSetNode(ID), A(a), B(b), Result(Unknown) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// findOrInsertDependencePair - Return true if a DependencePair for the
|
|
|
|
/// given Values already exists, false if a new DependencePair had to be
|
|
|
|
/// created. The third argument is set to the pair found or created.
|
|
|
|
bool findOrInsertDependencePair(Value*, Value*, DependencePair*&);
|
|
|
|
|
|
|
|
/// TODO: doc
|
|
|
|
void analysePair(DependencePair *P) const;
|
|
|
|
|
2009-07-23 01:57:06 +00:00
|
|
|
public:
|
|
|
|
static char ID; // Class identification, replacement for typeinfo
|
|
|
|
LoopDependenceAnalysis() : LoopPass(&ID) {}
|
2009-06-24 21:29:13 +00:00
|
|
|
|
2009-07-23 14:32:46 +00:00
|
|
|
/// isDependencePair - Check wether two values can possibly give rise to a
|
|
|
|
/// data dependence: that is the case if both are instructions accessing
|
|
|
|
/// memory and at least one of those accesses is a write.
|
2009-07-23 01:57:06 +00:00
|
|
|
bool isDependencePair(const Value*, const Value*) const;
|
2009-07-23 14:32:46 +00:00
|
|
|
|
|
|
|
/// depends - Return a boolean indicating if there is a data dependence
|
|
|
|
/// between two instructions.
|
2009-07-23 01:57:06 +00:00
|
|
|
bool depends(Value*, Value*);
|
2009-06-28 00:21:21 +00:00
|
|
|
|
2009-07-23 01:57:06 +00:00
|
|
|
bool runOnLoop(Loop*, LPPassManager&);
|
2009-07-23 14:32:46 +00:00
|
|
|
virtual void releaseMemory();
|
2009-07-23 01:57:06 +00:00
|
|
|
virtual void getAnalysisUsage(AnalysisUsage&) const;
|
|
|
|
void print(raw_ostream&, const Module* = 0) const;
|
|
|
|
virtual void print(std::ostream&, const Module* = 0) const;
|
2009-07-23 14:32:46 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
FoldingSet<DependencePair> Pairs;
|
|
|
|
BumpPtrAllocator PairAllocator;
|
2009-07-23 01:57:06 +00:00
|
|
|
}; // class LoopDependenceAnalysis
|
2009-06-24 21:29:13 +00:00
|
|
|
|
|
|
|
|
2009-07-23 01:57:06 +00:00
|
|
|
// createLoopDependenceAnalysisPass - This creates an instance of the
|
|
|
|
// LoopDependenceAnalysis pass.
|
|
|
|
//
|
|
|
|
LoopPass *createLoopDependenceAnalysisPass();
|
2009-06-24 21:29:13 +00:00
|
|
|
|
|
|
|
} // namespace llvm
|
|
|
|
|
|
|
|
#endif /* LLVM_ANALYSIS_LOOP_DEPENDENCE_ANALYSIS_H */
|