Up until now PDL(L) has not supported dialect conversion because we had no way of remapping values or integrating with type conversions. This commit rectifies that by adding a new "pattern configuration" concept to PDL. This essentially allows for attaching external configurations to patterns, which can hook into pattern events (for now just the scope of a rewrite, but we could also pass configs to native rewrites as well). This allows for injecting the type converter into the conversion pattern rewriter. Differential Revision: https://reviews.llvm.org/D133142
19 lines
695 B
MLIR
19 lines
695 B
MLIR
// RUN: mlir-opt %s -test-dialect-conversion-pdll | FileCheck %s
|
|
|
|
// CHECK-LABEL: @TestSingleConversion
|
|
func.func @TestSingleConversion() {
|
|
// CHECK: %[[CAST:.*]] = "test.cast"() : () -> f64
|
|
// CHECK-NEXT: "test.return"(%[[CAST]]) : (f64) -> ()
|
|
%result = "test.cast"() : () -> (i64)
|
|
"test.return"(%result) : (i64) -> ()
|
|
}
|
|
|
|
// CHECK-LABEL: @TestLingeringConversion
|
|
func.func @TestLingeringConversion() -> i64 {
|
|
// CHECK: %[[ORIG_CAST:.*]] = "test.cast"() : () -> f64
|
|
// CHECK: %[[MATERIALIZE_CAST:.*]] = builtin.unrealized_conversion_cast %[[ORIG_CAST]] : f64 to i64
|
|
// CHECK-NEXT: return %[[MATERIALIZE_CAST]] : i64
|
|
%result = "test.cast"() : () -> (i64)
|
|
return %result : i64
|
|
}
|