aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Bolka <a@bolka.at>2009-06-28 00:21:21 +0000
committerAndreas Bolka <a@bolka.at>2009-06-28 00:21:21 +0000
commitf35626d3cda3af2f445a04322253a0d9dca607db (patch)
treeabfbd21076958810380c56d319b5279c86bb1819
parent707207adaed969c32a09ae873ac5a171b3744617 (diff)
Minimal LDA interface, maximally conservative tester.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74401 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Analysis/LoopDependenceAnalysis.h5
-rw-r--r--lib/Analysis/LoopDependenceAnalysis.cpp24
2 files changed, 29 insertions, 0 deletions
diff --git a/include/llvm/Analysis/LoopDependenceAnalysis.h b/include/llvm/Analysis/LoopDependenceAnalysis.h
index 0c3dadea75..bde426ba9a 100644
--- a/include/llvm/Analysis/LoopDependenceAnalysis.h
+++ b/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/lib/Analysis/LoopDependenceAnalysis.cpp b/lib/Analysis/LoopDependenceAnalysis.cpp
index 8f3e6baf5c..b23459e81a 100644
--- a/lib/Analysis/LoopDependenceAnalysis.cpp
+++ b/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() {
@@ -32,6 +33,29 @@ R("lda", "Loop Dependence Analysis", false, true);
char LoopDependenceAnalysis::ID = 0;
//===----------------------------------------------------------------------===//
+// Utility Functions
+//===----------------------------------------------------------------------===//
+
+static inline bool isMemRefInstr(const Value *I) {
+ return isa<LoadInst>(I) || isa<StoreInst>(I);
+}
+
+//===----------------------------------------------------------------------===//
+// Dependence Testing
+//===----------------------------------------------------------------------===//
+
+bool LoopDependenceAnalysis::isDependencePair(const Value *x,
+ const Value *y) const {
+ return isMemRefInstr(x) && isMemRefInstr(y)
+ && (isa<StoreInst>(x) || isa<StoreInst>(y));
+}
+
+bool LoopDependenceAnalysis::depends(Value *src, Value *dst) {
+ assert(isDependencePair(src, dst) && "Values form no dependence pair!");
+ return true;
+}
+
+//===----------------------------------------------------------------------===//
// LoopDependenceAnalysis Implementation
//===----------------------------------------------------------------------===//