Macro-embedding Compiler Intermediate Languages in Racket

๐Ÿ“… 2025-09-23
๐Ÿ“ˆ Citations: 0
โœจ Influential: 0
๐Ÿ“„ PDF
๐Ÿค– AI Summary
This work addresses two key challenges in compiler education: low reusability of intermediate language (IL) testing frameworks and the difficulty of reconciling high-level safety abstractions with low-level assembly features. We propose a family-of-intermediate-languages design methodology based on Racket macro embedding. Leveraging local macro expansion, we uniformly embed a series of ILsโ€”from Scheme-like source languages to x86-64 target codeโ€”into Racket, enabling semantic-level interoperability between higher-order functional abstractions and unsafe assembly primitives. Our approach innovates by supporting open, modular composition of language features: ILs can be dynamically assembled without modifying the host language. The resulting interpreter exposes multiple interfaces, significantly simplifying semantic specification and test development. Evaluated in university compiler courses, our framework has improved IL reuse and pedagogical scalability.

Technology Category

Application Category

๐Ÿ“ Abstract
We present the design and implementation of a macro-embedding of a family of compiler intermediate languages, from a Scheme-like language to x86-64, into Racket. This embedding is used as part of a testing framework for a compilers course to derive interpreters for all the intermediate languages. The embedding implements features including safe, functional abstractions as well as unsafe assembly features, and the interactions between the two at various intermediate stages. This paper aims to demonstrate language-oriented techniques and abstractions for implementing (1) a large family of languages and (2) interoperability between low- and high-level languages. The primary strength of this approach is the high degree of code reuse and interoperability compared to implementing each interpreter separately. The design emphasizes modularity and compositionality of an open set of language features by local macro expansion into a single host language, rather than implementing a language pre-defined by a closed set of features. This enables reuse from both the host language (Racket) and between intermediate languages, and enables interoperability between high- and low-level features, simplifying development of the intermediate language semantics. It also facilitates extending or redefining individual language features in intermediate languages, and exposing multiple interfaces to the embedded languages.
Problem

Research questions and friction points this paper is trying to address.

Embedding compiler intermediate languages into Racket for testing
Enabling interoperability between high-level and low-level language features
Achieving code reuse across language family through macro expansion
Innovation

Methods, ideas, or system contributions that make the work stand out.

Macro-embedding intermediate languages into Racket
Using local macro expansion for modular language features
Enabling interoperability between high- and low-level languages
๐Ÿ”Ž Similar Papers
No similar papers found.