Skip to content

Attrs

attrs

UI5: TypeAlias = IntegerType[Literal[5], Literal[Signedness.UNSIGNED]] module-attribute

SI20: TypeAlias = IntegerType[Literal[20], Literal[Signedness.SIGNED]] module-attribute

SI12: TypeAlias = IntegerType[Literal[12], Literal[Signedness.SIGNED]] module-attribute

I12: TypeAlias = IntegerType[Literal[12], Literal[Signedness.SIGNLESS]] module-attribute

I20: TypeAlias = IntegerType[Literal[20], Literal[Signedness.SIGNLESS]] module-attribute

ui5: UI5 = IntegerType(5, Signedness.UNSIGNED) module-attribute

si20: SI20 = IntegerType(20, Signedness.SIGNED) module-attribute

si12: SI12 = IntegerType(12, Signedness.SIGNED) module-attribute

i12: I12 = IntegerType(12, Signedness.SIGNLESS) module-attribute

i20: I20 = IntegerType(20, Signedness.SIGNLESS) module-attribute

FastMathFlagsAttr

Bases: FastMathAttrBase

riscv.fastmath is a mirror of LLVMs fastmath flags.

Source code in xdsl/dialects/riscv/attrs.py
15
16
17
18
19
20
21
22
23
24
25
26
@irdl_attr_definition
class FastMathFlagsAttr(FastMathAttrBase):
    """
    riscv.fastmath is a mirror of LLVMs fastmath flags.
    """

    name = "riscv.fastmath"

    def __init__(self, flags: None | Sequence[FastMathFlag] | Literal["none", "fast"]):
        # irdl_attr_definition defines an __init__ if none is defined, so we need to
        # explicitely define one here.
        super().__init__(flags)

name = 'riscv.fastmath' class-attribute instance-attribute

__init__(flags: None | Sequence[FastMathFlag] | Literal['none', 'fast'])

Source code in xdsl/dialects/riscv/attrs.py
23
24
25
26
def __init__(self, flags: None | Sequence[FastMathFlag] | Literal["none", "fast"]):
    # irdl_attr_definition defines an __init__ if none is defined, so we need to
    # explicitely define one here.
    super().__init__(flags)

LabelAttr dataclass

Bases: Data[str]

Source code in xdsl/dialects/riscv/attrs.py
41
42
43
44
45
46
47
48
49
50
51
52
@irdl_attr_definition
class LabelAttr(Data[str]):
    name = "riscv.label"

    @classmethod
    def parse_parameter(cls, parser: AttrParser) -> str:
        with parser.in_angle_brackets():
            return parser.parse_str_literal()

    def print_parameter(self, printer: Printer) -> None:
        with printer.in_angle_brackets():
            printer.print_string_literal(self.data)

name = 'riscv.label' class-attribute instance-attribute

parse_parameter(parser: AttrParser) -> str classmethod

Source code in xdsl/dialects/riscv/attrs.py
45
46
47
48
@classmethod
def parse_parameter(cls, parser: AttrParser) -> str:
    with parser.in_angle_brackets():
        return parser.parse_str_literal()

print_parameter(printer: Printer) -> None

Source code in xdsl/dialects/riscv/attrs.py
50
51
52
def print_parameter(self, printer: Printer) -> None:
    with printer.in_angle_brackets():
        printer.print_string_literal(self.data)

parse_immediate_value(parser: AttrParser, integer_type: IntegerType | IndexType) -> IntegerAttr[IntegerType | IndexType] | LabelAttr

Source code in xdsl/dialects/riscv/attrs.py
71
72
73
74
75
76
77
def parse_immediate_value(
    parser: AttrParser, integer_type: IntegerType | IndexType
) -> IntegerAttr[IntegerType | IndexType] | LabelAttr:
    return parser.expect(
        lambda: _parse_optional_immediate_value(parser, integer_type),
        "Expected immediate",
    )

print_immediate_value(printer: Printer, immediate: IntegerAttr | LabelAttr)

Source code in xdsl/dialects/riscv/attrs.py
80
81
82
83
84
85
def print_immediate_value(printer: Printer, immediate: IntegerAttr | LabelAttr):
    match immediate:
        case IntegerAttr():
            immediate.print_without_type(printer)
        case LabelAttr():
            printer.print_string_literal(immediate.data)