[OCaml] (PR16318) Add missing argument to Llvm.const_intcast

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194065 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Peter Zotov 2013-11-05 11:56:20 +00:00
parent 150c95eab5
commit c8ac229cc8
4 changed files with 17 additions and 5 deletions

View File

@ -529,7 +529,8 @@ external const_trunc_or_bitcast : llvalue -> lltype -> llvalue
= "LLVMConstTruncOrBitCast" = "LLVMConstTruncOrBitCast"
external const_pointercast : llvalue -> lltype -> llvalue external const_pointercast : llvalue -> lltype -> llvalue
= "LLVMConstPointerCast" = "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_fpcast : llvalue -> lltype -> llvalue = "LLVMConstFPCast"
external const_select : llvalue -> llvalue -> llvalue -> llvalue external const_select : llvalue -> llvalue -> llvalue -> llvalue
= "LLVMConstSelect" = "LLVMConstSelect"

View File

@ -1118,10 +1118,12 @@ val const_trunc_or_bitcast : llvalue -> lltype -> llvalue
See the method [llvm::ConstantExpr::getPointerCast]. *) See the method [llvm::ConstantExpr::getPointerCast]. *)
val const_pointercast : llvalue -> lltype -> llvalue val const_pointercast : llvalue -> lltype -> llvalue
(** [const_intcast c ty] returns a constant zext, bitcast, or trunc for integer (** [const_intcast c ty ~is_signed] returns a constant sext/zext, bitcast,
-> integer casts of constant [c] to type [ty]. or trunc for integer -> integer casts of constant [c] to type [ty].
See the method [llvm::ConstantExpr::getIntCast]. *) When converting a narrower value to a wider one, whether sext or zext
val const_intcast : llvalue -> lltype -> llvalue 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 -> (** [const_fpcast c ty] returns a constant fpext, bitcast, or fptrunc for fp ->
fp casts of constant [c] to type [ty]. fp casts of constant [c] to type [ty].

View File

@ -771,6 +771,12 @@ CAMLprim LLVMValueRef llvm_const_in_bounds_gep(LLVMValueRef ConstantVal,
Wosize_val(Indices)); 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 */ /* llvalue -> int array -> llvalue */
CAMLprim LLVMValueRef llvm_const_extractvalue(LLVMValueRef Aggregate, CAMLprim LLVMValueRef llvm_const_extractvalue(LLVMValueRef Aggregate,
value Indices) { value Indices) {

View File

@ -286,6 +286,7 @@ let test_constants () =
* CHECK: const_ptrtoint{{.*}}ptrtoint * CHECK: const_ptrtoint{{.*}}ptrtoint
* CHECK: const_inttoptr{{.*}}inttoptr * CHECK: const_inttoptr{{.*}}inttoptr
* CHECK: const_bitcast{{.*}}bitcast * CHECK: const_bitcast{{.*}}bitcast
* CHECK: const_intcast{{.*}}zext
*) *)
let i128_type = integer_type context 128 in let i128_type = integer_type context 128 in
ignore (define_global "const_trunc" (const_trunc (const_add foldbomb five) 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) ignore (define_global "const_inttoptr" (const_inttoptr (const_add foldbomb five)
void_ptr) m); void_ptr) m);
ignore (define_global "const_bitcast" (const_bitcast ffoldbomb i64_type) 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"; group "misc constants";
(* CHECK: const_size_of{{.*}}getelementptr{{.*}}null (* CHECK: const_size_of{{.*}}getelementptr{{.*}}null