Skip to content

Commit 3b355b2

Browse files
authored
[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.
1 parent 0dff5b5 commit 3b355b2

File tree

1 file changed

+2
-79
lines changed

1 file changed

+2
-79
lines changed

mlir/tools/mlir-tblgen/PassGen.cpp

Lines changed: 2 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -387,81 +387,6 @@ static void emitPass(const Pass &pass, raw_ostream &os) {
387387
emitPassDefs(pass, os);
388388
}
389389

390-
// TODO: Drop old pass declarations.
391-
// The old pass base class is being kept until all the passes have switched to
392-
// the new decls/defs design.
393-
const char *const oldPassDeclBegin = R"(
394-
template <typename DerivedT>
395-
class {0}Base : public {1} {
396-
public:
397-
using Base = {0}Base;
398-
399-
{0}Base() : {1}(::mlir::TypeID::get<DerivedT>()) {{}
400-
{0}Base(const {0}Base &other) : {1}(other) {{}
401-
{0}Base& operator=(const {0}Base &) = delete;
402-
{0}Base({0}Base &&) = delete;
403-
{0}Base& operator=({0}Base &&) = delete;
404-
~{0}Base() = default;
405-
406-
/// Returns the command-line argument attached to this pass.
407-
static constexpr ::llvm::StringLiteral getArgumentName() {
408-
return ::llvm::StringLiteral("{2}");
409-
}
410-
::llvm::StringRef getArgument() const override { return "{2}"; }
411-
412-
::llvm::StringRef getDescription() const override { return R"PD({3})PD"; }
413-
414-
/// Returns the derived pass name.
415-
static constexpr ::llvm::StringLiteral getPassName() {
416-
return ::llvm::StringLiteral("{0}");
417-
}
418-
::llvm::StringRef getName() const override { return "{0}"; }
419-
420-
/// Support isa/dyn_cast functionality for the derived pass class.
421-
static bool classof(const ::mlir::Pass *pass) {{
422-
return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
423-
}
424-
425-
/// A clone method to create a copy of this pass.
426-
std::unique_ptr<::mlir::Pass> clonePass() const override {{
427-
return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
428-
}
429-
430-
/// Register the dialects that must be loaded in the context before this pass.
431-
void getDependentDialects(::mlir::DialectRegistry &registry) const override {
432-
{4}
433-
}
434-
435-
/// Explicitly declare the TypeID for this class. We declare an explicit private
436-
/// instantiation because Pass classes should only be visible by the current
437-
/// library.
438-
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID({0}Base<DerivedT>)
439-
440-
protected:
441-
)";
442-
443-
// TODO: Drop old pass declarations.
444-
/// Emit a backward-compatible declaration of the pass base class.
445-
static void emitOldPassDecl(const Pass &pass, raw_ostream &os) {
446-
StringRef defName = pass.getDef()->getName();
447-
std::string dependentDialectRegistrations;
448-
{
449-
llvm::raw_string_ostream dialectsOs(dependentDialectRegistrations);
450-
llvm::interleave(
451-
pass.getDependentDialects(), dialectsOs,
452-
[&](StringRef dependentDialect) {
453-
dialectsOs << formatv(dialectRegistrationTemplate, dependentDialect);
454-
},
455-
"\n ");
456-
}
457-
os << formatv(oldPassDeclBegin, defName, pass.getBaseClass(),
458-
pass.getArgument(), pass.getSummary().trim(),
459-
dependentDialectRegistrations);
460-
emitPassOptionDecls(pass, os);
461-
emitPassStatisticDecls(pass, os);
462-
os << "};\n";
463-
}
464-
465390
static void emitPasses(const RecordKeeper &records, raw_ostream &os) {
466391
std::vector<Pass> passes = getPasses(records);
467392
os << "/* Autogenerated by mlir-tblgen; don't manually edit */\n";
@@ -479,12 +404,10 @@ static void emitPasses(const RecordKeeper &records, raw_ostream &os) {
479404

480405
emitRegistrations(passes, os);
481406

482-
// TODO: Drop old pass declarations.
407+
// TODO: Remove warning, kept in to make error understandable.
483408
// Emit the old code until all the passes have switched to the new design.
484-
os << "// Deprecated. Please use the new per-pass macros.\n";
485409
os << "#ifdef GEN_PASS_CLASSES\n";
486-
for (const Pass &pass : passes)
487-
emitOldPassDecl(pass, os);
410+
os << "#error \"GEN_PASS_CLASSES is deprecated; use per-pass macros\"\n";
488411
os << "#undef GEN_PASS_CLASSES\n";
489412
os << "#endif // GEN_PASS_CLASSES\n";
490413
}

0 commit comments

Comments
 (0)