## Metacomputation-based compiler architecture (2000)

### Cached

### Download Links

- [www.cs.missouri.edu]
- [www.cs.missouri.edu]
- [cse.cse.ogi.edu]
- [www-sal.cs.uiuc.edu]
- DBLP

### Other Repositories/Bibliography

Venue: | IN 5TH INTERNATIONAL CONFERENCE ON THE MATHEMATICS OF PROGRAM CONSTRUCTION |

Citations: | 9 - 5 self |

### BibTeX

@INPROCEEDINGS{Harrison00metacomputation-basedcompiler,

author = {William L. Harrison and Samuel N. Kamin},

title = {Metacomputation-based compiler architecture},

booktitle = {IN 5TH INTERNATIONAL CONFERENCE ON THE MATHEMATICS OF PROGRAM CONSTRUCTION},

year = {2000},

pages = {213--229},

publisher = {Springer-Verlag}

}

### Years of Citing Articles

### OpenURL

### Abstract

This paper presents a modular and extensible style of language specification based on metacomputations. This style uses two monads to factor the static and dynamic parts of the specification, thereby staging the specification and achieving strong binding-time separation. Because metacomputations are defined interms of monads, they can be constructed modularly and extensibly using monad transformers. A number of language constructs are specified: expressions, control flow, imperative features, and block structure. Metacomputation-style specification lends itself to semantics-directed compilation, which we demonstrate by creating a modular compiler for a block-structured, imperative while language.

### Citations

1353 | Introduction to Functional Programming
- Bird, Wadler
- 1988
(Show Context)
Citation Context ...tions based on metacomputations: Astyle of language speci cation based on metacomputation is proposed in which the static and dynamic parts of a language speci cation are factored into distinct monads=-=[7, 14, 18, 27]-=-. (3) Direct-style speci cations: instead of writing all speci cations in continuation-passing style, here we write in direct style,ss:Source compile Parsing Type Checking Code Generation Optimization... |

766 | Notions of computation and monads
- Moggi
- 1991
(Show Context)
Citation Context ...tions based on metacomputations: Astyle of language speci cation based on metacomputation is proposed in which the static and dynamic parts of a language speci cation are factored into distinct monads=-=[7, 14, 18, 27]-=-. (3) Direct-style speci cations: instead of writing all speci cations in continuation-passing style, here we write in direct style,ss:Source compile Parsing Type Checking Code Generation Optimization... |

634 |
Compiling with Continuations
- Appel
- 1992
(Show Context)
Citation Context ...[ Eq Control- ow [ Eq Block [ Eq Bool Source Code: new x in new y in x := 5; y := 1; while (1 x) do y := y*x; x := x-1; Target Code: 0 := 5; 2: 2 := [1]; 3: halt; 1 := 1; 3 := [0]; jump 1; 1 := [2] * =-=[3]-=-; 2 := [0]; 1: 2 := 1; 3 := 1; 3 := [0]; 0 := [2] - [3]; BRLEQ [2] [3] 2 3; jump 1; Fig. 13. Compiler for While language and example compilation Figure 13 contains the compiler for the while language,... |

496 |
Denotational Semantics: The Scott-Strachey Approach to Programming Language Theory
- Stoy
- 1977
(Show Context)
Citation Context ... of a single monolithic monad simpli es the use of the \code store" (de ned below) in the speci cation of reusable compiler building blocks. In [8], we borrowed a technique from denotational sema=-=ntics[26] for modeling j-=-umps, namely storing command continuations in a \code store" and denoting \jump L" as \execute the continuation at label L in the code store." Viewing command continuations as machine c... |

248 | Monad transformers and modular interpreters
- Liang, Hudak, et al.
- 1995
(Show Context)
Citation Context ...tions based on metacomputations: Astyle of language speci cation based on metacomputation is proposed in which the static and dynamic parts of a language speci cation are factored into distinct monads=-=[7, 14, 18, 27]-=-. (3) Direct-style speci cations: instead of writing all speci cations in continuation-passing style, here we write in direct style,ss:Source compile Parsing Type Checking Code Generation Optimization... |

209 | Continuation-based partial evaluation
- Lawall, Danvy
- 1994
(Show Context)
Citation Context ... (read 0))) Pretty printed version: ((store 0 (negate (read 1))) ((store 1 7) sto1))))))) 1 := 7; 0 := -[1]; Acc := -[0]; Fig. 6. Compiling \,,7" Code is generated via type-directed partial evalu=-=ation[4]-=- using the method of Danvy and Vestergaard[5]. An example of code generation is presented in Figure 6. The code produced takes the form of a number of stores and reads from storage (underlined in the ... |

