Next: A Brief Digression on
Up: But Mom, I don't
Previous: But Mom, I don't
Functional-language compilers often use an intermediate representation
(IR) based on the
-calculus. These IR's generally come in
two flavors:
- Direct style (DS)
- function arguments are atomic; all intermediate results are
bound to variables
- makes data-flow explict
- Continuation passing style
- function applications restricted to tail positions; function
returns are represetned as application of continuation function
- maked both data-flow and control-flow explicit
In general, we have
To the right, we have more regular IRs, but programs require more
functions (which obscure original program structure). To the left, we
have more compact representations that are faithful to the original
program.
Closure conversion phases of compilation generally transform programs
to a first-order IR (either in DS or CPS). In this first-order IR,
tail calls to known functions can be implemented as gotos (as opposed
to indirect jumps or calls and returns).
Local CPS: allow a direct-style compiler to increase the number of
tail-calls to known functions; locally apply CPS conversion; i.e.,
only convert the caller and do not requires whole-program analysis.
Next: A Brief Digression on
Up: But Mom, I don't
Previous: But Mom, I don't
Matthew Fluet
2002-02-22