Skip to content

Commit

Permalink
[HandshakeToFIRRTL] legalize top FIRRTL module to meet the def-before…
Browse files Browse the repository at this point in the history
…-use requirement (#537)

* [HandshakeToFIRRTL] legalize top FIRRTL module to meet the def-before-use requirement

* using SmallVector rather than std vector

* using getBodyBlock
  • Loading branch information
hanchenye authored Jan 30, 2021
1 parent d1a3e10 commit 21e9cdd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
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 @@ -2068,6 +2075,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

0 comments on commit 21e9cdd

Please sign in to comment.