This is an archive of the discontinued LLVM Phabricator instance.

[mlir][capi] Add DialectRegistry to MLIR C-API
ClosedPublic

Authored by trilorez on Jan 26 2022, 4:25 PM.

Details

Summary

Exposes mlir::DialectRegistry to the C API as MlirDialectRegistry along with
helper functions. A hook has been added to MlirDialectHandle that inserts
the dialect into a registry.

Diff Detail

Event Timeline

trilorez created this revision.Jan 26 2022, 4:25 PM
trilorez requested review of this revision.Jan 26 2022, 4:25 PM
GeorgeLyon added inline comments.Jan 31 2022, 9:05 AM
mlir/include/mlir/CAPI/Registration.h
33

We can probably remove this and implement the C function in terms of dialectregistry

stellaraccident accepted this revision.Jan 31 2022, 9:19 AM
stellaraccident added inline comments.
mlir/include/mlir/CAPI/Registration.h
33

Agreed. I believe this is used in a number of downstreams. Can you document the recommended change in the commit description and note that we will remove this soon. Add a todo here.

This revision is now accepted and ready to land.Jan 31 2022, 9:19 AM
GeorgeLyon added inline comments.Jan 31 2022, 9:30 AM
mlir/include/mlir/CAPI/Registration.h
33

I’m pro deprecation, but I was merely referring to the function pointer. We can keep the C API and just call the registry version from the implementation. So we could remove this and add a note.

trilorez updated this revision to Diff 404579.Jan 31 2022, 9:31 AM

Added TODO regarding removing MlirContextRegisterDialectHook and updated
commit message.

trilorez added inline comments.Jan 31 2022, 9:33 AM
mlir/include/mlir/CAPI/Registration.h
33

Oh, I interpreted this as people were directly using the function pointer. I can get rid of it if that isn't the case.

trilorez updated this revision to Diff 404968.Feb 1 2022, 9:20 AM

Remove MlirContextRegisterDialectHook and implement
mlirDialectHandleRegisterDialect using mlirDialectHandleInsertDialect

trilorez added inline comments.Feb 1 2022, 9:21 AM
mlir/include/mlir/CAPI/Registration.h
33

Updated to remove the function pointer and implement mlirDialectHandleRegisterDialect using mlirDialectHandleInsertDialect.

trilorez updated this revision to Diff 404975.Feb 1 2022, 9:46 AM

Fix MLIR_DEFINE_CAPI_DIALECT_REGISTRATION

mehdi_amini accepted this revision.Feb 1 2022, 10:01 AM
mehdi_amini added inline comments.
mlir/include/mlir-c/Registration.h
54

Do we need to deprecate this API? Seems like it can stay as a convenient wrapper?

trilorez added inline comments.Feb 1 2022, 10:53 AM
mlir/include/mlir-c/Registration.h
54

That's true, I can just leave the declaration as is for now

trilorez updated this revision to Diff 405010.Feb 1 2022, 10:54 AM

Remove deprecation TODO

This revision was automatically updated to reflect the committed changes.