Remove trailing white spaces.
[deliverable/binutils-gdb.git] / opcodes / ia64-gen.c
index bfad2f7b4e437c7d09ec9a3932788ead5f94ea4d..b1d0225262ff682b60ae9b8823b9bb101388106f 100644 (file)
@@ -1,5 +1,6 @@
 /* ia64-gen.c -- Generate a shrunk set of opcode tables
-   Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+   Copyright 1999, 2000, 2001, 2002, 2004, 2005, 2006
+   Free Software Foundation, Inc.
    Written by Bob Manson, Cygnus Solutions, <manson@cygnus.com>
 
    This file is part of GDB, GAS, and the GNU binutils.
@@ -16,8 +17,8 @@
 
    You should have received a copy of the GNU General Public License
    along with this file; see the file COPYING.  If not, write to the
-   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA.  */
+   Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
+   02110-1301, USA.  */
 
 /* While the ia64-opc-* set of opcode tables are easy to maintain,
    they waste a tremendous amount of space.  ia64-gen rearranges the
 #include <libintl.h>
 #define _(String) gettext (String)
 
+/* This is a copy of fprintf_vma from bfd/bfd-in2.h.  We have to use this
+   always, because we might be compiled without BFD64 defined, if configured
+   for a 32-bit target and --enable-targets=all is used.  This will work for
+   both 32-bit and 64-bit hosts.  */
+#define _opcode_int64_low(x) ((unsigned long) (((x) & 0xffffffff)))
+#define _opcode_int64_high(x) ((unsigned long) (((x) >> 32) & 0xffffffff))
+#define opcode_fprintf_vma(s,x) \
+  fprintf ((s), "%08lx%08lx", _opcode_int64_high (x), _opcode_int64_low (x))
+
 const char * program_name = NULL;
 int debug = 0;
 
@@ -238,8 +248,8 @@ static int dlistlen = 0;
 static int dlisttotlen = 0;
 
 
-static void fail (const char *, ...);
-static void warn (const char *, ...);
+static void fail (const char *, ...) ATTRIBUTE_PRINTF_1;
+static void warn (const char *, ...) ATTRIBUTE_PRINTF_1;
 static struct rdep * insert_resource (const char *, enum ia64_dependency_mode);
 static int  deplist_equals (struct deplist *, struct deplist *);
 static short insert_deplist (int, unsigned short *);
@@ -457,7 +467,7 @@ fetch_insn_class (const char *full_name, int create)
   int ind;
   int is_class = 0;
 
-  if (strncmp (full_name, "IC:", 3) == 0)
+  if (CONST_STRNEQ (full_name, "IC:"))
     {
       name = xstrdup (full_name + 3);
       is_class = 1;
@@ -739,7 +749,7 @@ parse_resource_users (ref, usersp, nusersp, notesp)
          are read.  Only create new classes if it's *not* an insn class,
          or if it's a composite class (which wouldn't necessarily be in the IC
          table).  */
-      if (strncmp (name, "IC:", 3) != 0 || xsect != NULL)
+      if (! CONST_STRNEQ (name, "IC:") || xsect != NULL)
         create = 1;
       
       iclass = fetch_insn_class (name, create);
