Skip to content

Wasmssa

wasmssa

RefType: TypeAlias = FuncRefType | ExternRefType module-attribute

Type alias for opaque references in WebAssembly

WasmIntegerType: TypeAlias = I32 | I64 module-attribute

Type alias for integer types that are supported by WebAssembly

WasmFPType: TypeAlias = Float32Type | Float64Type module-attribute

Type alias for floating-point types that are supported by WebAssembly

NumericType: TypeAlias = WasmIntegerType | WasmFPType module-attribute

Type alias for numeric types that are supported by WebAssembly

ValType: TypeAlias = I128 | NumericType | FuncRefType | ExternRefType module-attribute

Type alias for value types that are supported by WebAssembly

WasmSSA = Dialect('wasmssa', [AbsOp, AddOp, AndOp, CeilOp, ClzOp, ConstOp, ConvertSOp, ConvertUOp, CopySignOp, CtzOp, DemoteOp, DivOp, DivSIOp, DivUIOp, EqOp, EqzOp, FloorOp, ExtendLowBitsSOp, ExtendSI32Op, ExtendUI32Op, GeOp, GeSIOp, GeUIOp, GlobalGetOp, GtOp, GtSIOp, GtUIOp, LeOp, LeSIOp, LeUIOp, LtOp, LtSIOp, LtUIOp, MaxOp, MinOp, MulOp, NeOp, NegOp, OrOp, PopCntOp, RemSIOp, RemUIOp, RotlOp, RotrOp, ShLOp, ShRSOp, ShRUOp, SqrtOp, SubOp, TruncOp, PromoteOp, ReinterpretOp, WrapOp, XOrOp], [ExternRefType, FuncRefType, LimitType, LocalRefType, TableType]) module-attribute

FuncRefType dataclass

Bases: ParametrizedAttribute, TypeAttribute

Opaque type for function reference

Source code in xdsl/dialects/wasmssa.py
51
52
53
54
55
56
57
@irdl_attr_definition
class FuncRefType(ParametrizedAttribute, TypeAttribute):
    """
    Opaque type for function reference
    """

    name = "wasmssa.funcref"

name = 'wasmssa.funcref' class-attribute instance-attribute

ExternRefType dataclass

Bases: ParametrizedAttribute, TypeAttribute

Opaque type for extern reference

Source code in xdsl/dialects/wasmssa.py
60
61
62
63
64
65
66
@irdl_attr_definition
class ExternRefType(ParametrizedAttribute, TypeAttribute):
    """
    Opaque type for extern reference
    """

    name = "wasmssa.externref"

name = 'wasmssa.externref' class-attribute instance-attribute

LimitType dataclass

Bases: ParametrizedAttribute, OpaqueSyntaxAttribute, TypeAttribute

Wasm limit type

Prints as !wasmssa<limit[$min: $max]>

Source code in xdsl/dialects/wasmssa.py
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
@irdl_attr_definition
class LimitType(ParametrizedAttribute, OpaqueSyntaxAttribute, TypeAttribute):
    """
    Wasm limit type

    Prints as `!wasmssa<limit[$min: $max]>`
    """

    name = "wasmssa.limit"

    min: IntAttr
    max: IntAttr | NoneAttr

    @classmethod
    def parse_parameters(cls, parser: AttrParser) -> tuple[IntAttr, IntAttr | NoneAttr]:
        with parser.in_square_brackets():
            min = parser.parse_integer(False, False)
            parser.parse_punctuation(":")
            max = parser.parse_optional_integer(False, False)
        return (IntAttr(min), IntAttr(max) if max is not None else NoneAttr())

    def print_parameters(self, printer: Printer) -> None:
        with printer.in_square_brackets():
            printer.print_int(self.min.data)
            printer.print_string(":")
            if not isinstance(self.max, NoneAttr):
                printer.print_string(" ")
                printer.print_int(self.max.data)

name = 'wasmssa.limit' class-attribute instance-attribute

min: IntAttr instance-attribute

max: IntAttr | NoneAttr instance-attribute

parse_parameters(parser: AttrParser) -> tuple[IntAttr, IntAttr | NoneAttr] classmethod

Source code in xdsl/dialects/wasmssa.py
 99
100
101
102
103
104
105
@classmethod
def parse_parameters(cls, parser: AttrParser) -> tuple[IntAttr, IntAttr | NoneAttr]:
    with parser.in_square_brackets():
        min = parser.parse_integer(False, False)
        parser.parse_punctuation(":")
        max = parser.parse_optional_integer(False, False)
    return (IntAttr(min), IntAttr(max) if max is not None else NoneAttr())

print_parameters(printer: Printer) -> None

Source code in xdsl/dialects/wasmssa.py
107
108
109
110
111
112
113
def print_parameters(self, printer: Printer) -> None:
    with printer.in_square_brackets():
        printer.print_int(self.min.data)
        printer.print_string(":")
        if not isinstance(self.max, NoneAttr):
            printer.print_string(" ")
            printer.print_int(self.max.data)

LocalRefType dataclass

Bases: ParametrizedAttribute, SpacedOpaqueSyntaxAttribute, TypeAttribute

Type of a local variable

Prints as !wasmssa<local ref to $elementType>

Source code in xdsl/dialects/wasmssa.py
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
@irdl_attr_definition
class LocalRefType(ParametrizedAttribute, SpacedOpaqueSyntaxAttribute, TypeAttribute):
    """
    Type of a local variable

    Prints as `!wasmssa<local ref to $elementType>`
    """

    name = "wasmssa.local"

    elementType: ValType

    @classmethod
    def parse_parameters(cls, parser: AttrParser) -> Sequence[TypeAttribute]:
        parser.parse_keyword("ref")
        parser.parse_keyword("to")
        ty = parser.parse_type()
        return [ty]

    def print_parameters(self, printer: Printer) -> None:
        printer.print_string("ref to ")
        printer.print_attribute(self.elementType)

name = 'wasmssa.local' class-attribute instance-attribute

elementType: ValType instance-attribute

