[ExportVerilog] Use ODS constructor for pre-passes

Convert ExportVerilog pre-passes to use ODS constructors instead of
unnecessarily hand-rolling custom constructors.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
This commit is contained in:
Schuyler Eldridge 2025-07-14 21:53:21 -04:00
parent ec79b1b617
commit e5603e1437
No known key found for this signature in database
GPG Key ID: 50C5E9936AAD536D
7 changed files with 8 additions and 37 deletions

View File

@ -30,14 +30,6 @@ class HWModuleLike;
class HWEmittableModuleLike;
} // namespace hw
std::unique_ptr<mlir::Pass>
createTestApplyLoweringOptionPass(llvm::StringRef options);
std::unique_ptr<mlir::Pass> createTestApplyLoweringOptionPass();
std::unique_ptr<mlir::Pass> createHWLowerInstanceChoicesPass();
std::unique_ptr<mlir::Pass> createPrepareForEmissionPass();
std::unique_ptr<mlir::Pass> createLegalizeAnonEnumsPass();
std::unique_ptr<mlir::Pass>
createExportVerilogPass(std::unique_ptr<llvm::raw_ostream> os);
std::unique_ptr<mlir::Pass> createExportVerilogPass(llvm::raw_ostream &os);

View File

@ -83,7 +83,6 @@ def TestApplyLoweringOption : Pass<"test-apply-lowering-options",
construction.
}];
let constructor = "createTestApplyLoweringOptionPass()";
let dependentDialects = [
"circt::sv::SVDialect", "circt::comb::CombDialect", "circt::hw::HWDialect"
];
@ -98,7 +97,6 @@ def LegalizeAnonEnums : Pass<"legalize-anon-enums", "mlir::ModuleOp"> {
This pass transforms all anonymous enumeration types into typedecls to work
around difference in how anonymous enumerations work in SystemVerilog.
}];
let constructor = "createLegalizeAnonEnumsPass()";
let dependentDialects = [
"circt::sv::SVDialect", "circt::comb::CombDialect", "circt::hw::HWDialect"
];
@ -111,8 +109,6 @@ def HWLowerInstanceChoices : Pass<"hw-lower-instance-choices",
This pass runs as part of verilog emission.
It introduces the macros & file lists to which instance choices lower to.
}];
let constructor = "createHWLowerInstanceChoicesPass()";
let dependentDialects = [
"circt::sv::SVDialect", "circt::hw::HWDialect"
];
@ -125,8 +121,6 @@ def PrepareForEmission : Pass<"prepare-for-emission"> {
It is not necessary for users to run this pass explicitly since
ExportVerilog internally runs PrepareForEmission.
}];
let constructor = "createPrepareForEmissionPass()";
let dependentDialects = [
"circt::sv::SVDialect", "circt::comb::CombDialect", "circt::hw::HWDialect"
];
@ -856,7 +850,7 @@ def ConvertAIGToComb: Pass<"convert-aig-to-comb", "hw::HWModuleOp"> {
def ConvertCombToDatapath: Pass<"convert-comb-to-datapath", "hw::HWModuleOp"> {
let summary = "Lower Comb ops to Datapath ops";
let description = [{
This pass converts arithmetic Comb operations into Datapath operations that
This pass converts arithmetic Comb operations into Datapath operations that
leverage redundant number representations (carry save). Primarily for use
in the circt-synth flow.
}];

View File

@ -28,7 +28,8 @@ namespace {
struct TestApplyLoweringOptionPass
: public circt::impl::TestApplyLoweringOptionBase<
TestApplyLoweringOptionPass> {
TestApplyLoweringOptionPass() = default;
using Base::Base;
void runOnOperation() override {
if (!optionsString.hasValue()) {
markAllAnalysesPreserved();
@ -42,7 +43,3 @@ struct TestApplyLoweringOptionPass
}
};
} // namespace
std::unique_ptr<mlir::Pass> circt::createTestApplyLoweringOptionPass() {
return std::make_unique<TestApplyLoweringOptionPass>();
}

View File

@ -7116,10 +7116,10 @@ struct ExportVerilogPass
void runOnOperation() override {
// Prepare the ops in the module for emission.
mlir::OpPassManager preparePM("builtin.module");
preparePM.addPass(createLegalizeAnonEnumsPass());
preparePM.addPass(createHWLowerInstanceChoicesPass());
preparePM.addPass(createLegalizeAnonEnums());
preparePM.addPass(createHWLowerInstanceChoices());
auto &modulePM = preparePM.nestAny();
modulePM.addPass(createPrepareForEmissionPass());
modulePM.addPass(createPrepareForEmission());
if (failed(runPipeline(preparePM, getOperation())))
return signalPassFailure();
@ -7298,10 +7298,10 @@ struct ExportSplitVerilogPass
void runOnOperation() override {
// Prepare the ops in the module for emission.
mlir::OpPassManager preparePM("builtin.module");
preparePM.addPass(createHWLowerInstanceChoicesPass());
preparePM.addPass(createHWLowerInstanceChoices());
auto &modulePM = preparePM.nest<hw::HWModuleOp>();
modulePM.addPass(createPrepareForEmissionPass());
modulePM.addPass(createPrepareForEmission());
if (failed(runPipeline(preparePM, getOperation())))
return signalPassFailure();

View File

@ -111,7 +111,3 @@ void HWLowerInstanceChoicesPass::runOnOperation() {
if (failed(lowerHWInstanceChoices(module)))
signalPassFailure();
}
std::unique_ptr<mlir::Pass> circt::createHWLowerInstanceChoicesPass() {
return std::make_unique<HWLowerInstanceChoicesPass>();
}

View File

@ -205,7 +205,3 @@ struct LegalizeAnonEnums
};
} // end anonymous namespace
std::unique_ptr<mlir::Pass> circt::createLegalizeAnonEnumsPass() {
return std::make_unique<LegalizeAnonEnums>();
}

View File

@ -1404,7 +1404,3 @@ struct PrepareForEmissionPass
};
} // end anonymous namespace
std::unique_ptr<mlir::Pass> circt::createPrepareForEmissionPass() {
return std::make_unique<PrepareForEmissionPass>();
}