aco: validate sub-dword pseudo instructions
authorRhys Perry <pendingchaos02@gmail.com>
Tue, 19 May 2020 10:45:12 +0000 (11:45 +0100)
committerMarge Bot <eric+marge@anholt.net>
Mon, 15 Jun 2020 18:24:22 +0000 (18:24 +0000)
No fossil-db changes.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5245>

src/amd/compiler/aco_validate.cpp

index d4ba88e014a351c24ee6f6dd949823337e7486c1..53c16bc5ac7b22407fe2ba968ee689f6eb60f736 100644 (file)
@@ -272,6 +272,24 @@ void validate(Program* program, FILE * output)
 
          switch (instr->format) {
          case Format::PSEUDO: {
+            bool is_subdword = false;
+            bool has_const_sgpr = false;
+            bool has_literal = false;
+            for (Definition def : instr->definitions)
+               is_subdword |= def.regClass().is_subdword();
+            for (unsigned i = 0; i < instr->operands.size(); i++) {
+               if (instr->opcode == aco_opcode::p_extract_vector && i == 1)
+                  continue;
+               Operand op = instr->operands[i];
+               is_subdword |= op.hasRegClass() && op.regClass().is_subdword();
+               has_const_sgpr |= op.isConstant() || (op.hasRegClass() && op.regClass().type() == RegType::sgpr);
+               has_literal |= op.isLiteral();
+            }
+
+            check(!is_subdword || !has_const_sgpr || program->chip_class >= GFX9,
+                  "Sub-dword pseudo instructions can only take constants or SGPRs on GFX9+", instr.get());
+            check(!is_subdword || !has_literal, "Sub-dword pseudo instructions cannot take literals", instr.get());
+
             if (instr->opcode == aco_opcode::p_create_vector) {
                unsigned size = 0;
                for (const Operand& op : instr->operands) {