parse_parameters(parser: AttrParser) -> Sequence[TypeAttribute] classmethod

Source code in xdsl/dialects/wasmssa.py
128
129
130
131
132
133
@classmethod
def parse_parameters(cls, parser: AttrParser) -> Sequence[TypeAttribute]:
    parser.parse_keyword("ref")
    parser.parse_keyword("to")
    ty = parser.parse_type()
    return [ty]

print_parameters(printer: Printer) -> None

Source code in xdsl/dialects/wasmssa.py
135
136
137
def print_parameters(self, printer: Printer) -> None:
    printer.print_string("ref to ")
    printer.print_attribute(self.elementType)

TableType dataclass

Bases: ParametrizedAttribute, SpacedOpaqueSyntaxAttribute, TypeAttribute

Wasm table type

Prints as !wasmssa<tabletype $reference [$limit.min: $limit.max]>

Source code in xdsl/dialects/wasmssa.py
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
@irdl_attr_definition
class TableType(ParametrizedAttribute, SpacedOpaqueSyntaxAttribute, TypeAttribute):
    """
    Wasm table type

    Prints as `!wasmssa<tabletype $reference [$limit.min: $limit.max]>`
    """

    name = "wasmssa.tabletype"

    reference: RefType
    limit: LimitType

    @classmethod
    def parse_parameters(cls, parser: AttrParser) -> tuple[RefType, LimitType]:
        reference = cast(RefType, parser.parse_type())
        min, max = LimitType.parse_parameters(parser)

        return (reference, LimitType(min, max))

    def print_parameters(self, printer: Printer) -> None:
        printer.print_attribute(self.reference)
        printer.print_string(" ")
        self.limit.print_parameters(printer)

name = 'wasmssa.tabletype' class-attribute instance-attribute

reference: RefType instance-attribute

limit: LimitType instance-attribute

parse_parameters(parser: AttrParser) -> tuple[RefType, LimitType] classmethod

Source code in xdsl/dialects/wasmssa.py
153
154
155
156
157
158
@classmethod
def parse_parameters(cls, parser: AttrParser) -> tuple[RefType, LimitType]:
    reference = cast(RefType, parser.parse_type())
    min, max = LimitType.parse_parameters(parser)

    return (reference, LimitType(min, max))

print_parameters(printer: Printer) -> None

Source code in xdsl/dialects/wasmssa.py
160
161
162
163
def print_parameters(self, printer: Printer) -> None:
    printer.print_attribute(self.reference)
    printer.print_string(" ")
    self.limit.print_parameters(printer)

ConstOp

Bases: IRDLOperation

Define a WebAssembly numeric constant.

Source code in xdsl/dialects/wasmssa.py
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
@irdl_op_definition
class ConstOp(IRDLOperation):
    """Define a WebAssembly numeric constant."""

    name = "wasmssa.const"

    T: ClassVar = VarConstraint.get("T", NumericType)

    value = prop_def(
        ParamAttrConstraint(IntegerAttr, (AnyAttr(), T))
        | ParamAttrConstraint(FloatAttr, (AnyAttr(), T))
    )
    result = result_def(T)

    traits = traits_def(ConstantLike())

    assembly_format = "$value attr-dict"

    def __init__(self, value: IntegerAttr | FloatAttr):
        super().__init__(
            properties={"value": value},
            result_types=[value.get_type()],
        )

name = 'wasmssa.const' class-attribute instance-attribute

T: ClassVar = VarConstraint.get('T', NumericType) class-attribute instance-attribute

value = prop_def(ParamAttrConstraint(IntegerAttr, (AnyAttr(), T)) | ParamAttrConstraint(FloatAttr, (AnyAttr(), T))) class-attribute instance-attribute

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

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

assembly_format = '$value attr-dict' class-attribute instance-attribute

__init__(value: IntegerAttr | FloatAttr)

Source code in xdsl/dialects/wasmssa.py
184
185
186
187
188
def __init__(self, value: IntegerAttr | FloatAttr):
    super().__init__(
        properties={"value": value},
        result_types=[value.get_type()],
    )

GlobalGetOp

Bases: IRDLOperation

Return the value of a WebAssembly global.

Source code in xdsl/dialects/wasmssa.py
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
@irdl_op_definition
class GlobalGetOp(IRDLOperation):
    """Return the value of a WebAssembly global."""

    name = "wasmssa.global_get"

    global_ = prop_def(FlatSymbolRefAttrConstr, prop_name="global")
    global_val = result_def(ValType)

    traits = traits_def(ConstantLike())

    assembly_format = "$global attr-dict `:` type($global_val)"

    def __init__(
        self,
        global_: str | SymbolRefAttr,
        result_type: ValType,
    ):
        super().__init__(
            properties={"global": SymbolRefAttr.get(global_)},
            result_types=[result_type],
        )

name = 'wasmssa.global_get' class-attribute instance-attribute

global_ = prop_def(FlatSymbolRefAttrConstr, prop_name='global') class-attribute instance-attribute

global_val = result_def(ValType) class-attribute instance-attribute

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

assembly_format = '$global attr-dict `:` type($global_val)' class-attribute instance-attribute

__init__(global_: str | SymbolRefAttr, result_type: ValType)

Source code in xdsl/dialects/wasmssa.py
204
205
206
207
208
209
210
211
212
def __init__(
    self,
    global_: str | SymbolRefAttr,
    result_type: ValType,
):
    super().__init__(
        properties={"global": SymbolRefAttr.get(global_)},
        result_types=[result_type],
    )

BinaryNumericalOperation

Bases: IRDLOperation, ABC, Generic[_NumericTypeInvT]

Base class for binary WebAssembly numeric operations.

Source code in xdsl/dialects/wasmssa.py
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
class BinaryNumericalOperation(IRDLOperation, ABC, Generic[_NumericTypeInvT]):
    """Base class for binary WebAssembly numeric operations."""

    T: ClassVar = VarConstraint(
        "T", irdl_to_attr_constraint(_NumericTypeInvT, allow_type_var=True)
    )

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

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

    def __init__(
        self,
        lhs: SSAValue | Operation,
        rhs: SSAValue | Operation,
    ):
        lhs = SSAValue.get(lhs)
        super().__init__(operands=[lhs, rhs], result_types=[lhs.type])

