Displaying 5 results from an estimated 5 matches for "build_icmp".
2007 Nov 26
1
[LLVMdev] How to declare and use sprintf
...y 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 |> ignore;
return retb (int 1);
let apply f xs = build_call f xs "apply" recurseb in
let ( +: ) f g = build_add f g "add" recurseb in
let ( -: ) f g = build_sub f g "sub"...
2007 Nov 25
2
[LLVMdev] Fibonacci example in OCaml
...pe 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);
ignore(build_ret one retb);
let sub = build_sub argx one "arg" recurseb in
let callfibx1 = build_call fibf [|sub|] "fibx1" recurseb in
let sub = build_sub argx two "...
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 26
0
[LLVMdev] Fibonacci example in OCaml
...; const_int i32_type n, state
| Var x -> find state x, state
| BinOp(op, f, g) ->
let f, state = expr state f in
let g, state = expr state g in
let build, name = match op with
| `Add -> build_add, "add"
| `Sub -> build_sub, "sub"
| `Leq -> build_icmp Icmp_sle, "leq" in
build f g name (bb state), state
| If(p, t, f) ->
let t_blk = new_block state "pass" in
let f_blk = new_block state "fail" in
let k_blk = new_block state "cont" in
let cond, state = expr state p in
b...