summaryrefslogtreecommitdiffstats
path: root/tests/012/oop-dsc.tl
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2023-07-15 19:32:42 -0700
committerKaz Kylheku <kaz@kylheku.com>2023-07-15 19:32:42 -0700
commitc30b2adac82ee1922883551363874779b0083d83 (patch)
tree8d2958b1caad568f0ddf69e059600218f1a86d58 /tests/012/oop-dsc.tl
parent2f9ed3990a67fcdd9473b862bbb83ab257560610 (diff)
downloadtxr-c30b2adac82ee1922883551363874779b0083d83.tar.gz
txr-c30b2adac82ee1922883551363874779b0083d83.tar.bz2
txr-c30b2adac82ee1922883551363874779b0083d83.zip
compiler: constant folding in optimizer.
The compiler handles trivial constant folding over the source code, as a source to source transformation. However, there are more opportunities for constant folding after data flow optimizations of the VM code. Early constant folding will not fold, for instance, (let ((a 2) (b 3)) (* a b)) but we can reduce this to an end instruction that returns the value of a D register that holds 6. Data flow optimizations will propagate the D registers for 2 and 3 into the gcall instruction. We can then recognize that we have a gcall with nothing but D register operands, calling a constant-foldable function. We can allocate a new D register to hold the result of that calculation and just move that D register's value into the target register of the original gcall. * stdlib/compiler.tl (compiler get-dreg): When allocating a new D reg, we must invalidate the datavec slot which is calculated from the data hash. This didn't matter before, because until now, get-datavec was called after compilation, at which point no new D regs will exist. That is changing; the optimizer can allocate D regs. (compiler null-dregs, compiler null-stab): New methods. (compiler optimize): Pass self to constructor for basic-blocks. basic-blocks now references back to the compiler. At optimization level 5 or higher, constant folding can now happen, so we call the new method in the optimizer to null the unused data. This overwrites unused D registers and unused parts of the symbol vector with nil. * stdlib/optimize (basic-blocks): Boa constructor now takes a new leftmost param, the compiler. (basic-blocks do-peephole-block): New optimization case: gcall instruction invoking const-foldable function, with all arguments being dregs. (basic-blocks null-unused-data): New method.
Diffstat (limited to 'tests/012/oop-dsc.tl')
0 files changed, 0 insertions, 0 deletions