T: ClassVar = VarConstraint('T', irdl_to_attr_constraint(_NumericTypeInvT, allow_type_var=True)) class-attribute instance-attribute

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

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

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

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

__init__(lhs: SSAValue | Operation, rhs: SSAValue | Operation)

Source code in xdsl/dialects/wasmssa.py
228
229
230
231
232
233
234
def __init__(
    self,
    lhs: SSAValue | Operation,
    rhs: SSAValue | Operation,
):
    lhs = SSAValue.get(lhs)
    super().__init__(operands=[lhs, rhs], result_types=[lhs.type])

AddOp dataclass

Bases: BinaryNumericalOperation

Sum two WebAssembly numeric values.

Source code in xdsl/dialects/wasmssa.py
237
238
239
240
241
242
243
@irdl_op_definition
class AddOp(BinaryNumericalOperation):
    """Sum two WebAssembly numeric values."""

    name = "wasmssa.add"

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

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

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

AndOp dataclass

Bases: BinaryNumericalOperation

Compute the bitwise AND between two values.

Source code in xdsl/dialects/wasmssa.py
246
247
248
249
250
251
252
@irdl_op_definition
class AndOp(BinaryNumericalOperation):
    """Compute the bitwise AND between two values."""

    name = "wasmssa.and"

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

name = 'wasmssa.and' class-attribute instance-attribute

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

DivOp dataclass

Bases: BinaryNumericalOperation[WasmFPType]

Divide two floating-point values.

Source code in xdsl/dialects/wasmssa.py
255
256
257
258
259
260
261
@irdl_op_definition
class DivOp(BinaryNumericalOperation[WasmFPType]):
    """Divide two floating-point values."""

    name = "wasmssa.div"

    traits = traits_def(Pure())

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

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

DivUIOp dataclass

Bases: BinaryNumericalOperation[WasmIntegerType]

Divide two values interpreted as unsigned integers.

Source code in xdsl/dialects/wasmssa.py
264
265
266
267
268
269
270
@irdl_op_definition
class DivUIOp(BinaryNumericalOperation[WasmIntegerType]):
    """Divide two values interpreted as unsigned integers."""

    name = "wasmssa.div_ui"

    traits = traits_def(NoMemoryEffect())

name = 'wasmssa.div_ui' class-attribute instance-attribute

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

DivSIOp dataclass

Bases: BinaryNumericalOperation[WasmIntegerType]

Divide two values interpreted as signed integers.

Source code in xdsl/dialects/wasmssa.py
273
274
275
276
277
278
279
@irdl_op_definition
class DivSIOp(BinaryNumericalOperation[WasmIntegerType]):
    """Divide two values interpreted as signed integers."""

    name = "wasmssa.div_si"

    traits = traits_def(NoMemoryEffect())

name = 'wasmssa.div_si' class-attribute instance-attribute

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

MulOp dataclass

Bases: BinaryNumericalOperation

Multiply two values.

Source code in xdsl/dialects/wasmssa.py
282
283
284
285
286
287
288
@irdl_op_definition
class MulOp(BinaryNumericalOperation):
    """Multiply two values."""

    name = "wasmssa.mul"

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

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

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

OrOp dataclass

Bases: BinaryNumericalOperation

Compute the bitwise OR between two values.

Source code in xdsl/dialects/wasmssa.py
291
292
293
294
295
296
297
@irdl_op_definition
class OrOp(BinaryNumericalOperation):
    """Compute the bitwise OR between two values."""

    name = "wasmssa.or"

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

name = 'wasmssa.or' class-attribute instance-attribute

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

SubOp dataclass

Bases: BinaryNumericalOperation

Subtract two values.

Source code in xdsl/dialects/wasmssa.py
300
301
302
303
304
305
306
@irdl_op_definition
class SubOp(BinaryNumericalOperation):
    """Subtract two values."""

    name = "wasmssa.sub"

    traits = traits_def(Pure())

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

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

RemUIOp dataclass

Bases: BinaryNumericalOperation[WasmIntegerType]

Compute the unsigned integer remainder of two values.

Source code in xdsl/dialects/wasmssa.py
309
310
311
312
313
314
315
@irdl_op_definition
class RemUIOp(BinaryNumericalOperation[WasmIntegerType]):
    """Compute the unsigned integer remainder of two values."""

    name = "wasmssa.rem_ui"

    traits = traits_def(NoMemoryEffect())

name = 'wasmssa.rem_ui' class-attribute instance-attribute

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

RemSIOp dataclass

Bases: BinaryNumericalOperation[WasmIntegerType]

Compute the signed integer remainder of two values.

Source code in xdsl/dialects/wasmssa.py
318
319
320
321
322
323
324
@irdl_op_definition
class RemSIOp(BinaryNumericalOperation[WasmIntegerType]):
    """Compute the signed integer remainder of two values."""

    name = "wasmssa.rem_si"

    traits = traits_def(NoMemoryEffect())

name = 'wasmssa.rem_si' class-attribute instance-attribute

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

XOrOp dataclass

Bases: BinaryNumericalOperation

Compute the bitwise XOR between two values.

Source code in xdsl/dialects/wasmssa.py
327
328
329
330
331
332
333
@irdl_op_definition
class XOrOp(BinaryNumericalOperation):
    """Compute the bitwise XOR between two values."""

    name = "wasmssa.xor"

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

name = 'wasmssa.xor' class-attribute instance-attribute

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

MinOp dataclass

Bases: BinaryNumericalOperation[WasmFPType]

Compute the minimum of two floating-point values.

Source code in xdsl/dialects/wasmssa.py
336
337
338
339
340
341
342
@irdl_op_definition
class MinOp(BinaryNumericalOperation[WasmFPType]):
    """Compute the minimum of two floating-point values."""

    name = "wasmssa.min"

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

