From c06dcaf0a04e0d8304564e0259b4e2cda3943fa7 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 16 Apr 2021 18:02:24 -0400 Subject: [PATCH] agx: Implement native int->float conversions This time 8, 16, and 32-bit sources are supported natively, but not 64-bit. Signed-off-by: Alyssa Rosenzweig Acked-by: Jason Ekstrand Acked-by: Bas Nieuwenhuizen Part-of: --- src/asahi/compiler/agx_compile.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/asahi/compiler/agx_compile.c b/src/asahi/compiler/agx_compile.c index 3e1fa3c3861..978c6684cee 100644 --- a/src/asahi/compiler/agx_compile.c +++ b/src/asahi/compiler/agx_compile.c @@ -280,6 +280,34 @@ agx_emit_alu(agx_builder *b, nir_alu_instr *instr) return agx_convert_to(b, dst, agx_immediate(AGX_CONVERT_F_TO_U32), s0, AGX_ROUND_RTZ); + case nir_op_u2f16: + case nir_op_u2f32: + { + if (src_sz == 64) + unreachable("64-bit conversions unimplemented"); + + enum agx_convert mode = + (src_sz == 32) ? AGX_CONVERT_U32_TO_F : + (src_sz == 16) ? AGX_CONVERT_U16_TO_F : + AGX_CONVERT_U8_TO_F; + + return agx_convert_to(b, dst, agx_immediate(mode), s0, AGX_ROUND_RTE); + } + + case nir_op_i2f16: + case nir_op_i2f32: + { + if (src_sz == 64) + unreachable("64-bit conversions unimplemented"); + + enum agx_convert mode = + (src_sz == 32) ? AGX_CONVERT_S32_TO_F : + (src_sz == 16) ? AGX_CONVERT_S16_TO_F : + AGX_CONVERT_S8_TO_F; + + return agx_convert_to(b, dst, agx_immediate(mode), s0, AGX_ROUND_RTE); + } + case nir_op_vec2: case nir_op_vec3: case nir_op_vec4: