skip to main content
article
Open access

Operational semantics-directed compilers and machine architectures

Published: 01 July 1994 Publication History

Abstract

We consider the task of automatically constructing intermediate-level machine architectures and compilers generating code for these architectures, given operational semantics for source languages. We use operational semantics in the form of abstract machines given by rewrite systems in which the rewrite rules operate on terms representing states of computations. To construct compilers and new architectures we employ a particular strategy called pass separation, a form of staging transformation, that takes a program p and constructs a pair of programs p1, p2 such that p(x, y) = p2(p1(x), y)) for all x,y. If p represents an operational semantics for a language, with arguments x and y denoting a source program and its input data, then pass separation constructs programs p1 and p2 corresponding to a compiler and an executor.
The compiler translates the source language into an intermediate-level target language, and the executor provides the definition for this language. Our use of pass separation supports the automatic definition of target languages or architectures, and the structure of these architectures is directed by the structure of the given source semantics. These architectures resemble abstract machine languages found in hand-crafted compilers. Our method is restricted to a limited class of abstract machines given as term-rewriting systems, but we argue that this class encompasses a large set of language definitions derived from more natural operational semantics. We provide two examples of our method by constructing compilers and target architectures for a simple functional language and a simple imperative language. Though we construct these architectures automatically, they bear a striking resemblance to existing architectures constructed by hand.

References

[1]
BONDORF, A. 1990. Automatic autoprojection of higher order recursive equations. In ESOP '90. 3rd European Symposium on Programming (Copenhagen, Denmark, May). Lecture Notes in Computer Science, vol. 432, N. D. Jones, Ed. Springer-Verlag, Berlin, 70-87.
[2]
BONDORF, A. AND DANVY, O. 1990. Automatic autoprojection of recursive equations with global variables and abstract data types. Tech. Rep. 90/4, DIKU, University of Copenhagen.
[3]
COUSINEAU, G., CURIEN, P.-L., AND MAUNY, M. 1987. The categorical abstract machine. Sc~. Program. 8, 2, 173-202.
[4]
HANNAN, J. 1991a. Making abstract machines less abstract. In Proceedings of the Conference on Functmnal Programmtng and Computer Architecture, J. Hughes, Ed. Springer-Verlag, Berlin, 618-635.
[5]
HANNAN, J. 1991b. Staging transformations for abstract machines. In Proceedings of the ACM SIGPLAN Symposium on Partial Evaluation and Semantics Based Program Manipulation. ACM Press, New York, 130-141.
[6]
HANNAN, J. AND MILLER, D. 1992. From operational semantics to abstract machines. Math. Struct. Comput. Sci. 2, 4, 415-459.
[7]
HANNAN, J. AND PFENNING, F. 1992. Compiler verification in LF. In Proceedings of the 7th Annual IEEE Symposium on Logic ~n Computer Science, A. Scedrov, Ed. IEEE Computer Society Press, Los Alamitos, Calif., 407-418.
[8]
HARPER, R., HONSELL, F., AND PLOTKIN, G. 1993. A framework for defining logics. J. ACM 40, 1, 143-184.
[9]
JONES, N.D. 1987. Challenging problems in partial evaluation and mixed computation. In Partial Evaluation and Mixed Computation, D. Bjorner, A. P. Ershov, and N. D. Jones, Eds. North-Holland, Amsterdam, 1-14.
[10]
JONES, N. D., ED. 1980. Semantics-Directed Compiler Generation. Lecture Notes in Computer Science, vol. 94. Springer-Verlag, Berlin.
[11]
JONES, N., SESTOFT, P., AND SCNDERGAARD, H. 1989. MIX: A self-applicable partial evaluator for experiments in compiler generation. J. LISP Symbol. Comput. 2, 1, 9-50.
[12]
JCRRING, U. AND SCHERLIS, W. 1986. Compiler and staging transformations. In The 13th ACM Sympostum on Principles of Programming Languages. ACM, New York, 86-96.
[13]
KAHN, G. 1987. Natural semantics. In Proceedings of the Symposium on Theoretical Aspects of Computer Science. Springer-Verlag, Berlin, 22-39.
[14]
KELSEY, Z. AND HUDAK, P. 1989. Realistic compilation by program transformation. In The 16th ACM Sympostum on Prtnciples of Programming Languages. ACM, New York, 281-292.
[15]
KURSAWE, P. 1987. How to invent a prolog machine. New Gen. Comput. 5, 1, 97-114.
[16]
LANDIN, P.J. 1964. The mechanical evaluation of expressions. Comput. J. 6, 5, 308-320.
[17]
LEE, P. 1989. Realisttc Compiler Generation. MIT Press, Cambridge, Mass.
[18]
NIELSON, H. R. AND NIELSON, F. 1992. Semantics wtth Apphcations: A Formal Introduction. John Wiley and Sons, New York.
[19]
NILSSON, U. 1993. Towards a methodology for the design of abstract machines for logic programming languages. J. Logic Program. 16, 1, 2 (May), 163-189.
[20]
PAULSON, L. 1982. A semantics-directed compiler generator. In Proceedings of the ACM Conference on Principles of Programming Languages. ACM, New York, 224.
[21]
PLOTKIN, G. 1981. A structural approach to operational semantics. DAIMI FN-19, Aarhus Univ., Aarhus, Denmark.
[22]
SU~REZ, A. 1990. Compiling ML into CAM. In Logical Foundatmns of Functional Programming, G. Huet, Ed. Addison-Wesley, Reading, Mass., 47-73.
[23]
WAND, M. 1982a. Deriving target code as a representation of continuation semantics. ACM Trans. Program. Lang. Syst. 4, 3,496-517.
[24]
WAND, M. 1982b. Semantics-directed machine architecture. In the 9th ACM Sympostum on Principles of Programming Languages. ACM, New York, 234-241.

Cited By

View all

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Transactions on Programming Languages and Systems
ACM Transactions on Programming Languages and Systems  Volume 16, Issue 4
July 1994
318 pages
ISSN:0164-0925
EISSN:1558-4593
DOI:10.1145/183432
Issue’s Table of Contents

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 01 July 1994
Published in TOPLAS Volume 16, Issue 4

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. abstract machines
  2. pass separation
  3. semantics-based compilation

Qualifiers

  • Article

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)80
  • Downloads (Last 6 weeks)23
Reflects downloads up to 05 Feb 2025

Other Metrics

Citations

Cited By

View all

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Login options

Full Access

Figures

Tables

Media

Share

Share

Share this Publication link

Share on social media