|
| 1 | +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 2 | +# See https://llvm.org/LICENSE.txt for license information. |
| 3 | +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 4 | + |
| 5 | +from ._irdl_ops_gen import * |
| 6 | +from ._irdl_ops_gen import _Dialect |
| 7 | +from ._irdl_enum_gen import * |
| 8 | +from .._mlir_libs._mlirDialectsIRDL import * |
| 9 | +from ..ir import register_attribute_builder |
| 10 | +from ._ods_common import ( |
| 11 | + get_op_result_or_value as _get_value, |
| 12 | + get_op_results_or_values as _get_values, |
| 13 | + _cext as _ods_cext, |
| 14 | +) |
| 15 | +from ..extras.meta import region_op |
| 16 | + |
| 17 | +@_ods_cext.register_operation(_Dialect, replace=True) |
| 18 | +class DialectOp(DialectOp): |
| 19 | + """Specialization for the dialect op class.""" |
| 20 | + |
| 21 | + def __init__(self, sym_name, *, loc=None, ip=None): |
| 22 | + super().__init__(sym_name, loc=loc, ip=ip) |
| 23 | + self.regions[0].blocks.append() |
| 24 | + |
| 25 | + @property |
| 26 | + def body(self): |
| 27 | + return self.regions[0].blocks[0] |
| 28 | + |
| 29 | +@_ods_cext.register_operation(_Dialect, replace=True) |
| 30 | +class OperationOp(OperationOp): |
| 31 | + """Specialization for the operation op class.""" |
| 32 | + |
| 33 | + def __init__(self, sym_name, *, loc=None, ip=None): |
| 34 | + super().__init__(sym_name, loc=loc, ip=ip) |
| 35 | + self.regions[0].blocks.append() |
| 36 | + |
| 37 | + @property |
| 38 | + def body(self): |
| 39 | + return self.regions[0].blocks[0] |
| 40 | + |
| 41 | +@register_attribute_builder("VariadicityArrayAttr") |
| 42 | +def _variadicity_array_attr(x, context): |
| 43 | + return _ods_cext.ir.Attribute.parse(f"#irdl<variadicity_array [{', '.join(str(i) for i in x)}]>") |
0 commit comments