[llvm-commits] [polly] r134991 - in /polly/trunk: include/polly/ lib/Analysis/ lib/Exchange/ test/CodeGen/MemAccess/
Raghesh Aloor
raghesh.a at gmail.com
Tue Jul 12 10:14:03 PDT 2011
Author: raghesh
Date: Tue Jul 12 12:14:03 2011
New Revision: 134991
URL: http://llvm.org/viewvc/llvm-project?rev=134991&view=rev
Log:
MemAccess: Reading Change in Access Function
This patch reads the change in access functions from
imported JSCOP file. A test case is also added.
Added:
polly/trunk/test/CodeGen/MemAccess/
polly/trunk/test/CodeGen/MemAccess/memaccess_simple.c
polly/trunk/test/CodeGen/MemAccess/memaccess_simple.ll
polly/trunk/test/CodeGen/MemAccess/memaccess_simple___%for.cond---%for.end.jscop
polly/trunk/test/CodeGen/MemAccess/memaccess_simple___%for.cond---%for.end.jscop.transformed
polly/trunk/test/CodeGen/MemAccess/memaccess_simple___%for.cond4---%for.end14.jscop
polly/trunk/test/CodeGen/MemAccess/memaccess_simple___%for.cond4---%for.end14.jscop.transformed
Modified:
polly/trunk/include/polly/ScopInfo.h
polly/trunk/lib/Analysis/ScopInfo.cpp
polly/trunk/lib/Exchange/JSONExporter.cpp
Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=134991&r1=134990&r2=134991&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Tue Jul 12 12:14:03 2011
@@ -95,6 +95,8 @@
void setBaseName();
ScopStmt *statement;
+ /// Updated access relation read from JSCOP file.
+ isl_map *newAccessRelation;
public:
// @brief Create an affine memory access.
//
@@ -143,6 +145,8 @@
/// @brief Get the statement that contains this memory access.
ScopStmt *getStatement() const { return statement; }
+ /// @brief Set the updated access relation read from JSCOP file.
+ void setNewAccessFunction(isl_map *newAccessRelation);
/// @brief Print the MemoryAccess.
///
/// @param OS The output stream the MemoryAccess is printed to.
Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=134991&r1=134990&r2=134991&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Tue Jul 12 12:14:03 2011
@@ -156,6 +156,7 @@
}
MemoryAccess::MemoryAccess(const SCEVAffFunc &AffFunc, ScopStmt *Statement) {
+ newAccessRelation = NULL;
BaseAddr = AffFunc.getBaseAddr();
Type = AffFunc.isRead() ? Read : Write;
statement = Statement;
@@ -191,6 +192,7 @@
}
MemoryAccess::MemoryAccess(const Value *BaseAddress, ScopStmt *Statement) {
+ newAccessRelation = NULL;
BaseAddr = BaseAddress;
Type = Read;
statement = Statement;
@@ -334,6 +336,9 @@
return isl_set_is_equal(stride, strideZero);
}
+void MemoryAccess::setNewAccessFunction(isl_map *newAccessRelation) {
+ newAccessRelation = newAccessRelation;
+}
//===----------------------------------------------------------------------===//
void ScopStmt::buildScattering(SmallVectorImpl<unsigned> &Scatter) {
Modified: polly/trunk/lib/Exchange/JSONExporter.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Exchange/JSONExporter.cpp?rev=134991&r1=134990&r2=134991&view=diff
==============================================================================
--- polly/trunk/lib/Exchange/JSONExporter.cpp (original)
+++ polly/trunk/lib/Exchange/JSONExporter.cpp Tue Jul 12 12:14:03 2011
@@ -22,6 +22,9 @@
#include "llvm/Support/system_error.h"
#include "llvm/ADT/OwningPtr.h"
#include "llvm/Assembly/Writer.h"
+#include "llvm/ADT/Statistic.h"
+
+#define DEBUG_TYPE "polly-import-jscop"
#include "json/reader.h"
#include "json/writer.h"
@@ -36,6 +39,8 @@
using namespace llvm;
using namespace polly;
+STATISTIC(NewAccessMapFound, "Number of updated access functions");
+
namespace {
static cl::opt<std::string>
ImportDir("polly-import-jscop-dir",
@@ -245,6 +250,31 @@
Stmt->setScattering(NewScattering[Stmt]);
}
+ int statementIdx = 0;
+ int memoryAccessIdx = 0;
+ for (Scop::iterator SI = S->begin(), SE = S->end(); SI != SE; ++SI) {
+ ScopStmt *Stmt = *SI;
+
+ if (Stmt->isFinalRead())
+ continue;
+
+ for (ScopStmt::memacc_iterator MI = Stmt->memacc_begin(),
+ ME = Stmt->memacc_end(); MI != ME; ++MI) {
+ Json::Value accesses = jscop["statements"][statementIdx]
+ ["accesses"][memoryAccessIdx]["relation"];
+ isl_map *newAccessMap = isl_map_read_from_str(S->getCtx(),
+ accesses.asCString(), -1);
+ isl_map *currentAccessMap = (*MI)->getAccessFunction();
+ if (!isl_map_is_equal(newAccessMap, currentAccessMap)) {
+ // Statistics.
+ ++NewAccessMapFound;
+ (*MI)->setNewAccessFunction(newAccessMap);
+ }
+ memoryAccessIdx++;
+ }
+ statementIdx++;
+ }
+
return false;
}
Added: polly/trunk/test/CodeGen/MemAccess/memaccess_simple.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/CodeGen/MemAccess/memaccess_simple.c?rev=134991&view=auto
==============================================================================
--- polly/trunk/test/CodeGen/MemAccess/memaccess_simple.c (added)
+++ polly/trunk/test/CodeGen/MemAccess/memaccess_simple.c Tue Jul 12 12:14:03 2011
@@ -0,0 +1,17 @@
+int A[100];
+int B[100];
+
+int memaccess_simple()
+{
+ int i, j;
+ for (i = 0; i < 12; i++) {
+ A[i] = i;
+ }
+
+ for (i = 0; i < 12; i++) {
+ B[i] = i;
+ }
+
+ return 0;
+}
+
Added: polly/trunk/test/CodeGen/MemAccess/memaccess_simple.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/CodeGen/MemAccess/memaccess_simple.ll?rev=134991&view=auto
==============================================================================
--- polly/trunk/test/CodeGen/MemAccess/memaccess_simple.ll (added)
+++ polly/trunk/test/CodeGen/MemAccess/memaccess_simple.ll Tue Jul 12 12:14:03 2011
@@ -0,0 +1,47 @@
+;RUN: opt %loadPolly -polly-import-jscop -polly-import-jscop-dir=`dirname %s` -polly-import-jscop-postfix=transformed -stats %s 2>&1 | FileCheck %s
+; ModuleID = 'memaccess_simple.ll'
+target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
+target triple = "i386-pc-linux-gnu"
+
+ at A = common global [100 x i32] zeroinitializer, align 4
+ at B = common global [100 x i32] zeroinitializer, align 4
+
+define i32 @memaccess_simple() nounwind {
+entry:
+ br label %for.cond
+
+for.cond: ; preds = %for.inc, %entry
+ %0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
+ %arrayidx = getelementptr [100 x i32]* @A, i32 0, i32 %0
+ %exitcond1 = icmp ne i32 %0, 12
+ br i1 %exitcond1, label %for.body, label %for.end
+
+for.body: ; preds = %for.cond
+ store i32 %0, i32* %arrayidx
+ br label %for.inc
+
+for.inc: ; preds = %for.body
+ %inc = add nsw i32 %0, 1
+ br label %for.cond
+
+for.end: ; preds = %for.cond
+ br label %for.cond4
+
+for.cond4: ; preds = %for.inc11, %for.end
+ %1 = phi i32 [ 0, %for.end ], [ %inc13, %for.inc11 ]
+ %arrayidx10 = getelementptr [100 x i32]* @B, i32 0, i32 %1
+ %exitcond = icmp ne i32 %1, 12
+ br i1 %exitcond, label %for.body7, label %for.end14
+
+for.body7: ; preds = %for.cond4
+ store i32 %1, i32* %arrayidx10
+ br label %for.inc11
+
+for.inc11: ; preds = %for.body7
+ %inc13 = add nsw i32 %1, 1
+ br label %for.cond4
+
+for.end14: ; preds = %for.cond4
+ ret i32 0
+}
+; CHECK: 2 polly-import-jscop
Added: polly/trunk/test/CodeGen/MemAccess/memaccess_simple___%for.cond---%for.end.jscop
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/CodeGen/MemAccess/memaccess_simple___%25for.cond---%25for.end.jscop?rev=134991&view=auto
==============================================================================
--- polly/trunk/test/CodeGen/MemAccess/memaccess_simple___%for.cond---%for.end.jscop (added)
+++ polly/trunk/test/CodeGen/MemAccess/memaccess_simple___%for.cond---%for.end.jscop Tue Jul 12 12:14:03 2011
@@ -0,0 +1,17 @@
+{
+ "context" : "{ [] }",
+ "name" : "for.cond => for.end",
+ "statements" : [
+ {
+ "accesses" : [
+ {
+ "kind" : "write",
+ "relation" : "{ Stmt_for_body[i0] -> MemRef_A[i0] }"
+ }
+ ],
+ "domain" : "{ Stmt_for_body[i0] : i0 >= 0 and i0 <= 11 }",
+ "name" : "Stmt_for_body",
+ "schedule" : "{ Stmt_for_body[i0] -> scattering[0, i0, 0] }"
+ }
+ ]
+}
Added: polly/trunk/test/CodeGen/MemAccess/memaccess_simple___%for.cond---%for.end.jscop.transformed
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/CodeGen/MemAccess/memaccess_simple___%25for.cond---%25for.end.jscop.transformed?rev=134991&view=auto
==============================================================================
--- polly/trunk/test/CodeGen/MemAccess/memaccess_simple___%for.cond---%for.end.jscop.transformed (added)
+++ polly/trunk/test/CodeGen/MemAccess/memaccess_simple___%for.cond---%for.end.jscop.transformed Tue Jul 12 12:14:03 2011
@@ -0,0 +1,17 @@
+{
+ "context" : "{ [] }",
+ "name" : "for.cond => for.end",
+ "statements" : [
+ {
+ "accesses" : [
+ {
+ "kind" : "write",
+ "relation" : "{ Stmt_for_body[i0] -> MemRef_A[0] }"
+ }
+ ],
+ "domain" : "{ Stmt_for_body[i0] : i0 >= 0 and i0 <= 11 }",
+ "name" : "Stmt_for_body",
+ "schedule" : "{ Stmt_for_body[i0] -> scattering[0, i0, 0] }"
+ }
+ ]
+}
Added: polly/trunk/test/CodeGen/MemAccess/memaccess_simple___%for.cond4---%for.end14.jscop
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/CodeGen/MemAccess/memaccess_simple___%25for.cond4---%25for.end14.jscop?rev=134991&view=auto
==============================================================================
--- polly/trunk/test/CodeGen/MemAccess/memaccess_simple___%for.cond4---%for.end14.jscop (added)
+++ polly/trunk/test/CodeGen/MemAccess/memaccess_simple___%for.cond4---%for.end14.jscop Tue Jul 12 12:14:03 2011
@@ -0,0 +1,17 @@
+{
+ "context" : "{ [] }",
+ "name" : "for.cond4 => for.end14",
+ "statements" : [
+ {
+ "accesses" : [
+ {
+ "kind" : "write",
+ "relation" : "{ Stmt_for_body7[i0] -> MemRef_B[i0] }"
+ }
+ ],
+ "domain" : "{ Stmt_for_body7[i0] : i0 >= 0 and i0 <= 11 }",
+ "name" : "Stmt_for_body7",
+ "schedule" : "{ Stmt_for_body7[i0] -> scattering[0, i0, 0] }"
+ }
+ ]
+}
Added: polly/trunk/test/CodeGen/MemAccess/memaccess_simple___%for.cond4---%for.end14.jscop.transformed
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/CodeGen/MemAccess/memaccess_simple___%25for.cond4---%25for.end14.jscop.transformed?rev=134991&view=auto
==============================================================================
--- polly/trunk/test/CodeGen/MemAccess/memaccess_simple___%for.cond4---%for.end14.jscop.transformed (added)
+++ polly/trunk/test/CodeGen/MemAccess/memaccess_simple___%for.cond4---%for.end14.jscop.transformed Tue Jul 12 12:14:03 2011
@@ -0,0 +1,17 @@
+{
+ "context" : "{ [] }",
+ "name" : "for.cond4 => for.end14",
+ "statements" : [
+ {
+ "accesses" : [
+ {
+ "kind" : "write",
+ "relation" : "{ Stmt_for_body7[i0] -> MemRef_B[0] }"
+ }
+ ],
+ "domain" : "{ Stmt_for_body7[i0] : i0 >= 0 and i0 <= 11 }",
+ "name" : "Stmt_for_body7",
+ "schedule" : "{ Stmt_for_body7[i0] -> scattering[0, i0, 0] }"
+ }
+ ]
+}
More information about the llvm-commits
mailing list