Skip to content

[MLIR][NFC] Retire let constructor for EmitC #133732

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 1 commit into from
Apr 1, 2025

Conversation

chelini
Copy link
Contributor

@chelini chelini commented Mar 31, 2025

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

@llvmbot
Copy link
Member

llvmbot commented Mar 31, 2025

@llvm/pr-subscribers-mlir

Author: lorenzo chelini (chelini)

Changes

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

3 Files Affected:

  • (modified) mlir/include/mlir/Dialect/EmitC/Transforms/Passes.h (+2-6)
  • (modified) mlir/include/mlir/Dialect/EmitC/Transforms/Passes.td (+1-2)
  • (modified) mlir/lib/Dialect/EmitC/Transforms/FormExpressions.cpp (+2-6)
diff --git a/mlir/include/mlir/Dialect/EmitC/Transforms/Passes.h b/mlir/include/mlir/Dialect/EmitC/Transforms/Passes.h
index 5cd27149d366e..5a103f181c76b 100644
--- a/mlir/include/mlir/Dialect/EmitC/Transforms/Passes.h
+++ b/mlir/include/mlir/Dialect/EmitC/Transforms/Passes.h
@@ -14,12 +14,8 @@
 namespace mlir {
 namespace emitc {
 
-//===----------------------------------------------------------------------===//
-// Passes
-//===----------------------------------------------------------------------===//
-
-/// Creates an instance of the C-style expressions forming pass.
-std::unique_ptr<Pass> createFormExpressionsPass();
+#define GEN_PASS_DECL_FORMEXPRESSIONSPASS
+#include "mlir/Dialect/EmitC/Transforms/Passes.h.inc"
 
 //===----------------------------------------------------------------------===//
 // Registration
diff --git a/mlir/include/mlir/Dialect/EmitC/Transforms/Passes.td b/mlir/include/mlir/Dialect/EmitC/Transforms/Passes.td
index fd083abc95715..f46b705ca2dfe 100644
--- a/mlir/include/mlir/Dialect/EmitC/Transforms/Passes.td
+++ b/mlir/include/mlir/Dialect/EmitC/Transforms/Passes.td
@@ -11,13 +11,12 @@
 
 include "mlir/Pass/PassBase.td"
 
-def FormExpressions : Pass<"form-expressions"> {
+def FormExpressionsPass : Pass<"form-expressions"> {
   let summary = "Form C-style expressions from C-operator ops";
   let description = [{
     The pass wraps emitc ops modelling C operators in emitc.expression ops and
     then folds single-use expressions into their users where possible.
   }];
-  let constructor = "mlir::emitc::createFormExpressionsPass()";
   let dependentDialects = ["emitc::EmitCDialect"];
 }
 
diff --git a/mlir/lib/Dialect/EmitC/Transforms/FormExpressions.cpp b/mlir/lib/Dialect/EmitC/Transforms/FormExpressions.cpp
index 3385514375804..224d68ab8b4a6 100644
--- a/mlir/lib/Dialect/EmitC/Transforms/FormExpressions.cpp
+++ b/mlir/lib/Dialect/EmitC/Transforms/FormExpressions.cpp
@@ -18,7 +18,7 @@
 
 namespace mlir {
 namespace emitc {
-#define GEN_PASS_DEF_FORMEXPRESSIONS
+#define GEN_PASS_DEF_FORMEXPRESSIONSPASS
 #include "mlir/Dialect/EmitC/Transforms/Passes.h.inc"
 } // namespace emitc
 } // namespace mlir
@@ -28,7 +28,7 @@ using namespace emitc;
 
 namespace {
 struct FormExpressionsPass
-    : public emitc::impl::FormExpressionsBase<FormExpressionsPass> {
+    : public emitc::impl::FormExpressionsPassBase<FormExpressionsPass> {
   void runOnOperation() override {
     Operation *rootOp = getOperation();
     MLIRContext *context = rootOp->getContext();
@@ -56,7 +56,3 @@ struct FormExpressionsPass
   }
 };
 } // namespace
-
-std::unique_ptr<Pass> mlir::emitc::createFormExpressionsPass() {
-  return std::make_unique<FormExpressionsPass>();
-}

@llvmbot
Copy link
Member

llvmbot commented Mar 31, 2025

@llvm/pr-subscribers-mlir-emitc

Author: lorenzo chelini (chelini)

Changes

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

3 Files Affected:

  • (modified) mlir/include/mlir/Dialect/EmitC/Transforms/Passes.h (+2-6)
  • (modified) mlir/include/mlir/Dialect/EmitC/Transforms/Passes.td (+1-2)
  • (modified) mlir/lib/Dialect/EmitC/Transforms/FormExpressions.cpp (+2-6)
diff --git a/mlir/include/mlir/Dialect/EmitC/Transforms/Passes.h b/mlir/include/mlir/Dialect/EmitC/Transforms/Passes.h
index 5cd27149d366e..5a103f181c76b 100644
--- a/mlir/include/mlir/Dialect/EmitC/Transforms/Passes.h
+++ b/mlir/include/mlir/Dialect/EmitC/Transforms/Passes.h
@@ -14,12 +14,8 @@
 namespace mlir {
 namespace emitc {
 
-//===----------------------------------------------------------------------===//
-// Passes
-//===----------------------------------------------------------------------===//
-
-/// Creates an instance of the C-style expressions forming pass.
-std::unique_ptr<Pass> createFormExpressionsPass();
+#define GEN_PASS_DECL_FORMEXPRESSIONSPASS
+#include "mlir/Dialect/EmitC/Transforms/Passes.h.inc"
 
 //===----------------------------------------------------------------------===//
 // Registration
diff --git a/mlir/include/mlir/Dialect/EmitC/Transforms/Passes.td b/mlir/include/mlir/Dialect/EmitC/Transforms/Passes.td
index fd083abc95715..f46b705ca2dfe 100644
--- a/mlir/include/mlir/Dialect/EmitC/Transforms/Passes.td
+++ b/mlir/include/mlir/Dialect/EmitC/Transforms/Passes.td
@@ -11,13 +11,12 @@
 
 include "mlir/Pass/PassBase.td"
 
-def FormExpressions : Pass<"form-expressions"> {
+def FormExpressionsPass : Pass<"form-expressions"> {
   let summary = "Form C-style expressions from C-operator ops";
   let description = [{
     The pass wraps emitc ops modelling C operators in emitc.expression ops and
     then folds single-use expressions into their users where possible.
   }];
-  let constructor = "mlir::emitc::createFormExpressionsPass()";
   let dependentDialects = ["emitc::EmitCDialect"];
 }
 
diff --git a/mlir/lib/Dialect/EmitC/Transforms/FormExpressions.cpp b/mlir/lib/Dialect/EmitC/Transforms/FormExpressions.cpp
index 3385514375804..224d68ab8b4a6 100644
--- a/mlir/lib/Dialect/EmitC/Transforms/FormExpressions.cpp
+++ b/mlir/lib/Dialect/EmitC/Transforms/FormExpressions.cpp
@@ -18,7 +18,7 @@
 
 namespace mlir {
 namespace emitc {
-#define GEN_PASS_DEF_FORMEXPRESSIONS
+#define GEN_PASS_DEF_FORMEXPRESSIONSPASS
 #include "mlir/Dialect/EmitC/Transforms/Passes.h.inc"
 } // namespace emitc
 } // namespace mlir
@@ -28,7 +28,7 @@ using namespace emitc;
 
 namespace {
 struct FormExpressionsPass
-    : public emitc::impl::FormExpressionsBase<FormExpressionsPass> {
+    : public emitc::impl::FormExpressionsPassBase<FormExpressionsPass> {
   void runOnOperation() override {
     Operation *rootOp = getOperation();
     MLIRContext *context = rootOp->getContext();
@@ -56,7 +56,3 @@ struct FormExpressionsPass
   }
 };
 } // namespace
-
-std::unique_ptr<Pass> mlir::emitc::createFormExpressionsPass() {
-  return std::make_unique<FormExpressionsPass>();
-}

Copy link
Member

@marbre marbre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @chelini! I am not sure about the naming convention, but I was wondering if FormExpressions.cpp should be renamed to FormExpressionsPass.cpp or if we should stick with def FormExpressions and update the function calls accordingly? I could take over if you like me to.

@chelini
Copy link
Contributor Author

chelini commented Mar 31, 2025

Thanks @chelini! I am not sure about the naming convention, but I was wondering if FormExpressions.cpp should be renamed to FormExpressionsPass.cpp or if we should stick with def FormExpressions and update the function calls accordingly? I could take over if you like me to.

@marbre, feel free to change it. Can I merge this one or you want to push on this PR?

@marbre
Copy link
Member

marbre commented Mar 31, 2025

Thanks @chelini! I am not sure about the naming convention, but I was wondering if FormExpressions.cpp should be renamed to FormExpressionsPass.cpp or if we should stick with def FormExpressions and update the function calls accordingly? I could take over if you like me to.

@marbre, feel free to change it. Can I merge this one or you want to push on this PR?

Whatever works best for you :)

@chelini
Copy link
Contributor Author

chelini commented Apr 1, 2025

Thanks @chelini! I am not sure about the naming convention, but I was wondering if FormExpressions.cpp should be renamed to FormExpressionsPass.cpp or if we should stick with def FormExpressions and update the function calls accordingly? I could take over if you like me to.

@marbre, feel free to change it. Can I merge this one or you want to push on this PR?

Whatever works best for you :)

Ok, then please follow-up. I will merge this.

@chelini chelini merged commit 105c8c3 into llvm:main Apr 1, 2025
14 checks passed
Ankur-0429 pushed a commit to Ankur-0429/llvm-project that referenced this pull request Apr 2, 2025
`let constructor` is legacy (do not use in tree!) since the tableGen
backend emits most of the glue logic to build a pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants