genoutput.c (name_for_index): New function.
authorRichard Henderson <rth@cygnus.com>
Tue, 19 Jan 1999 20:24:22 +0000 (12:24 -0800)
committerRichard Henderson <rth@gcc.gnu.org>
Tue, 19 Jan 1999 20:24:22 +0000 (12:24 -0800)
        * genoutput.c (name_for_index): New function.
        (scan_operands, validate_insn_alternatives): Use it.
        * genrecog.c (insn_name_ptr_size): New variable.
        (make_insn_sequence): Fill in insn_name_ptr.
        (merge_trees): Use it.

From-SVN: r24770

gcc/ChangeLog
gcc/genoutput.c
gcc/genrecog.c

index 4b51d91c9b420805e3400a5e1c22fe7b9b73229a..457463471328d64de31bc989b2bfa9325dab0277 100644 (file)
@@ -1,3 +1,11 @@
+Tue Jan 19 16:56:03 1999  Richard Henderson  <rth@cygnus.com>
+
+       * genoutput.c (name_for_index): New function.
+       (scan_operands, validate_insn_alternatives): Use it.
+       * genrecog.c (insn_name_ptr_size): New variable.
+       (make_insn_sequence): Fill in insn_name_ptr.
+       (merge_trees): Use it.
+
 Tue Jan 19 16:37:36 1999  Richard Henderson  <rth@cygnus.com>
 
        * i386/isc.h (TARGET_DEFAULT): Define symbolicly.
index eaa4461c3041147fdfbd492ef23d3bba29c79819..04667fee0ee7c5a1958e96d183db4a9ddf425513 100644 (file)
@@ -170,6 +170,7 @@ int have_constraints;
 
 static int have_error;
 \f
+static char * name_for_index PROTO((int));
 static void output_prologue PROTO((void));
 static void output_epilogue PROTO((void));
 static void scan_operands PROTO((rtx, int, int));
@@ -181,6 +182,29 @@ static void gen_expand PROTO((rtx));
 static void gen_split PROTO((rtx));
 static int n_occurrences PROTO((int, char *));
 \f
+static char *
+name_for_index (index)
+     int index;
+{
+  static char buf[100];
+
+  struct data *i, *last_named = NULL;
+  for (i = insn_data; i ; i = i->next)
+    {
+      if (i->index_number == index)
+       return i->name;
+      if (i->name)
+       last_named = i;
+    }
+
+  if (last_named)
+    sprintf(buf, "%s+%d", last_named->name, index - last_named->index_number);
+  else
+    sprintf(buf, "insn %d", index);
+
+  return buf;
+}
+
 static void
 output_prologue ()
 {
@@ -440,13 +464,13 @@ scan_operands (part, this_address_p, this_strict_low)
        max_opno = opno;
       if (max_opno >= MAX_MAX_OPERANDS)
        {
-         error ("Too many operands (%d) in definition %d.\n",
-                max_opno + 1, next_index_number);
+         error ("Too many operands (%d) in definition %s.\n",
+                max_opno + 1, name_for_index (next_index_number));
          return;
        }
       if (seen[opno])
-       error ("Definition %d specified operand number %d more than once.\n",
-              next_index_number, opno);
+       error ("Definition %s specified operand number %d more than once.\n",
+              name_for_index (next_index_number), opno);
       seen[opno] = 1;
       modes[opno] = GET_MODE (part);
       strict_low[opno] = this_strict_low;
@@ -466,13 +490,13 @@ scan_operands (part, this_address_p, this_strict_low)
        max_opno = opno;
       if (max_opno >= MAX_MAX_OPERANDS)
        {
-         error ("Too many operands (%d) in definition %d.\n",
-                max_opno + 1, next_index_number);
+         error ("Too many operands (%d) in definition %s.\n",
+                max_opno + 1, name_for_index (next_index_number));
          return;
        }
       if (seen[opno])
-       error ("Definition %d specified operand number %d more than once.\n",
-              next_index_number, opno);
+       error ("Definition %s specified operand number %d more than once.\n",
+              name_for_index (next_index_number), opno);
       seen[opno] = 1;
       modes[opno] = GET_MODE (part);
       strict_low[opno] = 0;
@@ -493,13 +517,13 @@ scan_operands (part, this_address_p, this_strict_low)
        max_opno = opno;
       if (max_opno >= MAX_MAX_OPERANDS)
        {
-         error ("Too many operands (%d) in definition %d.\n",
-                max_opno + 1, next_index_number);
+         error ("Too many operands (%d) in definition %s.\n",
+                max_opno + 1, name_for_index (next_index_number));
          return;
        }
       if (seen[opno])
-       error ("Definition %d specified operand number %d more than once.\n",
-              next_index_number, opno);
+       error ("Definition %s specified operand number %d more than once.\n",
+              name_for_index (next_index_number), opno);
       seen[opno] = 1;
       modes[opno] = GET_MODE (part);
       strict_low[opno] = 0;
@@ -644,8 +668,8 @@ validate_insn_alternatives (d)
        if (n == 0)
          n = d->op_n_alternatives[start];
        else if (n != d->op_n_alternatives[start])
-         error ("wrong number of alternatives in operand %d of insn number %d",
-                start, d->index_number);
+         error ("wrong number of alternatives in operand %d of insn %s",
+                start, name_for_index (d->index_number));
       }
   /* Record the insn's overall number of alternatives.  */
   d->n_alternatives = n;
