powerpc: Only initialise opcode indices once
authorAnton Blanchard <anton@samba.org>
Wed, 25 Mar 2015 02:44:28 +0000 (13:44 +1100)
committerAnton Blanchard <anton@samba.org>
Wed, 25 Mar 2015 22:12:50 +0000 (09:12 +1100)
The gdb TUI is calling gdb_print_insn() (which calls
disassemble_init_powerpc()) enough to show up high in profiles. As
suggested by Alan, only initialise if the indices are empty.

opcodes/ChangeLog:
2015-03-25  Anton Blanchard  <anton@samba.org>

* ppc-dis.c (disassemble_init_powerpc): Only initialise
powerpc_opcd_indices and vle_opcd_indices once.

opcodes/ChangeLog
opcodes/ppc-dis.c

index b19a1b18a87b4deb727d154b16c526771f8be3e9..9fdcbe488ff2087d5def3b874703a7172ee89947 100644 (file)
@@ -1,3 +1,8 @@
+2015-03-25  Anton Blanchard  <anton@samba.org>
+
+       * ppc-dis.c (disassemble_init_powerpc): Only initialise
+       powerpc_opcd_indices and vle_opcd_indices once.
+
 2015-03-25  Anton Blanchard  <anton@samba.org>
 
        * ppc-opc.c (powerpc_opcodes): Add slbfee.
index cf60873640c58d1f6bf6403fa1f70c25a347e779..ccea46680e2d6edc1e7cc76b61acf401431eb510 100644 (file)
@@ -341,37 +341,41 @@ disassemble_init_powerpc (struct disassemble_info *info)
   int i;
   unsigned short last;
 
-  i = powerpc_num_opcodes;
-  while (--i >= 0)
+  if (powerpc_opcd_indices[PPC_OPCD_SEGS] == 0)
     {
-      unsigned op = PPC_OP (powerpc_opcodes[i].opcode);
 
-      powerpc_opcd_indices[op] = i;
-    }
+      i = powerpc_num_opcodes;
+      while (--i >= 0)
+        {
+          unsigned op = PPC_OP (powerpc_opcodes[i].opcode);
 
-  last = powerpc_num_opcodes;
-  for (i = PPC_OPCD_SEGS; i > 0; --i)
-    {
-      if (powerpc_opcd_indices[i] == 0)
-       powerpc_opcd_indices[i] = last;
-      last = powerpc_opcd_indices[i];
-    }
+          powerpc_opcd_indices[op] = i;
+        }
 
-  i = vle_num_opcodes;
-  while (--i >= 0)
-    {
-      unsigned op = VLE_OP (vle_opcodes[i].opcode, vle_opcodes[i].mask);
-      unsigned seg = VLE_OP_TO_SEG (op);
+      last = powerpc_num_opcodes;
+      for (i = PPC_OPCD_SEGS; i > 0; --i)
+        {
+          if (powerpc_opcd_indices[i] == 0)
+           powerpc_opcd_indices[i] = last;
+          last = powerpc_opcd_indices[i];
+        }
 
-      vle_opcd_indices[seg] = i;
-    }
+      i = vle_num_opcodes;
+      while (--i >= 0)
+        {
+          unsigned op = VLE_OP (vle_opcodes[i].opcode, vle_opcodes[i].mask);
+          unsigned seg = VLE_OP_TO_SEG (op);
 
-  last = vle_num_opcodes;
-  for (i = VLE_OPCD_SEGS; i > 0; --i)
-    {
-      if (vle_opcd_indices[i] == 0)
-       vle_opcd_indices[i] = last;
-      last = vle_opcd_indices[i];
+          vle_opcd_indices[seg] = i;
+        }
+
+      last = vle_num_opcodes;
+      for (i = VLE_OPCD_SEGS; i > 0; --i)
+        {
+          if (vle_opcd_indices[i] == 0)
+           vle_opcd_indices[i] = last;
+          last = vle_opcd_indices[i];
+        }
     }
 
   if (info->arch == bfd_arch_powerpc)
This page took 0.028096 seconds and 4 git commands to generate.