-
Notifications
You must be signed in to change notification settings - Fork 309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HandshakeToFIRRTL should respect FIRRTL requiring classic SSA def-before-use #534
Comments
Interesting... Is that supposed to be legal given that it's a use before def of an SSA value? The SFC disallows use before def like this: circuit Foo:
module Foo:
input a: UInt<1>
output b: UInt<1>
x <= a
wire x: UInt<1>
b <= x firrtl -i Foo.fir
# Exception in thread "main" firrtl.passes.CheckHighFormLike$UndeclaredReferenceException: : [module Foo] Reference x is not declared. But, interestingly, CIRCT will allow the equivalent MLIR input. 🤔 My gut is that this should be a hard error and we should fix this in |
Since It's not up to me if it should be a requirement that FIRRTL modules enforce definitions before use, so I'll leave it to the FIRRTL owners. That said, the quick fix for this within LowerTypes is simple, and I've already implemented it, so I'll make a PR anyway. If you ultimately decide this IR shouldn't be valid, I can update the |
It is currently valid for FIRRTL to contain ops that use values before they are defined. This is being discussed in #534, but for the meantime, this fixes the LowerTypes pass to handle such situations.
I don't think the firrtl dialect should support this, it should require classic def-before-use SSA-style dominance. The RTL dialect should support more flexible graph-style constructs. LowerToRTL (as one example) won't work with graph style FIRRTL IR. |
This is easy enough to fix, we should remove this from FModuleOp:
And remove the Rationale: FIRRTL is really a part of the Chisel stack, and it doesn't need graph support. We should implement most of the interesting logic in CIRCT on the RTL dialect, and keep the FIRRTL lowering stuff as simple as possible. I'd recommend Handshake lowering to eventually move to targeting RTL directly as it gets more mature. |
Sounds good to me. This is really a HandshakeToFIRRTL issue then. |
This matches the expectation of the SFC compiler, and LowerTypes/LowerToRTL require this. This patch xfails the HandshakeToFIRRTL/test_load.mlir test, which is tracked in Issue #534.
Thanks Mike, I changed the FIRRTL dialect to correctly enforce this in bf56ef1. This broke HandshakeToFIRRTL/test_load.mlir which I xfailed. I looked into it, but didn't see an obvious solution. I hope that is ok, if not, lemme know and I'll be happy to revert this for now. |
Done in #537 |
thx! |
The following psuedo-IR can be produced by HandshakeToFIRRTL, passes the verifier, but will crash the LowerTypes pass:
The actual test case I have is quite complex, and I'm trying to reduce it to something we can realistically put in a unit test.
The
solutionquick fix seems pretty clear: instead of processing every operation in order in the LowerTypesrunOnOperation
function, just track the connects to process, and take a second pass to actually process them. I've implemented this already, and will share a PR once I've reduced a reasonable test case.The text was updated successfully, but these errors were encountered: