Automatic retargetable code generation: A new technique

  • Sanjeev Kumar
  • V. M. Malhotra
Session 1 Software Technology
Part of the Lecture Notes in Computer Science book series (LNCS, volume 241)


A new technique for automatic retargetable code generation is presented. This technique is based on the observation that a ‘reduced instruction set’ subset can always be found for a target machine instruction set; the rest of the instructions are seen to be equivalent to sequence of the reduced instruction set instructions. Given a target machine description, a method is presented which partitions it into two: one partition contains the reduced instruction set; the other contains the rest of the instructions, along with corresponding simulation sequences — these simulation sequences are unique with respect to the partition. In view of the above, the code generation problem, more precisely the instruction selection problem, is seen as a sequence of two phases: The first phase generates reduced instruction set code; the second phase finds opportunities for optimization through compaction of sub sequences in the generated code, to complex instructions. The full capability of the target machine can be potentially utilized due to the latter phase. Retargetability is achieved by automatically generating the above phases from the information in the partition. The phases are based on tree-pattern-matching, implemented through LR parsing. The technique has been tested for the MC 68000; simple comparisons show the generated code to be satisfactory.


Code Generation Machine Instruction Machine Code Abstract Syntax Tree Target Machine 
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.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Aho, A.V., and Ullman, J.D. Principles of Compiler Design. Addison-Wesley, Reading, Mass., 1977.Google Scholar
  2. 2.
    Cattel, R.G.G. Automatic Derivation of Code Generators from Machine Descriptions. ACM Trans. Program. Lang. System 2,2 1980, 173–190.Google Scholar
  3. 3.
    Davidson, J.W., and Fraser, C.W. Code Selection Through Object Code Optimization. ACM Trans. Program. Lang. System 6,4 1984, 505–526.Google Scholar
  4. 4.
    Ganapathy, M., and Fischer, C.N. Description Driven Code Generation Using Attribute Grammars. In 9th ACM Symp. Principles of Prog. Lang. 1982.Google Scholar
  5. 5.
    Ganapathy M., Fischer, C.N., and Hennessy, J.L. Retargetable Compiler Code Generation. Computing Surveys 14,4 (1982), 573–592.Google Scholar
  6. 6.
    Glanville, R.S., and Graham, S. A new Method for Compiler Code Generation. In 5th ACM Sump. Principles of Prog. Lang. 1978.Google Scholar
  7. 7.
    Graham, S. Table Driven Code Generation. IEEE Computer 13,8 1980, 25–34.Google Scholar
  8. 8.
    Johnson, S.C. YACC — Yet Another Compiler Compiler. Computing Science TR 32, Bell Labs. 1975.Google Scholar
  9. 9.
    Johnson, S.C. A Portable Compiler: Theory and Practice. In 5th ACM Symp. on Principles of Prog. Lang. 1978.Google Scholar
  10. 10.
    Wulf, W.A. Compiler and Computer Architecture. IEEE Computer Architecture. IEEE Computer 14,7 1981, 41–48.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1986

Authors and Affiliations

  • Sanjeev Kumar
    • 1
  • V. M. Malhotra
    • 1
  1. 1.Dept. of Computer Science and Engg. I.I.T.KanpurIndia

Personalised recommendations