This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] powerpc: Only initialise opcode indices once


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

commit 27c49e9a8fc004de116243ba8887e054f1190b42
Author: Anton Blanchard <anton@samba.org>
Date:   Wed Mar 25 13:44:28 2015 +1100

    powerpc: Only initialise opcode indices once
    
    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.

Diff:
---
 opcodes/ChangeLog |  5 +++++
 opcodes/ppc-dis.c | 54 +++++++++++++++++++++++++++++-------------------------
 2 files changed, 34 insertions(+), 25 deletions(-)

diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index b19a1b1..9fdcbe4 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,5 +1,10 @@
 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.
 
 2015-03-24  Terry Guo  <terry.guo@arm.com>
diff --git a/opcodes/ppc-dis.c b/opcodes/ppc-dis.c
index cf60873..ccea466 100644
--- a/opcodes/ppc-dis.c
+++ b/opcodes/ppc-dis.c
@@ -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)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]