mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
Expose most of the Constant creation functions to ocaml.
llvm-svn: 79162
This commit is contained in:
parent
57dcc1e1a3
commit
ed8dffc10b
@ -220,7 +220,6 @@ external refine_type : lltype -> lltype -> unit = "llvm_refine_type"
|
||||
|
||||
|
||||
(*===-- Values ------------------------------------------------------------===*)
|
||||
|
||||
external type_of : llvalue -> lltype = "llvm_type_of"
|
||||
external value_name : llvalue -> string = "llvm_value_name"
|
||||
external set_value_name : string -> llvalue -> unit = "llvm_set_value_name"
|
||||
@ -253,12 +252,18 @@ external const_vector : llvalue array -> llvalue = "llvm_const_vector"
|
||||
external align_of : lltype -> llvalue = "LLVMAlignOf"
|
||||
external size_of : lltype -> llvalue = "LLVMSizeOf"
|
||||
external const_neg : llvalue -> llvalue = "LLVMConstNeg"
|
||||
external const_fneg : llvalue -> llvalue = "LLVMConstFNeg"
|
||||
external const_not : llvalue -> llvalue = "LLVMConstNot"
|
||||
external const_add : llvalue -> llvalue -> llvalue = "LLVMConstAdd"
|
||||
external const_nsw_add : llvalue -> llvalue -> llvalue = "LLVMConstNSWAdd"
|
||||
external const_fadd : llvalue -> llvalue -> llvalue = "LLVMConstFAdd"
|
||||
external const_sub : llvalue -> llvalue -> llvalue = "LLVMConstSub"
|
||||
external const_fsub : llvalue -> llvalue -> llvalue = "LLVMConstFSub"
|
||||
external const_mul : llvalue -> llvalue -> llvalue = "LLVMConstMul"
|
||||
external const_fmul : llvalue -> llvalue -> llvalue = "LLVMConstFMul"
|
||||
external const_udiv : llvalue -> llvalue -> llvalue = "LLVMConstUDiv"
|
||||
external const_sdiv : llvalue -> llvalue -> llvalue = "LLVMConstSDiv"
|
||||
external const_exact_sdiv : llvalue -> llvalue -> llvalue = "LLVMConstExactSDiv"
|
||||
external const_fdiv : llvalue -> llvalue -> llvalue = "LLVMConstFDiv"
|
||||
external const_urem : llvalue -> llvalue -> llvalue = "LLVMConstURem"
|
||||
external const_srem : llvalue -> llvalue -> llvalue = "LLVMConstSRem"
|
||||
@ -274,6 +279,8 @@ external const_shl : llvalue -> llvalue -> llvalue = "LLVMConstShl"
|
||||
external const_lshr : llvalue -> llvalue -> llvalue = "LLVMConstLShr"
|
||||
external const_ashr : llvalue -> llvalue -> llvalue = "LLVMConstAShr"
|
||||
external const_gep : llvalue -> llvalue array -> llvalue = "llvm_const_gep"
|
||||
external const_in_bounds_gep : llvalue -> llvalue array -> llvalue
|
||||
= "llvm_const_in_bounds_gep"
|
||||
external const_trunc : llvalue -> lltype -> llvalue = "LLVMConstTrunc"
|
||||
external const_sext : llvalue -> lltype -> llvalue = "LLVMConstSExt"
|
||||
external const_zext : llvalue -> lltype -> llvalue = "LLVMConstZExt"
|
||||
@ -286,6 +293,16 @@ external const_fptosi : llvalue -> lltype -> llvalue = "LLVMConstFPToSI"
|
||||
external const_ptrtoint : llvalue -> lltype -> llvalue = "LLVMConstPtrToInt"
|
||||
external const_inttoptr : llvalue -> lltype -> llvalue = "LLVMConstIntToPtr"
|
||||
external const_bitcast : llvalue -> lltype -> llvalue = "LLVMConstBitCast"
|
||||
external const_zext_or_bitcast : llvalue -> lltype -> llvalue
|
||||
= "LLVMConstZExtOrBitCast"
|
||||
external const_sext_or_bitcast : llvalue -> lltype -> llvalue
|
||||
= "LLVMConstSExtOrBitCast"
|
||||
external const_trunc_or_bitcast : llvalue -> lltype -> llvalue
|
||||
= "LLVMConstTruncOrBitCast"
|
||||
external const_pointercast : llvalue -> lltype -> llvalue
|
||||
= "LLVMConstPointerCast"
|
||||
external const_intcast : llvalue -> lltype -> llvalue = "LLVMConstIntCast"
|
||||
external const_fpcast : llvalue -> lltype -> llvalue = "LLVMConstFPCast"
|
||||
external const_select : llvalue -> llvalue -> llvalue -> llvalue
|
||||
= "LLVMConstSelect"
|
||||
external const_extractelement : llvalue -> llvalue -> llvalue
|
||||
@ -294,6 +311,10 @@ external const_insertelement : llvalue -> llvalue -> llvalue -> llvalue
|
||||
= "LLVMConstInsertElement"
|
||||
external const_shufflevector : llvalue -> llvalue -> llvalue -> llvalue
|
||||
= "LLVMConstShuffleVector"
|
||||
external const_extractvalue : llvalue -> int array -> llvalue
|
||||
= "llvm_const_extractvalue"
|
||||
external const_insertvalue : llvalue -> llvalue -> int array -> llvalue
|
||||
= "llvm_const_insertvalue"
|
||||
|
||||
(*--... Operations on global variables, functions, and aliases (globals) ...--*)
|
||||
external global_parent : llvalue -> llmodule = "LLVMGetGlobalParent"
|
||||
|
@ -531,6 +531,10 @@ external size_of : lltype -> llvalue = "LLVMSizeOf"
|
||||
See the method [llvm::ConstantExpr::getNeg]. *)
|
||||
external const_neg : llvalue -> llvalue = "LLVMConstNeg"
|
||||
|
||||
(** [const_fneg c] returns the arithmetic negation of the constant float [c].
|
||||
See the method [llvm::ConstantExpr::getFNeg]. *)
|
||||
external const_fneg : llvalue -> llvalue = "LLVMConstFNeg"
|
||||
|
||||
(** [const_not c] returns the bitwise inverse of the constant [c].
|
||||
See the method [llvm::ConstantExpr::getNot]. *)
|
||||
external const_not : llvalue -> llvalue = "LLVMConstNot"
|
||||
@ -539,14 +543,31 @@ external const_not : llvalue -> llvalue = "LLVMConstNot"
|
||||
See the method [llvm::ConstantExpr::getAdd]. *)
|
||||
external const_add : llvalue -> llvalue -> llvalue = "LLVMConstAdd"
|
||||
|
||||
(** [const_nsw_add c1 c2] returns the constant sum of two constants with no
|
||||
signed wrapping. The result is undefined if the sum overflows.
|
||||
See the method [llvm::ConstantExpr::getNSWAdd]. *)
|
||||
external const_nsw_add : llvalue -> llvalue -> llvalue = "LLVMConstNSWAdd"
|
||||
|
||||
(** [const_fadd c1 c2] returns the constant sum of two constant floats.
|
||||
See the method [llvm::ConstantExpr::getFAdd]. *)
|
||||
external const_fadd : llvalue -> llvalue -> llvalue = "LLVMConstFAdd"
|
||||
|
||||
(** [const_sub c1 c2] returns the constant difference, [c1 - c2], of two
|
||||
constants. See the method [llvm::ConstantExpr::getSub]. *)
|
||||
external const_sub : llvalue -> llvalue -> llvalue = "LLVMConstSub"
|
||||
|
||||
(** [const_fsub c1 c2] returns the constant difference, [c1 - c2], of two
|
||||
constant floats. See the method [llvm::ConstantExpr::getFSub]. *)
|
||||
external const_fsub : llvalue -> llvalue -> llvalue = "LLVMConstFSub"
|
||||
|
||||
(** [const_mul c1 c2] returns the constant product of two constants.
|
||||
See the method [llvm::ConstantExpr::getMul]. *)
|
||||
external const_mul : llvalue -> llvalue -> llvalue = "LLVMConstMul"
|
||||
|
||||
(** [const_fmul c1 c2] returns the constant product of two constants floats.
|
||||
See the method [llvm::ConstantExpr::getFMul]. *)
|
||||
external const_fmul : llvalue -> llvalue -> llvalue = "LLVMConstFMul"
|
||||
|
||||
(** [const_udiv c1 c2] returns the constant quotient [c1 / c2] of two unsigned
|
||||
integer constants.
|
||||
See the method [llvm::ConstantExpr::getUDiv]. *)
|
||||
@ -554,20 +575,25 @@ external const_udiv : llvalue -> llvalue -> llvalue = "LLVMConstUDiv"
|
||||
|
||||
(** [const_sdiv c1 c2] returns the constant quotient [c1 / c2] of two signed
|
||||
integer constants.
|
||||
See the method [llvm::ConstantExpr::]. *)
|
||||
See the method [llvm::ConstantExpr::getSDiv]. *)
|
||||
external const_sdiv : llvalue -> llvalue -> llvalue = "LLVMConstSDiv"
|
||||
|
||||
(** [const_exact_sdiv c1 c2] returns the constant quotient [c1 / c2] of two
|
||||
signed integer constants. The result is undefined if the result is rounded
|
||||
or overflows. See the method [llvm::ConstantExpr::getExactSDiv]. *)
|
||||
external const_exact_sdiv : llvalue -> llvalue -> llvalue = "LLVMConstExactSDiv"
|
||||
|
||||
(** [const_fdiv c1 c2] returns the constant quotient [c1 / c2] of two floating
|
||||
point constants.
|
||||
See the method [llvm::ConstantExpr::getFDiv]. *)
|
||||
external const_fdiv : llvalue -> llvalue -> llvalue = "LLVMConstFDiv"
|
||||
|
||||
(** [const_udiv c1 c2] returns the constant remainder [c1 MOD c2] of two
|
||||
(** [const_urem c1 c2] returns the constant remainder [c1 MOD c2] of two
|
||||
unsigned integer constants.
|
||||
See the method [llvm::ConstantExpr::getURem]. *)
|
||||
external const_urem : llvalue -> llvalue -> llvalue = "LLVMConstURem"
|
||||
|
||||
(** [const_sdiv c1 c2] returns the constant remainder [c1 MOD c2] of two
|
||||
(** [const_srem c1 c2] returns the constant remainder [c1 MOD c2] of two
|
||||
signed integer constants.
|
||||
See the method [llvm::ConstantExpr::getSRem]. *)
|
||||
external const_srem : llvalue -> llvalue -> llvalue = "LLVMConstSRem"
|
||||
@ -624,6 +650,12 @@ external const_ashr : llvalue -> llvalue -> llvalue = "LLVMConstAShr"
|
||||
See the method [llvm::ConstantExpr::getGetElementPtr]. *)
|
||||
external const_gep : llvalue -> llvalue array -> llvalue = "llvm_const_gep"
|
||||
|
||||
(** [const_in_bounds_gep pc indices] returns the constant [getElementPtr] of [p1]
|
||||
with the constant integers indices from the array [indices].
|
||||
See the method [llvm::ConstantExpr::getInBoundsGetElementPtr]. *)
|
||||
external const_in_bounds_gep : llvalue -> llvalue array -> llvalue
|
||||
= "llvm_const_in_bounds_gep"
|
||||
|
||||
(** [const_trunc c ty] returns the constant truncation of integer constant [c]
|
||||
to the smaller integer type [ty].
|
||||
See the method [llvm::ConstantExpr::getTrunc]. *)
|
||||
@ -684,6 +716,42 @@ external const_inttoptr : llvalue -> lltype -> llvalue = "LLVMConstIntToPtr"
|
||||
See the method [llvm::ConstantExpr::getBitCast]. *)
|
||||
external const_bitcast : llvalue -> lltype -> llvalue = "LLVMConstBitCast"
|
||||
|
||||
(** [const_zext_or_bitcast c ty] returns a constant zext or bitwise cast
|
||||
conversion of constant [c] to type [ty].
|
||||
See the method [llvm::ConstantExpr::getZExtOrBitCast]. *)
|
||||
external const_zext_or_bitcast : llvalue -> lltype -> llvalue
|
||||
= "LLVMConstZExtOrBitCast"
|
||||
|
||||
(** [const_sext_or_bitcast c ty] returns a constant sext or bitwise cast
|
||||
conversion of constant [c] to type [ty].
|
||||
See the method [llvm::ConstantExpr::getSExtOrBitCast]. *)
|
||||
external const_sext_or_bitcast : llvalue -> lltype -> llvalue
|
||||
= "LLVMConstSExtOrBitCast"
|
||||
|
||||
(** [const_trunc_or_bitcast c ty] returns a constant trunc or bitwise cast
|
||||
conversion of constant [c] to type [ty].
|
||||
See the method [llvm::ConstantExpr::getTruncOrBitCast]. *)
|
||||
external const_trunc_or_bitcast : llvalue -> lltype -> llvalue
|
||||
= "LLVMConstTruncOrBitCast"
|
||||
|
||||
(** [const_pointercast c ty] returns a constant bitcast or a pointer-to-int
|
||||
cast conversion of constant [c] to type [ty] of equal size.
|
||||
See the method [llvm::ConstantExpr::getPointerCast]. *)
|
||||
external const_pointercast : llvalue -> lltype -> llvalue
|
||||
= "LLVMConstPointerCast"
|
||||
|
||||
(** [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]. *)
|
||||
external const_intcast : llvalue -> lltype -> llvalue
|
||||
= "LLVMConstIntCast"
|
||||
|
||||
(** [const_fpcast c ty] returns a constant fpext, bitcast, or fptrunc for fp ->
|
||||
fp casts of constant [c] to type [ty].
|
||||
See the method [llvm::ConstantExpr::getFPCast]. *)
|
||||
external const_fpcast : llvalue -> lltype -> llvalue
|
||||
= "LLVMConstFPCast"
|
||||
|
||||
(** [const_select cond t f] returns the constant conditional which returns value
|
||||
[t] if the boolean constant [cond] is true and the value [f] otherwise.
|
||||
See the method [llvm::ConstantExpr::getSelect]. *)
|
||||
@ -713,6 +781,18 @@ external const_insertelement : llvalue -> llvalue -> llvalue -> llvalue
|
||||
external const_shufflevector : llvalue -> llvalue -> llvalue -> llvalue
|
||||
= "LLVMConstShuffleVector"
|
||||
|
||||
(** [const_extractvalue agg idxs] returns the constant [idxs]th value of
|
||||
constant aggregate [agg]. Each [idxs] must be less than the size of the
|
||||
aggregate. See the method [llvm::ConstantExpr::getExtractValue]. *)
|
||||
external const_extractvalue : llvalue -> int array -> llvalue
|
||||
= "llvm_const_extractvalue"
|
||||
|
||||
(** [const_insertvalue agg val idxs] inserts the value [val] in the specified
|
||||
indexs [idxs] in the aggegate [agg]. Each [idxs] must be less than the size
|
||||
of the aggregate. See the method [llvm::ConstantExpr::getInsertValue]. *)
|
||||
external const_insertvalue : llvalue -> llvalue -> int array -> llvalue
|
||||
= "llvm_const_insertvalue"
|
||||
|
||||
|
||||
(** {7 Operations on global variables, functions, and aliases (globals)} *)
|
||||
|
||||
|
@ -452,6 +452,49 @@ CAMLprim LLVMValueRef llvm_const_gep(LLVMValueRef ConstantVal, value Indices) {
|
||||
Wosize_val(Indices));
|
||||
}
|
||||
|
||||
/* llvalue -> llvalue array -> llvalue */
|
||||
CAMLprim LLVMValueRef llvm_const_in_bounds_gep(LLVMValueRef ConstantVal,
|
||||
value Indices) {
|
||||
return LLVMConstInBoundsGEP(ConstantVal, (LLVMValueRef*) Op_val(Indices),
|
||||
Wosize_val(Indices));
|
||||
}
|
||||
|
||||
/* llvalue -> int array -> llvalue */
|
||||
CAMLprim LLVMValueRef llvm_const_extractvalue(LLVMValueRef Aggregate,
|
||||
value Indices) {
|
||||
CAMLparam1(Indices);
|
||||
int size = Wosize_val(Indices);
|
||||
int i;
|
||||
LLVMValueRef result;
|
||||
|
||||
unsigned* idxs = (unsigned*)malloc(size * sizeof(unsigned));
|
||||
for (i = 0; i < size; i++) {
|
||||
idxs[i] = Int_val(Field(Indices, i));
|
||||
}
|
||||
|
||||
result = LLVMConstExtractValue(Aggregate, idxs, size);
|
||||
free(idxs);
|
||||
CAMLreturnT(LLVMValueRef, result);
|
||||
}
|
||||
|
||||
/* llvalue -> llvalue -> int array -> llvalue */
|
||||
CAMLprim LLVMValueRef llvm_const_insertvalue(LLVMValueRef Aggregate,
|
||||
LLVMValueRef Val, value Indices) {
|
||||
CAMLparam1(Indices);
|
||||
int size = Wosize_val(Indices);
|
||||
int i;
|
||||
LLVMValueRef result;
|
||||
|
||||
unsigned* idxs = (unsigned*)malloc(size * sizeof(unsigned));
|
||||
for (i = 0; i < size; i++) {
|
||||
idxs[i] = Int_val(Field(Indices, i));
|
||||
}
|
||||
|
||||
result = LLVMConstInsertValue(Aggregate, Val, idxs, size);
|
||||
free(idxs);
|
||||
CAMLreturnT(LLVMValueRef, result);
|
||||
}
|
||||
|
||||
/*--... Operations on global variables, functions, and aliases (globals) ...--*/
|
||||
|
||||
/* llvalue -> bool */
|
||||
|
Loading…
Reference in New Issue
Block a user