197 | A modal analysis of staged computation - Davies, Pfenning - 1996 |

174 |
An abstract view of programming languages
- Moggi
- 1989
(Show Context)
Citation Context ...et M2St by applying the ordinary state monad twice. Unfortunately, M St(M St ) and M2St are very di erent types. This points to a di culty with monads: they do not compose in this simple manner. Moggi=-=[17]-=- developed the notion of monad transformers (which he called monad constructors) to solve this composition problem in a categorical setting, and this work was extended in [7, 14]. When applied to a mo... |

160 |
Denotational semantics
- Mosses
- 1990
(Show Context)
Citation Context ...m is that the meaning of [,] can be reinterpreted in a variety of monads. Monadic semantics separate the description of a language from its denotation. In this sense, it is similar to action semantics=-=[19]-=- and high-level semantics[12].sIdentity Monad Id: Id = unitId x = x x?Id f = fx CPS Monad Transformer TCPS: M 0 = TCPS ans M = ( ! M ans) ! M ans unit M 0 x = : x x? M 0 f= : x( a:f a ) lift M !M 0 x ... |

140 |
Modern Compiler Implementation in ML
- Appel
- 1998
(Show Context)
Citation Context ...antage over the monolithic approach. Consider the three de nitions of the conditional if-then statement in Figure 8. The rst is a dual continuation \control- ow" semantics, found commonly in comp=-=ilers[2]-=-. If B is true, then the rst continuation, [c] ? D ,is executed, otherwise c is skipped and just is executed. A more implementationoriented (informal) speci cation might be: [if b then c] = [b] ? D B:... |

54 |
Realistic Compiler Generation
- Lee
- 1989
(Show Context)
Citation Context ...can be reinterpreted in a variety of monads. Monadic semantics separate the description of a language from its denotation. In this sense, it is similar to action semantics[19] and high-level semantics=-=[12]-=-.sIdentity Monad Id: Id = unitId x = x x?Id f = fx CPS Monad Transformer TCPS: M 0 = TCPS ans M = ( ! M ans) ! M ans unit M 0 x = : x x? M 0 f= : x( a:f a ) lift M !M 0 x = x?M callcc :((a!M 0 b)!M 0 ... |

52 | Deriving target code as a representation of continuation semantics - Wand - 1982 |

38 | Semantic Lego
- Espinosa
- 1995
(Show Context)
Citation Context |

38 | Compilers and staging transformations - Jørring, Scherlis - 1986 |

30 | Modular Monadic Semantics and Compilation
- Liang
- 1998
(Show Context)
Citation Context ...adding new source language features and the speci cation would still hold 3 . So, the use of monad transformers in this work yields a kind of proof reuse for metacomputation-based compiler correctness=-=[15]-=-. 8 Conclusions and Future Work Metacomputations are a simple and elegant structure for representing staged computation within the semantics of a programming language. This paper presents a modular an... |

29 |
Automatic binding time analysis for a typed l calculus
- Nielson, Nielson
- 1988
(Show Context)
Citation Context ...ut since he does not compile to machine language, many of the issues we confront|especially staging|do not arise. A syntactic form of metacomputation can be found in the two-level -calculus of Nielson=-=[21]-=-. Two-level -calculus contains two distinct -calculi|representing the static and dynamic levels. Expressions of mixed level, then, have strongly separated binding times by de nition. Nielson[20] appli... |

24 | Semantics-based compiling: A case study in typedirected partial evaluation
- Danvy, Vestergaard
- 1996
(Show Context)
Citation Context ...ty, extensibility, and modularity). While our binding time analysis is not automatic as in [21, 16], we consider a far wider range of programming language features than they do.sDanvy and Vestergaard =-=[5] show how to pr-=-oduce code that \looks like" machine language, by expressing the source language semantics in terms of machine language-like combinators (e.g., \popblock", \push"). When the interpreter... |

20 | Modular Compilers Based on Monad Transformers
- Harrison, Kamin
- 1998
(Show Context)
Citation Context ...here are separate \update" and \get" combinators for the value and code states, Sto and Code. These are, respectively, updateSto and getSto for Sto and updateCode and getCode for Code. In ou=-=r work in [8], we -=-found it convenient to factor the state monad into two parts: the state proper and the address allocator. This was really a \staging transformation," with the state monad representing dynamic com... |

20 |
Imperative functional programming
- Peyton-Jones, Wadler
(Show Context)
Citation Context ...r and code store states tosthe underlying monad. Indeed, the primary use for monads in functional programming seems to be that of adding state-like features to purely functional languages and programs=-=[27, 22]-=-, and the fact that we structured our monads in [8] with monad transformers made adding the new states simple. The use of a code store is integral to the modular compilation technique described in [8]... |

