Skip to content

Bigint

bigint

Dialect for unlimited precision integers with Python int semantics.

bigint = BigIntegerType() module-attribute

BigInt = Dialect('bigint', [AddOp, SubOp, MulOp, FloorDivOp, ModOp, PowOp, LShiftOp, RShiftOp, BitOrOp, BitXorOp, BitAndOp, DivOp, EqOp, NeqOp, GtOp, GteOp, LtOp, LteOp], [BigIntegerType]) module-attribute

BigIntegerType dataclass

Bases: ParametrizedAttribute, TypeAttribute

Type for unlimited precision integers, with Python int semantics.

Source code in xdsl/dialects/bigint.py
24
25
26
27
28
@irdl_attr_definition
class BigIntegerType(ParametrizedAttribute, TypeAttribute):
    """Type for unlimited precision integers, with Python `int` semantics."""

    name = "bigint.bigint"

name = 'bigint.bigint' class-attribute instance-attribute

BinaryOperation

Bases: IRDLOperation, ABC

Binary operation where all operands and results are bigints.

Source code in xdsl/dialects/bigint.py
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
class BinaryOperation(IRDLOperation, abc.ABC):
    """Binary operation where all operands and results are `bigint`s."""

    lhs = operand_def(bigint)
    rhs = operand_def(bigint)
    result = result_def(bigint)

    assembly_format = "$lhs `,` $rhs attr-dict `:` type($result)"

    def __init__(
        self,
        operand1: Operation | SSAValue,
        operand2: Operation | SSAValue,
    ):
        super().__init__(operands=[operand1, operand2], result_types=[bigint])

lhs = operand_def(bigint) class-attribute instance-attribute

rhs = operand_def(bigint) class-attribute instance-attribute

result = result_def(bigint) class-attribute instance-attribute

assembly_format = '$lhs `,` $rhs attr-dict `:` type($result)' class-attribute instance-attribute

__init__(operand1: Operation | SSAValue, operand2: Operation | SSAValue)

Source code in xdsl/dialects/bigint.py
43
44
45
46
47
48
def __init__(
    self,
    operand1: Operation | SSAValue,
    operand2: Operation | SSAValue,
):
    super().__init__(operands=[operand1, operand2], result_types=[bigint])

AddOp dataclass

Bases: BinaryOperation

Add two bigints.

Source code in xdsl/dialects/bigint.py
51
52
53
54
55
56
57
58
59
60
61
@irdl_op_definition
class AddOp(BinaryOperation):
    """Add two `bigint`s."""

    name = "bigint.add"

    traits = traits_def(
        Pure(),
        Commutative(),
        SameOperandsAndResultType(),
    )

name = 'bigint.add' class-attribute instance-attribute

traits = traits_def(Pure(), Commutative(), SameOperandsAndResultType()) class-attribute instance-attribute

SubOp dataclass

Bases: BinaryOperation

Subtract two bigints.

Source code in xdsl/dialects/bigint.py
64
65
66
67
68
69
70
71
72
73
74
@irdl_op_definition
class SubOp(BinaryOperation):
    """Subtract two `bigint`s."""

    name = "bigint.sub"

    traits = traits_def(
        Pure(),
        Commutative(),
        SameOperandsAndResultType(),
    )

name = 'bigint.sub' class-attribute instance-attribute

traits = traits_def(Pure(), Commutative(), SameOperandsAndResultType()) class-attribute instance-attribute

MulOp dataclass

Bases: BinaryOperation

Multiply two bigints.

Source code in xdsl/dialects/bigint.py
77
78
79
80
81
82
83
84
85
86
87
@irdl_op_definition
class MulOp(BinaryOperation):
    """Multiply two `bigint`s."""

    name = "bigint.mul"

    traits = traits_def(
        Pure(),
        Commutative(),
        SameOperandsAndResultType(),
    )

name = 'bigint.mul' class-attribute instance-attribute

traits = traits_def(Pure(), Commutative(), SameOperandsAndResultType()) class-attribute instance-attribute

FloorDivOp dataclass

Bases: BinaryOperation

Floor divide two bigints, rounding down to the nearest integer.

Source code in xdsl/dialects/bigint.py
90
91
92
93
94
95
96
97
98
99
@irdl_op_definition
class FloorDivOp(BinaryOperation):
    """Floor divide two `bigint`s, rounding down to the nearest integer."""

    name = "bigint.floordiv"

    traits = traits_def(
        Pure(),
        SameOperandsAndResultType(),
    )

name = 'bigint.floordiv' class-attribute instance-attribute

traits = traits_def(Pure(), SameOperandsAndResultType()) class-attribute instance-attribute

ModOp dataclass

Bases: BinaryOperation

Modulo two bigints, taking the sign of the divisor.

Source code in xdsl/dialects/bigint.py
102
103
104
105
106
107
108
109
110
111
@irdl_op_definition
class ModOp(BinaryOperation):
    """Modulo two `bigint`s, taking the sign of the divisor."""

    name = "bigint.mod"

    traits = traits_def(
        Pure(),
        SameOperandsAndResultType(),
    )

