"""
This file is automatically generated by xDSL and not meant to be modified.

It was generated from tests/xdsl_tblgen/test.json
"""

# ruff: noqa: F403, F405

from xdsl.dialects.builtin import *
from xdsl.ir import *
from xdsl.irdl import *


@irdl_attr_definition
class Test_SingletonAType(ParametrizedAttribute, TypeAttribute):
    name = "test.singleton_a"


@irdl_attr_definition
class Test_SingletonBType(ParametrizedAttribute, TypeAttribute):
    name = "test.singleton_b"


@irdl_attr_definition
class Test_SingletonCType(ParametrizedAttribute, TypeAttribute):
    name = "test.singleton_c"


@irdl_attr_definition
class Test_TestAttr(ParametrizedAttribute):
    name = "test.test"


@irdl_op_definition
class Test_AndOp(IRDLOperation):
    name = "test.and"

    in_ = operand_def(AllOf((BaseAttr(Test_SingletonAType), AnyAttr())))


@irdl_op_definition
class Test_AnyAttrOfOp(IRDLOperation):
    name = "test.any_attr_of_i32_str"

    attr = prop_def(
        AnyOf(
            [
                IntegerAttr.constr(EqAttrConstraint(IntegerType(32))),
                BaseAttr(StringAttr),
            ]
        )
    )


@irdl_op_definition
class Test_AnyAttrOfSingleOp(IRDLOperation):
    name = "test.any_attr_of_i32"

    attr = prop_def(AnyOf([IntegerAttr.constr(EqAttrConstraint(IntegerType(32)))]))


@irdl_op_definition
class Test_AnyOp(IRDLOperation):
    name = "test.any"

    in_ = operand_def(AnyAttr())


@irdl_op_definition
class Test_AssemblyFormat(IRDLOperation):
    name = "test.assembly"

    assembly_format = """attr-dict"""


@irdl_op_definition
class Test_AssemblyFormatLong(IRDLOperation):
    name = "test.assembly_long"

    assembly_format = """
          `a`
          `very`
          `long`
          `assembly`
          `format`
          attr-dict
      """


@irdl_op_definition
class Test_AttributesOp(IRDLOperation):
    name = "test.attributes"

    int_attr = prop_def(IntegerAttr.constr(EqAttrConstraint(IntegerType(16))))

    in_ = prop_def(BaseAttr(Test_TestAttr), prop_name="in")

    opt = opt_prop_def(BaseAttr(Test_TestAttr))


@irdl_op_definition
class Test_ConfinedOp(IRDLOperation):
    name = "test.confined"

    tensor = operand_def(AnyAttr())

    vector = operand_def(AnyAttr())


@irdl_op_definition
class Test_Integers(IRDLOperation):
    name = "test.integers"

    any_int = operand_def(
        ParamAttrConstraint(
            IntegerType,
            (EqAttrConstraint(IntAttr(8)), AnyAttr()),
        )
    )

    any_integer = operand_def(BaseAttr(IntegerType))


@irdl_op_definition
class Test_OrOp(IRDLOperation):
    name = "test.or"

    in_ = operand_def(
        AnyOf(
            (
                BaseAttr(Test_SingletonAType),
                BaseAttr(Test_SingletonBType),
                BaseAttr(Test_SingletonCType),
            )
        )
    )


@irdl_op_definition
class Test_SummaryOp(IRDLOperation):
    """Op with a summary."""

    name = "test.summary"


@irdl_op_definition
class Test_TypesOp(IRDLOperation):
    name = "test.types"

    a = operand_def(EqAttrConstraint(IntegerType(32)))

    b = operand_def(EqAttrConstraint(IntegerType(64, Signedness.SIGNED)))

    c = operand_def(EqAttrConstraint(IntegerType(8, Signedness.UNSIGNED)))

    d = operand_def(EqAttrConstraint(IndexType()))

    e = operand_def(EqAttrConstraint(Float32Type()))

    f = operand_def(EqAttrConstraint(NoneType()))

    g = prop_def(SymbolNameConstraint())

    v1 = operand_def(
        ParamAttrConstraint(
            ComplexType,
            (AnyAttr(),),
        )
    )


@irdl_op_definition
class Test_VariadicityOp(IRDLOperation):
    name = "test.variadicity"

    variadic = var_operand_def(BaseAttr(Test_SingletonAType))

    optional = opt_operand_def(BaseAttr(Test_SingletonBType))

    required = operand_def(BaseAttr(Test_SingletonCType))


Test_Dialect = Dialect(
    "test",
    [
        Test_AndOp,
        Test_AnyAttrOfOp,
        Test_AnyAttrOfSingleOp,
        Test_AnyOp,
        Test_AssemblyFormat,
        Test_AssemblyFormatLong,
        Test_AttributesOp,
        Test_ConfinedOp,
        Test_Integers,
        Test_OrOp,
        Test_SummaryOp,
        Test_TypesOp,
        Test_VariadicityOp,
    ],
    [
        Test_SingletonAType,
        Test_SingletonBType,
        Test_SingletonCType,
        Test_TestAttr,
    ],
)