10 |
Using functor categories to generate intermediate code
- Reynolds
- 1995
(Show Context)
Citation Context ...in a \code store" and denoting \jump L" as \execute the continuation at label L in the code store." Viewing command continuations as machine code is a common technique in semanticsdirec=-=ted compilation[28, 25]-=-. Because our language speci cations were in monadic style, it was a simple matter to add label generator and code store states tosthe underlying monad. Indeed, the primary use for monads in functiona... |

9 |
Modular Compilers and Their Correctness Proofs
- Harrison
- 2001
(Show Context)
Citation Context ...onal if-then. Its standard and compilation semantics are presented in Figure 8. A (slightly informal) speci cation of if-then is: If L c 6= L and L c;L are unbound 2 The interested reader may consult =-=[9]-=-.sin the code store, then IfThen([b]; [c];L c;L ) ? D :initCode =[if b then c] ? D :initCode where initCode = updateCode( : ) for arbitrary constant : Code. Because IfThen([b];[c];Lc ;L ) will a ect t... |

7 |
A modular semantics for compiler generation
- Liang
- 1995
(Show Context)
Citation Context ...ations and that this naturally makes them easier to reason about. 3 Related work Espinosa [7] and Hudak, Liang, and Jones [14] use monad transformers to create modular, extensible interpreters. Liang =-=[13, 15]-=- addresses the question of whether compilers can be developed similarly, but since he does not compile to machine language, many of the issues we confront|especially staging|do not arise. A syntactic ... |

6 |
Separating binding times in language speci cations
- Mogensen
- 1989
(Show Context)
Citation Context ...s to code generation for a typed -calculus, and Nielson[21] presents an algorithm for static analysis of a typed -calculus which converts one-level speci cations into two-level speci cations. Mogensen=-=[16]-=- generalizes this algorithm to handle variables of mixed binding times. The present work o ers a semantic alternative to the two-level -calculus. We formalize distinct levels (in the sense of Nielson[... |

6 |
Global state considered unnecessary: Semantics of interference-free imperative programming
- Reddy
- 1993
(Show Context)
Citation Context ...tyle speci cations forced all static data to be explicitly passed to stored command continuations, although this was at the expense of modularity. Infact to compile if-then-else, the snapback operator=-=[23]-=- had to be used. These complications also make reasoning about compilers constructed in [8] di cult. We shall demonstrate in Section 5 that using metacomputations results in vastly simpler compiler sp... |

4 |
The Essence of Algol," Algorithmic Languages
- Reynolds
- 1981
(Show Context)
Citation Context ...ompiler building block for this language appears in Figure 10. The static part of this speci cation allocates a free stack location a, and the program variable x is bound to an accepter-expresser pair=-=[24]-=- in the current environment .Inanaccepter-expresser pair hacc; expi, acc accepts an integer value and sets the value of its variable to the value, and the expresser exp simply returns the current valu... |

2 |
Code Generation from two-level denotational metalanguages
- Nielson, Nielson
- 1986
(Show Context)
Citation Context ...ielson[21]. Two-level -calculus contains two distinct -calculi|representing the static and dynamic levels. Expressions of mixed level, then, have strongly separated binding times by de nition. Nielson=-=[20]-=- applies two-level -calculus to code generation for a typed -calculus, and Nielson[21] presents an algorithm for static analysis of a typed -calculus which converts one-level speci cations into two-le... |

2 |
Separating binding times in language speci
- Mogensen
- 1989
(Show Context)
Citation Context ... to code generation for a typed -calculus, and Nielson[19] presents an algorithm for static analysis of a typed -calculus which converts one-level specications into twolevel specications. Mogensen[15] generalizes this algorithm to handle variables of mixed binding times. The present work oers a semantic alternative to the two-level -calculus. We formalize distinct levels (in the sense of Nielson... |

2 |
Realistic Compiler Generation
- unknown authors
- 1991
(Show Context)
Citation Context ...can be reinterpreted in a variety of monads. Monadic semantics separate the description of a language from its denotation. In this sense, it is similar to action semantics[19] and high-level semantics=-=[12]-=-.sIdentity Monad Id: Id = unitId x = x x?Id f = fx CPS Monad Transformer TCPS: M 0 = TCPS ans M = ( ! M ans) ! M ans unit M 0 x = : x x? M 0 f = : x( a:f a ) lift M !M 0 x = x?M callcc :((a ! M 0 b) !... |