aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bindings/ocaml/llvm/llvm.ml1
-rw-r--r--bindings/ocaml/llvm/llvm.mli4
-rw-r--r--test/Bindings/Ocaml/vmcore.ml7
3 files changed, 12 insertions, 0 deletions
diff --git a/bindings/ocaml/llvm/llvm.ml b/bindings/ocaml/llvm/llvm.ml
index c317a80458..7c72a61abc 100644
--- a/bindings/ocaml/llvm/llvm.ml
+++ b/bindings/ocaml/llvm/llvm.ml
@@ -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 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"
diff --git a/bindings/ocaml/llvm/llvm.mli b/bindings/ocaml/llvm/llvm.mli
index 7025f85b54..9f91980943 100644
--- a/bindings/ocaml/llvm/llvm.mli
+++ b/bindings/ocaml/llvm/llvm.mli
@@ -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"
+(** [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"
diff --git a/test/Bindings/Ocaml/vmcore.ml b/test/Bindings/Ocaml/vmcore.ml
index 379cde1bf8..44cdd84ac1 100644
--- a/test/Bindings/Ocaml/vmcore.ml
+++ b/test/Bindings/Ocaml/vmcore.ml
@@ -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 "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
*)