summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/gallivm
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/auxiliary/gallivm')
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_arit_overflow.c24
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_arit_overflow.h6
2 files changed, 30 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit_overflow.c b/src/gallium/auxiliary/gallivm/lp_bld_arit_overflow.c
index 91247fdbc95..152ad573451 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_arit_overflow.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_arit_overflow.c
@@ -127,6 +127,30 @@ lp_build_uadd_overflow(struct gallivm_state *gallivm,
}
/**
+ * Performs unsigned subtraction of two integers and reports
+ * overflow if detected.
+ *
+ * The values @a and @b must be of the same integer type. If
+ * an overflow is detected the IN/OUT @ofbit parameter is used:
+ * - if it's pointing to a null value, the overflow bit is simply
+ * stored inside the variable it's pointing to,
+ * - if it's pointing to a valid value, then that variable,
+ * which must be of i1 type, is ORed with the newly detected
+ * overflow bit. This is done to allow chaining of a number of
+ * overflow functions together without having to test the
+ * overflow bit after every single one.
+ */
+LLVMValueRef
+lp_build_usub_overflow(struct gallivm_state *gallivm,
+ LLVMValueRef a,
+ LLVMValueRef b,
+ LLVMValueRef *ofbit)
+{
+ return build_binary_int_overflow(gallivm, "llvm.usub.with.overflow",
+ a, b, ofbit);
+}
+
+/**
* Performs unsigned multiplication of two integers and
* reports overflow if detected.
*
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit_overflow.h b/src/gallium/auxiliary/gallivm/lp_bld_arit_overflow.h
index 8c35a04181b..34ce00ee0e8 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_arit_overflow.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_arit_overflow.h
@@ -49,6 +49,12 @@ lp_build_uadd_overflow(struct gallivm_state *gallivm,
LLVMValueRef *ofbit);
LLVMValueRef
+lp_build_usub_overflow(struct gallivm_state *gallivm,
+ LLVMValueRef a,
+ LLVMValueRef b,
+ LLVMValueRef *ofbit);
+
+LLVMValueRef
lp_build_umul_overflow(struct gallivm_state *gallivm,
LLVMValueRef a,
LLVMValueRef b,