diff options
author | Dave Airlie <[email protected]> | 2012-02-17 19:02:21 +0000 |
---|---|---|
committer | Dave Airlie <[email protected]> | 2012-02-28 10:42:17 +0000 |
commit | aec11e4daa36fb31774971ce34f04e3ebeeeeed7 (patch) | |
tree | 7de363d6cfb5b19dbe691324a3f81029d7fd4649 /src/gallium/auxiliary/gallivm/lp_bld_bitarit.c | |
parent | 72931ca4b9fb1002f5b62b74f7f7f32e94e80fde (diff) |
gallivm: add bitarit xor and not ops.
Signed-off-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/gallivm/lp_bld_bitarit.c')
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_bitarit.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_bitarit.c b/src/gallium/auxiliary/gallivm/lp_bld_bitarit.c index a9c57d682f2..97ae1622c27 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_bitarit.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_bitarit.c @@ -62,6 +62,31 @@ lp_build_or(struct lp_build_context *bld, LLVMValueRef a, LLVMValueRef b) return res; } +/* bitwise XOR (a ^ b) */ +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 +146,25 @@ lp_build_andnot(struct lp_build_context *bld, LLVMValueRef a, LLVMValueRef b) return res; } +/* bitwise NOT */ +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. |