[PATCH 23/23] aarch64: Add qualifier checks to aarch64-gen

Alice Carlotti alice.carlotti@arm.com
Thu May 7 16:15:30 GMT 2026


Add checks to verify that all qualifier sequences have the correct
length.


diff --git a/opcodes/aarch64-gen.c b/opcodes/aarch64-gen.c
index 1988879da81036611c9f65e29c9ccf79fc03f6e3..d989c55752390939ae0ddcdecdf0fd7dc9628909 100644
--- a/opcodes/aarch64-gen.c
+++ b/opcodes/aarch64-gen.c
@@ -150,6 +150,11 @@ read_table (const struct aarch64_opcode* table)
     {
       bool match = false;
 
+      unsigned int operand_count = 0;
+      while (operand_count < ARRAY_SIZE (ent->operands)
+	     && ent->operands[operand_count] != AARCH64_OPND_NIL)
+	operand_count++;
+
       /* F_PSEUDO needs to be used together with F_ALIAS to indicate an alias
 	 opcode is a programmer friendly pseudo instruction available only in
 	 the assembly code (thus will not show up in the disassembly).  */
@@ -189,6 +194,47 @@ read_table (const struct aarch64_opcode* table)
 	  ++errors;
 	}
 
+      /* Check that the qualifier sequence lengths match the number of
+	 operands.  */
+      bool qlf_end = false;
+      for (unsigned int i = 0; i < ARRAY_SIZE (ent->qualifiers_list); i++)
+	{
+	  for (unsigned int j = 0; j < ARRAY_SIZE (ent->qualifiers_list[0]); j++)
+	    {
+	      if (j >= operand_count || qlf_end)
+		{
+		  if (ent->qualifiers_list[i][j] != AARCH64_OPND_QLF_UNUSED)
+		    {
+		      fprintf (stderr,
+			       "%s (%08x,%08x): Qualifier %u for sequence %u should be UNUSED.\n",
+			       ent->name, ent->opcode, ent->mask, j, i);
+		      ++errors;
+		    }
+		}
+	      else if (ent->qualifiers_list[i][j] == AARCH64_OPND_QLF_UNUSED)
+		{
+		  if (j == 0)
+		    {
+		      qlf_end = true;
+		      if (i == 0 && operand_count > 0)
+			{
+			  fprintf (stderr,
+				   "%s (%08x,%08x): No qualifiers specified.\n",
+				   ent->name, ent->opcode, ent->mask);
+			  ++errors;
+			}
+		    }
+		  else
+		    {
+		      fprintf (stderr,
+			       "%s (%08x,%08x): Qualifier %u for sequence %u is missing.\n",
+			       ent->name, ent->opcode, ent->mask, j, i);
+		      ++errors;
+		    }
+		}
+	    }
+	}
+
       if (ent->flags & F_SUBCLASS)
 	iclass_has_subclasses_p[ent->iclass] = true;
 


More information about the Binutils mailing list