Back to PBT run

test.mlir

// RUN: loom-raise-opt --loom-lower-graph-memory %s | FileCheck %s

module attributes {
} {
  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>
    %lower = arith.constant 0 : index
    %upper = arith.constant 4 : index
    %step = arith.constant 1 : index
    scf.for %iv = %lower to %upper step %step {
    llvm.fence syncscope("system") acquire
    }
    dataflow.graph.return %start : none
  }
}

// CHECK: module {
// CHECK-NEXT:   dataflow.graph private @source_memory_graph(%arg0: none, %arg1: !llvm.ptr, %arg2: i32, %arg3: i32, %arg4: i64, %arg5: i1, %arg6: memref<?xi8>) -> () attributes {input_segments = array<i32: 5, 0, 1>, result_segments = array<i32: 0, 0, 0>} {
// CHECK-NEXT:     %c0 = arith.constant 0 : index
// CHECK-NEXT:     %c4 = arith.constant 4 : index
// CHECK-NEXT:     %c1 = arith.constant 1 : index
// CHECK-NEXT:     %0 = arith.index_cast %c0 : index to i32
// CHECK-NEXT:     %1 = arith.index_cast %c4 : index to i32
// CHECK-NEXT:     %2 = arith.index_cast %c1 : index to i32
// CHECK-NEXT:     %iv, %phase = dataflow.stream %0, %1, %2 step add while slt : i32
// CHECK-NEXT:     %3 = dataflow.carry %phase, %arg0, %5 : none
// CHECK-NEXT:     %4:2 = dataflow.demux %phase, %3 : (i1, none) -> (none, none)
// CHECK-NEXT:     %5 = dataflow.fence %4#1 {contract = #dataflow.fence_contract<ordering = acquire, sync_scope = <system>>}
// CHECK-NEXT:     dataflow.graph.return %4#0 : none
// CHECK-NEXT:   }
// CHECK-NEXT: }
// CHECK-EMPTY: