ocaml/C bindings: type->isSized()
authorTorok Edwin <edwintorok@gmail.com>
Thu, 6 Oct 2011 12:13:28 +0000 (12:13 +0000)
committerTorok Edwin <edwintorok@gmail.com>
Thu, 6 Oct 2011 12:13:28 +0000 (12:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141288 91177308-0d34-0410-b5e6-96231b3b80d8

bindings/ocaml/llvm/llvm.ml
bindings/ocaml/llvm/llvm.mli
bindings/ocaml/llvm/llvm_ocaml.c
include/llvm-c/Core.h
lib/VMCore/Core.cpp

index 1f7809e4daee0af3e8851f999b0800a886709e94..eaca48d8496ff90d361588ac0e90856f7d3fe33e 100644 (file)
@@ -167,6 +167,7 @@ external set_module_inline_asm : llmodule -> string -> unit
 (*===-- Types -------------------------------------------------------------===*)
 external classify_type : lltype -> TypeKind.t = "llvm_classify_type"
 external type_context : lltype -> llcontext = "llvm_type_context"
+external type_is_sized : lltype -> bool = "llvm_type_is_sized"
 
 (*--... Operations on integer types ........................................--*)
 external i1_type : llcontext -> lltype = "llvm_i1_type"
index a5e5c850d6f5901bc3ba7c8dfb1dc3d651e82282..0f1e9a901707c198b70a9245d89c8655194e7ba6 100644 (file)
@@ -271,6 +271,11 @@ val set_module_inline_asm : llmodule -> string -> unit
     See the method [llvm::Type::getTypeID]. *)
 val classify_type : lltype -> TypeKind.t
 
+(** [type_is_sized ty] returns whether the type has a size or not.
+ * If it doesn't then it is not safe to call the [TargetData::] methods on it.
+ * *)
+val type_is_sized : lltype -> bool
+
 (** [type_context ty] returns the {!llcontext} corresponding to the type [ty].
     See the method [llvm::Type::getContext]. *)
 val type_context : lltype -> llcontext
index d6849cd193a544da70ecbdae00d734969f4a8729..dd8cb16544ca01c1ec2d4126d9649f670977af72 100644 (file)
@@ -172,6 +172,10 @@ CAMLprim value llvm_classify_type(LLVMTypeRef Ty) {
   return Val_int(LLVMGetTypeKind(Ty));
 }
 
+CAMLprim value llvm_type_is_sized(LLVMTypeRef Ty) {
+    return Val_bool(LLVMTypeIsSized(Ty));
+}
+
 /* lltype -> llcontext */
 CAMLprim LLVMContextRef llvm_type_context(LLVMTypeRef Ty) {
   return LLVMGetTypeContext(Ty);
index 83fe89cbcfe0ba0d73b0451be53d92bc6b72125d..4d14af1e06bd0eb13bfe57daf277a7841c3daf9d 100644 (file)
@@ -355,6 +355,7 @@ LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M);
 
 /** See llvm::LLVMTypeKind::getTypeID. */
 LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty);
+LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty);
 
 /** See llvm::LLVMType::getContext. */
 LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty);
index b8d2baf1e36ffb21c118ce178823185053a576a7..a6f04aed1f3212576c3df6e5cbe7378b4d33f965 100644 (file)
@@ -167,6 +167,11 @@ LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty) {
   }
 }
 
+LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty)
+{
+    return unwrap(Ty)->isSized();
+}
+
 LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty) {
   return wrap(&unwrap(Ty)->getContext());
 }