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
67 68 69 70 71 72 73 74 75 76 77 78 | |
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
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
__str__()
Returns a string representation of the node.
Source code in src/finch/finch_assembly/nodes.py
53 54 55 56 57 | |
from_children(*children)
classmethod
Creates a term from the given children. This is used to create terms from the children of a node.
Source code in src/finch/finch_assembly/nodes.py
45 46 47 48 49 50 51 | |
head()
classmethod
Returns the head of the node.
Source code in src/finch/finch_assembly/nodes.py
35 36 37 38 | |
make_term(head, *args)
classmethod
Creates a term with the given head and arguments.
Source code in src/finch/finch_assembly/nodes.py
40 41 42 43 | |
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
81 82 83 84 85 86 87 | |
AssemblyTree
dataclass
Bases: AssemblyNode, TermTree
Source code in src/finch/finch_assembly/nodes.py
60 61 62 63 64 | |
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
463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 | |
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
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
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
561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 | |
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
549 550 551 552 553 554 555 556 557 558 | |
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
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 | |
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
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | |
children
property
Returns the children of the node.
result_type
property
Returns the type of the expression.
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
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 | |
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
503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 | |
children
property
Returns the children of the node.
from_children(*children)
classmethod
Creates a term with the given head and arguments.
Source code in src/finch/finch_assembly/nodes.py
524 525 526 527 528 | |
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
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | |
children
property
Returns the children of the node.
result_type
property
Returns the type of the expression.
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
444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 | |
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
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 | |
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
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 | |
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
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
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
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | |
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
582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 | |
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
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | |
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
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | |
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
531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 | |
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
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | |
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
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |
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
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 | |
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
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
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
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
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
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 | |
children
property
Returns the children of the node.