ir3: teach backend about sad

It only supports (neg) in its 2nd src but other than that has the same
properties as mad.

Signed-off-by: Job Noorman <jnoorman@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32501>
This commit is contained in:
Job Noorman
2024-12-11 13:40:25 +01:00
committed by Marge Bot
parent 49c7a22ac8
commit ed58a8688f
3 changed files with 18 additions and 4 deletions
+12
View File
@@ -641,6 +641,18 @@ is_madsh(opc_t opc)
}
}
static inline bool
is_sad(opc_t opc)
{
switch (opc) {
case OPC_SAD_S16:
case OPC_SAD_S32:
return true;
default:
return false;
}
}
static inline bool
is_local_atomic(opc_t opc)
{
+1 -1
View File
@@ -1301,7 +1301,7 @@ ir3_valid_flags(struct ir3_instruction *instr, unsigned n, unsigned flags)
break;
case 3:
valid_flags =
ir3_cat3_absneg(instr->opc) | IR3_REG_RELATIV | IR3_REG_SHARED;
ir3_cat3_absneg(instr->opc, n) | IR3_REG_RELATIV | IR3_REG_SHARED;
switch (instr->opc) {
case OPC_SHRM:
+5 -3
View File
@@ -1699,7 +1699,7 @@ ir3_cat2_absneg(opc_t opc)
/* map cat3 instructions to valid abs/neg flags: */
static inline unsigned
ir3_cat3_absneg(opc_t opc)
ir3_cat3_absneg(opc_t opc, unsigned src_n)
{
switch (opc) {
case OPC_MAD_F16:
@@ -1708,6 +1708,10 @@ ir3_cat3_absneg(opc_t opc)
case OPC_SEL_F32:
return IR3_REG_FNEG;
case OPC_SAD_S16:
case OPC_SAD_S32:
return src_n == 1 ? IR3_REG_SNEG : 0;
case OPC_MAD_U16:
case OPC_MADSH_U16:
case OPC_MAD_S16:
@@ -1716,8 +1720,6 @@ ir3_cat3_absneg(opc_t opc)
case OPC_MAD_S24:
case OPC_SEL_S16:
case OPC_SEL_S32:
case OPC_SAD_S16:
case OPC_SAD_S32:
/* neg *may* work on 3rd src.. */
case OPC_SEL_B16: