On 02/17/2012 12:02 PM, Dave Airlie wrote:
From: Dave Airlie<[email protected]>

Signed-off-by: Dave Airlie<[email protected]>
---
  src/gallium/auxiliary/gallivm/lp_bld_bitarit.c |   42 ++++++++++++++++++++++++
  src/gallium/auxiliary/gallivm/lp_bld_bitarit.h |    5 +++
  2 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_bitarit.c 
b/src/gallium/auxiliary/gallivm/lp_bld_bitarit.c
index a9c57d6..0a1ace1 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_bitarit.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_bitarit.c
@@ -62,6 +62,30 @@ lp_build_or(struct lp_build_context *bld, LLVMValueRef a, 
LLVMValueRef b)
     return res;
  }

+LLVMValueRef
+lp_build_xor(struct lp_build_context *bld, LLVMValueRef a, LLVMValueRef b)
+{
+   LLVMBuilderRef builder = bld->gallivm->builder;
+   const struct lp_type type = bld->type;
+   LLVMValueRef res;
+
+   assert(lp_check_value(type, a));
+   assert(lp_check_value(type, b));
+
+   /* can't do bitwise ops on floating-point values */
+   if (type.floating) {
+      a = LLVMBuildBitCast(builder, a, bld->int_vec_type, "");
+      b = LLVMBuildBitCast(builder, b, bld->int_vec_type, "");
+   }
+
+   res = LLVMBuildXor(builder, a, b, "");
+
+   if (type.floating) {
+      res = LLVMBuildBitCast(builder, res, bld->vec_type, "");
+   }
+
+   return res;
+}

  /**
   * Return (a&  b)
@@ -121,6 +145,24 @@ lp_build_andnot(struct lp_build_context *bld, LLVMValueRef 
a, LLVMValueRef b)
     return res;
  }

+LLVMValueRef
+lp_build_not(struct lp_build_context *bld, LLVMValueRef a)
+{
+   LLVMBuilderRef builder = bld->gallivm->builder;
+   const struct lp_type type = bld->type;
+   LLVMValueRef res;
+
+   assert(lp_check_value(type, a));
+
+   if (type.floating) {
+      a = LLVMBuildBitCast(builder, a, bld->int_vec_type, "");
+   }
+   res = LLVMBuildNot(builder, a, "");
+   if (type.floating) {
+      res = LLVMBuildBitCast(builder, res, bld->vec_type, "");
+   }
+   return res;
+}

  /**
   * Shift left.

Looks good, but would you mind adding comments to those function just be clear about whether the operations are bitwise or logical?

-Brian
_______________________________________________
mesa-dev mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to