Skip to content

[MLIR][NFC] Retire let constructor for Reducer #134786

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 8, 2025

Conversation

chelini
Copy link
Contributor

@chelini chelini commented Apr 8, 2025

let constructor is legacy (do not use in tree!) since the tableGen
backend emits most of the glue logic to build a pass.

@chelini chelini requested a review from joker-eph April 8, 2025 04:54
@llvmbot llvmbot added mlir:core MLIR Core Infrastructure mlir labels Apr 8, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 8, 2025

@llvm/pr-subscribers-mlir

@llvm/pr-subscribers-mlir-core

Author: lorenzo chelini (chelini)

Changes

let constructor is legacy (do not use in tree!) since the tableGen
backend emits most of the glue logic to build a pass.


Full diff: https://github.com/llvm/llvm-project/pull/134786.diff

4 Files Affected:

  • (modified) mlir/include/mlir/Reducer/Passes.h (-4)
  • (modified) mlir/include/mlir/Reducer/Passes.td (+2-6)
  • (modified) mlir/lib/Reducer/OptReductionPass.cpp (+5-7)
  • (modified) mlir/lib/Reducer/ReductionTreePass.cpp (+4-8)
diff --git a/mlir/include/mlir/Reducer/Passes.h b/mlir/include/mlir/Reducer/Passes.h
index 474d87a37fc3c..d961737aaffae 100644
--- a/mlir/include/mlir/Reducer/Passes.h
+++ b/mlir/include/mlir/Reducer/Passes.h
@@ -15,10 +15,6 @@ namespace mlir {
 #define GEN_PASS_DECL
 #include "mlir/Reducer/Passes.h.inc"
 
-std::unique_ptr<Pass> createReductionTreePass();
-
-std::unique_ptr<Pass> createOptReductionPass();
-
 /// Generate the code for registering reducer passes.
 #define GEN_PASS_REGISTRATION
 #include "mlir/Reducer/Passes.h.inc"
diff --git a/mlir/include/mlir/Reducer/Passes.td b/mlir/include/mlir/Reducer/Passes.td
index cf89176106050..624e2e1edc329 100644
--- a/mlir/include/mlir/Reducer/Passes.td
+++ b/mlir/include/mlir/Reducer/Passes.td
@@ -24,11 +24,9 @@ def CommonReductionPassOptions {
   ];
 }
 
-def ReductionTree : Pass<"reduction-tree"> {
+def ReductionTreePass : Pass<"reduction-tree"> {
   let summary = "Reduce the input with reduction-tree algorithm";
 
-  let constructor = "mlir::createReductionTreePass()";
-
   let options = [
     Option<"traversalModeId", "traversal-mode", "unsigned",
            /* default */"0",
@@ -36,11 +34,9 @@ def ReductionTree : Pass<"reduction-tree"> {
   ] # CommonReductionPassOptions.options;
 }
 
-def OptReduction : Pass<"opt-reduction-pass", "ModuleOp"> {
+def OptReductionPass : Pass<"opt-reduction-pass", "ModuleOp"> {
   let summary = "A wrapper pass that reduces the file with optimization passes";
 
-  let constructor = "mlir::createOptReductionPass()";
-
   let options = [
     Option<"optPass", "opt-pass", "std::string", /* default */"",
            "The optimization passes used for reduction, e.g., symbol-dce">,
diff --git a/mlir/lib/Reducer/OptReductionPass.cpp b/mlir/lib/Reducer/OptReductionPass.cpp
index 8618de5eeee7b..358753b1168d2 100644
--- a/mlir/lib/Reducer/OptReductionPass.cpp
+++ b/mlir/lib/Reducer/OptReductionPass.cpp
@@ -19,7 +19,7 @@
 #include "llvm/Support/Debug.h"
 
 namespace mlir {
-#define GEN_PASS_DEF_OPTREDUCTION
+#define GEN_PASS_DEF_OPTREDUCTIONPASS
 #include "mlir/Reducer/Passes.h.inc"
 } // namespace mlir
 
@@ -29,8 +29,10 @@ using namespace mlir;
 
 namespace {
 
-class OptReductionPass : public impl::OptReductionBase<OptReductionPass> {
+class OptReductionPass : public impl::OptReductionPassBase<OptReductionPass> {
 public:
+  using Base::Base;
+
   /// Runs the pass instance in the pass pipeline.
   void runOnOperation() override;
 };
@@ -85,8 +87,4 @@ void OptReductionPass::runOnOperation() {
   moduleVariant->destroy();
 
   LLVM_DEBUG(llvm::dbgs() << "Pass Complete\n\n");
-}
-
-std::unique_ptr<Pass> mlir::createOptReductionPass() {
-  return std::make_unique<OptReductionPass>();
-}
+}
\ No newline at end of file
diff --git a/mlir/lib/Reducer/ReductionTreePass.cpp b/mlir/lib/Reducer/ReductionTreePass.cpp
index ef32adbab5577..7292752c712ae 100644
--- a/mlir/lib/Reducer/ReductionTreePass.cpp
+++ b/mlir/lib/Reducer/ReductionTreePass.cpp
@@ -29,7 +29,7 @@
 #include "llvm/Support/ManagedStatic.h"
 
 namespace mlir {
-#define GEN_PASS_DEF_REDUCTIONTREE
+#define GEN_PASS_DEF_REDUCTIONTREEPASS
 #include "mlir/Reducer/Passes.h.inc"
 } // namespace mlir
 
@@ -191,10 +191,10 @@ class ReductionPatternInterfaceCollection
 /// This class defines the Reduction Tree Pass. It provides a framework to
 /// to implement a reduction pass using a tree structure to keep track of the
 /// generated reduced variants.
-class ReductionTreePass : public impl::ReductionTreeBase<ReductionTreePass> {
+class ReductionTreePass
+    : public impl::ReductionTreePassBase<ReductionTreePass> {
 public:
-  ReductionTreePass() = default;
-  ReductionTreePass(const ReductionTreePass &pass) = default;
+  using Base::Base;
 
   LogicalResult initialize(MLIRContext *context) override;
 
@@ -256,7 +256,3 @@ LogicalResult ReductionTreePass::reduceOp(ModuleOp module, Region &region) {
     return module.emitError() << "unsupported traversal mode detected";
   }
 }
-
-std::unique_ptr<Pass> mlir::createReductionTreePass() {
-  return std::make_unique<ReductionTreePass>();
-}

@chelini chelini merged commit e7365d3 into llvm:main Apr 8, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mlir:core MLIR Core Infrastructure mlir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants