[PATCH] [review request] OCaml bindings: implement Llvm_target.{qualified_, }intptr_type_in_context

Peter Zotov whitequark at whitequark.org
Sat Oct 12 23:08:30 PDT 2013


  Changed argument order to reflect changes in D1912.

Hi sylvestre.ledru,

http://llvm-reviews.chandlerc.com/D1925

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D1925?vs=4880&id=4888#toc

Files:
  bindings/ocaml/target/llvm_target.ml
  bindings/ocaml/target/llvm_target.mli
  bindings/ocaml/target/target_ocaml.c

Index: bindings/ocaml/target/llvm_target.ml
===================================================================
--- bindings/ocaml/target/llvm_target.ml
+++ bindings/ocaml/target/llvm_target.ml
@@ -26,10 +26,14 @@
 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 = "LLVMIntPtrType"
+external intptr_type_in_context : Llvm.llcontext -> DataLayout.t -> Llvm.lltype
+                                = "llvm_intptr_type_in_context"
 external qualified_pointer_size : DataLayout.t -> int -> int
                                 = "llvm_qualified_pointer_size"
 external qualified_intptr_type : DataLayout.t -> int -> Llvm.lltype
                                = "llvm_qualified_intptr_type"
+external qualified_intptr_type_in_context : Llvm.llcontext -> DataLayout.t -> int -> Llvm.lltype
+                               = "llvm_qualified_intptr_type_in_context"
 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"
Index: bindings/ocaml/target/llvm_target.mli
===================================================================
--- bindings/ocaml/target/llvm_target.mli
+++ bindings/ocaml/target/llvm_target.mli
@@ -53,6 +53,11 @@
     See the method llvm::DataLayout::getIntPtrType. *)
 external intptr_type : DataLayout.t -> Llvm.lltype = "LLVMIntPtrType"
 
+(** Returns the integer type that is the same size as a pointer on a target.
+    See the method llvm::DataLayout::getIntPtrType. *)
+external intptr_type_in_context : Llvm.llcontext -> DataLayout.t -> Llvm.lltype
+                                = "llvm_intptr_type_in_context"
+
 (** Returns the pointer size in bytes for a target in a given address
     space.
     See the method llvm::DataLayout::getPointerSize. *)
@@ -65,6 +70,13 @@
 external qualified_intptr_type : DataLayout.t -> int -> Llvm.lltype
                                = "llvm_qualified_intptr_type"
 
+(** Returns the integer type that is the same size as a pointer on a target
+    in a given address space.
+    See the method llvm::DataLayout::getIntPtrType. *)
+external qualified_intptr_type_in_context
+            : Llvm.llcontext -> DataLayout.t -> int -> Llvm.lltype
+            = "llvm_qualified_intptr_type_in_context"
+
 (** Computes the size of a type in bytes for a target.
     See the method llvm::DataLayout::getTypeSizeInBits. *)
 external size_in_bits : DataLayout.t -> Llvm.lltype -> Int64.t
Index: bindings/ocaml/target/target_ocaml.c
===================================================================
--- bindings/ocaml/target/target_ocaml.c
+++ bindings/ocaml/target/target_ocaml.c
@@ -53,6 +53,11 @@
   return Val_int(LLVMPointerSize(TD));
 }
 
+/* DataLayout.t -> Llvm.llcontext -> int */
+CAMLprim LLVMTypeRef llvm_intptr_type_in_context(LLVMContextRef C, value TD) {
+  return LLVMIntPtrTypeInContext(C, TargetData_val(TD));
+}
+
 /* DataLayout.t -> int -> int */
 CAMLprim value llvm_qualified_pointer_size(LLVMTargetDataRef TD, value AS) {
   return Val_int(LLVMPointerSizeForAS(TD, Int_val(AS)));
@@ -63,6 +68,12 @@
   return LLVMIntPtrTypeForAS(TD, Int_val(AS));
 }
 
+/* DataLayout.t -> Llvm.llcontext -> int -> Llvm.lltype */
+CAMLprim LLVMTypeRef llvm_qualified_intptr_type_in_context(LLVMContextRef C, value TD,
+                                                           value AS) {
+  return LLVMIntPtrTypeForASInContext(C, TargetData_val(TD), Int_val(AS));
+}
+
 /* DataLayout.t -> Llvm.lltype -> Int64.t */
 CAMLprim value llvm_size_in_bits(LLVMTargetDataRef TD, LLVMTypeRef Ty) {
   return caml_copy_int64(LLVMSizeOfTypeInBits(TD, Ty));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1925.2.patch
Type: text/x-patch
Size: 3786 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131012/3b682685/attachment.bin>


More information about the llvm-commits mailing list