#include "lp_bld_arit.h"
+/**
+ * Generate min(a, b)
+ * No checks for special case values of a or b = 1 or 0 are done.
+ */
static LLVMValueRef
lp_build_min_simple(struct lp_build_context *bld,
LLVMValueRef a,
}
+/**
+ * Generate max(a, b)
+ * No checks for special case values of a or b = 1 or 0 are done.
+ */
static LLVMValueRef
lp_build_max_simple(struct lp_build_context *bld,
LLVMValueRef a,
}
+/**
+ * Generate 1 - a, or ~a depending on bld->type.
+ */
LLVMValueRef
lp_build_comp(struct lp_build_context *bld,
LLVMValueRef a)
}
+/**
+ * Generate a + b
+ */
LLVMValueRef
lp_build_add(struct lp_build_context *bld,
LLVMValueRef a,
else
res = LLVMBuildAdd(bld->builder, a, b, "");
+ /* clamp to ceiling of 1.0 */
if(bld->type.norm && (bld->type.floating || bld->type.fixed))
res = lp_build_min_simple(bld, res, bld->one);
+ /* XXX clamp to floor of -1 or 0??? */
+
return res;
}
+/**
+ * Generate a - b
+ */
LLVMValueRef
lp_build_sub(struct lp_build_context *bld,
LLVMValueRef a,
}
+/**
+ * Build constant int vector of width 'n' and value 'c'.
+ */
static LLVMValueRef
lp_build_const_vec(LLVMTypeRef type, unsigned n, long long c)
{
}
+/**
+ * Generate a * b
+ */
LLVMValueRef
lp_build_mul(struct lp_build_context *bld,
LLVMValueRef a,
}
+/**
+ * Generate a / b
+ */
LLVMValueRef
lp_build_div(struct lp_build_context *bld,
LLVMValueRef a,
}
+/**
+ * Generate min(a, b)
+ * Do checks for special cases.
+ */
LLVMValueRef
lp_build_min(struct lp_build_context *bld,
LLVMValueRef a,
}
+/**
+ * Generate max(a, b)
+ * Do checks for special cases.
+ */
LLVMValueRef
lp_build_max(struct lp_build_context *bld,
LLVMValueRef a,
}
+/**
+ * Generate abs(a)
+ */
LLVMValueRef
lp_build_abs(struct lp_build_context *bld,
LLVMValueRef a)
}
+/**
+ * Generate 1/sqrt(a)
+ */
LLVMValueRef
lp_build_rsqrt(struct lp_build_context *bld,
LLVMValueRef a)
}
+/**
+ * Generate cos(a)
+ */
LLVMValueRef
lp_build_cos(struct lp_build_context *bld,
LLVMValueRef a)
}
+/**
+ * Generate sin(a)
+ */
LLVMValueRef
lp_build_sin(struct lp_build_context *bld,
LLVMValueRef a)
}
+/**
+ * Generate pow(x, y)
+ */
LLVMValueRef
lp_build_pow(struct lp_build_context *bld,
LLVMValueRef x,
}
+/**
+ * Generate exp(x)
+ */
LLVMValueRef
lp_build_exp(struct lp_build_context *bld,
LLVMValueRef x)
}
+/**
+ * Generate log(x)
+ */
LLVMValueRef
lp_build_log(struct lp_build_context *bld,
LLVMValueRef x)
#define LOG_POLY_DEGREE 5
+/**
+ * Generate polynomial.
+ * Ex: x^2 * coeffs[0] + x * coeffs[1] + coeffs[2].
+ */
static LLVMValueRef
lp_build_polynomial(struct lp_build_context *bld,
LLVMValueRef x,