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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/Conversion/HandshakeToFIRRTL/HandshakeToFIRRTL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ using ValueVectorList = std::vector<ValueVector>;
// Utils
//===----------------------------------------------------------------------===//

static void legalizeFModule(FModuleOp moduleOp) {
SmallVector<Operation *, 8> connectOps;
moduleOp.walk([&](ConnectOp op) { connectOps.push_back(op); });
for (auto op : connectOps)
op->moveBefore(&moduleOp.getBodyBlock()->back());
}

/// Get the corresponding FIRRTL type given the built-in data type. Current
/// supported data types are integer (signed, unsigned, and signless), index,
/// and none.
Expand Down Expand Up @@ -1953,6 +1960,8 @@ struct HandshakeFuncOpLowering : public OpConversionPattern<handshake::FuncOp> {
}
rewriter.eraseOp(funcOp);

legalizeFModule(topModuleOp);

return success();
}
};
Expand Down
1 change: 0 additions & 1 deletion test/Conversion/HandshakeToFIRRTL/test_load.mlir
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// RUN: circt-opt -lower-handshake-to-firrtl -split-input-file -verify-diagnostics %s
// XFAIL: *

// CHECK-LABEL: firrtl.module @handshake_load_3ins_2outs_ui8(
// CHECK-SAME: %arg0: !firrtl.bundle<valid: uint<1>, ready: flip<uint<1>>, data: uint<64>>, %arg1: !firrtl.bundle<valid: uint<1>, ready: flip<uint<1>>, data: uint<8>>, %arg2: !firrtl.bundle<valid: uint<1>, ready: flip<uint<1>>>, %arg3: !firrtl.bundle<valid: flip<uint<1>>, ready: uint<1>, data: flip<uint<8>>>, %arg4: !firrtl.bundle<valid: flip<uint<1>>, ready: uint<1>, data: flip<uint<64>>>) {
Expand Down