Skip to main content

An implementation of retargetable code generators in prolog

  • Logic Programming In Compiler Writing
  • Conference paper
  • First Online:

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 348))

Abstract

A major problem in deriving a compiler from a formal definition is the production of correct and efficient object code. In this context, we propose a solution to the problem of code generator generation.

Our approach is based on a target machine description where the basic concepts used (storage classes, access modes, access classes and instructions) are hierarchically described by tree-patterns. These tree-patterns are written in an abstract tree language which is also used to write the program intermediate representation (input to the code generator). The code generation process is based on access mode template-driven rewritings in which the program intermediate representation is progressively transformed. The result is that each program instruction is reduced to a sequence of elementary machine instructions, each of them representing an instance of an instruction template. A data base of clauses is derived automatically from the target machine description. It is used by the kernel of the rewriting system implemented in Prolog.

First, this paper presents a way of structuring formal specifications of target machines in order to decrease the size of the description. We propose to get complete specification components by instances of parameterized specifications. As a consequence, legibility which is an important requirement of large specifications is improved.

Second a theoretical support of the intermediate rewritings based on abstract data types is given.

Third the code generation algorithm is presented and illustrated.

Finally an implementation in Prolog of a code generator based on our appoach is developped.

This is a preview of subscription content, log in via an institution.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Bibliography

  1. Bidoit M., Gaudel M. C., Mauboussin A.: "How to make algebraic specifications more understandable ? an experiment with the PLUSS specification language", Rapport LRI No 343, Université d'Orsay, France 1987.

    Google Scholar 

  2. Cattell R. G. G.: "A Survey and Critique of some Models of Code Generation", Carnegie-Mellon University, Computer Sciences Department, Technical Report, CMU-CS-115, 1977.

    Google Scholar 

  3. Cattell R. G. G.: "Automatic Derivation of Code Generators from Machine Description", ACM Transactions on Programming Languages and Systems, Vol. 2, No.2 p173–199, April 1980.

    Google Scholar 

  4. Despland A., Mazaud M., Rakotozafy R.: "Code generator generation based on template-driven target term rewriting", LNCS no 256 p 105–120, Proceedings of Rewriting Techniques and Applications, Bordeaux, France, May 1987.

    Google Scholar 

  5. Deschamp Ph.: "PERLUETTE: a compiler producing system using abstract data types", Proceedings of International Symposium on Programming, Turin, April 1982.

    Google Scholar 

  6. Ganzinger H, Giegerich R.: "A truly Generative Semantics-Directed Compiler Generator", Proceedings of the SIGPLAN 82 Symposium on Compiler Construction, ACM SIGPLAN no 17, 6, June 1982.

    Google Scholar 

  7. Gaudel M. C., Deschamp Ph., Mazaud M.: "Compiler Construction From High Level Specification", Automatic Program Construction Techniques, Macmillan Inc, 1984.

    Google Scholar 

  8. Ganapathi M., Fischer C. N.: "Description-Driven Code Generation Using attributed Grammars", Conference of the Nineth Annual ACM Symposium on Programming Languages, Albuquerque New-Mexico, p 108–109, January 25–27, 1982.

    Google Scholar 

  9. Graham S. L, Glanville R. S.: "A New Method for Compiler Code Generation", Conference Record of the Fifth Annual ACM Symposium on Principles of Programming Languages, p 231–240, January 1978.

    Google Scholar 

  10. Graham S. L., Henry R. R. & Al. "Experiment with a Graham-Glanville Style Code generator", Proceedings of the SIGPLAN 84, Symposium on Compiler Construction, ACM Not. 19, 6, June 1984.

    Google Scholar 

  11. Giegerich R.: "Logic specification of Code Generation Techniques", LNCS no 217, p 96–111, Programs as data objects, Copenhague October 17–19, 1985.

    Google Scholar 

  12. Madelaine E.: "Système d'aide à la preuve de compilateurs", Thèse de 3ème cycle, Université de Paris VII, Septembre 1983.

    Google Scholar 

  13. Mazaud M., Rakotozafy R., Szumachowski-Despland A.: "Code generator generation based on template-driven target term rewriting", Rapport de recherche INRIA RR-582, 1986.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

P. Deransart B. Lorho J. Małuszyński

Rights and permissions

Reprints and permissions

Copyright information

© 1989 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Despland, A., Mazaud, M., Rakotozafy, R. (1989). An implementation of retargetable code generators in prolog. In: Deransart, P., Lorho, B., Małuszyński, J. (eds) Programming Languages Implementation and Logic Programming. PLILP 1988. Lecture Notes in Computer Science, vol 348. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-50820-1_42

Download citation

  • DOI: https://doi.org/10.1007/3-540-50820-1_42

  • Published:

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-50820-5

  • Online ISBN: 978-3-540-46092-3

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics