24 const TypeConverter &typeConverter,
25 ConversionPatternRewriter &rewriter) {
26 ModuleType type = modOp.getHWModuleType();
32 SmallVector<ModulePort> newPorts;
33 TypeConverter::SignatureConversion result(type.getNumInputs());
35 unsigned curInputs = 0;
36 for (
auto &p : type.getPorts()) {
37 if (p.dir == ModulePort::Direction::Output) {
38 SmallVector<Type, 1> newResults;
39 if (failed(typeConverter.convertType(p.type, newResults)))
41 for (
auto np : newResults)
42 newPorts.push_back({p.name, np, p.dir});
44 if (failed(typeConverter.convertSignatureArg(
47 p.dir == ModulePort::Direction::Input ? p.type
48 : InOutType::get(p.type),
51 for (
auto np : result.getConvertedTypes().drop_front(curInputs))
52 newPorts.push_back({p.name, np, p.dir});
53 curInputs = result.getConvertedTypes().size();
57 if (failed(rewriter.convertRegionTypes(&modOp->getRegion(0), typeConverter,
61 auto newType = ModuleType::get(rewriter.getContext(), newPorts);
62 rewriter.modifyOpInPlace(modOp, [&] { modOp.setHWModuleType(newType); });
74 : ConversionPattern(converter, moduleLikeOpName, 1, ctx) {}