[Mlir-commits] [mlir] [MLIR][Python] Add optional `results` parameter for building op with inferable result types (PR #156818)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu Sep 4 09:49:17 PDT 2025


================
@@ -226,21 +226,21 @@ def DefaultValuedAttrsOp : TestOp<"default_valued_attrs"> {
 
 // CHECK-LABEL: OPERATION_NAME = "test.derive_result_types_op"
 def DeriveResultTypesOp : TestOp<"derive_result_types_op", [FirstAttrDerivedResultType]> {
-  // CHECK: def __init__(self, type_, *, loc=None, ip=None):
+  // CHECK: def __init__(self, type_, *, results=None, loc=None, ip=None):
   // CHECK:   operands = []
-  // CHECK:   results = []
-  // CHECK:   _ods_result_type_source_attr = attributes["type"]
-  // CHECK:   _ods_derived_result_type = (
+  // CHECK:   if results is None:
+  // CHECK:     _ods_result_type_source_attr = attributes["type"]
+  // CHECK:     _ods_derived_result_type = (
   // CHECK:       _ods_ir.TypeAttr(_ods_result_type_source_attr).value
   // CHECK:       if _ods_ir.TypeAttr.isinstance(_ods_result_type_source_attr) else
   // CHECK:       _ods_result_type_source_attr.type)
-  // CHECK:   results.extend([_ods_derived_result_type] * 2)
+  // CHECK:   results = [_ods_derived_result_type] * 2
----------------
PragmaTwice wrote:

Ahh thank you. Fixed in https://github.com/llvm/llvm-project/pull/156818/commits/4e72e8f2dd62041284d7d5ff3b3fda20d997596a. The template code in tablegen is correct i.e. with two spaces.

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


More information about the Mlir-commits mailing list