name = 'bigint.mod' class-attribute instance-attribute

traits = traits_def(Pure(), SameOperandsAndResultType()) class-attribute instance-attribute

PowOp dataclass

Bases: BinaryOperation

Exponentiate a bigint by another.

Source code in xdsl/dialects/bigint.py
114
115
116
117
118
119
120
121
122
123
@irdl_op_definition
class PowOp(BinaryOperation):
    """Exponentiate a `bigint` by another."""

    name = "bigint.pow"

    traits = traits_def(
        Pure(),
        SameOperandsAndResultType(),
    )

name = 'bigint.pow' class-attribute instance-attribute

traits = traits_def(Pure(), SameOperandsAndResultType()) class-attribute instance-attribute

LShiftOp dataclass

Bases: BinaryOperation

Left shift a bigint by another.

Source code in xdsl/dialects/bigint.py
126
127
128
129
130
131
132
133
134
135
@irdl_op_definition
class LShiftOp(BinaryOperation):
    """Left shift a `bigint` by another."""

    name = "bigint.lshift"

    traits = traits_def(
        Pure(),
        SameOperandsAndResultType(),
    )

name = 'bigint.lshift' class-attribute instance-attribute

traits = traits_def(Pure(), SameOperandsAndResultType()) class-attribute instance-attribute

RShiftOp dataclass

Bases: BinaryOperation

Right shift a bigint by another.

Source code in xdsl/dialects/bigint.py
138
139
140
141
142
143
144
145
146
147
@irdl_op_definition
class RShiftOp(BinaryOperation):
    """Right shift a `bigint` by another."""

    name = "bigint.rshift"

    traits = traits_def(
        Pure(),
        SameOperandsAndResultType(),
    )

name = 'bigint.rshift' class-attribute instance-attribute

traits = traits_def(Pure(), SameOperandsAndResultType()) class-attribute instance-attribute

BitOrOp dataclass

Bases: BinaryOperation

Bitwise OR a bigint with another.

Source code in xdsl/dialects/bigint.py
150
151
152
153
154
155
156
157
158
159
160
@irdl_op_definition
class BitOrOp(BinaryOperation):
    """Bitwise OR a `bigint` with another."""

    name = "bigint.bitor"

    traits = traits_def(
        Pure(),
        Commutative(),
        SameOperandsAndResultType(),
    )

name = 'bigint.bitor' class-attribute instance-attribute

traits = traits_def(Pure(), Commutative(), SameOperandsAndResultType()) class-attribute instance-attribute

BitXorOp dataclass

Bases: BinaryOperation

Bitwise XOR a bigint with another.

Source code in xdsl/dialects/bigint.py
163
164
165
166
167
168
169
170
171
172
173
@irdl_op_definition
class BitXorOp(BinaryOperation):
    """Bitwise XOR a `bigint` with another."""

    name = "bigint.bitxor"

    traits = traits_def(
        Pure(),
        Commutative(),
        SameOperandsAndResultType(),
    )

name = 'bigint.bitxor' class-attribute instance-attribute

traits = traits_def(Pure(), Commutative(), SameOperandsAndResultType()) class-attribute instance-attribute

BitAndOp dataclass

Bases: BinaryOperation

Bitwise AND a bigint with another.

Source code in xdsl/dialects/bigint.py
176
177
178
179
180
181
182
183
184
185
186
@irdl_op_definition
class BitAndOp(BinaryOperation):
    """Bitwise AND a `bigint` with another."""

    name = "bigint.bitand"

    traits = traits_def(
        Pure(),
        Commutative(),
        SameOperandsAndResultType(),
    )

name = 'bigint.bitand' class-attribute instance-attribute

traits = traits_def(Pure(), Commutative(), SameOperandsAndResultType()) class-attribute instance-attribute

DivOp

Bases: IRDLOperation

Divide two bigints, yielding a 64-bit floating point type.

Note that this operation follows Python semantics, for example by rounding to minus infinity.

Source code in xdsl/dialects/bigint.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
@irdl_op_definition
class DivOp(IRDLOperation):
    """Divide two `bigint`s, yielding a 64-bit floating point type.

    Note that this operation follows Python semantics, for example by rounding
    to minus infinity.
    """

    name = "bigint.div"

    lhs = operand_def(bigint)
    rhs = operand_def(bigint)
    result = result_def(f64)

    assembly_format = "$lhs `,` $rhs attr-dict `:` type($result)"

    traits = traits_def(
        Pure(),
    )

    def __init__(
        self,
        operand1: Operation | SSAValue,
        operand2: Operation | SSAValue,
    ):
        super().__init__(operands=[operand1, operand2], result_types=[f64])

name = 'bigint.div' class-attribute instance-attribute

lhs = operand_def(bigint) class-attribute instance-attribute

rhs = operand_def(bigint) class-attribute instance-attribute

