[llvm] r194065 - [OCaml] (PR16318) Add missing argument to Llvm.const_intcast
Peter Zotov
whitequark at whitequark.org
Tue Nov 5 03:56:21 PST 2013
Author: whitequark
Date: Tue Nov 5 05:56:20 2013
New Revision: 194065
URL: http://llvm.org/viewvc/llvm-project?rev=194065&view=rev
Log:
[OCaml] (PR16318) Add missing argument to Llvm.const_intcast
Modified:
llvm/trunk/bindings/ocaml/llvm/llvm.ml
llvm/trunk/bindings/ocaml/llvm/llvm.mli
llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c
llvm/trunk/test/Bindings/Ocaml/vmcore.ml
Modified: llvm/trunk/bindings/ocaml/llvm/llvm.ml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm.ml?rev=194065&r1=194064&r2=194065&view=diff
==============================================================================
--- llvm/trunk/bindings/ocaml/llvm/llvm.ml (original)
+++ llvm/trunk/bindings/ocaml/llvm/llvm.ml Tue Nov 5 05:56:20 2013
@@ -529,7 +529,8 @@ external const_trunc_or_bitcast : llvalu
= "LLVMConstTruncOrBitCast"
external const_pointercast : llvalue -> lltype -> llvalue
= "LLVMConstPointerCast"
-external const_intcast : llvalue -> lltype -> llvalue = "LLVMConstIntCast"
+external const_intcast : llvalue -> lltype -> is_signed:bool -> llvalue
+ = "llvm_const_intcast"
external const_fpcast : llvalue -> lltype -> llvalue = "LLVMConstFPCast"
external const_select : llvalue -> llvalue -> llvalue -> llvalue
= "LLVMConstSelect"
Modified: llvm/trunk/bindings/ocaml/llvm/llvm.mli
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm.mli?rev=194065&r1=194064&r2=194065&view=diff
==============================================================================
--- llvm/trunk/bindings/ocaml/llvm/llvm.mli (original)
+++ llvm/trunk/bindings/ocaml/llvm/llvm.mli Tue Nov 5 05:56:20 2013
@@ -1118,10 +1118,12 @@ val const_trunc_or_bitcast : llvalue ->
See the method [llvm::ConstantExpr::getPointerCast]. *)
val const_pointercast : llvalue -> lltype -> llvalue
-(** [const_intcast c ty] returns a constant zext, bitcast, or trunc for integer
- -> integer casts of constant [c] to type [ty].
- See the method [llvm::ConstantExpr::getIntCast]. *)
-val const_intcast : llvalue -> lltype -> llvalue
+(** [const_intcast c ty ~is_signed] returns a constant sext/zext, bitcast,
+ or trunc for integer -> integer casts of constant [c] to type [ty].
+ When converting a narrower value to a wider one, whether sext or zext
+ will be used is controlled by [is_signed].
+ See the method [llvm::ConstantExpr::getIntegerCast]. *)
+val const_intcast : llvalue -> lltype -> is_signed:bool -> llvalue
(** [const_fpcast c ty] returns a constant fpext, bitcast, or fptrunc for fp ->
fp casts of constant [c] to type [ty].
Modified: llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c?rev=194065&r1=194064&r2=194065&view=diff
==============================================================================
--- llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c (original)
+++ llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c Tue Nov 5 05:56:20 2013
@@ -771,6 +771,12 @@ CAMLprim LLVMValueRef llvm_const_in_boun
Wosize_val(Indices));
}
+/* llvalue -> lltype -> is_signed:bool -> llvalue */
+CAMLprim LLVMValueRef llvm_const_intcast(LLVMValueRef CV, LLVMTypeRef T,
+ value IsSigned) {
+ return LLVMConstIntCast(CV, T, Bool_val(IsSigned));
+}
+
/* llvalue -> int array -> llvalue */
CAMLprim LLVMValueRef llvm_const_extractvalue(LLVMValueRef Aggregate,
value Indices) {
Modified: llvm/trunk/test/Bindings/Ocaml/vmcore.ml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bindings/Ocaml/vmcore.ml?rev=194065&r1=194064&r2=194065&view=diff
==============================================================================
--- llvm/trunk/test/Bindings/Ocaml/vmcore.ml (original)
+++ llvm/trunk/test/Bindings/Ocaml/vmcore.ml Tue Nov 5 05:56:20 2013
@@ -286,6 +286,7 @@ let test_constants () =
* CHECK: const_ptrtoint{{.*}}ptrtoint
* CHECK: const_inttoptr{{.*}}inttoptr
* CHECK: const_bitcast{{.*}}bitcast
+ * CHECK: const_intcast{{.*}}zext
*)
let i128_type = integer_type context 128 in
ignore (define_global "const_trunc" (const_trunc (const_add foldbomb five)
@@ -305,6 +306,8 @@ let test_constants () =
ignore (define_global "const_inttoptr" (const_inttoptr (const_add foldbomb five)
void_ptr) m);
ignore (define_global "const_bitcast" (const_bitcast ffoldbomb i64_type) m);
+ ignore (define_global "const_intcast"
+ (const_intcast foldbomb i128_type ~is_signed:false) m);
group "misc constants";
(* CHECK: const_size_of{{.*}}getelementptr{{.*}}null
More information about the llvm-commits
mailing list