llvmpipe: Simpler variant of lp_build_broadcast_scalar.
authorJosé Fonseca <jfonseca@vmware.com>
Wed, 19 Aug 2009 16:57:07 +0000 (17:57 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Sat, 29 Aug 2009 08:21:35 +0000 (09:21 +0100)
src/gallium/drivers/llvmpipe/lp_bld_swizzle.c
src/gallium/drivers/llvmpipe/lp_bld_swizzle.h

index 3402d4f5d94fbccf4caf2138c185b853ac401555..5204a851d61af859eadac991ae727d59003cdf1c 100644 (file)
 #include "lp_bld_swizzle.h"
 
 
+LLVMValueRef
+lp_build_broadcast(LLVMBuilderRef builder,
+                   LLVMTypeRef vec_type,
+                   LLVMValueRef scalar)
+{
+   const unsigned n = LLVMGetVectorSize(vec_type);
+   LLVMValueRef res;
+   unsigned i;
+
+   res = LLVMGetUndef(vec_type);
+   for(i = 0; i < n; ++i) {
+      LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0);
+      res = LLVMBuildInsertElement(builder, res, scalar, index, "");
+   }
+
+   return res;
+}
+
+
 LLVMValueRef
 lp_build_broadcast_scalar(struct lp_build_context *bld,
                           LLVMValueRef scalar)
index ceaaabf9ecf0c3e634324425447af8685db23c31..7a4aa8838248487b0fbcce1ef25c090a352b2319 100644 (file)
@@ -44,6 +44,12 @@ union lp_type type;
 struct lp_build_context;
 
 
+LLVMValueRef
+lp_build_broadcast(LLVMBuilderRef builder,
+                   LLVMTypeRef vec_type,
+                   LLVMValueRef scalar);
+
+
 LLVMValueRef
 lp_build_broadcast_scalar(struct lp_build_context *bld,
                           LLVMValueRef scalar);