Hello everyone!
I’m currently implementing a dataflow-centered dialect. For that, I have an input
type that represents the input end of a FIFO channel. An associated op is used to push items into the channel:
dfg.push(%value) %chan : (i32) -> !dfg.input<i32>
Since I want to ensure type correctness here, I want to model the constraint that the type of %value
matches the inner type of %chan
. So, I thought (after browsing the MLIR codebase and seeing this post) I can use TypesMatchWith
for my purposes.
I implemented dfg.push
like this:
def Dfg_PushOp : Dfg_Op<
"push",
[
TypesMatchWith<"Channel type matches pushed type",
"chan", "inp",
"InputType::get($_ctxt, $_self).getElementType()">
]
> {
// -- snip --
let arguments = (ins AnyType: $inp, Dfg_InputType: $chan);
let assemblyFormat = [{
`(` $inp `)` $chan attr-dict `:` functional-type($inp, $chan)
}];
}
def Dfg_InputType : Dfg_Type<"Input", []> {
let mnemonic = "input";
// -- snip --
let parameters = (ins "Type":$elementType);
let assemblyFormat = "`<` $elementType `>`";
}
However, a (in my opinion) correct code sample like the one above triggers the verification failure “failed to verify that Channel type matches pushed type”. Am I using TypesMatchWith
incorrectly (which I assume) or is there a bug?
Thanks in advance for any hints!