Code generator generation based on template-driven target term rewriting

  • Annie Despland
  • Monique Mazaud
  • Raymond Rakotozafy
Code Generation
Part of the Lecture Notes in Computer Science book series (LNCS, volume 256)


A major problem in deriving a compiler from a formal definition is the production of 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 (access modes, access classes and instructions) are bottom-up hierarchically described by tree-patterns. These tree-patterns are written in an abstract tree language which is also used to write the intermediate program representation (input to the code generator).

The first phase of code production is based on access mode template-driven rewritings in which the program intermediate representation is progressively transformed into its "canonical form". The result is that each program instruction is reduced to a sequence of elementary instructions, each of these elementary instructions representing an instance of an instruction pattern.

The local and global optimizations phases as well as the storage management phase may be realized by multipass rewritings and attribute evaluations of the canonical form.

In the last phase of code production, each pattern instruction instance of the updated intermediate form is replaced by the corresponding instance of the associated pattern code.


Source Position Code Production Access Mode Access Path Left Child 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


  1. [Cat 77]
    Catell R. G. G. "A Survey and Critique of some Models of Code Generation" Carnegie-Mellon University, Computer Sciences Department, Technical Report, 1977.Google Scholar
  2. [Cat 80]
    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
  3. [Des 82]
    Deschamp Ph. "PERLUETTE: a compiler producing system using abstract data types" Proceedings of International Symposium on Programming, Turin, April 1982.Google Scholar
  4. [Don 82]
    Donzeau-Gouge V., "Les raisons des choix dans la définition formelle du langage ADA" Thèse d'état Paris VII 1982.Google Scholar
  5. [GDM 84]
    Gaudel M. C., Deschamp Ph, Mazaud M. "Compiler Construction From High Level Specification". Automatic Program Construction Techniques. Macmillan Inc, 1984.Google Scholar
  6. [Gan Gie 82]
    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. [GF 82]
    Ganapathi M., Fischer C.N. "Descriptive-Driven Code Generation Using attributed Grammars" Conference of the Nineth Annual ACM Symposium on Programming Languages.Google Scholar
  8. [GG 78]
    Graham S.L, Glanville R. S. "A New Method for Compiler Code Generation" Conference Record of the Fith Annual ACM Symposium on Principles of Programming Languages, p231–240, January 1978.Google Scholar
  9. [GH 84]
    Graham S. L., Henry R. R. et 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
  10. [Gie 85]
    Giegerich R. "Logic specification of Code Generation Techniques" Lecture Notes in Computer Science. Programs as data objects, Copenhague 17–19 October 1985.Google Scholar
  11. [GRW 77]
    Ganzinger H., Ripken K., Wilhelm R. "Automatic Generation of Optimizing Multipass Compilers" IFIP77, North-Holland Publishing Company p535..540, 1977.Google Scholar
  12. [Kro 75]
    Kron H. H. "Tree Templates and subtree transformational grammars" PhD-thesis Univ of Cal., Santa Cruz, 1975.Google Scholar
  13. [Ho O'D 82]
    Hoffmann C.M, O'Donnell M.J. "Pattern Matching in Trees" JACM vol 29 No 1, Jan 1982, pp 68–95.Google Scholar
  14. [CHNRSW 79]
    Leverett B.W., Cattell G.G., Hobbs S.O., Newcomer J.M., Reiner A.H., Schatz B.R., Wulf W.A. "An Overview of the Production Quality Compiler-Compiler Project" CMU-CS-79-105.Google Scholar
  15. [Lev 81]
    Leverett B.W. "Register Allocation in Optimizing Compilers" CMU-CS-81-103.Google Scholar
  16. [Lun 83]
    Lunell H. "Code Generator writing systems" Software Systems Research Center S-581 83 Linköping, Sweden.Google Scholar
  17. [Mad 83]
    Madelaine E. "Système d'aide à la preuve de compilateurs" Th`ese de 3ème cycle, Université de Paris VII, Septembre 1983.Google Scholar
  18. [MRS 86]
    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

Copyright information

© Springer-Verlag Berlin Heidelberg 1987

Authors and Affiliations

  • Annie Despland
    • 2
  • Monique Mazaud
    • 1
  • Raymond Rakotozafy
    • 2
  1. 1.I.N.R.I.A. Domaine de VoluceauLe Chesnay CedexFrance
  2. 2.Université d'OrléansOrléans CedexFrance and I.N.R.I.A.

Personalised recommendations