diff options
author | Gordon Henriksen <gordonhenriksen@mac.com> | 2007-10-06 14:29:36 +0000 |
---|---|---|
committer | Gordon Henriksen <gordonhenriksen@mac.com> | 2007-10-06 14:29:36 +0000 |
commit | 4647569fe7706e76135a08ca0e5f90a447ccc5b4 (patch) | |
tree | 3048a0ee53d324bd3ec7b2998a81a55334579e88 /bindings/ocaml | |
parent | 57db1734af6d7bc9bb2659272122f875d62946a4 (diff) |
Adding C and Ocaml bindings for ConstantExpr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42696 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings/ocaml')
-rw-r--r-- | bindings/ocaml/llvm/llvm.ml | 45 | ||||
-rw-r--r-- | bindings/ocaml/llvm/llvm.mli | 45 | ||||
-rw-r--r-- | bindings/ocaml/llvm/llvm_ocaml.c | 40 |
3 files changed, 121 insertions, 9 deletions
diff --git a/bindings/ocaml/llvm/llvm.ml b/bindings/ocaml/llvm/llvm.ml index 5121291cea..79de1c760b 100644 --- a/bindings/ocaml/llvm/llvm.ml +++ b/bindings/ocaml/llvm/llvm.ml @@ -209,6 +209,51 @@ external make_struct_constant : llvalue array -> bool -> llvalue external make_vector_constant : llvalue array -> llvalue = "llvm_make_vector_constant" +(*--... Constant expressions ...............................................--*) +external sizeof : lltype -> llvalue = "LLVMSizeOf" +external const_neg : llvalue -> llvalue = "LLVMConstNeg" +external const_not : llvalue -> llvalue = "LLVMConstNot" +external const_add : llvalue -> llvalue -> llvalue = "LLVMConstAdd" +external const_sub : llvalue -> llvalue -> llvalue = "LLVMConstSub" +external const_mul : llvalue -> llvalue -> llvalue = "LLVMConstMul" +external const_udiv : llvalue -> llvalue -> llvalue = "LLVMConstUDiv" +external const_sdiv : llvalue -> llvalue -> llvalue = "LLVMConstSDiv" +external const_fdiv : llvalue -> llvalue -> llvalue = "LLVMConstFDiv" +external const_urem : llvalue -> llvalue -> llvalue = "LLVMConstURem" +external const_srem : llvalue -> llvalue -> llvalue = "LLVMConstSRem" +external const_frem : llvalue -> llvalue -> llvalue = "LLVMConstFRem" +external const_and : llvalue -> llvalue -> llvalue = "LLVMConstAnd" +external const_or : llvalue -> llvalue -> llvalue = "LLVMConstOr" +external const_xor : llvalue -> llvalue -> llvalue = "LLVMConstXor" +external const_icmp : int_predicate -> llvalue -> llvalue -> llvalue + = "llvm_const_icmp" +external const_fcmp : real_predicate -> llvalue -> llvalue -> llvalue + = "llvm_const_fcmp" +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_trunc : llvalue -> lltype -> llvalue = "LLVMConstTrunc" +external const_sext : llvalue -> lltype -> llvalue = "LLVMConstSExt" +external const_zext : llvalue -> lltype -> llvalue = "LLVMConstZExt" +external const_fptrunc : llvalue -> lltype -> llvalue = "LLVMConstFPTrunc" +external const_fpext : llvalue -> lltype -> llvalue = "LLVMConstFPExt" +external const_uitofp : llvalue -> lltype -> llvalue = "LLVMConstUIToFP" +external const_sitofp : llvalue -> lltype -> llvalue = "LLVMConstSIToFP" +external const_fptoui : llvalue -> lltype -> llvalue = "LLVMConstFPToUI" +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_select : llvalue -> llvalue -> llvalue -> llvalue + = "LLVMConstSelect" +external const_extractelement : llvalue -> llvalue -> llvalue + = "LLVMConstExtractElement" +external const_insertelement : llvalue -> llvalue -> llvalue -> llvalue + = "LLVMConstInsertElement" +external const_shufflevector : llvalue -> llvalue -> llvalue -> llvalue + = "LLVMConstShuffleVector" + (*--... Operations on global variables, functions, and aliases (globals) ...--*) external is_declaration : llvalue -> bool = "llvm_is_declaration" external linkage : llvalue -> linkage = "llvm_linkage" diff --git a/bindings/ocaml/llvm/llvm.mli b/bindings/ocaml/llvm/llvm.mli index 85b93ae19d..943563acb2 100644 --- a/bindings/ocaml/llvm/llvm.mli +++ b/bindings/ocaml/llvm/llvm.mli @@ -192,6 +192,51 @@ external make_struct_constant : llvalue array -> bool -> llvalue external make_vector_constant : llvalue array -> llvalue = "llvm_make_vector_constant" +(*--... Constant expressions ...............................................--*) +external sizeof : lltype -> llvalue = "LLVMSizeOf" +external const_neg : llvalue -> llvalue = "LLVMConstNeg" +external const_not : llvalue -> llvalue = "LLVMConstNot" +external const_add : llvalue -> llvalue -> llvalue = "LLVMConstAdd" +external const_sub : llvalue -> llvalue -> llvalue = "LLVMConstSub" +external const_mul : llvalue -> llvalue -> llvalue = "LLVMConstMul" +external const_udiv : llvalue -> llvalue -> llvalue = "LLVMConstUDiv" +external const_sdiv : llvalue -> llvalue -> llvalue = "LLVMConstSDiv" +external const_fdiv : llvalue -> llvalue -> llvalue = "LLVMConstFDiv" +external const_urem : llvalue -> llvalue -> llvalue = "LLVMConstURem" +external const_srem : llvalue -> llvalue -> llvalue = "LLVMConstSRem" +external const_frem : llvalue -> llvalue -> llvalue = "LLVMConstFRem" +external const_and : llvalue -> llvalue -> llvalue = "LLVMConstAnd" +external const_or : llvalue -> llvalue -> llvalue = "LLVMConstOr" +external const_xor : llvalue -> llvalue -> llvalue = "LLVMConstXor" +external const_icmp : int_predicate -> llvalue -> llvalue -> llvalue + = "llvm_const_icmp" +external const_fcmp : real_predicate -> llvalue -> llvalue -> llvalue + = "llvm_const_fcmp" +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_trunc : llvalue -> lltype -> llvalue = "LLVMConstTrunc" +external const_sext : llvalue -> lltype -> llvalue = "LLVMConstSExt" +external const_zext : llvalue -> lltype -> llvalue = "LLVMConstZExt" +external const_fptrunc : llvalue -> lltype -> llvalue = "LLVMConstFPTrunc" +external const_fpext : llvalue -> lltype -> llvalue = "LLVMConstFPExt" +external const_uitofp : llvalue -> lltype -> llvalue = "LLVMConstUIToFP" +external const_sitofp : llvalue -> lltype -> llvalue = "LLVMConstSIToFP" +external const_fptoui : llvalue -> lltype -> llvalue = "LLVMConstFPToUI" +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_select : llvalue -> llvalue -> llvalue -> llvalue + = "LLVMConstSelect" +external const_extractelement : llvalue -> llvalue -> llvalue + = "LLVMConstExtractElement" +external const_insertelement : llvalue -> llvalue -> llvalue -> llvalue + = "LLVMConstInsertElement" +external const_shufflevector : llvalue -> llvalue -> llvalue -> llvalue + = "LLVMConstShuffleVector" + (*--... Operations on global variables, functions, and aliases (globals) ...--*) external is_declaration : llvalue -> bool = "llvm_is_declaration" external linkage : llvalue -> linkage = "llvm_linkage" diff --git a/bindings/ocaml/llvm/llvm_ocaml.c b/bindings/ocaml/llvm/llvm_ocaml.c index bc6e0b70f0..47f1936892 100644 --- a/bindings/ocaml/llvm/llvm_ocaml.c +++ b/bindings/ocaml/llvm/llvm_ocaml.c @@ -139,10 +139,10 @@ CAMLprim value llvm_param_types(LLVMTypeRef FunTy) { /*--... Operations on struct types .........................................--*/ /* lltype array -> bool -> lltype */ -CAMLprim value llvm_make_struct_type(value ElementTypes, value Packed) { - return (value) LLVMCreateStructType((LLVMTypeRef *) ElementTypes, - Wosize_val(ElementTypes), - Bool_val(Packed)); +CAMLprim LLVMTypeRef llvm_make_struct_type(value ElementTypes, value Packed) { + return LLVMCreateStructType((LLVMTypeRef *) ElementTypes, + Wosize_val(ElementTypes), + Bool_val(Packed)); } /* lltype -> lltype array */ @@ -160,8 +160,8 @@ CAMLprim value llvm_is_packed(LLVMTypeRef StructTy) { /*--... Operations on array, pointer, and vector types .....................--*/ /* lltype -> int -> lltype */ -CAMLprim value llvm_make_array_type(LLVMTypeRef ElementTy, value Count) { - return (value) LLVMCreateArrayType(ElementTy, Int_val(Count)); +CAMLprim LLVMTypeRef llvm_make_array_type(LLVMTypeRef ElementTy, value Count) { + return LLVMCreateArrayType(ElementTy, Int_val(Count)); } /* lltype -> lltype */ @@ -291,9 +291,31 @@ CAMLprim LLVMValueRef llvm_make_struct_constant(value ElementVals, } /* llvalue array -> llvalue */ -CAMLprim value llvm_make_vector_constant(value ElementVals) { - return (value) LLVMGetVectorConstant((LLVMValueRef*) Op_val(ElementVals), - Wosize_val(ElementVals)); +CAMLprim LLVMValueRef llvm_make_vector_constant(value ElementVals) { + return LLVMGetVectorConstant((LLVMValueRef*) Op_val(ElementVals), + Wosize_val(ElementVals)); +} + +/*--... Constant expressions ...............................................--*/ + +/* int_predicate -> llvalue -> llvalue -> llvalue */ +CAMLprim LLVMValueRef llvm_const_icmp(value Pred, + LLVMValueRef LHSConstant, + LLVMValueRef RHSConstant) { + return LLVMConstICmp(Int_val(Pred) + LLVMIntEQ, LHSConstant, RHSConstant); +} + +/* real_predicate -> llvalue -> llvalue -> llvalue */ +CAMLprim LLVMValueRef llvm_const_fcmp(value Pred, + LLVMValueRef LHSConstant, + LLVMValueRef RHSConstant) { + return LLVMConstFCmp(Int_val(Pred), LHSConstant, RHSConstant); +} + +/* llvalue -> llvalue array -> llvalue */ +CAMLprim LLVMValueRef llvm_const_gep(LLVMValueRef ConstantVal, value Indices) { + return LLVMConstGEP(ConstantVal, (LLVMValueRef*) Op_val(Indices), + Wosize_val(Indices)); } /*--... Operations on global variables, functions, and aliases (globals) ...--*/ |