LLVM Cookbook

More Information
  • Introduction to LLVM modular design and LLVM tools
  • Write a frontend for a language
  • Add JIT support and use frontends for different languages
  • Learn about the LLVM Pass infrastructure and the LLVM Pass Manager
  • Create analyses and transform optimization passes
  • Build a LLVM TOY backend from scratch
  • Optimize the code at SelectionDAG level and allocate registers to variables

LLVM is a compiler framework with libraries that provides a modern source-and target-independent optimizer, along with a code generator.

This book not only explains the effective use of the compiler infrastructure that LLVM provides, but also helps you implement it in one of your projects. You start with a simple task to get you up-and-running with LLVM, followed by learning the process of writing a frontend for a language, which includes writing a lexer, a parser, and generating IR code. You will then see how to implement optimizations at different levels, generate target-independent code, and then map this generated code to a backend. Finally, you will look into the functionalities that the LLVM infrastructure provides, such as exception handling, LLVM Utility Passes, using sanitizers, the garbage collector, and how we can use these in our projects.

  • Write a frontend for any language to generate LLVM IR
  • Create optimization passes to optimize the IR code using LLVM Pass Infrastructure and Pass Manager
  • Design and implement structures for highly-optimized compilers using LLVM, through detailed step-by-step recipes
Page Count 296
Course Length 8 hours 52 minutes
ISBN 9781785285981
Date Of Publication 29 May 2015


Mayur Pandey

Mayur Pandey is a professional software engineer and open source enthusiast focused on compiler development and tools. He is an active contributor to the LLVM open source community. He has been a part of the compiler team for the Tizen project and has hands-on experience of other proprietary compilers.

He has earned a bachelor's degree in Information Technology from Motilal Nehru National Institute of Technology, Allahabad, India. Currently, he lives in Bengaluru, India.

Suyog Sarda

Suyog Sarda is a professional software engineer and an open source enthusiast. He focuses on compiler development and compiler tools. He is an active contributor to the LLVM open source community. Suyog was also involved in code performance improvements for the ARM and X86 architectures. He has been a part of the compiler team for the Tizen project. His interest in compiler development lies more in code optimization and vectorization.

Previously, he has authored a book on LLVM, titled LLVM Cookbook by Packt Publishing.

Apart from compilers, Suyog is also interested in Linux Kernel Development. He has published a technical paper titled Secure Co-resident Virtualization in Multicore Systems by VM Pinning and Page Coloring at the IEEE Proceedings of the 2012 International Conference on Cloud Computing, Technologies, Applications, and Management at the Birla Institute of Technology, Dubai. He has earned a bachelor's degree in computer technology from the College of Engineering, Pune, India.