[Mlir-commits] [mlir] [mlir][Transforms] Dialect conversion: Context-aware type conversions (PR #140434)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon May 19 07:14:53 PDT 2025


================
@@ -2899,6 +2899,28 @@ LogicalResult TypeConverter::convertType(Type t,
   return failure();
 }
 
+LogicalResult TypeConverter::convertType(Value v,
+                                         SmallVectorImpl<Type> &results) const {
+  assert(v && "expected non-null value");
+
+  // If this type converter does not have context-aware type conversions, call
+  // the type-based overload, which has caching.
+  if (!hasContextAwareTypeConversions) {
+    return convertType(v.getType(), results);
+  }
----------------
cchen435 wrote:

Yeah, it doesn't provide caching for value-based conversions. It only caches for fallbacks (and context-unaware). The motivation for the use cases (if there are) of mixing the use of context-aware and context-unaware in the same conversion, in which context-unaware can still be cached. But, I have to agree there is no need to do in this way if there is no such use cases. I agree with you on the second argument regarding to the API. This PR LGTM.

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


More information about the Mlir-commits mailing list