[binutils-gdb] opcodes/aarch64: convert print_sme_za_list()'s zan[] / zan_v[]

Jan Beulich jbeulich@sourceware.org
Fri Aug 1 07:19:30 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=bdd43bccaf29230f45d1458f30ad470764df1078

commit bdd43bccaf29230f45d1458f30ad470764df1078
Author: Jan Beulich <jbeulich@suse.com>
Date:   Fri Aug 1 09:17:40 2025 +0200

    opcodes/aarch64: convert print_sme_za_list()'s zan[] / zan_v[]
    
    Merge them into a single array of struct type. There's further no reason
    to have the compiler materialize such objects on the stack. And there's
    also no reason to allow the array(s) to be modifiable. Finally, given
    how short the strings are, there's little point using more space to
    store pointers to them (on 64-bit hosts; the situation is a little
    better on 32-bit ones).
    
    While there also correct indentation in adjacent code, and avoid open-
    coding ARRAY_SIZE().

Diff:
---
 opcodes/aarch64-opc.c | 47 ++++++++++++++++++++++++++++++-----------------
 1 file changed, 30 insertions(+), 17 deletions(-)

diff --git a/opcodes/aarch64-opc.c b/opcodes/aarch64-opc.c
index 7e7875b826a..f7dae4bddd2 100644
--- a/opcodes/aarch64-opc.c
+++ b/opcodes/aarch64-opc.c
@@ -4024,28 +4024,41 @@ static void
 print_sme_za_list (char *buf, size_t size, int mask,
 		   struct aarch64_styler *styler)
 {
-  const char* zan[] = { "za",    "za0.h", "za1.h", "za0.s",
-                        "za1.s", "za2.s", "za3.s", "za0.d",
-                        "za1.d", "za2.d", "za3.d", "za4.d",
-                        "za5.d", "za6.d", "za7.d", " " };
-  const int zan_v[] = { 0xff, 0x55, 0xaa, 0x11,
-                        0x22, 0x44, 0x88, 0x01,
-                        0x02, 0x04, 0x08, 0x10,
-                        0x20, 0x40, 0x80, 0x00 };
-  int i, k;
-  const int ZAN_SIZE = sizeof(zan) / sizeof(zan[0]);
+  static const struct {
+    unsigned char mask;
+    char name[7];
+  } zan[] = {
+    { 0xff, "za" },
+    { 0x55, "za0.h" },
+    { 0xaa, "za1.h" },
+    { 0x11, "za0.s" },
+    { 0x22, "za1.s" },
+    { 0x44, "za2.s" },
+    { 0x88, "za3.s" },
+    { 0x01, "za0.d" },
+    { 0x02, "za1.d" },
+    { 0x04, "za2.d" },
+    { 0x08, "za3.d" },
+    { 0x10, "za4.d" },
+    { 0x20, "za5.d" },
+    { 0x40, "za6.d" },
+    { 0x80, "za7.d" },
+    { 0x00, " " },
+  };
+  int k;
 
   k = snprintf (buf, size, "{");
-  for (i = 0; i < ZAN_SIZE; i++)
+  for (unsigned int i = 0; i < ARRAY_SIZE (zan); i++)
     {
-      if ((mask & zan_v[i]) == zan_v[i])
-        {
-          mask &= ~zan_v[i];
-          if (k > 1)
+      if ((mask & zan[i].mask) == zan[i].mask)
+	{
+	  mask &= ~zan[i].mask;
+	  if (k > 1)
 	    k += snprintf (buf + k, size - k, ", ");
 
-	  k += snprintf (buf + k, size - k, "%s", style_reg (styler, zan[i]));
-        }
+	  k += snprintf (buf + k, size - k, "%s",
+			 style_reg (styler, zan[i].name));
+	}
       if (mask == 0)
         break;
     }


More information about the Binutils-cvs mailing list