@@ -1024,7 +1034,7 @@ in_iclass (struct ia64_opcode *idesc, struct iclass *ic,
 
   if (ic->comment)
     {
-      if (!strncmp (ic->comment, "Format", 6))
+      if (CONST_STRNEQ (ic->comment, "Format"))
         {
           /* Assume that the first format seen is the most restrictive, and
              only keep a later one if it looks like it's more restrictive.  */
@@ -1040,7 +1050,7 @@ in_iclass (struct ia64_opcode *idesc, struct iclass *ic,
           else
             format = ic->comment;
         }
-      else if (!strncmp (ic->comment, "Field", 5))
+      else if (CONST_STRNEQ (ic->comment, "Field"))
         {
           if (field)
             warn (_("overlapping field %s->%s\n"),
@@ -1054,7 +1064,7 @@ in_iclass (struct ia64_opcode *idesc, struct iclass *ic,
      instructions.  */
   if (ic->nsubs == 0 && ic->nxsubs == 0)
     {
-      int is_mov = strncmp (idesc->name, "mov", 3) == 0;
+      int is_mov = CONST_STRNEQ (idesc->name, "mov");
       int plain_mov = strcmp (idesc->name, "mov") == 0;
       int len = strlen(ic->name);
 
@@ -1113,32 +1123,32 @@ in_iclass (struct ia64_opcode *idesc, struct iclass *ic,
 
       if (resolved && format)
         {
-          if (strncmp (idesc->name, "dep", 3) == 0
+          if (CONST_STRNEQ (idesc->name, "dep")
                    && strstr (format, "I13") != NULL)
             resolved = idesc->operands[1] == IA64_OPND_IMM8;
-          else if (strncmp (idesc->name, "chk", 3) == 0
+          else if (CONST_STRNEQ (idesc->name, "chk")
                    && strstr (format, "M21") != NULL)
             resolved = idesc->operands[0] == IA64_OPND_F2;
-          else if (strncmp (idesc->name, "lfetch", 6) == 0)
+          else if (CONST_STRNEQ (idesc->name, "lfetch"))
             resolved = (strstr (format, "M14 M15") != NULL
                         && (idesc->operands[1] == IA64_OPND_R2
                             || idesc->operands[1] == IA64_OPND_IMM9b));
-          else if (strncmp (idesc->name, "br.call", 7) == 0
+          else if (CONST_STRNEQ (idesc->name, "br.call")
                    && strstr (format, "B5") != NULL)
             resolved = idesc->operands[1] == IA64_OPND_B2;
-          else if (strncmp (idesc->name, "br.call", 7) == 0
+          else if (CONST_STRNEQ (idesc->name, "br.call")
                    && strstr (format, "B3") != NULL)
             resolved = idesc->operands[1] == IA64_OPND_TGT25c;
-          else if (strncmp (idesc->name, "brp", 3) == 0
+          else if (CONST_STRNEQ (idesc->name, "brp")
                    && strstr (format, "B7") != NULL)
             resolved = idesc->operands[0] == IA64_OPND_B2;
           else if (strcmp (ic->name, "invala") == 0)
             resolved = strcmp (idesc->name, ic->name) == 0;
-         else if (strncmp (idesc->name, "st", 2) == 0
+         else if (CONST_STRNEQ (idesc->name, "st")
                   && (strstr (format, "M5") != NULL
                       || strstr (format, "M10") != NULL))
            resolved = idesc->flags & IA64_OPCODE_POSTINC;
-         else if (strncmp (idesc->name, "ld", 2) == 0
+         else if (CONST_STRNEQ (idesc->name, "ld")
                   && (strstr (format, "M2 M3") != NULL
                       || strstr (format, "M12") != NULL
                       || strstr (format, "M7 M8") != NULL))
@@ -1151,7 +1161,7 @@ in_iclass (struct ia64_opcode *idesc, struct iclass *ic,
          plain brl matches brl.cond.  */
       if (!resolved
           && (strcmp (idesc->name, "brl") == 0
-              || strncmp (idesc->name, "brl.", 4) == 0)
+              || CONST_STRNEQ (idesc->name, "brl."))
           && strcmp (ic->name, "brl.cond") == 0)
         {
           resolved = 1;
@@ -1160,7 +1170,7 @@ in_iclass (struct ia64_opcode *idesc, struct iclass *ic,
       /* Misc br variations ('.cond' is optional).  */
       if (!resolved 
           && (strcmp (idesc->name, "br") == 0
-              || strncmp (idesc->name, "br.", 3) == 0)
+              || CONST_STRNEQ (idesc->name, "br."))
           && strcmp (ic->name, "br.cond") == 0)
         {
           if (format)
@@ -1173,7 +1183,7 @@ in_iclass (struct ia64_opcode *idesc, struct iclass *ic,
         }
 
       /* probe variations.  */
-      if (!resolved && strncmp (idesc->name, "probe", 5) == 0)
+      if (!resolved && CONST_STRNEQ (idesc->name, "probe"))
         {
           resolved = strcmp (ic->name, "probe") == 0 
             && !((strstr (idesc->name, "fault") != NULL) 
@@ -1207,7 +1217,7 @@ in_iclass (struct ia64_opcode *idesc, struct iclass *ic,
             }
 
           /* Some variants of mov and mov.[im].  */
-          if (!resolved && strncmp (ic->name, "mov_", 4) == 0)
+          if (!resolved && CONST_STRNEQ (ic->name, "mov_"))
            resolved = in_iclass_mov_x (idesc, ic, format, field);
         }
 
@@ -1399,6 +1409,8 @@ lookup_regindex (const char *name, int specifier)
         return 44;
       else if (strstr (name, ".ia"))
         return 45;
+      else if (strstr (name, ".vm"))
+        return 46;
       else
         abort ();
     default:
@@ -1464,13 +1476,13 @@ lookup_specifier (const char *name)
       warn (_("Don't know how to specify # dependency %s\n"),
            name);
     }
-  else if (strncmp (name, "AR[FPSR]", 8) == 0)
+  else if (CONST_STRNEQ (name, "AR[FPSR]"))
     return IA64_RS_AR_FPSR;
-  else if (strncmp (name, "AR[", 3) == 0)
+  else if (CONST_STRNEQ (name, "AR["))
     return IA64_RS_ARX;
-  else if (strncmp (name, "CR[", 3) == 0)
+  else if (CONST_STRNEQ (name, "CR["))
     return IA64_RS_CRX;
-  else if (strncmp (name, "PSR.", 4) == 0)
+  else if (CONST_STRNEQ (name, "PSR."))
     return IA64_RS_PSR;
   else if (strcmp (name, "InService*") == 0)
     return IA64_RS_INSERVICE;
@@ -1559,7 +1571,20 @@ print_dependency_table ()
               rdeps[i]->name, specifier,
               (int)rdeps[i]->mode, (int)rdeps[i]->semantics, regindex);
       if (rdeps[i]->semantics == IA64_DVS_OTHER)
-        printf ("\"%s\", ", rdeps[i]->extra);
+       {
+         const char *quote, *rest;
+
+         putchar ('\"');
+         rest = rdeps[i]->extra;
+         quote = strchr (rest, '\"');
+         while (quote != NULL)
+           {
+             printf ("%.*s\\\"", (int) (quote - rest), rest);
+             rest = quote + 1;
+             quote = strchr (rest, '\"');
+           }
+         printf ("%s\", ", rest);
+       }
       else
        printf ("NULL, ");
       printf("},\n");
@@ -1570,7 +1595,7 @@ print_dependency_table ()
   for (i=0;i < dlistlen;i++)
     {
       int len = 2;
-      printf ("static const short dep%d[] = {\n  ", i);
+      printf ("static const unsigned short dep%d[] = {\n  ", i);
       for (j=0;j < dlists[i]->len; j++)
         {
           len += printf ("%d, ", dlists[i]->deps[j]);
@@ -1913,7 +1938,7 @@ gen_dis_table (ent)
   if ((needed_bytes + insn_list_len) > tot_insn_list_len)
     {
       tot_insn_list_len += 256;
-      insn_list = (char *) xrealloc (insn_list, tot_insn_list_len);
+      insn_list = (unsigned char *) xrealloc (insn_list, tot_insn_list_len);
     }
   our_offset = insn_list_len;
   insn_list_len += needed_bytes;
@@ -2064,7 +2089,7 @@ gen_dis_table (ent)
          /* Store the address of the entry being branched to.  */
          while (currbits >= 0)
            {
-             char *byte = insn_list + our_offset + bitsused / 8;
+             unsigned char *byte = insn_list + our_offset + bitsused / 8;
 
              if (idest & (1 << currbits))
                *byte |= (1 << (7 - (bitsused % 8)));
@@ -2423,7 +2448,7 @@ insert_opcode_dependencies (opc, cmp)
       int j;
 
       if (strcmp (opc->name, "cmp.eq.and") == 0
-          && strncmp (rs->name, "PR%", 3) == 0
+          && CONST_STRNEQ (rs->name, "PR%")
           && rs->mode == 1)
         no_class_found = 99;
 
@@ -2434,7 +2459,7 @@ insert_opcode_dependencies (opc, cmp)
           if (in_iclass (opc, ics[rs->regs[j]], NULL, NULL, &ic_note))
             {
               /* We can ignore ic_note 11 for non PR resources.  */
-              if (ic_note == 11 && strncmp (rs->name, "PR", 2) != 0)
+              if (ic_note == 11 && ! CONST_STRNEQ (rs->name, "PR"))
                 ic_note = 0;
 
               if (ic_note != 0 && rs->regnotes[j] != 0
@@ -2462,7 +2487,7 @@ insert_opcode_dependencies (opc, cmp)
           if (in_iclass (opc, ics[rs->chks[j]], NULL, NULL, &ic_note))
             {
               /* We can ignore ic_note 11 for non PR resources.  */
-              if (ic_note == 11 && strncmp (rs->name, "PR", 2) != 0)
+              if (ic_note == 11 && ! CONST_STRNEQ (rs->name, "PR"))
                 ic_note = 0;
 
               if (ic_note != 0 && rs->chknotes[j] != 0
@@ -2700,9 +2725,9 @@ print_main_table (void)
              ptr->name->num,
              ptr->opcode->type,
              ptr->opcode->num_outputs);
-      fprintf_vma (stdout, ptr->opcode->opcode);
+      opcode_fprintf_vma (stdout, ptr->opcode->opcode);
       printf ("ull, 0x");
-      fprintf_vma (stdout, ptr->opcode->mask);
+      opcode_fprintf_vma (stdout, ptr->opcode->mask);
       printf ("ull, { %d, %d, %d, %d, %d }, 0x%x, %d, },\n",
              ptr->opcode->operands[0],
              ptr->opcode->operands[1],
This page took 0.028522 seconds and 4 git commands to generate.