================
@@ -664,50 +680,139 @@ void mlirTypeConverterAddConversion(
           });
 }
 
+void mlirTypeConverterConversionResultsAppend(
+    MlirTypeConverterConversionResults results, MlirType type) {
+  static_cast<SmallVectorImpl<Type> *>(results.ptr)->push_back(unwrap(type));
+}
+
+void mlirTypeConverterAdd1ToNConversion(
+    MlirTypeConverter typeConverter,
+    MlirTypeConverter1ToNConversionCallback convertType, void *userData) {
+  unwrap(typeConverter)
+      ->addConversion(
+          [convertType, userData](Type type, SmallVectorImpl<Type> &results)
+              -> std::optional<LogicalResult> {
+            size_t numPriorResults = results.size();
+            MlirTypeConverterConversionResults wrappedResults{&results};
+            MlirLogicalResult result =
+                convertType(wrap(type), wrappedResults, userData);
+            if (mlirLogicalResultIsFailure(result)) {
+              // The callback declined. Restore any types it appended so the
+              // driver's "try the next conversion" invariant holds (a 
declining
+              // conversion function must not mutate `results`).
+              results.truncate(numPriorResults);
+              return std::nullopt;
+            }
+            return success();
----------------
makslevental wrote:

I added an 3-state enum to handle and then plumbed it here but that makes this 
callback inconsistent with `MlirTypeConverterConversionCallback` which you 
introduced in 
https://github.com/llvm/llvm-project/commit/f992f9719fe13c9ed8bf8e3571d190a69e0e5593.
 What do you think? Should be break that API to unify these two callbacks?

https://github.com/llvm/llvm-project/pull/208935
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to