diff --git a/lib/Conversion/HandshakeToFIRRTL/HandshakeToFIRRTL.cpp b/lib/Conversion/HandshakeToFIRRTL/HandshakeToFIRRTL.cpp index b2e835ba1f44..8b96867cdea8 100644 --- a/lib/Conversion/HandshakeToFIRRTL/HandshakeToFIRRTL.cpp +++ b/lib/Conversion/HandshakeToFIRRTL/HandshakeToFIRRTL.cpp @@ -32,6 +32,13 @@ using ValueVectorList = std::vector; // Utils //===----------------------------------------------------------------------===// +static void legalizeFModule(FModuleOp moduleOp) { + SmallVector 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. @@ -1953,6 +1960,8 @@ struct HandshakeFuncOpLowering : public OpConversionPattern { } rewriter.eraseOp(funcOp); + legalizeFModule(topModuleOp); + return success(); } }; diff --git a/test/Conversion/HandshakeToFIRRTL/test_load.mlir b/test/Conversion/HandshakeToFIRRTL/test_load.mlir index a881f962004a..6a92fb893f4e 100644 --- a/test/Conversion/HandshakeToFIRRTL/test_load.mlir +++ b/test/Conversion/HandshakeToFIRRTL/test_load.mlir @@ -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, ready: flip>, data: uint<64>>, %arg1: !firrtl.bundle, ready: flip>, data: uint<8>>, %arg2: !firrtl.bundle, ready: flip>>, %arg3: !firrtl.bundle>, ready: uint<1>, data: flip>>, %arg4: !firrtl.bundle>, ready: uint<1>, data: flip>>) {