[llvm-commits] [llvm] r97965 - in /llvm/trunk/docs/tutorial: OCamlLangImpl3.html OCamlLangImpl4.html OCamlLangImpl5.html OCamlLangImpl6.html OCamlLangImpl7.html

Erick Tryzelaar idadesub at users.sourceforge.net
Mon Mar 8 11:32:18 PST 2010


Author: erickt
Date: Mon Mar  8 13:32:18 2010
New Revision: 97965

URL: http://llvm.org/viewvc/llvm-project?rev=97965&view=rev
Log:
Update the OCaml Kaleidoscope tutorial.

Modified:
    llvm/trunk/docs/tutorial/OCamlLangImpl3.html
    llvm/trunk/docs/tutorial/OCamlLangImpl4.html
    llvm/trunk/docs/tutorial/OCamlLangImpl5.html
    llvm/trunk/docs/tutorial/OCamlLangImpl6.html
    llvm/trunk/docs/tutorial/OCamlLangImpl7.html

Modified: llvm/trunk/docs/tutorial/OCamlLangImpl3.html
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/tutorial/OCamlLangImpl3.html?rev=97965&r1=97964&r2=97965&view=diff
==============================================================================
--- llvm/trunk/docs/tutorial/OCamlLangImpl3.html (original)
+++ llvm/trunk/docs/tutorial/OCamlLangImpl3.html Mon Mar  8 13:32:18 2010
@@ -98,6 +98,7 @@
 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
+let double_type = double_type context
 </pre>
 </div>
 
@@ -389,7 +390,7 @@
 <div class="doc_code">
 <pre>
       (* Create a new basic block to start insertion into. *)
-      let bb = append_block "entry" the_function in
+      let bb = append_block context "entry" the_function in
       position_at_end bb builder;
 
       try
@@ -903,6 +904,7 @@
 let the_module = create_module context "my cool jit"
 let builder = builder context
 let named_values:(string, llvalue) Hashtbl.t = Hashtbl.create 10
+let double_type = double_type context
 
 let rec codegen_expr = function
   | Ast.Number n -> const_float double_type n
@@ -974,7 +976,7 @@
       let the_function = codegen_proto proto in
 
       (* Create a new basic block to start insertion into. *)
-      let bb = append_block "entry" the_function in
+      let bb = append_block context "entry" the_function in
       position_at_end bb builder;
 
       try

Modified: llvm/trunk/docs/tutorial/OCamlLangImpl4.html
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/tutorial/OCamlLangImpl4.html?rev=97965&r1=97964&r2=97965&view=diff
==============================================================================
--- llvm/trunk/docs/tutorial/OCamlLangImpl4.html (original)
+++ llvm/trunk/docs/tutorial/OCamlLangImpl4.html Mon Mar  8 13:32:18 2010
@@ -186,9 +186,8 @@
 <div class="doc_code">
 <pre>
   (* Create the JIT. *)
-  let the_module_provider = ModuleProvider.create Codegen.the_module in
-  let the_execution_engine = ExecutionEngine.create the_module_provider in
-  let the_fpm = PassManager.create_function the_module_provider in
+  let the_execution_engine = ExecutionEngine.create Codegen.the_module in
+  let the_fpm = PassManager.create_function Codegen.the_module in
 
   (* Set up the optimizer pipeline.  Start with registering info about how the
    * target lays out data structures. *)
@@ -213,18 +212,11 @@
 </pre>
 </div>
 
-<p>This code defines two values, an <tt>Llvm.llmoduleprovider</tt> and a
-<tt>Llvm.PassManager.t</tt>.  The former is basically a wrapper around our
-<tt>Llvm.llmodule</tt> that the <tt>Llvm.PassManager.t</tt> requires.  It
-provides certain flexibility that we're not going to take advantage of here,
-so I won't dive into any details about it.</p>
-
 <p>The meat of the matter here, is the definition of "<tt>the_fpm</tt>".  It
-requires a pointer to the <tt>the_module</tt> (through the
-<tt>the_module_provider</tt>) to construct itself.  Once it is set up, we use a
-series of "add" calls to add a bunch of LLVM passes.  The first pass is
-basically boilerplate, it adds a pass so that later optimizations know how the
-data structures in the program are laid out.  The
+requires a pointer to the <tt>the_module</tt> to construct itself.  Once it is
+set up, we use a series of "add" calls to add a bunch of LLVM passes.  The
+first pass is basically boilerplate, it adds a pass so that later optimizations
+know how the data structures in the program are laid out.  The
 "<tt>the_execution_engine</tt>" variable is related to the JIT, which we will
 get to in the next section.</p>
 
