From: Pierre-Eric Pelloux-Prayer Date: Wed, 6 Oct 2021 12:50:09 +0000 (+0200) Subject: llvmpipe: add missing NIR alu-op handling X-Git-Tag: upstream/22.3.5~15997 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cd6e9ad36a27010df78d9e3ae4f4d31fb38fb180;p=platform%2Fupstream%2Fmesa.git llvmpipe: add missing NIR alu-op handling nir_op_bcsel implemented based on ac_nir_to_llvm.c emit_bcsel function. Reviewed-by: Marek Olšák Part-of: --- diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir.c b/src/gallium/auxiliary/gallivm/lp_bld_nir.c index ca56330..6dbb840 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;