Skip to content

Commit

Permalink
[firtool] Add optimization option -O [debug|release] (#3553)
Browse files Browse the repository at this point in the history
This adds an option to `firtool` to specify the optimizations at a large
granularity, with two `release` and `debug`. Right now, this just
customizes the value preservation flag. The use of a hook allows these
options to compose sensibly with the finer grained options, s the last
command line option specified overrides previous settings.
  • Loading branch information
youngar authored Jul 20, 2022
1 parent 3eaaecc commit 275e45f
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tools/firtool/firtool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,26 @@ static cl::opt<bool> stripDebugInfo(
cl::desc("Disable source locator information in output Verilog"),
cl::init(false), cl::cat(mainCategory));

// Build mode options.
enum BuildMode { BuildModeDebug, BuildModeRelease };
static cl::opt<BuildMode> buildMode(
"O", cl::desc("Controls how much optimization should be performed"),
cl::values(clEnumValN(BuildModeDebug, "debug",
"compile with only necessary optimizations"),
clEnumValN(BuildModeRelease, "release",
"compile with optimizations")),
cl::init(BuildModeRelease), cl::cat(mainCategory),
cl::callback([](const BuildMode &buildMode) {
switch (buildMode) {
case BuildModeDebug:
preserveMode = firrtl::PreserveValues::Named;
break;
case BuildModeRelease:
preserveMode = firrtl::PreserveValues::None;
break;
}
}));

/// Create a simple canonicalizer pass.
static std::unique_ptr<Pass> createSimpleCanonicalizerPass() {
mlir::GreedyRewriteConfig config;
Expand Down

0 comments on commit 275e45f

Please sign in to comment.