diff --git a/include/circt/Firtool/Firtool.h b/include/circt/Firtool/Firtool.h index baed0b88fa67..fb85cbebe4bb 100644 --- a/include/circt/Firtool/Firtool.h +++ b/include/circt/Firtool/Firtool.h @@ -96,6 +96,7 @@ class FirtoolOptions { } bool shouldConvertProbesToSignals() const { return probesToSignals; } bool shouldReplaceSequentialMemories() const { return replSeqMem; } + bool shouldDisableLayerSink() const { return disableLayerSink; } bool shouldDisableOptimization() const { return disableOptimization; } bool shouldAdvancedLayerSink() const { return advancedLayerSink; } bool shouldLowerMemories() const { return lowerMemories; } @@ -189,6 +190,11 @@ class FirtoolOptions { return *this; } + FirtoolOptions &setDisableLayerSink(bool value) { + disableLayerSink = value; + return *this; + } + FirtoolOptions &setDisableOptimization(bool value) { disableOptimization = value; return *this; @@ -381,6 +387,7 @@ class FirtoolOptions { firrtl::PreserveValues::PreserveMode preserveMode; bool enableDebugInfo; BuildMode buildMode; + bool disableLayerSink; bool disableOptimization; bool exportChiselInterface; std::string chiselInterfaceOutDirectory; diff --git a/lib/Firtool/Firtool.cpp b/lib/Firtool/Firtool.cpp index 4aa85db1b08d..cd67d417647e 100644 --- a/lib/Firtool/Firtool.cpp +++ b/lib/Firtool/Firtool.cpp @@ -228,11 +228,14 @@ LogicalResult firtool::populateCHIRRTLToLowFIRRTL(mlir::PassManager &pm, // // TODO: Improve LowerLayers to avoid the need for canonicalization. See: // https://github.com/llvm/circt/issues/7896 - if (opt.shouldAdvancedLayerSink()) - pm.nest().addPass(firrtl::createAdvancedLayerSinkPass()); - else - pm.nest().nest().addPass( - firrtl::createLayerSinkPass()); + if (opt.shouldDisableLayerSink()) { + if (opt.shouldAdvancedLayerSink()) + pm.nest().addPass( + firrtl::createAdvancedLayerSinkPass()); + else + pm.nest().nest().addPass( + firrtl::createLayerSinkPass()); + } pm.nest().addPass(firrtl::createLowerLayersPass()); if (!opt.shouldDisableOptimization()) pm.nest().nest().addPass( @@ -522,6 +525,11 @@ struct FirtoolCmdOptions { "release", "Compile with optimizations")), llvm::cl::init(firtool::FirtoolOptions::BuildModeDefault)}; + llvm::cl::opt disableLayerSink{ + "disable-layer-sink", + llvm::cl::desc("Disable layer sink"), + }; + llvm::cl::opt disableOptimization{ "disable-opt", llvm::cl::desc("Disable optimizations"), @@ -789,6 +797,7 @@ circt::firtool::FirtoolOptions::FirtoolOptions() preserveMode = clOptions->preserveMode; enableDebugInfo = clOptions->enableDebugInfo; buildMode = clOptions->buildMode; + disableLayerSink = clOptions->disableLayerSink; disableOptimization = clOptions->disableOptimization; exportChiselInterface = clOptions->exportChiselInterface; chiselInterfaceOutDirectory = clOptions->chiselInterfaceOutDirectory;