[all-commits] [llvm/llvm-project] 3da515: [mlir] enable delayed registration of dialect inte...

ftynse via All-commits all-commits at lists.llvm.org
Wed Feb 10 03:08:00 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 3da51522fb4f72b7d4619f2dfd454bb3073ab460
      https://github.com/llvm/llvm-project/commit/3da51522fb4f72b7d4619f2dfd454bb3073ab460
  Author: Alex Zinenko <zinenko at google.com>
  Date:   2021-02-10 (Wed, 10 Feb 2021)

  Changed paths:
    M mlir/include/mlir/IR/Dialect.h
    M mlir/lib/IR/Dialect.cpp
    M mlir/lib/IR/MLIRContext.cpp
    M mlir/lib/Support/MlirOptMain.cpp
    M mlir/unittests/IR/DialectTest.cpp

  Log Message:
  -----------
  [mlir] enable delayed registration of dialect interfaces

This introduces a mechanism to register interfaces for a dialect without making
the dialect itself depend on the interface. The registration request happens on
DialectRegistry and, if the dialect has not been loaded yet, the actual
registration is delayed until the dialect is loaded. It requires
DialectRegistry to become aware of the context that contains it and the context
to expose methods for querying if a dialect is loaded.

This mechanism will enable a simple extension mechanism for dialects that can
have interfaces defined outside of the dialect code. It is particularly helpful
for, e.g., translation to LLVM IR where we don't want the dialect itself to
depend on LLVM IR libraries.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D96137


  Commit: 2996a8d67553b9d469e01215b49bb1af17ad6d1e
      https://github.com/llvm/llvm-project/commit/2996a8d67553b9d469e01215b49bb1af17ad6d1e
  Author: Alex Zinenko <zinenko at google.com>
  Date:   2021-02-10 (Wed, 10 Feb 2021)

  Changed paths:
    M flang/tools/tco/tco.cpp
    M mlir/include/mlir/CAPI/Registration.h
    M mlir/include/mlir/IR/Dialect.h
    M mlir/include/mlir/IR/MLIRContext.h
    M mlir/include/mlir/InitAllDialects.h
    M mlir/lib/CAPI/Registration/Registration.cpp
    M mlir/lib/ExecutionEngine/JitRunner.cpp
    M mlir/lib/IR/Dialect.cpp
    M mlir/lib/IR/MLIRContext.cpp
    M mlir/lib/Pass/Pass.cpp
    M mlir/lib/Support/MlirOptMain.cpp
    M mlir/lib/Target/SPIRV/TranslateRegistration.cpp
    M mlir/lib/Translation/Translation.cpp
    M mlir/tools/mlir-reduce/mlir-reduce.cpp
    M mlir/unittests/IR/DialectTest.cpp

  Log Message:
  -----------
  [mlir] avoid exposing mutable DialectRegistry from MLIRContext

MLIRContext allows its users to access directly to the DialectRegistry it
contains. While sometimes useful for registering additional dialects on an
already existing context, this breaks the encapsulation by essentially giving
raw accesses to a part of the context's internal state. Remove this mutable
access and instead provide a method to append a given DialectRegistry to the
one already contained in the context. Also provide a shortcut mechanism to
construct a context from an already existing registry, which seems to be a
common use case in the wild. Keep read-only access to the registry contained in
the context in case it needs to be copied or used for constructing another
context.

With this change, DialectRegistry is no longer concerned with loading the
dialects and deciding whether to invoke delayed interface registration. Loading
is concentrated in the MLIRContext, and the functionality of the registry
better reflects its name.

Depends On D96137

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D96331


Compare: https://github.com/llvm/llvm-project/compare/a3c74d6d53fc...2996a8d67553


More information about the All-commits mailing list