ml_switcheroo.compiler.frontends.rdna.nodesΒΆ
RDNA AST Nodes.
Defines the data structures for the AMD RDNA / GCN syntax tree. Each node corresponds to a syntactic element in RDNA assembly and implements __str__ to emit valid assembly code.
ClassesΒΆ
Abstract base class for all RDNA AST nodes. |
|
Base class for instruction operands (Registers, Immediates, etc.). |
|
Represents a reference to a label (e.g. as a jump target) or generic identifier operand. |
|
Represents a Scalar General Purpose Register (e.g., s0, s10). |
|
Represents a Vector General Purpose Register (e.g., v0, v255). |
|
Represents a literal constant value. |
|
Represents an instruction modifier or attribute. |
|
Represents a memory address operand, typically used in generic loads/stores. |
|
Represents a single RDNA operation line. |
|
Represents a jump target label. |
|
Represents an assembler directive. |
|
Represents a line comment. |
FunctionsΒΆ
|
Helper to create a single SGPR. |
|
Helper to create a single VGPR. |
Module ContentsΒΆ
- class ml_switcheroo.compiler.frontends.rdna.nodes.RdnaNode[source]ΒΆ
Bases:
abc.ABCAbstract base class for all RDNA AST nodes.
- class ml_switcheroo.compiler.frontends.rdna.nodes.Operand[source]ΒΆ
Bases:
RdnaNodeBase class for instruction operands (Registers, Immediates, etc.).
- class ml_switcheroo.compiler.frontends.rdna.nodes.LabelRef[source]ΒΆ
Bases:
OperandRepresents a reference to a label (e.g. as a jump target) or generic identifier operand.
- nameΒΆ
The label identifier.
- Type:
str
- name: strΒΆ
- class ml_switcheroo.compiler.frontends.rdna.nodes.SGPR[source]ΒΆ
Bases:
OperandRepresents a Scalar General Purpose Register (e.g., s0, s10).
- indexΒΆ
The register index.
- Type:
int
- countΒΆ
If > 1, represents a range/multi-register (e.g., s[0:3]).
- Type:
int
- index: intΒΆ
- count: int = 1ΒΆ
- class ml_switcheroo.compiler.frontends.rdna.nodes.VGPR[source]ΒΆ
Bases:
OperandRepresents a Vector General Purpose Register (e.g., v0, v255).
- indexΒΆ
The register index.
- Type:
int
- countΒΆ
If > 1, represents a range/multi-register (e.g., v[0:3]).
- Type:
int
- index: intΒΆ
- count: int = 1ΒΆ
- ml_switcheroo.compiler.frontends.rdna.nodes.c_SGPR(idx: int) SGPR[source]ΒΆ
Helper to create a single SGPR.
- ml_switcheroo.compiler.frontends.rdna.nodes.c_VGPR(idx: int) VGPR[source]ΒΆ
Helper to create a single VGPR.
- class ml_switcheroo.compiler.frontends.rdna.nodes.Immediate[source]ΒΆ
Bases:
OperandRepresents a literal constant value.
- valueΒΆ
The numeric value.
- Type:
Union[int, float]
- is_hexΒΆ
If True, renders as hex string (e.g., 0xff).
- Type:
bool
- value: int | floatΒΆ
- is_hex: bool = FalseΒΆ
- class ml_switcheroo.compiler.frontends.rdna.nodes.Modifier[source]ΒΆ
Bases:
OperandRepresents an instruction modifier or attribute. e.g., glc, slc, off.
- nameΒΆ
The modifier string.
- Type:
str
- name: strΒΆ
- class ml_switcheroo.compiler.frontends.rdna.nodes.Memory[source]ΒΆ
Bases:
OperandRepresents a memory address operand, typically used in generic loads/stores. RDNA often passes the address as a register or register pair, but explicit offset syntax exists.
Format: method[base + offset] or simply register references depending on op. This node models the bracketed syntax global_load_dword v0, v[1:2], off. Usually, RDNA just uses registers as operands, but sometimes specific addressing notation is used. Here we treat it as an explicit container if needed, primarily for offsets.
- offsetΒΆ
Immediate byte offset.
- Type:
Optional[int]
- offset: int | None = NoneΒΆ
- class ml_switcheroo.compiler.frontends.rdna.nodes.Instruction[source]ΒΆ
Bases:
RdnaNodeRepresents a single RDNA operation line.
Format: {opcode} {operands} Modifiers are treated as operands in the list for flexible placement.
- opcodeΒΆ
The instruction mnemonic (e.g., βv_add_f32β, βs_mov_b32β).
- Type:
str
- opcode: strΒΆ
- class ml_switcheroo.compiler.frontends.rdna.nodes.Label[source]ΒΆ
Bases:
RdnaNodeRepresents a jump target label.
Format: {name}:
- nameΒΆ
The label identifier.
- Type:
str
- name: strΒΆ