Skip to content

Commit

Permalink
missing memref op
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Manainen authored and Max Manainen committed Oct 28, 2024
1 parent b746cc1 commit 1d0c281
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tests/filecheck/dialects/memref/memref_ops.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ builtin.module {
%fmemref = "test.op"() : () -> memref<32x32xf32>
%e = "test.op"() : () -> f32
%207 = "memref.atomic_rmw"(%e, %fmemref, %1, %1) <{kind = 0 : i64}> : (f32, memref<32x32xf32>, index, index) -> f32

%p = "memref.to_ptr"(%0) : (memref<1xindex>) -> !ptr.ptr
func.return
}
}
Expand Down Expand Up @@ -95,6 +95,7 @@ builtin.module {
// CHECK-NEXT: %{{.*}} = "test.op"() : () -> memref<32x32xf32>
// CHECK-NEXT: %{{.*}} = "test.op"() : () -> f32
// CHECK-NEXT: %{{.*}} = "memref.atomic_rmw"(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) <{"kind" = 0 : i64}> : (f32, memref<32x32xf32>, index, index) -> f32
// CHECK-NEXT: %p = memref.to_ptr %0 : memref<1xindex> -> !ptr.ptr
// CHECK-NEXT: func.return
// CHECK-NEXT: }
// CHECK-NEXT: }
12 changes: 12 additions & 0 deletions xdsl/dialects/memref.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
i32,
i64,
)
from xdsl.dialects.ptr import PtrType
from xdsl.dialects.utils import (
parse_dynamic_index_list_without_types,
print_dynamic_index_list,
Expand Down Expand Up @@ -1079,6 +1080,16 @@ def verify_(self) -> None:
)


@irdl_op_definition
class ToPtrOp(IRDLOperation):
name = "memref.to_ptr"

source = operand_def(MemRefType)
res = result_def(PtrType)

assembly_format = "$source attr-dict `:` type($source) `->` type($res)"


MemRef = Dialect(
"memref",
[
Expand All @@ -1103,6 +1114,7 @@ def verify_(self) -> None:
MemorySpaceCast,
DmaStartOp,
DmaWaitOp,
ToPtrOp,
],
[],
)

0 comments on commit 1d0c281

Please sign in to comment.