Displaying 2 results from an estimated 2 matches for "camlp4oof".
2007 Nov 26
0
[LLVMdev] Fibonacci example in OCaml
...ret (int 0) bb |> ignore;
if not (Llvm_bitwriter.write_bitcode_file m filename) then exit 1;
dispose_module m
let () = match Sys.argv with
| [|_; filename|] -> main filename
| _ as a -> Printf.eprintf "Usage: %s <file>\n" a.(0)
Compile with:
$ ocamlc -dtypes -pp camlp4oof -I +camlp4 dynlink.cma camlp4lib.cma -cc
g++ -I /usr/local/lib/ocaml/ llvm.cma llvm_bitwriter.cma minml.ml -o minml
Run on the following fib.ml file:
let rec fib n =
if n <= 2 then 1 else
fib(n-1) + fib(n-2)
do fib 40
with:
$ ./minml run.bc
$ llc -f run.bc -o run.s &&...
2007 Nov 25
2
[LLVMdev] Fibonacci example in OCaml
Here's my translation of the Fibonacci example into OCaml:
open Printf
open Llvm
let build_fib m =
let fibf =
define_function "fib" (function_type i32_type [| i32_type |]) m in
let bb = builder_at_end (entry_block fibf) in
let one = const_int i32_type 1 and two = const_int i32_type 2 in
let argx = param fibf 0 in
set_value_name "AnArg" argx;
let