ml_switcheroo.compiler.backends.rdna.synthesizerΒΆ
RDNA Synthesizer and Registry Backend.
This module provides the βMiddle-Endβ logic for the RDNA compiler pipeline. It bridges the gap between high-level Abstract Logic (LogicalGraphs) and low-level Physical Assembly (Instruction nodes/Registers).
It contains: 1. RegisterAllocator: A dual-pool allocator managing Scalar (SGPR) and
Vector (VGPR) register files independently.
RdnaSynthesizer: - Target Transformation (`from_graph`): Converts topological logical graphs
into a linear list of RDNA instructions.
Source Transformation (`to_python`): Converts RDNA AST nodes back into Python LibCST nodes for high-level analysis or documentation.
RdnaBackend: The CompilerBackend adapter for the Registry, including header generation.
AttributesΒΆ
ClassesΒΆ
Manages the mapping between symbolic variable names and physical registers. |
|
Bidirectional transpiler component for RDNA ISA. |
|
Compiler Backend implementation for AMD RDNA. |
Module ContentsΒΆ
- ml_switcheroo.compiler.backends.rdna.synthesizer.MAX_VGPR = 256ΒΆ
- ml_switcheroo.compiler.backends.rdna.synthesizer.MAX_SGPR = 106ΒΆ
- class ml_switcheroo.compiler.backends.rdna.synthesizer.RegisterAllocator[source]ΒΆ
Manages the mapping between symbolic variable names and physical registers. Maintains separate accounting for Scalar (SGPR) and Vector (VGPR) files.
- get_vector_register(var_name: str) ml_switcheroo.compiler.frontends.rdna.nodes.VGPR[source]ΒΆ
Retrieves or allocates a Vector register (VGPR) for a symbolic variable.
- get_scalar_register(var_name: str) ml_switcheroo.compiler.frontends.rdna.nodes.SGPR[source]ΒΆ
Retrieves or allocates a Scalar register (SGPR) for a symbolic variable.
- allocate_vector_temp() ml_switcheroo.compiler.frontends.rdna.nodes.VGPR[source]ΒΆ
Allocates an anonymous temporary VGPR.
- allocate_scalar_temp() ml_switcheroo.compiler.frontends.rdna.nodes.SGPR[source]ΒΆ
Allocates an anonymous temporary SGPR.
- class ml_switcheroo.compiler.backends.rdna.synthesizer.RdnaSynthesizer(semantics: ml_switcheroo.semantics.manager.SemanticsManager)[source]ΒΆ
Bidirectional transpiler component for RDNA ISA.
- semanticsΒΆ
- allocatorΒΆ
- macro_registry: Dict[str, Callable]ΒΆ
- from_graph(graph: ml_switcheroo.compiler.ir.LogicalGraph) List[ml_switcheroo.compiler.frontends.rdna.nodes.RdnaNode][source]ΒΆ
Converts a LogicalGraph into a list of RDNA AST nodes.
- to_python(rdna_nodes: List[ml_switcheroo.compiler.frontends.rdna.nodes.RdnaNode]) libcst.Module[source]ΒΆ
Converts RDNA AST nodes into a Python source structure representation.
- class ml_switcheroo.compiler.backends.rdna.synthesizer.RdnaBackend(semantics: ml_switcheroo.semantics.manager.SemanticsManager | None = None)[source]ΒΆ
Bases:
ml_switcheroo.compiler.backend.CompilerBackendCompiler Backend implementation for AMD RDNA. Orchestrates the synthesis (Graph -> AST) and emission (AST -> Text).
- synthesizerΒΆ
- emitterΒΆ
- target_arch = 'gfx1030'ΒΆ
- compile(graph: ml_switcheroo.compiler.ir.LogicalGraph) str[source]ΒΆ
Compiles LogicalGraph to RDNA Assembly string.
- Parameters:
graph β The intermediate representation.
- Returns:
The RDNA code.
- Return type:
str