ml_switcheroo.core.mlir.nodes ============================= .. py:module:: ml_switcheroo.core.mlir.nodes .. autoapi-nested-parse:: MLIR Concrete Syntax Tree Nodes. This module defines the data structures for representing MLIR source code. It ensures structural hierarchy (Module -> Operation -> Region -> Block) and trivia preservation for high-fidelity round-tripping. Classes ------- .. autoapisummary:: ml_switcheroo.core.mlir.nodes.MlirNode ml_switcheroo.core.mlir.nodes.TriviaNode ml_switcheroo.core.mlir.nodes.ValueNode ml_switcheroo.core.mlir.nodes.TypeNode ml_switcheroo.core.mlir.nodes.AttributeNode ml_switcheroo.core.mlir.nodes.BlockNode ml_switcheroo.core.mlir.nodes.RegionNode ml_switcheroo.core.mlir.nodes.OperationNode ml_switcheroo.core.mlir.nodes.ModuleNode Module Contents --------------- .. py:class:: MlirNode Bases: :py:obj:`abc.ABC` Abstract base class for all MLIR CST nodes. .. py:method:: to_text() -> str :abstractmethod: Return the textual MLIR representation of this node. .. py:class:: TriviaNode Bases: :py:obj:`MlirNode` Represents non-semantic tokens (whitespace, comments). .. py:attribute:: content :type: str .. py:attribute:: kind :type: str :value: 'whitespace' .. py:method:: to_text() -> str Return the trivia content verbatim. .. py:class:: ValueNode Bases: :py:obj:`MlirNode` Represents an SSA Value identifier (e.g. %0). .. py:attribute:: name :type: str .. py:method:: to_text() -> str Return the SSA identifier. .. py:class:: TypeNode Bases: :py:obj:`MlirNode` Represents a type annotation. .. py:attribute:: body :type: str .. py:method:: to_text() -> str Return the type string. .. py:class:: AttributeNode Bases: :py:obj:`MlirNode` Represents a named attribute. Value can be a string literal or a list of string literals (e.g. for bases). .. py:attribute:: name :type: str .. py:attribute:: value :type: Union[str, List[str]] .. py:attribute:: type_annotation :type: Optional[str] :value: None .. py:method:: to_text() -> str Return 'key = value' string format. .. py:class:: BlockNode Bases: :py:obj:`MlirNode` Represents a Basic Block within a Region. .. py:attribute:: label :type: str .. py:attribute:: operations :type: List[OperationNode] :value: [] .. py:attribute:: arguments :type: List[Tuple[ValueNode, TypeNode]] :value: [] .. py:attribute:: leading_trivia :type: List[TriviaNode] :value: [] .. py:method:: to_text() -> str Formats the block including label, arguments, and operations. .. py:class:: RegionNode Bases: :py:obj:`MlirNode` Represents a Region containing Blocks. .. py:attribute:: blocks :type: List[BlockNode] :value: [] .. py:method:: to_text() -> str Formats the region enclosed in braces. .. py:class:: OperationNode Bases: :py:obj:`MlirNode` Represents a specific MLIR Operation. .. py:attribute:: name :type: str .. py:attribute:: results :type: List[ValueNode] :value: [] .. py:attribute:: operands :type: List[ValueNode] :value: [] .. py:attribute:: attributes :type: List[AttributeNode] :value: [] .. py:attribute:: regions :type: List[RegionNode] :value: [] .. py:attribute:: result_types :type: List[TypeNode] :value: [] .. py:attribute:: leading_trivia :type: List[TriviaNode] :value: [] .. py:attribute:: name_trivia :type: List[TriviaNode] :value: [] .. py:attribute:: trailing_trivia :type: List[TriviaNode] :value: [] .. py:method:: to_text() -> str Formats the operation string following MLIR syntax rules. .. py:class:: ModuleNode Bases: :py:obj:`MlirNode` Top-level container. .. py:attribute:: body :type: BlockNode .. py:method:: to_text() -> str Return module body text.