Kaleidoscope: Adding JIT and Optimizer Support

Written by Chris Lattner

Part 4 Introduction

Welcome to part 4 of the "Implementing a language with LLVM" tutorial.

Code Generation setup

In order to generate LLVM IR, we want some simple setup to get started. First, we define virtual codegen methods in each AST class:

/// ExprAST - Base class for all expression nodes.
class ExprAST {
public:
  virtual ~ExprAST() {}
  virtual Value *Codegen() = 0;
};

/// NumberExprAST - Expression class for numeric literals like "1.0".
class NumberExprAST : public ExprAST {
  double Val;
public:
  explicit NumberExprAST(double val) : Val(val) {}
  virtual Value *Codegen();
};
...

Valid CSS! Valid HTML 4.01! Chris Lattner
The LLVM Compiler Infrastructure
Last modified: $Date: 2007-10-17 11:05:13 -0700 (Wed, 17 Oct 2007) $