diff options
author | Samuel Pitoiset <[email protected]> | 2018-09-14 12:52:33 +0200 |
---|---|---|
committer | Samuel Pitoiset <[email protected]> | 2018-09-17 15:18:23 +0200 |
commit | 074e29183cbe69450fe9ce65024bff5194038319 (patch) | |
tree | 7c8b988fefdcf7e140923dffef69127867ef1919 /src/amd | |
parent | 371c35e5bb19989953e371be924fb0b908407c47 (diff) |
ac: add ac_build_bifield_reverse() helper
Are we missing 64-bit support?
Signed-off-by: Samuel Pitoiset <[email protected]>
Reviewed-by: Bas Nieuwenhuizen <[email protected]>
Diffstat (limited to 'src/amd')
-rw-r--r-- | src/amd/common/ac_llvm_build.c | 22 | ||||
-rw-r--r-- | src/amd/common/ac_llvm_build.h | 3 | ||||
-rw-r--r-- | src/amd/common/ac_nir_to_llvm.c | 2 |
3 files changed, 26 insertions, 1 deletions
diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c index 4fbe0ddb9c5..a99314266c2 100644 --- a/src/amd/common/ac_llvm_build.c +++ b/src/amd/common/ac_llvm_build.c @@ -2135,6 +2135,28 @@ LLVMValueRef ac_build_bit_count(struct ac_llvm_context *ctx, LLVMValueRef src0) return result; } +LLVMValueRef ac_build_bitfield_reverse(struct ac_llvm_context *ctx, + LLVMValueRef src0) +{ + LLVMValueRef result; + unsigned bitsize; + + bitsize = ac_get_elem_bits(ctx, LLVMTypeOf(src0)); + + switch (bitsize) { + case 32: + result = ac_build_intrinsic(ctx, "llvm.bitreverse.i32", ctx->i32, + (LLVMValueRef []) { src0 }, 1, + AC_FUNC_ATTR_READNONE); + break; + default: + unreachable(!"invalid bitsize"); + break; + } + + return result; +} + #define AC_EXP_TARGET 0 #define AC_EXP_ENABLED_CHANNELS 1 #define AC_EXP_OUT0 2 diff --git a/src/amd/common/ac_llvm_build.h b/src/amd/common/ac_llvm_build.h index 98a61a24054..8524d1fa769 100644 --- a/src/amd/common/ac_llvm_build.h +++ b/src/amd/common/ac_llvm_build.h @@ -426,6 +426,9 @@ LLVMValueRef ac_build_fsign(struct ac_llvm_context *ctx, LLVMValueRef src0, LLVMValueRef ac_build_bit_count(struct ac_llvm_context *ctx, LLVMValueRef src0); +LLVMValueRef ac_build_bitfield_reverse(struct ac_llvm_context *ctx, + LLVMValueRef src0); + void ac_optimize_vs_outputs(struct ac_llvm_context *ac, LLVMValueRef main_fn, uint8_t *vs_output_param_offset, diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index d79ff4399b1..b01309cc2a9 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -836,7 +836,7 @@ static void visit_alu(struct ac_nir_context *ctx, const nir_alu_instr *instr) result = emit_bitfield_insert(&ctx->ac, src[0], src[1], src[2], src[3]); break; case nir_op_bitfield_reverse: - result = ac_build_intrinsic(&ctx->ac, "llvm.bitreverse.i32", ctx->ac.i32, src, 1, AC_FUNC_ATTR_READNONE); + result = ac_build_bitfield_reverse(&ctx->ac, src[0]); break; case nir_op_bit_count: result = ac_build_bit_count(&ctx->ac, src[0]); |