ml_switcheroo.core.mlir.emitter =============================== .. py:module:: ml_switcheroo.core.mlir.emitter .. autoapi-nested-parse:: MLIR Emitter Logic. This module provides the `PythonToMlirEmitter`, a compiler front-end that transforms Python LibCST trees into the MLIR CST object model. Classes ------- .. autoapisummary:: ml_switcheroo.core.mlir.emitter.SSAContext ml_switcheroo.core.mlir.emitter.PythonToMlirEmitter Module Contents --------------- .. py:class:: SSAContext Manages Single Static Assignment (SSA) variable scopes and ID allocation. .. py:method:: enter_scope() -> None Push a new variable scope onto the stack. .. py:method:: exit_scope() -> None Pop the current variable scope from the stack. .. py:method:: declare(name: str, value: ml_switcheroo.core.mlir.nodes.ValueNode) -> None Register a variable name in the current scope. :param name: The Python variable identifier. :param value: The MLIR ValueNode (SSA value) associated with it. .. py:method:: lookup(name: str) -> Optional[ml_switcheroo.core.mlir.nodes.ValueNode] Resolve a Python variable name to its current SSA value. Searches scopes from innermost to outermost. :param name: The Python identifier to look up. :returns: The associated ValueNode or None if not found. .. py:method:: allocate_ssa(prefix: str = '%') -> ml_switcheroo.core.mlir.nodes.ValueNode Generates a new unique SSA value. :param prefix: String prefix for the ID (default "%"). :returns: A new ValueNode with a unique ID (e.g. "%0", "%1"). .. py:class:: PythonToMlirEmitter Translates Python LibCST modules into MLIR structural nodes. .. py:attribute:: ctx .. py:method:: convert(node: libcst.Module) -> ml_switcheroo.core.mlir.nodes.ModuleNode Entry point: Converts a CST Module to an MLIR ModuleNode. :param node: The Python LibCST Module. :returns: The resulting MLIR ModuleNode containing the translated operations.