name = 'wasmssa.min' class-attribute instance-attribute

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

MaxOp dataclass

Bases: BinaryNumericalOperation[WasmFPType]

Compute the maximum of two floating-point values.

Source code in xdsl/dialects/wasmssa.py
345
346
347
348
349
350
351
@irdl_op_definition
class MaxOp(BinaryNumericalOperation[WasmFPType]):
    """Compute the maximum of two floating-point values."""

    name = "wasmssa.max"

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

name = 'wasmssa.max' class-attribute instance-attribute

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

CopySignOp dataclass

Bases: BinaryNumericalOperation[WasmFPType]

Copy the sign of the second floating-point value to the first.

Source code in xdsl/dialects/wasmssa.py
354
355
356
357
358
359
360
@irdl_op_definition
class CopySignOp(BinaryNumericalOperation[WasmFPType]):
    """Copy the sign of the second floating-point value to the first."""

    name = "wasmssa.copysign"

    traits = traits_def(Pure())

name = 'wasmssa.copysign' class-attribute instance-attribute

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

BinaryComparisonOperation

Bases: IRDLOperation, ABC, Generic[_NumericTypeInvT]

Base class for binary WebAssembly comparison operations.

Source code in xdsl/dialects/wasmssa.py
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
class BinaryComparisonOperation(IRDLOperation, ABC, Generic[_NumericTypeInvT]):
    """Base class for binary WebAssembly comparison operations."""

    T: ClassVar = VarConstraint(
        "T", irdl_to_attr_constraint(_NumericTypeInvT, allow_type_var=True)
    )

    lhs = operand_def(T)
    rhs = operand_def(T)
    result = result_def(I32)

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

    def __init__(
        self,
        lhs: SSAValue | Operation,
        rhs: SSAValue | Operation,
    ):
        super().__init__(operands=[lhs, rhs], result_types=[i32])

T: ClassVar = VarConstraint('T', irdl_to_attr_constraint(_NumericTypeInvT, allow_type_var=True)) class-attribute instance-attribute

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

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

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

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

__init__(lhs: SSAValue | Operation, rhs: SSAValue | Operation)

Source code in xdsl/dialects/wasmssa.py
376
377
378
379
380
381
def __init__(
    self,
    lhs: SSAValue | Operation,
    rhs: SSAValue | Operation,
):
    super().__init__(operands=[lhs, rhs], result_types=[i32])

EqOp dataclass

Bases: BinaryComparisonOperation

Check if two numeric values are equal.

Source code in xdsl/dialects/wasmssa.py
384
385
386
387
388
389
390
@irdl_op_definition
class EqOp(BinaryComparisonOperation):
    """Check if two numeric values are equal."""

    name = "wasmssa.eq"

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

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

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

NeOp dataclass

Bases: BinaryComparisonOperation

Check if two numeric values are different.

Source code in xdsl/dialects/wasmssa.py
393
394
395
396
397
398
399
@irdl_op_definition
class NeOp(BinaryComparisonOperation):
    """Check if two numeric values are different."""

    name = "wasmssa.ne"

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

name = 'wasmssa.ne' class-attribute instance-attribute

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

LtSIOp dataclass

Bases: BinaryComparisonOperation[WasmIntegerType]

Check if a signed integer is less than another.

Source code in xdsl/dialects/wasmssa.py
402
403
404
405
406
407
408
@irdl_op_definition
class LtSIOp(BinaryComparisonOperation[WasmIntegerType]):
    """Check if a signed integer is less than another."""

    name = "wasmssa.lt_si"

    traits = traits_def(Pure())

name = 'wasmssa.lt_si' class-attribute instance-attribute

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

LtUIOp dataclass

Bases: BinaryComparisonOperation[WasmIntegerType]

Check if an unsigned integer is less than another.

Source code in xdsl/dialects/wasmssa.py
411
412
413
414
415
416
417
@irdl_op_definition
class LtUIOp(BinaryComparisonOperation[WasmIntegerType]):
    """Check if an unsigned integer is less than another."""

    name = "wasmssa.lt_ui"

    traits = traits_def(Pure())

name = 'wasmssa.lt_ui' class-attribute instance-attribute

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

LeSIOp dataclass

Bases: BinaryComparisonOperation[WasmIntegerType]

Check if a signed integer is less than or equal to another.

Source code in xdsl/dialects/wasmssa.py
420
421
422
423
424
425
426
@irdl_op_definition
class LeSIOp(BinaryComparisonOperation[WasmIntegerType]):
    """Check if a signed integer is less than or equal to another."""

    name = "wasmssa.le_si"

    traits = traits_def(Pure())

name = 'wasmssa.le_si' class-attribute instance-attribute

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

LeUIOp dataclass

Bases: BinaryComparisonOperation[WasmIntegerType]

Check if an unsigned integer is less than or equal to another.

Source code in xdsl/dialects/wasmssa.py
429
430
431
432
433
434
435
@irdl_op_definition
class LeUIOp(BinaryComparisonOperation[WasmIntegerType]):
    """Check if an unsigned integer is less than or equal to another."""

    name = "wasmssa.le_ui"

    traits = traits_def(Pure())

name = 'wasmssa.le_ui' class-attribute instance-attribute

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

GtSIOp dataclass

Bases: BinaryComparisonOperation[WasmIntegerType]

Check if a signed integer is greater than another.

Source code in xdsl/dialects/wasmssa.py
438
439
440
441
442
443
444
@irdl_op_definition
class GtSIOp(BinaryComparisonOperation[WasmIntegerType]):
    """Check if a signed integer is greater than another."""

    name = "wasmssa.gt_si"

    traits = traits_def(Pure())

name = 'wasmssa.gt_si' class-attribute instance-attribute

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

GtUIOp dataclass

Bases: BinaryComparisonOperation[WasmIntegerType]

Check if an unsigned integer is greater than another.

