// RUN: mlir-tblgen -gen-python-op-bindings -bind-dialect=test -I %S/../../include %s | FileCheck %s include "mlir/IR/OpBase.td" include "mlir/IR/AttrTypeBase.td" include "mlir/Interfaces/InferTypeOpInterface.td" include "mlir/Bindings/Python/PythonBindings.td" // CHECK: @_ods_cext.register_dialect // CHECK: class _Dialect(_ods_ir.Dialect): // CHECK: DIALECT_NAMESPACE = "test" def Test_Dialect : Dialect { let name = "test"; let cppNamespace = "Test"; } class TestOp traits = []> : Op; def TestCustomAttr : DialectAttr($_self)">, "custom attribute"> { let storageType = "::test::CustomAttr"; } def : PythonAttrType<"TestCustomAttr", "test.CustomType">; // CHECK: @_ods_cext.register_operation(_Dialect) // CHECK-LABEL: class AttrSizedOperandsOp(_ods_ir.OpView): // CHECK: OPERATION_NAME = "test.attr_sized_operands" // CHECK: _ODS_OPERAND_SEGMENTS = [-1,1,0,] def AttrSizedOperandsOp : TestOp<"attr_sized_operands", [AttrSizedOperandSegments]> { // CHECK: def __init__(self, variadic1: _Sequence[_ods_ir.Value], non_variadic: _ods_ir.Value, *, variadic2: _Optional[_ods_ir.Value] = None, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None): // CHECK: operands = [] // CHECK: attributes = {} // CHECK: regions = None // CHECK: operands.append(_get_op_results_or_values(variadic1)) // CHECK: operands.append(non_variadic) // CHECK: operands.append(variadic2) // CHECK: results = [] // CHECK: _ods_successors = None // CHECK: super().__init__( // CHECK: self.OPERATION_NAME, self._ODS_REGIONS, self._ODS_OPERAND_SEGMENTS, self._ODS_RESULT_SEGMENTS, // CHECK: attributes=attributes, results=results, operands=operands, // CHECK: successors=_ods_successors, regions=regions, loc=loc, ip=ip) // CHECK: @builtins.property // CHECK: def variadic1(self) -> _ods_ir.OpOperandList: // CHECK: operand_range = _ods_segmented_accessor( // CHECK: self.operation.operands, // CHECK: self.operation.attributes["operandSegmentSizes"], 0) // CHECK: return operand_range // CHECK-NOT: if len(operand_range) // // CHECK: @builtins.property // CHECK: def non_variadic(self) -> _ods_ir.Value: // CHECK: operand_range = _ods_segmented_accessor( // CHECK: self.operation.operands, // CHECK: self.operation.attributes["operandSegmentSizes"], 1) // CHECK: return operand_range[0] // // CHECK: @builtins.property // CHECK: def variadic2(self) -> _Optional[_ods_ir.Value]: // CHECK: operand_range = _ods_segmented_accessor( // CHECK: self.operation.operands, // CHECK: self.operation.attributes["operandSegmentSizes"], 2) // CHECK: return operand_range[0] if len(operand_range) > 0 else None let arguments = (ins Variadic:$variadic1, AnyType:$non_variadic, Optional:$variadic2); } // CHECK: def attr_sized_operands(variadic1: _Sequence[_ods_ir.Value], non_variadic: _ods_ir.Value, *, variadic2: _Optional[_ods_ir.Value] = None, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None) -> AttrSizedOperandsOp: // CHECK: return AttrSizedOperandsOp(variadic1=variadic1, non_variadic=non_variadic, variadic2=variadic2, loc=loc, ip=ip) // CHECK: @_ods_cext.register_operation(_Dialect) // CHECK-LABEL: class AttrSizedResultsOp(_ods_ir.OpView): // CHECK: OPERATION_NAME = "test.attr_sized_results" // CHECK: _ODS_RESULT_SEGMENTS = [0,1,-1,] def AttrSizedResultsOp : TestOp<"attr_sized_results", [AttrSizedResultSegments]> { // CHECK: def __init__(self, variadic1: _Optional[_ods_ir.Type], non_variadic: _ods_ir.Type, variadic2: _Sequence[_ods_ir.Type], *, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None): // CHECK: operands = [] // CHECK: attributes = {} // CHECK: regions = None // CHECK: results = [] // CHECK: if variadic1 is not None: results.append(variadic1) // CHECK: results.append(non_variadic) // CHECK: results.append(variadic2) // CHECK: _ods_successors = None // CHECK: super().__init__( // CHECK: self.OPERATION_NAME, self._ODS_REGIONS, self._ODS_OPERAND_SEGMENTS, self._ODS_RESULT_SEGMENTS, // CHECK: attributes=attributes, results=results, operands=operands, // CHECK: successors=_ods_successors, regions=regions, loc=loc, ip=ip) // CHECK: @builtins.property // CHECK: def variadic1(self) -> _Optional[_ods_ir.OpResult]: // CHECK: result_range = _ods_segmented_accessor( // CHECK: self.operation.results, // CHECK: self.operation.attributes["resultSegmentSizes"], 0) // CHECK: return result_range[0] if len(result_range) > 0 else None // // CHECK: @builtins.property // CHECK: def non_variadic(self) -> _ods_ir.OpResult: // CHECK: result_range = _ods_segmented_accessor( // CHECK: self.operation.results, // CHECK: self.operation.attributes["resultSegmentSizes"], 1) // CHECK: return result_range[0] // // CHECK: @builtins.property // CHECK: def variadic2(self) -> _ods_ir.OpResultList: // CHECK: result_range = _ods_segmented_accessor( // CHECK: self.operation.results, // CHECK: self.operation.attributes["resultSegmentSizes"], 2) // CHECK: return result_range // CHECK-NOT: if len(result_range) let results = (outs Optional:$variadic1, AnyType:$non_variadic, Variadic:$variadic2); } // CHECK: def attr_sized_results(variadic1: _Optional[_ods_ir.Type], non_variadic: _ods_ir.Type, variadic2: _Sequence[_ods_ir.Type], *, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None) -> _Union[_ods_ir.OpResult, _ods_ir.OpResultList, AttrSizedResultsOp]: // CHECK: op = AttrSizedResultsOp(variadic1=variadic1, non_variadic=non_variadic, variadic2=variadic2, loc=loc, ip=ip); results = op.results // CHECK: return results if len(results) > 1 else (results[0] if len(results) == 1 else op) // CHECK: @_ods_cext.register_operation(_Dialect) // CHECK-LABEL: class AttributedOp(_ods_ir.OpView): // CHECK: OPERATION_NAME = "test.attributed_op" // CHECK-NOT: _ODS_OPERAND_SEGMENTS // CHECK-NOT: _ODS_RESULT_SEGMENTS def AttributedOp : TestOp<"attributed_op"> { // CHECK: def __init__(self, i32attr: _Union[int, _ods_ir.IntegerAttr], in_: _Union[int, _ods_ir.IntegerAttr], *, optionalF32Attr: _Optional[_Union[float, _ods_ir.FloatAttr]] = None, unitAttr: _Optional[bool] = None, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None): // CHECK: operands = [] // CHECK: attributes = {} // CHECK: regions = None // CHECK: attributes["i32attr"] = (i32attr if ( // CHECK-NEXT: isinstance(i32attr, _ods_ir.Attribute) or // CHECK-NEXT: not _ods_ir.AttrBuilder.contains('I32Attr') // CHECK-NEXT: _ods_ir.AttrBuilder.get('I32Attr')(i32attr, context=_ods_context) // CHECK: if optionalF32Attr is not None: attributes["optionalF32Attr"] = (optionalF32Attr // CHECK: if bool(unitAttr): attributes["unitAttr"] = _ods_ir.UnitAttr.get( // CHECK: _ods_get_default_loc_context(loc)) // CHECK: attributes["in"] = (in_ // CHECK: results = [] // CHECK: _ods_successors = None // CHECK: super().__init__( // CHECK: self.OPERATION_NAME, self._ODS_REGIONS, self._ODS_OPERAND_SEGMENTS, self._ODS_RESULT_SEGMENTS, // CHECK: attributes=attributes, results=results, operands=operands, // CHECK: successors=_ods_successors, regions=regions, loc=loc, ip=ip) // CHECK: @builtins.property // CHECK: def i32attr(self) -> _ods_ir.IntegerAttr: // CHECK: return self.operation.attributes["i32attr"] // CHECK: @builtins.property // CHECK: def optionalF32Attr(self) -> _Optional[_ods_ir.FloatAttr]: // CHECK: if "optionalF32Attr" not in self.operation.attributes: // CHECK: return None // CHECK: return self.operation.attributes["optionalF32Attr"] // CHECK: @builtins.property // CHECK: def unitAttr(self) -> bool: // CHECK: return "unitAttr" in self.operation.attributes // CHECK: @builtins.property // CHECK: def in_(self) -> _ods_ir.IntegerAttr: // CHECK: return self.operation.attributes["in"] let arguments = (ins I32Attr:$i32attr, OptionalAttr:$optionalF32Attr, UnitAttr:$unitAttr, I32Attr:$in); } // CHECK: @_ods_cext.register_op_adaptor(AttributedOp) // CHECK-LABEL: class AttributedOpAdaptor(_ods_ir.OpAdaptor): // CHECK: OPERATION_NAME = "test.attributed_op" // CHECK: @builtins.property // CHECK: def i32attr(self) -> _ods_ir.IntegerAttr: // CHECK: return self.attributes["i32attr"] // CHECK: @builtins.property // CHECK: def optionalF32Attr(self) -> _Optional[_ods_ir.FloatAttr]: // CHECK: if "optionalF32Attr" not in self.attributes: // CHECK: return None // CHECK: return self.attributes["optionalF32Attr"] // CHECK: @builtins.property // CHECK: def unitAttr(self) -> bool: // CHECK: return "unitAttr" in self.attributes // CHECK: @builtins.property // CHECK: def in_(self) -> _ods_ir.IntegerAttr: // CHECK: return self.attributes["in"] // CHECK: def attributed_op(i32attr: _Union[int, _ods_ir.IntegerAttr], in_: _Union[int, _ods_ir.IntegerAttr], *, optional_f32_attr: _Optional[_Union[float, _ods_ir.FloatAttr]] = None, unit_attr: _Optional[bool] = None, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None) -> AttributedOp: // CHECK: return AttributedOp(i32attr=i32attr, in_=in_, optionalF32Attr=optional_f32_attr, unitAttr=unit_attr, loc=loc, ip=ip) // CHECK: @_ods_cext.register_operation(_Dialect) // CHECK-LABEL: class AttributedOpWithOperands(_ods_ir.OpView): // CHECK: OPERATION_NAME = "test.attributed_op_with_operands" // CHECK-NOT: _ODS_OPERAND_SEGMENTS // CHECK-NOT: _ODS_RESULT_SEGMENTS def AttributedOpWithOperands : TestOp<"attributed_op_with_operands"> { // CHECK: def __init__(self, _gen_arg_0: _ods_ir.Value[_ods_ir.IntegerType], _gen_arg_2: _ods_ir.Value[_ods_ir.FloatType], *, in_: _Optional[bool] = None, is_: _Optional[_Union[float, _ods_ir.FloatAttr]] = None, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None): // CHECK: operands = [] // CHECK: attributes = {} // CHECK: regions = None // CHECK: operands.append(_gen_arg_0) // CHECK: operands.append(_gen_arg_2) // CHECK: if bool(in_): attributes["in"] = _ods_ir.UnitAttr.get( // CHECK: _ods_get_default_loc_context(loc)) // CHECK: if is_ is not None: attributes["is"] = (is_ // CHECK: results = [] // CHECK: _ods_successors = None // CHECK: super().__init__( // CHECK: self.OPERATION_NAME, self._ODS_REGIONS, self._ODS_OPERAND_SEGMENTS, self._ODS_RESULT_SEGMENTS, // CHECK: attributes=attributes, results=results, operands=operands, // CHECK: successors=_ods_successors, regions=regions, loc=loc, ip=ip) // CHECK: @builtins.property // CHECK: def in_(self) -> bool: // CHECK: return "in" in self.operation.attributes // CHECK: @builtins.property // CHECK: def is_(self) -> _Optional[_ods_ir.FloatAttr]: // CHECK: if "is" not in self.operation.attributes: // CHECK: return None // CHECK: return self.operation.attributes["is"] let arguments = (ins I32, UnitAttr:$in, F32, OptionalAttr:$is); } // CHECK: def attributed_op_with_operands(_gen_arg_0: _ods_ir.Value[_ods_ir.IntegerType], _gen_arg_2: _ods_ir.Value[_ods_ir.FloatType], *, in_: _Optional[bool] = None, is_: _Optional[_Union[float, _ods_ir.FloatAttr]] = None, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None) -> AttributedOpWithOperands: // CHECK: return AttributedOpWithOperands(_gen_arg_0=_gen_arg_0, _gen_arg_2=_gen_arg_2, in_=in_, is_=is_, loc=loc, ip=ip) // CHECK: @_ods_cext.register_operation(_Dialect) // CHECK-LABEL: class CustomAttrOp(_ods_ir.OpView): def CustomAttrOp : TestOp<"custom_attr"> { // CHECK: def __init__(self, custom: _Union[test.CustomType, _ods_ir.Attribute], *, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None): let arguments = (ins TestCustomAttr:$custom); } // CHECK-LABEL: class DefaultValuedAttrsOp(_ods_ir.OpView): // CHECK: OPERATION_NAME = "test.default_valued_attrs" def DefaultValuedAttrsOp : TestOp<"default_valued_attrs"> { // CHECK: def __init__(self, *, arr: _Optional[_Union[_Sequence[int], _ods_ir.ArrayAttr]] = None, unsupported: _Optional[_Union[_Sequence[int], _ods_ir.ArrayAttr]] = None, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None): // CHECK: operands = [] // CHECK: attributes = {} // CHECK: regions = None // CHECK: if arr is not None: attributes["arr"] = (arr // CHECK: if unsupported is not None: attributes["unsupported"] = (unsupported // CHECK: results = [] // CHECK: _ods_successors = None // CHECK: super().__init__( // CHECK: self.OPERATION_NAME, self._ODS_REGIONS, self._ODS_OPERAND_SEGMENTS, self._ODS_RESULT_SEGMENTS, // CHECK: attributes=attributes, results=results, operands=operands, // CHECK: successors=_ods_successors, regions=regions, loc=loc, ip=ip) let arguments = (ins DefaultValuedAttr:$arr, DefaultValuedAttr:$unsupported); let results = (outs); } // CHECK: def default_valued_attrs(*, arr: _Optional[_Union[_Sequence[int], _ods_ir.ArrayAttr]] = None, unsupported: _Optional[_Union[_Sequence[int], _ods_ir.ArrayAttr]] = None, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None) -> DefaultValuedAttrsOp: // CHECK: return DefaultValuedAttrsOp(arr=arr, unsupported=unsupported, loc=loc, ip=ip) // CHECK-LABEL: OPERATION_NAME = "test.derive_result_types_op" def DeriveResultTypesOp : TestOp<"derive_result_types_op", [FirstAttrDerivedResultType]> { // CHECK: def __init__(self, type_: _Union[_ods_ir.Type, _ods_ir.TypeAttr], *, results: _Optional[_Sequence[_ods_ir.Type]] = None, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None): // CHECK: operands = [] // 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 isinstance(_ods_result_type_source_attr, _ods_ir.TypeAttr) else // CHECK: _ods_result_type_source_attr.type) // CHECK: results = [_ods_derived_result_type] * 2 let arguments = (ins TypeAttr:$type); let results = (outs AnyType:$res, AnyType); } // CHECK: def derive_result_types_op(type_: _Union[_ods_ir.Type, _ods_ir.TypeAttr], *, results: _Optional[_Sequence[_ods_ir.Type]] = None, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None) -> _ods_ir.OpResultList: // CHECK: return DeriveResultTypesOp(type_=type_, results=results, loc=loc, ip=ip).results // CHECK-LABEL: OPERATION_NAME = "test.derive_result_types_variadic_op" def DeriveResultTypesVariadicOp : TestOp<"derive_result_types_variadic_op", [FirstAttrDerivedResultType]> { // CHECK: def __init__(self, res: _ods_ir.Type, _gen_res_1: _Sequence[_ods_ir.Type], type_: _Union[_ods_ir.Type, _ods_ir.TypeAttr], *, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None): let arguments = (ins TypeAttr:$type); let results = (outs AnyType:$res, Variadic); } // CHECK: def derive_result_types_variadic_op(res: _ods_ir.Type, _gen_res_1: _Sequence[_ods_ir.Type], type_: _Union[_ods_ir.Type, _ods_ir.TypeAttr], *, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None) -> _Union[_ods_ir.OpResult, _ods_ir.OpResultList, DeriveResultTypesVariadicOp]: // CHECK: op = DeriveResultTypesVariadicOp(res=res, _gen_res_1=_gen_res_1, type_=type_, loc=loc, ip=ip); results = op.results // CHECK: return results if len(results) > 1 else (results[0] if len(results) == 1 else op) // CHECK: class DescriptionOp(_ods_ir.OpView): // CHECK: r""" // CHECK: This is a long description. // CHECK: It has multiple lines. // CHECK: A code block (to test the indent). // CHECK: ```mlir // CHECK: test.loop { // CHECK: test.yield // CHECK: } // CHECK: ``` // CHECK: Add \"\"\" will not terminate the description. // CHECK: """ def DescriptionOp : TestOp<"description"> { let description = [{ This is a long description. It has multiple lines. A code block (to test the indent). ```mlir test.loop { test.yield } ``` Add """ will not terminate the description. }]; } // CHECK: @_ods_cext.register_operation(_Dialect) // CHECK-LABEL: class EmptyOp(_ods_ir.OpView): // CHECK: OPERATION_NAME = "test.empty" def EmptyOp : TestOp<"empty">; // CHECK: def __init__(self, *, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None): // CHECK: operands = [] // CHECK: attributes = {} // CHECK: regions = None // CHECK: results = [] // CHECK: _ods_successors = None // CHECK: super().__init__( // CHECK: self.OPERATION_NAME, self._ODS_REGIONS, self._ODS_OPERAND_SEGMENTS, self._ODS_RESULT_SEGMENTS, // CHECK: attributes=attributes, results=results, operands=operands, // CHECK: successors=_ods_successors, regions=regions, loc=loc, ip=ip) // CHECK: def empty(*, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None) -> EmptyOp: // CHECK: return EmptyOp(loc=loc, ip=ip) // CHECK-LABEL: OPERATION_NAME = "test.infer_result_types_implied_op" def InferResultTypesImpliedOp : TestOp<"infer_result_types_implied_op"> { // CHECK: def __init__(self, *, results: _Optional[_Sequence[_ods_ir.Type]] = None, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None): // CHECK: _ods_context = _ods_get_default_loc_context(loc) // CHECK: super().__init__( // CHECK: self.OPERATION_NAME, self._ODS_REGIONS, self._ODS_OPERAND_SEGMENTS, self._ODS_RESULT_SEGMENTS, // CHECK: attributes=attributes, results=results, operands=operands, // CHECK: successors=_ods_successors, regions=regions, loc=loc, ip=ip) let results = (outs I32:$i32, F32:$f32); } // CHECK: def infer_result_types_implied_op(*, results: _Optional[_Sequence[_ods_ir.Type]] = None, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None) -> _ods_ir.OpResultList: // CHECK: return InferResultTypesImpliedOp(results=results, loc=loc, ip=ip).results // CHECK-LABEL: OPERATION_NAME = "test.infer_result_types_op" def InferResultTypesOp : TestOp<"infer_result_types_op", [InferTypeOpInterface]> { // CHECK: def __init__(self, *, results: _Optional[_Sequence[_ods_ir.Type]] = None, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None): // CHECK: operands = [] // CHECK: super().__init__( // CHECK: self.OPERATION_NAME, self._ODS_REGIONS, self._ODS_OPERAND_SEGMENTS, self._ODS_RESULT_SEGMENTS, // CHECK: attributes=attributes, results=results, operands=operands, // CHECK: successors=_ods_successors, regions=regions, loc=loc, ip=ip) let results = (outs AnyType, AnyType, AnyType); } // CHECK: def infer_result_types_op(*, results: _Optional[_Sequence[_ods_ir.Type]] = None, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None) -> _ods_ir.OpResultList: // CHECK: return InferResultTypesOp(results=results, loc=loc, ip=ip).results // CHECK: @_ods_cext.register_operation(_Dialect) // CHECK-LABEL: class MissingNamesOp(_ods_ir.OpView): // CHECK: OPERATION_NAME = "test.missing_names" def MissingNamesOp : TestOp<"missing_names"> { // CHECK: def __init__(self, i32: _ods_ir.Type, _gen_res_1: _ods_ir.Type, i64: _ods_ir.Type, _gen_arg_0: _ods_ir.Value[_ods_ir.IntegerType], f32: _ods_ir.Value[_ods_ir.FloatType], _gen_arg_2: _ods_ir.Value[_ods_ir.IntegerType], *, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None): // CHECK: operands = [] // CHECK: attributes = {} // CHECK: regions = None // CHECK: operands.append(_gen_arg_0) // CHECK: operands.append(f32) // CHECK: operands.append(_gen_arg_2) // CHECK: results = [] // CHECK: results.append(i32) // CHECK: results.append(_gen_res_1) // CHECK: results.append(i64) // CHECK: _ods_successors = None // CHECK: super().__init__( // CHECK: self.OPERATION_NAME, self._ODS_REGIONS, self._ODS_OPERAND_SEGMENTS, self._ODS_RESULT_SEGMENTS // CHECK: attributes=attributes, results=results, operands=operands, // CHECK: successors=_ods_successors, regions=regions, loc=loc, ip=ip) // CHECK: @builtins.property // CHECK: def f32(self) -> _ods_ir.Value[_ods_ir.FloatType]: // CHECK: return self.operation.operands[1] let arguments = (ins I32, F32:$f32, I64); // CHECK: @builtins.property // CHECK: def i32(self) -> _ods_ir.OpResult[_ods_ir.IntegerType]: // CHECK: return self.operation.results[0] // // CHECK: @builtins.property // CHECK: def i64(self) -> _ods_ir.OpResult[_ods_ir.IntegerType]: // CHECK: return self.operation.results[2] let results = (outs I32:$i32, AnyFloat, I64:$i64); } // CHECK: def missing_names(i32: _ods_ir.Type, _gen_res_1: _ods_ir.Type, i64: _ods_ir.Type, _gen_arg_0: _ods_ir.Value[_ods_ir.IntegerType], f32: _ods_ir.Value[_ods_ir.FloatType], _gen_arg_2: _ods_ir.Value[_ods_ir.IntegerType], *, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None) -> _ods_ir.OpResultList: // CHECK: return MissingNamesOp(i32=i32, _gen_res_1=_gen_res_1, i64=i64, _gen_arg_0=_gen_arg_0, f32=f32, _gen_arg_2=_gen_arg_2, loc=loc, ip=ip).results // CHECK: @_ods_cext.register_operation(_Dialect) // CHECK-LABEL: class OneOptionalOperandOp(_ods_ir.OpView): // CHECK: OPERATION_NAME = "test.one_optional_operand" // CHECK-NOT: _ODS_OPERAND_SEGMENTS // CHECK-NOT: _ODS_RESULT_SEGMENTS def OneOptionalOperandOp : TestOp<"one_optional_operand"> { let arguments = (ins AnyType:$non_optional, Optional:$optional); // CHECK: def __init__(self, non_optional: _ods_ir.Value, *, optional: _Optional[_ods_ir.Value] = None, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None): // CHECK: operands = [] // CHECK: attributes = {} // CHECK: regions = None // CHECK: operands.append(non_optional) // CHECK: if optional is not None: operands.append(optional) // CHECK: results = [] // CHECK: _ods_successors = None // CHECK: super().__init__( // CHECK: self.OPERATION_NAME, self._ODS_REGIONS, self._ODS_OPERAND_SEGMENTS, self._ODS_RESULT_SEGMENTS // CHECK: attributes=attributes, results=results, operands=operands, // CHECK: successors=_ods_successors, regions=regions, loc=loc, ip=ip) // CHECK: @builtins.property // CHECK: def non_optional(self) -> _ods_ir.Value: // CHECK: return self.operation.operands[0] // CHECK: @builtins.property // CHECK: def optional(self) -> _Optional[_ods_ir.Value]: // CHECK: return None if len(self.operation.operands) < 2 else self.operation.operands[1] } // CHECK: @_ods_cext.register_op_adaptor(OneOptionalOperandOp) // CHECK-LABEL: class OneOptionalOperandOpAdaptor(_ods_ir.OpAdaptor): // CHECK: OPERATION_NAME = "test.one_optional_operand" // CHECK: @builtins.property // CHECK: def non_optional(self) -> _ods_ir.Value: // CHECK: return self.operands[0] // CHECK: @builtins.property // CHECK: def optional(self) -> _Optional[_ods_ir.Value]: // CHECK: return None if len(self.operands) < 2 else self.operands[1] // CHECK: def one_optional_operand(non_optional: _ods_ir.Value, *, optional: _Optional[_ods_ir.Value] = None, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None) -> OneOptionalOperandOp: // CHECK: return OneOptionalOperandOp(non_optional=non_optional, optional=optional, loc=loc, ip=ip) // CHECK: @_ods_cext.register_operation(_Dialect) // CHECK-LABEL: class OneVariadicOperandOp(_ods_ir.OpView): // CHECK: OPERATION_NAME = "test.one_variadic_operand" // CHECK-NOT: _ODS_OPERAND_SEGMENTS // CHECK-NOT: _ODS_RESULT_SEGMENTS def OneVariadicOperandOp : TestOp<"one_variadic_operand"> { // CHECK: def __init__(self, non_variadic: _ods_ir.Value, variadic: _Sequence[_ods_ir.Value], *, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None): // CHECK: operands = [] // CHECK: attributes = {} // CHECK: regions = None // CHECK: operands.append(non_variadic) // CHECK: operands.extend(_get_op_results_or_values(variadic)) // CHECK: results = [] // CHECK: _ods_successors = None // CHECK: super().__init__( // CHECK: self.OPERATION_NAME, self._ODS_REGIONS, self._ODS_OPERAND_SEGMENTS, self._ODS_RESULT_SEGMENTS // CHECK: attributes=attributes, results=results, operands=operands, // CHECK: successors=_ods_successors, regions=regions, loc=loc, ip=ip) // CHECK: @builtins.property // CHECK: def non_variadic(self) -> _ods_ir.Value: // CHECK: return self.operation.operands[0] // // CHECK: @builtins.property // CHECK: def variadic(self) -> _ods_ir.OpOperandList: // CHECK: _ods_variadic_group_length = len(self.operation.operands) - 2 + 1 // CHECK: return self.operation.operands[1:1 + _ods_variadic_group_length] let arguments = (ins AnyType:$non_variadic, Variadic:$variadic); } // CHECK: @_ods_cext.register_op_adaptor(OneVariadicOperandOp) // CHECK-LABEL: class OneVariadicOperandOpAdaptor(_ods_ir.OpAdaptor): // CHECK: OPERATION_NAME = "test.one_variadic_operand" // CHECK: @builtins.property // CHECK: def non_variadic(self) -> _ods_ir.Value: // CHECK: return self.operands[0] // CHECK: @builtins.property // CHECK: def variadic(self) -> _ods_ir.OpOperandList: // CHECK: _ods_variadic_group_length = len(self.operands) - 2 + 1 // CHECK: return self.operands[1:1 + _ods_variadic_group_length] // CHECK: def one_variadic_operand(non_variadic: _ods_ir.Value, variadic: _Sequence[_ods_ir.Value], *, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None) -> OneVariadicOperandOp: // CHECK: return OneVariadicOperandOp(non_variadic=non_variadic, variadic=variadic, loc=loc, ip=ip) // CHECK: @_ods_cext.register_operation(_Dialect) // CHECK-LABEL: class OneVariadicResultOp(_ods_ir.OpView): // CHECK: OPERATION_NAME = "test.one_variadic_result" // CHECK-NOT: _ODS_OPERAND_SEGMENTS // CHECK-NOT: _ODS_RESULT_SEGMENTS def OneVariadicResultOp : TestOp<"one_variadic_result"> { // CHECK: def __init__(self, variadic: _Sequence[_ods_ir.Type], non_variadic: _ods_ir.Type, *, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None): // CHECK: operands = [] // CHECK: attributes = {} // CHECK: regions = None // CHECK: results = [] // CHECK: results.extend(variadic) // CHECK: results.append(non_variadic) // CHECK: _ods_successors = None // CHECK: super().__init__( // CHECK: self.OPERATION_NAME, self._ODS_REGIONS, self._ODS_OPERAND_SEGMENTS, self._ODS_RESULT_SEGMENTS // CHECK: attributes=attributes, results=results, operands=operands, // CHECK: successors=_ods_successors, regions=regions, loc=loc, ip=ip) // CHECK: @builtins.property // CHECK: def variadic(self) -> _ods_ir.OpResultList: // CHECK: _ods_variadic_group_length = len(self.operation.results) - 2 + 1 // CHECK: return self.operation.results[0:0 + _ods_variadic_group_length] // // CHECK: @builtins.property // CHECK: def non_variadic(self) -> _ods_ir.OpResult: // CHECK: _ods_variadic_group_length = len(self.operation.results) - 2 + 1 // CHECK: return self.operation.results[1 + _ods_variadic_group_length - 1] let results = (outs Variadic:$variadic, AnyType:$non_variadic); } // CHECK: def one_variadic_result(variadic: _Sequence[_ods_ir.Type], non_variadic: _ods_ir.Type, *, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None) -> _Union[_ods_ir.OpResult, _ods_ir.OpResultList, OneVariadicResultOp]: // CHECK: op = OneVariadicResultOp(variadic=variadic, non_variadic=non_variadic, loc=loc, ip=ip); results = op.results // CHECK: return results if len(results) > 1 else (results[0] if len(results) == 1 else op) // CHECK: @_ods_cext.register_operation(_Dialect) // CHECK-LABEL: class PythonKeywordOp(_ods_ir.OpView): // CHECK: OPERATION_NAME = "test.python_keyword" def PythonKeywordOp : TestOp<"python_keyword"> { // CHECK: def __init__(self, in_: _ods_ir.Value, *, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None): // CHECK: operands = [] // CHECK: attributes = {} // CHECK: regions = None // CHECK: operands.append(in_) // CHECK: results = [] // CHECK: _ods_successors = None // CHECK: super().__init__( // CHECK: self.OPERATION_NAME, self._ODS_REGIONS, self._ODS_OPERAND_SEGMENTS, self._ODS_RESULT_SEGMENTS // CHECK: attributes=attributes, results=results, operands=operands, // CHECK: successors=_ods_successors, regions=regions, loc=loc, ip=ip) // CHECK: @builtins.property // CHECK: def in_(self) -> _ods_ir.Value: // CHECK: return self.operation.operands[0] let arguments = (ins AnyType:$in); } // CHECK: def python_keyword(in_: _ods_ir.Value, *, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None) -> PythonKeywordOp: // CHECK: return PythonKeywordOp(in_=in_, loc=loc, ip=ip) // CHECK-LABEL: OPERATION_NAME = "test.same_results" def SameResultsOp : TestOp<"same_results", [SameOperandsAndResultType]> { // CHECK: def __init__(self, in1: _ods_ir.Value, in2: _ods_ir.Value, *, results: _Optional[_Sequence[_ods_ir.Type]] = None, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None): // CHECK: operands = [] // CHECK: operands.append // CHECK: if results is None: results = [operands[0].type] * 1 let arguments = (ins AnyType:$in1, AnyType:$in2); let results = (outs AnyType:$res); } // CHECK: def same_results(in1: _ods_ir.Value, in2: _ods_ir.Value, *, results: _Optional[_Sequence[_ods_ir.Type]] = None, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None) -> _ods_ir.OpResult: // CHECK: return SameResultsOp(in1=in1, in2=in2, results=results, loc=loc, ip=ip).result // CHECK-LABEL: OPERATION_NAME = "test.same_results_variadic" def SameResultsVariadicOp : TestOp<"same_results_variadic", [SameOperandsAndResultType]> { // CHECK: def __init__(self, res: _Sequence[_ods_ir.Type], in1: _ods_ir.Value, in2: _ods_ir.Value, *, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None): let arguments = (ins AnyType:$in1, AnyType:$in2); let results = (outs Variadic:$res); } // CHECK: def same_results_variadic(res: _Sequence[_ods_ir.Type], in1: _ods_ir.Value, in2: _ods_ir.Value, *, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None) -> _Union[_ods_ir.OpResult, _ods_ir.OpResultList, SameResultsVariadicOp]: // CHECK: op = SameResultsVariadicOp(res=res, in1=in1, in2=in2, loc=loc, ip=ip); results = op.results // CHECK: return results if len(results) > 1 else (results[0] if len(results) == 1 else op) // CHECK: @_ods_cext.register_operation(_Dialect) // CHECK-LABEL: class SameVariadicOperandSizeOp(_ods_ir.OpView): // CHECK: OPERATION_NAME = "test.same_variadic_operand" def SameVariadicOperandSizeOp : TestOp<"same_variadic_operand", [SameVariadicOperandSize]> { // CHECK: @builtins.property // CHECK: def variadic1(self) -> _ods_ir.OpOperandList: // CHECK: start, elements_per_group = _ods_equally_sized_accessor(self.operation.operands, 1, 2, 0, 0) // CHECK: return self.operation.operands[start:start + elements_per_group] // // CHECK: @builtins.property // CHECK: def non_variadic(self) -> _ods_ir.Value: // CHECK: start, elements_per_group = _ods_equally_sized_accessor(self.operation.operands, 1, 2, 0, 1) // CHECK: return self.operation.operands[start] // // CHECK: @builtins.property // CHECK: def variadic2(self) -> _ods_ir.OpOperandList: // CHECK: start, elements_per_group = _ods_equally_sized_accessor(self.operation.operands, 1, 2, 1, 1) // CHECK: return self.operation.operands[start:start + elements_per_group] let arguments = (ins Variadic:$variadic1, AnyType:$non_variadic, Variadic:$variadic2); } // CHECK: def same_variadic_operand(variadic1: _Sequence[_ods_ir.Value], non_variadic: _ods_ir.Value, variadic2: _Sequence[_ods_ir.Value], *, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None) -> SameVariadicOperandSizeOp: // CHECK: return SameVariadicOperandSizeOp(variadic1=variadic1, non_variadic=non_variadic, variadic2=variadic2, loc=loc, ip=ip) // CHECK: @_ods_cext.register_operation(_Dialect) // CHECK-LABEL: class SameVariadicResultSizeOp(_ods_ir.OpView): // CHECK: OPERATION_NAME = "test.same_variadic_result" def SameVariadicResultSizeOp : TestOp<"same_variadic_result", [SameVariadicResultSize]> { // CHECK: @builtins.property // CHECK: def variadic1(self) -> _ods_ir.OpResultList: // CHECK: start, elements_per_group = _ods_equally_sized_accessor(self.operation.results, 1, 2, 0, 0) // CHECK: return self.operation.results[start:start + elements_per_group] // // CHECK: @builtins.property // CHECK: def non_variadic(self) -> _ods_ir.OpResult: // CHECK: start, elements_per_group = _ods_equally_sized_accessor(self.operation.results, 1, 2, 0, 1) // CHECK: return self.operation.results[start] // // CHECK: @builtins.property // CHECK: def variadic2(self) -> _ods_ir.OpResultList: // CHECK: start, elements_per_group = _ods_equally_sized_accessor(self.operation.results, 1, 2, 1, 1) // CHECK: return self.operation.results[start:start + elements_per_group] let results = (outs Variadic:$variadic1, AnyType:$non_variadic, Variadic:$variadic2); } // CHECK: def same_variadic_result(variadic1: _Sequence[_ods_ir.Type], non_variadic: _ods_ir.Type, variadic2: _Sequence[_ods_ir.Type], *, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None) -> _Union[_ods_ir.OpResult, _ods_ir.OpResultList, SameVariadicResultSizeOp]: // CHECK: op = SameVariadicResultSizeOp(variadic1=variadic1, non_variadic=non_variadic, variadic2=variadic2, loc=loc, ip=ip); results = op.results // CHECK: return results if len(results) > 1 else (results[0] if len(results) == 1 else op) // CHECK: @_ods_cext.register_operation(_Dialect) // CHECK-LABEL: class SimpleOp(_ods_ir.OpView): // CHECK: OPERATION_NAME = "test.simple" def SimpleOp : TestOp<"simple"> { // CHECK: def __init__(self, i64: _ods_ir.Type, f64: _ods_ir.Type, i32: _ods_ir.Value[_ods_ir.IntegerType], f32: _ods_ir.Value[_ods_ir.FloatType], *, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None): // CHECK: operands = [] // CHECK: attributes = {} // CHECK: regions = None // CHECK: operands.append(i32) // CHECK: operands.append(f32) // CHECK: results = [] // CHECK: results.append(i64) // CHECK: results.append(f64) // CHECK: _ods_successors = None // CHECK: super().__init__( // CHECK: self.OPERATION_NAME, self._ODS_REGIONS, self._ODS_OPERAND_SEGMENTS, self._ODS_RESULT_SEGMENTS // CHECK: attributes=attributes, results=results, operands=operands, // CHECK: successors=_ods_successors, regions=regions, loc=loc, ip=ip) // CHECK: @builtins.property // CHECK: def i32(self) -> _ods_ir.Value[_ods_ir.IntegerType]: // CHECK: return self.operation.operands[0] // // CHECK: @builtins.property // CHECK: def f32(self) -> _ods_ir.Value[_ods_ir.FloatType]: // CHECK: return self.operation.operands[1] let arguments = (ins I32:$i32, F32:$f32); // CHECK: @builtins.property // CHECK: def i64(self) -> _ods_ir.OpResult[_ods_ir.IntegerType]: // CHECK: return self.operation.results[0] // // CHECK: @builtins.property // CHECK: def f64(self) -> _ods_ir.OpResult[_ods_ir.FloatType]: // CHECK: return self.operation.results[1] let results = (outs I64:$i64, AnyFloat:$f64); } // CHECK: def simple(i64: _ods_ir.Type, f64: _ods_ir.Type, i32: _ods_ir.Value[_ods_ir.IntegerType], f32: _ods_ir.Value[_ods_ir.FloatType], *, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None) -> _ods_ir.OpResultList: // CHECK: return SimpleOp(i64=i64, f64=f64, i32=i32, f32=f32, loc=loc, ip=ip).results // CHECK: @_ods_cext.register_operation(_Dialect) // CHECK-LABEL: class SingleTypedResultOp(_ods_ir.OpView): // CHECK: OPERATION_NAME = "test.single_typed_result" def SingleTypedResultOp : TestOp<"single_typed_result"> { // CHECK: @builtins.property // CHECK: def i64(self) -> _ods_ir.OpResult[_ods_ir.IntegerType]: // CHECK: return self.operation.results[0] let arguments = (ins AnyType:$in); let results = (outs I64:$i64); } // CHECK: def single_typed_result(in_: _ods_ir.Value, *, results: _Optional[_Sequence[_ods_ir.Type]] = None, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None) -> _ods_ir.OpResult[_ods_ir.IntegerType]: // CHECK: return SingleTypedResultOp(in_=in_, results=results, loc=loc, ip=ip).result // CHECK: @_ods_cext.register_operation(_Dialect) // CHECK-LABEL: class TypedVariadicOperandOp(_ods_ir.OpView): // CHECK: OPERATION_NAME = "test.typed_variadic_operand" def TypedVariadicOperandOp : TestOp<"typed_variadic_operand"> { // CHECK: def __init__(self, variadic: _Sequence[_ods_ir.Value[_ods_ir.IntegerType]], non_variadic: _ods_ir.Value[_ods_ir.FloatType], *, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None): // CHECK: @builtins.property // CHECK: def non_variadic(self) -> _ods_ir.Value[_ods_ir.FloatType]: // // CHECK: @builtins.property // CHECK: def variadic(self) -> _ods_ir.OpOperandList[_ods_ir.IntegerType]: let arguments = (ins Variadic:$variadic, F32:$non_variadic); } // CHECK: def typed_variadic_operand(variadic: _Sequence[_ods_ir.Value[_ods_ir.IntegerType]], non_variadic: _ods_ir.Value[_ods_ir.FloatType], *, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None) -> TypedVariadicOperandOp: // CHECK: return TypedVariadicOperandOp(variadic=variadic, non_variadic=non_variadic, loc=loc, ip=ip) // CHECK-LABEL: class VariadicAndNormalRegionOp(_ods_ir.OpView): // CHECK: OPERATION_NAME = "test.variadic_and_normal_region" def VariadicAndNormalRegionOp : TestOp<"variadic_and_normal_region"> { // CHECK: def __init__(self, num_variadic: int, *, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None): // CHECK: operands = [] // CHECK: attributes = {} // CHECK: regions = None // CHECK: results = [] // CHECK: _ods_successors = None // CHECK: regions = 2 + num_variadic // CHECK: super().__init__( // CHECK: self.OPERATION_NAME, self._ODS_REGIONS, self._ODS_OPERAND_SEGMENTS, self._ODS_RESULT_SEGMENTS // CHECK: attributes=attributes, results=results, operands=operands, // CHECK: successors=_ods_successors, regions=regions, loc=loc, ip=ip) let regions = (region AnyRegion:$region, AnyRegion, VariadicRegion:$variadic); // CHECK: @builtins.property // CHECK: def region(self) -> _ods_ir.Region: // CHECK: return self.regions[0] // CHECK: @builtins.property // CHECK: def variadic(self) -> _ods_ir.RegionSequence: // CHECK: return self.regions[2:] } // CHECK: def variadic_and_normal_region(num_variadic: int, *, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None) -> VariadicAndNormalRegionOp: // CHECK: return VariadicAndNormalRegionOp(num_variadic=num_variadic, loc=loc, ip=ip) // CHECK-LABEL: class VariadicRegionOp(_ods_ir.OpView): // CHECK: OPERATION_NAME = "test.variadic_region" def VariadicRegionOp : TestOp<"variadic_region"> { // CHECK: def __init__(self, num_variadic: int, *, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None): // CHECK: operands = [] // CHECK: attributes = {} // CHECK: regions = None // CHECK: results = [] // CHECK: _ods_successors = None // CHECK: regions = 0 + num_variadic // CHECK: super().__init__( // CHECK: self.OPERATION_NAME, self._ODS_REGIONS, self._ODS_OPERAND_SEGMENTS, self._ODS_RESULT_SEGMENTS // CHECK: attributes=attributes, results=results, operands=operands, // CHECK: successors=_ods_successors, regions=regions, loc=loc, ip=ip) let regions = (region VariadicRegion:$Variadic); // CHECK: @builtins.property // CHECK: def Variadic(self) -> _ods_ir.RegionSequence: // CHECK: return self.regions[0:] } // CHECK: def variadic_region(num_variadic: int, *, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None) -> VariadicRegionOp: // CHECK: return VariadicRegionOp(num_variadic=num_variadic, loc=loc, ip=ip) // CHECK: @_ods_cext.register_operation(_Dialect) // CHECK-LABEL: class WithSpecialCharactersOp(_ods_ir.OpView): // CHECK: OPERATION_NAME = "test.123with--special.characters" def WithSpecialCharactersOp : TestOp<"123with--special.characters"> { } // CHECK: def _123with__special_characters(*, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None) -> WithSpecialCharactersOp: // CHECK: return WithSpecialCharactersOp(loc=loc, ip=ip) // CHECK: @_ods_cext.register_operation(_Dialect) // CHECK-LABEL: class WithSuccessorsOp(_ods_ir.OpView): // CHECK: OPERATION_NAME = "test.with_successors" def WithSuccessorsOp : TestOp<"with_successors"> { // CHECK-NOT: _ods_successors = None // CHECK: _ods_successors = [] // CHECK-NEXT: _ods_successors.append(successor) // CHECK-NEXT: _ods_successors.extend(successors) let successors = (successor AnySuccessor:$successor, VariadicSuccessor:$successors); } // CHECK: def with_successors(successor: _ods_ir.Block, successors: _Sequence[_ods_ir.Block], *, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None) -> WithSuccessorsOp: // CHECK: return WithSuccessorsOp(successor=successor, successors=successors, loc=loc, ip=ip) // CHECK-LABEL: class snake_case(_ods_ir.OpView): // CHECK: OPERATION_NAME = "test.snake_case" def already_snake_case : TestOp<"snake_case"> {} // CHECK: def snake_case_(*, loc: _Optional[_ods_ir.Location] = None, ip: _Optional[_ods_ir.InsertionPoint] = None) -> snake_case: // CHECK: return snake_case(loc=loc, ip=ip)