result = result_def(f64) class-attribute instance-attribute

assembly_format = '$lhs `,` $rhs attr-dict `:` type($result)' class-attribute instance-attribute

traits = traits_def(Pure()) class-attribute instance-attribute

__init__(operand1: Operation | SSAValue, operand2: Operation | SSAValue)

Source code in xdsl/dialects/bigint.py
209
210
211
212
213
214
def __init__(
    self,
    operand1: Operation | SSAValue,
    operand2: Operation | SSAValue,
):
    super().__init__(operands=[operand1, operand2], result_types=[f64])

ComparisonOperation

Bases: IRDLOperation, ABC

Binary operation comparing two bigints and returning a boolean.

Source code in xdsl/dialects/bigint.py
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
class ComparisonOperation(IRDLOperation, abc.ABC):
    """Binary operation comparing two `bigint`s and returning a boolean."""

    lhs = operand_def(bigint)
    rhs = operand_def(bigint)
    result = result_def(i1)

    assembly_format = "$lhs `,` $rhs attr-dict `:` type($result)"

    def __init__(
        self,
        operand1: Operation | SSAValue,
        operand2: Operation | SSAValue,
    ):
        super().__init__(operands=[operand1, operand2], result_types=[i1])

lhs = operand_def(bigint) class-attribute instance-attribute

rhs = operand_def(bigint) class-attribute instance-attribute

result = result_def(i1) class-attribute instance-attribute

assembly_format = '$lhs `,` $rhs attr-dict `:` type($result)' class-attribute instance-attribute

__init__(operand1: Operation | SSAValue, operand2: Operation | SSAValue)

Source code in xdsl/dialects/bigint.py
226
227
228
229
230
231
def __init__(
    self,
    operand1: Operation | SSAValue,
    operand2: Operation | SSAValue,
):
    super().__init__(operands=[operand1, operand2], result_types=[i1])

EqOp dataclass

Bases: ComparisonOperation

Check equality of two bigints.

Source code in xdsl/dialects/bigint.py
234
235
236
237
238
239
240
241
242
243
@irdl_op_definition
class EqOp(ComparisonOperation):
    """Check equality of two `bigint`s."""

    name = "bigint.eq"

    traits = traits_def(
        Pure(),
        Commutative(),
    )

name = 'bigint.eq' class-attribute instance-attribute

traits = traits_def(Pure(), Commutative()) class-attribute instance-attribute

NeqOp dataclass

Bases: ComparisonOperation

Check inequality of two bigints.

Source code in xdsl/dialects/bigint.py
246
247
248
249
250
251
252
253
254
255
@irdl_op_definition
class NeqOp(ComparisonOperation):
    """Check inequality of two `bigint`s."""

    name = "bigint.neq"

    traits = traits_def(
        Pure(),
        Commutative(),
    )

name = 'bigint.neq' class-attribute instance-attribute

traits = traits_def(Pure(), Commutative()) class-attribute instance-attribute

GtOp dataclass

Bases: ComparisonOperation

Check if one bigint is greater than another.

Source code in xdsl/dialects/bigint.py
258
259
260
261
262
263
264
265
266
@irdl_op_definition
class GtOp(ComparisonOperation):
    """Check if one `bigint` is greater than another."""

    name = "bigint.gt"

    traits = traits_def(
        Pure(),
    )

name = 'bigint.gt' class-attribute instance-attribute

traits = traits_def(Pure()) class-attribute instance-attribute

GteOp dataclass

Bases: ComparisonOperation

Check if one bigint is greater than or equal to another.

Source code in xdsl/dialects/bigint.py
269
270
271
272
273
274
275
276
277
@irdl_op_definition
class GteOp(ComparisonOperation):
    """Check if one `bigint` is greater than or equal to another."""

    name = "bigint.gte"

    traits = traits_def(
        Pure(),
    )

name = 'bigint.gte' class-attribute instance-attribute

traits = traits_def(Pure()) class-attribute instance-attribute

LtOp dataclass

Bases: ComparisonOperation

Check if one bigint is less than another.

Source code in xdsl/dialects/bigint.py
280
281
282
283
284
285
286
287
288
@irdl_op_definition
class LtOp(ComparisonOperation):
    """Check if one `bigint` is less than another."""

    name = "bigint.lt"

    traits = traits_def(
        Pure(),
    )

name = 'bigint.lt' class-attribute instance-attribute

traits = traits_def(Pure()) class-attribute instance-attribute

LteOp dataclass

Bases: ComparisonOperation

Check if one bigint is less than or equal to another.

Source code in xdsl/dialects/bigint.py
291
292
293
294
295
296
297
298
299
@irdl_op_definition
class LteOp(ComparisonOperation):
    """Check if one `bigint` is less than or equal to another."""

    name = "bigint.lte"

    traits = traits_def(
        Pure(),
    )

name = 'bigint.lte' class-attribute instance-attribute

traits = traits_def(Pure()) class-attribute instance-attribute