summaryrefslogtreecommitdiff
path: root/bindings
diff options
context:
space:
mode:
authorErick Tryzelaar <idadesub@users.sourceforge.net>2010-02-28 05:51:43 +0000
committerErick Tryzelaar <idadesub@users.sourceforge.net>2010-02-28 05:51:43 +0000
commit19f047f5f6c44d1cd5681f9314b3ff5e7bae122d (patch)
treebf196d080abb211c923c4233257d45751c26b8f3 /bindings
parent1940dd10dd6b79e3332f384756c268b85d0ad400 (diff)
downloadllvm-19f047f5f6c44d1cd5681f9314b3ff5e7bae122d.tar.gz
llvm-19f047f5f6c44d1cd5681f9314b3ff5e7bae122d.tar.bz2
llvm-19f047f5f6c44d1cd5681f9314b3ff5e7bae122d.tar.xz
Add the new builder arthmetic instructions to llvm-c and ocaml.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97372 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings')
-rw-r--r--bindings/ocaml/llvm/llvm.ml23
-rw-r--r--bindings/ocaml/llvm/llvm.mli94
-rw-r--r--bindings/ocaml/llvm/llvm_ocaml.c48
3 files changed, 165 insertions, 0 deletions
diff --git a/bindings/ocaml/llvm/llvm.ml b/bindings/ocaml/llvm/llvm.ml
index c2226b10da..0c2cebd6a2 100644
--- a/bindings/ocaml/llvm/llvm.ml
+++ b/bindings/ocaml/llvm/llvm.ml
@@ -270,14 +270,21 @@ external const_union : lltype -> llvalue -> llvalue = "LLVMConstUnion"
external align_of : lltype -> llvalue = "LLVMAlignOf"
external size_of : lltype -> llvalue = "LLVMSizeOf"
external const_neg : llvalue -> llvalue = "LLVMConstNeg"
+external const_nsw_neg : llvalue -> llvalue = "LLVMConstNSWNeg"
+external const_nuw_neg : llvalue -> llvalue = "LLVMConstNUWNeg"
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_nuw_add : llvalue -> llvalue -> llvalue = "LLVMConstNUWAdd"
external const_fadd : llvalue -> llvalue -> llvalue = "LLVMConstFAdd"
external const_sub : llvalue -> llvalue -> llvalue = "LLVMConstSub"
+external const_nsw_sub : llvalue -> llvalue -> llvalue = "LLVMConstNSWSub"
+external const_nuw_sub : llvalue -> llvalue -> llvalue = "LLVMConstNUWSub"
external const_fsub : llvalue -> llvalue -> llvalue = "LLVMConstFSub"
external const_mul : llvalue -> llvalue -> llvalue = "LLVMConstMul"
+external const_nsw_mul : llvalue -> llvalue -> llvalue = "LLVMConstNSWMul"
+external const_nuw_mul : llvalue -> llvalue -> llvalue = "LLVMConstNUWMul"
external const_fmul : llvalue -> llvalue -> llvalue = "LLVMConstFMul"
external const_udiv : llvalue -> llvalue -> llvalue = "LLVMConstUDiv"
external const_sdiv : llvalue -> llvalue -> llvalue = "LLVMConstSDiv"
@@ -711,14 +718,24 @@ external build_add : llvalue -> llvalue -> string -> llbuilder -> llvalue
= "llvm_build_add"
external build_nsw_add : llvalue -> llvalue -> string -> llbuilder -> llvalue
= "llvm_build_nsw_add"
+external build_nuw_add : llvalue -> llvalue -> string -> llbuilder -> llvalue
+ = "llvm_build_nuw_add"
external build_fadd : llvalue -> llvalue -> string -> llbuilder -> llvalue
= "llvm_build_fadd"
external build_sub : llvalue -> llvalue -> string -> llbuilder -> llvalue
= "llvm_build_sub"
+external build_nsw_sub : llvalue -> llvalue -> string -> llbuilder -> llvalue
+ = "llvm_build_nsw_sub"
+external build_nuw_sub : llvalue -> llvalue -> string -> llbuilder -> llvalue
+ = "llvm_build_nuw_sub"
external build_fsub : llvalue -> llvalue -> string -> llbuilder -> llvalue
= "llvm_build_fsub"
external build_mul : llvalue -> llvalue -> string -> llbuilder -> llvalue
= "llvm_build_mul"
+external build_nsw_mul : llvalue -> llvalue -> string -> llbuilder -> llvalue
+ = "llvm_build_nsw_mul"
+external build_nuw_mul : llvalue -> llvalue -> string -> llbuilder -> llvalue
+ = "llvm_build_nuw_mul"
external build_fmul : llvalue -> llvalue -> string -> llbuilder -> llvalue
= "llvm_build_fmul"
external build_udiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
@@ -749,6 +766,12 @@ external build_xor : llvalue -> llvalue -> string -> llbuilder -> llvalue
= "llvm_build_xor"
external build_neg : llvalue -> string -> llbuilder -> llvalue
= "llvm_build_neg"
+external build_nsw_neg : llvalue -> string -> llbuilder -> llvalue
+ = "llvm_build_nsw_neg"
+external build_nuw_neg : llvalue -> string -> llbuilder -> llvalue
+ = "llvm_build_nuw_neg"
+external build_fneg : llvalue -> string -> llbuilder -> llvalue
+ = "llvm_build_fneg"
external build_not : llvalue -> string -> llbuilder -> llvalue
= "llvm_build_not"
diff --git a/bindings/ocaml/llvm/llvm.mli b/bindings/ocaml/llvm/llvm.mli
index 2eaee9e25a..98ba05f208 100644
--- a/bindings/ocaml/llvm/llvm.mli
+++ b/bindings/ocaml/llvm/llvm.mli
@@ -615,6 +615,16 @@ external size_of : lltype -> llvalue = "LLVMSizeOf"
See the method [llvm::ConstantExpr::getNeg]. *)
external const_neg : llvalue -> llvalue = "LLVMConstNeg"
+(** [const_nsw_neg c] returns the arithmetic negation of the constant [c] with
+ no signed wrapping. The result is undefined if the negation overflows.
+ See the method [llvm::ConstantExpr::getNSWNeg]. *)
+external const_nsw_neg : llvalue -> llvalue = "LLVMConstNSWNeg"
+
+(** [const_nuw_neg c] returns the arithmetic negation of the constant [c] with
+ no unsigned wrapping. The result is undefined if the negation overflows.
+ See the method [llvm::ConstantExpr::getNUWNeg]. *)
+external const_nuw_neg : llvalue -> llvalue = "LLVMConstNUWNeg"
+
(** [const_fneg c] returns the arithmetic negation of the constant float [c].
See the method [llvm::ConstantExpr::getFNeg]. *)
external const_fneg : llvalue -> llvalue = "LLVMConstFNeg"
@@ -632,6 +642,11 @@ external const_add : llvalue -> llvalue -> llvalue = "LLVMConstAdd"
See the method [llvm::ConstantExpr::getNSWAdd]. *)
external const_nsw_add : llvalue -> llvalue -> llvalue = "LLVMConstNSWAdd"
+(** [const_nuw_add c1 c2] returns the constant sum of two constants with no
+ unsigned wrapping. The result is undefined if the sum overflows.
+ See the method [llvm::ConstantExpr::getNSWAdd]. *)
+external const_nuw_add : llvalue -> llvalue -> llvalue = "LLVMConstNUWAdd"
+
(** [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"
@@ -640,6 +655,16 @@ external const_fadd : llvalue -> llvalue -> llvalue = "LLVMConstFAdd"
constants. See the method [llvm::ConstantExpr::getSub]. *)
external const_sub : llvalue -> llvalue -> llvalue = "LLVMConstSub"
+(** [const_nsw_sub c1 c2] returns the constant difference of two constants with
+ no signed wrapping. The result is undefined if the sum overflows.
+ See the method [llvm::ConstantExpr::getNSWSub]. *)
+external const_nsw_sub : llvalue -> llvalue -> llvalue = "LLVMConstNSWSub"
+
+(** [const_nuw_sub c1 c2] returns the constant difference of two constants with
+ no unsigned wrapping. The result is undefined if the sum overflows.
+ See the method [llvm::ConstantExpr::getNSWSub]. *)
+external const_nuw_sub : llvalue -> llvalue -> llvalue = "LLVMConstNUWSub"
+
(** [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"
@@ -648,6 +673,16 @@ external const_fsub : llvalue -> llvalue -> llvalue = "LLVMConstFSub"
See the method [llvm::ConstantExpr::getMul]. *)
external const_mul : llvalue -> llvalue -> llvalue = "LLVMConstMul"
+(** [const_nsw_mul c1 c2] returns the constant product of two constants with
+ no signed wrapping. The result is undefined if the sum overflows.
+ See the method [llvm::ConstantExpr::getNSWMul]. *)
+external const_nsw_mul : llvalue -> llvalue -> llvalue = "LLVMConstNSWMul"
+
+(** [const_nuw_mul c1 c2] returns the constant product of two constants with
+ no unsigned wrapping. The result is undefined if the sum overflows.
+ See the method [llvm::ConstantExpr::getNSWMul]. *)
+external const_nuw_mul : llvalue -> llvalue -> llvalue = "LLVMConstNUWMul"
+
(** [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"
@@ -1502,6 +1537,13 @@ external build_add : llvalue -> llvalue -> string -> llbuilder -> llvalue
external build_nsw_add : llvalue -> llvalue -> string -> llbuilder -> llvalue
= "llvm_build_nsw_add"
+(** [build_nuw_add x y name b] creates a
+ [%name = nuw add %x, %y]
+ instruction at the position specified by the instruction builder [b].
+ See the method [llvm::LLVMBuilder::CreateNUWAdd]. *)
+external build_nuw_add : llvalue -> llvalue -> string -> llbuilder -> llvalue
+ = "llvm_build_nuw_add"
+
(** [build_fadd x y name b] creates a
[%name = fadd %x, %y]
instruction at the position specified by the instruction builder [b].
@@ -1516,6 +1558,20 @@ external build_fadd : llvalue -> llvalue -> string -> llbuilder -> llvalue
external build_sub : llvalue -> llvalue -> string -> llbuilder -> llvalue
= "llvm_build_sub"
+(** [build_nsw_sub x y name b] creates a
+ [%name = nsw sub %x, %y]
+ instruction at the position specified by the instruction builder [b].
+ See the method [llvm::LLVMBuilder::CreateNSWSub]. *)
+external build_nsw_sub : llvalue -> llvalue -> string -> llbuilder -> llvalue
+ = "llvm_build_nsw_sub"
+
+(** [build_nuw_sub x y name b] creates a
+ [%name = nuw sub %x, %y]
+ instruction at the position specified by the instruction builder [b].
+ See the method [llvm::LLVMBuilder::CreateNUWSub]. *)
+external build_nuw_sub : llvalue -> llvalue -> string -> llbuilder -> llvalue
+ = "llvm_build_nuw_sub"
+
(** [build_fsub x y name b] creates a
[%name = fsub %x, %y]
instruction at the position specified by the instruction builder [b].
@@ -1530,6 +1586,20 @@ external build_fsub : llvalue -> llvalue -> string -> llbuilder -> llvalue
external build_mul : llvalue -> llvalue -> string -> llbuilder -> llvalue
= "llvm_build_mul"
+(** [build_nsw_mul x y name b] creates a
+ [%name = nsw mul %x, %y]
+ instruction at the position specified by the instruction builder [b].
+ See the method [llvm::LLVMBuilder::CreateNSWMul]. *)
+external build_nsw_mul : llvalue -> llvalue -> string -> llbuilder -> llvalue
+ = "llvm_build_nsw_mul"
+
+(** [build_nuw_mul x y name b] creates a
+ [%name = nuw mul %x, %y]
+ instruction at the position specified by the instruction builder [b].
+ See the method [llvm::LLVMBuilder::CreateNUWMul]. *)
+external build_nuw_mul : llvalue -> llvalue -> string -> llbuilder -> llvalue
+ = "llvm_build_nuw_mul"
+
(** [build_fmul x y name b] creates a
[%name = fmul %x, %y]
instruction at the position specified by the instruction builder [b].
@@ -1636,6 +1706,30 @@ external build_xor : llvalue -> llvalue -> string -> llbuilder -> llvalue
external build_neg : llvalue -> string -> llbuilder -> llvalue
= "llvm_build_neg"
+(** [build_nsw_neg x name b] creates a
+ [%name = nsw sub 0, %x]
+ instruction at the position specified by the instruction builder [b].
+ [-0.0] is used for floating point types to compute the correct sign.
+ See the method [llvm::LLVMBuilder::CreateNeg]. *)
+external build_nsw_neg : llvalue -> string -> llbuilder -> llvalue
+ = "llvm_build_nsw_neg"
+
+(** [build_nuw_neg x name b] creates a
+ [%name = nuw sub 0, %x]
+ instruction at the position specified by the instruction builder [b].
+ [-0.0] is used for floating point types to compute the correct sign.
+ See the method [llvm::LLVMBuilder::CreateNeg]. *)
+external build_nuw_neg : llvalue -> string -> llbuilder -> llvalue
+ = "llvm_build_nuw_neg"
+
+(** [build_fneg x name b] creates a
+ [%name = fsub 0, %x]
+ instruction at the position specified by the instruction builder [b].
+ [-0.0] is used for floating point types to compute the correct sign.
+ See the method [llvm::LLVMBuilder::CreateFNeg]. *)
+external build_fneg : llvalue -> string -> llbuilder -> llvalue
+ = "llvm_build_fneg"
+
(** [build_xor x name b] creates a
[%name = xor %x, -1]
instruction at the position specified by the instruction builder [b].
diff --git a/bindings/ocaml/llvm/llvm_ocaml.c b/bindings/ocaml/llvm/llvm_ocaml.c
index 9000c38303..2b6eb56d98 100644
--- a/bindings/ocaml/llvm/llvm_ocaml.c
+++ b/bindings/ocaml/llvm/llvm_ocaml.c
@@ -1096,6 +1096,12 @@ CAMLprim LLVMValueRef llvm_build_nsw_add(LLVMValueRef LHS, LLVMValueRef RHS,
}
/* llvalue -> llvalue -> string -> llbuilder -> llvalue */
+CAMLprim LLVMValueRef llvm_build_nuw_add(LLVMValueRef LHS, LLVMValueRef RHS,
+ value Name, value B) {
+ return LLVMBuildNUWAdd(Builder_val(B), LHS, RHS, String_val(Name));
+}
+
+/* llvalue -> llvalue -> string -> llbuilder -> llvalue */
CAMLprim LLVMValueRef llvm_build_fadd(LLVMValueRef LHS, LLVMValueRef RHS,
value Name, value B) {
return LLVMBuildFAdd(Builder_val(B), LHS, RHS, String_val(Name));
@@ -1108,6 +1114,18 @@ CAMLprim LLVMValueRef llvm_build_sub(LLVMValueRef LHS, LLVMValueRef RHS,
}
/* llvalue -> llvalue -> string -> llbuilder -> llvalue */
+CAMLprim LLVMValueRef llvm_build_nsw_sub(LLVMValueRef LHS, LLVMValueRef RHS,
+ value Name, value B) {
+ return LLVMBuildNSWSub(Builder_val(B), LHS, RHS, String_val(Name));
+}
+
+/* llvalue -> llvalue -> string -> llbuilder -> llvalue */
+CAMLprim LLVMValueRef llvm_build_nuw_sub(LLVMValueRef LHS, LLVMValueRef RHS,
+ value Name, value B) {
+ return LLVMBuildNUWSub(Builder_val(B), LHS, RHS, String_val(Name));
+}
+
+/* llvalue -> llvalue -> string -> llbuilder -> llvalue */
CAMLprim LLVMValueRef llvm_build_fsub(LLVMValueRef LHS, LLVMValueRef RHS,
value Name, value B) {
return LLVMBuildFSub(Builder_val(B), LHS, RHS, String_val(Name));
@@ -1120,6 +1138,18 @@ CAMLprim LLVMValueRef llvm_build_mul(LLVMValueRef LHS, LLVMValueRef RHS,
}
/* llvalue -> llvalue -> string -> llbuilder -> llvalue */
+CAMLprim LLVMValueRef llvm_build_nsw_mul(LLVMValueRef LHS, LLVMValueRef RHS,
+ value Name, value B) {
+ return LLVMBuildNSWMul(Builder_val(B), LHS, RHS, String_val(Name));
+}
+
+/* llvalue -> llvalue -> string -> llbuilder -> llvalue */
+CAMLprim LLVMValueRef llvm_build_nuw_mul(LLVMValueRef LHS, LLVMValueRef RHS,
+ value Name, value B) {
+ return LLVMBuildNUWMul(Builder_val(B), LHS, RHS, String_val(Name));
+}
+
+/* llvalue -> llvalue -> string -> llbuilder -> llvalue */
CAMLprim LLVMValueRef llvm_build_fmul(LLVMValueRef LHS, LLVMValueRef RHS,
value Name, value B) {
return LLVMBuildFMul(Builder_val(B), LHS, RHS, String_val(Name));
@@ -1210,6 +1240,24 @@ CAMLprim LLVMValueRef llvm_build_neg(LLVMValueRef X,
}
/* llvalue -> string -> llbuilder -> llvalue */
+CAMLprim LLVMValueRef llvm_build_nsw_neg(LLVMValueRef X,
+ value Name, value B) {
+ return LLVMBuildNSWNeg(Builder_val(B), X, String_val(Name));
+}
+
+/* llvalue -> string -> llbuilder -> llvalue */
+CAMLprim LLVMValueRef llvm_build_nuw_neg(LLVMValueRef X,
+ value Name, value B) {
+ return LLVMBuildNUWNeg(Builder_val(B), X, String_val(Name));
+}
+
+/* llvalue -> string -> llbuilder -> llvalue */
+CAMLprim LLVMValueRef llvm_build_fneg(LLVMValueRef X,
+ value Name, value B) {
+ return LLVMBuildFNeg(Builder_val(B), X, String_val(Name));
+}
+
+/* llvalue -> string -> llbuilder -> llvalue */
CAMLprim LLVMValueRef llvm_build_not(LLVMValueRef X,
value Name, value B) {
return LLVMBuildNot(Builder_val(B), X, String_val(Name));