nodes
AssemblyExpression
¶
Bases: AssemblyNode, ExpressionTerm
Assembly AST expression base class.
An assembly expression is a program node which evaluates to a value.
Source code in src/finch/finch_assembly/nodes.py
result_type
abstractmethod
property
¶
Returns the type of the expression.
AssemblyNode
¶
Bases: Term
AssemblyNode
Represents a FinchAssembly IR node. FinchAssembly is the final intermediate representation before code generation (translation to the output language). It is a low-level imperative description of the program, with control flow, linear memory regions called "buffers", and explicit memory management.
Source code in src/finch/finch_assembly/nodes.py
AssemblyStatement
¶
Bases: AssemblyNode
Assembly AST statement base class.
An assembly statement is a program node nested inside a function which does not produce a value, but may modify the state of the machine.
Source code in src/finch/finch_assembly/nodes.py
AssemblyTree
dataclass
¶
Bases: AssemblyNode, TermTree
Source code in src/finch/finch_assembly/nodes.py
children
property
¶
Returns the children of the node.
Assert
dataclass
¶
Bases: AssemblyTree, AssemblyStatement
Checks that an expression is true at runtime. Also used in dataflow analysis to record conditions in conditionals and loops.
Attributes:
| Name | Type | Description |
|---|---|---|
exp |
AssemblyExpression
|
Expression which is being asserted. |
Source code in src/finch/finch_assembly/nodes.py
children
property
¶
Returns the children of the node.
Assign
dataclass
¶
Bases: AssemblyTree, AssemblyStatement
Represents a logical AST statement that evaluates rhs, binding the result
to lhs.
Attributes:
| Name | Type | Description |
|---|---|---|
lhs |
Variable
|
The left-hand side of the binding. |
rhs |
AssemblyExpression
|
The right-hand side to evaluate. |
Source code in src/finch/finch_assembly/nodes.py
children
property
¶
Returns the children of the node.
Block
dataclass
¶
Bases: AssemblyTree, AssemblyStatement
Represents a statement that executes a sequence of statements bodies....
Attributes:
| Name | Type | Description |
|---|---|---|
bodies |
tuple[AssemblyStatement | AssemblyExpression, ...]
|
The sequence of statements to execute. |
Source code in src/finch/finch_assembly/nodes.py
children
property
¶
Returns the children of the node.
Break
dataclass
¶
Bases: AssemblyTree, AssemblyStatement
Represents a break statement that exits the current loop.
Source code in src/finch/finch_assembly/nodes.py
children
property
¶
Returns the children of the node.
BufferLoop
dataclass
¶
Bases: AssemblyTree, AssemblyStatement
Represents a loop that iterates over the elements of a buffer.
Attributes:
| Name | Type | Description |
|---|---|---|
buffer |
AssemblyExpression
|
The buffer to iterate over. |
var |
Variable
|
The loop variable for each element in the buffer. |
body |
AssemblyStatement
|
The body of the loop to execute for each element. |
Source code in src/finch/finch_assembly/nodes.py
children
property
¶
Returns the children of the node.
Call
dataclass
¶
Bases: AssemblyExpression, AssemblyTree, CallTerm
Represents an expression for calling the function op on args....
Attributes:
| Name | Type | Description |
|---|---|---|
op |
AssemblyExpression
|
The function to call. |
args |
tuple[AssemblyExpression, ...]
|
The arguments to call on the function. |
Source code in src/finch/finch_assembly/nodes.py
ForLoop
dataclass
¶
Bases: AssemblyTree, AssemblyStatement
Represents a for loop that iterates over a range of values.
Attributes:
| Name | Type | Description |
|---|---|---|
var |
Variable
|
The loop variable. |
start |
AssemblyExpression
|
The starting value of the range. |
end |
AssemblyExpression
|
The ending value of the range. |
body |
AssemblyStatement
|
The body of the loop to execute. |
Source code in src/finch/finch_assembly/nodes.py
children
property
¶
Returns the children of the node.
Function
dataclass
¶
Bases: AssemblyTree
A module-level function definition with arguments args....
Attributes:
| Name | Type | Description |
|---|---|---|
name |
Variable
|
The function variable, annotated with its AssemblyKernelFType. |
args |
tuple[Variable, ...]
|
The arguments to the function. |
body |
AssemblyStatement
|
The body of the function. If it does not contain a return statement,
the function returns the value of |
Source code in src/finch/finch_assembly/nodes.py
GetAttr
dataclass
¶
Bases: AssemblyExpression, AssemblyTree
Represents a getter for an attribute attr of an object obj.
Attributes:
obj: The object to get the attribute from.
attr: The name of the attribute to get.
Source code in src/finch/finch_assembly/nodes.py
If
dataclass
¶
Bases: AssemblyTree, AssemblyStatement
Represents an if statement that executes the body if the condition is true.
Attributes:
| Name | Type | Description |
|---|---|---|
condition |
AssemblyExpression
|
The condition to evaluate for the if to execute the body. |
body |
AssemblyStatement
|
The body of the if statement to execute. |
Source code in src/finch/finch_assembly/nodes.py
children
property
¶
Returns the children of the node.
IfElse
dataclass
¶
Bases: AssemblyTree, AssemblyStatement
Represents an if-else statement that executes the body if the condition is true, otherwise executes else_body.
Attributes:
| Name | Type | Description |
|---|---|---|
condition |
AssemblyExpression
|
The condition to evaluate for the if to execute the body. |
body |
AssemblyStatement
|
The body of the if statement to execute. |
else_body |
AssemblyStatement
|
An alternative body to execute if the condition is false. |
Source code in src/finch/finch_assembly/nodes.py
children
property
¶
Returns the children of the node.
Length
dataclass
¶
Bases: AssemblyExpression, AssemblyTree
Represents getting the length of a buffer.
Attributes:
| Name | Type | Description |
|---|---|---|
buffer |
AssemblyExpression
|
The buffer whose length is queried. |
Source code in src/finch/finch_assembly/nodes.py
result_type
property
¶
Returns the type of the expression.
Literal
dataclass
¶
Bases: AssemblyExpression, LiteralTerm[T]
Represents the literal value val.
Attributes:
| Name | Type | Description |
|---|---|---|
val |
T
|
The literal value. |
Source code in src/finch/finch_assembly/nodes.py
result_type
property
¶
Returns the type of the expression.
Load
dataclass
¶
Bases: AssemblyExpression, AssemblyTree
Represents loading a value from a buffer at a given index.
Attributes:
| Name | Type | Description |
|---|---|---|
buffer |
AssemblyExpression
|
The buffer to load from. |
index |
AssemblyExpression
|
The index to load at. |
Source code in src/finch/finch_assembly/nodes.py
result_type
property
¶
Returns the type of the expression.
Module
dataclass
¶
Bases: AssemblyTree
Represents a group of functions. This is the toplevel translation unit for FinchAssembly.
Attributes:
| Name | Type | Description |
|---|---|---|
funcs |
tuple[Function, ...]
|
The functions defined in the module. |
Source code in src/finch/finch_assembly/nodes.py
children
property
¶
Returns the children of the node.
Repack
dataclass
¶
Bases: AssemblyTree, AssemblyStatement
Registers updates from a symbolic object val with the original
object. The original object may now be accessed and modified.
Attributes:
| Name | Type | Description |
|---|---|---|
slot |
The symbolic object to read from. |
Source code in src/finch/finch_assembly/nodes.py
children
property
¶
Returns the children of the node.
Resize
dataclass
¶
Bases: AssemblyTree, AssemblyStatement
Represents resizing a buffer to a new size.
Attributes:
| Name | Type | Description |
|---|---|---|
buffer |
AssemblyExpression
|
The buffer to resize. |
new_size |
AssemblyExpression
|
The new size for the buffer. |
Source code in src/finch/finch_assembly/nodes.py
Return
dataclass
¶
Bases: AssemblyTree, AssemblyStatement
Represents a return statement that returns arg from the current function.
Halts execution of the function body.
Attributes:
| Name | Type | Description |
|---|---|---|
arg |
AssemblyExpression
|
The argument to return. |
Source code in src/finch/finch_assembly/nodes.py
children
property
¶
Returns the children of the node.
SetAttr
dataclass
¶
Bases: AssemblyTree, AssemblyStatement
Represents a setter for an attribute attr of an object obj.
Attributes:
obj: The object to set the attribute on.
attr: The name of the attribute to set.
value: The value to set the attribute to.
Source code in src/finch/finch_assembly/nodes.py
children
property
¶
Returns the children of the node.
Slot
dataclass
¶
Bases: AssemblyExpression
Represents a register to a symbolic object. Using a register in an expression creates a copy of the object.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The name of the symbolic object to register. |
type |
Any
|
The type of the symbolic object. |
Source code in src/finch/finch_assembly/nodes.py
result_type
property
¶
Returns the type of the expression.
Store
dataclass
¶
Bases: AssemblyTree, AssemblyStatement
Represents storing a value into a buffer at a given index.
Attributes:
| Name | Type | Description |
|---|---|---|
buffer |
AssemblyExpression
|
The buffer to store into. |
index |
AssemblyExpression
|
The index to store at. |
value |
AssemblyExpression
|
The value to store. |
Source code in src/finch/finch_assembly/nodes.py
Unpack
dataclass
¶
Bases: AssemblyTree, AssemblyStatement
Attempts to convert rhs into a symbolic, which can be registerd with
lhs. The original object must not be accessed or modified until the
corresponding Repack node is reached.
Attributes:
| Name | Type | Description |
|---|---|---|
lhs |
Slot
|
The symbolic object to write to. |
rhs |
AssemblyExpression
|
The original object to read from. |
Source code in src/finch/finch_assembly/nodes.py
children
property
¶
Returns the children of the node.
Variable
dataclass
¶
Bases: AssemblyExpression, NamedTerm
Represents a logical AST expression for a variable named name, which
will hold a value of type type.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The name of the variable. |
type |
FType
|
The type of the variable. |
Source code in src/finch/finch_assembly/nodes.py
result_type
property
¶
Returns the type of the expression.
WhileLoop
dataclass
¶
Bases: AssemblyTree, AssemblyStatement
Represents a while loop that executes as long as the condition is true.
Attributes:
| Name | Type | Description |
|---|---|---|
condition |
AssemblyExpression
|
The condition to evaluate for the loop to continue. |
body |
AssemblyStatement
|
The body of the loop to execute. |
Source code in src/finch/finch_assembly/nodes.py
children
property
¶
Returns the children of the node.