gallivm: Add function lp_bld_gather_values()
authorTom Stellard <thomas.stellard@amd.com>
Wed, 11 Jan 2012 18:05:16 +0000 (13:05 -0500)
committerTom Stellard <thomas.stellard@amd.com>
Mon, 30 Jan 2012 18:37:00 +0000 (13:37 -0500)
src/gallium/auxiliary/gallivm/lp_bld_gather.c
src/gallium/auxiliary/gallivm/lp_bld_gather.h

index 0dc81b1abbedcb35077527a9c47ac296374fbd0b..1bdd4e4845afb8ee862fe2f8c0ff1073f3db2035 100644 (file)
@@ -147,3 +147,20 @@ lp_build_gather(struct gallivm_state *gallivm,
 
    return res;
 }
+
+LLVMValueRef
+lp_build_gather_values(struct gallivm_state * gallivm,
+                       LLVMValueRef * values,
+                       unsigned value_count)
+{
+   LLVMTypeRef vec_type = LLVMVectorType(LLVMTypeOf(values[0]), value_count);
+   LLVMBuilderRef builder = gallivm->builder;
+   LLVMValueRef vec = LLVMGetUndef(vec_type);
+   unsigned i;
+
+   for (i = 0; i < value_count; i++) {
+      LLVMValueRef index = lp_build_const_int32(gallivm, i);
+      vec = LLVMBuildInsertElement(builder, vec, values[i], index, "");
+   }
+   return vec;
+}
index 5b0413173027a68c86b0975cf7ad700cc8257a92..8e4c07d82b8d706212c85e273e2fd5f09b5d11e7 100644 (file)
@@ -57,5 +57,9 @@ lp_build_gather(struct gallivm_state *gallivm,
                 LLVMValueRef base_ptr,
                 LLVMValueRef offsets);
 
+LLVMValueRef
+lp_build_gather_values(struct gallivm_state * gallivm,
+                       LLVMValueRef * values,
+                       unsigned value_count);
 
 #endif /* LP_BLD_GATHER_H_ */