aco: validate register alignment of subdword operands and definitions
authorDaniel Schürmann <daniel@schuermann.dev>
Tue, 24 Mar 2020 17:24:23 +0000 (18:24 +0100)
committerDaniel Schürmann <daniel@schuermann.dev>
Fri, 3 Apr 2020 22:13:15 +0000 (23:13 +0100)
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-By: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4002>

src/amd/compiler/aco_validate.cpp

index 68e0c9caf8b4bce804d266c9f51908bfda9da42b..0fc80e6800883ee7383283a8b309488f85bdc4f8 100644 (file)
@@ -157,6 +157,12 @@ void validate(Program* program, FILE * output)
             }
          }
 
+         /* check subdword definitions */
+         for (unsigned i = 0; i < instr->definitions.size(); i++) {
+            if (instr->definitions[i].regClass().is_subdword())
+               check(instr->isSDWA() || instr->format == Format::PSEUDO, "Only SDWA and Pseudo instructions can write subdword registers", instr.get());
+         }
+
          if (instr->isSALU() || instr->isVALU()) {
             /* check literals */
             Operand literal(s1);
@@ -448,6 +454,8 @@ bool validate_ra(Program *program, const struct radv_nir_compiler_options *optio
                err |= ra_fail(output, loc, assignments.at(op.tempId()).firstloc, "Operand %d has an out-of-bounds register assignment", i);
             if (op.physReg() == vcc && !program->needs_vcc)
                err |= ra_fail(output, loc, Location(), "Operand %d fixed to vcc but needs_vcc=false", i);
+            if (!(instr->isSDWA() || instr->format == Format::PSEUDO) && op.regClass().is_subdword() && op.physReg().byte())
+               err |= ra_fail(output, loc, assignments.at(op.tempId()).firstloc, "Operand %d must be aligned to a full register", i);
             if (!assignments[op.tempId()].firstloc.block)
                assignments[op.tempId()].firstloc = loc;
             if (!assignments[op.tempId()].defloc.block)