Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanradanov committed May 17, 2024
1 parent 5aaf7a8 commit 8519ed6
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions tools/polymer/lib/Support/ScopStmt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -216,36 +216,24 @@ void ScopStmt::getAccessMapAndMemRef(mlir::Operation *op,
IRMapping argMap;
impl->getArgsValueMapping(argMap);

AffineMap map;
SmallVector<Value, 4> indices;
if (auto loadOp = dyn_cast<affine::AffineReadOpInterface>(op)) {
*memref = loadOp.getMemRef();
llvm::append_range(indices, loadOp.getMapOperands());
map = loadOp.getAffineMap();
} else {
assert(isa<affine::AffineWriteOpInterface>(op) &&
"Affine read/write op expected");
auto storeOp = cast<affine::AffineWriteOpInterface>(op);
*memref = storeOp.getMemRef();
llvm::append_range(indices, storeOp.getMapOperands());
}

// Get affine map from AffineLoad/Store.
AffineMap map;
if (auto loadOp = dyn_cast<affine::AffineReadOpInterface>(op))
map = loadOp.getAffineMap();
else
map = cast<affine::AffineWriteOpInterface>(op).getAffineMap();
}

affine::AffineValueMap aMap;

// SmallVector<Value, 8> operands2(indices.begin(), indices.end());
// affine::fullyComposeAffineMapAndOperands(&map, &operands2);
// map = simplifyAffineMap(map);
// affine::canonicalizeMapAndOperands(&map, &operands2);
aMap.reset(map, indices);

// TODO: assert op is in the callee.
affine::MemRefAccess access(op);

// Replace its operands by what the caller uses.
SmallVector<mlir::Value, 8> operands;
for (mlir::Value operand : aMap.getOperands()) {
Expand All @@ -261,5 +249,5 @@ void ScopStmt::getAccessMapAndMemRef(mlir::Operation *op,
// Set the access affine::AffineValueMap.
vMap->reset(aMap.getAffineMap(), operands);
// Set the memref.
*memref = argMap.lookup(access.memref);
*memref = argMap.lookup(*memref);
}

0 comments on commit 8519ed6

Please sign in to comment.