@@ -320,8 +312,7 @@
 let main () =
   ...
   <b>(* Create the JIT. *)
-  let the_module_provider = ModuleProvider.create Codegen.the_module in
-  let the_execution_engine = ExecutionEngine.create the_module_provider in</b>
+  let the_execution_engine = ExecutionEngine.create Codegen.the_module in</b>
   ...
 </pre>
 </div>
@@ -351,7 +342,7 @@
               the_execution_engine in
 
             print_string "Evaluated to ";
-            print_float (GenericValue.as_float double_type result);
+            print_float (GenericValue.as_float Codegen.double_type result);
             print_newline ();
 </pre>
 </div>
@@ -796,6 +787,7 @@
 let the_module = create_module context "my cool jit"
 let builder = builder context
 let named_values:(string, llvalue) Hashtbl.t = Hashtbl.create 10
+let double_type = double_type context
 
 let rec codegen_expr = function
   | Ast.Number n -> const_float double_type n
@@ -867,7 +859,7 @@
       let the_function = codegen_proto proto in
 
       (* Create a new basic block to start insertion into. *)
-      let bb = append_block "entry" the_function in
+      let bb = append_block context "entry" the_function in
       position_at_end bb builder;
 
       try
@@ -932,7 +924,7 @@
               the_execution_engine in
 
             print_string "Evaluated to ";
-            print_float (GenericValue.as_float double_type result);
+            print_float (GenericValue.as_float Codegen.double_type result);
             print_newline ();
         with Stream.Error s | Codegen.Error s ->
           (* Skip token for error recovery. *)
@@ -971,16 +963,15 @@
   let stream = Lexer.lex (Stream.of_channel stdin) in
 
   (* Create the JIT. *)
-  let the_module_provider = ModuleProvider.create Codegen.the_module in
-  let the_execution_engine = ExecutionEngine.create the_module_provider in
-  let the_fpm = PassManager.create_function the_module_provider in
+  let the_execution_engine = ExecutionEngine.create Codegen.the_module in
+  let the_fpm = PassManager.create_function Codegen.the_module in
 
   (* Set up the optimizer pipeline.  Start with registering info about how the
    * target lays out data structures. *)
   TargetData.add (ExecutionEngine.target_data the_execution_engine) the_fpm;
 
   (* Do simple "peephole" optimizations and bit-twiddling optzn. *)
-  add_instruction_combining the_fpm;
+  add_instruction_combination the_fpm;
 
   (* reassociate expressions. *)
   add_reassociation the_fpm;

Modified: llvm/trunk/docs/tutorial/OCamlLangImpl5.html
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/tutorial/OCamlLangImpl5.html?rev=97965&r1=97964&r2=97965&view=diff
==============================================================================
--- llvm/trunk/docs/tutorial/OCamlLangImpl5.html (original)
+++ llvm/trunk/docs/tutorial/OCamlLangImpl5.html Mon Mar  8 13:32:18 2010
@@ -364,7 +364,7 @@
       let start_bb = insertion_block builder in
       let the_function = block_parent start_bb in
 
-      let then_bb = append_block "then" the_function in
+      let then_bb = append_block context "then" the_function in
       position_at_end then_bb builder;
 </pre>
 </div>
@@ -417,7 +417,7 @@
 <div class="doc_code">
 <pre>
       (* Emit 'else' value. *)
-      let else_bb = append_block "else" the_function in
+      let else_bb = append_block context "else" the_function in
       position_at_end else_bb builder;
       let else_val = codegen_expr else_ in
 
@@ -433,7 +433,7 @@
 <div class="doc_code">
 <pre>
       (* Emit merge block. *)
-      let merge_bb = append_block "ifcont" the_function in
+      let merge_bb = append_block context "ifcont" the_function in
       position_at_end merge_bb builder;
       let incoming = [(then_val, new_then_bb); (else_val, new_else_bb)] in
       let phi = build_phi incoming "iftmp" builder in
@@ -704,7 +704,7 @@
        * block. *)
       let preheader_bb = insertion_block builder in
       let the_function = block_parent preheader_bb in
