Open
Description
Passing the following code to --lower-std-to-handshake
produces a weird output.
func.func @external_mem(%mem : memref<4xi32>) {
return
}
func.func @normal_mem() {
%mem = memref.alloc() : memref<4xi32>
func.call @external_mem(%mem) : (memref<4xi32>) -> ()
return
}
Output:
handshake.func @external_mem(%arg0: memref<4xi32>, %arg1: none, ...) -> none attributes {argNames = ["in0", "inCtrl"], resNames = ["outCtrl"]} {
extmemory[ld = 0, st = 0] (%arg0 : memref<4xi32>) () {id = 0 : i32} : () -> ()
return %arg1 : none
}
handshake.func @normal_mem(%arg0: none, ...) -> none attributes {argNames = ["inCtrl"], resNames = ["outCtrl"]} {
%0:2 = fork [2] %arg0 : none
%1 = memref.alloc() : memref<4xi32>
%2 = instance @external_mem(%1, %0#0) : (memref<4xi32>, none) -> none
sink %2 : none
return %0#1 : none
}
As you can see, a memref.alloc()
remains, which is not expected and thus breaks further transformations.
I would expect that a correct lowering would construct a MemoryOp
in the @normal_mem
function. How this exactly interacts with the external memory op is not clear to me, as this will cause cross function dependencies depending on the amount of memory operations in @external_mem
.