This MR introduces AST passes for symbol canonicalization and loop-invariant code motion, and an AST factory for more convenient creation of syntax trees..
Symbol Canonicalization The CanonicalizeSymbols
pass will transform an AST into a canonical form with respect to the symbols occuring inside it:
const
qualifier to the data type of any symbol that is never written toLoop-Invariant Motion of Declarations The HoistLoopInvariantDeclarations
pass moves declarations that are independent of loop iterations
outside of the loop nest. For it to work, all symbols may have at most one declaration, so a CanonicalizeSymbols
pass may have to be run before.
Both passes are now called by create_kernel
.
AST Factory The newly added backend.kernelcreation.AstFactory
exposes methods to quickly parse SymPy expressions and create loop nests,
and is open to be extended in the future.
This MR also introduces various minor changes:
FreezeExpressions
FullIterationSpace.create_from_slice
and the GenericCpu
platform to use AstFactory