-
Notifications
You must be signed in to change notification settings - Fork 310
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] legalize top FIRRTL module to meet the def-before-use requirement #537
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thanks for addressing this so quickly! I think with this change and #488, we can lower Handshake modules with a loop and a structured variable all the way to System Verilog.
@@ -32,6 +32,13 @@ using ValueVectorList = std::vector<ValueVector>; | |||
// Utils | |||
//===----------------------------------------------------------------------===// | |||
|
|||
static void legalizeFModule(FModuleOp moduleOp) { | |||
std::vector<Operation *> connectOps; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be an LLVM data structure like SmallVector or maybe SmallPtrSet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the quick fix!
SmallVector<Operation *, 8> connectOps; | ||
moduleOp.walk([&](ConnectOp op) { connectOps.push_back(op); }); | ||
for (auto op : connectOps) | ||
op->moveBefore(&moduleOp.front().back()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd recommend moduleOp.getBodyBlock().back()
This is a quick fix for issue #534. All ConnectOp in the top FIRRTL module are moved to the end for meeting the def-before-use requirement of FIRRTL dialect.