From 5d2d3e43b917f87ce4e8378076888dd03e4c7cc2 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Thu, 16 Jul 2015 13:52:22 +0000 Subject: 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 --- gcc/genextract.c | 56 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 25 deletions(-) (limited to 'gcc/genextract.c') diff --git a/gcc/genextract.c b/gcc/genextract.c index becd8ef..fe97701 100644 --- a/gcc/genextract.c +++ b/gcc/genextract.c @@ -75,13 +75,11 @@ struct accum_extract vec pathstr; }; -int line_no; - /* Forward declarations. */ -static void walk_rtx (rtx, struct accum_extract *); +static void walk_rtx (md_rtx_info *, rtx, struct accum_extract *); static void -gen_insn (rtx insn, int insn_code_number) +gen_insn (md_rtx_info *info) { int i; unsigned int op_count, dup_count, j; @@ -97,18 +95,19 @@ gen_insn (rtx insn, int insn_code_number) /* Walk the insn's pattern, remembering at all times the path down to the walking point. */ + rtx insn = info->def; if (XVECLEN (insn, 1) == 1) - walk_rtx (XVECEXP (insn, 1, 0), &acc); + walk_rtx (info, XVECEXP (insn, 1, 0), &acc); else for (i = XVECLEN (insn, 1) - 1; i >= 0; i--) { acc.pathstr.safe_push ('a' + i); - walk_rtx (XVECEXP (insn, 1, i), &acc); + walk_rtx (info, XVECEXP (insn, 1, i), &acc); acc.pathstr.pop (); } link = XNEW (struct code_ptr); - link->insn_code = insn_code_number; + link->insn_code = info->index; /* See if we find something that already had this extraction method. */ @@ -178,15 +177,17 @@ gen_insn (rtx insn, int insn_code_number) /* Helper subroutine of walk_rtx: given a vec, an index, and a string, insert the string at the index, which should either already exist and be NULL, or not yet exist within the vector. In the latter - case the vector is enlarged as appropriate. */ + case the vector is enlarged as appropriate. INFO describes the + containing define_* expression. */ static void -VEC_safe_set_locstr (vec *vp, unsigned int ix, char *str) +VEC_safe_set_locstr (md_rtx_info *info, vec *vp, + unsigned int ix, char *str) { if (ix < (*vp).length ()) { if ((*vp)[ix]) { - message_with_line (line_no, "repeated operand number %d", ix); + message_at (info->loc, "repeated operand number %d", ix); have_error = 1; } else @@ -213,7 +214,7 @@ VEC_char_to_string (vec v) } static void -walk_rtx (rtx x, struct accum_extract *acc) +walk_rtx (md_rtx_info *info, rtx x, struct accum_extract *acc) { RTX_CODE code; int i, len, base; @@ -233,20 +234,20 @@ walk_rtx (rtx x, struct accum_extract *acc) case MATCH_OPERAND: case MATCH_SCRATCH: - VEC_safe_set_locstr (&acc->oplocs, XINT (x, 0), + VEC_safe_set_locstr (info, &acc->oplocs, XINT (x, 0), VEC_char_to_string (acc->pathstr)); break; case MATCH_OPERATOR: case MATCH_PARALLEL: - VEC_safe_set_locstr (&acc->oplocs, XINT (x, 0), + VEC_safe_set_locstr (info, &acc->oplocs, XINT (x, 0), VEC_char_to_string (acc->pathstr)); base = (code == MATCH_OPERATOR ? '0' : 'a'); for (i = XVECLEN (x, 2) - 1; i >= 0; i--) { acc->pathstr.safe_push (base + i); - walk_rtx (XVECEXP (x, 2, i), acc); + walk_rtx (info, XVECEXP (x, 2, i), acc); acc->pathstr.pop (); } return; @@ -264,7 +265,7 @@ walk_rtx (rtx x, struct accum_extract *acc) for (i = XVECLEN (x, 1) - 1; i >= 0; i--) { acc->pathstr.safe_push (base + i); - walk_rtx (XVECEXP (x, 1, i), acc); + walk_rtx (info, XVECEXP (x, 1, i), acc); acc->pathstr.pop (); } return; @@ -280,7 +281,7 @@ walk_rtx (rtx x, struct accum_extract *acc) if (fmt[i] == 'e' || fmt[i] == 'u') { acc->pathstr.safe_push ('0' + i); - walk_rtx (XEXP (x, i), acc); + walk_rtx (info, XEXP (x, i), acc); acc->pathstr.pop (); } else if (fmt[i] == 'E') @@ -289,7 +290,7 @@ walk_rtx (rtx x, struct accum_extract *acc) for (j = XVECLEN (x, i) - 1; j >= 0; j--) { acc->pathstr.safe_push ('a' + j); - walk_rtx (XVECEXP (x, i, j), acc); + walk_rtx (info, XVECEXP (x, i, j), acc); acc->pathstr.pop (); } } @@ -394,12 +395,10 @@ insn_extract (rtx_insn *insn)\n{\n\ int main (int argc, char **argv) { - rtx desc; unsigned int i; struct extraction *p; struct code_ptr *link; const char *name; - int insn_code_number; progname = "genextract"; @@ -408,19 +407,26 @@ main (int argc, char **argv) /* Read the machine description. */ - while ((desc = read_md_rtx (&line_no, &insn_code_number)) != NULL) - { - if (GET_CODE (desc) == DEFINE_INSN) - gen_insn (desc, insn_code_number); + md_rtx_info info; + while (read_md_rtx (&info)) + switch (GET_CODE (info.def)) + { + case DEFINE_INSN: + gen_insn (&info); + break; - else if (GET_CODE (desc) == DEFINE_PEEPHOLE) + case DEFINE_PEEPHOLE: { struct code_ptr *link = XNEW (struct code_ptr); - link->insn_code = insn_code_number; + link->insn_code = info.index; link->next = peepholes; peepholes = link; } + break; + + default: + break; } if (have_error) -- cgit v1.1