[PATCH 16/28] aarch64: Eliminate global opcode_nodes_heads list

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


Pass the linked list around as a local variable instead.  Remove the
empty opcode_node at the list head and use a pointer to the first real
node instead.


diff --git a/opcodes/aarch64-gen.c b/opcodes/aarch64-gen.c
index f0604c2ecbdfec10261642d207447434dc6d82c0..0779618dcc95b2b6a91cff99f8edd34086e0f24e 100644
--- a/opcodes/aarch64-gen.c
+++ b/opcodes/aarch64-gen.c
@@ -53,9 +53,6 @@ struct opcode_node
 
 typedef struct opcode_node opcode_node;
 
-/* Head of the list of the opcode_node after read_table.  */
-static opcode_node opcode_nodes_head;
-
 /* Node in the decoding tree.  */
 
 struct bittree
@@ -211,10 +208,11 @@ validate_table (void)
 }
 
 /* Create a linked list of opcode table entries.  */
-static void
+static opcode_node*
 read_table (void)
 {
-  opcode_node **tail = &opcode_nodes_head.next;
+  opcode_node *head;
+  opcode_node **tail = &head;
   for (unsigned int index = 0; ; index++)
     {
       const struct aarch64_opcode *ent = &aarch64_opcode_table[index];
@@ -232,6 +230,7 @@ read_table (void)
       *tail = node;
       tail = &node->next;
     }
+  return head;
 }
 
 static inline void
@@ -243,16 +242,16 @@ print_one_opcode_node (opcode_node* ent)
 }
 
 /* As an internal debugging utility, print out the list of nodes pointed
-   by opcode_nodes_head.  */
+   by the linked list HEAD.  */
 static void
-print_opcode_nodes (void)
+print_opcode_nodes (opcode_node *head)
 {
-  opcode_node* ent = opcode_nodes_head.next;
+  opcode_node* node = head;
   printf ("print_opcode_nodes table:\n");
-  while (ent)
+  while (node)
     {
-      print_one_opcode_node (ent);
-      ent = ent->next;
+      print_one_opcode_node (node);
+      node = node->next;
     }
 }
 
@@ -429,10 +428,10 @@ divide_table_1 (struct bittree *bittree, opcode_node *opcode)
 /* Call divide_table_1 to divide the all the opcodes and thus create the
    decoding decision tree.  */
 static struct bittree *
-divide_table (void)
+divide_table (opcode_node *head)
 {
   struct bittree *bittree = new_bittree_node ();
-  divide_table_1 (bittree, opcode_nodes_head.next);
+  divide_table_1 (bittree, head);
   return bittree;
 }
 
@@ -1410,10 +1409,11 @@ main (int argc, char **argv)
   /* Generate opcode entry lookup for the disassembler.  */
   if (gen_disassembler_p)
     {
-      read_table ();
+
+      opcode_node *head = read_table ();
       if (debug)
-	print_opcode_nodes ();
-      struct bittree *decoder_tree = divide_table ();
+	print_opcode_nodes (head);
+      struct bittree *decoder_tree = divide_table (head);
       if (debug)
 	print_divide_result (decoder_tree);
 


More information about the Binutils mailing list