]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/genextract.c
Update copyright years.
[thirdparty/gcc.git] / gcc / genextract.c
index 94b38c09d2b3e00c82068a7fc1eda73d9bcc938e..63911e72d338df7b1b39f8d590eb3516d0885d3b 100644 (file)
@@ -1,12 +1,11 @@
 /* Generate code from machine description to extract operands from insn as rtl.
-   Copyright (C) 1987, 1991, 1992, 1993, 1997, 1998, 1999, 2000, 2003, 2004
-   Free Software Foundation, Inc.
+   Copyright (C) 1987-2020 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
 GCC is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
+Software Foundation; either version 3, or (at your option) any later
 version.
 
 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -15,9 +14,8 @@ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 for more details.
 
 You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING.  If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA.  */
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
 
 
 #include "bconfig.h"
@@ -26,134 +24,135 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "tm.h"
 #include "rtl.h"
 #include "errors.h"
-#include "insn-config.h"
+#include "read-md.h"
 #include "gensupport.h"
 
-
 /* This structure contains all the information needed to describe one
    set of extractions methods.  Each method may be used by more than
    one pattern if the operands are in the same place.
 
    The string for each operand describes that path to the operand and
    contains `0' through `9' when going into an expression and `a' through
-   `z' when going into a vector.  We assume here that only the first operand
-   of an rtl expression is a vector.  genrecog.c makes the same assumption
-   (and uses the same representation) and it is currently true.  */
+   `z' then 'A' through to 'Z' when going into a vector.  We assume here that
+   only the first operand of an rtl expression is a vector.  genrecog.c makes
+   the same assumption (and uses the same representation) and it is currently
+   true.  */
+
+typedef char *locstr;
 
 struct extraction
 {
-  int op_count;
-  char *oplocs[MAX_RECOG_OPERANDS];
-  int dup_count;
-  char *duplocs[MAX_DUP_OPERANDS];
-  int dupnums[MAX_DUP_OPERANDS];
+  unsigned int op_count;
+  unsigned int dup_count;
+  locstr *oplocs;
+  locstr *duplocs;
+  int *dupnums;
   struct code_ptr *insns;
   struct extraction *next;
 };
 
-/* Holds a single insn code that use an extraction method.  */
-
+/* Holds a single insn code that uses an extraction method.  */
 struct code_ptr
 {
   int insn_code;
   struct code_ptr *next;
 };
 
+/* All extractions needed for this machine description.  */
 static struct extraction *extractions;
 
-/* Holds an array of names indexed by insn_code_number.  */
-static char **insn_name_ptr = 0;
-static int insn_name_ptr_size = 0;
-
-/* Number instruction patterns handled, starting at 0 for first one.  */
-
-static int insn_code_number;
-
-/* Records the large operand number in this insn.  */
-
-static int op_count;
-
-/* Records the location of any operands using the string format described
-   above.  */
-
-static char *oplocs[MAX_RECOG_OPERANDS];
-
-/* Number the occurrences of MATCH_DUP in each instruction,
-   starting at 0 for the first occurrence.  */
-
-static int dup_count;
+/* All insn codes for old-style peepholes.  */
+static struct code_ptr *peepholes;
 
-/* Records the location of any MATCH_DUP operands.  */
+/* This structure is used by gen_insn and walk_rtx to accumulate the
+   data that will be used to produce an extractions structure.  */
 
-static char *duplocs[MAX_DUP_OPERANDS];
 
-/* Record the operand number of any MATCH_DUPs.  */
+class accum_extract
+{
+public:
+  accum_extract () : oplocs (10), duplocs (10), dupnums (10), pathstr (20) {}
 
-static int dupnums[MAX_DUP_OPERANDS];
+  auto_vec<locstr> oplocs;
+  auto_vec<locstr> duplocs;
+  auto_vec<int> dupnums;
+  auto_vec<char> pathstr;
+};
 
-/* Record the list of insn_codes for peepholes.  */
+/* Forward declarations.  */
+static void walk_rtx (md_rtx_info *, rtx, class accum_extract *);
 
-static struct code_ptr *peepholes;
+#define UPPER_OFFSET ('A' - ('z' - 'a' + 1))
 
-static void gen_insn (rtx);
-static void walk_rtx (rtx, const char *);
-static void print_path (const char *);
-static void record_insn_name (int, const char *);
+/* Convert integer OPERAND into a character - either into [a-zA-Z] for vector
+   operands or [0-9] for integer operands - and push onto the end of the path
+   in ACC.  */
+static void
+push_pathstr_operand (int operand, bool is_vector,
+                    class accum_extract *acc)
+{
+  if (is_vector && 'a' + operand > 'z')
+    acc->pathstr.safe_push (operand + UPPER_OFFSET);
+  else if (is_vector)
+    acc->pathstr.safe_push (operand + 'a');
+  else
+    acc->pathstr.safe_push (operand + '0');
+}
 
 static void
-gen_insn (rtx insn)
+gen_insn (md_rtx_info *info)
 {
   int i;
+  unsigned int op_count, dup_count, j;
   struct extraction *p;
   struct code_ptr *link;
-
-  op_count = 0;
-  dup_count = 0;
-
-  /* No operands seen so far in this pattern.  */
-  memset (oplocs, 0, sizeof oplocs);
+  class accum_extract acc;
 
   /* Walk the insn's pattern, remembering at all times the path
      down to the walking point.  */
 
+  rtx insn = info->def;
   if (XVECLEN (insn, 1) == 1)
-    walk_rtx (XVECEXP (insn, 1, 0), "");
+    walk_rtx (info, XVECEXP (insn, 1, 0), &acc);
   else
     for (i = XVECLEN (insn, 1) - 1; i >= 0; i--)
       {
-       char path[2];
-
-       path[0] = 'a' + i;
-       path[1] = 0;
-
-       walk_rtx (XVECEXP (insn, 1, i), path);
+       push_pathstr_operand (i, true, &acc);
+       walk_rtx (info, XVECEXP (insn, 1, i), &acc);
+       acc.pathstr.pop ();
       }
 
-  link = xmalloc (sizeof (struct code_ptr));
-  link->insn_code = insn_code_number;
+  link = XNEW (struct code_ptr);
+  link->insn_code = info->index;
 
   /* See if we find something that already had this extraction method.  */
 
+  op_count = acc.oplocs.length ();
+  dup_count = acc.duplocs.length ();
+  gcc_assert (dup_count == acc.dupnums.length ());
+
   for (p = extractions; p; p = p->next)
     {
       if (p->op_count != op_count || p->dup_count != dup_count)
        continue;
 
-      for (i = 0; i < op_count; i++)
-       if (p->oplocs[i] != oplocs[i]
-           && ! (p->oplocs[i] != 0 && oplocs[i] != 0
-                 && ! strcmp (p->oplocs[i], oplocs[i])))
-         break;
+      for (j = 0; j < op_count; j++)
+       {
+         char *a = p->oplocs[j];
+         char *b = acc.oplocs[j];
+         if (a != b && (!a || !b || strcmp (a, b)))
+           break;
+       }
 
-      if (i != op_count)
+      if (j != op_count)
        continue;
 
-      for (i = 0; i < dup_count; i++)
-       if (p->dupnums[i] != dupnums[i]
-           || strcmp (p->duplocs[i], duplocs[i]))
+      for (j = 0; j < dup_count; j++)
+       if (p->dupnums[j] != acc.dupnums[j]
+           || strcmp (p->duplocs[j], acc.duplocs[j]))
          break;
 
-      if (i != dup_count)
+      if (j != dup_count)
        continue;
 
       /* This extraction is the same as ours.  Just link us in.  */
@@ -162,9 +161,13 @@ gen_insn (rtx insn)
       return;
     }
 
-  /* Otherwise, make a new extraction method.  */
+  /* Otherwise, make a new extraction method.  We stash the arrays
+     after the extraction structure in memory.  */
 
-  p = xmalloc (sizeof (struct extraction));
+  p = XNEWVAR (struct extraction, sizeof (struct extraction)
+              + op_count*sizeof (char *)
+              + dup_count*sizeof (char *)
+              + dup_count*sizeof (int));
   p->op_count = op_count;
   p->dup_count = dup_count;
   p->next = extractions;
@@ -172,28 +175,65 @@ gen_insn (rtx insn)
   p->insns = link;
   link->next = 0;
 
-  for (i = 0; i < op_count; i++)
-    p->oplocs[i] = oplocs[i];
+  p->oplocs = (char **)((char *)p + sizeof (struct extraction));
+  p->duplocs = p->oplocs + op_count;
+  p->dupnums = (int *)(p->duplocs + dup_count);
 
-  for (i = 0; i < dup_count; i++)
-    p->dupnums[i] = dupnums[i], p->duplocs[i] = duplocs[i];
+  memcpy (p->oplocs, acc.oplocs.address (), op_count * sizeof (locstr));
+  memcpy (p->duplocs, acc.duplocs.address (), dup_count * sizeof (locstr));
+  memcpy (p->dupnums, acc.dupnums.address (), dup_count * sizeof (int));
 }
 \f
+/* Helper subroutine of walk_rtx: given a vec<locstr>, an index, and a
+   string, insert the string at the index, which should either already
+   exist and be NULL, or not yet exist within the vector.  In the latter
+   case the vector is enlarged as appropriate.  INFO describes the
+   containing define_* expression.  */
 static void
-walk_rtx (rtx x, const char *path)
+VEC_safe_set_locstr (md_rtx_info *info, vec<locstr> *vp,
+                    unsigned int ix, char *str)
+{
+  if (ix < (*vp).length ())
+    {
+      if ((*vp)[ix])
+       {
+         message_at (info->loc, "repeated operand number %d", ix);
+         have_error = 1;
+       }
+      else
+        (*vp)[ix] = str;
+    }
+  else
+    {
+      while (ix > (*vp).length ())
+       vp->safe_push (NULL);
+      vp->safe_push (str);
+    }
+}
+
+/* Another helper subroutine of walk_rtx: given a vec<char>, convert it
+   to a NUL-terminated string in malloc memory.  */
+static char *
+VEC_char_to_string (vec<char> v)
+{
+  size_t n = v.length ();
+  char *s = XNEWVEC (char, n + 1);
+  memcpy (s, v.address (), n);
+  s[n] = '\0';
+  return s;
+}
+
+static void
+walk_rtx (md_rtx_info *info, rtx x, class accum_extract *acc)
 {
   RTX_CODE code;
-  int i;
-  int len;
+  int i, len;
   const char *fmt;
-  int depth = strlen (path);
-  char *newpath;
 
   if (x == 0)
     return;
 
   code = GET_CODE (x);
-
   switch (code)
     {
     case PC:
@@ -204,98 +244,65 @@ walk_rtx (rtx x, const char *path)
 
     case MATCH_OPERAND:
     case MATCH_SCRATCH:
-      oplocs[XINT (x, 0)] = xstrdup (path);
-      op_count = MAX (op_count, XINT (x, 0) + 1);
+      VEC_safe_set_locstr (info, &acc->oplocs, XINT (x, 0),
+                          VEC_char_to_string (acc->pathstr));
       break;
 
-    case MATCH_DUP:
-      duplocs[dup_count] = xstrdup (path);
-      dupnums[dup_count] = XINT (x, 0);
-      dup_count++;
-      break;
-
-    case MATCH_PAR_DUP:
-    case MATCH_OP_DUP:
-      duplocs[dup_count] = xstrdup (path);
-      dupnums[dup_count] = XINT (x, 0);
-      dup_count++;
-
-      newpath = xmalloc (depth + 2);
-      strcpy (newpath, path);
-      newpath[depth + 1] = 0;
-
-      for (i = XVECLEN (x, 1) - 1; i >= 0; i--)
-        {
-         newpath[depth] = (code == MATCH_OP_DUP ? '0' : 'a') + i;
-         walk_rtx (XVECEXP (x, 1, i), newpath);
-        }
-      free (newpath);
-      return;
-
     case MATCH_OPERATOR:
-      oplocs[XINT (x, 0)] = xstrdup (path);
-      op_count = MAX (op_count, XINT (x, 0) + 1);
-
-      newpath = xmalloc (depth + 2);
-      strcpy (newpath, path);
-      newpath[depth + 1] = 0;
+    case MATCH_PARALLEL:
+      VEC_safe_set_locstr (info, &acc->oplocs, XINT (x, 0),
+                          VEC_char_to_string (acc->pathstr));
 
       for (i = XVECLEN (x, 2) - 1; i >= 0; i--)
        {
-         newpath[depth] = '0' + i;
-         walk_rtx (XVECEXP (x, 2, i), newpath);
-       }
-      free (newpath);
+         push_pathstr_operand (i, code != MATCH_OPERATOR, acc);
+         walk_rtx (info, XVECEXP (x, 2, i), acc);
+         acc->pathstr.pop ();
+        }
       return;
 
-    case MATCH_PARALLEL:
-      oplocs[XINT (x, 0)] = xstrdup (path);
-      op_count = MAX (op_count, XINT (x, 0) + 1);
-
-      newpath = xmalloc (depth + 2);
-      strcpy (newpath, path);
-      newpath[depth + 1] = 0;
+    case MATCH_DUP:
+    case MATCH_PAR_DUP:
+    case MATCH_OP_DUP:
+      acc->duplocs.safe_push (VEC_char_to_string (acc->pathstr));
+      acc->dupnums.safe_push (XINT (x, 0));
 
-      for (i = XVECLEN (x, 2) - 1; i >= 0; i--)
-       {
-         newpath[depth] = 'a' + i;
-         walk_rtx (XVECEXP (x, 2, i), newpath);
-       }
-      free (newpath);
-      return;
+      if (code == MATCH_DUP)
+       break;
 
-    case ADDRESS:
-      walk_rtx (XEXP (x, 0), path);
+      for (i = XVECLEN (x, 1) - 1; i >= 0; i--)
+        {
+         push_pathstr_operand (i, code != MATCH_OP_DUP, acc);
+         walk_rtx (info, XVECEXP (x, 1, i), acc);
+         acc->pathstr.pop ();
+        }
       return;
 
     default:
       break;
     }
 
-  newpath = xmalloc (depth + 2);
-  strcpy (newpath, path);
-  newpath[depth + 1] = 0;
-
   fmt = GET_RTX_FORMAT (code);
   len = GET_RTX_LENGTH (code);
   for (i = 0; i < len; i++)
     {
       if (fmt[i] == 'e' || fmt[i] == 'u')
        {
-         newpath[depth] = '0' + i;
-         walk_rtx (XEXP (x, i), newpath);
+         push_pathstr_operand (i, false, acc);
+         walk_rtx (info, XEXP (x, i), acc);
+         acc->pathstr.pop ();
        }
       else if (fmt[i] == 'E')
        {
          int j;
          for (j = XVECLEN (x, i) - 1; j >= 0; j--)
            {
-             newpath[depth] = 'a' + j;
-             walk_rtx (XVECEXP (x, i, j), newpath);
+             push_pathstr_operand (j, true, acc);
+             walk_rtx (info, XVECEXP (x, i, j), acc);
+             acc->pathstr.pop ();
            }
        }
     }
-  free (newpath);
 }
 
 /* Given a PATH, representing a path down the instruction's
@@ -312,113 +319,133 @@ print_path (const char *path)
     {
       /* Don't emit "pat", since we may try to take the address of it,
         which isn't what is intended.  */
-      printf("PATTERN (insn)");
+      fputs ("PATTERN (insn)", stdout);
       return;
     }
 
   /* We first write out the operations (XEXP or XVECEXP) in reverse
-     order, then write "insn", then the indices in forward order.  */
+     order, then write "pat", then the indices in forward order.  */
 
   for (i = len - 1; i >= 0 ; i--)
     {
-      if (ISLOWER(path[i]))
-       printf ("XVECEXP (");
-      else if (ISDIGIT(path[i]))
-       printf ("XEXP (");
+      if (ISLOWER (path[i]) || ISUPPER (path[i]))
+       fputs ("XVECEXP (", stdout);
+      else if (ISDIGIT (path[i]))
+       fputs ("XEXP (", stdout);
       else
-       abort ();
+       gcc_unreachable ();
     }
 
-  printf ("pat");
+  fputs ("pat", stdout);
 
   for (i = 0; i < len; i++)
     {
-      if (ISLOWER(path[i]))
+      if (ISUPPER (path[i]))
+       printf (", 0, %d)", path[i] - UPPER_OFFSET);
+      else if (ISLOWER (path[i]))
        printf (", 0, %d)", path[i] - 'a');
-      else if (ISDIGIT(path[i]))
+      else if (ISDIGIT (path[i]))
        printf (", %d)", path[i] - '0');
       else
-       abort ();
+       gcc_unreachable ();
     }
 }
 \f
+static void
+print_header (void)
+{
+  /* N.B. Code below avoids putting squiggle braces in column 1 inside
+     a string, because this confuses some editors' syntax highlighting
+     engines.  */
+
+  puts ("\
+/* Generated automatically by the program `genextract'\n\
+   from the machine description file `md'.  */\n\
+\n\
+#define IN_TARGET_CODE 1\n\
+#include \"config.h\"\n\
+#include \"system.h\"\n\
+#include \"coretypes.h\"\n\
+#include \"tm.h\"\n\
+#include \"rtl.h\"\n\
+#include \"insn-config.h\"\n\
+#include \"recog.h\"\n\
+#include \"diagnostic-core.h\"\n\
+\n\
+/* This variable is used as the \"location\" of any missing operand\n\
+   whose numbers are skipped by a given pattern.  */\n\
+static rtx junk ATTRIBUTE_UNUSED;\n");
+
+  puts ("\
+void\n\
+insn_extract (rtx_insn *insn)\n{\n\
+  rtx *ro = recog_data.operand;\n\
+  rtx **ro_loc = recog_data.operand_loc;\n\
+  rtx pat = PATTERN (insn);\n\
+  int i ATTRIBUTE_UNUSED; /* only for peepholes */\n\
+\n\
+  if (flag_checking)\n\
+    {\n\
+      memset (ro, 0xab, sizeof (*ro) * MAX_RECOG_OPERANDS);\n\
+      memset (ro_loc, 0xab, sizeof (*ro_loc) * MAX_RECOG_OPERANDS);\n\
+    }\n");
+
+  puts ("\
+  switch (INSN_CODE (insn))\n\
+    {\n\
+    default:\n\
+      /* Control reaches here if insn_extract has been called with an\n\
+         unrecognizable insn (code -1), or an insn whose INSN_CODE\n\
+         corresponds to a DEFINE_EXPAND in the machine description;\n\
+         either way, a bug.  */\n\
+      if (INSN_CODE (insn) < 0)\n\
+        fatal_insn (\"unrecognizable insn:\", insn);\n\
+      else\n\
+        fatal_insn (\"insn with invalid code number:\", insn);\n");
+}
 
 int
