search for: builder_at_end

Displaying 13 results from an estimated 13 matches for "builder_at_end".

2007 Nov 26
1
[LLVMdev] How to declare and use sprintf
...most elegant Fibonacci example in OCaml so far: open Llvm let ( |> ) x f = f x let int n = const_int i32_type n let return b x = build_ret x b |> ignore let build_fib m = let ty = function_type i32_type [| i32_type |] in let fibf = define_function "fib" ty m in let bb = builder_at_end (entry_block fibf) in let n = param fibf 0 in let retbb = append_block "return" fibf in let retb = builder_at_end retbb in let recursebb = append_block "recurse" fibf in let recurseb = builder_at_end recursebb in let ( <= ) f g = build_icmp Icmp_sle f g "co...
2007 Nov 26
0
[LLVMdev] How to declare and use sprintf
On Nov 25, 2007, at 18:53, Jon Harrop wrote: > So my Fib program is segfaulting and I'm not sure why. I think it > might be because my declaration and use of sprintf is wrong. > > I notice llvm-gcc produces declarations containing "..." like: > > declare int %printf(sbyte*, ...) > > What is the correct way to do this? The type you want is: let sp =
2007 Nov 25
2
[LLVMdev] How to declare and use sprintf
So my Fib program is segfaulting and I'm not sure why. I think it might be because my declaration and use of sprintf is wrong. I notice llvm-gcc produces declarations containing "..." like: declare int %printf(sbyte*, ...) but I'm not sure how to do this so I've used: let sprintf = declare_function "sprintf" (function_type (pointer_type
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 retbb = append_block "return" fibf in let retb = builder_at_end retbb in let recursebb = append_block "rec...
2007 Oct 02
2
[LLVMdev] OCaml Install Error
...pe [| make_pointer_type i8_type |] false) m in (* define i32 @main() { entry: *) let main = define_function "main" (make_function_type i32_type [| |] false) m in let at_entry = builder_at_end (entry_block main) in (* %tmp = getelementptr [14 x i8]* @greeting, i32 0, i32 0 *) let zero = make_int_constant i32_type 0 false in let str = build_gep greeting [| zero; zero |] "tmp" at_entry in (* call i32 @puts( i8* %tmp ) *) ignore (build_call puts [| str |] "&q...
2007 Nov 26
0
[LLVMdev] Fibonacci example in OCaml
...ib.ml")) with | Loc.Exc_located(loc, e) -> printf "%s at line %d\n" (Printexc.to_string e) (Loc.start_line loc); exit 1 open Llvm let ( |> ) x f = f x type state = { fn: llvalue; blk: llbasicblock; vars: (string * llvalue) list } let bb state = builder_at_end state.blk let new_block state name = append_block name state.fn let find state v = try List.assoc v state.vars with Not_found -> eprintf "Unknown variable %s\n" v; raise Not_found let cont (v, state) dest_blk = build_br dest_blk (bb state) |> ignore; v, state let rec...
2007 Dec 23
0
[LLVMdev] Ocaml JIT example
...e i32 @puts(i8* ) *) let puts = declare_function "puts" (function_type i32_type [| pointer_type i8_type |]) m in (* define i32 @main() { entry: *) let main = define_function "main" (function_type i32_type [| |]) m in let at_entry = builder_at_end (entry_block main) in (* %tmp = getelementptr [14 x i8]* @greeting, i32 0, i32 0 *) let zero = const_int i32_type 0 in let str = build_gep greeting [| zero; zero |] "tmp" at_entry in (* call i32 @puts( i8* %tmp ) *) ignore (build_call puts [| str |] "" at_entry)...
2007 Oct 19
0
[LLVMdev] OCaml Install Error
...make_pointer_type i8_type > |] false) m in > > (* define i32 @main() { > entry: *) > let main = define_function "main" (make_function_type > i32_type [| |] false) m in > let at_entry = builder_at_end (entry_block main) in > > (* %tmp = getelementptr [14 x i8]* @greeting, i32 0, i32 0 *) > let zero = make_int_constant i32_type 0 false in > let str = build_gep greeting [| zero; zero |] "tmp" at_entry in > > (* call i32 @puts( i8* %tmp ) *) > ignore (build_...
2007 Oct 02
0
[LLVMdev] OCaml Install Error
Hi, where can I read more about this? I assume (hope) the lib provides some kind of OCaml bindings? I could not find any trace of it in the 2.1 release source so I guess it's currently SVN only? greetings, Jan On 2. Okt 2007, at 12:22, Gordon Henriksen wrote: > On 2007-10-02, at 03:19, Gordon Henriksen wrote: > >> On Oct 2, 2007, at 00:17, Bill Wendling wrote: >>
2007 Oct 02
4
[LLVMdev] OCaml Install Error
On 2007-10-02, at 03:19, Gordon Henriksen wrote: > On Oct 2, 2007, at 00:17, Bill Wendling wrote: > >> I get this error duing a "make install": >> >> llvm[3]: Installing Debug /usr/local/lib/ocaml/libllvm.a >> install: /usr/local/lib/ocaml/libllvm.a: Permission denied >> make[3]: *** [install-a] Error 71 >> make[2]: *** [install] Error 1
2007 Nov 25
0
[LLVMdev] OCaml
Jon, On 2007-11-24, at 21:58, Jon Harrop wrote: > I just took another look at the LLVM project and it has come along > in leaps and bounds since I last looked. I've been working through > the (awesome!) tutorial and am now really hyped about the project. Excellent! > I am particularly interested in using LLVM to write compilers for > OCaml-like languages in OCaml-like
2007 Nov 25
9
[LLVMdev] OCaml
Hi! I just took another look at the LLVM project and it has come along in leaps and bounds since I last looked. I've been working through the (awesome!) tutorial and am now really hyped about the project. I am particularly interested in using LLVM to write compilers for OCaml-like languages in OCaml-like languages. This requires some core functionality that would be generically useful:
2007 Nov 25
5
[LLVMdev] OCaml
...t;) m in (* declare i32 @puts(i8* ) *) let puts = declare_function "puts" (function_type i32_type [|pointer_type i8_type|]) m in (* define i32 @main() { entry: *) let main = define_function "main" (function_type i32_type [| |]) m in let at_entry = builder_at_end (entry_block main) in (* %tmp = getelementptr [14 x i8]* @greeting, i32 0, i32 0 *) let zero = const_int i32_type 0 in let str = build_gep greeting [| zero; zero |] "tmp" at_entry in (* call i32 @puts( i8* %tmp ) *) ignore (build_call puts [| str |] "" at_entry)...