From ededb108d9bf365c49deef29577067f88b3a2c32 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Sun, 23 Oct 2022 20:50:17 -0400 Subject: [PATCH] agx: Implement unary math ops Implement nir_op_bitfield_reverse, nir_op_bit_count, and nir_op_ufind_msb. These map to native instructions. With appropriate integer render target and multiple render target support, passes: dEQP-GLES31.functional.shaders.builtin_functions.integer.bitfieldreverse.*vertex dEQP-GLES31.functional.shaders.builtin_functions.integer.bitfieldreverse.*fragment dEQP-GLES31.functional.shaders.builtin_functions.integer.bitcount.*vertex dEQP-GLES31.functional.shaders.builtin_functions.integer.bitcount.*fragment dEQP-GLES31.functional.shaders.builtin_functions.integer.findLSB.*vertex dEQP-GLES31.functional.shaders.builtin_functions.integer.findLSB.*fragment dEQP-GLES31.functional.shaders.builtin_functions.integer.findMSB.*vertex dEQP-GLES31.functional.shaders.builtin_functions.integer.findMSB.*fragment Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/compiler/agx_compile.c | 3 +++ src/asahi/compiler/agx_opcodes.py | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/asahi/compiler/agx_compile.c b/src/asahi/compiler/agx_compile.c index 0a0efc6..70b2294 100644 --- a/src/asahi/compiler/agx_compile.c +++ b/src/asahi/compiler/agx_compile.c @@ -871,6 +871,9 @@ agx_emit_alu(agx_builder *b, nir_alu_instr *instr) UNOP(mov, mov); UNOP(u2u16, mov); UNOP(u2u32, mov); + UNOP(bitfield_reverse, bitrev); + UNOP(bit_count, popcount); + UNOP(ufind_msb, ffs); UNOP(inot, not); BINOP(iand, and); BINOP(ior, or); diff --git a/src/asahi/compiler/agx_opcodes.py b/src/asahi/compiler/agx_opcodes.py index c86463f..191396d 100644 --- a/src/asahi/compiler/agx_opcodes.py +++ b/src/asahi/compiler/agx_opcodes.py @@ -148,6 +148,13 @@ def funop(name, opcode): 0x3F | L | (((1 << 14) - 1) << 28), 6, _), srcs = 1, is_float = True) +def iunop(name, opcode): + assert(opcode < 4) + op(name, (0x3E | (opcode << 26), + 0x7F | L | (((1 << 14) - 1) << 26), + 6, _), + srcs = 1) + # Listing of opcodes funop("floor", 0b000000) funop("srsqrt", 0b000001) @@ -163,6 +170,10 @@ funop("ceil", 0b010000) funop("trunc", 0b100000) funop("roundeven", 0b110000) +iunop("bitrev", 0b01) +iunop("popcount", 0b10) +iunop("ffs", 0b11) + op("fadd", encoding_16 = (0x26 | L, 0x3F | L, 6, _), encoding_32 = (0x2A | L, 0x3F | L, 6, _), -- 2.7.4