Back to PBT run
test.mlir
// RUN: loom-raise-opt --loom-lower-graph-memory --mlir-print-op-generic %s | FileCheck %s
module {
dataflow.graph private @view_export_0(
%start: none, %lb: i64, %ub: i64, %step: i64, %i: index, %c: i1, %v: i32,
%m: memref<4xi32>) -> (memref<?xi32>)
attributes {input_segments = array<i32: 6, 0, 1>,
result_segments = array<i32: 0, 0, 1>} {
%view = memref.cast %m : memref<4xi32> to memref<?xi32>
scf.if %c {
memref.store %v, %view[%i] : memref<?xi32>
}
dataflow.graph.return values() streams()
memories(%view : memref<?xi32>) complete(%start : none)
}
dataflow.graph private @fresh_export_1(
%start: none, %lb: i64, %ub: i64, %step: i64, %i: index, %c: i1, %v: i32)
-> (memref<4xi32>)
attributes {input_segments = array<i32: 6, 0, 0>,
result_segments = array<i32: 0, 0, 1>} {
%slot = memref.alloc() : memref<4xi32>
scf.for %iv = %lb to %ub step %step : i64 {
%idx = arith.index_cast %iv : i64 to index
memref.store %v, %slot[%idx] : memref<4xi32>
}
dataflow.graph.return values() streams()
memories(%slot : memref<4xi32>) complete(%start : none)
}
}
// CHECK: "builtin.module"() ({
// CHECK-NEXT: "dataflow.graph"() <{function_type = (i64, i64, i64, index, i1, i32, memref<4xi32>) -> memref<?xi32>, input_segments = array<i32: 6, 0, 1>, result_segments = array<i32: 0, 0, 1>, sym_name = "view_export_0", sym_visibility = "private"}> ({
// CHECK-NEXT: ^bb0(%arg7: none, %arg8: i64, %arg9: i64, %arg10: i64, %arg11: index, %arg12: i1, %arg13: i32, %arg14: memref<4xi32>):
// CHECK-NEXT: %18 = "memref.cast"(%arg14) : (memref<4xi32>) -> memref<?xi32>
// CHECK-NEXT: %19:2 = "dataflow.demux"(%arg12, %arg7) : (i1, none) -> (none, none)
// CHECK-NEXT: %20:2 = "dataflow.demux"(%arg12, %arg7) : (i1, none) -> (none, none)
// CHECK-NEXT: %21:2 = "dataflow.demux"(%arg12, %arg7) : (i1, none) -> (none, none)
// CHECK-NEXT: %22:2 = "dataflow.demux"(%arg12, %arg13) : (i1, i32) -> (i32, i32)
// CHECK-NEXT: %23:2 = "dataflow.demux"(%arg12, %arg11) : (i1, index) -> (index, index)
// CHECK-NEXT: %24:2 = "dataflow.sync"(%19#1, %21#1) : (none, none) -> (none, none)
// CHECK-NEXT: %25 = "dataflow.store"(%18, %23#1, %22#1, %24#0) : (memref<?xi32>, index, i32, none) -> none
// CHECK-NEXT: %26 = "dataflow.mux"(%arg12, %21#0, %25) : (i1, none, none) -> none
// CHECK-NEXT: %27 = "dataflow.mux"(%arg12, %19#0, %19#1) : (i1, none, none) -> none
// CHECK-NEXT: "dataflow.graph.return"(%18, %27, %26) <{operandSegmentSizes = array<i32: 0, 0, 1, 2>}> : (memref<?xi32>, none, none) -> ()
// CHECK-NEXT: }) : () -> ()
// CHECK-NEXT: "dataflow.graph"() <{function_type = (i64, i64, i64, index, i1, i32) -> memref<4xi32>, input_segments = array<i32: 6, 0, 0>, result_segments = array<i32: 0, 0, 1>, sym_name = "fresh_export_1", sym_visibility = "private"}> ({
// CHECK-NEXT: ^bb0(%arg0: none, %arg1: i64, %arg2: i64, %arg3: i64, %arg4: index, %arg5: i1, %arg6: i32):
// CHECK-NEXT: %0 = "memref.alloc"() <{operandSegmentSizes = array<i32: 0, 0>}> : () -> memref<4xi32>
// CHECK-NEXT: %1:2 = "dataflow.stream"(%arg1, %arg2, %arg3) <{predicate = 2 : i64, step_kind = 0 : i32}> : (i64, i64, i64) -> (i64, i1)
// CHECK-NEXT: %2 = "dataflow.carry"(%1#1, %arg0, %3#1) : (i1, none, none) -> none
// CHECK-NEXT: %3:2 = "dataflow.demux"(%1#1, %2) : (i1, none) -> (none, none)
// CHECK-NEXT: %4 = "dataflow.invariant"(%1#1, %arg6) : (i1, i32) -> i32
// CHECK-NEXT: %5:2 = "dataflow.gate"(%1#1, %4) : (i1, i32) -> (i1, i32)
// CHECK-NEXT: %6:2 = "dataflow.demux"(%5#0, %5#1) : (i1, i32) -> (i32, i32)
// CHECK-NEXT: %7 = "dataflow.carry"(%1#1, %arg0, %13) : (i1, none, none) -> none
// CHECK-NEXT: %8 = "dataflow.carry"(%1#1, %arg0, %13) : (i1, none, none) -> none
// CHECK-NEXT: %9:2 = "dataflow.demux"(%1#1, %7) : (i1, none) -> (none, none)
// CHECK-NEXT: %10:2 = "dataflow.demux"(%1#1, %8) : (i1, none) -> (none, none)
// CHECK-NEXT: %11 = "arith.index_cast"(%1#0) : (i64) -> index
// CHECK-NEXT: %12:2 = "dataflow.sync"(%3#1, %10#1) : (none, none) -> (none, none)
// CHECK-NEXT: %13 = "dataflow.store"(%0, %11, %5#1, %12#0) : (memref<4xi32>, index, i32, none) -> none
// CHECK-NEXT: %14 = "arith.cmpi"(%arg1, %arg2) <{predicate = 2 : i64}> : (i64, i64) -> i1
// CHECK-NEXT: %15:2 = "dataflow.demux"(%14, %3#0) : (i1, none) -> (none, none)
// CHECK-NEXT: %16:2 = "dataflow.sync"(%15#1, %6#0) : (none, i32) -> (none, i32)
// CHECK-NEXT: %17 = "dataflow.mux"(%14, %15#0, %16#0) : (i1, none, none) -> none
// CHECK-NEXT: "dataflow.graph.return"(%0, %17, %10#0) <{operandSegmentSizes = array<i32: 0, 0, 1, 2>}> : (memref<4xi32>, none, none) -> ()
// CHECK-NEXT: }) : () -> ()
// CHECK-NEXT: }) : () -> ()
// CHECK-EMPTY: