Back to PBT run
test.mlir
// RUN: loom-raise-opt --loom-lower-graph-memory --mlir-print-op-generic %s | FileCheck %s
module attributes {
llvm.data_layout = "e-p:64:64",
dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry<index, 64>>
} {
dataflow.graph private @source_memory_graph(
%start: none, %base: !llvm.ptr, %expected: i32, %desired: i32,
%index: i64, %cond: i1) -> ()
attributes {input_segments = array<i32: 5, 0, 0>,
result_segments = array<i32: 0, 0, 0>} {
%ptr = llvm.getelementptr inbounds %base[%index]
: (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<4 x i8>
scf.if %cond {
llvm.store %desired, %ptr atomic syncscope("system") monotonic {alignment = 4 : i64} : i32, !llvm.ptr
%val1 = llvm.load volatile %ptr {alignment = 8 : i64} : !llvm.ptr -> i32
%rmw2 = llvm.atomicrmw sub %ptr, %desired release {alignment = 4 : i64} : !llvm.ptr, i32
%rmw3 = llvm.atomicrmw xchg %ptr, %desired syncscope("singlethread") acq_rel {alignment = 4 : i64} : !llvm.ptr, i32
%val4 = llvm.load %ptr atomic syncscope("singlethread") monotonic {alignment = 4 : i64} : !llvm.ptr -> i32
}
dataflow.graph.return %start : none
}
}
// CHECK: "builtin.module"() ({
// CHECK-NEXT: "dataflow.graph"() <{function_type = (!llvm.ptr, i32, i32, i64, i1, memref<?xi32>) -> (), input_segments = array<i32: 5, 0, 1>, result_segments = array<i32: 0, 0, 0>, sym_name = "source_memory_graph", sym_visibility = "private"}> ({
// CHECK-NEXT: ^bb0(%arg0: none, %arg1: !llvm.ptr, %arg2: i32, %arg3: i32, %arg4: i64, %arg5: i1, %arg6: memref<?xi32>):
// CHECK-NEXT: %0 = "llvm.getelementptr"(%arg1, %arg4) <{elem_type = !llvm.array<4 x i8>, noWrapFlags = 3 : i32, rawConstantIndices = array<i32: -2147483648>}> : (!llvm.ptr, i64) -> !llvm.ptr
// CHECK-NEXT: %1:2 = "dataflow.demux"(%arg5, %arg0) : (i1, none) -> (none, none)
// CHECK-NEXT: %2:2 = "dataflow.demux"(%arg5, %arg0) : (i1, none) -> (none, none)
// CHECK-NEXT: %3:2 = "dataflow.demux"(%arg5, %arg0) : (i1, none) -> (none, none)
// CHECK-NEXT: %4:2 = "dataflow.demux"(%arg5, %0) : (i1, !llvm.ptr) -> (!llvm.ptr, !llvm.ptr)
// CHECK-NEXT: %5:2 = "dataflow.demux"(%arg5, %arg3) : (i1, i32) -> (i32, i32)
// CHECK-NEXT: %6:2 = "dataflow.sync"(%1#1, %3#1) : (none, none) -> (none, none)
// CHECK-NEXT: %7 = "dataflow.store"(%arg6, %4#1, %5#1, %6#0) <{contract = #dataflow.atomic_access<ordering = monotonic, sync_scope = <system>, source_alignment_bytes = 4>}> : (memref<?xi32>, !llvm.ptr, i32, none) -> none
// CHECK-NEXT: %8:2 = "dataflow.load"(%arg6, %4#1, %7) <{contract = #dataflow.plain_access<is_volatile = true>}> : (memref<?xi32>, !llvm.ptr, none) -> (i32, none)
// CHECK-NEXT: %9:2 = "dataflow.atomic_rmw"(%arg6, %4#1, %5#1, %8#1) <{contract = #dataflow.rmw_contract<kind = sub, access = <ordering = release, sync_scope = <system>, source_alignment_bytes = 4>>}> : (memref<?xi32>, !llvm.ptr, i32, none) -> (i32, none)
// CHECK-NEXT: %10:2 = "dataflow.atomic_rmw"(%arg6, %4#1, %5#1, %9#1) <{contract = #dataflow.rmw_contract<kind = xchg, access = <ordering = acq_rel, sync_scope = <single_thread>, source_alignment_bytes = 4>>}> : (memref<?xi32>, !llvm.ptr, i32, none) -> (i32, none)
// CHECK-NEXT: %11:2 = "dataflow.load"(%arg6, %4#1, %10#1) <{contract = #dataflow.atomic_access<ordering = monotonic, sync_scope = <single_thread>, source_alignment_bytes = 4>}> : (memref<?xi32>, !llvm.ptr, none) -> (i32, none)
// CHECK-NEXT: %12 = "dataflow.mux"(%arg5, %3#0, %11#1) : (i1, none, none) -> none
// CHECK-NEXT: %13 = "dataflow.mux"(%arg5, %1#0, %10#1) : (i1, none, none) -> none
// CHECK-NEXT: "dataflow.graph.return"(%13, %12) <{operandSegmentSizes = array<i32: 0, 0, 0, 2>}> : (none, none) -> ()
// CHECK-NEXT: }) : () -> ()
// CHECK-NEXT: }) {dlti.dl_spec = #dlti.dl_spec<index = 64 : i64>, llvm.data_layout = "e-p:64:64"} : () -> ()
// CHECK-EMPTY: