Page MenuHomePhabricator

[mlir] expose standard types to C API
ClosedPublic

Authored by ftynse on Aug 17 2020, 10:58 AM.

Details

Summary

Provide C API for MLIR standard types. Since standard types live under lib/IR
in core MLIR, place the C APIs in the IR library as well (standard ops will go
into a separate library). This also defines a placeholder for affine maps that
are necessary to construct a memref, but are not yet exposed to the C API.

Diff Detail

Event Timeline

ftynse created this revision.Aug 17 2020, 10:58 AM
Herald added a project: Restricted Project. · View Herald Transcript
ftynse requested review of this revision.Aug 17 2020, 10:58 AM
ftynse added inline comments.Aug 17 2020, 11:00 AM
mlir/include/mlir-c/StandardTypes.h
135

@stellaraccident rank and shape are int64_tin C++ (not unsigned as usual), do we want to keep them as is or use intptr_t instead?

mlir/test/CAPI/ir.c
453

Apparently there is a problem with printing unranked memrefs in non-default memory space.

ftynse added inline comments.Aug 17 2020, 11:27 AM
stellaraccident accepted this revision.Aug 17 2020, 9:47 PM
stellaraccident added inline comments.
mlir/docs/CAPI.md
83
97
mlir/include/mlir-c/StandardTypes.h
135

I think these should be int64_t since that is the natural range of the value, regardless of platform. I would apply this rule: the compiler should be able to represent the same program IR regardless of whether it is built with a 32 or 64bit pointer size (within the limit of not being able to express programs that exceed internal limits of data structure sizes).

141

I think this is fine as an intptr_t: these relate to the sizes of ir internal data structures.

mlir/include/mlir/CAPI/Wrap.h
41

Shouldn't this be size_t (and I'm the function)

This revision is now accepted and ready to land.Aug 17 2020, 9:47 PM
ftynse updated this revision to Diff 286211.Aug 18 2020, 12:53 AM
ftynse marked 5 inline comments as done.

Rebase on top of a bugfix and address review.

ftynse updated this revision to Diff 286215.Aug 18 2020, 1:29 AM

Rebase once more

This revision was landed with ongoing or failed builds.Aug 18 2020, 4:11 AM
This revision was automatically updated to reflect the committed changes.