[mlir] Async: add unrealized cast materializations to AsyncToLLVM pass
authorEugene Zhulenev <ezhulenev@google.com>
Fri, 26 Aug 2022 22:38:41 +0000 (15:38 -0700)
committerEugene Zhulenev <ezhulenev@google.com>
Tue, 30 Aug 2022 17:50:20 +0000 (10:50 -0700)
[mlir] Async: add unrealized cast materializations to AsyncToLLVM pass

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D132768

mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp

index aa6598c..26154e4 100644 (file)
@@ -278,6 +278,17 @@ public:
   AsyncRuntimeTypeConverter() {
     addConversion([](Type type) { return type; });
     addConversion(convertAsyncTypes);
+
+    // Use UnrealizedConversionCast as the bridge so that we don't need to pull
+    // in patterns for other dialects.
+    auto addUnrealizedCast = [](OpBuilder &builder, Type type,
+                                ValueRange inputs, Location loc) {
+      auto cast = builder.create<UnrealizedConversionCastOp>(loc, type, inputs);
+      return Optional<Value>(cast.getResult(0));
+    };
+
+    addSourceMaterialization(addUnrealizedCast);
+    addTargetMaterialization(addUnrealizedCast);
   }
 
   static Optional<Type> convertAsyncTypes(Type type) {