Description
I've been thinking about whether it's reasonable to restrict handshake
operations to having handshake.func
s as their parent op. I think the main argument for doing so currently is avoiding confusion between e.g. func.func
and handshake.func
, with regards to the whole "every SSA value is a handshake channel" (i.e. fine-grained dataflow).
However, it's exactly that latter part which I'm questioning. We may want to use handshake within any region which has fine-grained dataflow semantics. In other words, would it make more sense to say that Handshake ops should have something like ParentOf<"FineGrainedDataflowRegionOpInterface">
(note: this isn't currently feasible, since interfaces can't be used in ParentOf
, but a capability that many dialects need about... so probably will be possible soon).
This would mean that I could bring my own op, which implements this interface, and use handshake (and handshake lowerings) to transform my custom fine-grained dataflow operation into the more explicit, low-level format that DC represents:
// myDialect.fgdf implements FineGrainedDataflowRegionOpInterface for its inner region
%out = myDialect.fgdf(%a : !myDialect.MyType<i32>, %b : !myDialect.MyType<i32>) -> (out : !nyDialect.MyType<i32>) {
^bb0(%a_ : i32, %b_ : i32)
// this is a fine-grained dataflow region wherein we can reason about using
// handshake operations and semantics.
%res = arith.addi %a_, %b_ : i32
return %res : i32
}
// -------------------------------------------------------------------------- //
// This means that we can use handshake-style lowering to lower the above to:
%in0 = myDialect.to_dc %a : !myDialect.MyType<i32> -> !dc.value<i32>
%in1 = myDialect.to_dc %b : !myDialect.MyType<i32> -> !dc.value<i32>
%token, %output = dc.unpack %in0 : !dc.value<i32>
%token_0, %output_1 = dc.unpack %in1 : !dc.value<i32>
%0 = dc.join %token, %token_0
%1 = arith.addi %output, %output_1 : i32
%2 = dc.pack %0, %1 : i32
%out = myDialect.from_dc %2 : !dc.value<i32> -> !myDialect.MyType<i32>
hw.output %out : !myDialect.MyType<i32>
tl;dr: i want to use handshake ops outside of handshake.func
.
CC @Dinistro @mikeurbach @RamirezLucas @teqdruid