Skip to content

Wasmssa

wasmssa

RefType: TypeAlias = FuncRefType | ExternRefType module-attribute

Type alias for opaque references in WebAssembly

ValType: TypeAlias = I32 | I64 | I128 | Float32Type | Float64Type | FuncRefType | ExternRefType module-attribute

Type alias for value types that are supported by WebAssembly

WasmSSA = Dialect('wasmssa', [], [ExternRefType, FuncRefType, LimitType, LocalRefType, TableType]) module-attribute

FuncRefType dataclass

Bases: ParametrizedAttribute, TypeAttribute

Opaque type for function reference

Source code in xdsl/dialects/wasmssa.py
25
26
27
28
29
30
31
@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
34
35
36
37
38
39
40
@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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
@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
64
65
66
67
68
69
70
@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
72
73
74
75
76
77
78
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
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
@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
93
94
95
96
97
98
@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
100
101
102
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
@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
118
119
120
121
122
123
@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
125
126
127
128
def print_parameters(self, printer: Printer) -> None:
    printer.print_attribute(self.reference)
    printer.print_string(" ")
    self.limit.print_parameters(printer)