Commit 8aeba909 by Richard Henderson Committed by Richard Henderson

genoutput.c (name_for_index): New function.

        * 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
parent 67e5db2c
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> Tue Jan 19 16:37:36 1999 Richard Henderson <rth@cygnus.com>
* i386/isc.h (TARGET_DEFAULT): Define symbolicly. * i386/isc.h (TARGET_DEFAULT): Define symbolicly.
......
...@@ -170,6 +170,7 @@ int have_constraints; ...@@ -170,6 +170,7 @@ int have_constraints;
static int have_error; static int have_error;
static char * name_for_index PROTO((int));
static void output_prologue PROTO((void)); static void output_prologue PROTO((void));
static void output_epilogue PROTO((void)); static void output_epilogue PROTO((void));
static void scan_operands PROTO((rtx, int, int)); static void scan_operands PROTO((rtx, int, int));
...@@ -181,6 +182,29 @@ static void gen_expand PROTO((rtx)); ...@@ -181,6 +182,29 @@ static void gen_expand PROTO((rtx));
static void gen_split PROTO((rtx)); static void gen_split PROTO((rtx));
static int n_occurrences PROTO((int, char *)); static int n_occurrences PROTO((int, char *));
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 static void
output_prologue () output_prologue ()
{ {
...@@ -440,13 +464,13 @@ scan_operands (part, this_address_p, this_strict_low) ...@@ -440,13 +464,13 @@ scan_operands (part, this_address_p, this_strict_low)
max_opno = opno; max_opno = opno;
if (max_opno >= MAX_MAX_OPERANDS) if (max_opno >= MAX_MAX_OPERANDS)
{ {
error ("Too many operands (%d) in definition %d.\n", error ("Too many operands (%d) in definition %s.\n",
max_opno + 1, next_index_number); max_opno + 1, name_for_index (next_index_number));
return; return;
} }
if (seen[opno]) if (seen[opno])
error ("Definition %d specified operand number %d more than once.\n", error ("Definition %s specified operand number %d more than once.\n",
next_index_number, opno); name_for_index (next_index_number), opno);
seen[opno] = 1; seen[opno] = 1;
modes[opno] = GET_MODE (part); modes[opno] = GET_MODE (part);
strict_low[opno] = this_strict_low; strict_low[opno] = this_strict_low;
...@@ -466,13 +490,13 @@ scan_operands (part, this_address_p, this_strict_low) ...@@ -466,13 +490,13 @@ scan_operands (part, this_address_p, this_strict_low)
max_opno = opno; max_opno = opno;
if (max_opno >= MAX_MAX_OPERANDS) if (max_opno >= MAX_MAX_OPERANDS)
{ {
error ("Too many operands (%d) in definition %d.\n", error ("Too many operands (%d) in definition %s.\n",
max_opno + 1, next_index_number); max_opno + 1, name_for_index (next_index_number));
return; return;
} }
if (seen[opno]) if (seen[opno])
error ("Definition %d specified operand number %d more than once.\n", error ("Definition %s specified operand number %d more than once.\n",
next_index_number, opno); name_for_index (next_index_number), opno);
seen[opno] = 1; seen[opno] = 1;
modes[opno] = GET_MODE (part); modes[opno] = GET_MODE (part);
strict_low[opno] = 0; strict_low[opno] = 0;
...@@ -493,13 +517,13 @@ scan_operands (part, this_address_p, this_strict_low) ...@@ -493,13 +517,13 @@ scan_operands (part, this_address_p, this_strict_low)
max_opno = opno; max_opno = opno;
if (max_opno >= MAX_MAX_OPERANDS) if (max_opno >= MAX_MAX_OPERANDS)
{ {
error ("Too many operands (%d) in definition %d.\n", error ("Too many operands (%d) in definition %s.\n",
max_opno + 1, next_index_number); max_opno + 1, name_for_index (next_index_number));
return; return;
} }
if (seen[opno]) if (seen[opno])
error ("Definition %d specified operand number %d more than once.\n", error ("Definition %s specified operand number %d more than once.\n",
next_index_number, opno); name_for_index (next_index_number), opno);
seen[opno] = 1; seen[opno] = 1;
modes[opno] = GET_MODE (part); modes[opno] = GET_MODE (part);
strict_low[opno] = 0; strict_low[opno] = 0;
...@@ -644,8 +668,8 @@ validate_insn_alternatives (d) ...@@ -644,8 +668,8 @@ validate_insn_alternatives (d)
if (n == 0) if (n == 0)
n = d->op_n_alternatives[start]; n = d->op_n_alternatives[start];
else if (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", error ("wrong number of alternatives in operand %d of insn %s",
start, d->index_number); start, name_for_index (d->index_number));
} }
/* Record the insn's overall number of alternatives. */ /* Record the insn's overall number of alternatives. */
d->n_alternatives = n; d->n_alternatives = n;
......
...@@ -60,8 +60,9 @@ struct obstack *rtl_obstack = &obstack; ...@@ -60,8 +60,9 @@ struct obstack *rtl_obstack = &obstack;
#define obstack_chunk_alloc xmalloc #define obstack_chunk_alloc xmalloc
#define obstack_chunk_free free #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; char **insn_name_ptr = 0;
int insn_name_ptr_size = 0;
/* Data structure for a listhead of decision trees. The alternatives /* 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 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) ...@@ -210,6 +211,37 @@ make_insn_sequence (insn, type)
struct decision *last; struct decision *last;
struct decision_head head; 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) if (XVECLEN (insn, type == RECOG) == 1)
x = XVECEXP (insn, type == RECOG, 0); x = XVECEXP (insn, type == RECOG, 0);
else else
...@@ -896,7 +928,11 @@ merge_trees (oldh, addh) ...@@ -896,7 +928,11 @@ merge_trees (oldh, addh)
old->num_clobbers_to_add = 0; old->num_clobbers_to_add = 0;
} }
else 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) if (old->insn_code_number == -1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment