ml_switcheroo.compiler.frontends.sass.nodes¶
SASS AST Nodes.
Defines the data structures for the NVIDIA SASS syntax tree. Each node corresponds to a syntactic element in SASS assembly and implements __str__ to emit valid code.
Classes¶
Abstract base class for all SASS AST nodes. |
|
Base class for instruction operands (Registers, Immediates, etc.). |
|
Represents a general-purpose register (e.g., R0, RZ). |
|
Represents a predicate register (e.g., @P0, !P1). |
|
Represents a literal constant value. |
|
Represents a memory address operand. |
|
Represents a single SASS operation line. |
|
Represents a jump target label. |
|
Represents an assembler directive. |
|
Represents a line comment. |
Module Contents¶
- class ml_switcheroo.compiler.frontends.sass.nodes.SassNode[source]¶
Bases:
abc.ABCAbstract base class for all SASS AST nodes.
- class ml_switcheroo.compiler.frontends.sass.nodes.Operand[source]¶
Bases:
SassNodeBase class for instruction operands (Registers, Immediates, etc.).
- class ml_switcheroo.compiler.frontends.sass.nodes.Register[source]¶
Bases:
OperandRepresents a general-purpose register (e.g., R0, RZ).
- name¶
The register identifier (e.g., “R0”, “RZ”).
- Type:
str
- negated¶
If True, prepends a negation sign (e.g., “-R0”).
- name: str¶
- negated: bool = False¶
- absolute: bool = False¶
- class ml_switcheroo.compiler.frontends.sass.nodes.Predicate[source]¶
Bases:
OperandRepresents a predicate register (e.g., @P0, !P1).
Used both as instruction guards (preceding the opcode) and as operands in logical instructions (ISETP).
- name¶
The predicate identifier (e.g., “P0”, “PT”).
- Type:
str
- negated¶
If True, indicates logical NOT (e.g., “!P0”).
- Type:
bool
- name: str¶
- negated: bool = False¶
- class ml_switcheroo.compiler.frontends.sass.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., “0x1”).
- Type:
bool
- value: int | float¶
- is_hex: bool = False¶
- class ml_switcheroo.compiler.frontends.sass.nodes.Memory[source]¶
Bases:
OperandRepresents a memory address operand.
Supports Constant Bank access (e.g., c[0x0][0x4]) and Global/Local addressing (e.g., [R1], [R1 + 0x4]).
- base¶
The base register (e.g., “R1”) or constant bank string (e.g., “c[0x0]”).
- Type:
Union[str, Register]
- offset¶
Optional byte offset to add to the base.
- Type:
Optional[int]
- offset: int | None = None¶
- class ml_switcheroo.compiler.frontends.sass.nodes.Instruction[source]¶
Bases:
SassNodeRepresents a single SASS operation line.
Format: @{predicate} {opcode} {operands};
- opcode¶
The instruction mnemonic (e.g., “FADD”, “MOV”).
- Type:
str
- opcode: str¶
- class ml_switcheroo.compiler.frontends.sass.nodes.Label[source]¶
Bases:
SassNodeRepresents a jump target label.
Format: {name}:
- name¶
The label identifier.
- Type:
str
- name: str¶