Add support for getting a null pointer.
authorErick Tryzelaar <idadesub@users.sourceforge.net>
Sun, 28 Feb 2010 09:46:27 +0000 (09:46 +0000)
committerErick Tryzelaar <idadesub@users.sourceforge.net>
Sun, 28 Feb 2010 09:46:27 +0000 (09:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97380 91177308-0d34-0410-b5e6-96231b3b80d8

bindings/ocaml/llvm/llvm.ml
bindings/ocaml/llvm/llvm.mli
test/Bindings/Ocaml/vmcore.ml

index c317a804585b182a729b38a0f42dd3058a0e58ef..7c72a61abc4d6bb81a72d2f8ec8387388e45ecc6 100644 (file)
@@ -246,6 +246,7 @@ external replace_all_uses_with : llvalue -> llvalue -> unit
 external is_constant : llvalue -> bool = "llvm_is_constant"
 external const_null : lltype -> llvalue = "LLVMConstNull"
 external const_all_ones : (*int|vec*)lltype -> llvalue = "LLVMConstAllOnes"
 external is_constant : llvalue -> bool = "llvm_is_constant"
 external const_null : lltype -> llvalue = "LLVMConstNull"
 external const_all_ones : (*int|vec*)lltype -> llvalue = "LLVMConstAllOnes"
+external const_pointer_null : lltype -> llvalue = "LLVMConstPointerNull"
 external undef : lltype -> llvalue = "LLVMGetUndef"
 external is_null : llvalue -> bool = "llvm_is_null"
 external is_undef : llvalue -> bool = "llvm_is_undef"
 external undef : lltype -> llvalue = "LLVMGetUndef"
 external is_null : llvalue -> bool = "llvm_is_null"
 external is_undef : llvalue -> bool = "llvm_is_undef"
index 7025f85b54202066c90a84c3cbaa97338360ace3..9f919809433c56a321cf0ecd5f585eec5684c0ad 100644 (file)
@@ -527,6 +527,10 @@ external const_null : lltype -> llvalue = "LLVMConstNull"
     [ty]. See the method [llvm::Constant::getAllOnesValue]. *)
 external const_all_ones : (*int|vec*)lltype -> llvalue = "LLVMConstAllOnes"
 
     [ty]. See the method [llvm::Constant::getAllOnesValue]. *)
 external const_all_ones : (*int|vec*)lltype -> llvalue = "LLVMConstAllOnes"
 
+(** [const_pointer_null ty] returns the constant null (zero) pointer of the type
+    [ty]. See the method [llvm::ConstantPointerNull::get]. *)
+external const_pointer_null : lltype -> llvalue = "LLVMConstPointerNull"
+
 (** [undef ty] returns the undefined value of the type [ty].
     See the method [llvm::UndefValue::get]. *)
 external undef : lltype -> llvalue = "LLVMGetUndef"
 (** [undef ty] returns the undefined value of the type [ty].
     See the method [llvm::UndefValue::get]. *)
 external undef : lltype -> llvalue = "LLVMGetUndef"
index 379cde1bf8e005fee2f643b355a029146f40d657..44cdd84ac186e30c1fd37a48df11b4ed6ac4e292 100644 (file)
@@ -315,6 +315,13 @@ let test_constants () =
   group "all ones";
   let c = const_all_ones i64_type in
   ignore (define_global "const_all_ones" c m);
   group "all ones";
   let c = const_all_ones i64_type in
   ignore (define_global "const_all_ones" c m);
+
+  group "pointer null"; begin
+    (* RUN: grep {const_pointer_null = global i64\\* null} < %t.ll
+     *)
+    let c = const_pointer_null (pointer_type i64_type) in
+    ignore (define_global "const_pointer_null" c m);
+  end;
   
   (* RUN: grep {const_undef.*undef} < %t.ll
    *)
   
   (* RUN: grep {const_undef.*undef} < %t.ll
    *)