Displaying 9 results from an estimated 9 matches for "refine_type".
2007 Nov 26
2
[LLVMdev] Fibonacci example in OCaml
...y value to some generic
value type and use lots of bitcasts. The value type is either the
native integer (i32 or i64 depending on target) or a pointer type,
probably the recursive pointer type:
let value_ty =
let temp_ty = opaque_type () in
let h = handle_to_type temp_ty in
refine_type temp_ty (pointer_type temp_ty);
type_of_handle h
Since LLVM does not have an intptr type, you'd need to know your
target and parameterize your codegen accordingly to use the integer
types.
The bitcasts have no runtime cost, and LLVM optimization passes can
simplify them. Your compi...
2008 May 11
0
[LLVMdev] Python bindings available.
...ated PATypeHolder, which is discussed here:
http://llvm.org/docs/ProgrammersManual.html#BuildRecType
The file test/Bindings/Ocaml/vmcore.ml contains this fragment:
(* RUN: grep -v {RecursiveTy.*RecursiveTy} < %t.ll
*)
let ty = opaque_type () in
let th = handle_to_type ty in
refine_type ty (pointer_type ty);
let ty = type_of_handle th in
insist (define_type_name "RecursiveTy" ty m);
insist (ty == element_type ty)
Which constructs %RecursiveType = type %RecursiveType*.
>> Finally, just as the C++ STL has reverse_iterator, it did prove
>> necessary...
2008 May 11
2
[LLVMdev] Python bindings available.
Hi Gordon,
Thanks for your comments.
> > Constant.string(value, dont_null_terminate) -- value is a string
> > Constant.struct(consts, packed) -- a struct, consts is a list of
> > other constants, packed is boolean
>
> I did this in Ocaml initially, but found the boolean constants pretty
> confusing to read in code. I kept asking "What's that random true
2008 Mar 04
1
[LLVMdev] [PATCH] Prefer to use *.opt ocaml executables as they are more efficient.
I noticed that the ocaml compilation isn't using the .opt
executables if they're available. We might gain a slight
optimization in ocaml compile time by optionally using them
with this patch.
---
autoconf/configure.ac | 18 +++++
configure | 195 ++++++++++++++++++++++++++++++++++++++++++------
2 files changed, 188 insertions(+), 25 deletions(-)
-------------- next part
2008 Mar 04
0
[LLVMdev] [PATCH] Cleanup the c and ocaml binding documentation.
...tance of [lltype].
> See the
> - * llvm::Type class.
> + * Each value in the LLVM IR has a type, an instance of
> [LLVMTypeRef]. See the
> + * [llvm::Type] class.
> */
> typedef struct LLVMOpaqueType *LLVMTypeRef;
>
> /**
> - * When building recursive types using [refine_type], [lltype]
> values may become
> - * invalid; use [lltypehandle] to resolve this problem. See the
> - * llvm::AbstractTypeHolder] class.
> + * When building recursive types using [LLVMRefineType],
> [LLVMTypeRef] values may become
> + * invalid; use [LLVMTypeHandleRef] to reso...
2007 Nov 26
0
[LLVMdev] Fibonacci example in OCaml
...e type and use lots of bitcasts. The value type is either the
> native integer (i32 or i64 depending on target) or a pointer type,
> probably the recursive pointer type:
>
> let value_ty =
> let temp_ty = opaque_type () in
> let h = handle_to_type temp_ty in
> refine_type temp_ty (pointer_type temp_ty);
> type_of_handle h
>
> Since LLVM does not have an intptr type, you'd need to know your
> target and parameterize your codegen accordingly to use the integer
> types.
>
> The bitcasts have no runtime cost, and LLVM optimization passes ca...
2008 Mar 04
1
[LLVMdev] [PATCH] Cleanup the c and ocaml binding documentation.
---
bindings/ocaml/llvm/llvm.ml | 2 +-
bindings/ocaml/llvm/llvm.mli | 2 +-
bindings/ocaml/llvm/llvm_ocaml.c | 2 +-
include/llvm-c/Core.h | 32 +++++++++++++++++++-------------
4 files changed, 22 insertions(+), 16 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 316a84e85ed2363551149e65a227c8e7c8192624.diff
Type:
2007 Nov 26
0
[LLVMdev] Fibonacci example in OCaml
Here is a complete 104-line native code compiler for a tiny subset of OCaml
that is expressive enough to compile an external Fibonacci program:
type expr =
| Int of int
| Var of string
| BinOp of [ `Add | `Sub | `Leq ] * expr * expr
| If of expr * expr * expr
| Apply of expr * expr
type defn =
| LetRec of string * string * expr
open Camlp4.PreCast;;
let expr = Gram.Entry.mk
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