search for: build_call

Displaying 17 results from an estimated 17 matches for "build_call".

Did you mean: build_all
2007 Nov 26
1
[LLVMdev] How to declare and use sprintf
..._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" recurseb in return recurseb (apply fibf [| n -: int 1 |] +: apply fibf [| n -: int 2 |]); fibf let main filename = let m = create_module fil...
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
...rse" 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 "arg" recurseb in let callfibx2 = build_call fibf [|sub|] "fibx2" recurseb in let sum = build_add callfibx1 callfibx2 "addresult" recurseb in build_ret sum recurseb; fibf let ma...
2007 Oct 02
2
[LLVMdev] OCaml Install Error
...n 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 |] "" at_entry); (* ret void *) ignore (build_ret (make_null i32_type) at_entry); (* write the module to a file *) if not (write_bitcode_file m filename) then exit 1; dispose_module m $ ocamlopt -cc g++ llvm.cmxa llvm_bitwriter.cmxa -o metahelloworld metahe...
2007 Nov 26
0
[LLVMdev] Fibonacci example in OCaml
...blk = t_blk } t) k_blk in let f, state = cont (expr { state with blk = f_blk } f) k_blk in let phi = build_phi [t, t_blk; f, f_blk] "join" (bb state) in phi, state | Apply(f, arg) -> let f, state = expr state f in let arg, state = expr state arg in build_call f [|arg|] "apply" (bb state), state let defn m vars = function | LetRec(f, arg, body) -> let ty = function_type i32_type [| i32_type |] in let fn = define_function f ty m in let vars' = (arg, param fn 0) :: (f, fn) :: vars in let body, state = expr { fn...
2007 Dec 23
0
[LLVMdev] Ocaml JIT example
...ype [| |]) 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); (* ret void *) ignore (build_ret (const_null i32_type) at_entry); (main, m) let _ = let (f, m) = build_module in execute_function f m $ ocamlopt -cc g++ llvm.cmxa llvm_executionengine.cmxa -o jithelloworld jithelloworld.ml $ ./jithelloworl...
2007 Oct 19
0
[LLVMdev] OCaml Install Error
...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 |] "" at_entry); > > (* ret void *) > ignore (build_ret (make_null i32_type) at_entry); > > (* write the module to a file *) > if not (write_bitcode_file m filename) then exit 1; > dispose_module m > > $ ocamlopt -cc g++ llvm.cmxa llvm_bitw...
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: >>
2008 Mar 15
0
[LLVMdev] improving the ocaml binding's type safety
...verify: (* Easy; is encoded in the C++ type system. *) isa<Constant>(x) && isa<Constant>(y) (* Harder; assertions in C++. *) x->getType() == y->getType() x->getType()->isIntOrIntVector() || x->getType()->isFPOrFPVector() I was very impressed that Bryan made build_call statically type check! Still, there are also some problems that I don't think are tractable. Consider param 1 f. Even if the type checker knows the type of f via something like `Function of ('a v -> 'b v -> 'c v) v, I don't think it's possible for the expression...
2007 Nov 27
0
[LLVMdev] Fibonacci example in OCaml
...ngs harder to use. Use phantom types to track the type of each llvalue: type 'a llvalue This could prevent my OCaml code with a function pointer error from compiling. For example, the "define_function" function would return a value of the type: [ `function ] llvalue and the build_call function would require a value of that type, so you could not accidentally pass it an int. I would use polymorphic variants more, particularly for enums and types that are only used once (e.g. "linkage" and "visibility"). So types would be `i32 rather than i32_type and int_p...
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 26
4
[LLVMdev] Fibonacci example in OCaml
On Nov 26, 2007, at 14:18, Jon Harrop wrote: > On Monday 26 November 2007 16:21, Gordon Henriksen wrote: >> > >> Unfortunately, even if the bindings were more strongly typed, it >> would still be structurally possible to build invalid LLVM code, so >> you've just got to take care not to violate the invariants, then >> use the verifier as a
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
2008 Mar 15
4
[LLVMdev] improving the ocaml binding's type safety
I was talking to Gordon on #llvm earlier, and he challenged me with coming up with a way to improve the ocaml binding's type safety. We can't go letting haskell beat us now, can we? I think I got an easy solution with phantom types. For those who don't know what the problem is, the ocaml bindings share one type between whole class branches (like values). This means we need to downcast
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
...ype [| |]) 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); (* ret void *) ignore (build_ret (const_null i32_type) at_entry); (* write the module to a file *) if not (Llvm_bitwriter.write_bitcode_file m filename) then exit 1; dispose_module m let () = match Sys.argv with | [|_; filename|] -> main...