Source code in xdsl/dialects/wasmssa.py
447
448
449
450
451
452
453
@irdl_op_definition
class GtUIOp(BinaryComparisonOperation[WasmIntegerType]):
    """Check if an unsigned integer is greater than another."""

    name = "wasmssa.gt_ui"

    traits = traits_def(Pure())

name = 'wasmssa.gt_ui' class-attribute instance-attribute

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

GeSIOp dataclass

Bases: BinaryComparisonOperation[WasmIntegerType]

Check if a signed integer is greater than or equal to another.

Source code in xdsl/dialects/wasmssa.py
456
457
458
459
460
461
462
@irdl_op_definition
class GeSIOp(BinaryComparisonOperation[WasmIntegerType]):
    """Check if a signed integer is greater than or equal to another."""

    name = "wasmssa.ge_si"

    traits = traits_def(Pure())

name = 'wasmssa.ge_si' class-attribute instance-attribute

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

GeUIOp dataclass

Bases: BinaryComparisonOperation[WasmIntegerType]

Check if an unsigned integer is greater than or equal to another.

Source code in xdsl/dialects/wasmssa.py
465
466
467
468
469
470
471
@irdl_op_definition
class GeUIOp(BinaryComparisonOperation[WasmIntegerType]):
    """Check if an unsigned integer is greater than or equal to another."""

    name = "wasmssa.ge_ui"

    traits = traits_def(Pure())

name = 'wasmssa.ge_ui' class-attribute instance-attribute

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

LtOp dataclass

Bases: BinaryComparisonOperation[WasmFPType]

Check if a floating-point value is less than another.

Source code in xdsl/dialects/wasmssa.py
474
475
476
477
478
479
480
@irdl_op_definition
class LtOp(BinaryComparisonOperation[WasmFPType]):
    """Check if a floating-point value is less than another."""

    name = "wasmssa.lt"

    traits = traits_def(Pure())

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

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

LeOp dataclass

Bases: BinaryComparisonOperation[WasmFPType]

Check if a floating-point value is less than or equal to another.

Source code in xdsl/dialects/wasmssa.py
483
484
485
486
487
488
489
@irdl_op_definition
class LeOp(BinaryComparisonOperation[WasmFPType]):
    """Check if a floating-point value is less than or equal to another."""

    name = "wasmssa.le"

    traits = traits_def(Pure())

name = 'wasmssa.le' class-attribute instance-attribute

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

GtOp dataclass

Bases: BinaryComparisonOperation[WasmFPType]

Check if a floating-point value is greater than another.

Source code in xdsl/dialects/wasmssa.py
492
493
494
495
496
497
498
@irdl_op_definition
class GtOp(BinaryComparisonOperation[WasmFPType]):
    """Check if a floating-point value is greater than another."""

    name = "wasmssa.gt"

    traits = traits_def(Pure())

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

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

GeOp dataclass

Bases: BinaryComparisonOperation[WasmFPType]

Check if a floating-point value is greater than or equal to another.

Source code in xdsl/dialects/wasmssa.py
501
502
503
504
505
506
507
@irdl_op_definition
class GeOp(BinaryComparisonOperation[WasmFPType]):
    """Check if a floating-point value is greater than or equal to another."""

    name = "wasmssa.ge"

    traits = traits_def(Pure())

name = 'wasmssa.ge' class-attribute instance-attribute

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

EqzOp

Bases: IRDLOperation

Check if an integer value is equal to zero.

Source code in xdsl/dialects/wasmssa.py
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
@irdl_op_definition
class EqzOp(IRDLOperation):
    """Check if an integer value is equal to zero."""

    name = "wasmssa.eqz"

    input = operand_def(WasmIntegerType)
    result = result_def(I32)

    traits = traits_def(Pure())

    assembly_format = "$input `:` type($input) `->` type($result) attr-dict"

    def __init__(self, input: SSAValue | Operation):
        super().__init__(operands=[input], result_types=[i32])

name = 'wasmssa.eqz' class-attribute instance-attribute

input = operand_def(WasmIntegerType) class-attribute instance-attribute

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

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

assembly_format = '$input `:` type($input) `->` type($result) attr-dict' class-attribute instance-attribute

__init__(input: SSAValue | Operation)

Source code in xdsl/dialects/wasmssa.py
523
524
def __init__(self, input: SSAValue | Operation):
    super().__init__(operands=[input], result_types=[i32])

ShiftRotateOperation

Bases: IRDLOperation, ABC

Base class for WebAssembly integer shift and rotate operations.

Source code in xdsl/dialects/wasmssa.py
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
class ShiftRotateOperation(IRDLOperation, ABC):
    """Base class for WebAssembly integer shift and rotate operations."""

    T: ClassVar = VarConstraint.get("T", WasmIntegerType)

    val = operand_def(T)
    bits = operand_def(T)
    result = result_def(T)

    assembly_format = "$val `by` $bits `bits` `:` type($val) attr-dict"

    traits = traits_def(Pure())

    def __init__(
        self,
        val: SSAValue | Operation,
        bits: SSAValue | Operation,
    ):
        val = SSAValue.get(val)
        super().__init__(operands=[val, bits], result_types=[val.type])

T: ClassVar = VarConstraint.get('T', WasmIntegerType) class-attribute instance-attribute

val = operand_def(T) class-attribute instance-attribute

bits = operand_def(T) class-attribute instance-attribute

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

assembly_format = '$val `by` $bits `bits` `:` type($val) attr-dict' class-attribute instance-attribute

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

__init__(val: SSAValue | Operation, bits: SSAValue | Operation)

Source code in xdsl/dialects/wasmssa.py
540
541
542
543
544
545
546
def __init__(
    self,
    val: SSAValue | Operation,
    bits: SSAValue | Operation,
):
    val = SSAValue.get(val)
    super().__init__(operands=[val, bits], result_types=[val.type])

ShLOp dataclass

Bases: ShiftRotateOperation

Shift an integer value left.

Source code in xdsl/dialects/wasmssa.py
549
550
551
552
553
@irdl_op_definition
class ShLOp(ShiftRotateOperation):
    """Shift an integer value left."""

    name = "wasmssa.shl"

