diff options
author | Gordon Henriksen <gordonhenriksen@mac.com> | 2007-10-06 15:11:06 +0000 |
---|---|---|
committer | Gordon Henriksen <gordonhenriksen@mac.com> | 2007-10-06 15:11:06 +0000 |
commit | e3b989d4a4ba47f77d5d38c35ff17e9673d9f87b (patch) | |
tree | 35133c2bda61e4ee882053c7f4598872957ac4da /bindings | |
parent | 4647569fe7706e76135a08ca0e5f90a447ccc5b4 (diff) |
Adopting a uniform naming convention for constant constructors in bindings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42697 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings')
-rw-r--r-- | bindings/ocaml/llvm/llvm.ml | 33 | ||||
-rw-r--r-- | bindings/ocaml/llvm/llvm.mli | 33 | ||||
-rw-r--r-- | bindings/ocaml/llvm/llvm_ocaml.c | 63 |
3 files changed, 62 insertions, 67 deletions
diff --git a/bindings/ocaml/llvm/llvm.ml b/bindings/ocaml/llvm/llvm.ml index 79de1c760b..016c17af83 100644 --- a/bindings/ocaml/llvm/llvm.ml +++ b/bindings/ocaml/llvm/llvm.ml @@ -185,32 +185,29 @@ external dump_value : llvalue -> unit = "llvm_dump_value" (*--... Operations on constants of (mostly) any type .......................--*) external is_constant : llvalue -> bool = "llvm_is_constant" -external make_null : lltype -> llvalue = "LLVMGetNull" -external make_all_ones : (*int|vec*)lltype -> llvalue = "LLVMGetAllOnes" -external make_undef : lltype -> llvalue = "LLVMGetUndef" +external const_null : lltype -> llvalue = "LLVMConstNull" +external const_all_ones : (*int|vec*)lltype -> llvalue = "LLVMConstAllOnes" +external undef : lltype -> llvalue = "LLVMGetUndef" 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" +external const_int : lltype -> int -> llvalue = "llvm_const_int" +external const_of_int64 : lltype -> Int64.t -> bool -> llvalue + = "llvm_const_of_int64" +external const_float : lltype -> float -> llvalue = "llvm_const_float" (*--... Operations on composite constants ..................................--*) -external make_string_constant : string -> bool -> llvalue - = "llvm_make_string_constant" -external make_array_constant : lltype -> llvalue array -> llvalue - = "llvm_make_array_constant" -external make_struct_constant : llvalue array -> bool -> llvalue - = "llvm_make_struct_constant" -external make_vector_constant : llvalue array -> llvalue - = "llvm_make_vector_constant" +external const_string : string -> llvalue = "llvm_const_string" +external const_stringz : string -> llvalue = "llvm_const_stringz" +external const_array : lltype -> llvalue array -> llvalue = "llvm_const_array" +external const_struct : llvalue array -> llvalue = "llvm_const_struct" +external const_packed_struct : llvalue array -> llvalue + = "llvm_const_packed_struct" +external const_vector : llvalue array -> llvalue = "llvm_const_vector" (*--... Constant expressions ...............................................--*) -external sizeof : lltype -> llvalue = "LLVMSizeOf" +external size_of : lltype -> llvalue = "LLVMSizeOf" external const_neg : llvalue -> llvalue = "LLVMConstNeg" external const_not : llvalue -> llvalue = "LLVMConstNot" external const_add : llvalue -> llvalue -> llvalue = "LLVMConstAdd" diff --git a/bindings/ocaml/llvm/llvm.mli b/bindings/ocaml/llvm/llvm.mli index 943563acb2..3ded2db420 100644 --- a/bindings/ocaml/llvm/llvm.mli +++ b/bindings/ocaml/llvm/llvm.mli @@ -168,32 +168,29 @@ external dump_value : llvalue -> unit = "llvm_dump_value" (*--... Operations on constants of (mostly) any type .......................--*) external is_constant : llvalue -> bool = "llvm_is_constant" -external make_null : lltype -> llvalue = "LLVMGetNull" -external make_all_ones : (*int|vec*)lltype -> llvalue = "LLVMGetAllOnes" -external make_undef : lltype -> llvalue = "LLVMGetUndef" +external const_null : lltype -> llvalue = "LLVMConstNull" +external const_all_ones : (*int|vec*)lltype -> llvalue = "LLVMConstAllOnes" +external undef : lltype -> llvalue = "LLVMGetUndef" 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" +external const_int : lltype -> int -> llvalue = "llvm_const_int" +external const_of_int64 : lltype -> Int64.t -> bool -> llvalue + = "llvm_const_of_int64" +external const_float : lltype -> float -> llvalue = "llvm_const_float" (*--... Operations on composite constants ..................................--*) -external make_string_constant : string -> bool -> llvalue - = "llvm_make_string_constant" -external make_array_constant : lltype -> llvalue array -> llvalue - = "llvm_make_array_constant" -external make_struct_constant : llvalue array -> bool -> llvalue - = "llvm_make_struct_constant" -external make_vector_constant : llvalue array -> llvalue - = "llvm_make_vector_constant" +external const_string : string -> llvalue = "llvm_const_string" +external const_stringz : string -> llvalue = "llvm_const_stringz" +external const_array : lltype -> llvalue array -> llvalue = "llvm_const_array" +external const_struct : llvalue array -> llvalue = "llvm_const_struct" +external const_packed_struct : llvalue array -> llvalue + = "llvm_const_packed_struct" +external const_vector : llvalue array -> llvalue = "llvm_const_vector" (*--... Constant expressions ...............................................--*) -external sizeof : lltype -> llvalue = "LLVMSizeOf" +external size_of : lltype -> llvalue = "LLVMSizeOf" external const_neg : llvalue -> llvalue = "LLVMConstNeg" external const_not : llvalue -> llvalue = "LLVMConstNot" external const_add : llvalue -> llvalue -> llvalue = "LLVMConstAdd" diff --git a/bindings/ocaml/llvm/llvm_ocaml.c b/bindings/ocaml/llvm/llvm_ocaml.c index 47f1936892..6460930eb5 100644 --- a/bindings/ocaml/llvm/llvm_ocaml.c +++ b/bindings/ocaml/llvm/llvm_ocaml.c @@ -244,56 +244,57 @@ CAMLprim value llvm_is_undef(LLVMValueRef Val) { /*--... Operations on scalar constants .....................................--*/ -/* lltype -> int -> bool -> llvalue */ -CAMLprim LLVMValueRef llvm_make_int_constant(LLVMTypeRef IntTy, value N, - value SExt) { - /* GCC warns if we use the ternary operator. */ - unsigned long long N2; - if (Bool_val(SExt)) - N2 = (value) Int_val(N); - else - N2 = (mlsize_t) Int_val(N); - - return LLVMGetIntConstant(IntTy, N2, Bool_val(SExt)); +/* lltype -> int -> llvalue */ +CAMLprim LLVMValueRef llvm_const_int(LLVMTypeRef IntTy, value N) { + return LLVMConstInt(IntTy, (long long) Int_val(N), 1); } /* lltype -> Int64.t -> bool -> llvalue */ -CAMLprim LLVMValueRef llvm_make_int64_constant(LLVMTypeRef IntTy, value N, - value SExt) { - return LLVMGetIntConstant(IntTy, Int64_val(N), Bool_val(SExt)); +CAMLprim LLVMValueRef llvm_const_of_int64(LLVMTypeRef IntTy, value N, + value SExt) { + return LLVMConstInt(IntTy, Int64_val(N), Bool_val(SExt)); } /* lltype -> float -> llvalue */ -CAMLprim LLVMValueRef llvm_make_real_constant(LLVMTypeRef RealTy, value N) { - return LLVMGetRealConstant(RealTy, Double_val(N)); +CAMLprim LLVMValueRef llvm_const_float(LLVMTypeRef RealTy, value N) { + return LLVMConstReal(RealTy, Double_val(N)); } /*--... Operations on composite constants ..................................--*/ -/* string -> bool -> llvalue */ -CAMLprim LLVMValueRef llvm_make_string_constant(value Str, value NullTerminate) { - return LLVMGetStringConstant(String_val(Str), string_length(Str), - Bool_val(NullTerminate) == 0); +/* string -> llvalue */ +CAMLprim LLVMValueRef llvm_const_string(value Str, value NullTerminate) { + return LLVMConstString(String_val(Str), string_length(Str), 1); +} + +/* string -> llvalue */ +CAMLprim LLVMValueRef llvm_const_stringz(value Str, value NullTerminate) { + return LLVMConstString(String_val(Str), string_length(Str), 0); } /* lltype -> llvalue array -> llvalue */ -CAMLprim LLVMValueRef llvm_make_array_constant(LLVMTypeRef ElementTy, +CAMLprim LLVMValueRef llvm_const_array(LLVMTypeRef ElementTy, value ElementVals) { - return LLVMGetArrayConstant(ElementTy, (LLVMValueRef*) Op_val(ElementVals), - Wosize_val(ElementVals)); + return LLVMConstArray(ElementTy, (LLVMValueRef*) Op_val(ElementVals), + Wosize_val(ElementVals)); +} + +/* llvalue array -> llvalue */ +CAMLprim LLVMValueRef llvm_const_struct(value ElementVals) { + return LLVMConstStruct((LLVMValueRef *) Op_val(ElementVals), + Wosize_val(ElementVals), 0); } -/* llvalue array -> bool -> llvalue */ -CAMLprim LLVMValueRef llvm_make_struct_constant(value ElementVals, - value Packed) { - return LLVMGetStructConstant((LLVMValueRef *) Op_val(ElementVals), - Wosize_val(ElementVals), Bool_val(Packed)); +/* llvalue array -> llvalue */ +CAMLprim LLVMValueRef llvm_const_packed_struct(value ElementVals) { + return LLVMConstStruct((LLVMValueRef *) Op_val(ElementVals), + Wosize_val(ElementVals), 1); } /* llvalue array -> llvalue */ -CAMLprim LLVMValueRef llvm_make_vector_constant(value ElementVals) { - return LLVMGetVectorConstant((LLVMValueRef*) Op_val(ElementVals), - Wosize_val(ElementVals)); +CAMLprim LLVMValueRef llvm_const_vector(value ElementVals) { + return LLVMConstVector((LLVMValueRef*) Op_val(ElementVals), + Wosize_val(ElementVals)); } /*--... Constant expressions ...............................................--*/ |