-      let loop_bb = append_block "loop" the_function in
+      let loop_bb = append_block context "loop" the_function in
 
       (* Insert an explicit fall through from the current block to the
        * loop_bb. *)
@@ -804,7 +804,7 @@
 <pre>
       (* Create the "after loop" block and insert it. *)
       let loop_end_bb = insertion_block builder in
-      let after_bb = append_block "afterloop" the_function in
+      let after_bb = append_block context "afterloop" the_function in
 
       (* Insert the conditional branch into the end of loop_end_bb. *)
       ignore (build_cond_br end_cond loop_bb after_bb builder);
@@ -1204,6 +1204,7 @@
 let the_module = create_module context "my cool jit"
 let builder = builder context
 let named_values:(string, llvalue) Hashtbl.t = Hashtbl.create 10
+let double_type = double_type context
 
 let rec codegen_expr = function
   | Ast.Number n -> const_float double_type n
@@ -1250,7 +1251,7 @@
       let start_bb = insertion_block builder in
       let the_function = block_parent start_bb in
 
-      let then_bb = append_block "then" the_function in
+      let then_bb = append_block context "then" the_function in
 
       (* Emit 'then' value. *)
       position_at_end then_bb builder;
@@ -1262,7 +1263,7 @@
       let new_then_bb = insertion_block builder in
 
       (* Emit 'else' value. *)
-      let else_bb = append_block "else" the_function in
+      let else_bb = append_block context "else" the_function in
       position_at_end else_bb builder;
       let else_val = codegen_expr else_ in
 
@@ -1271,7 +1272,7 @@
       let new_else_bb = insertion_block builder in
 
       (* Emit merge block. *)
-      let merge_bb = append_block "ifcont" the_function in
+      let merge_bb = append_block context "ifcont" the_function in
       position_at_end merge_bb builder;
       let incoming = [(then_val, new_then_bb); (else_val, new_else_bb)] in
       let phi = build_phi incoming "iftmp" builder in
@@ -1297,7 +1298,7 @@
        * block. *)
       let preheader_bb = insertion_block builder in
       let the_function = block_parent preheader_bb in
-      let loop_bb = append_block "loop" the_function in
+      let loop_bb = append_block context "loop" the_function in
 
       (* Insert an explicit fall through from the current block to the
        * loop_bb. *)
@@ -1341,7 +1342,7 @@
 
       (* Create the "after loop" block and insert it. *)
       let loop_end_bb = insertion_block builder in
-      let after_bb = append_block "afterloop" the_function in
+      let after_bb = append_block context "afterloop" the_function in
 
       (* Insert the conditional branch into the end of loop_end_bb. *)
       ignore (build_cond_br end_cond loop_bb after_bb builder);
@@ -1397,7 +1398,7 @@
       let the_function = codegen_proto proto in
 
       (* Create a new basic block to start insertion into. *)
-      let bb = append_block "entry" the_function in
+      let bb = append_block context "entry" the_function in
       position_at_end bb builder;
 
       try
@@ -1462,7 +1463,7 @@
               the_execution_engine in
 
             print_string "Evaluated to ";
-            print_float (GenericValue.as_float double_type result);
+            print_float (GenericValue.as_float Codegen.double_type result);
             print_newline ();
         with Stream.Error s | Codegen.Error s ->
           (* Skip token for error recovery. *)
@@ -1501,16 +1502,15 @@
   let stream = Lexer.lex (Stream.of_channel stdin) in
 
   (* Create the JIT. *)
-  let the_module_provider = ModuleProvider.create Codegen.the_module in
-  let the_execution_engine = ExecutionEngine.create the_module_provider in
-  let the_fpm = PassManager.create_function the_module_provider in
+  let the_execution_engine = ExecutionEngine.create Codegen.the_module in
+  let the_fpm = PassManager.create_function Codegen.the_module in
 
   (* Set up the optimizer pipeline.  Start with registering info about how the
    * target lays out data structures. *)
   TargetData.add (ExecutionEngine.target_data the_execution_engine) the_fpm;
 
   (* Do simple "peephole" optimizations and bit-twiddling optzn. *)
-  add_instruction_combining the_fpm;
+  add_instruction_combination the_fpm;
 
   (* reassociate expressions. *)
   add_reassociation the_fpm;

