Chapter 3. Extending the Frontend and Adding JIT Support

In this chapter, we will cover the following recipes:

  • Handling decision making paradigms – if/then/else constructs
  • Generating code for loops
  • Handling user-defined operators – binary operators
  • Handling user-defined operators – unary operators
  • Adding JIT support

Introduction

In the last chapter, the basics of the frontend component for a language were defined. This included defining tokens for different types of expressions, writing a lexer to tokenize a stream of input, chalking out a skeleton for the abstract syntax tree of various expressions, writing a parser, and generating code for the language. Also, how various optimizations can be hooked to the frontend was explained.

A language is more powerful ...

Get LLVM Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.