Displaying 20 results from an estimated 20 matches for "i32_type".
2007 Nov 26
1
[LLVMdev] How to declare and use sprintf
...y 26 November 2007 00:40, Gordon Henriksen wrote:
> The type you want is:
>
> let sp = pointer_type i8_type in
> var_arg_function_type sp [| sp; sp |]
Awesome stuff. Here is my most elegant Fibonacci 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 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 r...
2007 Nov 25
2
[LLVMdev] How to declare and use sprintf
...eclarations 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.ffconsultancy.com/products/?e
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 Oct 02
2
[LLVMdev] OCaml Install Error
...4 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
i32_type [| |] false) m in
let at_entry = bu...
2007 Dec 23
0
[LLVMdev] Ocaml JIT example
...oworld" 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 = getelementptr [14 x i8]* @greeting, i32 0, i32 0 *)
le...
2007 Nov 26
0
[LLVMdev] Fibonacci example in OCaml
...ck 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 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,...
2007 Oct 19
0
[LLVMdev] OCaml Install Error
...!\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
> i32_type [| |] fal...
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:
>>
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
2014 Oct 02
3
[LLVMdev] How do I update Ocaml debug info? (was Re: [llvm] r218914 - DI: Fold constant arguments into a single MDString)
-llvm-commits, +llvmdev
> On Oct 2, 2014, at 2:57 PM, Duncan P. N. Exon Smith <dexonsmith at apple.com> wrote:
>
> Author: dexonsmith
> Date: Thu Oct 2 16:56:57 2014
> New Revision: 218914
>
> URL: http://llvm.org/viewvc/llvm-project?rev=218914&view=rev
> Log:
> DI: Fold constant arguments into a single MDString
>
> This patch addresses the first
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
2018 Jan 09
2
Passing Array base address/pointer to runtime function in LLVM IR
Hello LLVM,
I am a beginner in LLVM
My Goal is to initialize array element with random values.
llvm::Type *i32_type = llvm::IntegerType::getInt32Ty(allocaInst->getContext());
llvm::Value *value = llvm::ConstantInt::get(i32_type, numberOfElement);
args.push_back(getElementPtrInst->getPointerOperand());
args.push_back(value);
callInst = llvm::CallInst::Create(runtimeInitializeRandomIntegerArr...
2007 Nov 27
1
[LLVMdev] Fibonacci example in OCaml
...represent multiple-level inheritance? Value -> GlobalValue ->
GlobalVariable, say.
> 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
Types are not enums, they're first-class objects.
> and int_predicate and real_predicate would become overlapping sum
> types, e.g. `ugt is valid for both.
These variant types were set up to have a 1:1 correspondence with the C
++ enums, and I'd prefer to keep that. There's...
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 27
0
[LLVMdev] Fibonacci example in OCaml
...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_predicate and real_predicate would become
overlapping sum types, e.g. `ugt is valid for both. I'd also rather see
structuring than identifier bloat, e.g.:
module Linkage = struct
type linkage =
[ `External
| `Link_once
| `Weak
| `Appending
| `Internal...
2007 Nov 25
5
[LLVMdev] OCaml
...e 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]* @greeting, i32 0, i32 0 *)
let zero = const_int...
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 Sep 14
0
[LLVMdev] C interface
...make_pointer_type
> (make_struct_type [| make_integer_type 1;
> make_integer_type 3;
> i8_type ();
> i32_type () |] false);
> make_pointer_type
> (make_array_type (make_opaque_type ()) 4) |]
> false) in
>
> (* string_of_lltype is implemented in ocaml, so the info on stdout
> shows that make_*_type isn...
2007 Sep 12
7
[LLVMdev] C interface
...make_pointer_type
(make_struct_type [| make_integer_type 1;
make_integer_type 3;
i8_type ();
i32_type () |]
false);
make_pointer_type
(make_array_type (make_opaque_type ())
4) |]
false) in
(* string_of_lltype is implemented in ocaml, so the info on stdout
shows that make_*_type isn't a write-once/re...