blob: e2f71bdc2007a298c581853ba9c0ea70b537a503 [file] [log] [blame]
Lang Hames42c9b592016-05-26 21:17:06 +00001=============================================
2Building a JIT: Per-function Lazy Compilation
3=============================================
4
5.. contents::
6 :local:
7
8**This tutorial is under active development. It is incomplete and details may
9change frequently.** Nonetheless we invite you to try it out as it stands, and
10we welcome any feedback.
11
12Chapter 3 Introduction
13======================
14
15Welcome to Chapter 3 of the "Building an ORC-based JIT in LLVM" tutorial. This
16chapter discusses lazy JITing and shows you how to enable it by adding an ORC
17CompileOnDemand layer the JIT from `Chapter 2 <BuildingAJIT2.html>`_.
18
19**To be done:**
20
21**(1) Describe lazy function-at-a-time JITing and how it differs from the kind
22of eager module-at-a-time JITing that we've been doing so far. **
23
24**(2) Discuss CompileCallbackManagers and IndirectStubManagers.**
25
26**(3) Describe CompileOnDemandLayer (automates these components and builds stubs
27and lazy compilation callbacks for IR) and how to add it to the JIT. **
28
29Full Code Listing
30=================
31
32Here is the complete code listing for our running example with a CompileOnDemand
33layer added to enable lazy function-at-a-time compilation. To build this example, use:
34
35.. code-block:: bash
36
37 # Compile
38 clang++ -g toy.cpp `llvm-config --cxxflags --ldflags --system-libs --libs core orc native` -O3 -o toy
39 # Run
40 ./toy
41
42Here is the code:
43
44.. literalinclude:: ../../examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h
45 :language: c++
46
47`Next: Extreme Laziness -- Using Compile Callbacks to JIT directly from ASTs <BuildingAJIT4.html>`_