name = 'wasmssa.shl' class-attribute instance-attribute

ShRSOp dataclass

Bases: ShiftRotateOperation

Shift a signed integer value right.

Source code in xdsl/dialects/wasmssa.py
556
557
558
559
560
@irdl_op_definition
class ShRSOp(ShiftRotateOperation):
    """Shift a signed integer value right."""

    name = "wasmssa.shr_s"

name = 'wasmssa.shr_s' class-attribute instance-attribute

ShRUOp dataclass

Bases: ShiftRotateOperation

Shift an unsigned integer value right.

Source code in xdsl/dialects/wasmssa.py
563
564
565
566
567
@irdl_op_definition
class ShRUOp(ShiftRotateOperation):
    """Shift an unsigned integer value right."""

    name = "wasmssa.shr_u"

name = 'wasmssa.shr_u' class-attribute instance-attribute

RotlOp dataclass

Bases: ShiftRotateOperation

Rotate an integer value left.

Source code in xdsl/dialects/wasmssa.py
570
571
572
573
574
@irdl_op_definition
class RotlOp(ShiftRotateOperation):
    """Rotate an integer value left."""

    name = "wasmssa.rotl"

name = 'wasmssa.rotl' class-attribute instance-attribute

RotrOp dataclass

Bases: ShiftRotateOperation

Rotate an integer value right.

Source code in xdsl/dialects/wasmssa.py
577
578
579
580
581
@irdl_op_definition
class RotrOp(ShiftRotateOperation):
    """Rotate an integer value right."""

    name = "wasmssa.rotr"

name = 'wasmssa.rotr' class-attribute instance-attribute

UnaryNumericalOperation

Bases: IRDLOperation, ABC, Generic[_NumericTypeInvT]

Base class for unary WebAssembly numeric operations.

Source code in xdsl/dialects/wasmssa.py
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
class UnaryNumericalOperation(IRDLOperation, ABC, Generic[_NumericTypeInvT]):
    """Base class for unary WebAssembly numeric operations."""

    T: ClassVar = VarConstraint(
        "T", irdl_to_attr_constraint(_NumericTypeInvT, allow_type_var=True)
    )

    src = operand_def(T)
    result = result_def(T)

    assembly_format = "$src `:` type($src) attr-dict"

    traits = traits_def(Pure())

    def __init__(self, src: SSAValue | Operation):
        src = SSAValue.get(src)
        super().__init__(operands=[src], result_types=[src.type])

T: ClassVar = VarConstraint('T', irdl_to_attr_constraint(_NumericTypeInvT, allow_type_var=True)) class-attribute instance-attribute

src = operand_def(T) class-attribute instance-attribute

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

assembly_format = '$src `:` type($src) attr-dict' class-attribute instance-attribute

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

__init__(src: SSAValue | Operation)

Source code in xdsl/dialects/wasmssa.py
598
599
600
def __init__(self, src: SSAValue | Operation):
    src = SSAValue.get(src)
    super().__init__(operands=[src], result_types=[src.type])

AbsOp dataclass

Bases: UnaryNumericalOperation[WasmFPType]

Compute the absolute value of a floating-point value.

Source code in xdsl/dialects/wasmssa.py
603
604
605
606
607
@irdl_op_definition
class AbsOp(UnaryNumericalOperation[WasmFPType]):
    """Compute the absolute value of a floating-point value."""

    name = "wasmssa.abs"

name = 'wasmssa.abs' class-attribute instance-attribute

CeilOp dataclass

Bases: UnaryNumericalOperation[WasmFPType]

Round a floating-point value toward positive infinity.

Source code in xdsl/dialects/wasmssa.py
610
611
612
613
614
@irdl_op_definition
class CeilOp(UnaryNumericalOperation[WasmFPType]):
    """Round a floating-point value toward positive infinity."""

    name = "wasmssa.ceil"

name = 'wasmssa.ceil' class-attribute instance-attribute

FloorOp dataclass

Bases: UnaryNumericalOperation[WasmFPType]

Round a floating-point value toward negative infinity.

Source code in xdsl/dialects/wasmssa.py
617
618
619
620
621
@irdl_op_definition
class FloorOp(UnaryNumericalOperation[WasmFPType]):
    """Round a floating-point value toward negative infinity."""

    name = "wasmssa.floor"

name = 'wasmssa.floor' class-attribute instance-attribute

NegOp dataclass

Bases: UnaryNumericalOperation[WasmFPType]

Negate a floating-point value.

Source code in xdsl/dialects/wasmssa.py
624
625
626
627
628
@irdl_op_definition
class NegOp(UnaryNumericalOperation[WasmFPType]):
    """Negate a floating-point value."""

    name = "wasmssa.neg"

name = 'wasmssa.neg' class-attribute instance-attribute

SqrtOp dataclass

Bases: UnaryNumericalOperation[WasmFPType]

Compute the square root of a floating-point value.

Source code in xdsl/dialects/wasmssa.py
631
632
633
634
635
@irdl_op_definition
class SqrtOp(UnaryNumericalOperation[WasmFPType]):
    """Compute the square root of a floating-point value."""

    name = "wasmssa.sqrt"

name = 'wasmssa.sqrt' class-attribute instance-attribute

TruncOp dataclass

Bases: UnaryNumericalOperation[WasmFPType]

Round a floating-point value toward zero.

Source code in xdsl/dialects/wasmssa.py
638
639
640
641
642
@irdl_op_definition
class TruncOp(UnaryNumericalOperation[WasmFPType]):
    """Round a floating-point value toward zero."""

    name = "wasmssa.trunc"

name = 'wasmssa.trunc' class-attribute instance-attribute

ClzOp dataclass

Bases: UnaryNumericalOperation[WasmIntegerType]

Count leading zeroes in an integer value.

Source code in xdsl/dialects/wasmssa.py
645
646
647
648
649
@irdl_op_definition
class ClzOp(UnaryNumericalOperation[WasmIntegerType]):
    """Count leading zeroes in an integer value."""

    name = "wasmssa.clz"

