diff options
author | Boris Brezillon <boris.brezillon@collabora.com> | 2020-11-06 11:18:15 +0100 |
---|---|---|
committer | Boris Brezillon <boris.brezillon@collabora.com> | 2020-11-09 20:36:50 +0100 |
commit | 2a80b2d0cd1db54522fbf07a202e546724876bfe (patch) | |
tree | 081d73760ec5d448770aa0e3da807a4afb64fc6d | |
parent | cc0950722c03fc3a4f1f6fb709c71e23b4d264e6 (diff) |
pan/bi: Move bitwise op packing out of bi_pack_fma()
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7472>
-rw-r--r-- | src/panfrost/bifrost/bi_pack.c | 96 |
1 files changed, 45 insertions, 51 deletions
diff --git a/src/panfrost/bifrost/bi_pack.c b/src/panfrost/bifrost/bi_pack.c index 860534a4bb9..47ee8c802c4 100644 --- a/src/panfrost/bifrost/bi_pack.c +++ b/src/panfrost/bifrost/bi_pack.c @@ -404,6 +404,50 @@ bi_pack_fma_special(bi_clause *clause, bi_instruction *ins, bi_registers *regs) } } +#define BI_PACK_SHIFT(name) \ +static unsigned \ +bi_pack_fma_ ## name(bi_clause *clause, bi_instruction *ins, bi_registers *regs) \ +{ \ + switch (nir_alu_type_get_type_size(ins->dest_type)) { \ + case 32: \ + return pan_pack_fma_ ## name ## _i32(clause, ins, regs); \ + case 16: \ + return pan_pack_fma_ ## name ## _v2i16(clause, ins, regs); \ + case 8: \ + return pan_pack_fma_ ## name ## _v4i8(clause, ins, regs); \ + default: \ + unreachable("Invalid dest size"); \ + } \ +} + +BI_PACK_SHIFT(rshift_and) +BI_PACK_SHIFT(lshift_and) +BI_PACK_SHIFT(rshift_or) +BI_PACK_SHIFT(lshift_or) +BI_PACK_SHIFT(rshift_xor) +BI_PACK_SHIFT(lshift_xor) + +static unsigned +bi_pack_fma_bitwise(bi_clause *clause, bi_instruction *ins, bi_registers *regs) +{ + switch (ins->op.bitwise) { + case BI_BITWISE_AND: + return ins->bitwise.rshift ? + bi_pack_fma_rshift_and(clause, ins, regs) : + bi_pack_fma_lshift_and(clause, ins, regs); + case BI_BITWISE_OR: + return ins->bitwise.rshift ? + bi_pack_fma_rshift_or(clause, ins, regs) : + bi_pack_fma_lshift_or(clause, ins, regs); + case BI_BITWISE_XOR: + return ins->bitwise.rshift ? + bi_pack_fma_rshift_xor(clause, ins, regs) : + bi_pack_fma_lshift_xor(clause, ins, regs); + default: + unreachable("Invalid bitwise op"); + } +} + static unsigned bi_pack_fma(bi_clause *clause, bi_bundle bundle, bi_registers *regs) { @@ -415,10 +459,8 @@ bi_pack_fma(bi_clause *clause, bi_bundle bundle, bi_registers *regs) bool u32 = bundle.fma->dest_type == nir_type_uint32 || bundle.fma->dest_type == nir_type_bool32; bool u16 = bundle.fma->dest_type == nir_type_uint16; - ASSERTED bool u8 = bundle.fma->dest_type == nir_type_uint8; bool s32 = bundle.fma->dest_type == nir_type_int32; bool s16 = bundle.fma->dest_type == nir_type_int16; - ASSERTED bool s8 = bundle.fma->dest_type == nir_type_int8; bool src0_f16 = bundle.fma->src_types[0] == nir_type_float16; bool src0_f32 = bundle.fma->src_types[0] == nir_type_float32; @@ -446,55 +488,7 @@ bi_pack_fma(bi_clause *clause, bi_bundle bundle, bi_registers *regs) else return pan_pack_fma_fcmp_v2f16(clause, bundle.fma, regs); case BI_BITWISE: - if (bundle.fma->op.bitwise == BI_BITWISE_AND) { - if (u32 || s32) { - return bundle.fma->bitwise.rshift ? - pan_pack_fma_rshift_and_i32(clause, bundle.fma, regs) : - pan_pack_fma_lshift_and_i32(clause, bundle.fma, regs); - } else if (u16 || s16) { - return bundle.fma->bitwise.rshift ? - pan_pack_fma_rshift_and_v2i16(clause, bundle.fma, regs) : - pan_pack_fma_lshift_and_v2i16(clause, bundle.fma, regs); - } else { - assert(u8 || s8); - return bundle.fma->bitwise.rshift ? - pan_pack_fma_rshift_and_v4i8(clause, bundle.fma, regs) : - pan_pack_fma_lshift_and_v4i8(clause, bundle.fma, regs); - } - - } else if (bundle.fma->op.bitwise == BI_BITWISE_OR) { - if (u32 || s32) { - return bundle.fma->bitwise.rshift ? - pan_pack_fma_rshift_or_i32(clause, bundle.fma, regs) : - pan_pack_fma_lshift_or_i32(clause, bundle.fma, regs); - } else if (u16 || s16) { - return bundle.fma->bitwise.rshift ? - pan_pack_fma_rshift_or_v2i16(clause, bundle.fma, regs) : - pan_pack_fma_lshift_or_v2i16(clause, bundle.fma, regs); - } else { - assert(u8 || s8); - return bundle.fma->bitwise.rshift ? - pan_pack_fma_rshift_or_v4i8(clause, bundle.fma, regs) : - pan_pack_fma_lshift_or_v4i8(clause, bundle.fma, regs); - } - } else { - assert(bundle.fma->op.bitwise == BI_BITWISE_XOR); - - if (u32 || s32) { - return bundle.fma->bitwise.rshift ? - pan_pack_fma_rshift_xor_i32(clause, bundle.fma, regs) : - pan_pack_fma_lshift_xor_i32(clause, bundle.fma, regs); - } else if (u16 || s16) { - return bundle.fma->bitwise.rshift ? - pan_pack_fma_rshift_xor_v2i16(clause, bundle.fma, regs) : - pan_pack_fma_lshift_xor_v2i16(clause, bundle.fma, regs); - } else { - assert(u8 || s8); - return bundle.fma->bitwise.rshift ? - pan_pack_fma_rshift_xor_v4i8(clause, bundle.fma, regs) : - pan_pack_fma_lshift_xor_v4i8(clause, bundle.fma, regs); - } - } + return bi_pack_fma_bitwise(clause, bundle.fma, regs); case BI_CONVERT: if (src0_s8) { assert(s32); |