[Mlir-commits] [mlir] 3b355b2 - [mlir] Remove deprecated GEN_PASS_CLASSES. (#166904)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Sat Dec 6 23:54:15 PST 2025


Author: Jacques Pienaar
Date: 2025-12-07T09:54:10+02:00
New Revision: 3b355b26bf4e8d5706a0a920698c1611357479f4

URL: https://github.com/llvm/llvm-project/commit/3b355b26bf4e8d5706a0a920698c1611357479f4
DIFF: https://github.com/llvm/llvm-project/commit/3b355b26bf4e8d5706a0a920698c1611357479f4.diff

LOG: [mlir] Remove deprecated GEN_PASS_CLASSES. (#166904)

This was marked as deprecated in 2022, but as comment. Switch to error
to make visible and stop generating. Will remove the error message in
follow up, just felt this was easier for folks to understand compilation
errors. The change required to new form is rather minimal.

Added: 
    

Modified: 
    mlir/tools/mlir-tblgen/PassGen.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/tools/mlir-tblgen/PassGen.cpp b/mlir/tools/mlir-tblgen/PassGen.cpp
index f4b8eb43b49b8..e4ae78f022405 100644
--- a/mlir/tools/mlir-tblgen/PassGen.cpp
+++ b/mlir/tools/mlir-tblgen/PassGen.cpp
@@ -387,81 +387,6 @@ static void emitPass(const Pass &pass, raw_ostream &os) {
   emitPassDefs(pass, os);
 }
 
-// TODO: Drop old pass declarations.
-// The old pass base class is being kept until all the passes have switched to
-// the new decls/defs design.
-const char *const oldPassDeclBegin = R"(
-template <typename DerivedT>
-class {0}Base : public {1} {
-public:
-  using Base = {0}Base;
-
-  {0}Base() : {1}(::mlir::TypeID::get<DerivedT>()) {{}
-  {0}Base(const {0}Base &other) : {1}(other) {{}
-  {0}Base& operator=(const {0}Base &) = delete;
-  {0}Base({0}Base &&) = delete;
-  {0}Base& operator=({0}Base &&) = delete;
-  ~{0}Base() = default;
-
-  /// Returns the command-line argument attached to this pass.
-  static constexpr ::llvm::StringLiteral getArgumentName() {
-    return ::llvm::StringLiteral("{2}");
-  }
-  ::llvm::StringRef getArgument() const override { return "{2}"; }
-
-  ::llvm::StringRef getDescription() const override { return R"PD({3})PD"; }
-
-  /// Returns the derived pass name.
-  static constexpr ::llvm::StringLiteral getPassName() {
-    return ::llvm::StringLiteral("{0}");
-  }
-  ::llvm::StringRef getName() const override { return "{0}"; }
-
-  /// Support isa/dyn_cast functionality for the derived pass class.
-  static bool classof(const ::mlir::Pass *pass) {{
-    return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
-  }
-
-  /// A clone method to create a copy of this pass.
-  std::unique_ptr<::mlir::Pass> clonePass() const override {{
-    return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
-  }
-
-  /// Register the dialects that must be loaded in the context before this pass.
-  void getDependentDialects(::mlir::DialectRegistry &registry) const override {
-    {4}
-  }
-
-  /// Explicitly declare the TypeID for this class. We declare an explicit private
-  /// instantiation because Pass classes should only be visible by the current
-  /// library.
-  MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID({0}Base<DerivedT>)
-
-protected:
-)";
-
-// TODO: Drop old pass declarations.
-/// Emit a backward-compatible declaration of the pass base class.
-static void emitOldPassDecl(const Pass &pass, raw_ostream &os) {
-  StringRef defName = pass.getDef()->getName();
-  std::string dependentDialectRegistrations;
-  {
-    llvm::raw_string_ostream dialectsOs(dependentDialectRegistrations);
-    llvm::interleave(
-        pass.getDependentDialects(), dialectsOs,
-        [&](StringRef dependentDialect) {
-          dialectsOs << formatv(dialectRegistrationTemplate, dependentDialect);
-        },
-        "\n    ");
-  }
-  os << formatv(oldPassDeclBegin, defName, pass.getBaseClass(),
-                pass.getArgument(), pass.getSummary().trim(),
-                dependentDialectRegistrations);
-  emitPassOptionDecls(pass, os);
-  emitPassStatisticDecls(pass, os);
-  os << "};\n";
-}
-
 static void emitPasses(const RecordKeeper &records, raw_ostream &os) {
   std::vector<Pass> passes = getPasses(records);
   os << "/* Autogenerated by mlir-tblgen; don't manually edit */\n";
@@ -479,12 +404,10 @@ static void emitPasses(const RecordKeeper &records, raw_ostream &os) {
 
   emitRegistrations(passes, os);
 
-  // TODO: Drop old pass declarations.
+  // TODO: Remove warning, kept in to make error understandable.
   // Emit the old code until all the passes have switched to the new design.
-  os << "// Deprecated. Please use the new per-pass macros.\n";
   os << "#ifdef GEN_PASS_CLASSES\n";
-  for (const Pass &pass : passes)
-    emitOldPassDecl(pass, os);
+  os << "#error \"GEN_PASS_CLASSES is deprecated; use per-pass macros\"\n";
   os << "#undef GEN_PASS_CLASSES\n";
   os << "#endif // GEN_PASS_CLASSES\n";
 }


        


More information about the Mlir-commits mailing list