search for: append_block

Displaying 5 results from an estimated 5 matches for "append_block".

2007 Nov 26
1
[LLVMdev] How to declare and use sprintf
...= 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 "cond" bb in build_cond_br (n <= int 2) retbb recursebb bb |> ign...
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
...et 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 "recurse" fibf in let recurseb = builder_at_end recursebb in let condinst = build_icmp Icmp_sle argx two "cond" bb in ignore(build_cond_br condinst retbb recursebb bb);...
2007 Nov 26
0
[LLVMdev] Fibonacci example in OCaml
...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 expr state = function | Int n -> const_int i3...