From cd6e9ad36a27010df78d9e3ae4f4d31fb38fb180 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Wed, 6 Oct 2021 14:50:09 +0200 Subject: [PATCH] llvmpipe: add missing NIR alu-op handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit nir_op_bcsel implemented based on ac_nir_to_llvm.c emit_bcsel function. Reviewed-by: Marek Olšák Part-of: --- src/gallium/auxiliary/gallivm/lp_bld_nir.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir.c b/src/gallium/auxiliary/gallivm/lp_bld_nir.c index ca56330f9ef..6dbb840cd73 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_nir.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_nir.c @@ -719,6 +719,7 @@ static LLVMValueRef do_alu_action(struct lp_build_nir_context *bld_base, result = lp_build_sub(flt_bld, src[0], tmp); break; } + case nir_op_fge: case nir_op_fge32: result = fcmp32(bld_base, PIPE_FUNC_GEQUAL, src_bit_size[0], src); break; @@ -1044,6 +1045,26 @@ static LLVMValueRef do_alu_action(struct lp_build_nir_context *bld_base, result = lp_build_shr(uint_bld, src[0], src[1]); break; } + case nir_op_bcsel: { + LLVMTypeRef src1_type = LLVMTypeOf(src[1]); + LLVMTypeRef src2_type = LLVMTypeOf(src[2]); + + if (LLVMGetTypeKind(src1_type) == LLVMPointerTypeKind && + LLVMGetTypeKind(src2_type) != LLVMPointerTypeKind) { + src[2] = LLVMBuildIntToPtr(builder, src[2], src1_type, ""); + } else if (LLVMGetTypeKind(src2_type) == LLVMPointerTypeKind && + LLVMGetTypeKind(src1_type) != LLVMPointerTypeKind) { + src[1] = LLVMBuildIntToPtr(builder, src[1], src2_type, ""); + } + + for (int i = 1; i <= 2; i++) { + LLVMTypeRef type = LLVMTypeOf(src[i]); + if (LLVMGetTypeKind(type) == LLVMPointerTypeKind) + break; + src[i] = LLVMBuildBitCast(builder, src[i], get_int_bld(bld_base, true, src_bit_size[i])->vec_type, ""); + } + return LLVMBuildSelect(builder, src[0], src[1], src[2], ""); + } default: assert(0); break;