blob: 3d3f81e438584b6d3271f3fe25c7694c56059246 [file] [log] [blame]
Lang Hames88cec7f2016-05-27 22:34:56 +00001===========================================================================
2Building a JIT: Extreme Laziness - Using Compile Callbacks to JIT from ASTs
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 4 Introduction
13======================
14
15Welcome to Chapter 4 of the "Building an ORC-based JIT in LLVM" tutorial. This
16chapter introduces the Compile Callbacks and Indirect Stubs APIs and shows how
17they can be used to replace the CompileOnDemand layer from
18`Chapter 3 <BuildingAJIT3.html>`_ with a custom lazy-JITing scheme that JITs
19directly from Kaleidoscope ASTs.
20
21**To be done:**
22
23**(1) Describe the drawbacks of JITing from IR (have to compile to IR first,
24which reduces the benefits of laziness).**
25
26**(2) Describe CompileCallbackManagers and IndirectStubManagers in detail.**
27
28**(3) Run through the implementation of addFunctionAST.**
29
30Full Code Listing
31=================
32
33Here is the complete code listing for our running example that JITs lazily from
34Kaleidoscope ASTS. To build this example, use:
35
36.. code-block:: bash
37
38 # Compile
Don Hinton4b93d232017-09-17 00:24:43 +000039 clang++ -g toy.cpp `llvm-config --cxxflags --ldflags --system-libs --libs core orcjit native` -O3 -o toy
Lang Hames88cec7f2016-05-27 22:34:56 +000040 # Run
41 ./toy
42
43Here is the code:
44
45.. literalinclude:: ../../examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h
46 :language: c++
47
48`Next: Remote-JITing -- Process-isolation and laziness-at-a-distance <BuildingAJIT5.html>`_