Modified: llvm/trunk/docs/tutorial/OCamlLangImpl6.html
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/tutorial/OCamlLangImpl6.html?rev=97965&r1=97964&r2=97965&view=diff
==============================================================================
--- llvm/trunk/docs/tutorial/OCamlLangImpl6.html (original)
+++ llvm/trunk/docs/tutorial/OCamlLangImpl6.html Mon Mar  8 13:32:18 2010
@@ -300,7 +300,7 @@
       end;</b>
 
       (* Create a new basic block to start insertion into. *)
-      let bb = append_block "entry" the_function in
+      let bb = append_block context "entry" the_function in
       position_at_end bb builder;
       ...
 </pre>
@@ -1177,6 +1177,7 @@
 let the_module = create_module context "my cool jit"
 let builder = builder context
 let named_values:(string, llvalue) Hashtbl.t = Hashtbl.create 10
+let double_type = double_type context
 
 let rec codegen_expr = function
   | Ast.Number n -> const_float double_type n
@@ -1241,7 +1242,7 @@
       let start_bb = insertion_block builder in
       let the_function = block_parent start_bb in
 
-      let then_bb = append_block "then" the_function in
+      let then_bb = append_block context "then" the_function in
 
       (* Emit 'then' value. *)
       position_at_end then_bb builder;
@@ -1253,7 +1254,7 @@
       let new_then_bb = insertion_block builder in
 
       (* Emit 'else' value. *)
-      let else_bb = append_block "else" the_function in
+      let else_bb = append_block context "else" the_function in
       position_at_end else_bb builder;
       let else_val = codegen_expr else_ in
 
@@ -1262,7 +1263,7 @@
       let new_else_bb = insertion_block builder in
 
       (* Emit merge block. *)
-      let merge_bb = append_block "ifcont" the_function in
+      let merge_bb = append_block context "ifcont" the_function in
       position_at_end merge_bb builder;
       let incoming = [(then_val, new_then_bb); (else_val, new_else_bb)] in
       let phi = build_phi incoming "iftmp" builder in
@@ -1288,7 +1289,7 @@
        * block. *)
       let preheader_bb = insertion_block builder in
       let the_function = block_parent preheader_bb in
-      let loop_bb = append_block "loop" the_function in
+      let loop_bb = append_block context "loop" the_function in
 
       (* Insert an explicit fall through from the current block to the
        * loop_bb. *)
@@ -1332,7 +1333,7 @@
 
       (* Create the "after loop" block and insert it. *)
       let loop_end_bb = insertion_block builder in
-      let after_bb = append_block "afterloop" the_function in
+      let after_bb = append_block context "afterloop" the_function in
 
       (* Insert the conditional branch into the end of loop_end_bb. *)
       ignore (build_cond_br end_cond loop_bb after_bb builder);
@@ -1396,7 +1397,7 @@
       end;
 
       (* Create a new basic block to start insertion into. *)
-      let bb = append_block "entry" the_function in
+      let bb = append_block context "entry" the_function in
       position_at_end bb builder;
 
       try
@@ -1461,7 +1462,7 @@
               the_execution_engine in
 
             print_string "Evaluated to ";
-            print_float (GenericValue.as_float double_type result);
+            print_float (GenericValue.as_float Codegen.double_type result);
             print_newline ();
         with Stream.Error s | Codegen.Error s ->
           (* Skip token for error recovery. *)
@@ -1500,16 +1501,15 @@
   let stream = Lexer.lex (Stream.of_channel stdin) in
 
   (* Create the JIT. *)
-  let the_module_provider = ModuleProvider.create Codegen.the_module in
-  let the_execution_engine = ExecutionEngine.create the_module_provider in
-  let the_fpm = PassManager.create_function the_module_provider in
+  let the_execution_engine = ExecutionEngine.create Codegen.the_module in
+  let the_fpm = PassManager.create_function Codegen.the_module in
 
   (* Set up the optimizer pipeline.  Start with registering info about how the
    * target lays out data structures. *)
   TargetData.add (ExecutionEngine.target_data the_execution_engine) the_fpm;
 
   (* Do simple "peephole" optimizations and bit-twiddling optzn. *)
-  add_instruction_combining the_fpm;
+  add_instruction_combination the_fpm;
 
   (* reassociate expressions. *)
   add_reassociation the_fpm;

