A nanopass infrastructure for compiler education

D Sarkar, O Waddell, RK Dybvig - ACM SIGPLAN Notices, 2004 - dl.acm.org
D Sarkar, O Waddell, RK Dybvig
ACM SIGPLAN Notices, 2004dl.acm.org
Compilers structured as a small number of monolithic passes are difficult to understand and
difficult to maintain. Adding new optimizations often requires major restructuring of existing
passes that cannot be understood in isolation. The steep learning curve is daunting, and
even experienced developers find it hard to modify existing passes without introducing
subtle and tenacious bugs. These problems are especially frustrating when the developer is
a student in a compiler class. An attractive alternative is to structure a compiler as a …
Compilers structured as a small number of monolithic passes are difficult to understand and difficult to maintain. Adding new optimizations often requires major restructuring of existing passes that cannot be understood in isolation. The steep learning curve is daunting, and even experienced developers find it hard to modify existing passes without introducing subtle and tenacious bugs. These problems are especially frustrating when the developer is a student in a compiler class.An attractive alternative is to structure a compiler as a collection of many small passes, each of which performs a single task. This "micropass" structure aligns the actual implementation of a compiler with its logical organization, simplifying development, testing, and debugging. Unfortunately, writing many small passes duplicates code for traversing and rewriting abstract syntax trees and can obscure the meaningful transformations performed by individual passes.To address these problems, we have developed a methodology and associated tools that simplify the task of building compilers composed of many fine-grained passes. We describe these compilers as "nanopass" compilers to indicate both the intended granularity of the passes and the amount of source code required to implement each pass. This paper describes the methodology and tools comprising the nanopass framework.
ACM Digital Library