TL;DR: Is there a method for constructing backedges in MLIR? If not, we should add one.
With the addition of graph regions, backedge construction has become an issue. In CIRCT, we have a support utility named BackedgeBuilder
which constructs a dummy op with the result type of a specified type. We then use the dummy op result to construct the op which consumes the fed back value with the dummy value, then replace the dummy value when the actual op gets constructed.
Up until a few days ago, we used an unregistered operation as the dummy op and set the flag in MLIRContext
to allow unregistered ops, which wasn’t great. We’ve moved to a registered dummy op in our hw
dialect, but that introduces a dependency on the hw
dialect from the support library (which shouldn’t have any dialect deps). BackedgeBuilder
is templated (to specify the dummy op), but other code in the support library uses it, so that code would have to become templated as well, which may mean other code would have to (rinse and repeat). This feels like a hacky solution just to avoid a dependency.
Is there a better way?