Modified: llvm/trunk/docs/tutorial/OCamlLangImpl7.html
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/tutorial/OCamlLangImpl7.html?rev=97965&r1=97964&r2=97965&view=diff
==============================================================================
--- llvm/trunk/docs/tutorial/OCamlLangImpl7.html (original)
+++ llvm/trunk/docs/tutorial/OCamlLangImpl7.html Mon Mar  8 13:32:18 2010
@@ -543,7 +543,7 @@
 <pre>
 let main () =
   ...
-  let the_fpm = PassManager.create_function the_module_provider in
+  let the_fpm = PassManager.create_function Codegen.the_module in
 
   (* Set up the optimizer pipeline.  Start with registering info about how the
    * target lays out data structures. *)
@@ -1388,6 +1388,7 @@
 let the_module = create_module context "my cool jit"
 let builder = builder context
 let named_values:(string, llvalue) Hashtbl.t = Hashtbl.create 10
+let double_type = double_type context
 
 (* Create an alloca instruction in the entry block of the function. This
  * is used for mutable variables etc. *)
@@ -1482,7 +1483,7 @@
       let start_bb = insertion_block builder in
       let the_function = block_parent start_bb in
 
-      let then_bb = append_block "then" the_function in
+      let then_bb = append_block context "then" the_function in
 
       (* Emit 'then' value. *)
       position_at_end then_bb builder;
@@ -1494,7 +1495,7 @@
       let new_then_bb = insertion_block builder in
 
       (* Emit 'else' value. *)
-      let else_bb = append_block "else" the_function in
+      let else_bb = append_block context "else" the_function in
       position_at_end else_bb builder;
       let else_val = codegen_expr else_ in
 
@@ -1503,7 +1504,7 @@
       let new_else_bb = insertion_block builder in
 
       (* Emit merge block. *)
-      let merge_bb = append_block "ifcont" the_function in
+      let merge_bb = append_block context "ifcont" the_function in
       position_at_end merge_bb builder;
       let incoming = [(then_val, new_then_bb); (else_val, new_else_bb)] in
       let phi = build_phi incoming "iftmp" builder in
@@ -1555,7 +1556,7 @@
 
       (* Make the new basic block for the loop header, inserting after current
        * block. *)
-      let loop_bb = append_block "loop" the_function in
+      let loop_bb = append_block context "loop" the_function in
 
       (* Insert an explicit fall through from the current block to the
        * loop_bb. *)
@@ -1599,7 +1600,7 @@
       let end_cond = build_fcmp Fcmp.One end_cond zero "loopcond" builder in
 
       (* Create the "after loop" block and insert it. *)
-      let after_bb = append_block "afterloop" the_function in
+      let after_bb = append_block context "afterloop" the_function in
 
       (* Insert the conditional branch into the end of loop_end_bb. *)
       ignore (build_cond_br end_cond loop_bb after_bb builder);
@@ -1723,7 +1724,7 @@
       end;
 
       (* Create a new basic block to start insertion into. *)
-      let bb = append_block "entry" the_function in
+      let bb = append_block context "entry" the_function in
       position_at_end bb builder;
 
       try
@@ -1791,7 +1792,7 @@
               the_execution_engine in
 
             print_string "Evaluated to ";
-            print_float (GenericValue.as_float double_type result);
+            print_float (GenericValue.as_float Codegen.double_type result);
             print_newline ();
         with Stream.Error s | Codegen.Error s ->
           (* Skip token for error recovery. *)
@@ -1831,9 +1832,8 @@
   let stream = Lexer.lex (Stream.of_channel stdin) in
 
   (* Create the JIT. *)
-  let the_module_provider = ModuleProvider.create Codegen.the_module in
-  let the_execution_engine = ExecutionEngine.create the_module_provider in
-  let the_fpm = PassManager.create_function the_module_provider in
+  let the_execution_engine = ExecutionEngine.create Codegen.the_module in
+  let the_fpm = PassManager.create_function Codegen.the_module in
 
   (* Set up the optimizer pipeline.  Start with registering info about how the
    * target lays out data structures. *)
@@ -1843,7 +1843,7 @@
   add_memory_to_register_promotion the_fpm;
 
   (* Do simple "peephole" optimizations and bit-twiddling optzn. *)
-  add_instruction_combining the_fpm;
+  add_instruction_combination the_fpm;
 
   (* reassociate expressions. *)
   add_reassociation the_fpm;





More information about the llvm-commits mailing list