mod_arith is a dialect implementing modular arithmetic, originally
implemented as part of the HEIR project (https://github.com/google/heir/tree/main).
ModArith = Dialect('mod_arith', [AddOp])
module-attribute
BinaryOp
Bases: IRDLOperation, ABC
Simple binary operation
Source code in xdsl/dialects/mod_arith.py
| class BinaryOp(IRDLOperation, ABC):
"""
Simple binary operation
"""
T: ClassVar = VarConstraint("T", signlessIntegerLike)
lhs = operand_def(T)
rhs = operand_def(T)
output = result_def(T)
modulus = prop_def(IntegerAttr)
irdl_options = (ParsePropInAttrDict(),)
assembly_format = "$lhs `,` $rhs attr-dict `:` type($output)"
traits = traits_def(Pure())
def __init__(
self,
lhs: OperandArg,
rhs: OperandArg,
result_type: Attribute | None,
modulus: Attribute,
):
if result_type is None:
result_type = SSAValue.get(lhs).type
super().__init__(
operands=[lhs, rhs],
result_types=[result_type],
properties={"modulus": modulus},
)
|
T: ClassVar = VarConstraint('T', signlessIntegerLike)
class-attribute
instance-attribute
lhs = operand_def(T)
class-attribute
instance-attribute
rhs = operand_def(T)
class-attribute
instance-attribute
output = result_def(T)
class-attribute
instance-attribute
modulus = prop_def(IntegerAttr)
class-attribute
instance-attribute
irdl_options = (ParsePropInAttrDict(),)
class-attribute
instance-attribute
traits = traits_def(Pure())
class-attribute
instance-attribute
__init__(lhs: OperandArg, rhs: OperandArg, result_type: Attribute | None, modulus: Attribute)
Source code in xdsl/dialects/mod_arith.py
| def __init__(
self,
lhs: OperandArg,
rhs: OperandArg,
result_type: Attribute | None,
modulus: Attribute,
):
if result_type is None:
result_type = SSAValue.get(lhs).type
super().__init__(
operands=[lhs, rhs],
result_types=[result_type],
properties={"modulus": modulus},
)
|
AddOp
dataclass
Bases: BinaryOp
Source code in xdsl/dialects/mod_arith.py
| @irdl_op_definition
class AddOp(BinaryOp):
name = "mod_arith.add"
|
name = 'mod_arith.add'
class-attribute
instance-attribute