Commit ca018d3c by Richard Sandiford Committed by Richard Sandiford

genoutput.c (data): Use a file_location to record the source position.

gcc/
	* genoutput.c (data): Use a file_location to record the source
	position.
	(nothing): Delete.
	(idata, idata_end): Remove initialization.
	(constraint_data): Replace lineno with a file_location.
	(output_insn_data): Update after changes to data.
	(gen_insn, gen_peephole, gen_expand, gen_split): Likewise.
	(scan_operands): Likewise, using *_at rather than *_with_line
	functions.
	(process_template): Likewise.
	(validate_insn_alternatives): Likewise.
	(validate_insn_operands): Likewise.
	(validate_optab_operands): Likewise.
	(init_insn_for_nothing): Initialize idata and idata_end.
	(note_constraint): Update after changes to constraint_data,
	using at rather than with_line functions.
	(mdep_constraint_len): Take a file_location rather than a
	line number.  Use at rather than with_line functions.

From-SVN: r225881
parent 8f246310
2015-07-16 Richard Sandiford <richard.sandiford@arm.com> 2015-07-16 Richard Sandiford <richard.sandiford@arm.com>
* genoutput.c (data): Use a file_location to record the source
position.
(nothing): Delete.
(idata, idata_end): Remove initialization.
(constraint_data): Replace lineno with a file_location.
(output_insn_data): Update after changes to data.
(gen_insn, gen_peephole, gen_expand, gen_split): Likewise.
(scan_operands): Likewise, using *_at rather than *_with_line
functions.
(process_template): Likewise.
(validate_insn_alternatives): Likewise.
(validate_insn_operands): Likewise.
(validate_optab_operands): Likewise.
(init_insn_for_nothing): Initialize idata and idata_end.
(note_constraint): Update after changes to constraint_data,
using at rather than with_line functions.
(mdep_constraint_len): Take a file_location rather than a
line number. Use at rather than with_line functions.
2015-07-16 Richard Sandiford <richard.sandiford@arm.com>
* read-md.h (fatal_at): Declare. * read-md.h (fatal_at): Declare.
* read-md.c (fatal_at): New function. * read-md.c (fatal_at): New function.
* genattrtab.c (insn_def, attr_desc, delay_desc): Use a file_location * genattrtab.c (insn_def, attr_desc, delay_desc): Use a file_location
......
...@@ -154,9 +154,8 @@ struct data ...@@ -154,9 +154,8 @@ struct data
struct data *next; struct data *next;
const char *name; const char *name;
const char *template_code; const char *template_code;
file_location loc;
int code_number; int code_number;
const char *filename;
int lineno;
int n_generator_args; /* Number of arguments passed to generator */ int n_generator_args; /* Number of arguments passed to generator */
int n_operands; /* Number of operands this insn recognizes */ int n_operands; /* Number of operands this insn recognizes */
int n_dups; /* Number times match_dup appears in pattern */ int n_dups; /* Number times match_dup appears in pattern */
...@@ -166,15 +165,12 @@ struct data ...@@ -166,15 +165,12 @@ struct data
struct operand_data operand[MAX_MAX_OPERANDS]; struct operand_data operand[MAX_MAX_OPERANDS];
}; };
/* A dummy insn, for CODE_FOR_nothing. */
static struct data nothing;
/* This variable points to the first link in the insn chain. */ /* This variable points to the first link in the insn chain. */
static struct data *idata = &nothing; static struct data *idata;
/* This variable points to the end of the insn chain. This is where /* This variable points to the end of the insn chain. This is where
everything relevant from the machien description is appended to. */ everything relevant from the machien description is appended to. */
static struct data **idata_end = &nothing.next; static struct data **idata_end;
static void output_prologue (void); static void output_prologue (void);
...@@ -196,9 +192,9 @@ static void gen_split (rtx, int); ...@@ -196,9 +192,9 @@ static void gen_split (rtx, int);
struct constraint_data struct constraint_data
{ {
struct constraint_data *next_this_letter; struct constraint_data *next_this_letter;
int lineno; file_location loc;
unsigned int namelen; unsigned int namelen;
const char name[1]; char name[1];
}; };
/* All machine-independent constraint characters (except digits) that /* All machine-independent constraint characters (except digits) that
...@@ -208,7 +204,7 @@ static const char indep_constraints[] = ",=+%*?!^$#&g"; ...@@ -208,7 +204,7 @@ static const char indep_constraints[] = ",=+%*?!^$#&g";
static struct constraint_data * static struct constraint_data *
constraints_by_letter_table[1 << CHAR_BIT]; constraints_by_letter_table[1 << CHAR_BIT];
static int mdep_constraint_len (const char *, int, int); static int mdep_constraint_len (const char *, file_location, int);
static void note_constraint (rtx, int); static void note_constraint (rtx, int);
static void static void
...@@ -306,7 +302,7 @@ output_insn_data (void) ...@@ -306,7 +302,7 @@ output_insn_data (void)
for (d = idata; d; d = d->next) for (d = idata; d; d = d->next)
{ {
printf (" /* %s:%d */\n", d->filename, d->lineno); printf (" /* %s:%d */\n", d->loc.filename, d->loc.lineno);
printf (" {\n"); printf (" {\n");
if (d->name) if (d->name)
...@@ -449,11 +445,11 @@ scan_operands (struct data *d, rtx part, int this_address_p, ...@@ -449,11 +445,11 @@ scan_operands (struct data *d, rtx part, int this_address_p,
opno = XINT (part, 0); opno = XINT (part, 0);
if (opno >= MAX_MAX_OPERANDS) if (opno >= MAX_MAX_OPERANDS)
{ {
error_with_line (d->lineno, "maximum number of operands exceeded"); error_at (d->loc, "maximum number of operands exceeded");
return; return;
} }
if (d->operand[opno].seen) if (d->operand[opno].seen)
error_with_line (d->lineno, "repeated operand number %d\n", opno); error_at (d->loc, "repeated operand number %d\n", opno);
d->operand[opno].seen = 1; d->operand[opno].seen = 1;
d->operand[opno].mode = GET_MODE (part); d->operand[opno].mode = GET_MODE (part);
...@@ -470,11 +466,11 @@ scan_operands (struct data *d, rtx part, int this_address_p, ...@@ -470,11 +466,11 @@ scan_operands (struct data *d, rtx part, int this_address_p,
opno = XINT (part, 0); opno = XINT (part, 0);
if (opno >= MAX_MAX_OPERANDS) if (opno >= MAX_MAX_OPERANDS)
{ {
error_with_line (d->lineno, "maximum number of operands exceeded"); error_at (d->loc, "maximum number of operands exceeded");
return; return;
} }
if (d->operand[opno].seen) if (d->operand[opno].seen)
error_with_line (d->lineno, "repeated operand number %d\n", opno); error_at (d->loc, "repeated operand number %d\n", opno);
d->operand[opno].seen = 1; d->operand[opno].seen = 1;
d->operand[opno].mode = GET_MODE (part); d->operand[opno].mode = GET_MODE (part);
...@@ -492,11 +488,11 @@ scan_operands (struct data *d, rtx part, int this_address_p, ...@@ -492,11 +488,11 @@ scan_operands (struct data *d, rtx part, int this_address_p,
opno = XINT (part, 0); opno = XINT (part, 0);
if (opno >= MAX_MAX_OPERANDS) if (opno >= MAX_MAX_OPERANDS)
{ {
error_with_line (d->lineno, "maximum number of operands exceeded"); error_at (d->loc, "maximum number of operands exceeded");
return; return;
} }
if (d->operand[opno].seen) if (d->operand[opno].seen)
error_with_line (d->lineno, "repeated operand number %d\n", opno); error_at (d->loc, "repeated operand number %d\n", opno);
d->operand[opno].seen = 1; d->operand[opno].seen = 1;
d->operand[opno].mode = GET_MODE (part); d->operand[opno].mode = GET_MODE (part);
...@@ -708,8 +704,7 @@ process_template (struct data *d, const char *template_code) ...@@ -708,8 +704,7 @@ process_template (struct data *d, const char *template_code)
sp = ep + 1; sp = ep + 1;
if (sp != ep) if (sp != ep)
message_with_line (d->lineno, message_at (d->loc, "trailing whitespace in output template");
"trailing whitespace in output template");
while (cp < sp) while (cp < sp)
{ {
...@@ -732,11 +727,11 @@ process_template (struct data *d, const char *template_code) ...@@ -732,11 +727,11 @@ process_template (struct data *d, const char *template_code)
i++; i++;
} }
if (i == 1) if (i == 1)
message_with_line (d->lineno, message_at (d->loc, "'@' is redundant for output template with"
"'@' is redundant for output template with single alternative"); " single alternative");
if (i != d->n_alternatives) if (i != d->n_alternatives)
error_with_line (d->lineno, error_at (d->loc, "wrong number of alternatives in the output"
"wrong number of alternatives in the output template"); " template");
if (found_star) if (found_star)
puts (" default: gcc_unreachable ();\n }\n}"); puts (" default: gcc_unreachable ();\n }\n}");
...@@ -773,9 +768,8 @@ validate_insn_alternatives (struct data *d) ...@@ -773,9 +768,8 @@ validate_insn_alternatives (struct data *d)
{ {
if ((c == '%' || c == '=' || c == '+') if ((c == '%' || c == '=' || c == '+')
&& p != d->operand[start].constraint) && p != d->operand[start].constraint)
error_with_line (d->lineno, error_at (d->loc, "character '%c' can only be used at the"
"character '%c' can only be used at the" " beginning of a constraint string", c);
" beginning of a constraint string", c);
if (c == '=' || c == '+') if (c == '=' || c == '+')
seen_write = true; seen_write = true;
...@@ -783,10 +777,8 @@ validate_insn_alternatives (struct data *d) ...@@ -783,10 +777,8 @@ validate_insn_alternatives (struct data *d)
/* Earlyclobber operands must always be marked write-only /* Earlyclobber operands must always be marked write-only
or read/write. */ or read/write. */
if (!seen_write && c == '&') if (!seen_write && c == '&')
error_with_line (d->lineno, error_at (d->loc, "earlyclobber operands may not be"
"earlyclobber operands may not be" " read-only in alternative %d", which_alternative);
" read-only in alternative %d",
which_alternative);
if (ISSPACE (c) || strchr (indep_constraints, c)) if (ISSPACE (c) || strchr (indep_constraints, c))
len = 1; len = 1;
...@@ -799,7 +791,7 @@ validate_insn_alternatives (struct data *d) ...@@ -799,7 +791,7 @@ validate_insn_alternatives (struct data *d)
len = q - p; len = q - p;
} }
else else
len = mdep_constraint_len (p, d->lineno, start); len = mdep_constraint_len (p, d->loc, start);
if (c == ',') if (c == ',')
{ {
...@@ -810,17 +802,15 @@ validate_insn_alternatives (struct data *d) ...@@ -810,17 +802,15 @@ validate_insn_alternatives (struct data *d)
for (i = 1; i < len; i++) for (i = 1; i < len; i++)
if (p[i] == '\0') if (p[i] == '\0')
{ {
error_with_line (d->lineno, error_at (d->loc, "NUL in alternative %d of operand %d",
"NUL in alternative %d of operand %d", which_alternative, start);
which_alternative, start);
alternative_count_unsure = 1; alternative_count_unsure = 1;
break; break;
} }
else if (strchr (",#*", p[i])) else if (strchr (",#*", p[i]))
{ {
error_with_line (d->lineno, error_at (d->loc, "'%c' in alternative %d of operand %d",
"'%c' in alternative %d of operand %d", p[i], which_alternative, start);
p[i], which_alternative, start);
alternative_count_unsure = 1; alternative_count_unsure = 1;
} }
} }
...@@ -829,9 +819,8 @@ validate_insn_alternatives (struct data *d) ...@@ -829,9 +819,8 @@ validate_insn_alternatives (struct data *d)
if (n == 0) if (n == 0)
n = d->operand[start].n_alternatives; n = d->operand[start].n_alternatives;
else if (n != d->operand[start].n_alternatives) else if (n != d->operand[start].n_alternatives)
error_with_line (d->lineno, error_at (d->loc, "wrong number of alternatives in operand %d",
"wrong number of alternatives in operand %d", start);
start);
} }
} }
...@@ -848,7 +837,7 @@ validate_insn_operands (struct data *d) ...@@ -848,7 +837,7 @@ validate_insn_operands (struct data *d)
for (i = 0; i < d->n_operands; ++i) for (i = 0; i < d->n_operands; ++i)
if (d->operand[i].seen == 0) if (d->operand[i].seen == 0)
error_with_line (d->lineno, "missing operand %d", i); error_at (d->loc, "missing operand %d", i);
} }
static void static void
...@@ -862,7 +851,7 @@ validate_optab_operands (struct data *d) ...@@ -862,7 +851,7 @@ validate_optab_operands (struct data *d)
&& d->name[strlen (d->name) - 1] == '4' && d->name[strlen (d->name) - 1] == '4'
&& d->operand[0].mode == VOIDmode) && d->operand[0].mode == VOIDmode)
{ {
message_with_line (d->lineno, "missing mode for operand 0 of cstore"); message_at (d->loc, "missing mode for operand 0 of cstore");
have_error = 1; have_error = 1;
} }
} }
...@@ -875,12 +864,11 @@ static void ...@@ -875,12 +864,11 @@ static void
gen_insn (rtx insn, int lineno) gen_insn (rtx insn, int lineno)
{ {
struct pattern_stats stats; struct pattern_stats stats;
struct data *d = XNEW (struct data); data *d = new data;
int i; int i;
d->code_number = next_code_number; d->code_number = next_code_number;
d->filename = read_md_filename; d->loc = file_location (read_md_filename, lineno);
d->lineno = lineno;
if (XSTR (insn, 0)[0]) if (XSTR (insn, 0)[0])
d->name = XSTR (insn, 0); d->name = XSTR (insn, 0);
else else
...@@ -917,12 +905,11 @@ static void ...@@ -917,12 +905,11 @@ static void
gen_peephole (rtx peep, int lineno) gen_peephole (rtx peep, int lineno)
{ {
struct pattern_stats stats; struct pattern_stats stats;
struct data *d = XNEW (struct data); data *d = new data;
int i; int i;
d->code_number = next_code_number; d->code_number = next_code_number;
d->filename = read_md_filename; d->loc = file_location (read_md_filename, lineno);
d->lineno = lineno;
d->name = 0; d->name = 0;
/* Build up the list in the same order as the insns are seen /* Build up the list in the same order as the insns are seen
...@@ -956,12 +943,11 @@ static void ...@@ -956,12 +943,11 @@ static void
gen_expand (rtx insn, int lineno) gen_expand (rtx insn, int lineno)
{ {
struct pattern_stats stats; struct pattern_stats stats;
struct data *d = XNEW (struct data); data *d = new data;
int i; int i;
d->code_number = next_code_number; d->code_number = next_code_number;
d->filename = read_md_filename; d->loc = file_location (read_md_filename, lineno);
d->lineno = lineno;
if (XSTR (insn, 0)[0]) if (XSTR (insn, 0)[0])
d->name = XSTR (insn, 0); d->name = XSTR (insn, 0);
else else
...@@ -1001,12 +987,11 @@ static void ...@@ -1001,12 +987,11 @@ static void
gen_split (rtx split, int lineno) gen_split (rtx split, int lineno)
{ {
struct pattern_stats stats; struct pattern_stats stats;
struct data *d = XNEW (struct data); data *d = new data;
int i; int i;
d->code_number = next_code_number; d->code_number = next_code_number;
d->filename = read_md_filename; d->loc = file_location (read_md_filename, lineno);
d->lineno = lineno;
d->name = 0; d->name = 0;
/* Build up the list in the same order as the insns are seen /* Build up the list in the same order as the insns are seen
...@@ -1037,9 +1022,11 @@ gen_split (rtx split, int lineno) ...@@ -1037,9 +1022,11 @@ gen_split (rtx split, int lineno)
static void static void
init_insn_for_nothing (void) init_insn_for_nothing (void)
{ {
memset (&nothing, 0, sizeof (nothing)); idata = XCNEW (struct data);
nothing.name = "*placeholder_for_nothing"; new (idata) data ();
nothing.filename = "<internal>"; idata->name = "*placeholder_for_nothing";
idata->loc = file_location ("<internal>", 0);
idata_end = &idata->next;
} }
extern int main (int, char **); extern int main (int, char **);
...@@ -1189,28 +1176,30 @@ note_constraint (rtx exp, int lineno) ...@@ -1189,28 +1176,30 @@ note_constraint (rtx exp, int lineno)
if (!strcmp ((*iter)->name, name)) if (!strcmp ((*iter)->name, name))
{ {
error_with_line (lineno, "redefinition of constraint '%s'", name); error_with_line (lineno, "redefinition of constraint '%s'", name);
message_with_line ((*iter)->lineno, "previous definition is here"); message_at ((*iter)->loc, "previous definition is here");
return; return;
} }
else if (!strncmp ((*iter)->name, name, (*iter)->namelen)) else if (!strncmp ((*iter)->name, name, (*iter)->namelen))
{ {
error_with_line (lineno, "defining constraint '%s' here", name); error_with_line (lineno, "defining constraint '%s' here", name);
message_with_line ((*iter)->lineno, "renders constraint '%s' " message_at ((*iter)->loc, "renders constraint '%s' "
"(defined here) a prefix", (*iter)->name); "(defined here) a prefix", (*iter)->name);
return; return;
} }
else if (!strncmp ((*iter)->name, name, namelen)) else if (!strncmp ((*iter)->name, name, namelen))
{ {
error_with_line (lineno, "constraint '%s' is a prefix", name); error_with_line (lineno, "constraint '%s' is a prefix", name);
message_with_line ((*iter)->lineno, "of constraint '%s' " message_at ((*iter)->loc, "of constraint '%s' "
"(defined here)", (*iter)->name); "(defined here)", (*iter)->name);
return; return;
} }
} }
new_cdata = XNEWVAR (struct constraint_data, sizeof (struct constraint_data) + namelen); new_cdata = XNEWVAR (struct constraint_data,
sizeof (struct constraint_data) + namelen);
new (new_cdata) constraint_data ();
strcpy (CONST_CAST (char *, new_cdata->name), name); strcpy (CONST_CAST (char *, new_cdata->name), name);
new_cdata->namelen = namelen; new_cdata->namelen = namelen;
new_cdata->lineno = lineno; new_cdata->loc = file_location (read_md_filename, lineno);
new_cdata->next_this_letter = *slot; new_cdata->next_this_letter = *slot;
*slot = new_cdata; *slot = new_cdata;
} }
...@@ -1220,7 +1209,7 @@ note_constraint (rtx exp, int lineno) ...@@ -1220,7 +1209,7 @@ note_constraint (rtx exp, int lineno)
is no such constraint. Does not expect to be called for generic is no such constraint. Does not expect to be called for generic
constraints. */ constraints. */
static int static int
mdep_constraint_len (const char *s, int lineno, int opno) mdep_constraint_len (const char *s, file_location loc, int opno)
{ {
struct constraint_data *p; struct constraint_data *p;
...@@ -1231,9 +1220,8 @@ mdep_constraint_len (const char *s, int lineno, int opno) ...@@ -1231,9 +1220,8 @@ mdep_constraint_len (const char *s, int lineno, int opno)
if (!strncmp (s, p->name, p->namelen)) if (!strncmp (s, p->name, p->namelen))
return p->namelen; return p->namelen;
error_with_line (lineno, error_at (loc, "error: undefined machine-specific constraint "
"error: undefined machine-specific constraint " "at this point: \"%s\"", s);
"at this point: \"%s\"", s); message_at (loc, "note: in operand %d", opno);
message_with_line (lineno, "note: in operand %d", opno);
return 1; /* safe */ return 1; /* safe */
} }
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