20#include "mlir/IR/BuiltinOps.h"
21#include "mlir/IR/PatternMatch.h"
22#include "mlir/Pass/Pass.h"
23#include "mlir/Pass/PassRegistry.h"
24#include "mlir/Transforms/DialectConversion.h"
25#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
29#define GEN_PASS_DEF_EXPORTTCL
30#include "circt/Dialect/MSFT/MSFTPasses.h.inc"
42template <
typename PhysOpTy>
48 matchAndRewrite(PhysOpTy op, OpAdaptor adaptor,
49 ConversionPatternRewriter &rewriter)
const final {
57struct ExportTclPass :
public circt::msft::impl::ExportTclBase<ExportTclPass> {
58 void runOnOperation()
override;
62void ExportTclPass::runOnOperation() {
63 auto top = getOperation();
64 auto *
ctxt = &getContext();
65 TclEmitter emitter(top);
69 for (
const std::string &moduleName : tops) {
71 emitter.getDefinition(FlatSymbolRefAttr::get(ctxt, moduleName));
73 top.emitError(
"Failed to find module '") << moduleName <<
"'";
77 if (failed(emitter.emit(hwmod, tclFile))) {
78 hwmod->emitError(
"failed to emit tcl");
84 ConversionTarget target(*ctxt);
85 target.addIllegalDialect<msft::MSFTDialect>();
86 target.addLegalDialect<hw::HWDialect>();
87 target.addLegalDialect<sv::SVDialect>();
90 patterns.insert<RemovePhysOpLowering<PDPhysLocationOp>>(
ctxt);
91 patterns.insert<RemovePhysOpLowering<PDRegPhysLocationOp>>(
ctxt);
92 patterns.insert<RemovePhysOpLowering<PDPhysRegionOp>>(
ctxt);
93 patterns.insert<RemovePhysOpLowering<InstanceHierarchyOp>>(
ctxt);
94 patterns.insert<RemovePhysOpLowering<DynamicInstanceVerbatimAttrOp>>(
ctxt);
95 patterns.insert<RemoveOpLowering<DeclPhysicalRegionOp>>(
ctxt);
96 if (failed(applyPartialConversion(top, target, std::move(
patterns))))
101 return std::make_unique<ExportTclPass>();
std::unique_ptr< mlir::Pass > createExportTclPass()
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.