![](https://csdnimg.cn/release/download_crawler_static/3551996/bg3.jpg)
Nanopass Framework 3
Week 1: simplification
verify-scheme
1
rename-var
remove-implicit-begin
1
remove-unquoted-constant
remove-one-armed-if
verify-a1-output
1
Week 2: assignment conv.
remove-not
mark-assigned
optimize-letrec
2
remove-impure-letrec
convert-assigned
verify-a2-output
1
Week 3: closure conversion
optimize-direct-call
remove-anon-lambda
sanitize-binding-forms
uncover-free
convert-closure
optimize-known-call
3
uncover-well-known
2
optimize-free
2
optimize-self-reference
2
analyze-closure-size
1
lift-letrec
verify-a3-output
1
Week 4: canonicalization
introduce-closure-prims
remove-complex-constant
normalize-context
verify-a4-output
1
Week 5: encoding/allocati on
specify-immed iate -repn
specify-nonim med iate- repn
Week 6: start of UIL compiler
verify-uil
Week 7: labels and temps
remove-complex-opera*
lift-letrec-body
introduce-return-point
verify-a7-output
1
Week 8: virtual registerizing
remove-nonunary-let
uncover-local
the-return-of-set!
flatten-set!
verify-a8-output
1
Week 9: brief digression
generate-C-code
4
Week 10: register alloc. setup
uncover-call-live
2
optimize-save-placement
2
eliminate-redundant-saves
2
rewrite-saves/restores
2
impose-ca lling -convention
reveal-allocation-pointer
verify-a10-output
1
Week 11: live analysis
uncover-live-1
uncover-frame-conflict
strip-live-1
uncover-frame-move
verify-a11-output
1
Week 12: call frames
uncover-call-live-spills
assign-frame-1
assign-new-frame
optimize-fp-assignments
2
verify-a12-output
1
Week 13: spill code
finalize-frame-locations
eliminate-frame-var
introduce-unspillables
verify-a13-output
1
Week 14: register assignment
uncover-live-2
uncover-register-conflict
verify-unspillables
1
strip-live-2
uncover-register-move
assign-registers
assign-frame-2
finalize-register-locations
analyze-frame-traffic
1
verify-a14-output
1
Week 15: assembly
flatten-program
generate-Sparc-code
Table 1. Passes assigned during a recent semester, given in running order and
grouped roughly by week and primary task. Notes:
1
Supplied by the instructor.
2
Challenge passes required of graduate students, not necessarily in the week shown.
3
Actually written during Week 4.
4
Not included in final compiler. During Week 6,
students also had an opportunity to turn in updated versions of earlier passes.
Week 9 was a short week leading up to spring-break week. Most passes are run
once, but the passes comprising the main part of the register and frame allocator
are repeated until all variables have been given register or frame homes.
case, resulting in either confusing errors or malformed output to trip up later passes.
Finally, the resulting compiler is slow, which leaves students with a mistaken im-
pression about the speed of a compiler and the importance thereof.
To address these problems, we have developed a “nanopass” methodology and a
domain-specific language for writing nanopass compilers. A nanopass compiler dif-
fers from a micropass compiler in three ways: (1) the intermediate-language gram-
mars are formally specified and enforced; (2) each pass needs to contain traversal
code only for forms that undergo meaningful transformation; and (3) the interme-
diate code is represented more efficiently as records, although all interaction with
the programmer is still via the s-expression syntax. We use the word “nanopass”