name = 'wasmssa.clz' class-attribute instance-attribute

CtzOp dataclass

Bases: UnaryNumericalOperation[WasmIntegerType]

Count trailing zeroes in an integer value.

Source code in xdsl/dialects/wasmssa.py
652
653
654
655
656
@irdl_op_definition
class CtzOp(UnaryNumericalOperation[WasmIntegerType]):
    """Count trailing zeroes in an integer value."""

    name = "wasmssa.ctz"

name = 'wasmssa.ctz' class-attribute instance-attribute

PopCntOp dataclass

Bases: UnaryNumericalOperation[WasmIntegerType]

Count set bits in an integer value.

Source code in xdsl/dialects/wasmssa.py
659
660
661
662
663
@irdl_op_definition
class PopCntOp(UnaryNumericalOperation[WasmIntegerType]):
    """Count set bits in an integer value."""

    name = "wasmssa.popcnt"

name = 'wasmssa.popcnt' class-attribute instance-attribute

ConversionOperation

Bases: IRDLOperation, ABC, Generic[_NumericTypeInvT, _NumericResultTypeInvT]

Base class for WebAssembly conversion operations.

Source code in xdsl/dialects/wasmssa.py
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
class ConversionOperation(
    IRDLOperation,
    ABC,
    Generic[_NumericTypeInvT, _NumericResultTypeInvT],
):
    """Base class for WebAssembly conversion operations."""

    input = operand_def(irdl_to_attr_constraint(_NumericTypeInvT, allow_type_var=True))
    result = result_def(
        irdl_to_attr_constraint(_NumericResultTypeInvT, allow_type_var=True)
    )

    assembly_format = "$input `:` type($input) `to` type($result) attr-dict"

    def __init__(
        self,
        input: SSAValue | Operation,
        result_type: NumericType,
    ):
        super().__init__(operands=[input], result_types=[result_type])

input = operand_def(irdl_to_attr_constraint(_NumericTypeInvT, allow_type_var=True)) class-attribute instance-attribute

result = result_def(irdl_to_attr_constraint(_NumericResultTypeInvT, allow_type_var=True)) class-attribute instance-attribute

assembly_format = '$input `:` type($input) `to` type($result) attr-dict' class-attribute instance-attribute

__init__(input: SSAValue | Operation, result_type: NumericType)

Source code in xdsl/dialects/wasmssa.py
680
681
682
683
684
685
def __init__(
    self,
    input: SSAValue | Operation,
    result_type: NumericType,
):
    super().__init__(operands=[input], result_types=[result_type])

ConvertUOp dataclass

Bases: ConversionOperation[WasmIntegerType, WasmFPType]

Convert an unsigned integer value to a floating-point value.

Source code in xdsl/dialects/wasmssa.py
688
689
690
691
692
693
694
@irdl_op_definition
class ConvertUOp(ConversionOperation[WasmIntegerType, WasmFPType]):
    """Convert an unsigned integer value to a floating-point value."""

    name = "wasmssa.convert_u"

    traits = traits_def(Pure())

name = 'wasmssa.convert_u' class-attribute instance-attribute

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

ConvertSOp dataclass

Bases: ConversionOperation[WasmIntegerType, WasmFPType]

Convert a signed integer value to a floating-point value.

Source code in xdsl/dialects/wasmssa.py
697
698
699
700
701
702
703
@irdl_op_definition
class ConvertSOp(ConversionOperation[WasmIntegerType, WasmFPType]):
    """Convert a signed integer value to a floating-point value."""

    name = "wasmssa.convert_s"

    traits = traits_def(Pure())

name = 'wasmssa.convert_s' class-attribute instance-attribute

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

DemoteOp dataclass

Bases: ConversionOperation[Float64Type, Float32Type]

Convert an f64 value to f32.

Source code in xdsl/dialects/wasmssa.py
706
707
708
709
710
711
712
@irdl_op_definition
class DemoteOp(ConversionOperation[Float64Type, Float32Type]):
    """Convert an f64 value to f32."""

    name = "wasmssa.demote"

    traits = traits_def(Pure())

name = 'wasmssa.demote' class-attribute instance-attribute

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

ExtendSI32Op

Bases: IRDLOperation

Sign-extend an i32 value to i64.

Source code in xdsl/dialects/wasmssa.py
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
@irdl_op_definition
class ExtendSI32Op(IRDLOperation):
    """Sign-extend an i32 value to i64."""

    name = "wasmssa.extend_i32_s"

    input = operand_def(I32)
    result = result_def(I64)

    traits = traits_def(Pure())

    assembly_format = "$input `to` type($result) attr-dict"

    def __init__(self, input: SSAValue | Operation):
        super().__init__(operands=[input], result_types=[i64])

name = 'wasmssa.extend_i32_s' class-attribute instance-attribute

input = operand_def(I32) class-attribute instance-attribute

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

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

assembly_format = '$input `to` type($result) attr-dict' class-attribute instance-attribute

__init__(input: SSAValue | Operation)

Source code in xdsl/dialects/wasmssa.py
728
729
def __init__(self, input: SSAValue | Operation):
    super().__init__(operands=[input], result_types=[i64])

ExtendUI32Op

Bases: IRDLOperation

Zero-extend an i32 value to i64.

Source code in xdsl/dialects/wasmssa.py
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
@irdl_op_definition
class ExtendUI32Op(IRDLOperation):
    """Zero-extend an i32 value to i64."""

    name = "wasmssa.extend_i32_u"

    input = operand_def(I32)
    result = result_def(I64)

    traits = traits_def(Pure())

    assembly_format = "$input `to` type($result) attr-dict"

    def __init__(self, input: SSAValue | Operation):
        super().__init__(operands=[input], result_types=[i64])

name = 'wasmssa.extend_i32_u' class-attribute instance-attribute

input = operand_def(I32) class-attribute instance-attribute

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

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

assembly_format = '$input `to` type($result) attr-dict' class-attribute instance-attribute

