[PATCH 13/28] aarch64: Remove multiple opcode table handling

Alice Carlotti alice.carlotti@arm.com
Wed Nov 4 18:44:45 GMT 2026


There is currently only one opcode table, and much of the aarch64-gen
machinery already assumes this to be the case.  The code providing
incomplete support for multiple opcode tables is therefore unnecessary
and confusing, so this patch removes it.


diff --git a/opcodes/aarch64-gen.c b/opcodes/aarch64-gen.c
index 7bfc169528355ed0adaf2ceb9b2972fc4e59b56c..b41fc5c5e5598ed3266a50561a4d4c1e65e5cba1 100644
--- a/opcodes/aarch64-gen.c
+++ b/opcodes/aarch64-gen.c
@@ -84,58 +84,23 @@ new_opcode_node (void)
   return ent;
 }
 
-/* Multiple tables are supported, although currently only one table is
-   in use.  N.B. there are still some functions have the table name
-   'aarch64_opcode_table' hard-coded in, e.g. print_find_next_opcode;
-   therefore some amount of work needs to be done if the full support
-   for multiple tables needs to be enabled.  */
-static const struct aarch64_opcode * const aarch64_opcode_tables[] =
-{aarch64_opcode_table};
-
-/* Use top 2 bits to indiate which table.  */
-static unsigned int
-initialize_index (const struct aarch64_opcode* table)
-{
-  int i;
-  const int num_of_tables = sizeof (aarch64_opcode_tables)
-    / sizeof (struct aarch64_opcode *);
-  for (i = 0; i < num_of_tables; ++i)
-    if (table == aarch64_opcode_tables [i])
-      break;
-  if (i == num_of_tables)
-    abort ();
-  return (unsigned int)i << 30;
-}
-
-static inline const struct aarch64_opcode *
-index2table (unsigned int index)
-{
-  return aarch64_opcode_tables[(index >> 30) & 0x3];
-}
-
-static inline unsigned int
-real_index (unsigned int index)
-{
-  return index & ((1 << 30) - 1);
-}
-
 /* Given OPCODE_NODE, return the corresponding aarch64_opcode*.  */
 static const aarch64_opcode*
 get_aarch64_opcode (const opcode_node *opcode_node)
 {
   if (opcode_node == NULL)
     return NULL;
-  return &index2table (opcode_node->index)[real_index (opcode_node->index)];
+  return &aarch64_opcode_table[opcode_node->index];
 }
 
 static bool iclass_has_subclasses_p[last_iclass + 1];
 
 static void
-read_table (const struct aarch64_opcode* table)
+read_table (void)
 {
-  const struct aarch64_opcode *ent = table;
+  const struct aarch64_opcode *ent = aarch64_opcode_table;
   opcode_node **new_ent;
-  unsigned int index = initialize_index (table);
+  unsigned int index = 0;
   unsigned int errors = 0;
 
   if (!ent->name)
@@ -245,7 +210,7 @@ read_table (const struct aarch64_opcode* table)
       new_ent = &((*new_ent)->next);
     } while ((++ent)->name);
 
-  ent = table;
+  ent = aarch64_opcode_table;
   do
     {
       /* If a subclass is set for one insn of an iclass, every insn of that
@@ -272,7 +237,7 @@ print_one_opcode_node (opcode_node* ent)
 {
   printf ("%s\t%08x\t%08x\t%d\n", get_aarch64_opcode (ent)->name,
 	  get_aarch64_opcode (ent)->opcode, get_aarch64_opcode (ent)->mask,
-	  (int)real_index (ent->index));
+	  (int) ent->index);
 }
 
 /* As an internal debugging utility, print out the list of nodes pointed
@@ -474,11 +439,7 @@ divide_table (void)
 static struct bittree *
 initialize_decoder_tree (void)
 {
-  int i;
-  const int num_of_tables = (sizeof (aarch64_opcode_tables)
-			     / sizeof (struct aarch64_opcode *));
-  for (i = 0; i < num_of_tables; ++i)
-    read_table (aarch64_opcode_tables [i]);
+  read_table ();
   if (debug)
     print_opcode_nodes ();
   return divide_table ();
@@ -515,7 +476,7 @@ print_decision_tree_1 (unsigned int indent, struct bittree* bittree)
       indented_print (indent, "   10987654321098765432109876543210\n");
       indented_print (indent, "   %s.  */\n", pattern);
       indented_print (indent, "return %s;\n",
-		      opcode_node_labels[real_index (bittree->list->index)]);
+		      opcode_node_labels[bittree->list->index]);
       return;
     }
 
@@ -583,7 +544,7 @@ print_find_next_opcode_1 (struct bittree* bittree)
 	      printf ("    case %s:\n",
 		      opcode_node_labels[curr - aarch64_opcode_table]);
 	      printf ("      value = %s;\n      break;\n",
-		      opcode_node_labels[real_index (list->next->index)]);
+		      opcode_node_labels[list->next->index]);
 
 	      list = list->next;
 	    }
@@ -687,13 +648,13 @@ print_find_real_opcode (const opcode_node *table, int num)
 	if (get_aarch64_opcode (alias)->flags & F_CONV)
 	  {
 	    printf ("    case %s:\n",
-		    opcode_node_labels[real_index (alias->index)]);
+		    opcode_node_labels[alias->index]);
 	    used = true;
 	  }
       if (used)
 	{
 	  printf ("      value = %s;\n",
-		  opcode_node_labels[real_index (real->index)]);
+		  opcode_node_labels[real->index]);
 	  printf ("      break;\n");
 	}
     }
@@ -733,8 +694,8 @@ print_find_next_alias_opcode (const opcode_node *table, int num)
       while (node->next)
 	{
 	  printf ("    case %s:\n      value = %s;\n      break;\n",
-		  opcode_node_labels[real_index (node->index)],
-		  opcode_node_labels[real_index (node->next->index)]);
+		  opcode_node_labels[node->index],
+		  opcode_node_labels[node->next->index]);
 	  node = node->next;
 	}
     }


More information about the Binutils mailing list