[Mlir-commits] [mlir] [mlir][Transforms] Make 1:N function conversion pattern interface-based (PR #92395)
Ingo Müller
llvmlistbot at llvm.org
Thu May 16 06:59:06 PDT 2024
================
@@ -412,4 +413,62 @@ applyPartialOneToNConversion(Operation *op, OneToNTypeConverter &typeConverter,
return success();
}
+namespace {
+class FunctionOpInterfaceSignatureConversion : public OneToNConversionPattern {
+public:
+ FunctionOpInterfaceSignatureConversion(StringRef functionLikeOpName,
+ MLIRContext *ctx,
+ TypeConverter &converter)
+ : OneToNConversionPattern(converter, functionLikeOpName, /*benefit=*/1,
+ ctx) {}
+
+ LogicalResult matchAndRewrite(Operation *op, OneToNPatternRewriter &rewriter,
+ const OneToNTypeMapping &operandMapping,
+ const OneToNTypeMapping &resultMapping,
+ ValueRange convertedOperands) const override {
+ auto funcOp = cast<FunctionOpInterface>(op);
----------------
ingomueller-net wrote:
Is this *guaranteed* to work? I suppose that the base already tests for `functionLikeOpName`? But what if that op doesn't implement the `FunctionOpInterface`?. Maybe there should an assert here? (I *guess* it should not be a match failure because whoever used the pattern must have thought that the op actually does implement the interface...)
https://github.com/llvm/llvm-project/pull/92395
More information about the Mlir-commits
mailing list