Skip to content

Commit

Permalink
[firtool] Add option to disable layer sink
Browse files Browse the repository at this point in the history
The layer sink pass is showing some performance problems, and we want
the ability to turn it off to work around the issue, until we can
properly fix it.
  • Loading branch information
youngar committed Dec 13, 2024
1 parent 2aaf978 commit 1ddaf68
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
7 changes: 7 additions & 0 deletions include/circt/Firtool/Firtool.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -189,6 +190,11 @@ class FirtoolOptions {
return *this;
}

FirtoolOptions &setDisableLayerSink(bool value) {
disableLayerSink = value;
return *this;
}

FirtoolOptions &setDisableOptimization(bool value) {
disableOptimization = value;
return *this;
Expand Down Expand Up @@ -381,6 +387,7 @@ class FirtoolOptions {
firrtl::PreserveValues::PreserveMode preserveMode;
bool enableDebugInfo;
BuildMode buildMode;
bool disableLayerSink;
bool disableOptimization;
bool exportChiselInterface;
std::string chiselInterfaceOutDirectory;
Expand Down
19 changes: 14 additions & 5 deletions lib/Firtool/Firtool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<firrtl::CircuitOp>().addPass(firrtl::createAdvancedLayerSinkPass());
else
pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
firrtl::createLayerSinkPass());
if (opt.shouldDisableLayerSink()) {
if (opt.shouldAdvancedLayerSink())
pm.nest<firrtl::CircuitOp>().addPass(
firrtl::createAdvancedLayerSinkPass());
else
pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
firrtl::createLayerSinkPass());
}
pm.nest<firrtl::CircuitOp>().addPass(firrtl::createLowerLayersPass());
if (!opt.shouldDisableOptimization())
pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
Expand Down Expand Up @@ -522,6 +525,11 @@ struct FirtoolCmdOptions {
"release", "Compile with optimizations")),
llvm::cl::init(firtool::FirtoolOptions::BuildModeDefault)};

llvm::cl::opt<bool> disableLayerSink{
"disable-layer-sink",
llvm::cl::desc("Disable layer sink"),
};

llvm::cl::opt<bool> disableOptimization{
"disable-opt",
llvm::cl::desc("Disable optimizations"),
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 1ddaf68

Please sign in to comment.