[mlir] Add ViewLikeOpInterface to std.memref_cast.
authorAlexander Belyaev <pifon@google.com>
Wed, 8 Jul 2020 11:44:36 +0000 (13:44 +0200)
committerAlexander Belyaev <pifon@google.com>
Wed, 8 Jul 2020 12:32:23 +0000 (14:32 +0200)
Summery:  It's needed for correct work of BufferPlacement.

Differential Revision: https://reviews.llvm.org/D83385

mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
mlir/lib/Dialect/StandardOps/IR/Ops.cpp

index 2019db4..677e294 100644 (file)
@@ -1772,7 +1772,9 @@ def Log2Op : FloatUnaryOp<"log2"> {
 // MemRefCastOp
 //===----------------------------------------------------------------------===//
 
-def MemRefCastOp : CastOp<"memref_cast"> {
+def MemRefCastOp : CastOp<"memref_cast", [
+    DeclareOpInterfaceMethods<ViewLikeOpInterface>
+  ]> {
   let summary = "memref cast operation";
   let description = [{
     Syntax:
index f792e5d..7c28608 100644 (file)
@@ -1822,6 +1822,8 @@ OpFoldResult LoadOp::fold(ArrayRef<Attribute> cstOperands) {
 // MemRefCastOp
 //===----------------------------------------------------------------------===//
 
+Value MemRefCastOp::getViewSource() { return source(); }
+
 bool MemRefCastOp::areCastCompatible(Type a, Type b) {
   auto aT = a.dyn_cast<MemRefType>();
   auto bT = b.dyn_cast<MemRefType>();