[PATCH] D141662: [MLIR][memref] Add details on the semantic of reinterpret_cast

Quentin Colombet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 13 00:10:35 PST 2023


qcolombet created this revision.
qcolombet added reviewers: mehdi_amini, ftynse, pifon2a.
qcolombet added a project: MLIR.
Herald added subscribers: Moerafaat, bzcheeseman, sdasgup3, wenzhicui, wrengr, cota, teijeong, rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, mgester, arpith-jacob, antiagainst, shauheen, rriddle.
Herald added a project: All.
qcolombet requested review of this revision.
Herald added a reviewer: nicolasvasilache.
Herald added subscribers: stephenneuendorffer, nicolasvasilache.

Make it clearer what the semantic of `reinterpret_cast` is.

In particular, call out that this instruction is not a no-op.

NFC

Related to https://github.com/llvm/llvm-project/issues/59896


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141662

Files:
  mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td


Index: mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td
===================================================================
--- mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td
+++ mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td
@@ -1246,6 +1246,24 @@
       strides: [%stride0, %stride1]
     : memref<*xf32> to memref<?x?xf32, strided<[?, ?], offset: ?>>
     ```
+
+    This operation creates a new memref descriptor using the base of the
+    source and applying the input arguments to the other metadata.
+    In other words:
+    ```mlir
+    %dst = memref.reinterpret_cast %src to
+      offset: [%offset],
+      sizes: [%sizes],
+      strides: [%strides]
+    ```
+    means that `%dst`'s descriptor will be:
+    ```mlir
+    %dst.base = %src.base
+    %dst.aligned = %src.aligned
+    %dst.offset = %offset
+    %dst.sizes = %sizes
+    %dst.strides = %strides
+    ```
   }];
 
   let arguments = (ins Arg<AnyRankedOrUnrankedMemRef, "", []>:$source,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141662.488884.patch
Type: text/x-patch
Size: 964 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230113/05076266/attachment.bin>


More information about the llvm-commits mailing list