2003-03-31 Andrew Cagney <cagney@redhat.com>
[deliverable/binutils-gdb.git] / opcodes / xstormy16-dis.c
index 595ed2aa50783f95968ac623cf9ef315dc7d466a..17c54a68a15ce6b336c2f5be1dace124d3ea6058 100644 (file)
@@ -4,7 +4,8 @@
 THIS FILE IS MACHINE GENERATED WITH CGEN.
 - the resultant file is machine generated, cgen-dis.in isn't
 
-Copyright 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002
+Free Software Foundation, Inc.
 
 This file is part of the GNU Binutils and GDB, the GNU debugger.
 
@@ -31,6 +32,7 @@ along with this program; if not, write to the Free Software Foundation, Inc.,
 #include "dis-asm.h"
 #include "bfd.h"
 #include "symcat.h"
+#include "libiberty.h"
 #include "xstormy16-desc.h"
 #include "xstormy16-opc.h"
 #include "opintl.h"
@@ -92,10 +94,10 @@ xstormy16_cgen_print_operand (cd, opindex, xinfo, fields, attrs, pc, length)
   switch (opindex)
     {
     case XSTORMY16_OPERAND_RB :
-      print_keyword (cd, info, & xstormy16_cgen_opval_gr_names, fields->f_Rb, 0);
+      print_keyword (cd, info, & xstormy16_cgen_opval_gr_Rb_names, fields->f_Rb, 0);
       break;
     case XSTORMY16_OPERAND_RBJ :
-      print_keyword (cd, info, & xstormy16_cgen_opval_gr_Rbj_names, fields->f_Rbj, 0);
+      print_keyword (cd, info, & xstormy16_cgen_opval_gr_Rb_names, fields->f_Rbj, 0);
       break;
     case XSTORMY16_OPERAND_RD :
       print_keyword (cd, info, & xstormy16_cgen_opval_gr_names, fields->f_Rd, 0);
@@ -350,9 +352,13 @@ print_insn (cd, pc, info, buf, buflen)
   CGEN_INSN_INT insn_value;
   const CGEN_INSN_LIST *insn_list;
   CGEN_EXTRACT_INFO ex_info;
+  int basesize;
 
   /* Extract base part of instruction, just in case CGEN_DIS_* uses it. */
-  insn_value = cgen_get_insn_value (cd, buf, buflen * 8);
+  basesize = cd->base_insn_bitsize < buflen * 8 ?
+                                     cd->base_insn_bitsize : buflen * 8;
+  insn_value = cgen_get_insn_value (cd, buf, basesize);
+
 
   /* Fill in ex_info fields like read_insn would.  Don't actually call
      read_insn, since the incoming buffer is already read (and possibly
@@ -479,11 +485,21 @@ default_print_insn (cd, pc, info)
    Print one instruction from PC on INFO->STREAM.
    Return the size of the instruction (in bytes).  */
 
+typedef struct cpu_desc_list {
+  struct cpu_desc_list *next;
+  int isa;
+  int mach;
+  int endian;
+  CGEN_CPU_DESC cd;
+} cpu_desc_list;
+
 int
 print_insn_xstormy16 (pc, info)
      bfd_vma pc;
      disassemble_info *info;
 {
+  static cpu_desc_list *cd_list = 0;
+  cpu_desc_list *cl = 0;
   static CGEN_CPU_DESC cd = 0;
   static int prev_isa;
   static int prev_mach;
@@ -514,18 +530,27 @@ print_insn_xstormy16 (pc, info)
 #ifdef CGEN_COMPUTE_ISA
   isa = CGEN_COMPUTE_ISA (info);
 #else
-  isa = 0;
+  isa = info->insn_sets;
 #endif
 
-  /* If we've switched cpu's, close the current table and open a new one.  */
+  /* If we've switched cpu's, try to find a handle we've used before */
   if (cd
       && (isa != prev_isa
          || mach != prev_mach
          || endian != prev_endian))
     {
-      xstormy16_cgen_cpu_close (cd);
       cd = 0;
-    }
+      for (cl = cd_list; cl; cl = cl->next)
+       {
+         if (cl->isa == isa &&
+             cl->mach == mach &&
+             cl->endian == endian)
+           {
+             cd = cl->cd;
+             break;
+           }
+       }
+    } 
 
   /* If we haven't initialized yet, initialize the opcode table.  */
   if (! cd)
@@ -546,6 +571,16 @@ print_insn_xstormy16 (pc, info)
                                 CGEN_CPU_OPEN_END);
       if (!cd)
        abort ();
+
+      /* save this away for future reference */
+      cl = xmalloc (sizeof (struct cpu_desc_list));
+      cl->cd = cd;
+      cl->isa = isa;
+      cl->mach = mach;
+      cl->endian = endian;
+      cl->next = cd_list;
+      cd_list = cl;
+
       xstormy16_cgen_init_dis (cd);
     }
 
This page took 0.024709 seconds and 4 git commands to generate.