search for: opaque_type

Displaying 6 results from an estimated 6 matches for "opaque_type".

Did you mean: opaque_ty
2007 Nov 26
2
[LLVMdev] Fibonacci example in OCaml
...oes have some nice properties), you'll want to slam every 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...
2008 May 11
0
[LLVMdev] Python bindings available.
...LVMTypeHandleRef is really a pointer to a heap-allocated 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 h...
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
2007 Nov 26
0
[LLVMdev] Fibonacci example in OCaml
...operties), you'll want to slam every 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. >...
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