This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
better errors from genoutput
- To: gcc-patches at gcc dot gnu dot org
- Subject: better errors from genoutput
- From: Richard Henderson <rth at cygnus dot com>
- Date: Sat, 27 May 2000 13:01:51 -0700
Line numbers for error messages. What a concept.
r~
* genoutput.c: Don't include errors.h.
(struct data): Add lineno member.
(have_error): New.
(scan_operands): Use message_with_line instead of error.
(validate_insn_alternatives): Likewise.
(gen_insn): Accept and store the pattern's line number.
(gen_peephole, gen_expand, gen_split): Likewise.
(main): Don't set progname. Pass line_no to gen_foo.
Index: genoutput.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/genoutput.c,v
retrieving revision 1.53
diff -c -p -d -r1.53 genoutput.c
*** genoutput.c 2000/05/18 22:05:14 1.53
--- genoutput.c 2000/05/27 19:57:42
*************** Boston, MA 02111-1307, USA. */
*** 88,94 ****
#include "hconfig.h"
#include "system.h"
#include "rtl.h"
- #include "errors.h"
#include "gensupport.h"
/* No instruction can have more operands than this. Sorry for this
--- 88,93 ----
*************** struct data
*** 158,163 ****
--- 157,163 ----
const char *template;
int code_number;
int index_number;
+ int lineno;
int n_operands; /* Number of operands this insn recognizes */
int n_dups; /* Number times match_dup appears in pattern */
int n_alternatives; /* Number of alternatives in each constraint */
*************** struct data
*** 169,174 ****
--- 169,176 ----
/* This variable points to the first link in the insn chain. */
static struct data *idata, **idata_end = &idata;
+
+ static int have_error;
static void output_prologue PARAMS ((void));
static void output_predicate_decls PARAMS ((void));
*************** static int compare_operands PARAMS ((str
*** 181,190 ****
static void place_operands PARAMS ((struct data *));
static void process_template PARAMS ((struct data *, const char *));
static void validate_insn_alternatives PARAMS ((struct data *));
! static void gen_insn PARAMS ((rtx));
! static void gen_peephole PARAMS ((rtx));
! static void gen_expand PARAMS ((rtx));
! static void gen_split PARAMS ((rtx));
const char *
get_insn_name (index)
--- 183,192 ----
static void place_operands PARAMS ((struct data *));
static void process_template PARAMS ((struct data *, const char *));
static void validate_insn_alternatives PARAMS ((struct data *));
! static void gen_insn PARAMS ((rtx, int));
! static void gen_peephole PARAMS ((rtx, int));
! static void gen_expand PARAMS ((rtx, int));
! static void gen_split PARAMS ((rtx, int));
const char *
get_insn_name (index)
*************** static void
*** 213,219 ****
output_prologue ()
{
printf ("/* Generated automatically by the program `genoutput'\n\
! from the machine description file `md'. */\n\n");
printf ("#include \"config.h\"\n");
printf ("#include \"system.h\"\n");
--- 215,221 ----
output_prologue ()
{
printf ("/* Generated automatically by the program `genoutput'\n\
! from the machine description file `md'. */\n\n");
printf ("#include \"config.h\"\n");
printf ("#include \"system.h\"\n");
*************** scan_operands (d, part, this_address_p,
*** 421,433 ****
max_opno = opno;
if (max_opno >= MAX_MAX_OPERANDS)
{
! error ("Too many operands (%d) in definition %s.\n",
! max_opno + 1, get_insn_name (next_index_number));
return;
}
if (d->operand[opno].seen)
! error ("Definition %s specified operand number %d more than once.\n",
! get_insn_name (next_index_number), opno);
d->operand[opno].seen = 1;
d->operand[opno].mode = GET_MODE (part);
d->operand[opno].strict_low = this_strict_low;
--- 423,440 ----
max_opno = opno;
if (max_opno >= MAX_MAX_OPERANDS)
{
! message_with_line (d->lineno,
! "maximum number of operands exceeded");
! have_error = 1;
return;
}
if (d->operand[opno].seen)
! {
! message_with_line (d->lineno,
! "repeated operand number %d\n", opno);
! have_error = 1;
! }
!
d->operand[opno].seen = 1;
d->operand[opno].mode = GET_MODE (part);
d->operand[opno].strict_low = this_strict_low;
*************** scan_operands (d, part, this_address_p,
*** 445,457 ****
max_opno = opno;
if (max_opno >= MAX_MAX_OPERANDS)
{
! error ("Too many operands (%d) in definition %s.\n",
! max_opno + 1, get_insn_name (next_index_number));
return;
}
if (d->operand[opno].seen)
! error ("Definition %s specified operand number %d more than once.\n",
! get_insn_name (next_index_number), opno);
d->operand[opno].seen = 1;
d->operand[opno].mode = GET_MODE (part);
d->operand[opno].strict_low = 0;
--- 452,469 ----
max_opno = opno;
if (max_opno >= MAX_MAX_OPERANDS)
{
! message_with_line (d->lineno,
! "maximum number of operands exceeded");
! have_error = 1;
return;
}
if (d->operand[opno].seen)
! {
! message_with_line (d->lineno,
! "repeated operand number %d\n", opno);
! have_error = 1;
! }
!
d->operand[opno].seen = 1;
d->operand[opno].mode = GET_MODE (part);
d->operand[opno].strict_low = 0;
*************** scan_operands (d, part, this_address_p,
*** 470,482 ****
max_opno = opno;
if (max_opno >= MAX_MAX_OPERANDS)
{
! error ("Too many operands (%d) in definition %s.\n",
! max_opno + 1, get_insn_name (next_index_number));
return;
}
if (d->operand[opno].seen)
! error ("Definition %s specified operand number %d more than once.\n",
! get_insn_name (next_index_number), opno);
d->operand[opno].seen = 1;
d->operand[opno].mode = GET_MODE (part);
d->operand[opno].strict_low = 0;
--- 482,499 ----
max_opno = opno;
if (max_opno >= MAX_MAX_OPERANDS)
{
! message_with_line (d->lineno,
! "maximum number of operands exceeded");
! have_error = 1;
return;
}
if (d->operand[opno].seen)
! {
! message_with_line (d->lineno,
! "repeated operand number %d\n", opno);
! have_error = 1;
! }
!
d->operand[opno].seen = 1;
d->operand[opno].mode = GET_MODE (part);
d->operand[opno].strict_low = 0;
*************** validate_insn_alternatives (d)
*** 695,702 ****
if (n == 0)
n = d->operand[start].n_alternatives;
else if (n != d->operand[start].n_alternatives)
! error ("wrong number of alternatives in operand %d of insn %s",
! start, get_insn_name (d->index_number));
}
/* Record the insn's overall number of alternatives. */
--- 712,723 ----
if (n == 0)
n = d->operand[start].n_alternatives;
else if (n != d->operand[start].n_alternatives)
! {
! message_with_line (d->lineno,
! "wrong number of alternatives in operand %d",
! start);
! have_error = 1;
! }
}
/* Record the insn's overall number of alternatives. */
*************** validate_insn_alternatives (d)
*** 708,721 ****
a hairy output action, output a function for now. */
static void
! gen_insn (insn)
rtx insn;
{
register struct data *d = (struct data *) xmalloc (sizeof (struct data));
register int i;
d->code_number = next_code_number;
d->index_number = next_index_number;
if (XSTR (insn, 0)[0])
d->name = XSTR (insn, 0);
else
--- 729,744 ----
a hairy output action, output a function for now. */
static void
! gen_insn (insn, lineno)
rtx insn;
+ int lineno;
{
register struct data *d = (struct data *) xmalloc (sizeof (struct data));
register int i;
d->code_number = next_code_number;
d->index_number = next_index_number;
+ d->lineno = lineno;
if (XSTR (insn, 0)[0])
d->name = XSTR (insn, 0);
else
*************** gen_insn (insn)
*** 747,760 ****
If the insn has a hairy output action, output it now. */
static void
! gen_peephole (peep)
rtx peep;
{
register struct data *d = (struct data *) xmalloc (sizeof (struct data));
register int i;
d->code_number = next_code_number;
d->index_number = next_index_number;
d->name = 0;
/* Build up the list in the same order as the insns are seen
--- 770,785 ----
If the insn has a hairy output action, output it now. */
static void
! gen_peephole (peep, lineno)
rtx peep;
+ int lineno;
{
register struct data *d = (struct data *) xmalloc (sizeof (struct data));
register int i;
d->code_number = next_code_number;
d->index_number = next_index_number;
+ d->lineno = lineno;
d->name = 0;
/* Build up the list in the same order as the insns are seen
*************** gen_peephole (peep)
*** 785,798 ****
only for the purposes of `insn_gen_function'. */
static void
! gen_expand (insn)
rtx insn;
{
register struct data *d = (struct data *) xmalloc (sizeof (struct data));
register int i;
d->code_number = next_code_number;
d->index_number = next_index_number;
if (XSTR (insn, 0)[0])
d->name = XSTR (insn, 0);
else
--- 810,825 ----
only for the purposes of `insn_gen_function'. */
static void
! gen_expand (insn, lineno)
rtx insn;
+ int lineno;
{
register struct data *d = (struct data *) xmalloc (sizeof (struct data));
register int i;
d->code_number = next_code_number;
d->index_number = next_index_number;
+ d->lineno = lineno;
if (XSTR (insn, 0)[0])
d->name = XSTR (insn, 0);
else
*************** gen_expand (insn)
*** 828,841 ****
only for reasons of consistency and to simplify genrecog. */
static void
! gen_split (split)
rtx split;
{
register struct data *d = (struct data *) xmalloc (sizeof (struct data));
register int i;
d->code_number = next_code_number;
d->index_number = next_index_number;
d->name = 0;
/* Build up the list in the same order as the insns are seen
--- 855,870 ----
only for reasons of consistency and to simplify genrecog. */
static void
! gen_split (split, lineno)
rtx split;
+ int lineno;
{
register struct data *d = (struct data *) xmalloc (sizeof (struct data));
register int i;
d->code_number = next_code_number;
d->index_number = next_index_number;
+ d->lineno = lineno;
d->name = 0;
/* Build up the list in the same order as the insns are seen
*************** main (argc, argv)
*** 872,879 ****
{
rtx desc;
- progname = "genoutput";
-
if (argc <= 1)
fatal ("No input file name.");
--- 901,906 ----
*************** main (argc, argv)
*** 895,908 ****
break;
if (GET_CODE (desc) == DEFINE_INSN)
! gen_insn (desc);
if (GET_CODE (desc) == DEFINE_PEEPHOLE)
! gen_peephole (desc);
if (GET_CODE (desc) == DEFINE_EXPAND)
! gen_expand (desc);
if (GET_CODE (desc) == DEFINE_SPLIT
|| GET_CODE (desc) == DEFINE_PEEPHOLE2)
! gen_split (desc);
next_index_number++;
}
--- 922,935 ----
break;
if (GET_CODE (desc) == DEFINE_INSN)
! gen_insn (desc, line_no);
if (GET_CODE (desc) == DEFINE_PEEPHOLE)
! gen_peephole (desc, line_no);
if (GET_CODE (desc) == DEFINE_EXPAND)
! gen_expand (desc, line_no);
if (GET_CODE (desc) == DEFINE_SPLIT
|| GET_CODE (desc) == DEFINE_PEEPHOLE2)
! gen_split (desc, line_no);
next_index_number++;
}