From 17ff2e8c52b6d7d90006112a20f3a85812f26525 Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Tue, 31 Jan 2023 13:14:46 +0100 Subject: [PATCH] aco: validate VALU modifiers MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Daniel Schürmann Reviewed-by: Timur Kristóf Part-of: --- src/amd/compiler/aco_validate.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/amd/compiler/aco_validate.cpp b/src/amd/compiler/aco_validate.cpp index 599eb31..1b5ed3e 100644 --- a/src/amd/compiler/aco_validate.cpp +++ b/src/amd/compiler/aco_validate.cpp @@ -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()) { -- 2.7.4