13#include "../PassDetails.h"
24#include "mlir/Transforms/DialectConversion.h"
26#include "llvm/ADT/StringExtras.h"
27#include "llvm/ADT/TypeSwitch.h"
28#include "llvm/Support/JSON.h"
32#define GEN_PASS_DEF_LOWERESITOHW
33#include "circt/Dialect/ESI/ESIPasses.h.inc"
49 PipelineStageLowering(
ESIHWBuilder &builder, MLIRContext *ctxt)
51 using OpConversionPattern::OpConversionPattern;
54 matchAndRewrite(PipelineStageOp stage, OpAdaptor adaptor,
55 ConversionPatternRewriter &rewriter)
const final;
62LogicalResult PipelineStageLowering::matchAndRewrite(
63 PipelineStageOp stage, OpAdaptor adaptor,
64 ConversionPatternRewriter &rewriter)
const {
65 auto loc = stage.getLoc();
66 auto chPort = dyn_cast<ChannelType>(stage.getInput().getType());
68 return rewriter.notifyMatchFailure(stage,
"stage had wrong type");
69 Operation *symTable = stage->getParentWithTrait<OpTrait::SymbolTable>();
70 auto stageModule = builder.declareStage(symTable, stage);
74 ArrayAttr stageParams =
75 builder.getStageParameterList(rewriter.getUI32IntegerAttr(width));
83 UnwrapValidReadyOp::create(rewriter, loc, stage.getInput(), wrapReady);
85 StringRef pipeStageName =
"pipelineStage";
86 if (
auto name = stage->getAttrOfType<StringAttr>(
"name"))
87 pipeStageName = name.getValue();
91 llvm::SmallVector<Value> operands = {stage.getClk(), stage.getRst()};
92 operands.push_back(
unwrap.getRawOutput());
93 operands.push_back(
unwrap.getValid());
94 operands.push_back(stageReady);
95 auto stageInst = hw::InstanceOp::create(rewriter, loc, stageModule,
96 pipeStageName, operands, stageParams);
97 auto stageInstResults = stageInst.getResults();
101 wrapReady.
setValue(stageInstResults[0]);
103 x = stageInstResults[1];
104 xValid = stageInstResults[2];
107 auto wrap = WrapValidReadyOp::create(rewriter, loc, chPort,
108 rewriter.getI1Type(), x, xValid);
112 rewriter.replaceOp(stage,
wrap.getChanOutput());
120 using OpConversionPattern::OpConversionPattern;
123 matchAndRewrite(NullSourceOp nullop, OpAdaptor adaptor,
124 ConversionPatternRewriter &rewriter)
const final;
128LogicalResult NullSourceOpLowering::matchAndRewrite(
129 NullSourceOp nullop, OpAdaptor adaptor,
130 ConversionPatternRewriter &rewriter)
const {
131 auto innerType = cast<ChannelType>(nullop.getOut().getType()).getInner();
132 Location loc = nullop.getLoc();
133 int64_t width = hw::getBitWidth(
innerType);
135 return rewriter.notifyMatchFailure(
136 nullop,
"NullOp lowering only supports hw types");
138 rewriter.getI1Type(), 0);
142 auto wrap = WrapValidReadyOp::create(rewriter, loc, typedZero, valid);
143 wrap->setAttr(
"name", rewriter.getStringAttr(
"nullsource"));
144 rewriter.replaceOp(nullop, {
wrap.getChanOutput()});
150struct RemoveWrapUnwrap :
public ConversionPattern {
152 RemoveWrapUnwrap(MLIRContext *
context)
153 : ConversionPattern(MatchAnyOpTypeTag(), 1,
context) {}
156 matchAndRewrite(Operation *op, ArrayRef<Value> operands,
157 ConversionPatternRewriter &rewriter)
const override {
158 Value valid, ready,
data;
159 WrapValidReadyOp
wrap = dyn_cast<WrapValidReadyOp>(op);
160 UnwrapValidReadyOp
unwrap = dyn_cast<UnwrapValidReadyOp>(op);
162 if (ChannelType::hasNoConsumers(
wrap.getChanOutput())) {
164 rewriter.getI1Type(), 1);
165 rewriter.replaceOp(
wrap, {
nullptr, c1});
169 if (!ChannelType::hasOneConsumer(
wrap.getChanOutput()))
170 return rewriter.notifyMatchFailure(
171 wrap,
"This conversion only supports wrap-unwrap back-to-back. "
172 "Wrap didn't have exactly one use.");
173 if (!(
unwrap = dyn_cast<UnwrapValidReadyOp>(
174 ChannelType::getSingleConsumer(
wrap.getChanOutput())
176 return rewriter.notifyMatchFailure(
177 wrap,
"This conversion only supports wrap-unwrap back-to-back. "
178 "Could not find 'unwrap'.");
182 ready =
unwrap.getReady();
184 Operation *defOp = operands[0].getDefiningOp();
186 return rewriter.notifyMatchFailure(
187 unwrap,
"unwrap input is not defined by an op");
188 wrap = dyn_cast<WrapValidReadyOp>(defOp);
190 return rewriter.notifyMatchFailure(
191 operands[0].getDefiningOp(),
192 "This conversion only supports wrap-unwrap back-to-back. "
193 "Could not find 'wrap'.");
194 valid =
wrap.getValid();
201 if (!ChannelType::hasOneConsumer(
wrap.getChanOutput()))
202 return rewriter.notifyMatchFailure(
wrap, [](Diagnostic &d) {
203 d <<
"This conversion only supports wrap-unwrap back-to-back. "
204 "Wrap didn't have exactly one use.";
206 rewriter.replaceOp(
wrap, {
nullptr, ready});
217 using OpConversionPattern::OpConversionPattern;
220 matchAndRewrite(SnoopValidReadyOp op, SnoopValidReadyOpAdaptor operands,
221 ConversionPatternRewriter &rewriter)
const override {
222 Operation *defOp = op.getInput().getDefiningOp();
224 return rewriter.notifyMatchFailure(op,
225 "snoop input is not defined by an op");
226 auto wrap = dyn_cast<WrapValidReadyOp>(defOp);
228 return rewriter.notifyMatchFailure(
229 defOp,
"This conversion only supports wrap-unwrap back-to-back. "
230 "Could not find 'wrap'.");
231 auto *unwrapOpOperand =
232 ChannelType::getSingleConsumer(
wrap.getChanOutput());
233 if (!unwrapOpOperand)
234 return rewriter.notifyMatchFailure(
235 defOp,
"This conversion only supports wrap-unwrap back-to-back. "
236 "Could sole consumer.");
237 auto unwrap = dyn_cast<UnwrapValidReadyOp>(unwrapOpOperand->getOwner());
239 return rewriter.notifyMatchFailure(
240 defOp,
"This conversion only supports wrap-unwrap back-to-back. "
241 "Could not find 'unwrap'.");
251struct RemoveSnoopTransactionOp
254 using OpConversionPattern::OpConversionPattern;
257 matchAndRewrite(SnoopTransactionOp op, SnoopTransactionOpAdaptor operands,
258 ConversionPatternRewriter &rewriter)
const override {
259 Operation *defOp = op.getInput().getDefiningOp();
261 return rewriter.notifyMatchFailure(op,
262 "snoop input is not defined by an op");
265 if (
auto wrapVR = dyn_cast<WrapValidReadyOp>(defOp)) {
266 auto *unwrapOpOperand =
267 ChannelType::getSingleConsumer(wrapVR.getChanOutput());
268 if (!unwrapOpOperand)
269 return rewriter.notifyMatchFailure(
270 defOp,
"This conversion only supports wrap-unwrap back-to-back. "
271 "Could not find sole consumer.");
272 auto unwrapVR = dyn_cast<UnwrapValidReadyOp>(unwrapOpOperand->getOwner());
274 return rewriter.notifyMatchFailure(
275 defOp,
"This conversion only supports wrap-unwrap back-to-back. "
276 "Could not find 'unwrap'.");
279 auto validAndReady = comb::AndOp::create(
280 rewriter, op.getLoc(), wrapVR.getValid(), unwrapVR.getReady());
282 rewriter.replaceOp(op, {validAndReady, wrapVR.getRawInput()});
287 if (
auto wrapFIFO = dyn_cast<WrapFIFOOp>(defOp)) {
288 auto *unwrapOpOperand =
289 ChannelType::getSingleConsumer(wrapFIFO.getChanOutput());
290 if (!unwrapOpOperand)
291 return rewriter.notifyMatchFailure(
292 defOp,
"This conversion only supports wrap-unwrap back-to-back. "
293 "Could not find sole consumer.");
294 auto unwrapFIFO = dyn_cast<UnwrapFIFOOp>(unwrapOpOperand->getOwner());
296 return rewriter.notifyMatchFailure(
297 defOp,
"This conversion only supports wrap-unwrap back-to-back. "
298 "Could not find 'unwrap'.");
301 auto notEmpty = comb::XorOp::create(
302 rewriter, op.getLoc(), wrapFIFO.getEmpty(),
304 rewriter.getBoolAttr(
true)));
305 auto transaction = comb::AndOp::create(rewriter, op.getLoc(), notEmpty,
306 unwrapFIFO.getRden());
308 rewriter.replaceOp(op, {transaction, wrapFIFO.getData()});
312 return rewriter.notifyMatchFailure(
313 defOp,
"This conversion only supports wrap-unwrap back-to-back for "
314 "ValidReady and FIFO signaling.");
322template <
typename Op>
328 matchAndRewrite(Op op,
typename Op::Adaptor adaptor,
329 ConversionPatternRewriter &rewriter)
const final {
330 if (failed(Op::canonicalize(op, rewriter)))
331 return rewriter.notifyMatchFailure(op->getLoc(),
"canonicalizer failed");
338struct ESItoHWPass :
public circt::esi::impl::LowerESItoHWBase<ESItoHWPass> {
339 void runOnOperation()
override;
348 using OpConversionPattern::OpConversionPattern;
351 matchAndRewrite(WrapSVInterfaceOp
wrap, OpAdaptor adaptor,
352 ConversionPatternRewriter &rewriter)
const final;
357WrapInterfaceLower::matchAndRewrite(WrapSVInterfaceOp
wrap, OpAdaptor adaptor,
358 ConversionPatternRewriter &rewriter)
const {
359 auto operands = adaptor.getOperands();
360 if (operands.size() != 1)
361 return rewriter.notifyMatchFailure(
wrap, [&operands](Diagnostic &d) {
362 d <<
"wrap.iface has 1 argument. Got " << operands.size() <<
"operands";
364 auto sinkModport = dyn_cast<GetModportOp>(operands[0].getDefiningOp());
368 dyn_cast<InterfaceInstanceOp>(sinkModport.getIface().getDefiningOp());
372 auto loc =
wrap.getLoc();
373 auto validSignal = ReadInterfaceSignalOp::create(rewriter, loc, ifaceInstance,
376 dataSignal = ReadInterfaceSignalOp::create(rewriter, loc, ifaceInstance,
379 WrapValidReadyOp::create(rewriter, loc, dataSignal, validSignal);
380 AssignInterfaceSignalOp::create(rewriter, loc, ifaceInstance,
382 rewriter.replaceOp(
wrap, {wrapVR.getChanOutput()});
392 using OpConversionPattern::OpConversionPattern;
395 matchAndRewrite(UnwrapSVInterfaceOp
wrap, OpAdaptor adaptor,
396 ConversionPatternRewriter &rewriter)
const final;
400LogicalResult UnwrapInterfaceLower::matchAndRewrite(
401 UnwrapSVInterfaceOp
unwrap, OpAdaptor adaptor,
402 ConversionPatternRewriter &rewriter)
const {
403 auto operands = adaptor.getOperands();
404 if (operands.size() != 2)
405 return rewriter.notifyMatchFailure(
unwrap, [&operands](Diagnostic &d) {
406 d <<
"Unwrap.iface has 2 arguments. Got " << operands.size()
410 auto sourceModport = dyn_cast<GetModportOp>(operands[1].getDefiningOp());
414 dyn_cast<InterfaceInstanceOp>(sourceModport.getIface().getDefiningOp());
418 auto loc =
unwrap.getLoc();
419 auto readySignal = ReadInterfaceSignalOp::create(rewriter, loc, ifaceInstance,
422 UnwrapValidReadyOp::create(rewriter, loc, operands[0], readySignal);
423 AssignInterfaceSignalOp::create(rewriter, loc, ifaceInstance,
426 AssignInterfaceSignalOp::create(rewriter, loc, ifaceInstance,
428 unwrapVR.getRawOutput());
441 using OpConversionPattern::OpConversionPattern;
444 matchAndRewrite(CosimToHostEndpointOp, OpAdaptor adaptor,
445 ConversionPatternRewriter &rewriter)
const final;
452LogicalResult CosimToHostLowering::matchAndRewrite(
453 CosimToHostEndpointOp ep, OpAdaptor adaptor,
454 ConversionPatternRewriter &rewriter)
const {
455 auto loc = ep.getLoc();
456 auto *ctxt = rewriter.getContext();
459 Value toHost = adaptor.getToHost();
460 Type type = toHost.getType();
461 auto chanTy = dyn_cast<ChannelType>(type);
465 SmallVector<Attribute, 8> params;
466 params.push_back(ParamDeclAttr::get(
"ENDPOINT_ID", ep.getIdAttr()));
467 params.push_back(ParamDeclAttr::get(
"TO_HOST_TYPE_ID",
getTypeID(type)));
468 params.push_back(ParamDeclAttr::get(
469 "TO_HOST_SIZE_BITS", rewriter.getI32IntegerAttr(width > 0 ? width : 1)));
472 auto sendReady = bb.get(rewriter.getI1Type());
473 UnwrapValidReadyOp unwrapSend =
474 UnwrapValidReadyOp::create(rewriter, loc, toHost, sendReady);
476 Value rawSendData = unwrapSend.getRawOutput();
479 if (WindowType windowType = dyn_cast_or_null<WindowType>(chanTy.getInner()))
480 rawSendData = UnwrapWindow::create(rewriter, loc, rawSendData);
482 Value castedSendData;
485 rewriter, loc, rewriter.getIntegerType(width), rawSendData);
488 rewriter, loc, rewriter.getIntegerType(1), rewriter.getBoolAttr(
false));
491 Operation *symTable = ep->getParentWithTrait<OpTrait::SymbolTable>();
492 HWModuleExternOp endpoint =
493 builder.declareCosimEndpointToHostModule(symTable);
499 unwrapSend.getValid(),
503 hw::InstanceOp::create(rewriter, loc, endpoint, ep.getIdAttr(), operands,
504 ArrayAttr::get(ctxt, params));
505 sendReady.setValue(cosimEpModule.getResult(0));
508 rewriter.eraseOp(ep);
516struct CosimFromHostLowering
522 using OpConversionPattern::OpConversionPattern;
525 matchAndRewrite(CosimFromHostEndpointOp, OpAdaptor adaptor,
526 ConversionPatternRewriter &rewriter)
const final;
533LogicalResult CosimFromHostLowering::matchAndRewrite(
534 CosimFromHostEndpointOp ep, OpAdaptor adaptor,
535 ConversionPatternRewriter &rewriter)
const {
536 auto loc = ep.getLoc();
537 auto *ctxt = rewriter.getContext();
540 ChannelType type = ep.getFromHost().getType();
541 WindowType windowType = dyn_cast<WindowType>(type.getInner());
545 SmallVector<Attribute, 8> params;
546 params.push_back(ParamDeclAttr::get(
"ENDPOINT_ID", ep.getIdAttr()));
547 params.push_back(ParamDeclAttr::get(
"FROM_HOST_TYPE_ID",
getTypeID(type)));
549 ParamDeclAttr::get(
"FROM_HOST_SIZE_BITS",
550 rewriter.getI32IntegerAttr(width > 0 ? width : 1)));
553 auto recvReady = bb.get(rewriter.getI1Type());
556 Operation *symTable = ep->getParentWithTrait<OpTrait::SymbolTable>();
557 HWModuleExternOp endpoint =
558 builder.declareCosimEndpointFromHostModule(symTable);
561 Value operands[] = {adaptor.getClk(), adaptor.getRst(), recvReady};
563 hw::InstanceOp::create(rewriter, loc, endpoint, ep.getIdAttr(), operands,
564 ArrayAttr::get(ctxt, params));
567 Value recvDataFromCosim = cosimEpModule.getResult(1);
568 Value recvValidFromCosim = cosimEpModule.getResult(0);
569 Value castedRecvData;
570 Type castToType = windowType ? windowType.getLoweredType() : type.getInner();
576 rewriter, loc, rewriter.getIntegerType(0),
577 rewriter.getIntegerAttr(rewriter.getIntegerType(0), 0));
582 WrapWindow::create(rewriter, loc, windowType, castedRecvData);
584 WrapValidReadyOp wrapRecv = WrapValidReadyOp::create(
585 rewriter, loc, castedRecvData, recvValidFromCosim);
586 recvReady.setValue(wrapRecv.getReady());
589 rewriter.replaceOp(ep, wrapRecv.getChanOutput());
600 using OpConversionPattern::OpConversionPattern;
601 constexpr static StringRef manifestRomName =
"__ESI_Manifest_ROM";
604 matchAndRewrite(CompressedManifestOp, OpAdaptor adaptor,
605 ConversionPatternRewriter &rewriter)
const override;
608 LogicalResult createRomModule(CompressedManifestOp op,
609 ConversionPatternRewriter &rewriter)
const;
613LogicalResult ManifestRomLowering::createRomModule(
614 CompressedManifestOp op, ConversionPatternRewriter &rewriter)
const {
615 Location loc = op.getLoc();
616 auto mlirModBody = op->getParentOfType<mlir::ModuleOp>();
617 rewriter.setInsertionPointToStart(mlirModBody.getBody());
621 if (Operation *existingExtern = mlirModBody.lookupSymbol(manifestRomName)) {
622 if (!isa<hw::HWModuleExternOp>(existingExtern))
623 return rewriter.notifyMatchFailure(
625 "Found " + manifestRomName +
" but it wasn't an HWModuleExternOp");
626 rewriter.eraseOp(existingExtern);
631 {{rewriter.getStringAttr(
"clk"), rewriter.getType<seq::ClockType>(),
632 ModulePort::Direction::Input}},
633 {{rewriter.getStringAttr(
"address"), rewriter.getIntegerType(29),
634 ModulePort::Direction::Input}},
635 {{rewriter.getStringAttr(
"data"), rewriter.getI64Type(),
636 ModulePort::Direction::Output}},
638 auto rom = HWModuleOp::create(rewriter, loc,
639 rewriter.getStringAttr(manifestRomName), ports);
640 Block *romBody = rom.getBodyBlock();
641 rewriter.setInsertionPointToStart(romBody);
642 Value
clk = romBody->getArgument(0);
643 Value inputAddress = romBody->getArgument(1);
646 ArrayRef<uint8_t> maniBytes = op.getCompressedManifest().getData();
647 SmallVector<uint64_t> words;
648 words.push_back(maniBytes.size());
650 for (
size_t i = 0; i < maniBytes.size() - 7; i += 8) {
652 for (
size_t b = 0; b < 8; ++b)
653 word |=
static_cast<uint64_t
>(maniBytes[i + b]) << (8 * b);
654 words.push_back(word);
656 size_t overHang = maniBytes.size() % 8;
659 for (
size_t i = 0; i < overHang; ++i)
660 word |=
static_cast<uint64_t
>(maniBytes[maniBytes.size() - overHang + i])
662 words.push_back(word);
667 SmallVector<Attribute> wordAttrs;
668 for (uint64_t word : words)
669 wordAttrs.push_back(rewriter.getI64IntegerAttr(word));
670 auto manifestConstant = hw::AggregateConstantOp::create(
672 hw::UnpackedArrayType::get(rewriter.getI64Type(), words.size()),
673 rewriter.getArrayAttr(wordAttrs));
675 sv::RegOp::create(rewriter, loc, manifestConstant.getType());
679 size_t addrBits = llvm::Log2_64_Ceil(words.size());
684 sv::ArrayIndexInOutOp::create(rewriter, loc, manifestReg, inputAddresReg);
687 if (
auto *term = romBody->getTerminator())
688 rewriter.eraseOp(term);
689 hw::OutputOp::create(rewriter, loc, ValueRange{readDataReg});
693LogicalResult ManifestRomLowering::matchAndRewrite(
694 CompressedManifestOp op, OpAdaptor adaptor,
695 ConversionPatternRewriter &rewriter)
const {
696 LogicalResult ret = createRomModule(op, rewriter);
697 rewriter.eraseOp(op);
704struct CosimManifestLowering :
public ManifestRomLowering {
706 using ManifestRomLowering::ManifestRomLowering;
709 matchAndRewrite(CompressedManifestOp, OpAdaptor adaptor,
710 ConversionPatternRewriter &rewriter)
const final;
714LogicalResult CosimManifestLowering::matchAndRewrite(
715 CompressedManifestOp op, OpAdaptor adaptor,
716 ConversionPatternRewriter &rewriter)
const {
717 MLIRContext *ctxt = rewriter.getContext();
718 Location loc = op.getLoc();
722 LogicalResult ret = createRomModule(op, rewriter);
727 Attribute params[] = {
728 ParamDeclAttr::get(
"COMPRESSED_MANIFEST_SIZE", rewriter.getI32Type())};
730 {{rewriter.getStringAttr(
"compressed_manifest"),
731 rewriter.getType<hw::ArrayType>(
732 rewriter.getI8Type(),
733 ParamDeclRefAttr::get(
734 rewriter.getStringAttr(
"COMPRESSED_MANIFEST_SIZE"),
735 rewriter.getI32Type())),
736 ModulePort::Direction::Input},
739 rewriter.setInsertionPointToEnd(
740 op->getParentOfType<mlir::ModuleOp>().getBody());
741 auto cosimManifestExternModule = HWModuleExternOp::create(
742 rewriter, loc, rewriter.getStringAttr(
"Cosim_Manifest"), ports,
743 "Cosim_Manifest", ArrayAttr::get(ctxt, params));
746 auto manifestMod = hw::HWModuleOp::create(
747 rewriter, loc, rewriter.getStringAttr(
"__ESIManifest"), portInfo,
750 SmallVector<Attribute> bytes;
751 for (uint8_t b : op.getCompressedManifest().getData())
752 bytes.push_back(rewriter.getI8IntegerAttr(b));
753 auto manifestConstant = hw::AggregateConstantOp::create(
755 hw::ArrayType::get(rewriter.getI8Type(), bytes.size()),
756 rewriter.getArrayAttr(bytes));
758 sv::LogicOp::create(rewriter, loc, manifestConstant.getType());
759 sv::AssignOp::create(rewriter, loc, manifestLogic, manifestConstant);
760 auto manifest = sv::ReadInOutOp::create(rewriter, loc, manifestLogic);
763 hw::InstanceOp::create(rewriter, loc, cosimManifestExternModule,
764 "__manifest", ArrayRef<Value>({manifest}),
765 rewriter.getArrayAttr({ParamDeclAttr::get(
766 "COMPRESSED_MANIFEST_SIZE",
767 rewriter.getI32IntegerAttr(bytes.size()))}));
770 rewriter.setInsertionPoint(op);
771 hw::InstanceOp::create(rewriter, loc, manifestMod,
"__manifest",
772 ArrayRef<Value>({}));
774 rewriter.eraseOp(op);
777void ESItoHWPass::runOnOperation() {
778 auto top = getOperation();
779 auto *ctxt = &getContext();
782 ConversionTarget noBundlesTarget(*ctxt);
783 noBundlesTarget.markUnknownOpDynamicallyLegal(
784 [](Operation *) {
return true; });
785 noBundlesTarget.addIllegalOp<PackBundleOp>();
786 noBundlesTarget.addIllegalOp<UnpackBundleOp>();
787 RewritePatternSet bundlePatterns(&getContext());
788 bundlePatterns.add<CanonicalizerOpLowering<PackBundleOp>>(&getContext());
789 bundlePatterns.add<CanonicalizerOpLowering<UnpackBundleOp>>(&getContext());
790 if (failed(applyPartialConversion(getOperation(), noBundlesTarget,
791 std::move(bundlePatterns)))) {
797 ConversionTarget pass1Target(*ctxt);
798 pass1Target.addLegalDialect<comb::CombDialect>();
799 pass1Target.addLegalDialect<HWDialect>();
800 pass1Target.addLegalDialect<SVDialect>();
801 pass1Target.addLegalDialect<seq::SeqDialect>();
802 pass1Target.addLegalOp<WrapValidReadyOp, UnwrapValidReadyOp, WrapFIFOOp,
803 UnwrapFIFOOp, WrapWindow, UnwrapWindow>();
804 pass1Target.addLegalOp<SnoopTransactionOp, SnoopValidReadyOp>();
806 pass1Target.addIllegalOp<WrapSVInterfaceOp, UnwrapSVInterfaceOp>();
807 pass1Target.addIllegalOp<PipelineStageOp>();
808 pass1Target.addIllegalOp<CompressedManifestOp>();
812 RewritePatternSet pass1Patterns(ctxt);
813 pass1Patterns.insert<PipelineStageLowering>(esiBuilder, ctxt);
814 pass1Patterns.insert<WrapInterfaceLower>(ctxt);
815 pass1Patterns.insert<UnwrapInterfaceLower>(ctxt);
816 pass1Patterns.insert<CosimToHostLowering>(esiBuilder);
817 pass1Patterns.insert<CosimFromHostLowering>(esiBuilder);
818 pass1Patterns.insert<NullSourceOpLowering>(ctxt);
821 pass1Patterns.insert<CosimManifestLowering>(ctxt);
823 pass1Patterns.insert<ManifestRomLowering>(ctxt);
829 applyPartialConversion(top, pass1Target, std::move(pass1Patterns)))) {
835 ConversionTarget pass2Target(*ctxt);
836 pass2Target.addLegalDialect<comb::CombDialect>();
837 pass2Target.addLegalDialect<HWDialect>();
838 pass2Target.addLegalDialect<SVDialect>();
839 pass2Target.addIllegalOp<SnoopTransactionOp, SnoopValidReadyOp>();
840 pass2Target.addLegalOp<WrapValidReadyOp, UnwrapValidReadyOp, WrapFIFOOp,
842 RewritePatternSet pass2Patterns(ctxt);
843 pass2Patterns.insert<RemoveSnoopOp>(ctxt);
844 pass2Patterns.insert<RemoveSnoopTransactionOp>(ctxt);
846 applyPartialConversion(top, pass2Target, std::move(pass2Patterns)))) {
852 ConversionTarget pass3Target(*ctxt);
853 pass3Target.addLegalDialect<comb::CombDialect>();
854 pass3Target.addLegalDialect<HWDialect>();
855 pass3Target.addLegalDialect<SVDialect>();
856 pass3Target.addIllegalDialect<ESIDialect>();
857 pass3Target.addLegalOp<WrapWindow, UnwrapWindow>();
859 RewritePatternSet pass3Patterns(ctxt);
860 pass3Patterns.insert<CanonicalizerOpLowering<UnwrapFIFOOp>>(ctxt);
861 pass3Patterns.insert<CanonicalizerOpLowering<WrapFIFOOp>>(ctxt);
862 pass3Patterns.insert<RemoveWrapUnwrap>(ctxt);
864 applyPartialConversion(top, pass3Target, std::move(pass3Patterns))))
869 return std::make_unique<ESItoHWPass>();
return wrap(CMemoryType::get(unwrap(ctx), baseType, numElements))
static std::unique_ptr< Context > context
static EvaluatorValuePtr unwrap(OMEvaluatorValue c)
Instantiate one of these and use it to build typed backedges.
Backedge is a wrapper class around a Value.
void setValue(mlir::Value)
Assist the lowering steps for conversions which need to create auxiliary IR.
static constexpr char validStr[]
static constexpr char readyStr[]
static constexpr char dataStr[]
create(cls, result_type, reset=None, reset_value=None, name=None, sym_name=None, **kwargs)
uint64_t getWidth(Type t)
StringAttr getTypeID(Type t)
std::unique_ptr< OperationPass< ModuleOp > > createESItoHWPass()
mlir::Type innerType(mlir::Type type)
int64_t getBitWidth(mlir::Type type)
Return the hardware bit width of a type.
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Generic pattern for removing an op during pattern conversion.
This holds a decoded list of input/inout and output ports for a module or instance.
This holds the name, type, direction of a module's ports.