aboutsummaryrefslogtreecommitdiff
path: root/gcc/genoutput.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2015-07-16 13:52:22 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2015-07-16 13:52:22 +0000
commit5d2d3e43b917f87ce4e8378076888dd03e4c7cc2 (patch)
tree9d8586f4a5e07a89b18a2e4fb2c2f801fafb90b8 /gcc/genoutput.c
parentc9f84f2e1d697a8d6a6e696bd26933ca4a858da0 (diff)
downloadgcc-5d2d3e43b917f87ce4e8378076888dd03e4c7cc2.zip
gcc-5d2d3e43b917f87ce4e8378076888dd03e4c7cc2.tar.gz
gcc-5d2d3e43b917f87ce4e8378076888dd03e4c7cc2.tar.bz2
read-md.h (message_with_line, [...]): Delete.
gcc/ * read-md.h (message_with_line, error_with_line): Delete. * read-md.c (message_with_line, error_with_line): Delete. * gensupport.h: Include read-md.h. (md_rtx_info): New structure. (read_md_rtx): Use it. Return a bool success value. * gensupport.c (read_md_rtx): Likewise. * genattr-common.c (gen_attr): Take an md_rtx_info rather than an rtx. (main): Update after interface changes. * genattr.c (gen_attr): Take an md_rtx_info rather than an rtx. (main): Update after interface changes. * genattrtab.c (insn_code_number): Delete. (optimize_attrs): Add a max_insn_code parameter and use it instead of insn_code_number. (gen_attr): Take an md_rtx_info rather than an rtx and lineno. Use *_at rather than *_with_line functions. (gen_insn): Likewise. (gen_delay): Likewise. (gen_insn_reserv): Likewise. (gen_bypass): Take an md_rtx_info rather than an rtx. (main): Update after interface changes. Use a local max_insn_code variable instead of insn_code_number. * genautomata.c (gen_cpu_unit): Take an md_rtx_info rather than an rtx. Use fatal_at rather than fatal. (gen_query_cpu_unit, gen_bypass, gen_excl_set) (gen_presence_absence_set, gen_presence_set, gen_final_presence_set) (gen_absence_set, gen_final_absence_set, gen_automaton) (gen_automata_option, gen_reserv, gen_insn_reserv): Likewise. (main): Update after interface changes. * gencodes.c (gen_insn): Take an md_rtx_info rather than an rtx and code number. (main): Update after interface changes. * genconditions.c (main): Use new read_md_rtx interface. * genconfig.c (gen_insn): Take an md_rtx_info rather than an rtx. (gen_expand, gen_split, gen_peephole, gen_peephole2): Likewise. (main): Update after interface changes. * genemit.c (insn_code_number, insn_index_number): Delete. (gen_insn): Take an md_rtx_info rather than an rtx and lineno. Use fatal_at rather than fatal. (gen_expand): Take an md_rtx_info rather than an rtx. Use fatal_at rather than fatal. (gen_split): Likewise. (main): Update after interface changes. * genextract.c (line_no): Delete. (gen_insn): Take an md_rtx_info rather than an rtx and lineno. Update call to walk_rtx. (VEC_safe_set_locstr): Add an md_rtx_info argument. Use message_at rather than message_with_line. (walk_rtx): Add an md_rtx_info argument. Update call to VEC_safe_set_locstr. (main): Update after interface changes. * genflags.c (gen_insn): Take an md_rtx_info rather than an rtx and lineno. Use error_at rather than separate message_with_line calls and have_error assignments. (main): Update after interface changes. * genmddump.c (main): Use new read_md_rtx interface. * genopinit.c (insn): Take an md_rtx_info rather than an rtx. (main): Update after interface changes. * genoutput.c (next_code_number): Delete. (gen_insn): Take an md_rtx_info rather than an rtx and lineno. (gen_peephole, gen_expand, gen_split): Likewise. (note_constraint): Likewise. Use *_at rather than *_with_line functions. (main): Update after interface changes. * genpeep.c (gen_peephole): Take an md_rtx_info rather than an rtx and lineno. (main): Update after interface changes. * genpreds.c (process_define_predicate): Take an md_rtx_info rather than an rtx and lineno. (process_define_constraint): Likewise. (process_define_register_constraint): Likewise. (main): Update after interface changes. * genrecog.c (next_insn_code, pattern_lineno): Delete. (validate_pattern): Replace top-level rtx with an md_rtx_info. Use *_at rather than *_with_line functions. (match_pattern_2): Likewise. (match_pattern_1, match_pattern): Add an md_rtx_info parameter. (get_peephole2_pattern): Take an md_rtx_info rather than an rtvec. Use *_at rather than *_with_line functions. * gentarget-def.c (add_insn): New function. (main): Use it. Use new read_md_rtx interface. From-SVN: r225883
Diffstat (limited to 'gcc/genoutput.c')
-rw-r--r--gcc/genoutput.c130
1 files changed, 57 insertions, 73 deletions
diff --git a/gcc/genoutput.c b/gcc/genoutput.c
index 46ad602..cd7f129 100644
--- a/gcc/genoutput.c
+++ b/gcc/genoutput.c
@@ -103,12 +103,6 @@ static char general_mem[] = { TARGET_MEM_CONSTRAINT, 0 };
static int n_occurrences (int, const char *);
static const char *strip_whitespace (const char *);
-/* insns in the machine description are assigned sequential code numbers
- that are used by insn-recog.c (produced by genrecog) to communicate
- to insn-output.c (produced by this program). */
-
-static int next_code_number;
-
/* This counts all operands used in the md file. The first is null. */
static int next_operand_number = 1;
@@ -184,10 +178,6 @@ static void place_operands (struct data *);
static void process_template (struct data *, const char *);
static void validate_insn_alternatives (struct data *);
static void validate_insn_operands (struct data *);
-static void gen_insn (rtx, int);
-static void gen_peephole (rtx, int);
-static void gen_expand (rtx, int);
-static void gen_split (rtx, int);
struct constraint_data
{
@@ -205,7 +195,7 @@ static struct constraint_data *
constraints_by_letter_table[1 << CHAR_BIT];
static int mdep_constraint_len (const char *, file_location, int);
-static void note_constraint (rtx, int);
+static void note_constraint (md_rtx_info *);
static void
output_prologue (void)
@@ -861,14 +851,15 @@ validate_optab_operands (struct data *d)
a hairy output action, output a function for now. */
static void
-gen_insn (rtx insn, int lineno)
+gen_insn (md_rtx_info *info)
{
struct pattern_stats stats;
+ rtx insn = info->def;
data *d = new data;
int i;
- d->code_number = next_code_number;
- d->loc = file_location (read_md_filename, lineno);
+ d->code_number = info->index;
+ d->loc = info->loc;
if (XSTR (insn, 0)[0])
d->name = XSTR (insn, 0);
else
@@ -902,14 +893,14 @@ gen_insn (rtx insn, int lineno)
If the insn has a hairy output action, output it now. */
static void
-gen_peephole (rtx peep, int lineno)
+gen_peephole (md_rtx_info *info)
{
struct pattern_stats stats;
data *d = new data;
int i;
- d->code_number = next_code_number;
- d->loc = file_location (read_md_filename, lineno);
+ d->code_number = info->index;
+ d->loc = info->loc;
d->name = 0;
/* Build up the list in the same order as the insns are seen
@@ -923,6 +914,7 @@ gen_peephole (rtx peep, int lineno)
/* Get the number of operands by scanning all the patterns of the
peephole optimizer. But ignore all the rest of the information
thus obtained. */
+ rtx peep = info->def;
for (i = 0; i < XVECLEN (peep, 0); i++)
scan_operands (d, XVECEXP (peep, 0, i), 0, 0);
@@ -940,14 +932,15 @@ gen_peephole (rtx peep, int lineno)
only for the purposes of `insn_gen_function'. */
static void
-gen_expand (rtx insn, int lineno)
+gen_expand (md_rtx_info *info)
{
struct pattern_stats stats;
+ rtx insn = info->def;
data *d = new data;
int i;
- d->code_number = next_code_number;
- d->loc = file_location (read_md_filename, lineno);
+ d->code_number = info->index;
+ d->loc = info->loc;
if (XSTR (insn, 0)[0])
d->name = XSTR (insn, 0);
else
@@ -984,14 +977,14 @@ gen_expand (rtx insn, int lineno)
only for reasons of consistency and to simplify genrecog. */
static void
-gen_split (rtx split, int lineno)
+gen_split (md_rtx_info *info)
{
struct pattern_stats stats;
data *d = new data;
int i;
- d->code_number = next_code_number;
- d->loc = file_location (read_md_filename, lineno);
+ d->code_number = info->index;
+ d->loc = info->loc;
d->name = 0;
/* Build up the list in the same order as the insns are seen
@@ -1005,6 +998,7 @@ gen_split (rtx split, int lineno)
/* Get the number of operands by scanning all the patterns of the
split patterns. But ignore all the rest of the information thus
obtained. */
+ rtx split = info->def;
for (i = 0; i < XVECLEN (split, 0); i++)
scan_operands (d, XVECEXP (split, 0, i), 0, 0);
@@ -1034,8 +1028,6 @@ extern int main (int, char **);
int
main (int argc, char **argv)
{
- rtx desc;
-
progname = "genoutput";
init_insn_for_nothing ();
@@ -1047,44 +1039,37 @@ main (int argc, char **argv)
/* Read the machine description. */
- while (1)
- {
- int line_no;
-
- desc = read_md_rtx (&line_no, &next_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;
- switch (GET_CODE (desc))
- {
- case DEFINE_INSN:
- gen_insn (desc, line_no);
- break;
-
- case DEFINE_PEEPHOLE:
- gen_peephole (desc, line_no);
- break;
+ case DEFINE_PEEPHOLE:
+ gen_peephole (&info);
+ break;
- case DEFINE_EXPAND:
- gen_expand (desc, line_no);
- break;
+ case DEFINE_EXPAND:
+ gen_expand (&info);
+ break;
- case DEFINE_SPLIT:
- case DEFINE_PEEPHOLE2:
- gen_split (desc, line_no);
- break;
+ case DEFINE_SPLIT:
+ case DEFINE_PEEPHOLE2:
+ gen_split (&info);
+ break;
- case DEFINE_CONSTRAINT:
- case DEFINE_REGISTER_CONSTRAINT:
- case DEFINE_ADDRESS_CONSTRAINT:
- case DEFINE_MEMORY_CONSTRAINT:
- note_constraint (desc, line_no);
- break;
+ case DEFINE_CONSTRAINT:
+ case DEFINE_REGISTER_CONSTRAINT:
+ case DEFINE_ADDRESS_CONSTRAINT:
+ case DEFINE_MEMORY_CONSTRAINT:
+ note_constraint (&info);
+ break;
- default:
- break;
- }
- }
+ default:
+ break;
+ }
printf ("\n\n");
output_operand_data ();
@@ -1134,15 +1119,14 @@ strip_whitespace (const char *s)
return q;
}
-/* Record just enough information about a constraint to allow checking
- of operand constraint strings above, in validate_insn_alternatives.
- Does not validate most properties of the constraint itself; does
- enforce no duplicate names, no overlap with MI constraints, and no
- prefixes. EXP is the define_*constraint form, LINENO the line number
- reported by the reader. */
+/* Record just enough information about the constraint in *INFO to allow
+ checking of operand constraint strings above, in validate_insn_alternatives.
+ Does not validate most properties of the constraint itself; does enforce
+ no duplicate names, no overlap with MI constraints, and no prefixes. */
static void
-note_constraint (rtx exp, int lineno)
+note_constraint (md_rtx_info *info)
{
+ rtx exp = info->def;
const char *name = XSTR (exp, 0);
struct constraint_data **iter, **slot, *new_cdata;
@@ -1153,12 +1137,12 @@ note_constraint (rtx exp, int lineno)
if (strchr (indep_constraints, name[0]))
{
if (name[1] == '\0')
- error_with_line (lineno, "constraint letter '%s' cannot be "
- "redefined by the machine description", name);
+ error_at (info->loc, "constraint letter '%s' cannot be "
+ "redefined by the machine description", name);
else
- error_with_line (lineno, "constraint name '%s' cannot be defined by "
- "the machine description, as it begins with '%c'",
- name, name[0]);
+ error_at (info->loc, "constraint name '%s' cannot be defined by "
+ "the machine description, as it begins with '%c'",
+ name, name[0]);
return;
}
@@ -1175,20 +1159,20 @@ note_constraint (rtx exp, int lineno)
if (!strcmp ((*iter)->name, name))
{
- error_with_line (lineno, "redefinition of constraint '%s'", name);
+ error_at (info->loc, "redefinition of constraint '%s'", name);
message_at ((*iter)->loc, "previous definition is here");
return;
}
else if (!strncmp ((*iter)->name, name, (*iter)->namelen))
{
- error_with_line (lineno, "defining constraint '%s' here", name);
+ error_at (info->loc, "defining constraint '%s' here", name);
message_at ((*iter)->loc, "renders constraint '%s' "
"(defined here) a prefix", (*iter)->name);
return;
}
else if (!strncmp ((*iter)->name, name, namelen))
{
- error_with_line (lineno, "constraint '%s' is a prefix", name);
+ error_at (info->loc, "constraint '%s' is a prefix", name);
message_at ((*iter)->loc, "of constraint '%s' "
"(defined here)", (*iter)->name);
return;
@@ -1199,7 +1183,7 @@ note_constraint (rtx exp, int lineno)
new (new_cdata) constraint_data ();
strcpy (CONST_CAST (char *, new_cdata->name), name);
new_cdata->namelen = namelen;
- new_cdata->loc = file_location (read_md_filename, lineno);
+ new_cdata->loc = info->loc;
new_cdata->next_this_letter = *slot;
*slot = new_cdata;
}