-main (int argc, char **argv)
+main (int argc, const char **argv)
 {
-  rtx desc;
-  int i;
+  unsigned int i;
   struct extraction *p;
   struct code_ptr *link;
   const char *name;
 
   progname = "genextract";
 
-  if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE)
+  if (!init_rtx_reader_args (argc, argv))
     return (FATAL_EXIT_CODE);
 
-  /* Assign sequential codes to all entries in the machine description
-     in parallel with the tables in insn-output.c.  */
-
-  insn_code_number = 0;
-
-  printf ("/* Generated automatically by the program `genextract'\n\
-from the machine description file `md'.  */\n\n");
-
-  printf ("#include \"config.h\"\n");
-  printf ("#include \"system.h\"\n");
-  printf ("#include \"coretypes.h\"\n");
-  printf ("#include \"tm.h\"\n");
-  printf ("#include \"rtl.h\"\n");
-  printf ("#include \"insn-config.h\"\n");
-  printf ("#include \"recog.h\"\n");
-  printf ("#include \"toplev.h\"\n\n");
-
-  /* This variable exists only so it can be the "location"
-     of any missing operand whose numbers are skipped by a given pattern.  */
-  printf ("static rtx junk ATTRIBUTE_UNUSED;\n");
-
-  printf ("void\ninsn_extract (rtx insn)\n");
-  printf ("{\n");
-  printf ("  rtx *ro = recog_data.operand;\n");
-  printf ("  rtx **ro_loc = recog_data.operand_loc;\n");
-  printf ("  rtx pat = PATTERN (insn);\n");
-  printf ("  int i ATTRIBUTE_UNUSED;\n\n");
-#ifdef ENABLE_CHECKING
-  printf ("  memset (ro, 0xab, sizeof (*ro) * MAX_RECOG_OPERANDS);\n");
-  printf ("  memset (ro_loc, 0xab, sizeof (*ro_loc) * MAX_RECOG_OPERANDS);\n");
-#endif
-  printf ("  switch (INSN_CODE (insn))\n");
-  printf ("    {\n");
-  printf ("    case -1:\n");
-  printf ("      fatal_insn_not_found (insn);\n\n");
-
   /* Read the machine description.  */
 
