[llvm-branch-commits] [mlir] [mlir-c] Add 1:N TypeConverter conversion and materialization bindings (PR #208935)

Jacques Pienaar via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Jul 21 01:50:31 PDT 2026


================
@@ -601,32 +610,105 @@ mlirTypeConverterAddConversion(MlirTypeConverter typeConverter,
                                MlirTypeConverterConversionCallback convertType,
                                void *userData);
 
-/// Convert the given type using the given TypeConverter.
+/// Opaque accumulator for the result types of a 1:N type conversion. It is
+/// passed to a MlirTypeConverter1ToNConversionCallback, which appends converted
+/// types to it via mlirTypeConverterConversionResultsAppend.
+typedef struct MlirTypeConverterConversionResults {
+  void *ptr;
+} MlirTypeConverterConversionResults;
+
+/// Append a converted result type to the given 1:N conversion result
+/// accumulator.
+MLIR_CAPI_EXPORTED void mlirTypeConverterConversionResultsAppend(
+    MlirTypeConverterConversionResults results, MlirType type);
+
+/// Outcome of a 1:N type conversion callback
+/// (MlirTypeConverter1ToNConversionCallback). Mirrors the three states of the
+/// underlying C++ `std::optional<LogicalResult>` return.
+typedef enum MlirTypeConverterConversionStatus {
+  /// The type was converted; the types appended to the results accumulator make
+  /// up the conversion (appending none erases the type).
+  MlirTypeConverterConversionStatusSuccess = 0,
+  /// The conversion failed hard; no further conversion function will be tried.
+  /// Any types appended before returning failure are discarded.
----------------
jpienaar wrote:

Appended where? I'm wondering if these should be comments on the function below rather than the enum.

https://github.com/llvm/llvm-project/pull/208935


More information about the llvm-branch-commits mailing list