Lines Matching refs:JIT
2 Building a JIT: Starting out with KaleidoscopeJIT
11 Welcome to Chapter 1 of the "Building an ORC-based JIT in LLVM" tutorial. This
12 tutorial runs through the implementation of a JIT compiler using LLVM's
19 The goal of this tutorial is to introduce you to LLVM's ORC JIT APIs, show how
21 them to build a custom JIT that is suited to your use-case.
26 introduce some of the basic concepts of the ORC JIT APIs, including the
32 - `Chapter #3 <BuildingAJIT3.html>`_: Further extend the JIT by adding a
35 - `Chapter #4 <BuildingAJIT4.html>`_: Improve the laziness of our JIT by
41 a remote process with reduced privileges using the JIT Remote APIs.
43 To provide input for our JIT we will use the Kaleidoscope REPL from
46 code for that chapter and replace it with optimization support in our JIT class
49 Finally, a word on API generations: ORC is the 3rd generation of LLVM JIT API.
50 It was preceded by MCJIT, and before that by the (now deleted) legacy JIT.
56 JIT API Basics
59 The purpose of a JIT compiler is to compile code "on-the-fly" as it is needed,
61 compiler does. To support that aim our initial, bare-bones JIT API will be:
66 symbols (functions or variables) that have been added to the JIT.
67 3. void removeModule(Handle H) -- Remove a module from the JIT, releasing any
76 JIT J;
84 theme. Behind the API we will refine the implementation of the JIT to add
87 added to the JIT.
96 input for our JIT: Each time the user enters an expression the REPL will add a
97 new IR module containing the code for that expression to the JIT. If the
99 use the findSymbol method of our JIT class find and execute the code for the
102 of this tutorial we'll modify the REPL to enable new interactions with our JIT
104 the implementation of our JIT itself.
143 Passes: they wrap up useful JIT utilities behind an easy to compose interface.
144 The first layer, ObjectLinkingLayer, is the foundation of our JIT: it takes
146 them executable. This JIT-on-top-of-a-linker design was introduced in MCJIT,
155 ModuleHandle. This is the handle type that will be returned from our JIT's
187 // Lambda 1: Look back into the JIT itself to find symbols that are part of
207 // Add the set to the JIT with the resolver we created above and a newly
214 Now we come to the first of our JIT API methods: addModule. This method is
215 responsible for adding IR to the JIT and making it available for execution. In
216 this initial implementation of our JIT we will make our modules "available for
218 immediately compile them. In later chapters we will teach our JIT to be lazier
224 memory manager will be responsible for managing the memory allocated to JIT'd
226 tables (if the JIT'd code uses exceptions). For our memory manager we will use
229 resolver, is more interesting for us. It exists to tell the JIT where to look
232 functions outside the JIT and calls to functions defined in other modules that
233 have already been added to the JIT. It may seem as though modules added to the
234 JIT should "know about one another" by default, but since we would still have to
235 supply a symbol resolver for references to code outside the JIT it turns out to
238 process. Should we search for definitions within the JIT first, then fall back
240 available and only JIT code if we don't already have an available
257 tutorial we will adopt the following simple scheme: All modules added to the JIT
260 just search for JIT'd code by calling the CompileLayer's findSymbol method. If
261 we don't find a symbol in the JIT itself we'll fall back to our second lambda,
265 these paths the JIT will refuse to accept our module, returning a "symbol not
269 JIT. We do this by calling the CompileLayer's addModuleSet method [4]_. Since
289 Now that we can add code to our JIT, we need a way to find the symbols we've
292 for first. The reason for this is that the ORC JIT components use mangled
299 We now come to the last method in our JIT API: removeModule. This method is
308 JIT class is destructed, if the haven't been freed before then.
310 This brings us to the end of Chapter 1 of Building a JIT. You now have a basic
311 but fully functioning JIT stack that you can use to take LLVM IR and make it
312 executable within the context of your JIT process. In the next chapter we'll
313 look at how to extend this JIT to produce better quality code, and in the