+
+/**
+ * Build constant-valued vector from a scalar value.
+ */
+LLVMValueRef
+lp_build_const_vec(struct gallivm_state *gallivm, struct lp_type type,
+ double val)
+{
+ if (type.length == 1) {
+ return lp_build_const_elem(gallivm, type, val);
+ } else {
+ LLVMValueRef elems[LP_MAX_VECTOR_LENGTH];
+ unsigned i;
+ elems[0] = lp_build_const_elem(gallivm, type, val);
+ for(i = 1; i < type.length; ++i)
+ elems[i] = elems[0];
+ return LLVMConstVector(elems, type.length);
+ }