index e25c3dc789a3a7ddaba26d5b85e110e200ae0166..da2a0cf36e9722b1b4cfed6875505523f07d8804 100644 (file)
@@ -60,8 +60,9 @@ struct obstack *rtl_obstack = &obstack;
 #define obstack_chunk_alloc xmalloc
 #define obstack_chunk_free free
 
-/* Define this so we can link with print-rtl.o to get debug_rtx function.  */
+/* Holds an array of names indexed by insn_code_number.  */
 char **insn_name_ptr = 0;
+int insn_name_ptr_size = 0;
 
 /* Data structure for a listhead of decision trees.  The alternatives
    to a node are kept in a doublely-linked list so we can easily add nodes
@@ -210,6 +211,37 @@ make_insn_sequence (insn, type)
   struct decision *last;
   struct decision_head head;
 
+  {
+    static char *last_real_name = "insn";
+    static int last_real_code = 0;
+    char *name;
+
+    if (insn_name_ptr_size <= next_insn_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);
+       bzero (insn_name_ptr + insn_name_ptr_size,
+              sizeof(char *) * (new_size - insn_name_ptr_size));
+       insn_name_ptr_size = new_size;
+      }
+
+    name = XSTR (insn, 0);
+    if (!name || name[0] == '\0')
+      {
+       name = xmalloc (strlen (last_real_name) + 10);
+       sprintf (name, "%s+%d", last_real_name,
+                next_insn_code - last_real_code);
+      }
+    else
+      {
+       last_real_name = name;
+       last_real_code = next_insn_code;
+      }
+  
+    insn_name_ptr[next_insn_code] = name;
+  }  
+
   if (XVECLEN (insn, type == RECOG) == 1)
     x = XVECEXP (insn, type == RECOG, 0);
   else
@@ -896,7 +928,11 @@ merge_trees (oldh, addh)
                      old->num_clobbers_to_add = 0;
                    }
                  else
-                   fatal ("Two actions at one point in tree");
+                   fatal ("Two actions at one point in tree for insns \"%s\" (%d) and \"%s\" (%d)",
+                          insn_name_ptr[old->insn_code_number],
+                          old->insn_code_number,
+                          insn_name_ptr[add->insn_code_number],
+                          add->insn_code_number);
                }
 
              if (old->insn_code_number == -1)