diff options
author | Gordon Henriksen <gordonhenriksen@mac.com> | 2007-09-18 18:07:51 +0000 |
---|---|---|
committer | Gordon Henriksen <gordonhenriksen@mac.com> | 2007-09-18 18:07:51 +0000 |
commit | 344be5fbecec9908bab611eafeae0549ba3be6d7 (patch) | |
tree | be1d6313447d5e51529a9e2409b02a2303799e46 /bindings | |
parent | 869b2b2c231e2208e1273e65123393ee06d13611 (diff) |
Tests of the ocaml (and thus C) bindings for constants.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42101 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings')
-rw-r--r-- | bindings/ocaml/llvm/llvm.ml | 6 | ||||
-rw-r--r-- | bindings/ocaml/llvm/llvm.mli | 6 | ||||
-rw-r--r-- | bindings/ocaml/llvm/llvm_ocaml.c | 18 |
3 files changed, 27 insertions, 3 deletions
diff --git a/bindings/ocaml/llvm/llvm.ml b/bindings/ocaml/llvm/llvm.ml index 18a9e2154a..b8a62dcb68 100644 --- a/bindings/ocaml/llvm/llvm.ml +++ b/bindings/ocaml/llvm/llvm.ml @@ -141,14 +141,18 @@ external value_name : llvalue -> string = "llvm_value_name" external set_value_name : string -> llvalue -> unit = "llvm_set_value_name" (*--... Operations on constants of (mostly) any type .......................--*) +external is_constant : llvalue -> bool = "llvm_is_constant" external make_null : lltype -> llvalue = "llvm_make_null" -external make_all_ones : lltype -> llvalue = "llvm_make_all_ones" +external make_all_ones : (*int|vec*)lltype -> llvalue = "llvm_make_all_ones" external make_undef : lltype -> llvalue = "llvm_make_undef" external is_null : llvalue -> bool = "llvm_is_null" +external is_undef : llvalue -> bool = "llvm_is_undef" (*--... Operations on scalar constants .....................................--*) external make_int_constant : lltype -> int -> bool -> llvalue = "llvm_make_int_constant" +external make_int64_constant : lltype -> Int64.t -> bool -> llvalue + = "llvm_make_int64_constant" external make_real_constant : lltype -> float -> llvalue = "llvm_make_real_constant" diff --git a/bindings/ocaml/llvm/llvm.mli b/bindings/ocaml/llvm/llvm.mli index 7e14cd78bb..0e38ca0ef2 100644 --- a/bindings/ocaml/llvm/llvm.mli +++ b/bindings/ocaml/llvm/llvm.mli @@ -124,14 +124,18 @@ external value_name : llvalue -> string = "llvm_value_name" external set_value_name : string -> llvalue -> unit = "llvm_set_value_name" (*--... Operations on constants of (mostly) any type .......................--*) +external is_constant : llvalue -> bool = "llvm_is_constant" external make_null : lltype -> llvalue = "llvm_make_null" -external make_all_ones : lltype -> llvalue = "llvm_make_all_ones" +external make_all_ones : (*int|vec*)lltype -> llvalue = "llvm_make_all_ones" external make_undef : lltype -> llvalue = "llvm_make_undef" external is_null : llvalue -> bool = "llvm_is_null" +external is_undef : llvalue -> bool = "llvm_is_undef" (*--... Operations on scalar constants .....................................--*) external make_int_constant : lltype -> int -> bool -> llvalue = "llvm_make_int_constant" +external make_int64_constant : lltype -> Int64.t -> bool -> llvalue + = "llvm_make_int64_constant" external make_real_constant : lltype -> float -> llvalue = "llvm_make_real_constant" diff --git a/bindings/ocaml/llvm/llvm_ocaml.c b/bindings/ocaml/llvm/llvm_ocaml.c index 3191cb0563..ae07fb20fd 100644 --- a/bindings/ocaml/llvm/llvm_ocaml.c +++ b/bindings/ocaml/llvm/llvm_ocaml.c @@ -248,10 +248,20 @@ CAMLprim value llvm_make_undef(value Ty) { } /* llvalue -> bool */ +CAMLprim value llvm_is_constant(value Ty) { + return Val_bool(LLVMIsConstant((LLVMValueRef) Ty)); +} + +/* llvalue -> bool */ CAMLprim value llvm_is_null(value Val) { return Val_bool(LLVMIsNull((LLVMValueRef) Val)); } +/* llvalue -> bool */ +CAMLprim value llvm_is_undef(value Ty) { + return Val_bool(LLVMIsUndef((LLVMValueRef) Ty)); +} + /*--... Operations on scalar constants .....................................--*/ /* lltype -> int -> bool -> llvalue */ @@ -266,6 +276,12 @@ CAMLprim value llvm_make_int_constant(value IntTy, value N, value SExt) { return (value) LLVMGetIntConstant((LLVMTypeRef) IntTy, N2, Bool_val(SExt)); } +/* lltype -> Int64.t -> bool -> llvalue */ +CAMLprim value llvm_make_int64_constant(value IntTy, value N, value SExt) { + return (value) LLVMGetIntConstant((LLVMTypeRef) IntTy, Int64_val(N), + Bool_val(SExt)); +} + /* lltype -> float -> llvalue */ CAMLprim value llvm_make_real_constant(value RealTy, value N) { return (value) LLVMGetRealConstant((LLVMTypeRef) RealTy, Double_val(N)); @@ -276,7 +292,7 @@ CAMLprim value llvm_make_real_constant(value RealTy, value N) { /* string -> bool -> llvalue */ CAMLprim value llvm_make_string_constant(value Str, value NullTerminate) { return (value) LLVMGetStringConstant(String_val(Str), - Wosize_val(Str), + caml_string_length(Str), Bool_val(NullTerminate) == 0); } |