llvm.org GIT mirror llvm / 786a43e
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194381 91177308-0d34-0410-b5e6-96231b3b80d8 Peter Zotov 7 years ago
5 changed file(s) with 9 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
2323
2424 external byte_order : DataLayout.t -> Endian.t = "llvm_byte_order"
2525 external pointer_size : DataLayout.t -> int = "llvm_pointer_size"
26 external intptr_type : DataLayout.t -> Llvm.lltype = "llvm_intptr_type"
26 external intptr_type : DataLayout.t -> Llvm.llcontext -> Llvm.lltype
27 = "llvm_intptr_type"
2728 external size_in_bits : DataLayout.t -> Llvm.lltype -> Int64.t
2829 = "llvm_size_in_bits"
2930 external store_size : DataLayout.t -> Llvm.lltype -> Int64.t = "llvm_store_size"
4646
4747 (** Returns the integer type that is the same size as a pointer on a target.
4848 See the method llvm::DataLayout::getIntPtrType. *)
49 external intptr_type : DataLayout.t -> Llvm.lltype = "llvm_intptr_type"
49 external intptr_type : DataLayout.t -> Llvm.llcontext -> Llvm.lltype
50 = "llvm_intptr_type"
5051
5152 (** Computes the size of a type in bits for a target.
5253 See the method llvm::DataLayout::getTypeSizeInBits. *)
7171 return Val_int(LLVMPointerSize(TargetData_val(TD)));
7272 }
7373
74 /* DataLayout.t -> int -> Llvm.lltype */
75 CAMLprim LLVMTypeRef llvm_intptr_type(value TD) {
76 return LLVMIntPtrType(TargetData_val(TD));;
74 /* DataLayout.t -> Llvm.llcontext -> Llvm.lltype */
75 CAMLprim LLVMTypeRef llvm_intptr_type(value TD, LLVMContextRef C) {
76 return LLVMIntPtrTypeInContext(C, TargetData_val(TD));;
7777 }
7878
7979 /* DataLayout.t -> Llvm.lltype -> Int64.t */
106106 let td = ExecutionEngine.target_data ee in
107107
108108 (* Demonstrate that a garbage pointer wasn't returned. *)
109 let ty = intptr_type td in
109 let ty = intptr_type td context in
110110 if ty != i32_type && ty != i64_type then bomb "target_data did not work";
111111
112112 (* dispose *)
4545 assert_equal (DataLayout.as_string td) layout;
4646 assert_equal (byte_order td) Endian.Little;
4747 assert_equal (pointer_size td) 4;
48 assert_equal (intptr_type td) i32_type;
48 assert_equal (intptr_type td context) i32_type;
4949 assert_equal (size_in_bits td sty) (Int64.of_int 96);
5050 assert_equal (store_size td sty) (Int64.of_int 12);
5151 assert_equal (abi_size td sty) (Int64.of_int 12);