Compiler Step 6b: Final Cleanup


Step 6b tidies the code for the benefit of C and assembler code generation. The substeps are:

Constant promotion

This step first moves constants (numbers, 2D and 3D points) into temporary variables, assigned at the start of the code using the special operation constant-set!. Exception: constants inside icp-error forms are left alone.

This rewriting is done because many points are 2D or 3D, and all points (even 1D ones) are stored as structs large enough to accomodate 3D points. As a result, creation of points in the middle of a loop costs time. Furthermore, we have found that this sometimes results in faster C code even for simple numbers (though we can't fathom why).

It is important to apply arithmetic identities right before constant elevation, so that there are no complex constant expressions in the code.

Unused symbols

The compiler constructs a list of symbols used in the code. It then scans the symbol table, setting the type field to #f for unused symbols. Allocated but unused symbols are created for a variety of reasons, notably parts of scan forms that are eliminated as useless e.g. because the output value of the scan form is never used.


Ownership, Maintenance and Disclaimers

Manual Top Page

Last modified