llvm.org GIT mirror llvm / 1b42cfd
Expose most of the Constant creation functions to ocaml. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79162 91177308-0d34-0410-b5e6-96231b3b80d8 Erick Tryzelaar 10 years ago
3 changed file(s) with 148 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
219219
220220
221221 (*===-- Values ------------------------------------------------------------===*)
222
223222 external type_of : llvalue -> lltype = "llvm_type_of"
224223 external value_name : llvalue -> string = "llvm_value_name"
225224 external set_value_name : string -> llvalue -> unit = "llvm_set_value_name"
252251 external align_of : lltype -> llvalue = "LLVMAlignOf"
253252 external size_of : lltype -> llvalue = "LLVMSizeOf"
254253 external const_neg : llvalue -> llvalue = "LLVMConstNeg"
254 external const_fneg : llvalue -> llvalue = "LLVMConstFNeg"
255255 external const_not : llvalue -> llvalue = "LLVMConstNot"
256256 external const_add : llvalue -> llvalue -> llvalue = "LLVMConstAdd"
257 external const_nsw_add : llvalue -> llvalue -> llvalue = "LLVMConstNSWAdd"
258 external const_fadd : llvalue -> llvalue -> llvalue = "LLVMConstFAdd"
257259 external const_sub : llvalue -> llvalue -> llvalue = "LLVMConstSub"
260 external const_fsub : llvalue -> llvalue -> llvalue = "LLVMConstFSub"
258261 external const_mul : llvalue -> llvalue -> llvalue = "LLVMConstMul"
262 external const_fmul : llvalue -> llvalue -> llvalue = "LLVMConstFMul"
259263 external const_udiv : llvalue -> llvalue -> llvalue = "LLVMConstUDiv"
260264 external const_sdiv : llvalue -> llvalue -> llvalue = "LLVMConstSDiv"
265 external const_exact_sdiv : llvalue -> llvalue -> llvalue = "LLVMConstExactSDiv"
261266 external const_fdiv : llvalue -> llvalue -> llvalue = "LLVMConstFDiv"
262267 external const_urem : llvalue -> llvalue -> llvalue = "LLVMConstURem"
263268 external const_srem : llvalue -> llvalue -> llvalue = "LLVMConstSRem"
273278 external const_lshr : llvalue -> llvalue -> llvalue = "LLVMConstLShr"
274279 external const_ashr : llvalue -> llvalue -> llvalue = "LLVMConstAShr"
275280 external const_gep : llvalue -> llvalue array -> llvalue = "llvm_const_gep"
281 external const_in_bounds_gep : llvalue -> llvalue array -> llvalue
282 = "llvm_const_in_bounds_gep"
276283 external const_trunc : llvalue -> lltype -> llvalue = "LLVMConstTrunc"
277284 external const_sext : llvalue -> lltype -> llvalue = "LLVMConstSExt"
278285 external const_zext : llvalue -> lltype -> llvalue = "LLVMConstZExt"
285292 external const_ptrtoint : llvalue -> lltype -> llvalue = "LLVMConstPtrToInt"
286293 external const_inttoptr : llvalue -> lltype -> llvalue = "LLVMConstIntToPtr"
287294 external const_bitcast : llvalue -> lltype -> llvalue = "LLVMConstBitCast"
295 external const_zext_or_bitcast : llvalue -> lltype -> llvalue
296 = "LLVMConstZExtOrBitCast"
297 external const_sext_or_bitcast : llvalue -> lltype -> llvalue
298 = "LLVMConstSExtOrBitCast"
299 external const_trunc_or_bitcast : llvalue -> lltype -> llvalue
300 = "LLVMConstTruncOrBitCast"
301 external const_pointercast : llvalue -> lltype -> llvalue
302 = "LLVMConstPointerCast"
303 external const_intcast : llvalue -> lltype -> llvalue = "LLVMConstIntCast"
304 external const_fpcast : llvalue -> lltype -> llvalue = "LLVMConstFPCast"
288305 external const_select : llvalue -> llvalue -> llvalue -> llvalue
289306 = "LLVMConstSelect"
290307 external const_extractelement : llvalue -> llvalue -> llvalue
293310 = "LLVMConstInsertElement"
294311 external const_shufflevector : llvalue -> llvalue -> llvalue -> llvalue
295312 = "LLVMConstShuffleVector"
313 external const_extractvalue : llvalue -> int array -> llvalue
314 = "llvm_const_extractvalue"
315 external const_insertvalue : llvalue -> llvalue -> int array -> llvalue
316 = "llvm_const_insertvalue"
296317
297318 (*--... Operations on global variables, functions, and aliases (globals) ...--*)
298319 external global_parent : llvalue -> llmodule = "LLVMGetGlobalParent"
530530 See the method [llvm::ConstantExpr::getNeg]. *)
531531 external const_neg : llvalue -> llvalue = "LLVMConstNeg"
532532
533 (** [const_fneg c] returns the arithmetic negation of the constant float [c].
534 See the method [llvm::ConstantExpr::getFNeg]. *)
535 external const_fneg : llvalue -> llvalue = "LLVMConstFNeg"
536
533537 (** [const_not c] returns the bitwise inverse of the constant [c].
534538 See the method [llvm::ConstantExpr::getNot]. *)
535539 external const_not : llvalue -> llvalue = "LLVMConstNot"
538542 See the method [llvm::ConstantExpr::getAdd]. *)
539543 external const_add : llvalue -> llvalue -> llvalue = "LLVMConstAdd"
540544
545 (** [const_nsw_add c1 c2] returns the constant sum of two constants with no
546 signed wrapping. The result is undefined if the sum overflows.
547 See the method [llvm::ConstantExpr::getNSWAdd]. *)
548 external const_nsw_add : llvalue -> llvalue -> llvalue = "LLVMConstNSWAdd"
549
550 (** [const_fadd c1 c2] returns the constant sum of two constant floats.
551 See the method [llvm::ConstantExpr::getFAdd]. *)
552 external const_fadd : llvalue -> llvalue -> llvalue = "LLVMConstFAdd"
553
541554 (** [const_sub c1 c2] returns the constant difference, [c1 - c2], of two
542555 constants. See the method [llvm::ConstantExpr::getSub]. *)
543556 external const_sub : llvalue -> llvalue -> llvalue = "LLVMConstSub"
544557
558 (** [const_fsub c1 c2] returns the constant difference, [c1 - c2], of two
559 constant floats. See the method [llvm::ConstantExpr::getFSub]. *)
560 external const_fsub : llvalue -> llvalue -> llvalue = "LLVMConstFSub"
561
545562 (** [const_mul c1 c2] returns the constant product of two constants.
546563 See the method [llvm::ConstantExpr::getMul]. *)
547564 external const_mul : llvalue -> llvalue -> llvalue = "LLVMConstMul"
565
566 (** [const_fmul c1 c2] returns the constant product of two constants floats.
567 See the method [llvm::ConstantExpr::getFMul]. *)
568 external const_fmul : llvalue -> llvalue -> llvalue = "LLVMConstFMul"
548569
549570 (** [const_udiv c1 c2] returns the constant quotient [c1 / c2] of two unsigned
550571 integer constants.
553574
554575 (** [const_sdiv c1 c2] returns the constant quotient [c1 / c2] of two signed
555576 integer constants.
556 See the method [llvm::ConstantExpr::]. *)
577 See the method [llvm::ConstantExpr::getSDiv]. *)
557578 external const_sdiv : llvalue -> llvalue -> llvalue = "LLVMConstSDiv"
579
580 (** [const_exact_sdiv c1 c2] returns the constant quotient [c1 / c2] of two
581 signed integer constants. The result is undefined if the result is rounded
582 or overflows. See the method [llvm::ConstantExpr::getExactSDiv]. *)
583 external const_exact_sdiv : llvalue -> llvalue -> llvalue = "LLVMConstExactSDiv"
558584
559585 (** [const_fdiv c1 c2] returns the constant quotient [c1 / c2] of two floating
560586 point constants.
561587 See the method [llvm::ConstantExpr::getFDiv]. *)
562588 external const_fdiv : llvalue -> llvalue -> llvalue = "LLVMConstFDiv"
563589
564 (** [const_udiv c1 c2] returns the constant remainder [c1 MOD c2] of two
590 (** [const_urem c1 c2] returns the constant remainder [c1 MOD c2] of two
565591 unsigned integer constants.
566592 See the method [llvm::ConstantExpr::getURem]. *)
567593 external const_urem : llvalue -> llvalue -> llvalue = "LLVMConstURem"
568594
569 (** [const_sdiv c1 c2] returns the constant remainder [c1 MOD c2] of two
595 (** [const_srem c1 c2] returns the constant remainder [c1 MOD c2] of two
570596 signed integer constants.
571597 See the method [llvm::ConstantExpr::getSRem]. *)
572598 external const_srem : llvalue -> llvalue -> llvalue = "LLVMConstSRem"
623649 See the method [llvm::ConstantExpr::getGetElementPtr]. *)
624650 external const_gep : llvalue -> llvalue array -> llvalue = "llvm_const_gep"
625651
652 (** [const_in_bounds_gep pc indices] returns the constant [getElementPtr] of [p1]
653 with the constant integers indices from the array [indices].
654 See the method [llvm::ConstantExpr::getInBoundsGetElementPtr]. *)
655 external const_in_bounds_gep : llvalue -> llvalue array -> llvalue
656 = "llvm_const_in_bounds_gep"
657
626658 (** [const_trunc c ty] returns the constant truncation of integer constant [c]
627659 to the smaller integer type [ty].
628660 See the method [llvm::ConstantExpr::getTrunc]. *)
682714 to type [ty] of equal size.
683715 See the method [llvm::ConstantExpr::getBitCast]. *)
684716 external const_bitcast : llvalue -> lltype -> llvalue = "LLVMConstBitCast"
717
718 (** [const_zext_or_bitcast c ty] returns a constant zext or bitwise cast
719 conversion of constant [c] to type [ty].
720 See the method [llvm::ConstantExpr::getZExtOrBitCast]. *)
721 external const_zext_or_bitcast : llvalue -> lltype -> llvalue
722 = "LLVMConstZExtOrBitCast"
723
724 (** [const_sext_or_bitcast c ty] returns a constant sext or bitwise cast
725 conversion of constant [c] to type [ty].
726 See the method [llvm::ConstantExpr::getSExtOrBitCast]. *)
727 external const_sext_or_bitcast : llvalue -> lltype -> llvalue
728 = "LLVMConstSExtOrBitCast"
729
730 (** [const_trunc_or_bitcast c ty] returns a constant trunc or bitwise cast
731 conversion of constant [c] to type [ty].
732 See the method [llvm::ConstantExpr::getTruncOrBitCast]. *)
733 external const_trunc_or_bitcast : llvalue -> lltype -> llvalue
734 = "LLVMConstTruncOrBitCast"
735
736 (** [const_pointercast c ty] returns a constant bitcast or a pointer-to-int
737 cast conversion of constant [c] to type [ty] of equal size.
738 See the method [llvm::ConstantExpr::getPointerCast]. *)
739 external const_pointercast : llvalue -> lltype -> llvalue
740 = "LLVMConstPointerCast"
741
742 (** [const_intcast c ty] returns a constant zext, bitcast, or trunc for integer
743 -> integer casts of constant [c] to type [ty].
744 See the method [llvm::ConstantExpr::getIntCast]. *)
745 external const_intcast : llvalue -> lltype -> llvalue
746 = "LLVMConstIntCast"
747
748 (** [const_fpcast c ty] returns a constant fpext, bitcast, or fptrunc for fp ->
749 fp casts of constant [c] to type [ty].
750 See the method [llvm::ConstantExpr::getFPCast]. *)
751 external const_fpcast : llvalue -> lltype -> llvalue
752 = "LLVMConstFPCast"
685753
686754 (** [const_select cond t f] returns the constant conditional which returns value
687755 [t] if the boolean constant [cond] is true and the value [f] otherwise.
711779 See the method [llvm::ConstantExpr::getShuffleVector]. *)
712780 external const_shufflevector : llvalue -> llvalue -> llvalue -> llvalue
713781 = "LLVMConstShuffleVector"
782
783 (** [const_extractvalue agg idxs] returns the constant [idxs]th value of
784 constant aggregate [agg]. Each [idxs] must be less than the size of the
785 aggregate. See the method [llvm::ConstantExpr::getExtractValue]. *)
786 external const_extractvalue : llvalue -> int array -> llvalue
787 = "llvm_const_extractvalue"
788
789 (** [const_insertvalue agg val idxs] inserts the value [val] in the specified
790 indexs [idxs] in the aggegate [agg]. Each [idxs] must be less than the size
791 of the aggregate. See the method [llvm::ConstantExpr::getInsertValue]. *)
792 external const_insertvalue : llvalue -> llvalue -> int array -> llvalue
793 = "llvm_const_insertvalue"
714794
715795
716796 (** {7 Operations on global variables, functions, and aliases (globals)} *)
451451 Wosize_val(Indices));
452452 }
453453
454 /* llvalue -> llvalue array -> llvalue */
455 CAMLprim LLVMValueRef llvm_const_in_bounds_gep(LLVMValueRef ConstantVal,
456 value Indices) {
457 return LLVMConstInBoundsGEP(ConstantVal, (LLVMValueRef*) Op_val(Indices),
458 Wosize_val(Indices));
459 }
460
461 /* llvalue -> int array -> llvalue */
462 CAMLprim LLVMValueRef llvm_const_extractvalue(LLVMValueRef Aggregate,
463 value Indices) {
464 CAMLparam1(Indices);
465 int size = Wosize_val(Indices);
466 int i;
467 LLVMValueRef result;
468
469 unsigned* idxs = (unsigned*)malloc(size * sizeof(unsigned));
470 for (i = 0; i < size; i++) {
471 idxs[i] = Int_val(Field(Indices, i));
472 }
473
474 result = LLVMConstExtractValue(Aggregate, idxs, size);
475 free(idxs);
476 CAMLreturnT(LLVMValueRef, result);
477 }
478
479 /* llvalue -> llvalue -> int array -> llvalue */
480 CAMLprim LLVMValueRef llvm_const_insertvalue(LLVMValueRef Aggregate,
481 LLVMValueRef Val, value Indices) {
482 CAMLparam1(Indices);
483 int size = Wosize_val(Indices);
484 int i;
485 LLVMValueRef result;
486
487 unsigned* idxs = (unsigned*)malloc(size * sizeof(unsigned));
488 for (i = 0; i < size; i++) {
489 idxs[i] = Int_val(Field(Indices, i));
490 }
491
492 result = LLVMConstInsertValue(Aggregate, Val, idxs, size);
493 free(idxs);
494 CAMLreturnT(LLVMValueRef, result);
495 }
496
454497 /*--... Operations on global variables, functions, and aliases (globals) ...--*/
455498
456499 /* llvalue -> bool */