1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

[OCaml] Accept context explicitly in Llvm_target functions

Llvm_target.intptr_type used to implicitly use global context. As
none of other functions in OCaml bindings do, it is changed to
accept context explicitly.

llvm-svn: 194381
This commit is contained in:
Peter Zotov 2013-11-11 14:47:20 +00:00
parent 4625440ac9
commit 7456a45c87
5 changed files with 9 additions and 7 deletions

View File

@ -24,7 +24,8 @@ end
external byte_order : DataLayout.t -> Endian.t = "llvm_byte_order"
external pointer_size : DataLayout.t -> int = "llvm_pointer_size"
external intptr_type : DataLayout.t -> Llvm.lltype = "llvm_intptr_type"
external intptr_type : DataLayout.t -> Llvm.llcontext -> Llvm.lltype
= "llvm_intptr_type"
external size_in_bits : DataLayout.t -> Llvm.lltype -> Int64.t
= "llvm_size_in_bits"
external store_size : DataLayout.t -> Llvm.lltype -> Int64.t = "llvm_store_size"

View File

@ -47,7 +47,8 @@ external pointer_size : DataLayout.t -> int = "llvm_pointer_size"
(** Returns the integer type that is the same size as a pointer on a target.
See the method llvm::DataLayout::getIntPtrType. *)
external intptr_type : DataLayout.t -> Llvm.lltype = "llvm_intptr_type"
external intptr_type : DataLayout.t -> Llvm.llcontext -> Llvm.lltype
= "llvm_intptr_type"
(** Computes the size of a type in bits for a target.
See the method llvm::DataLayout::getTypeSizeInBits. *)

View File

@ -72,9 +72,9 @@ CAMLprim value llvm_pointer_size(value TD) {
return Val_int(LLVMPointerSize(TargetData_val(TD)));
}
/* DataLayout.t -> int -> Llvm.lltype */
CAMLprim LLVMTypeRef llvm_intptr_type(value TD) {
return LLVMIntPtrType(TargetData_val(TD));;
/* DataLayout.t -> Llvm.llcontext -> Llvm.lltype */
CAMLprim LLVMTypeRef llvm_intptr_type(value TD, LLVMContextRef C) {
return LLVMIntPtrTypeInContext(C, TargetData_val(TD));;
}
/* DataLayout.t -> Llvm.lltype -> Int64.t */

View File

@ -107,7 +107,7 @@ let test_executionengine () =
let td = ExecutionEngine.target_data ee in
(* Demonstrate that a garbage pointer wasn't returned. *)
let ty = intptr_type td in
let ty = intptr_type td context in
if ty != i32_type && ty != i64_type then bomb "target_data did not work";
(* dispose *)

View File

@ -46,7 +46,7 @@ let test_target_data () =
assert_equal (DataLayout.as_string td) layout;
assert_equal (byte_order td) Endian.Little;
assert_equal (pointer_size td) 4;
assert_equal (intptr_type td) i32_type;
assert_equal (intptr_type td context) i32_type;
assert_equal (size_in_bits td sty) (Int64.of_int 96);
assert_equal (store_size td sty) (Int64.of_int 12);
assert_equal (abi_size td sty) (Int64.of_int 12);