This is an archive of the discontinued LLVM Phabricator instance.

[mlir][CAPI] Add result type inference to the CAPI.
ClosedPublic

Authored by stellaraccident on Jan 22 2021, 6:50 PM.

Details

Summary
  • Adds a flag to MlirOperationState to enable result type inference using the InferTypeOpInterface.
  • I chose this level of implementation for a couple of reasons: a) In the creation flow is naturally where generated and custom builder code will be invoking such a thing b) it is a bit more efficient to share the data structure and unpacking vs having a standalone entry-point c) we can always decide to expose more of these interfaces with first-class APIs, but that doesn't preclude that we will always want to use this one in this way (and less API surface area for common things is better for API stability and evolution).
  • I struggled to find an appropriate way to test it since we don't link the test dialect into anything CAPI accessible at present. I opted instead for one of the simplest ops I found in a regular dialect which implements the interface.
  • This does not do any trait-based type selection. That will be left to generated tablegen wrappers.

Diff Detail

Event Timeline

stellaraccident requested review of this revision.Jan 22 2021, 6:50 PM
mehdi_amini accepted this revision.Jan 22 2021, 7:21 PM
mehdi_amini added inline comments.
mlir/lib/CAPI/IR/IR.cpp
260

(spurious braces)

This revision is now accepted and ready to land.Jan 22 2021, 7:21 PM
This revision was landed with ongoing or failed builds.Jan 23 2021, 2:33 PM
This revision was automatically updated to reflect the committed changes.