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

Matthias Springer llvmlistbot at llvm.org
Sun May 18 18:14:25 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);
+  }
----------------
matthias-springer wrote:

That won't help here: the dialect conversion framework calls the type converter in `remapValues`. How do you know if a context-aware or a context-unaware conversion should be attempted? It could be either one.

The reason why I decided to maintain a single `conversions` stack is because type conversions are attempted in the opposite order in which they are added. I didn't want to break this invariant for context-aware conversions.


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


More information about the Mlir-commits mailing list