__init__(input: SSAValue | Operation)

Source code in xdsl/dialects/wasmssa.py
745
746
def __init__(self, input: SSAValue | Operation):
    super().__init__(operands=[input], result_types=[i64])

ExtendLowBitsSOp

Bases: IRDLOperation

Sign-extend the low bits of an integer value to its full width.

Source code in xdsl/dialects/wasmssa.py
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
@irdl_op_definition
class ExtendLowBitsSOp(IRDLOperation):
    """Sign-extend the low bits of an integer value to its full width."""

    name = "wasmssa.extend"

    T: ClassVar = VarConstraint.get("T", WasmIntegerType)

    input = operand_def(T)
    bitsToTake = prop_def(IntegerAttr)
    result = result_def(T)

    traits = traits_def(Pure())

    assembly_format = (
        "$bitsToTake `low` `bits` `from` $input `:` type($input) attr-dict"
    )

    def __init__(
        self,
        input: SSAValue | Operation,
        bits_to_take: int | IntegerAttr,
    ):
        input = SSAValue.get(input)
        if isinstance(bits_to_take, int):
            bits_to_take = IntegerAttr(bits_to_take, i64)
        super().__init__(
            operands=[input],
            result_types=[input.type],
            properties={"bitsToTake": bits_to_take},
        )

    def verify_(self) -> None:
        bits_to_take = self.bitsToTake.value.data
        if bits_to_take not in (8, 16, 32):
            raise VerifyException(
                f"extend op can only take 8, 16 or 32 bits. Got {bits_to_take}"
            )

        input_type = self.input.type
        assert isinstance(input_type, IntegerType)
        if bits_to_take >= input_type.bitwidth:
            raise VerifyException(
                f"trying to extend the {bits_to_take} low bits from a "
                f"{input_type} value is illegal"
            )

name = 'wasmssa.extend' class-attribute instance-attribute

T: ClassVar = VarConstraint.get('T', WasmIntegerType) class-attribute instance-attribute

input = operand_def(T) class-attribute instance-attribute

bitsToTake = prop_def(IntegerAttr) class-attribute instance-attribute

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

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

assembly_format = '$bitsToTake `low` `bits` `from` $input `:` type($input) attr-dict' class-attribute instance-attribute

__init__(input: SSAValue | Operation, bits_to_take: int | IntegerAttr)

Source code in xdsl/dialects/wasmssa.py
767
768
769
770
771
772
773
774
775
776
777
778
779
def __init__(
    self,
    input: SSAValue | Operation,
    bits_to_take: int | IntegerAttr,
):
    input = SSAValue.get(input)
    if isinstance(bits_to_take, int):
        bits_to_take = IntegerAttr(bits_to_take, i64)
    super().__init__(
        operands=[input],
        result_types=[input.type],
        properties={"bitsToTake": bits_to_take},
    )

verify_() -> None

Source code in xdsl/dialects/wasmssa.py
781
782
783
784
785
786
787
788
789
790
791
792
793
794
def verify_(self) -> None:
    bits_to_take = self.bitsToTake.value.data
    if bits_to_take not in (8, 16, 32):
        raise VerifyException(
            f"extend op can only take 8, 16 or 32 bits. Got {bits_to_take}"
        )

    input_type = self.input.type
    assert isinstance(input_type, IntegerType)
    if bits_to_take >= input_type.bitwidth:
        raise VerifyException(
            f"trying to extend the {bits_to_take} low bits from a "
            f"{input_type} value is illegal"
        )

PromoteOp dataclass

Bases: ConversionOperation[Float32Type, Float64Type]

Convert an f32 value to f64.

Source code in xdsl/dialects/wasmssa.py
797
798
799
800
801
802
803
@irdl_op_definition
class PromoteOp(ConversionOperation[Float32Type, Float64Type]):
    """Convert an f32 value to f64."""

    name = "wasmssa.promote"

    traits = traits_def(Pure())

name = 'wasmssa.promote' class-attribute instance-attribute

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

WrapOp dataclass

Bases: ConversionOperation[I64, I32]

Wrap an i64 value to i32.

Source code in xdsl/dialects/wasmssa.py
806
807
808
809
810
811
812
@irdl_op_definition
class WrapOp(ConversionOperation[I64, I32]):
    """Wrap an i64 value to i32."""

    name = "wasmssa.wrap"

    traits = traits_def(Pure())

name = 'wasmssa.wrap' class-attribute instance-attribute

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

ReinterpretOp dataclass

Bases: ConversionOperation

Reinterpret a numeric value as a different type of the same bit width.

Source code in xdsl/dialects/wasmssa.py
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
@irdl_op_definition
class ReinterpretOp(ConversionOperation):
    """Reinterpret a numeric value as a different type of the same bit width."""

    name = "wasmssa.reinterpret"

    traits = traits_def(Pure())

    assembly_format = "$input `:` type($input) `as` type($result) attr-dict"

    def verify_(self) -> None:
        input_type = cast(NumericType, self.input.type)
        result_type = cast(NumericType, self.result.type)
        if input_type == result_type:
            raise VerifyException(
                "reinterpret input and output type should be distinct"
            )
        if input_type.bitwidth != result_type.bitwidth:
            raise VerifyException(
                f"input type ({input_type}) and output type ({result_type}) "
                "have incompatible bit widths"
            )

name = 'wasmssa.reinterpret' class-attribute instance-attribute

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

assembly_format = '$input `:` type($input) `as` type($result) attr-dict' class-attribute instance-attribute

verify_() -> None

Source code in xdsl/dialects/wasmssa.py
825
826
827
828
829
830
831
832
833
834
835
836
def verify_(self) -> None:
    input_type = cast(NumericType, self.input.type)
    result_type = cast(NumericType, self.result.type)
    if input_type == result_type:
        raise VerifyException(
            "reinterpret input and output type should be distinct"
        )
    if input_type.bitwidth != result_type.bitwidth:
        raise VerifyException(
            f"input type ({input_type}) and output type ({result_type}) "
            "have incompatible bit widths"
        )