-  while (1)
-    {
-      int line_no;
-
-      desc = read_md_rtx (&line_no, &insn_code_number);
-      if (desc == NULL)
+  md_rtx_info info;
+  while (read_md_rtx (&info))
+    switch (GET_CODE (info.def))
+      {
+      case DEFINE_INSN:
+       gen_insn (&info);
        break;
 
-       if (GET_CODE (desc) == DEFINE_INSN)
+      case DEFINE_PEEPHOLE:
        {
-         record_insn_name (insn_code_number, XSTR (desc, 0));
-         gen_insn (desc);
-       }
+         struct code_ptr *link = XNEW (struct code_ptr);
 
-      else if (GET_CODE (desc) == DEFINE_PEEPHOLE)
-       {
-         struct code_ptr *link = xmalloc (sizeof (struct code_ptr));
-
-         link->insn_code = insn_code_number;
+         link->insn_code = info.index;
          link->next = peepholes;
          peepholes = link;
        }
+       break;
+
+      default:
+       break;
     }
 
+  if (have_error)
+    return FATAL_EXIT_CODE;
+
+  print_header ();
+
   /* Write out code to handle peepholes and the insn_codes that it should
      be called for.  */
   if (peepholes)
@@ -431,9 +458,9 @@ from the machine description file `md'.  */\n\n");
         created just for the sake of this function.  We need to set the
         location of the operands for sake of simplifications after
         extraction, like eliminating subregs.  */
-      printf ("      for (i = XVECLEN (pat, 0) - 1; i >= 0; i--)\n");
-      printf ("          ro[i] = *(ro_loc[i] = &XVECEXP (pat, 0, i));\n");
-      printf ("      break;\n\n");
+      puts ("      for (i = XVECLEN (pat, 0) - 1; i >= 0; i--)\n"
+           "          ro[i] = *(ro_loc[i] = &XVECEXP (pat, 0, i));\n"
+           "      break;\n");
     }
 
   /* Write out all the ways to extract insn operands.  */
@@ -460,7 +487,7 @@ from the machine description file `md'.  */\n\n");
            {
              printf ("      ro[%d] = *(ro_loc[%d] = &", i, i);
              print_path (p->oplocs[i]);
-             printf (");\n");
+             puts (");");
            }
        }
 
