Skip to main content

Code Generation

  • Chapter
  • First Online:
  • 3417 Accesses

Part of the book series: Undergraduate Topics in Computer Science ((UTICS))

Abstract

The process of code generation takes the intermediate representation generated by the front-end of the compiler, with or without any optimisation performed by the machine-independent optimisation phase, and generates code for the target machine. Writing a good code generator is not easy. There is too much choice. There will be infinitely many ways of translating a piece of intermediate code to target code and there is no standard way of performing the translation. The translation process can involve many different algorithms, all interacting with each other in seemingly unpredictable ways, and ensuring that the code produced is of sufficiently high quality is something of a challenge.

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

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   49.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

References

  1. Payne M, Bhandarkar D (1980) VAX floating point: a solid foundation for numerical computation. SIGARCH Comput Archit News 8(4):22–33

    Article  Google Scholar 

  2. Lindholm T, Yellin F (1997) The Java virtual machine specification. The Java series, Addison-Wesley, Reading

    Google Scholar 

  3. Appel AW (2004) Modern compiler implementation in C. Cambridge University Press, Cambridge

    MATH  Google Scholar 

  4. Aho AV, Lam MS, Sethi R, Ullman JD (2007) Compilers – principles, techniques and tools, 2nd edn. Pearson Education, Upper Saddle River

    MATH  Google Scholar 

  5. Muchnick SS (1997) Advanced compiler design and implementation. Morgan Kaufmann Publishers, San Francisco

    Google Scholar 

  6. Cooper KD, Torczon L (2011) Engineering a compiler, 2nd edn. Morgan Kaufmann, San Francisco

    MATH  Google Scholar 

  7. Mittal S, Vetter JS (2015) A survey of CPU-GPU heterogeneous computing techniques. ACM Comput Surv 47(4):69:1–69:35

    Article  Google Scholar 

  8. McKeeman WM (1965) Peephole optimization. Commun ACM 8(7):443–444

    Article  Google Scholar 

  9. Davidson JW, Fraser CW (1984) Automatic generation of peephole optimizations. In: Proceedings of the ACM SIGPLAN ’84 symposium on compiler construction, Montreal, Canada, pp 111–116. Published as ACM SIGPLAN Notices 19:6

    Google Scholar 

  10. Davidson JW, Fraser CW (1980) The design and application of a retargetable peephole optimizer. ACM Trans Program Lang Syst 2(2):191–202

    Article  Google Scholar 

  11. Tanenbaum AS, van Staveren H, Stevenson JW (1982) Using peephole optimization on intermediate code. ACM Trans Program Lang Syst 4(1):21–36

    Article  MATH  Google Scholar 

  12. Massalin H (1987) Superoptimizer – A look at the smallest program. In: Proceedings of the second international conference on architectural support for programming languages and operating systems (ASPLOS-II), Palo Alto, California, pp 122–126. Published as ACM SIGPLAN Notices 22:10

    Google Scholar 

  13. Glanville RS, Graham SL (1978) A new method for compiler code generation. In: Proceedings of the 5th annual symposium on principles of programming languages, pp 231–240

    Google Scholar 

  14. Ganapathi M, Fischer CN (1982) Description-driven code generation using attribute grammars. In: Proceedings of the 9th annual symposium on principles of programming languages, Albuquerque, NM, pp 108–119

    Google Scholar 

  15. Ganapathi M, Fischer CN (1984) Attributed linear intermediate representations for retargetable code generators. Softw Pract Exp 14(4):347–364

    Article  Google Scholar 

  16. Ganapathi M, Fischer CN (1985) Affix grammar driven code generation. ACM Trans Program Lang Syst 7(4):560–599

    Article  Google Scholar 

  17. Aho AV, Ganapathi M, Tjiang SWK (1989) Code generation using tree matching and dynamic programming. ACM Trans Program Lang Syst 11(4):491–516

    Article  Google Scholar 

  18. Pelegri-Llopart E, Graham SL (1988) Optimal code generation for expression trees: an application of BURS theory. In: Proceedings of the 15th annual symposium on principles of programming languages, pp 294–308

    Google Scholar 

  19. Fraser CW, Henry RR, Proebsting TA (1992) BURG – fast optimal instruction selection and tree parsing. ACM SIGPLAN Not 27(4):68–76

    Article  Google Scholar 

  20. Blindell GH (2016) Instruction selection: principles, methods, and applications. Springer, Switzerland

    Book  Google Scholar 

  21. Chaitin GJ (1982) Register allocation and spilling via graph coloring. In: Proceedings of the ACM SIGPLAN ’82 symposium on compiler construction, Boston, Mass, pp 98–105. Published as ACM SIGPLAN Notices 17:6

    Google Scholar 

  22. Chow FC, Hennessy JL (1990) The priority-based coloring approach to register allocation. ACM Trans Program Lang Syst 12(4):501–536

    Article  Google Scholar 

  23. Mogensen TÆ (2011) Introduction to compiler design. Undergraduate topics in computer science. Springer, Berlin

    Google Scholar 

  24. Naur P (1963) Revised report on the algorithmic language ALGOL 60. Commun ACM 6(1):1–17

    Article  MathSciNet  MATH  Google Scholar 

  25. Sethi R (1989) Programming languages – concepts and constructs. Addison-Wesley Publishing Company, Reading

    MATH  Google Scholar 

  26. Free Software Foundation (2016) GCC, the GNU compiler collection. https://gcc.gnu.org/

  27. Davidson JW, Fraser CW (1984) Register allocation and exhaustive peephole optimization. Softw Pract Exp 14(9):857–865

    Article  Google Scholar 

  28. Granlund T, Kenner R (1992) Eliminating branches using a superoptimizer and the GNU C compiler. In: Proceedings of the ACM SIGPLAN ’92 conference on programming language design and implementation. San Francisco, California, pp 341–352, June 1992

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Des Watson .

Rights and permissions

Reprints and permissions

Copyright information

© 2017 Springer International Publishing AG

About this chapter

Cite this chapter

Watson, D. (2017). Code Generation. In: A Practical Approach to Compiler Construction. Undergraduate Topics in Computer Science. Springer, Cham. https://doi.org/10.1007/978-3-319-52789-5_8

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-52789-5_8

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-52787-1

  • Online ISBN: 978-3-319-52789-5

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics