BuildingAJIT4.rst 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. ===========================================================================
  2. Building a JIT: Extreme Laziness - Using Compile Callbacks to JIT from ASTs
  3. ===========================================================================
  4. .. contents::
  5. :local:
  6. **This tutorial is under active development. It is incomplete and details may
  7. change frequently.** Nonetheless we invite you to try it out as it stands, and
  8. we welcome any feedback.
  9. Chapter 4 Introduction
  10. ======================
  11. Welcome to Chapter 4 of the "Building an ORC-based JIT in LLVM" tutorial. This
  12. chapter introduces the Compile Callbacks and Indirect Stubs APIs and shows how
  13. they can be used to replace the CompileOnDemand layer from
  14. `Chapter 3 <BuildingAJIT3.html>`_ with a custom lazy-JITing scheme that JITs
  15. directly from Kaleidoscope ASTs.
  16. **To be done:**
  17. **(1) Describe the drawbacks of JITing from IR (have to compile to IR first,
  18. which reduces the benefits of laziness).**
  19. **(2) Describe CompileCallbackManagers and IndirectStubManagers in detail.**
  20. **(3) Run through the implementation of addFunctionAST.**
  21. Full Code Listing
  22. =================
  23. Here is the complete code listing for our running example that JITs lazily from
  24. Kaleidoscope ASTS. To build this example, use:
  25. .. code-block:: bash
  26. # Compile
  27. clang++ -g toy.cpp `llvm-config --cxxflags --ldflags --system-libs --libs core orcjit native` -O3 -o toy
  28. # Run
  29. ./toy
  30. Here is the code:
  31. .. literalinclude:: ../../examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h
  32. :language: c++
  33. `Next: Remote-JITing -- Process-isolation and laziness-at-a-distance <BuildingAJIT5.html>`_