From 5896db957876c4dc1cd7ecb4e6eef44690b10530 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 3 Mar 2020 08:35:51 -0500 Subject: [PATCH] pan/bi: Add swizzles Requires a new field on bifrost_instruction, as well as a new class property and a new class for the dedicated swizzle ops. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/bi_tables.c | 3 ++- src/panfrost/bifrost/compiler.h | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/panfrost/bifrost/bi_tables.c b/src/panfrost/bifrost/bi_tables.c index 9724481..5d3de06 100644 --- a/src/panfrost/bifrost/bi_tables.c +++ b/src/panfrost/bifrost/bi_tables.c @@ -33,7 +33,7 @@ unsigned bi_class_props[BI_NUM_CLASSES] = { [BI_CMP] = BI_GENERIC | BI_MODS | BI_SCHED_ALL, [BI_BLEND] = BI_ADD, [BI_BITWISE] = BI_GENERIC | BI_SCHED_ALL, - [BI_CONVERT] = BI_SCHED_ALL, + [BI_CONVERT] = BI_SCHED_ALL | BI_SWIZZLABLE, [BI_CSEL] = BI_SCHED_FMA, [BI_DISCARD] = BI_SCHED_ADD, [BI_FMA] = BI_ROUNDMODE | BI_SCHED_FMA, @@ -48,6 +48,7 @@ unsigned bi_class_props[BI_NUM_CLASSES] = { [BI_STORE] = BI_SCHED_ADD, [BI_STORE_VAR] = BI_SCHED_ADD, [BI_SPECIAL] = BI_SCHED_ADD | BI_SCHED_SLOW, + [BI_SWIZZLE] = BI_SCHED_ALL | BI_SWIZZLABLE, [BI_TEX] = BI_SCHED_ADD, [BI_ROUND] = BI_GENERIC | BI_ROUNDMODE | BI_SCHED_ALL, }; diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h index 6eddf44..5385f21 100644 --- a/src/panfrost/bifrost/compiler.h +++ b/src/panfrost/bifrost/compiler.h @@ -67,6 +67,7 @@ enum bi_class { BI_STORE, BI_STORE_VAR, BI_SPECIAL, /* _FAST, _TABLE on supported GPUs */ + BI_SWIZZLE, BI_TEX, BI_ROUND, BI_NUM_CLASSES @@ -99,6 +100,9 @@ extern unsigned bi_class_props[BI_NUM_CLASSES]; * nopped out. Used for _FAST operations. */ #define BI_SCHED_SLOW (1 << 5) +/* Swizzling allowed for the 8/16-bit source */ +#define BI_SWIZZLABLE (1 << 6) + /* It can't get any worse than csel4... can it? */ #define BIR_SRC_COUNT 4 @@ -171,6 +175,13 @@ typedef struct { * int). Zero if there is no destination. Bitsize included */ nir_alu_type dest_type; + /* If the source type is 8-bit or 16-bit such that SIMD is possible, and + * the class has BI_SWIZZLABLE, this is a swizzle for the input. Swizzles + * in practice only occur with one-source arguments (conversions, + * dedicated swizzle ops) and as component selection on two-sources + * where it is unambiguous which is which. Bounds are 32/type_size. */ + unsigned swizzle[4]; + /* A class-specific op from which the actual opcode can be derived * (along with the above information) */ -- 2.7.4