Skip to content
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

Merged
merged 3 commits into from
Jan 30, 2021

Conversation

hanchenye
Copy link
Member

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.

Copy link
Contributor

@mikeurbach mikeurbach left a 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;
Copy link
Contributor

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?

Copy link
Collaborator

@lattner lattner left a 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());
Copy link
Collaborator

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()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants