From: Alyssa Rosenzweig Date: Tue, 14 Apr 2020 16:50:48 +0000 (-0400) Subject: pan/bit: Add FREXP interp support X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=36cfe722e5ab6c01216f30cad6909888425d2931;p=mesa.git pan/bit: Add FREXP interp support Signed-off-by: Alyssa Rosenzweig Part-of: --- diff --git a/src/panfrost/bifrost/test/bi_interpret.c b/src/panfrost/bifrost/test/bi_interpret.c index 2f3295772d9..53c3d983eb1 100644 --- a/src/panfrost/bifrost/test/bi_interpret.c +++ b/src/panfrost/bifrost/test/bi_interpret.c @@ -340,6 +340,28 @@ bit_as_int16(nir_alu_type T, bit_t src, unsigned C, enum bifrost_roundmode rm) } } +static float +frexp_log(float x, int *e) +{ + /* Ignore sign until end */ + float xa = fabs(x); + + /* frexp reduces to [0.5, 1) */ + float f = frexpf(xa, e); + + /* reduce to [0.75, 1.5) */ + if (f < 0.75) { + f *= 2.0; + (*e)--; + } + + /* Reattach sign */ + if (xa < 0.0) + f = -f; + + return f; +} + void bit_step(struct bit_state *s, bi_instruction *ins, bool FMA) { @@ -424,7 +446,18 @@ bit_step(struct bit_state *s, bi_instruction *ins, bool FMA) unreachable("Unknown type"); } - case BI_FREXP: + case BI_FREXP: { + if (ins->src_types[0] != nir_type_float32) + unreachable("Unknown frexp type"); + + + if (ins->op.frexp == BI_FREXPE_LOG) + frexp_log(srcs[0].f32, &dest.i32); + else + unreachable("Unknown frexp"); + + break; + } case BI_ISUB: unreachable("Unsupported op");