Skip to content

Remove global dialect registration from MLIR usage #2958

Closed

Description

@ScottTodd

Copying an issue filed elsewhere by @joker-eph :


The global registration for MLIR Dialects has been deprecated and will be removed upstream "soon", IREE needs to adjust to this change and stop using the existing dialect registration.

  1. For passes, you need to override the method:
    virtual void getDependentDialects(DialectRegistry &registry) const {}

and register on the provided registry any dialect that this pass can produce:

    registry.insert<DialectClass>();

Passes defined in TableGen can provide this list in the dependentDialects list field.

  1. For dialects, on construction you can register dependent dialects using the
    provided MLIRContext: context.getOrLoadDialect<DialectName>()
    This is useful if a dialect may canonicalize or have interfaces involving
    another dialect.

  2. For loading IR, dialect that can be in the input file must be explicitly
    registered with the context. MlirOptMain() is taking an explicit registry for
    this purpose.

  mlir::DialectRegistry registry;
  registry.insert<mlir::StandardOpsDialect>();
  registry.insert<mlir::xyz123::XYZ123Dialect>();
  return failed(mlir::MlirOptMain(argc, argv, "XYZ123 Pass Driver", registry));

Only operations from these two dialects can be in the input file. To include all
of the dialects in MLIR Core, you can populate the registry this way:

  mlir::registerAllDialects(registry);
  1. For mlir-translate callbacks, as well as frontend, Dialects can be loaded in
    the context before emitting the IR: context.loadDialect<ToyDialect>()

Activity

  1. added
    compiler/dialects
    on Aug 20, 2020
  2. joker-eph commented on Aug 21, 2020

    @joker-eph
    Contributor

    The future removal of the global registry is here: https://reviews.llvm.org/D86356 (in case it can help testing that nothing it missing)

  3. ScottTodd commented on Aug 21, 2020

    @ScottTodd
    MemberAuthor

    @marbre expressed interest in working on this for IREE

  4. marbre commented on Aug 24, 2020

    @marbre
    Member

    FYI: This has been partially addressed by fa9dcf2, which allowed an LLVM submodule update.

  5. joker-eph commented on Aug 24, 2020

    @joker-eph
    Contributor

    fa9dcf2 is the code I wrote to minimally not break IREE, but it was written before opening this ticket: this ticket is really about the incoming removal of the global registry upstream.

  6. marbre commented on Aug 25, 2020

    @marbre
    Member

    fa9dcf2 is the code I wrote to minimally not break IREE, but it was written before opening this ticket: this ticket is really about the incoming removal of the global registry upstream.

    Thanks for your comment. I just wanted to reference this commit (which made it into main after the ticket was opened), to keep track of changes related to this issue. Indeed a lot more needs to be done :)

  7. added a commit that references this issue on Aug 27, 2020
  8. self-assigned this
    on Sep 1, 2020
  9. benvanik commented on Nov 22, 2020

    @benvanik
    Collaborator

    #3092 says it removed obsolete global dialect registration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

compiler/dialects

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions