aco: validate VALU modifiers
authorGeorg Lehmann <dadschoorse@gmail.com>
Tue, 31 Jan 2023 12:14:46 +0000 (13:14 +0100)
committerMarge Bot <emma+marge@anholt.net>
Tue, 7 Mar 2023 11:53:23 +0000 (11:53 +0000)
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21023>

src/amd/compiler/aco_validate.cpp

index 599eb31..1b5ed3e 100644 (file)
@@ -382,6 +382,30 @@ validate_ir(Program* program)
                }
                check(num_sgprs + (literal.isUndefined() ? 0 : 1) <= const_bus_limit,
                      "Too many SGPRs/literals", instr.get());
+
+               /* Validate modifiers. */
+               check(!instr->valu().opsel || instr->isVOP3() || instr->isVINTERP_INREG(),
+                     "OPSEL set for unsupported instruction format", instr.get());
+               check(!instr->valu().opsel_lo || instr->isVOP3P(),
+                     "OPSEL_LO set for unsupported instruction format", instr.get());
+               check(!instr->valu().opsel_hi || instr->isVOP3P(),
+                     "OPSEL_HI set for unsupported instruction format", instr.get());
+               check(!instr->valu().omod || instr->isVOP3() ||instr->isSDWA(),
+                     "OMOD set for unsupported instruction format", instr.get());
+               check(!instr->valu().clamp || instr->isVOP3() || instr->isVOP3P() ||
+                        instr->isSDWA() || instr->isVINTERP_INREG(),
+                     "CLAMP set for unsupported instruction format", instr.get());
+
+               for (bool abs : instr->valu().abs) {
+                  check(!abs || instr->isVOP3() || instr->isVOP3P() || instr->isSDWA() ||
+                           instr->isDPP16(),
+                        "ABS/NEG_HI set for unsupported instruction format", instr.get());
+               }
+               for (bool neg : instr->valu().neg) {
+                  check(!neg || instr->isVOP3() || instr->isVOP3P() || instr->isSDWA() ||
+                           instr->isDPP16() || instr->isVINTERP_INREG(),
+                        "NEG/NEG_LO set for unsupported instruction format", instr.get());
+               }
             }
 
             if (instr->isSOP1() || instr->isSOP2()) {