Bases: RISCVCustomFormatOperation, RISCVInstruction, HasFolderInterface, ABC
Loads a 64-bit immediate into rd.
This is an assembler pseudo-instruction.
See external documentation.
Source code in xdsl/dialects/rv64.py
43
44
45
46
47
48
49
50
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109 | @irdl_op_definition
class LiOp(RISCVCustomFormatOperation, RISCVInstruction, HasFolderInterface, ABC):
"""
Loads a 64-bit immediate into rd.
This is an assembler pseudo-instruction.
See external [documentation](https://github.com/riscv-non-isa/riscv-asm-manual/blob/main/src/asm-manual.adoc).
"""
name = "rv64.li"
rd = result_def(IntRegisterType)
immediate = attr_def(IntegerAttr[I64] | LabelAttr)
traits = traits_def(LiOpHasCanonicalizationPatternTrait(), ConstantLike())
def __init__(
self,
immediate: int | IntegerAttr[I64] | str | LabelAttr,
*,
rd: IntRegisterType = Registers.UNALLOCATED_INT,
comment: str | StringAttr | None = None,
):
if isinstance(immediate, int):
immediate = IntegerAttr(immediate, i64)
elif isinstance(immediate, str):
immediate = LabelAttr(immediate)
if isinstance(comment, str):
comment = StringAttr(comment)
super().__init__(
result_types=[rd],
attributes={
"immediate": immediate,
"comment": comment,
},
)
def assembly_line_args(self) -> tuple[AssemblyInstructionArg, ...]:
return self.rd, self.immediate
def fold(self) -> tuple[IntegerAttr[I64] | LabelAttr]:
return (self.immediate,)
@classmethod
def custom_parse_attributes(cls, parser: Parser) -> dict[str, Attribute]:
attributes = dict[str, Attribute]()
attributes["immediate"] = parse_immediate_value(parser, i64)
return attributes
def custom_print_attributes(self, printer: Printer) -> AbstractSet[str]:
printer.print_string(" ")
print_immediate_value(printer, self.immediate)
return {"immediate", "fastmath"}
@classmethod
def parse_op_type(
cls, parser: Parser
) -> tuple[Sequence[Attribute], Sequence[Attribute]]:
parser.parse_punctuation(":")
res_type = parser.parse_attribute()
return (), (res_type,)
def print_op_type(self, printer: Printer) -> None:
printer.print_string(" : ")
printer.print_attribute(self.rd.type)
|
name = 'rv64.li'
class-attribute
instance-attribute
rd = result_def(IntRegisterType)
class-attribute
instance-attribute
traits = traits_def(LiOpHasCanonicalizationPatternTrait(), ConstantLike())
class-attribute
instance-attribute
__init__(immediate: int | IntegerAttr[I64] | str | LabelAttr, *, rd: IntRegisterType = Registers.UNALLOCATED_INT, comment: str | StringAttr | None = None)
Source code in xdsl/dialects/rv64.py
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80 | def __init__(
self,
immediate: int | IntegerAttr[I64] | str | LabelAttr,
*,
rd: IntRegisterType = Registers.UNALLOCATED_INT,
comment: str | StringAttr | None = None,
):
if isinstance(immediate, int):
immediate = IntegerAttr(immediate, i64)
elif isinstance(immediate, str):
immediate = LabelAttr(immediate)
if isinstance(comment, str):
comment = StringAttr(comment)
super().__init__(
result_types=[rd],
attributes={
"immediate": immediate,
"comment": comment,
},
)
|
assembly_line_args() -> tuple[AssemblyInstructionArg, ...]
Source code in xdsl/dialects/rv64.py
| def assembly_line_args(self) -> tuple[AssemblyInstructionArg, ...]:
return self.rd, self.immediate
|
fold() -> tuple[IntegerAttr[I64] | LabelAttr]
Source code in xdsl/dialects/rv64.py
| def fold(self) -> tuple[IntegerAttr[I64] | LabelAttr]:
return (self.immediate,)
|
custom_parse_attributes(parser: Parser) -> dict[str, Attribute]
classmethod
Source code in xdsl/dialects/rv64.py
| @classmethod
def custom_parse_attributes(cls, parser: Parser) -> dict[str, Attribute]:
attributes = dict[str, Attribute]()
attributes["immediate"] = parse_immediate_value(parser, i64)
return attributes
|
custom_print_attributes(printer: Printer) -> AbstractSet[str]
Source code in xdsl/dialects/rv64.py
| def custom_print_attributes(self, printer: Printer) -> AbstractSet[str]:
printer.print_string(" ")
print_immediate_value(printer, self.immediate)
return {"immediate", "fastmath"}
|
parse_op_type(parser: Parser) -> tuple[Sequence[Attribute], Sequence[Attribute]]
classmethod
Source code in xdsl/dialects/rv64.py
99
100
101
102
103
104
105 | @classmethod
def parse_op_type(
cls, parser: Parser
) -> tuple[Sequence[Attribute], Sequence[Attribute]]:
parser.parse_punctuation(":")
res_type = parser.parse_attribute()
return (), (res_type,)
|
print_op_type(printer: Printer) -> None
Source code in xdsl/dialects/rv64.py
| def print_op_type(self, printer: Printer) -> None:
printer.print_string(" : ")
printer.print_attribute(self.rd.type)
|