Abstract Syntax Tree#
Canonical Form#
Many transformations in pystencils’ backend require that their input AST is in canonical form. This means that:
Each symbol, constant, and expression node is annotated with a data type;
Each symbol has at most one declaration;
Each symbol that is never written to apart from its declaration has a
consttype; andEach symbol whose type is not
consthas at least one non-declaring assignment.
The first requirement can be ensured by running the Typifier on each newly constructed subtree.
The other three requirements are ensured by the CanonicalizeSymbols pass,
which should be run first before applying any optimizing transformations.
Canonicality allows transformations to forego various checks that would otherwise be necessary to prove their legality.
API Documentation#
Inheritance Diagram#

Base Classes#
Base class for all nodes in the pystencils AST. |
|
Mix in with |
|
Mix-in for AST leaves. |
Structural Nodes#
Conditional branch |
|
Mix-in marking AST leaves that can be treated as empty by the code generator, such as comments and preprocessor directives. |
|
A C/C++ preprocessor pragma. |
|
Iteration Axes System#
Iteration range of an axis. |
|
Hypercube of multiple iteration ranges. |
|
Common base class for iteration axes. |
|
Loop axis. |
|
Parallel loop axis. |
|
Axis modelling a SIMD block. |
|
Common base class for GPU block+thread indexing axes. |
|
Gpu block axis. |
|
Gpu thread axis. |
|
Gpu block x thread axis. |
Expressions#
Base class for all expressions. |
|
Mix-in for all expressions that may occur as an lvalue; i.e. expressions that represent a memory location. |
|
A single symbol as an expression. |
|
Access into a |
|
N-dimensional subscript into an array. |
|
Pointer-based memory access with type-dependent offset. |
|
Ternary operator. |
|
Trait for operations valid only on numerical types |
|
Trait for operations valid only on integer types |
|
Trait for boolean operations |
|
Take the address of a memory location. |
|
C-style type cast. |
|
C-like integer division (round to zero). |
|
C-style integer division remainder |
|
Base class for binary relational operators |
|
N-dimensional array initialization matrix. |
SIMD Nodes#
Mix-in for vector operations |
|
Broadcast a scalar value to N vector lanes. |
|
Pointer-based vectorized memory access. |
Utility#
Evaluate a pystencils backend expression tree with values assigned to symbols according to the given valuation. |
|
Pre-Order depth-first traversal of an abstract syntax tree. |
|
Post-Order depth-first traversal of an abstract syntax tree. |
|
Return the memory object accessed by the given expression, together with its constness |