diff --git a/llvm/include/llvm/Analysis/LoopDependenceAnalysis.h b/llvm/include/llvm/Analysis/LoopDependenceAnalysis.h index 0c3dadea75fc..bde426ba9a88 100644 --- a/llvm/include/llvm/Analysis/LoopDependenceAnalysis.h +++ b/llvm/include/llvm/Analysis/LoopDependenceAnalysis.h @@ -28,6 +28,7 @@ namespace llvm { class AnalysisUsage; class ScalarEvolution; + class Value; class LoopDependenceAnalysis : public LoopPass { Loop *L; @@ -37,6 +38,10 @@ namespace llvm { static char ID; // Class identification, replacement for typeinfo LoopDependenceAnalysis() : LoopPass(&ID) {} + /// TODO: docs + bool isDependencePair(const Value*, const Value*) const; + bool depends(Value*, Value*); + bool runOnLoop(Loop*, LPPassManager&); virtual void getAnalysisUsage(AnalysisUsage&) const; diff --git a/llvm/lib/Analysis/LoopDependenceAnalysis.cpp b/llvm/lib/Analysis/LoopDependenceAnalysis.cpp index 8f3e6baf5c57..b23459e81ac7 100644 --- a/llvm/lib/Analysis/LoopDependenceAnalysis.cpp +++ b/llvm/lib/Analysis/LoopDependenceAnalysis.cpp @@ -21,6 +21,7 @@ #include "llvm/Analysis/LoopDependenceAnalysis.h" #include "llvm/Analysis/LoopPass.h" #include "llvm/Analysis/ScalarEvolution.h" +#include "llvm/Instructions.h" using namespace llvm; LoopPass *llvm::createLoopDependenceAnalysisPass() { @@ -31,6 +32,29 @@ static RegisterPass R("lda", "Loop Dependence Analysis", false, true); char LoopDependenceAnalysis::ID = 0; +//===----------------------------------------------------------------------===// +// Utility Functions +//===----------------------------------------------------------------------===// + +static inline bool isMemRefInstr(const Value *I) { + return isa(I) || isa(I); +} + +//===----------------------------------------------------------------------===// +// Dependence Testing +//===----------------------------------------------------------------------===// + +bool LoopDependenceAnalysis::isDependencePair(const Value *x, + const Value *y) const { + return isMemRefInstr(x) && isMemRefInstr(y) + && (isa(x) || isa(y)); +} + +bool LoopDependenceAnalysis::depends(Value *src, Value *dst) { + assert(isDependencePair(src, dst) && "Values form no dependence pair!"); + return true; +} + //===----------------------------------------------------------------------===// // LoopDependenceAnalysis Implementation //===----------------------------------------------------------------------===//