About sac2c
The language implementation goals are rather simply explained: transform SAC high-level program specifications into efficiently executable machine code and achieve the utmost runtime performance possible. Among others, this may be done by
- a mix of conventional optimizations, e.g. function inlining, constant folding, or loop invariant removal, which all benefit from referential transparency;
- a rigorous shape inference scheme;
- function specialization;
- a folding scheme for high-level array operations that helps to avoid the creation of superfluous intermediate arrays;
- a code generation scheme that takes the cache hierarchy into account;
- implicit support for non-sequential program execution on multiprocessor systems.
However, C is used as an intermediate language in order to achieve portability among different target architectures and to reuse existing compiler technology for the generation of machine specific code.
The following graphic illustrates the major compilation phases of sac2c. Most of the intermediate phases operate on a code representation that is based on static single assignment form (SSA). To achieve this two additional phases called Fun2LaC and LaC2Fun transform intermediate SAC code into this convenient format and vice versa. For example, front-end representations of loops and if-clauses are transformed to what they actually represent: tail-end recursive functions and functional conditionals.