@@ -468,61 +495,14 @@ from the machine description file `md'.  */\n\n");
        {
          printf ("      recog_data.dup_loc[%d] = &", i);
          print_path (p->duplocs[i]);
-         printf (";\n");
+         puts (";");
          printf ("      recog_data.dup_num[%d] = %d;\n", i, p->dupnums[i]);
        }
 
-      printf ("      break;\n\n");
+      puts ("      break;\n");
     }
 
-  /* This should never be reached.  Note that we would also reach this abort
-   if we tried to extract something whose INSN_CODE was a DEFINE_EXPAND or
-   DEFINE_SPLIT, but that is correct.  */
-  printf ("    default:\n      abort ();\n");
-
-  printf ("    }\n}\n");
-
+  puts ("    }\n}");
   fflush (stdout);
   return (ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE);
 }
-
-/* Define this so we can link with print-rtl.o to get debug_rtx function.  */
-const char *
-get_insn_name (int code ATTRIBUTE_UNUSED)
-{
-  if (code < insn_name_ptr_size)
-    return insn_name_ptr[code];
-  else
-    return NULL;
-}
-
-static void
-record_insn_name (int code, const char *name)
-{
-  static const char *last_real_name = "insn";
-  static int last_real_code = 0;
-  char *new;
-
-  if (insn_name_ptr_size <= code)
-    {
-      int new_size;
-      new_size = (insn_name_ptr_size ? insn_name_ptr_size * 2 : 512);
-      insn_name_ptr = xrealloc (insn_name_ptr, sizeof(char *) * new_size);
-      memset (insn_name_ptr + insn_name_ptr_size, 0,
-             sizeof(char *) * (new_size - insn_name_ptr_size));
-      insn_name_ptr_size = new_size;
-    }
-
-  if (!name || name[0] == '\0')
-    {
-      new = xmalloc (strlen (last_real_name) + 10);
-      sprintf (new, "%s+%d", last_real_name, code - last_real_code);
-    }
-  else
-    {
-      last_real_name = new = xstrdup (name);
-      last_real_code = code;
-    }
-
-  insn_name_ptr[code] = new;
-}