<li><a href="#code">Full Code Listing</a></li>
</ol>
</li>
-<li><a href="LangImpl4.html">Chapter 4</a>: Adding JIT and Optimizer
+<li><a href="OCamlLangImpl4.html">Chapter 4</a>: Adding JIT and Optimizer
Support</li>
</ul>
<pre>
exception Error of string
-let the_module = create_module "my cool jit"
-let builder = builder ()
+let the_module = create_module (global_context ()) "my cool jit"
+let builder = builder (global_context ())
let named_values:(string, llvalue) Hashtbl.t = Hashtbl.create 10
</pre>
</div>
<p>The <tt>Codegen.builder</tt> object is a helper object that makes it easy to
generate LLVM instructions. Instances of the <a
-href="http://llvm.org/doxygen/LLVMBuilder_8h-source.html"><tt>LLVMBuilder</tt></a>
+href="http://llvm.org/doxygen/IRBuilder_8h-source.html"><tt>IRBuilder</tt></a>
class keep track of the current place to insert instructions and has methods to
create new instructions.</p>
constants of <em>A</em>rbitrary <em>P</em>recision). This code basically just
creates and returns a <tt>ConstantFP</tt>. Note that in the LLVM IR
that constants are all uniqued together and shared. For this reason, the API
-uses "the foo::get(..)" idiom instead of "new foo(..)" or "foo::create(..)".</p>
+uses "the foo::get(..)" idiom instead of "new foo(..)" or "foo::Create(..)".</p>
<div class="doc_code">
<pre>
</div>
<p>References to variables are also quite simple using LLVM. In the simple
-version of Kaleidoscope, we assume that the variable has already been emited
+version of Kaleidoscope, we assume that the variable has already been emitted
somewhere and its value is available. In practice, the only values that can be
in the <tt>Codegen.named_values</tt> map are function arguments. This code
simply checks to see that the specified name is in the map (if not, an unknown
</p>
<p>In the example above, the LLVM builder class is starting to show its value.
-LLVMBuilder knows where to insert the newly created instruction, all you have to
+IRBuilder knows where to insert the newly created instruction, all you have to
do is specify what instruction to create (e.g. with <tt>Llvm.create_add</tt>),
which operands to use (<tt>lhs</tt> and <tt>rhs</tt> here) and optionally
provide a name for the generated instruction.</p>
first, we want to allow 'extern'ing a function more than once, as long as the
prototypes for the externs match (since all arguments have the same type, we
just have to check that the number of arguments match). Second, we want to
-allow 'extern'ing a function and then definining a body for it. This is useful
+allow 'extern'ing a function and then defining a body for it. This is useful
when defining mutually recursive functions.</p>
<div class="doc_code">
</div>
<p>Note how the parser turns the top-level expression into anonymous functions
-for us. This will be handy when we add <a href="LangImpl4.html#jit">JIT
+for us. This will be handy when we add <a href="OCamlLangImpl4.html#jit">JIT
support</a> in the next chapter. Also note that the code is very literally
transcribed, no optimizations are being performed. We will
<a href="OCamlLangImpl4.html#trivialconstfold">add optimizations</a> explicitly
each other.</p>
<p>This wraps up the third chapter of the Kaleidoscope tutorial. Up next, we'll
-describe how to <a href="LangImpl4.html">add JIT codegen and optimizer
+describe how to <a href="OCamlLangImpl4.html">add JIT codegen and optimizer
support</a> to this so we can actually start running code!</p>
</div>
exception Error of string
-let the_module = create_module "my cool jit"
-let builder = builder ()
+let context = global_context ()
+let the_module = create_module context "my cool jit"
+let builder = builder context
let named_values:(string, llvalue) Hashtbl.t = Hashtbl.create 10
let rec codegen_expr = function