This is an archive of the discontinued LLVM Phabricator instance.

Add Python bindings for the OpaqueType
ClosedPublic

Authored by dime10 on Jun 8 2022, 6:49 AM.

Details

Summary

Implement the C-API and Python bindings for the builtin opaque type, which was previously missing.

Diff Detail

Event Timeline

dime10 created this revision.Jun 8 2022, 6:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 8 2022, 6:49 AM
dime10 requested review of this revision.Jun 8 2022, 6:49 AM
ftynse requested changes to this revision.Jun 8 2022, 6:56 AM

Thanks! This looks good, I only have a couple of nits and a small request to add a test for the C API somewhere here https://github.com/llvm/llvm-project/blob/main/mlir/test/CAPI/ir.c#L625.

mlir/include/mlir-c/BuiltinTypes.h
340–341

Any reason why the data is not accepted as MlirStringRef? It is returned as such, so I'd go for consistency here.

mlir/lib/Bindings/Python/IRTypes.cpp
636

Nit: add trailing dots in the documentation here and below.

This revision now requires changes to proceed.Jun 8 2022, 6:56 AM
dime10 added inline comments.Jun 8 2022, 7:10 AM
mlir/include/mlir-c/BuiltinTypes.h
340–341

Hmm good question, I wanted to be consistent with the OpaqueAttribute , but I can change it.

ftynse added inline comments.Jun 8 2022, 7:15 AM
mlir/include/mlir-c/BuiltinTypes.h
340–341

That seems to have been overlooked when we introduced MlirStringRef, it is also worth changing :)

dime10 updated this revision to Diff 435173.Jun 8 2022, 8:12 AM

Implement suggestions from code review

  • punctuation in docstrings
  • use StringRef instead of char*
  • add C-API test
dime10 marked 3 inline comments as done.Jun 8 2022, 8:15 AM

Thanks a lot for your review @ftynse :)

ftynse accepted this revision.Jun 8 2022, 8:15 AM
This revision is now accepted and ready to land.Jun 8 2022, 8:15 AM
dime10 updated this revision to Diff 435178.Jun 8 2022, 8:20 AM

Include both commits in the patch

dime10 updated this revision to Diff 435210.Jun 8 2022, 9:30 AM

Fix C-API test failure

@ftynse Are you able to merge this in for me? :)

This revision was automatically updated to reflect the committed changes.