Displaying 15 results from an estimated 15 matches for "declare_function".
2007 Nov 25
2
[LLVMdev] How to declare and use sprintf
...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 i8_type) [| pointer_type i8_type;
pointer_type i8_type;
i32_type |]) m in
which gives:
declare i8* @sprintf(i8*, i8*, i32)
What is the correct way to do this?
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
http://www.ffcon...
2007 Oct 02
2
[LLVMdev] OCaml Install Error
...create_module filename in
(* @greeting = global [14 x i8] c"Hello, world!\00" *)
let greeting = define_global "greeting" (make_string_constant
"Hello, world!" true) m in
(* declare i32 @puts(i8*) *)
let puts = declare_function "puts" (make_function_type i32_type [|
make_pointer_type i8_type |]
false) m in
(* define i32 @main() {
entry: *)
let main = define_function "main" (make_function_type
i...
2007 Nov 25
2
[LLVMdev] Fibonacci example in OCaml
...x 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 main filename =
let m = create_module filename in
let puts =
declare_function "puts"
(function_type i32_type [|pointer_type i8_type|]) m in
let fib = build_fib m in
let main = define_function "main" (function_type i32_type [| |]) m in
let at_entry = builder_at_end (entry_block main) in
let n = build_call fib [| const_int i32_type 4...
2007 Dec 23
0
[LLVMdev] Ocaml JIT example
...se jit
let build_module =
let m = create_module "jithelloworld" in
(* @greeting = global [14 x i8] c"Hello, world!\00" *)
let greeting = define_global "greeting" (const_stringz "Hello,
world!") 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 =...
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 26
1
[LLVMdev] How to declare and use sprintf
...ot;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 filename in
let string = pointer_type i8_type in
let printf =
declare_function "printf" (var_arg_function_type i32_type [|string|]) m
in
let main =
define_function "main" (function_type i32_type [| |]) m
|> entry_block
|> builder_at_end in
let str s = define_global "buf" (const_stringz s) m in
let int_spec = build...
2007 Oct 19
0
[LLVMdev] OCaml Install Error
...(* @greeting = global [14 x i8] c"Hello, world!\00" *)
> let greeting = define_global "greeting" (make_string_constant
> "Hello, world!" true)
> m in
>
> (* declare i32 @puts(i8*) *)
> let puts = declare_function "puts" (make_function_type i32_type [|
> make_pointer_type i8_type
> |] false) m in
>
> (* define i32 @main() {
> entry: *)
> let main = define_function "main" (make_function_type
>...
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
...te classes given tags. (doxygen is your friend
here.) Try mocking up the type system for the concrete types
GlobalVariable, Function, ConstantFP and ConstantInt; the abstract
types GlobalValue, Value and Constant; and the functions
set_value_name, linkage, declare_global, set_initializer,
declare_function, entry_block, param, const_float, const_int, and
const_array. That should be a reasonable survey.
> We can't go letting haskell beat us now, can we?
To truly compete with Bryan's Haskell bindings in terms of type
safety, you'll need to go beyond preventing the cast macros in th...
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
0
[LLVMdev] Fibonacci example in OCaml
...t body, state =
expr { fn = fn; blk = entry_block fn; vars = vars' } body in
build_ret body (bb state) |> ignore;
(f, fn) :: vars
let int n = const_int i32_type n
let main filename =
let m = create_module filename in
let string = pointer_type i8_type in
let print =
declare_function "printf" (var_arg_function_type i32_type [|string|]) m in
let main = define_function "main" (function_type i32_type [| |]) m in
let blk = entry_block main in
let bb = builder_at_end blk in
let str s = define_global "buf" (const_stringz s) m in
let int_spec...
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
...f
open Llvm
let main filename =
let m = create_module filename in
(* @greeting = global [14 x i8] c"Hello, world!\00" *)
let greeting =
define_global "greeting" (const_string "Hello, world!\000") 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]* @g...