Displaying 20 results from an estimated 23 matches for "entry_block".
2007 Nov 26
1
[LLVMdev] How to declare and use sprintf
...bonacci 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 "cond" bb i...
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 "recurse" fi...
2005 Apr 11
2
[LLVMdev] JIT and array pointers
...nge buff[0] to 2
Value *c0 = ConstantUInt::get (Type::UIntTy, 0);
Value *c2 = ConstantUInt::get (Type::UIntTy, 2);
Module *m = new Module ("test_module");
Function *f = m->getOrInsertFunction ("test_function", Type::VoidTy,
0);
BasicBlock *b = new BasicBlock ("entry_block", f);
// Here is the problem.
// I need to get the buff pointer into variable, which I can
// pass to GetElementPtrInst
// Value *pbuff = ??
// -> %pbuff = external global [4096 x uint]
Value *ptr = new GetElementPtrInst (pbuff, c0, c0, "ptr", b);
// -> %ptr = ge...
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
2011 Sep 19
2
[LLVMdev] copy Value object?
...ble" as an alloca'ed stack
> variable that is read/written by loads/stores instead of as an SSA value
> that is defined only once.
>
> For example, instead of adding code that does this:
>
> %y = add %x, 5
> ...
> %z = sub %y, 2
>
> ... you add this:
>
> entry_block:
> %yp = alloca <type of y>
> ...
> %y1 = add %x, 5
> store %y1, %yp
> ...
> %y2 = load %yp
> %z = sub %y2, 2
>
> The second version of the code allows the "variable" stored into the
> alloca'ed memory to never have been initialized o...
2011 Sep 19
0
[LLVMdev] copy Value object?
...requirement, what you should do is add the "variable" as an alloca'ed
stack variable that is read/written by loads/stores instead of as an SSA
value that is defined only once.
For example, instead of adding code that does this:
%y = add %x, 5
...
%z = sub %y, 2
... you add this:
entry_block:
%yp = alloca <type of y>
...
%y1 = add %x, 5
store %y1, %yp
...
%y2 = load %yp
%z = sub %y2, 2
The second version of the code allows the "variable" stored into the
alloca'ed memory to never have been initialized or to be written
multiple times. You...
2005 Apr 11
0
[LLVMdev] JIT and array pointers
...te type, and
insert it into m:
GlobalVariable *BuffGV = new GlobalVariable([4096 x uint], false,
GlobalVariable::ExternalLinkage, 0, "Buff", m);
> Function *f = m->getOrInsertFunction ("test_function", Type::VoidTy,
> 0);
> BasicBlock *b = new BasicBlock ("entry_block", f);
>
> // Here is the problem.
> // I need to get the buff pointer into variable, which I can
> // pass to GetElementPtrInst
> // Value *pbuff = ??
> // -> %pbuff = external global [4096 x uint]
pbuff = BuffGV;
> Value *ptr = new GetElementPtrInst (pbuff,...
2011 Sep 19
2
[LLVMdev] copy Value object?
Is there a easy way to copy a Value object, so it can be used in
multiple instructions without a dominance issue?
2011 Sep 19
0
[LLVMdev] copy Value object?
...iable that is read/written by loads/stores instead of as an SSA value
>> that is defined only once.
>>
>> For example, instead of adding code that does this:
>>
>> %y = add %x, 5
>> ...
>> %z = sub %y, 2
>>
>> ... you add this:
>>
>> entry_block:
>> %yp = alloca<type of y>
>> ...
>> %y1 = add %x, 5
>> store %y1, %yp
>> ...
>> %y2 = load %yp
>> %z = sub %y2, 2
>>
>> The second version of the code allows the "variable" stored into the
>> alloca...
2007 Oct 02
2
[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_call puts [| str |] "" at_entry...
2007 Nov 26
0
[LLVMdev] Fibonacci example in OCaml
...quot;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 = 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_funct...
2007 Dec 23
0
[LLVMdev] Ocaml JIT example
...) *)
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);
(* ret...
2005 Apr 11
0
[LLVMdev] JIT and array pointers
On Mon, 11 Apr 2005, Paul wrote:
> I'm trying to pass an array pointer to my run-time generated module, and
> after a long time of searching for the answer, the only thing I got was
> a headache. Basically I have a few arrays (few megabytes which will
> sometimes be accessed as 8 / 16 / 32 / 64 bit binary / fp values), that
> will be modified by both the generated module, and my
2005 Apr 10
2
[LLVMdev] JIT and array pointers
I'm trying to pass an array pointer to my run-time generated module, and
after a long time of searching for the answer, the only thing I got was
a headache. Basically I have a few arrays (few megabytes which will
sometimes be accessed as 8 / 16 / 32 / 64 bit binary / fp values), that
will be modified by both the generated module, and my main c program, so
I would like to put those into global
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_call puts [|...
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
...ags. (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 the C
binding...
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