X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=gcc%2Fgenautomata.c;h=e39d32727a9564ffd27d5f9074f9761b99b5f9d2;hb=29f9683a5f2242786773eaa8f066001a39f18c82;hp=bafb2553cdef3eb4f70580ea50a8b70c52c99262;hpb=7492620dc25a8cef1b7ef7427bcf41e09678e797;p=pf3gnuchains%2Fgcc-fork.git diff --git a/gcc/genautomata.c b/gcc/genautomata.c index bafb2553cde..e39d32727a9 100644 --- a/gcc/genautomata.c +++ b/gcc/genautomata.c @@ -1,5 +1,6 @@ /* Pipeline hazard description translator. - Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 + Free Software Foundation, Inc. Written by Vladimir Makarov @@ -17,8 +18,8 @@ for more details. You should have received a copy of the GNU General Public License along with GCC; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. */ +Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301, USA. */ /* References: @@ -658,6 +659,8 @@ static struct obstack irp; #define NDFA_OPTION "-ndfa" +#define PROGRESS_OPTION "-progress" + /* The following flags are set up by function `initiate_automaton_gen'. */ /* Make automata with nondeterministic reservation by insns (`-ndfa'). */ @@ -680,6 +683,10 @@ static int time_flag; result automaton and statistics information (`-v'). */ static int v_flag; +/* Flag of output of a progress bar showing how many states were + generated so far for automaton being processed (`-progress'). */ +static int progress_flag; + /* Flag of generating warning instead of error for non-critical errors (`-w'). */ static int w_flag; @@ -1203,7 +1210,7 @@ struct ainsn ainsn_t next_equiv_class_insn; /* The following field value is nonzero if the insn declaration is the first insn declaration with given equivalence number. */ - char first_ainsn_with_given_equialence_num; + char first_ainsn_with_given_equivalence_num; /* The following field is number of class of equivalence of insns. It is necessary because many insns may be equivalent with the point of view of pipeline hazards. */ @@ -1350,7 +1357,8 @@ struct state_ainsn_table static const char *decl_name (enum decl_mode); static void decl_mode_check_failed (enum decl_mode, const char *, - const char *, int, const char *); + const char *, int, const char *) + ATTRIBUTE_NORETURN; /* Return string representation of declaration mode MODE. */ static const char * @@ -1438,32 +1446,32 @@ decl_mode_check_failed (enum decl_mode mode, const char *expected_mode_str, static const char *regexp_name (enum regexp_mode); static void regexp_mode_check_failed (enum regexp_mode, const char *, const char *, int, - const char *); + const char *) ATTRIBUTE_NORETURN; /* Return string representation of regexp mode MODE. */ static const char * regexp_name (enum regexp_mode mode) { - static char str [100]; - - if (mode == rm_unit) - return "rm_unit"; - else if (mode == rm_reserv) - return "rm_reserv"; - else if (mode == rm_nothing) - return "rm_nothing"; - else if (mode == rm_sequence) - return "rm_sequence"; - else if (mode == rm_repeat) - return "rm_repeat"; - else if (mode == rm_allof) - return "rm_allof"; - else if (mode == rm_oneof) - return "rm_oneof"; - else - sprintf (str, "unknown (%d)", (int) mode); - return str; + switch (mode) + { + case rm_unit: + return "rm_unit"; + case rm_reserv: + return "rm_reserv"; + case rm_nothing: + return "rm_nothing"; + case rm_sequence: + return "rm_sequence"; + case rm_repeat: + return "rm_repeat"; + case rm_allof: + return "rm_allof"; + case rm_oneof: + return "rm_oneof"; + default: + gcc_unreachable (); + } } /* The function prints message about unexpected regexp and finish the @@ -1623,6 +1631,7 @@ get_str_vect (char *str, int *els_num, int sep, int paren_p) int i; char **vect; char **pstr; + char *trail; *els_num = n_sep_els (str, sep, paren_p); if (*els_num <= 0) @@ -1633,8 +1642,8 @@ get_str_vect (char *str, int *els_num, int sep, int paren_p) pstr = &str; for (i = 0; i < *els_num; i++) vect [i] = next_sep_el (pstr, sep, paren_p); - if (next_sep_el (pstr, sep, paren_p) != NULL) - abort (); + trail = next_sep_el (pstr, sep, paren_p); + gcc_assert (!trail); vect [i] = NULL; return vect; } @@ -1816,8 +1825,7 @@ gen_presence_absence_set (rtx def, int presence_p, int final_p) { str_patterns [i] = get_str_vect ((char *) str_patterns [i], &length, ' ', FALSE); - if (str_patterns [i] == NULL) - abort (); + gcc_assert (str_patterns [i]); } decl = create_node (sizeof (struct decl)); decl->pos = 0; @@ -1922,16 +1930,18 @@ gen_automaton (rtx def) void gen_automata_option (rtx def) { - if (strcmp ((char *) XSTR (def, 0), NO_MINIMIZATION_OPTION + 1) == 0) + if (strcmp (XSTR (def, 0), NO_MINIMIZATION_OPTION + 1) == 0) no_minimization_flag = 1; - else if (strcmp ((char *) XSTR (def, 0), TIME_OPTION + 1) == 0) + else if (strcmp (XSTR (def, 0), TIME_OPTION + 1) == 0) time_flag = 1; - else if (strcmp ((char *) XSTR (def, 0), V_OPTION + 1) == 0) + else if (strcmp (XSTR (def, 0), V_OPTION + 1) == 0) v_flag = 1; - else if (strcmp ((char *) XSTR (def, 0), W_OPTION + 1) == 0) + else if (strcmp (XSTR (def, 0), W_OPTION + 1) == 0) w_flag = 1; - else if (strcmp ((char *) XSTR (def, 0), NDFA_OPTION + 1) == 0) + else if (strcmp (XSTR (def, 0), NDFA_OPTION + 1) == 0) ndfa_flag = 1; + else if (strcmp (XSTR (def, 0), PROGRESS_OPTION + 1) == 0) + progress_flag = 1; else fatal ("invalid option `%s' in automata_option", XSTR (def, 0)); } @@ -2159,8 +2169,8 @@ automaton_decl_hash (const void *automaton_decl) { const decl_t decl = (decl_t) automaton_decl; - if (decl->mode == dm_automaton && DECL_AUTOMATON (decl)->name == NULL) - abort (); + gcc_assert (decl->mode != dm_automaton + || DECL_AUTOMATON (decl)->name); return string_hash (DECL_AUTOMATON (decl)->name); } @@ -2175,9 +2185,10 @@ automaton_decl_eq_p (const void* automaton_decl_1, const decl_t decl1 = (decl_t) automaton_decl_1; const decl_t decl2 = (decl_t) automaton_decl_2; - if (decl1->mode != dm_automaton || DECL_AUTOMATON (decl1)->name == NULL - || decl2->mode != dm_automaton || DECL_AUTOMATON (decl2)->name == NULL) - abort (); + gcc_assert (decl1->mode == dm_automaton + && DECL_AUTOMATON (decl1)->name + && decl2->mode == dm_automaton + && DECL_AUTOMATON (decl2)->name); return strcmp (DECL_AUTOMATON (decl1)->name, DECL_AUTOMATON (decl2)->name) == 0; } @@ -2259,8 +2270,8 @@ insn_decl_hash (const void *insn_decl) { const decl_t decl = (decl_t) insn_decl; - if (decl->mode != dm_insn_reserv || DECL_INSN_RESERV (decl)->name == NULL) - abort (); + gcc_assert (decl->mode == dm_insn_reserv + && DECL_INSN_RESERV (decl)->name); return string_hash (DECL_INSN_RESERV (decl)->name); } @@ -2273,10 +2284,10 @@ insn_decl_eq_p (const void *insn_decl_1, const void *insn_decl_2) const decl_t decl1 = (decl_t) insn_decl_1; const decl_t decl2 = (decl_t) insn_decl_2; - if (decl1->mode != dm_insn_reserv || DECL_INSN_RESERV (decl1)->name == NULL - || decl2->mode != dm_insn_reserv - || DECL_INSN_RESERV (decl2)->name == NULL) - abort (); + gcc_assert (decl1->mode == dm_insn_reserv + && DECL_INSN_RESERV (decl1)->name + && decl2->mode == dm_insn_reserv + && DECL_INSN_RESERV (decl2)->name); return strcmp (DECL_INSN_RESERV (decl1)->name, DECL_INSN_RESERV (decl2)->name) == 0; } @@ -2357,15 +2368,14 @@ decl_hash (const void *decl) { const decl_t d = (const decl_t) decl; - if ((d->mode != dm_unit || DECL_UNIT (d)->name == NULL) - && (d->mode != dm_reserv || DECL_RESERV (d)->name == NULL)) - abort (); + gcc_assert ((d->mode == dm_unit && DECL_UNIT (d)->name) + || (d->mode == dm_reserv && DECL_RESERV (d)->name)); return string_hash (d->mode == dm_unit ? DECL_UNIT (d)->name : DECL_RESERV (d)->name); } /* The function tests declarations on equality of their keys. The - function is used by abstract data `hashtab'. The function + function is used by abstract data 'hashtab'. The function returns 1 if the declarations have the same key, 0 otherwise. */ static int decl_eq_p (const void *decl_1, const void *decl_2) @@ -2373,11 +2383,10 @@ decl_eq_p (const void *decl_1, const void *decl_2) const decl_t d1 = (const decl_t) decl_1; const decl_t d2 = (const decl_t) decl_2; - if (((d1->mode != dm_unit || DECL_UNIT (d1)->name == NULL) - && (d1->mode != dm_reserv || DECL_RESERV (d1)->name == NULL)) - || ((d2->mode != dm_unit || DECL_UNIT (d2)->name == NULL) - && (d2->mode != dm_reserv || DECL_RESERV (d2)->name == NULL))) - abort (); + gcc_assert ((d1->mode == dm_unit && DECL_UNIT (d1)->name) + || (d1->mode == dm_reserv && DECL_RESERV (d1)->name)); + gcc_assert ((d2->mode == dm_unit && DECL_UNIT (d2)->name) + || (d2->mode == dm_reserv && DECL_RESERV (d2)->name)); return strcmp ((d1->mode == dm_unit ? DECL_UNIT (d1)->name : DECL_RESERV (d1)->name), (d2->mode == dm_unit @@ -2716,7 +2725,7 @@ add_presence_absence (unit_set_el_t dest_list, } else warning - ("unit `%s' excludes and requires presence of `%s'", + (0, "unit `%s' excludes and requires presence of `%s'", dst->unit_decl->name, unit->name); } } @@ -2736,7 +2745,7 @@ add_presence_absence (unit_set_el_t dest_list, } else warning - ("unit `%s' requires absence and presence of `%s'", + (0, "unit `%s' requires absence and presence of `%s'", dst->unit_decl->name, unit->name); } if (no_error_flag) @@ -2818,7 +2827,7 @@ process_decls (void) error ("repeated declaration of automaton `%s'", DECL_AUTOMATON (decl)->name); else - warning ("repeated declaration of automaton `%s'", + warning (0, "repeated declaration of automaton `%s'", DECL_AUTOMATON (decl)->name); } } @@ -2938,7 +2947,7 @@ process_decls (void) DECL_BYPASS (decl)->in_insn_name); else warning - ("the same bypass `%s - %s' is already defined", + (0, "the same bypass `%s - %s' is already defined", DECL_BYPASS (decl)->out_insn_name, DECL_BYPASS (decl)->in_insn_name); } @@ -3048,7 +3057,7 @@ check_automaton_usage (void) if (!w_flag) error ("automaton `%s' is not used", DECL_AUTOMATON (decl)->name); else - warning ("automaton `%s' is not used", + warning (0, "automaton `%s' is not used", DECL_AUTOMATON (decl)->name); } } @@ -3066,48 +3075,60 @@ process_regexp (regexp_t regexp) regexp_t new_regexp; int i; - if (regexp->mode == rm_unit) + switch (regexp->mode) { + case rm_unit: decl_in_table = find_decl (REGEXP_UNIT (regexp)->name); if (decl_in_table == NULL) error ("undeclared unit or reservation `%s'", REGEXP_UNIT (regexp)->name); - else if (decl_in_table->mode == dm_unit) - { - DECL_UNIT (decl_in_table)->unit_is_used = 1; - REGEXP_UNIT (regexp)->unit_decl = DECL_UNIT (decl_in_table); - } - else if (decl_in_table->mode == dm_reserv) - { - DECL_RESERV (decl_in_table)->reserv_is_used = 1; - new_regexp = create_node (sizeof (struct regexp)); - new_regexp->mode = rm_reserv; - new_regexp->pos = regexp->pos; - REGEXP_RESERV (new_regexp)->name = REGEXP_UNIT (regexp)->name; - REGEXP_RESERV (new_regexp)->reserv_decl - = DECL_RESERV (decl_in_table); - regexp = new_regexp; - } else - abort (); + switch (decl_in_table->mode) + { + case dm_unit: + DECL_UNIT (decl_in_table)->unit_is_used = 1; + REGEXP_UNIT (regexp)->unit_decl = DECL_UNIT (decl_in_table); + break; + + case dm_reserv: + DECL_RESERV (decl_in_table)->reserv_is_used = 1; + new_regexp = create_node (sizeof (struct regexp)); + new_regexp->mode = rm_reserv; + new_regexp->pos = regexp->pos; + REGEXP_RESERV (new_regexp)->name = REGEXP_UNIT (regexp)->name; + REGEXP_RESERV (new_regexp)->reserv_decl + = DECL_RESERV (decl_in_table); + regexp = new_regexp; + break; + + default: + gcc_unreachable (); + } + break; + case rm_sequence: + for (i = 0; i regexps_num; i++) + REGEXP_SEQUENCE (regexp)->regexps [i] + = process_regexp (REGEXP_SEQUENCE (regexp)->regexps [i]); + break; + case rm_allof: + for (i = 0; i < REGEXP_ALLOF (regexp)->regexps_num; i++) + REGEXP_ALLOF (regexp)->regexps [i] + = process_regexp (REGEXP_ALLOF (regexp)->regexps [i]); + break; + case rm_oneof: + for (i = 0; i < REGEXP_ONEOF (regexp)->regexps_num; i++) + REGEXP_ONEOF (regexp)->regexps [i] + = process_regexp (REGEXP_ONEOF (regexp)->regexps [i]); + break; + case rm_repeat: + REGEXP_REPEAT (regexp)->regexp + = process_regexp (REGEXP_REPEAT (regexp)->regexp); + break; + case rm_nothing: + break; + default: + gcc_unreachable (); } - else if (regexp->mode == rm_sequence) - for (i = 0; i regexps_num; i++) - REGEXP_SEQUENCE (regexp)->regexps [i] - = process_regexp (REGEXP_SEQUENCE (regexp)->regexps [i]); - else if (regexp->mode == rm_allof) - for (i = 0; i < REGEXP_ALLOF (regexp)->regexps_num; i++) - REGEXP_ALLOF (regexp)->regexps [i] - = process_regexp (REGEXP_ALLOF (regexp)->regexps [i]); - else if (regexp->mode == rm_oneof) - for (i = 0; i < REGEXP_ONEOF (regexp)->regexps_num; i++) - REGEXP_ONEOF (regexp)->regexps [i] - = process_regexp (REGEXP_ONEOF (regexp)->regexps [i]); - else if (regexp->mode == rm_repeat) - REGEXP_REPEAT (regexp)->regexp - = process_regexp (REGEXP_REPEAT (regexp)->regexp); - else if (regexp->mode != rm_nothing) - abort (); return regexp; } @@ -3150,14 +3171,14 @@ check_usage (void) if (!w_flag) error ("unit `%s' is not used", DECL_UNIT (decl)->name); else - warning ("unit `%s' is not used", DECL_UNIT (decl)->name); + warning (0, "unit `%s' is not used", DECL_UNIT (decl)->name); } else if (decl->mode == dm_reserv && !DECL_RESERV (decl)->reserv_is_used) { if (!w_flag) error ("reservation `%s' is not used", DECL_RESERV (decl)->name); else - warning ("reservation `%s' is not used", DECL_RESERV (decl)->name); + warning (0, "reservation `%s' is not used", DECL_RESERV (decl)->name); } } } @@ -3176,10 +3197,12 @@ loop_in_regexp (regexp_t regexp, decl_t start_decl) if (regexp == NULL) return 0; - if (regexp->mode == rm_unit) - return 0; - else if (regexp->mode == rm_reserv) + switch (regexp->mode) { + case rm_unit: + return 0; + + case rm_reserv: if (start_decl->mode == dm_reserv && REGEXP_RESERV (regexp)->reserv_decl == DECL_RESERV (start_decl)) return 1; @@ -3194,35 +3217,33 @@ loop_in_regexp (regexp_t regexp, decl_t start_decl) return loop_in_regexp (REGEXP_RESERV (regexp)->reserv_decl->regexp, start_decl); } - } - else if (regexp->mode == rm_sequence) - { + + case rm_sequence: for (i = 0; i regexps_num; i++) if (loop_in_regexp (REGEXP_SEQUENCE (regexp)->regexps [i], start_decl)) return 1; return 0; - } - else if (regexp->mode == rm_allof) - { + + case rm_allof: for (i = 0; i < REGEXP_ALLOF (regexp)->regexps_num; i++) if (loop_in_regexp (REGEXP_ALLOF (regexp)->regexps [i], start_decl)) return 1; return 0; - } - else if (regexp->mode == rm_oneof) - { + + case rm_oneof: for (i = 0; i < REGEXP_ONEOF (regexp)->regexps_num; i++) if (loop_in_regexp (REGEXP_ONEOF (regexp)->regexps [i], start_decl)) return 1; return 0; - } - else if (regexp->mode == rm_repeat) - return loop_in_regexp (REGEXP_REPEAT (regexp)->regexp, start_decl); - else - { - if (regexp->mode != rm_nothing) - abort (); + + case rm_repeat: + return loop_in_regexp (REGEXP_REPEAT (regexp)->regexp, start_decl); + + case rm_nothing: return 0; + + default: + gcc_unreachable (); } } @@ -3250,8 +3271,7 @@ check_loops_in_regexps (void) DECL_RESERV (decl)->loop_pass_num = curr_loop_pass_num; if (loop_in_regexp (DECL_RESERV (decl)->regexp, decl)) { - if (DECL_RESERV (decl)->regexp == NULL) - abort (); + gcc_assert (DECL_RESERV (decl)->regexp); error ("cycle in definition of reservation `%s'", DECL_RESERV (decl)->name); } @@ -3268,8 +3288,9 @@ process_regexp_cycles (regexp_t regexp, int max_start_cycle, { int i; - if (regexp->mode == rm_unit) + switch (regexp->mode) { + case rm_unit: if (REGEXP_UNIT (regexp)->unit_decl->max_occ_cycle_num < max_start_cycle) REGEXP_UNIT (regexp)->unit_decl->max_occ_cycle_num = max_start_cycle; if (REGEXP_UNIT (regexp)->unit_decl->min_occ_cycle_num > min_start_cycle @@ -3277,13 +3298,15 @@ process_regexp_cycles (regexp_t regexp, int max_start_cycle, REGEXP_UNIT (regexp)->unit_decl->min_occ_cycle_num = min_start_cycle; *max_finish_cycle = max_start_cycle; *min_finish_cycle = min_start_cycle; - } - else if (regexp->mode == rm_reserv) - process_regexp_cycles (REGEXP_RESERV (regexp)->reserv_decl->regexp, - max_start_cycle, min_start_cycle, - max_finish_cycle, min_finish_cycle); - else if (regexp->mode == rm_repeat) - { + break; + + case rm_reserv: + process_regexp_cycles (REGEXP_RESERV (regexp)->reserv_decl->regexp, + max_start_cycle, min_start_cycle, + max_finish_cycle, min_finish_cycle); + break; + + case rm_repeat: for (i = 0; i < REGEXP_REPEAT (regexp)->repeat_num; i++) { process_regexp_cycles (REGEXP_REPEAT (regexp)->regexp, @@ -3292,9 +3315,9 @@ process_regexp_cycles (regexp_t regexp, int max_start_cycle, max_start_cycle = *max_finish_cycle + 1; min_start_cycle = *min_finish_cycle + 1; } - } - else if (regexp->mode == rm_sequence) - { + break; + + case rm_sequence: for (i = 0; i regexps_num; i++) { process_regexp_cycles (REGEXP_SEQUENCE (regexp)->regexps [i], @@ -3303,49 +3326,55 @@ process_regexp_cycles (regexp_t regexp, int max_start_cycle, max_start_cycle = *max_finish_cycle + 1; min_start_cycle = *min_finish_cycle + 1; } - } - else if (regexp->mode == rm_allof) - { - int max_cycle = 0; - int min_cycle = 0; + break; - for (i = 0; i < REGEXP_ALLOF (regexp)->regexps_num; i++) - { - process_regexp_cycles (REGEXP_ALLOF (regexp)->regexps [i], - max_start_cycle, min_start_cycle, - max_finish_cycle, min_finish_cycle); - if (max_cycle < *max_finish_cycle) - max_cycle = *max_finish_cycle; - if (i == 0 || min_cycle > *min_finish_cycle) - min_cycle = *min_finish_cycle; - } - *max_finish_cycle = max_cycle; - *min_finish_cycle = min_cycle; - } - else if (regexp->mode == rm_oneof) - { - int max_cycle = 0; - int min_cycle = 0; + case rm_allof: + { + int max_cycle = 0; + int min_cycle = 0; + + for (i = 0; i < REGEXP_ALLOF (regexp)->regexps_num; i++) + { + process_regexp_cycles (REGEXP_ALLOF (regexp)->regexps [i], + max_start_cycle, min_start_cycle, + max_finish_cycle, min_finish_cycle); + if (max_cycle < *max_finish_cycle) + max_cycle = *max_finish_cycle; + if (i == 0 || min_cycle > *min_finish_cycle) + min_cycle = *min_finish_cycle; + } + *max_finish_cycle = max_cycle; + *min_finish_cycle = min_cycle; + } + break; - for (i = 0; i < REGEXP_ONEOF (regexp)->regexps_num; i++) - { - process_regexp_cycles (REGEXP_ONEOF (regexp)->regexps [i], - max_start_cycle, min_start_cycle, - max_finish_cycle, min_finish_cycle); - if (max_cycle < *max_finish_cycle) - max_cycle = *max_finish_cycle; - if (i == 0 || min_cycle > *min_finish_cycle) - min_cycle = *min_finish_cycle; - } - *max_finish_cycle = max_cycle; - *min_finish_cycle = min_cycle; - } - else - { - if (regexp->mode != rm_nothing) - abort (); + case rm_oneof: + { + int max_cycle = 0; + int min_cycle = 0; + + for (i = 0; i < REGEXP_ONEOF (regexp)->regexps_num; i++) + { + process_regexp_cycles (REGEXP_ONEOF (regexp)->regexps [i], + max_start_cycle, min_start_cycle, + max_finish_cycle, min_finish_cycle); + if (max_cycle < *max_finish_cycle) + max_cycle = *max_finish_cycle; + if (i == 0 || min_cycle > *min_finish_cycle) + min_cycle = *min_finish_cycle; + } + *max_finish_cycle = max_cycle; + *min_finish_cycle = min_cycle; + } + break; + + case rm_nothing: *max_finish_cycle = max_start_cycle; *min_finish_cycle = min_start_cycle; + break; + + default: + gcc_unreachable (); } } @@ -3787,8 +3816,7 @@ reserv_sets_cmp (reserv_sets_t reservs_1, reserv_sets_t reservs_2) set_el_t *reserv_ptr_1; set_el_t *reserv_ptr_2; - if (reservs_1 == NULL || reservs_2 == NULL) - abort (); + gcc_assert (reservs_1 && reservs_2); reservs_num = els_in_reservs; reserv_ptr_1 = reservs_1; reserv_ptr_2 = reservs_2; @@ -3818,8 +3846,7 @@ reserv_sets_eq (reserv_sets_t reservs_1, reserv_sets_t reservs_2) static void set_unit_reserv (reserv_sets_t reservs, int cycle_num, int unit_num) { - if (cycle_num >= max_cycles_num) - abort (); + gcc_assert (cycle_num < max_cycles_num); SET_BIT (reservs, cycle_num * els_in_cycle_reserv * sizeof (set_el_t) * CHAR_BIT + unit_num); } @@ -3829,8 +3856,7 @@ set_unit_reserv (reserv_sets_t reservs, int cycle_num, int unit_num) static int test_unit_reserv (reserv_sets_t reservs, int cycle_num, int unit_num) { - if (cycle_num >= max_cycles_num) - abort (); + gcc_assert (cycle_num < max_cycles_num); return TEST_BIT (reservs, cycle_num * els_in_cycle_reserv * sizeof (set_el_t) * CHAR_BIT + unit_num); } @@ -3843,8 +3869,7 @@ it_is_empty_reserv_sets (reserv_sets_t operand) set_el_t *reserv_ptr; int reservs_num; - if (operand == NULL) - abort (); + gcc_assert (operand); for (reservs_num = els_in_reservs, reserv_ptr = operand; reservs_num != 0; reserv_ptr++, reservs_num--) @@ -3865,8 +3890,7 @@ reserv_sets_are_intersected (reserv_sets_t operand_1, set_el_t *cycle_ptr_1; set_el_t *cycle_ptr_2; - if (operand_1 == NULL || operand_2 == NULL) - abort (); + gcc_assert (operand_1 && operand_2); for (el_ptr_1 = operand_1, el_ptr_2 = operand_2; el_ptr_1 < operand_1 + els_in_reservs; el_ptr_1++, el_ptr_2++) @@ -3905,8 +3929,7 @@ reserv_sets_shift (reserv_sets_t result, reserv_sets_t operand) { int i; - if (result == NULL || operand == NULL || result == operand) - abort (); + gcc_assert (result && operand && result != operand); for (i = els_in_cycle_reserv; i < els_in_reservs; i++) result [i - els_in_cycle_reserv] = operand [i]; } @@ -3920,8 +3943,7 @@ reserv_sets_or (reserv_sets_t result, reserv_sets_t operand_1, set_el_t *el_ptr_2; set_el_t *result_set_el_ptr; - if (result == NULL || operand_1 == NULL || operand_2 == NULL) - abort (); + gcc_assert (result && operand_1 && operand_2); for (el_ptr_1 = operand_1, el_ptr_2 = operand_2, result_set_el_ptr = result; el_ptr_1 < operand_1 + els_in_reservs; el_ptr_1++, el_ptr_2++, result_set_el_ptr++) @@ -3937,8 +3959,7 @@ reserv_sets_and (reserv_sets_t result, reserv_sets_t operand_1, set_el_t *el_ptr_2; set_el_t *result_set_el_ptr; - if (result == NULL || operand_1 == NULL || operand_2 == NULL) - abort (); + gcc_assert (result && operand_1 && operand_2); for (el_ptr_1 = operand_1, el_ptr_2 = operand_2, result_set_el_ptr = result; el_ptr_1 < operand_1 + els_in_reservs; el_ptr_1++, el_ptr_2++, result_set_el_ptr++) @@ -3960,8 +3981,7 @@ output_cycle_reservs (FILE *f, reserv_sets_t reservs, int start_cycle, if (TEST_BIT (reservs, start_cycle * els_in_cycle_reserv * sizeof (set_el_t) * CHAR_BIT + unit_num)) reserved_units_num++; - if (repetition_num <= 0) - abort (); + gcc_assert (repetition_num > 0); if (repetition_num != 1 && reserved_units_num > 1) fprintf (f, "("); reserved_units_num = 0; @@ -3978,8 +3998,7 @@ output_cycle_reservs (FILE *f, reserv_sets_t reservs, int start_cycle, } if (reserved_units_num == 0) fprintf (f, NOTHING_NAME); - if (repetition_num <= 0) - abort (); + gcc_assert (repetition_num > 0); if (repetition_num != 1 && reserved_units_num > 1) fprintf (f, ")"); if (repetition_num != 1) @@ -4033,8 +4052,7 @@ get_free_state (int with_reservs, automaton_t automaton) { state_t result; - if (max_cycles_num <= 0 || automaton == NULL) - abort (); + gcc_assert (max_cycles_num > 0 && automaton); if (VLA_PTR_LENGTH (free_states) != 0) { result = VLA_PTR (free_states, VLA_PTR_LENGTH (free_states) - 1); @@ -4160,8 +4178,7 @@ set_state_reserv (state_t state, int cycle_num, int unit_num) static int intersected_state_reservs_p (state_t state1, state_t state2) { - if (state1->automaton != state2->automaton) - abort (); + gcc_assert (state1->automaton == state2->automaton); return reserv_sets_are_intersected (state1->reservs, state2->reservs); } @@ -4174,8 +4191,7 @@ states_union (state_t state1, state_t state2, reserv_sets_t reservs) state_t result; state_t state_in_table; - if (state1->automaton != state2->automaton) - abort (); + gcc_assert (state1->automaton == state2->automaton); result = get_free_state (1, state1->automaton); reserv_sets_or (result->reservs, state1->reservs, state2->reservs); reserv_sets_and (result->reservs, result->reservs, reservs); @@ -4276,15 +4292,13 @@ remove_arc (state_t from_state, arc_t arc) arc_t prev_arc; arc_t curr_arc; - if (arc == NULL) - abort (); + gcc_assert (arc); for (prev_arc = NULL, curr_arc = from_state->first_out_arc; curr_arc != NULL; prev_arc = curr_arc, curr_arc = curr_arc->next_out_arc) if (curr_arc == arc) break; - if (curr_arc == NULL) - abort (); + gcc_assert (curr_arc); if (prev_arc == NULL) from_state->first_out_arc = arc->next_out_arc; else @@ -4787,48 +4801,55 @@ copy_insn_regexp (regexp_t regexp) regexp_t result; int i; - if (regexp->mode == rm_reserv) - result = copy_insn_regexp (REGEXP_RESERV (regexp)->reserv_decl->regexp); - else if (regexp->mode == rm_unit) - result = copy_node (regexp, sizeof (struct regexp)); - else if (regexp->mode == rm_repeat) + switch (regexp->mode) { + case rm_reserv: + result = copy_insn_regexp (REGEXP_RESERV (regexp)->reserv_decl->regexp); + break; + + case rm_unit: + result = copy_node (regexp, sizeof (struct regexp)); + break; + + case rm_repeat: result = copy_node (regexp, sizeof (struct regexp)); REGEXP_REPEAT (result)->regexp = copy_insn_regexp (REGEXP_REPEAT (regexp)->regexp); - } - else if (regexp->mode == rm_sequence) - { + break; + + case rm_sequence: result = copy_node (regexp, sizeof (struct regexp) + sizeof (regexp_t) * (REGEXP_SEQUENCE (regexp)->regexps_num - 1)); for (i = 0; i regexps_num; i++) REGEXP_SEQUENCE (result)->regexps [i] = copy_insn_regexp (REGEXP_SEQUENCE (regexp)->regexps [i]); - } - else if (regexp->mode == rm_allof) - { + break; + + case rm_allof: result = copy_node (regexp, sizeof (struct regexp) + sizeof (regexp_t) * (REGEXP_ALLOF (regexp)->regexps_num - 1)); for (i = 0; i < REGEXP_ALLOF (regexp)->regexps_num; i++) REGEXP_ALLOF (result)->regexps [i] = copy_insn_regexp (REGEXP_ALLOF (regexp)->regexps [i]); - } - else if (regexp->mode == rm_oneof) - { + break; + + case rm_oneof: result = copy_node (regexp, sizeof (struct regexp) + sizeof (regexp_t) * (REGEXP_ONEOF (regexp)->regexps_num - 1)); for (i = 0; i < REGEXP_ONEOF (regexp)->regexps_num; i++) REGEXP_ONEOF (result)->regexps [i] = copy_insn_regexp (REGEXP_ONEOF (regexp)->regexps [i]); - } - else - { - if (regexp->mode != rm_nothing) - abort (); + break; + + case rm_nothing: result = copy_node (regexp, sizeof (struct regexp)); + break; + + default: + gcc_unreachable (); } return result; } @@ -4850,8 +4871,7 @@ transform_1 (regexp_t regexp) if (regexp->mode == rm_repeat) { repeat_num = REGEXP_REPEAT (regexp)->repeat_num; - if (repeat_num <= 1) - abort (); + gcc_assert (repeat_num > 1); operand = REGEXP_REPEAT (regexp)->regexp; pos = regexp->mode; regexp = create_node (sizeof (struct regexp) + sizeof (regexp_t) @@ -4889,9 +4909,8 @@ transform_2 (regexp_t regexp) } if (i < REGEXP_SEQUENCE (regexp)->regexps_num) { - if ( REGEXP_SEQUENCE (sequence)->regexps_num <= 1 - || REGEXP_SEQUENCE (regexp)->regexps_num <= 1) - abort (); + gcc_assert (REGEXP_SEQUENCE (sequence)->regexps_num > 1 + && REGEXP_SEQUENCE (regexp)->regexps_num > 1); result = create_node (sizeof (struct regexp) + sizeof (regexp_t) * (REGEXP_SEQUENCE (regexp)->regexps_num @@ -4934,9 +4953,8 @@ transform_2 (regexp_t regexp) } if (i < REGEXP_ALLOF (regexp)->regexps_num) { - if (REGEXP_ALLOF (allof)->regexps_num <= 1 - || REGEXP_ALLOF (regexp)->regexps_num <= 1) - abort (); + gcc_assert (REGEXP_ALLOF (allof)->regexps_num > 1 + && REGEXP_ALLOF (regexp)->regexps_num > 1); result = create_node (sizeof (struct regexp) + sizeof (regexp_t) * (REGEXP_ALLOF (regexp)->regexps_num @@ -4978,9 +4996,8 @@ transform_2 (regexp_t regexp) } if (i < REGEXP_ONEOF (regexp)->regexps_num) { - if (REGEXP_ONEOF (oneof)->regexps_num <= 1 - || REGEXP_ONEOF (regexp)->regexps_num <= 1) - abort (); + gcc_assert (REGEXP_ONEOF (oneof)->regexps_num > 1 + && REGEXP_ONEOF (regexp)->regexps_num > 1); result = create_node (sizeof (struct regexp) + sizeof (regexp_t) * (REGEXP_ONEOF (regexp)->regexps_num @@ -5034,9 +5051,8 @@ transform_3 (regexp_t regexp) } if (i < REGEXP_SEQUENCE (regexp)->regexps_num) { - if (REGEXP_ONEOF (oneof)->regexps_num <= 1 - || REGEXP_SEQUENCE (regexp)->regexps_num <= 1) - abort (); + gcc_assert (REGEXP_ONEOF (oneof)->regexps_num > 1 + && REGEXP_SEQUENCE (regexp)->regexps_num > 1); result = create_node (sizeof (struct regexp) + sizeof (regexp_t) * (REGEXP_ONEOF (oneof)->regexps_num - 1)); @@ -5087,9 +5103,8 @@ transform_3 (regexp_t regexp) } if (i < REGEXP_ALLOF (regexp)->regexps_num) { - if (REGEXP_ONEOF (oneof)->regexps_num <= 1 - || REGEXP_ALLOF (regexp)->regexps_num <= 1) - abort (); + gcc_assert (REGEXP_ONEOF (oneof)->regexps_num > 1 + && REGEXP_ALLOF (regexp)->regexps_num > 1); result = create_node (sizeof (struct regexp) + sizeof (regexp_t) * (REGEXP_ONEOF (oneof)->regexps_num - 1)); @@ -5123,23 +5138,28 @@ transform_3 (regexp_t regexp) if (regexp->mode == rm_allof) for (i = 0; i < REGEXP_ALLOF (regexp)->regexps_num; i++) { - if (REGEXP_ALLOF (regexp)->regexps [i]->mode == rm_sequence) + switch (REGEXP_ALLOF (regexp)->regexps [i]->mode) { + case rm_sequence: seq = REGEXP_ALLOF (regexp)->regexps [i]; if (max_seq_length < REGEXP_SEQUENCE (seq)->regexps_num) max_seq_length = REGEXP_SEQUENCE (seq)->regexps_num; - } - else if (REGEXP_ALLOF (regexp)->regexps [i]->mode != rm_unit - && REGEXP_ALLOF (regexp)->regexps [i]->mode != rm_nothing) - { - max_seq_length = 0; break; + + case rm_unit: + case rm_nothing: + break; + + default: + max_seq_length = 0; + goto break_for; } } + break_for: if (max_seq_length != 0) { - if (max_seq_length == 1 || REGEXP_ALLOF (regexp)->regexps_num <= 1) - abort (); + gcc_assert (max_seq_length != 1 + && REGEXP_ALLOF (regexp)->regexps_num > 1); result = create_node (sizeof (struct regexp) + sizeof (regexp_t) * (max_seq_length - 1)); result->mode = rm_sequence; @@ -5149,24 +5169,31 @@ transform_3 (regexp_t regexp) { allof_length = 0; for (j = 0; j < REGEXP_ALLOF (regexp)->regexps_num; j++) - if (REGEXP_ALLOF (regexp)->regexps [j]->mode == rm_sequence - && (i < (REGEXP_SEQUENCE (REGEXP_ALLOF (regexp) - ->regexps [j])->regexps_num))) + switch (REGEXP_ALLOF (regexp)->regexps [j]->mode) { - allof_op - = (REGEXP_SEQUENCE (REGEXP_ALLOF (regexp)->regexps [j]) - ->regexps [i]); - allof_length++; - } - else if (i == 0 - && (REGEXP_ALLOF (regexp)->regexps [j]->mode - == rm_unit - || (REGEXP_ALLOF (regexp)->regexps [j]->mode - == rm_nothing))) - { - allof_op = REGEXP_ALLOF (regexp)->regexps [j]; - allof_length++; + case rm_sequence: + if (i < (REGEXP_SEQUENCE (REGEXP_ALLOF (regexp) + ->regexps [j])->regexps_num)) + { + allof_op + = (REGEXP_SEQUENCE (REGEXP_ALLOF (regexp) + ->regexps [j]) + ->regexps [i]); + allof_length++; + } + break; + case rm_unit: + case rm_nothing: + if (i == 0) + { + allof_op = REGEXP_ALLOF (regexp)->regexps [j]; + allof_length++; + } + break; + default: + break; } + if (allof_length == 1) REGEXP_SEQUENCE (result)->regexps [i] = allof_op; else @@ -5219,23 +5246,39 @@ regexp_transform_func (regexp_t regexp, regexp_t (*func) (regexp_t regexp)) { int i; - if (regexp->mode == rm_sequence) - for (i = 0; i < REGEXP_SEQUENCE (regexp)->regexps_num; i++) - REGEXP_SEQUENCE (regexp)->regexps [i] - = regexp_transform_func (REGEXP_SEQUENCE (regexp)->regexps [i], func); - else if (regexp->mode == rm_allof) - for (i = 0; i < REGEXP_ALLOF (regexp)->regexps_num; i++) - REGEXP_ALLOF (regexp)->regexps [i] - = regexp_transform_func (REGEXP_ALLOF (regexp)->regexps [i], func); - else if (regexp->mode == rm_oneof) - for (i = 0; i < REGEXP_ONEOF (regexp)->regexps_num; i++) - REGEXP_ONEOF (regexp)->regexps [i] - = regexp_transform_func (REGEXP_ONEOF (regexp)->regexps [i], func); - else if (regexp->mode == rm_repeat) - REGEXP_REPEAT (regexp)->regexp - = regexp_transform_func (REGEXP_REPEAT (regexp)->regexp, func); - else if (regexp->mode != rm_nothing && regexp->mode != rm_unit) - abort (); + switch (regexp->mode) + { + case rm_sequence: + for (i = 0; i < REGEXP_SEQUENCE (regexp)->regexps_num; i++) + REGEXP_SEQUENCE (regexp)->regexps [i] + = regexp_transform_func (REGEXP_SEQUENCE (regexp)->regexps [i], + func); + break; + + case rm_allof: + for (i = 0; i < REGEXP_ALLOF (regexp)->regexps_num; i++) + REGEXP_ALLOF (regexp)->regexps [i] + = regexp_transform_func (REGEXP_ALLOF (regexp)->regexps [i], func); + break; + + case rm_oneof: + for (i = 0; i < REGEXP_ONEOF (regexp)->regexps_num; i++) + REGEXP_ONEOF (regexp)->regexps [i] + = regexp_transform_func (REGEXP_ONEOF (regexp)->regexps [i], func); + break; + + case rm_repeat: + REGEXP_REPEAT (regexp)->regexp + = regexp_transform_func (REGEXP_REPEAT (regexp)->regexp, func); + break; + + case rm_nothing: + case rm_unit: + break; + + default: + gcc_unreachable (); + } return (*func) (regexp); } @@ -5265,8 +5308,8 @@ transform_insn_regexps (void) transform_time = create_ticker (); add_advance_cycle_insn_decl (); - fprintf (stderr, "Reservation transformation..."); - fflush (stderr); + if (progress_flag) + fprintf (stderr, "Reservation transformation..."); for (i = 0; i < description->decls_num; i++) { decl = description->decls [i]; @@ -5275,9 +5318,9 @@ transform_insn_regexps (void) = transform_regexp (copy_insn_regexp (DECL_INSN_RESERV (decl)->regexp)); } - fprintf (stderr, "done\n"); + if (progress_flag) + fprintf (stderr, "done\n"); ticker_off (&transform_time); - fflush (stderr); } @@ -5318,9 +5361,8 @@ store_alt_unit_usage (regexp_t regexp, regexp_t unit, int cycle, struct unit_usage *unit_usage_ptr; int index; - if (regexp == NULL || regexp->mode != rm_oneof - || alt_num >= REGEXP_ONEOF (regexp)->regexps_num) - abort (); + gcc_assert (regexp && regexp->mode == rm_oneof + && alt_num < REGEXP_ONEOF (regexp)->regexps_num); unit_decl = REGEXP_UNIT (unit)->unit_decl; old_length = VLA_PTR_LENGTH (cycle_alt_unit_usages); length = (cycle + 1) * REGEXP_ONEOF (regexp)->regexps_num; @@ -5358,37 +5400,67 @@ check_regexp_units_distribution (const char *insn_reserv_name, for (i = REGEXP_ONEOF (regexp)->regexps_num - 1; i >= 0; i--) { seq = REGEXP_ONEOF (regexp)->regexps [i]; - if (seq->mode == rm_sequence) - for (j = 0; j < REGEXP_SEQUENCE (seq)->regexps_num; j++) - { - allof = REGEXP_SEQUENCE (seq)->regexps [j]; - if (allof->mode == rm_allof) - for (k = 0; k < REGEXP_ALLOF (allof)->regexps_num; k++) + switch (seq->mode) + { + case rm_sequence: + for (j = 0; j < REGEXP_SEQUENCE (seq)->regexps_num; j++) + { + allof = REGEXP_SEQUENCE (seq)->regexps [j]; + switch (allof->mode) { - unit = REGEXP_ALLOF (allof)->regexps [k]; - if (unit->mode == rm_unit) - store_alt_unit_usage (regexp, unit, j, i); - else if (unit->mode != rm_nothing) - abort (); + case rm_allof: + for (k = 0; k < REGEXP_ALLOF (allof)->regexps_num; k++) + { + unit = REGEXP_ALLOF (allof)->regexps [k]; + if (unit->mode == rm_unit) + store_alt_unit_usage (regexp, unit, j, i); + else + gcc_assert (unit->mode == rm_nothing); + } + break; + + case rm_unit: + store_alt_unit_usage (regexp, allof, j, i); + break; + + case rm_nothing: + break; + + default: + gcc_unreachable (); } - else if (allof->mode == rm_unit) - store_alt_unit_usage (regexp, allof, j, i); - else if (allof->mode != rm_nothing) - abort (); - } - else if (seq->mode == rm_allof) - for (k = 0; k < REGEXP_ALLOF (seq)->regexps_num; k++) - { - unit = REGEXP_ALLOF (seq)->regexps [k]; - if (unit->mode == rm_unit) - store_alt_unit_usage (regexp, unit, 0, i); - else if (unit->mode != rm_nothing) - abort (); - } - else if (seq->mode == rm_unit) - store_alt_unit_usage (regexp, seq, 0, i); - else if (seq->mode != rm_nothing) - abort (); + } + break; + + case rm_allof: + for (k = 0; k < REGEXP_ALLOF (seq)->regexps_num; k++) + { + unit = REGEXP_ALLOF (seq)->regexps [k]; + switch (unit->mode) + { + case rm_unit: + store_alt_unit_usage (regexp, unit, 0, i); + break; + + case rm_nothing: + break; + + default: + gcc_unreachable (); + } + } + break; + + case rm_unit: + store_alt_unit_usage (regexp, seq, 0, i); + break; + + case rm_nothing: + break; + + default: + gcc_unreachable (); + } } /* Check distribution: */ for (i = 0; i < (int) VLA_PTR_LENGTH (cycle_alt_unit_usages); i++) @@ -5443,7 +5515,8 @@ check_unit_distributions_to_automata (void) decl_t decl; int i; - fprintf (stderr, "Check unit distributions to automata..."); + if (progress_flag) + fprintf (stderr, "Check unit distributions to automata..."); annotation_message_reported_p = FALSE; for (i = 0; i < description->decls_num; i++) { @@ -5453,7 +5526,8 @@ check_unit_distributions_to_automata (void) (DECL_INSN_RESERV (decl)->name, DECL_INSN_RESERV (decl)->transformed_regexp); } - fprintf (stderr, "done\n"); + if (progress_flag) + fprintf (stderr, "done\n"); } @@ -5479,42 +5553,44 @@ process_seq_for_forming_states (regexp_t regexp, automaton_t automaton, if (regexp == NULL) return curr_cycle; - else if (regexp->mode == rm_unit) + + switch (regexp->mode) { + case rm_unit: if (REGEXP_UNIT (regexp)->unit_decl->corresponding_automaton_num == automaton->automaton_order_num) set_state_reserv (state_being_formed, curr_cycle, REGEXP_UNIT (regexp)->unit_decl->unit_num); return curr_cycle; - } - else if (regexp->mode == rm_sequence) - { + + case rm_sequence: for (i = 0; i < REGEXP_SEQUENCE (regexp)->regexps_num; i++) curr_cycle = process_seq_for_forming_states (REGEXP_SEQUENCE (regexp)->regexps [i], automaton, curr_cycle) + 1; return curr_cycle; - } - else if (regexp->mode == rm_allof) - { - int finish_cycle = 0; - int cycle; - for (i = 0; i < REGEXP_ALLOF (regexp)->regexps_num; i++) - { - cycle = process_seq_for_forming_states (REGEXP_ALLOF (regexp) - ->regexps [i], - automaton, curr_cycle); - if (finish_cycle < cycle) - finish_cycle = cycle; - } - return finish_cycle; - } - else - { - if (regexp->mode != rm_nothing) - abort (); + case rm_allof: + { + int finish_cycle = 0; + int cycle; + + for (i = 0; i < REGEXP_ALLOF (regexp)->regexps_num; i++) + { + cycle = process_seq_for_forming_states (REGEXP_ALLOF (regexp) + ->regexps [i], + automaton, curr_cycle); + if (finish_cycle < cycle) + finish_cycle = cycle; + } + return finish_cycle; + } + + case rm_nothing: return curr_cycle; + + default: + gcc_unreachable (); } } @@ -5564,8 +5640,7 @@ process_alts_for_forming_states (regexp_t regexp, automaton_t automaton, } else { - if (inside_oneof_p) - abort (); + gcc_assert (!inside_oneof_p); /* We processes it in reverse order to get list with the same order as in the description. See also the previous commentary. */ @@ -5732,8 +5807,8 @@ make_automaton (automaton_t automaton) = 1; VLA_PTR_ADD (state_stack, state2); states_n++; - if (states_n % 100 == 0) - fprintf (stderr, "*"); + if (progress_flag && states_n % 100 == 0) + fprintf (stderr, "."); } added_arc = add_arc (state, state2, ainsn, 1); if (!ndfa_flag) @@ -5763,11 +5838,10 @@ make_automaton (automaton_t automaton) state2->it_was_placed_in_stack_for_NDFA_forming = 1; VLA_PTR_ADD (state_stack, state2); states_n++; - if (states_n % 100 == 0) - fprintf (stderr, "*"); + if (progress_flag && states_n % 100 == 0) + fprintf (stderr, "."); } - if (advance_cycle_ainsn == NULL) - abort (); + gcc_assert (advance_cycle_ainsn); add_arc (state, state2, advance_cycle_ainsn, 1); } VLA_PTR_DELETE (state_stack); @@ -5789,8 +5863,7 @@ form_arcs_marked_by_insn (state_t state) } for (arc = first_out_arc (state); arc != NULL; arc = next_out_arc (arc)) { - if (arc->insn == NULL) - abort (); + gcc_assert (arc->insn); arc->next_arc_marked_by_insn = arc->insn->insn_reserv_decl->arcs_marked_by_insn; arc->insn->insn_reserv_decl->arcs_marked_by_insn = arc; @@ -5822,8 +5895,7 @@ create_composed_state (state_t original_state, arc_t arcs_marked_by_insn, state = arcs_marked_by_insn->to_state; else { - if (!ndfa_flag) - abort (); + gcc_assert (ndfa_flag); /* Create composed state. */ state = get_free_state (0, arcs_marked_by_insn->to_state->automaton); curr_alt_state = NULL; @@ -5845,8 +5917,7 @@ create_composed_state (state_t original_state, arc_t arcs_marked_by_insn, new_alt_state = get_free_alt_state (); new_alt_state->next_alt_state = curr_alt_state; new_alt_state->state = alt_state->state; - if (alt_state->state->component_states != NULL) - abort (); + gcc_assert (!alt_state->state->component_states); curr_alt_state = new_alt_state; } /* There are not identical sets in the alt state list. */ @@ -5863,15 +5934,14 @@ create_composed_state (state_t original_state, arc_t arcs_marked_by_insn, state_in_table = insert_state (state); if (state_in_table != state) { - if (!state_in_table->it_was_placed_in_stack_for_DFA_forming) - abort (); + gcc_assert + (state_in_table->it_was_placed_in_stack_for_DFA_forming); free_state (state); state = state_in_table; } else { - if (state->it_was_placed_in_stack_for_DFA_forming) - abort (); + gcc_assert (!state->it_was_placed_in_stack_for_DFA_forming); new_state_p = 1; for (curr_alt_state = state->component_states; curr_alt_state != NULL; @@ -5934,8 +6004,8 @@ NDFA_to_DFA (automaton_t automaton) &state_stack)) { states_n++; - if (states_n % 100 == 0) - fprintf (stderr, "*"); + if (progress_flag && states_n % 100 == 0) + fprintf (stderr, "."); } } } @@ -6004,18 +6074,16 @@ set_out_arc_insns_equiv_num (state_t state, int odd_iteration_flag) state_out_arcs_num = 0; for (arc = first_out_arc (state); arc != NULL; arc = next_out_arc (arc)) { - if (arc->insn->insn_reserv_decl->equiv_class_num != 0 - || arc->insn->insn_reserv_decl->state_alts != 0) - abort (); + gcc_assert (!arc->insn->insn_reserv_decl->equiv_class_num + && !arc->insn->insn_reserv_decl->state_alts); state_out_arcs_num++; arc->insn->insn_reserv_decl->equiv_class_num = (odd_iteration_flag ? arc->to_state->equiv_class_num_1 : arc->to_state->equiv_class_num_2); arc->insn->insn_reserv_decl->state_alts = arc->state_alts; - if (arc->insn->insn_reserv_decl->equiv_class_num == 0 - || arc->insn->insn_reserv_decl->state_alts <= 0) - abort (); + gcc_assert (arc->insn->insn_reserv_decl->equiv_class_num + && arc->insn->insn_reserv_decl->state_alts > 0); } return state_out_arcs_num; } @@ -6053,15 +6121,19 @@ copy_equiv_class (vla_ptr_t *to, const vla_ptr_t *from) static int first_cycle_unit_presence (state_t state, int unit_num) { - int presence_p; + alt_state_t alt_state; if (state->component_states == NULL) - presence_p = test_unit_reserv (state->reservs, 0, unit_num); + return test_unit_reserv (state->reservs, 0, unit_num); else - presence_p - = test_unit_reserv (state->component_states->state->reservs, - 0, unit_num); - return presence_p; + { + for (alt_state = state->component_states; + alt_state != NULL; + alt_state = alt_state->next_sorted_alt_state) + if (test_unit_reserv (alt_state->state->reservs, 0, unit_num)) + return true; + } + return false; } /* The function returns nonzero value if STATE is not equivalent to @@ -6142,8 +6214,7 @@ partition_equiv_class (state_t *equiv_class_ptr, int odd_iteration_flag, int out_arcs_num; partition_p = 0; - if (*equiv_class_ptr == NULL) - abort (); + gcc_assert (*equiv_class_ptr); for (first_state = *equiv_class_ptr; first_state != NULL; first_state = new_equiv_class) @@ -6282,7 +6353,7 @@ merge_states (automaton_t automaton, vla_ptr_t *equiv_classes) } } /* Its is important that alt states were sorted before and - after merging to have the same quering results. */ + after merging to have the same querying results. */ new_state->component_states = uniq_sort_alt_states (alt_states); } else @@ -6395,25 +6466,35 @@ build_automaton (automaton_t automaton) int arcs_num; ticker_on (&NDFA_time); - if (automaton->corresponding_automaton_decl == NULL) - fprintf (stderr, "Create anonymous automaton (1 star is 100 new states):"); - else - fprintf (stderr, "Create automaton `%s' (1 star is 100 new states):", - automaton->corresponding_automaton_decl->name); + if (progress_flag) + { + if (automaton->corresponding_automaton_decl == NULL) + fprintf (stderr, "Create anonymous automaton"); + else + fprintf (stderr, "Create automaton `%s'", + automaton->corresponding_automaton_decl->name); + fprintf (stderr, " (1 dot is 100 new states):"); + } make_automaton (automaton); - fprintf (stderr, " done\n"); + if (progress_flag) + fprintf (stderr, " done\n"); ticker_off (&NDFA_time); count_states_and_arcs (automaton, &states_num, &arcs_num); automaton->NDFA_states_num = states_num; automaton->NDFA_arcs_num = arcs_num; ticker_on (&NDFA_to_DFA_time); - if (automaton->corresponding_automaton_decl == NULL) - fprintf (stderr, "Make anonymous DFA (1 star is 100 new states):"); - else - fprintf (stderr, "Make DFA `%s' (1 star is 100 new states):", - automaton->corresponding_automaton_decl->name); + if (progress_flag) + { + if (automaton->corresponding_automaton_decl == NULL) + fprintf (stderr, "Make anonymous DFA"); + else + fprintf (stderr, "Make DFA `%s'", + automaton->corresponding_automaton_decl->name); + fprintf (stderr, " (1 dot is 100 new states):"); + } NDFA_to_DFA (automaton); - fprintf (stderr, " done\n"); + if (progress_flag) + fprintf (stderr, " done\n"); ticker_off (&NDFA_to_DFA_time); count_states_and_arcs (automaton, &states_num, &arcs_num); automaton->DFA_states_num = states_num; @@ -6421,13 +6502,17 @@ build_automaton (automaton_t automaton) if (!no_minimization_flag) { ticker_on (&minimize_time); - if (automaton->corresponding_automaton_decl == NULL) - fprintf (stderr, "Minimize anonymous DFA..."); - else - fprintf (stderr, "Minimize DFA `%s'...", - automaton->corresponding_automaton_decl->name); + if (progress_flag) + { + if (automaton->corresponding_automaton_decl == NULL) + fprintf (stderr, "Minimize anonymous DFA..."); + else + fprintf (stderr, "Minimize DFA `%s'...", + automaton->corresponding_automaton_decl->name); + } minimize_DFA (automaton); - fprintf (stderr, "done\n"); + if (progress_flag) + fprintf (stderr, "done\n"); ticker_off (&minimize_time); count_states_and_arcs (automaton, &states_num, &arcs_num); automaton->minimal_DFA_states_num = states_num; @@ -6512,8 +6597,7 @@ process_insn_equiv_class (ainsn_t ainsn, arc_t *insn_arcs_array) ainsn_t cyclic_insn_list; arc_t arc; - if (insn_arcs_array [ainsn->insn_reserv_decl->insn_num] == NULL) - abort (); + gcc_assert (insn_arcs_array [ainsn->insn_reserv_decl->insn_num]); curr_insn = ainsn; /* New class of ainsns which are not equivalent to given ainsn. */ cyclic_insn_list = NULL; @@ -6584,9 +6668,8 @@ set_insn_equiv_classes (automaton_t automaton) if (ainsn->insn_equiv_class_num < 0) { first_insn = ainsn; - if (!first_insn->first_insn_with_same_reservs) - abort (); - first_insn->first_ainsn_with_given_equialence_num = 1; + gcc_assert (first_insn->first_insn_with_same_reservs); + first_insn->first_ainsn_with_given_equivalence_num = 1; curr_insn = first_insn; do { @@ -6696,8 +6779,7 @@ units_to_automata_heuristic_distr (void) { rest_units_num = ((decl_t *) VLA_PTR_LAST (unit_decls) - unit_decl_ptr + 1); - if (automata_num - automaton_num - 1 > rest_units_num) - abort (); + gcc_assert (automata_num - automaton_num - 1 <= rest_units_num); if (automaton_num < automata_num - 1 && ((automata_num - automaton_num - 1 == rest_units_num) || (bound_value @@ -6711,8 +6793,7 @@ units_to_automata_heuristic_distr (void) bound_value *= DECL_UNIT (*unit_decl_ptr)->max_occ_cycle_num; DECL_UNIT (*unit_decl_ptr)->corresponding_automaton_num = automaton_num; } - if (automaton_num != automata_num - 1) - abort (); + gcc_assert (automaton_num == automata_num - 1); VLA_PTR_DELETE (unit_decls); } @@ -6851,14 +6932,18 @@ create_automata (void) curr_automaton != NULL; curr_automaton = curr_automaton->next_automaton) { - if (curr_automaton->corresponding_automaton_decl == NULL) - fprintf (stderr, "Prepare anonymous automaton creation ... "); - else - fprintf (stderr, "Prepare automaton `%s' creation...", - curr_automaton->corresponding_automaton_decl->name); + if (progress_flag) + { + if (curr_automaton->corresponding_automaton_decl == NULL) + fprintf (stderr, "Prepare anonymous automaton creation ... "); + else + fprintf (stderr, "Prepare automaton `%s' creation...", + curr_automaton->corresponding_automaton_decl->name); + } create_alt_states (curr_automaton); form_ainsn_with_same_reservs (curr_automaton); - fprintf (stderr, "done\n"); + if (progress_flag) + fprintf (stderr, "done\n"); build_automaton (curr_automaton); enumerate_states (curr_automaton); ticker_on (&equiv_time); @@ -6881,23 +6966,28 @@ form_regexp (regexp_t regexp) { int i; - if (regexp->mode == rm_unit || regexp->mode == rm_reserv) + switch (regexp->mode) { - const char *name = (regexp->mode == rm_unit - ? REGEXP_UNIT (regexp)->name - : REGEXP_RESERV (regexp)->name); - - obstack_grow (&irp, name, strlen (name)); - } - else if (regexp->mode == rm_sequence) - for (i = 0; i < REGEXP_SEQUENCE (regexp)->regexps_num; i++) + case rm_unit: case rm_reserv: { - if (i != 0) - obstack_1grow (&irp, ','); - form_regexp (REGEXP_SEQUENCE (regexp)->regexps [i]); + const char *name = (regexp->mode == rm_unit + ? REGEXP_UNIT (regexp)->name + : REGEXP_RESERV (regexp)->name); + + obstack_grow (&irp, name, strlen (name)); + break; } - else if (regexp->mode == rm_allof) - { + + case rm_sequence: + for (i = 0; i < REGEXP_SEQUENCE (regexp)->regexps_num; i++) + { + if (i != 0) + obstack_1grow (&irp, ','); + form_regexp (REGEXP_SEQUENCE (regexp)->regexps [i]); + } + break; + + case rm_allof: obstack_1grow (&irp, '('); for (i = 0; i < REGEXP_ALLOF (regexp)->regexps_num; i++) { @@ -6912,38 +7002,46 @@ form_regexp (regexp_t regexp) obstack_1grow (&irp, ')'); } obstack_1grow (&irp, ')'); - } - else if (regexp->mode == rm_oneof) - for (i = 0; i < REGEXP_ONEOF (regexp)->regexps_num; i++) - { - if (i != 0) - obstack_1grow (&irp, '|'); - if (REGEXP_ONEOF (regexp)->regexps[i]->mode == rm_sequence) - obstack_1grow (&irp, '('); - form_regexp (REGEXP_ONEOF (regexp)->regexps [i]); - if (REGEXP_ONEOF (regexp)->regexps[i]->mode == rm_sequence) + break; + + case rm_oneof: + for (i = 0; i < REGEXP_ONEOF (regexp)->regexps_num; i++) + { + if (i != 0) + obstack_1grow (&irp, '|'); + if (REGEXP_ONEOF (regexp)->regexps[i]->mode == rm_sequence) + obstack_1grow (&irp, '('); + form_regexp (REGEXP_ONEOF (regexp)->regexps [i]); + if (REGEXP_ONEOF (regexp)->regexps[i]->mode == rm_sequence) obstack_1grow (&irp, ')'); + } + break; + + case rm_repeat: + { + char digits [30]; + + if (REGEXP_REPEAT (regexp)->regexp->mode == rm_sequence + || REGEXP_REPEAT (regexp)->regexp->mode == rm_allof + || REGEXP_REPEAT (regexp)->regexp->mode == rm_oneof) + obstack_1grow (&irp, '('); + form_regexp (REGEXP_REPEAT (regexp)->regexp); + if (REGEXP_REPEAT (regexp)->regexp->mode == rm_sequence + || REGEXP_REPEAT (regexp)->regexp->mode == rm_allof + || REGEXP_REPEAT (regexp)->regexp->mode == rm_oneof) + obstack_1grow (&irp, ')'); + sprintf (digits, "*%d", REGEXP_REPEAT (regexp)->repeat_num); + obstack_grow (&irp, digits, strlen (digits)); + break; } - else if (regexp->mode == rm_repeat) - { - char digits [30]; - - if (REGEXP_REPEAT (regexp)->regexp->mode == rm_sequence - || REGEXP_REPEAT (regexp)->regexp->mode == rm_allof - || REGEXP_REPEAT (regexp)->regexp->mode == rm_oneof) - obstack_1grow (&irp, '('); - form_regexp (REGEXP_REPEAT (regexp)->regexp); - if (REGEXP_REPEAT (regexp)->regexp->mode == rm_sequence - || REGEXP_REPEAT (regexp)->regexp->mode == rm_allof - || REGEXP_REPEAT (regexp)->regexp->mode == rm_oneof) - obstack_1grow (&irp, ')'); - sprintf (digits, "*%d", REGEXP_REPEAT (regexp)->repeat_num); - obstack_grow (&irp, digits, strlen (digits)); - } - else if (regexp->mode == rm_nothing) - obstack_grow (&irp, NOTHING_NAME, strlen (NOTHING_NAME)); - else - abort (); + + case rm_nothing: + obstack_grow (&irp, NOTHING_NAME, strlen (NOTHING_NAME)); + break; + + default: + gcc_unreachable (); + } } /* The function returns string representation of REGEXP on IR @@ -7009,14 +7107,16 @@ longest_path_length (state_t state) arc_t arc; int length, result; - if (state->longest_path_length == ON_THE_PATH) - /* We don't expect the path cycle here. Our graph may contain - only cycles with one state on the path not containing `cycle - advance' arcs -- see comment below. */ - abort (); - else if (state->longest_path_length != UNDEFINED_LONGEST_PATH_LENGTH) - /* We already visited the state. */ - return state->longest_path_length; + if (state->longest_path_length != UNDEFINED_LONGEST_PATH_LENGTH) + { + /* We don't expect the path cycle here. Our graph may contain + only cycles with one state on the path not containing `cycle + advance' arcs -- see comment below. */ + gcc_assert (state->longest_path_length != ON_THE_PATH); + + /* We already visited the state. */ + return state->longest_path_length; + } result = 0; for (arc = first_out_arc (state); arc != NULL; arc = next_out_arc (arc)) @@ -7064,8 +7164,7 @@ output_dfa_max_issue_rate (void) { automaton_t automaton; - if (UNDEFINED_LONGEST_PATH_LENGTH == ON_THE_PATH || ON_THE_PATH >= 0) - abort (); + gcc_assert (UNDEFINED_LONGEST_PATH_LENGTH != ON_THE_PATH && ON_THE_PATH < 0); max_dfa_issue_rate = 0; for (automaton = description->first_automaton; automaton != NULL; @@ -7533,7 +7632,7 @@ output_state_ainsn_table (state_ainsn_table_t tab, char *table_name, } /* The following function adds vector with length VECT_LENGTH and - elements pointed by VECT to table TAB as its line with number + elements pointed to by VECT to table TAB as its line with number VECT_NUM. */ static void add_vect (state_ainsn_table_t tab, int vect_num, vect_el_t *vect, @@ -7550,20 +7649,19 @@ add_vect (state_ainsn_table_t tab, int vect_num, vect_el_t *vect, int no_state_value; vect_el_t vect_el; int i; + unsigned long vect_mask, comb_vect_mask; - if (vect_length == 0) - abort (); + gcc_assert (vect_length); real_vect_length = tab->automaton->insn_equiv_classes_num; - if (vect [vect_length - 1] == undefined_vect_el_value) - abort (); + gcc_assert (vect [vect_length - 1] != undefined_vect_el_value); /* Form full vector in the table: */ for (i = 0; i < vect_length; i++) VLA_HWINT (tab->full_vect, i + tab->automaton->insn_equiv_classes_num * vect_num) = vect [i]; /* Form comb vector in the table: */ - if (VLA_HWINT_LENGTH (tab->comb_vect) != VLA_HWINT_LENGTH (tab->check_vect)) - abort (); + gcc_assert (VLA_HWINT_LENGTH (tab->comb_vect) + == VLA_HWINT_LENGTH (tab->check_vect)); comb_vect_start = VLA_HWINT_BEGIN (tab->comb_vect); comb_vect_els_num = VLA_HWINT_LENGTH (tab->comb_vect); for (first_unempty_vect_index = 0; @@ -7571,23 +7669,77 @@ add_vect (state_ainsn_table_t tab, int vect_num, vect_el_t *vect, first_unempty_vect_index++) if (vect [first_unempty_vect_index] != undefined_vect_el_value) break; + /* Search for the place in comb vect for the inserted vect. */ - for (comb_vect_index = 0; - comb_vect_index < comb_vect_els_num; - comb_vect_index++) - { - for (vect_index = first_unempty_vect_index; - vect_index < vect_length - && vect_index + comb_vect_index < comb_vect_els_num; - vect_index++) - if (vect [vect_index] != undefined_vect_el_value - && (comb_vect_start [vect_index + comb_vect_index] - != undefined_vect_el_value)) - break; - if (vect_index >= vect_length - || vect_index + comb_vect_index >= comb_vect_els_num) - break; + + /* Slow case. */ + if (vect_length - first_unempty_vect_index >= SIZEOF_LONG * CHAR_BIT) + { + for (comb_vect_index = 0; + comb_vect_index < comb_vect_els_num; + comb_vect_index++) + { + for (vect_index = first_unempty_vect_index; + vect_index < vect_length + && vect_index + comb_vect_index < comb_vect_els_num; + vect_index++) + if (vect [vect_index] != undefined_vect_el_value + && (comb_vect_start [vect_index + comb_vect_index] + != undefined_vect_el_value)) + break; + if (vect_index >= vect_length + || vect_index + comb_vect_index >= comb_vect_els_num) + break; + } + goto found; + } + + /* Fast case. */ + vect_mask = 0; + for (vect_index = first_unempty_vect_index; + vect_index < vect_length; + vect_index++) + { + vect_mask = vect_mask << 1; + if (vect [vect_index] != undefined_vect_el_value) + vect_mask |= 1; + } + + /* Search for the place in comb vect for the inserted vect. */ + comb_vect_index = 0; + if (comb_vect_els_num == 0) + goto found; + + comb_vect_mask = 0; + for (vect_index = first_unempty_vect_index; + vect_index < vect_length && vect_index < comb_vect_els_num; + vect_index++) + { + comb_vect_mask <<= 1; + if (vect_index + comb_vect_index < comb_vect_els_num + && comb_vect_start [vect_index + comb_vect_index] + != undefined_vect_el_value) + comb_vect_mask |= 1; + } + if ((vect_mask & comb_vect_mask) == 0) + goto found; + + for (comb_vect_index = 1, i = vect_length; i < comb_vect_els_num; + comb_vect_index++, i++) + { + comb_vect_mask = (comb_vect_mask << 1) | 1; + comb_vect_mask ^= comb_vect_start [i] == undefined_vect_el_value; + if ((vect_mask & comb_vect_mask) == 0) + goto found; + } + for ( ; comb_vect_index < comb_vect_els_num; comb_vect_index++) + { + comb_vect_mask <<= 1; + if ((vect_mask & comb_vect_mask) == 0) + goto found; } + + found: /* Slot was found. */ additional_els_num = comb_vect_index + real_vect_length - comb_vect_els_num; if (additional_els_num < 0) @@ -7603,19 +7755,16 @@ add_vect (state_ainsn_table_t tab, int vect_num, vect_el_t *vect, } comb_vect_start = VLA_HWINT_BEGIN (tab->comb_vect); check_vect_start = VLA_HWINT_BEGIN (tab->check_vect); - if (VLA_HWINT_LENGTH (tab->comb_vect) - < (size_t) (comb_vect_index + real_vect_length)) - abort (); + gcc_assert (VLA_HWINT_LENGTH (tab->comb_vect) + >= (size_t) (comb_vect_index + real_vect_length)); /* Fill comb and check vectors. */ for (vect_index = 0; vect_index < vect_length; vect_index++) if (vect [vect_index] != undefined_vect_el_value) { - if (comb_vect_start [comb_vect_index + vect_index] - != undefined_vect_el_value) - abort (); + gcc_assert (comb_vect_start [comb_vect_index + vect_index] + == undefined_vect_el_value); comb_vect_start [comb_vect_index + vect_index] = vect [vect_index]; - if (vect [vect_index] < 0) - abort (); + gcc_assert (vect [vect_index] >= 0); if (tab->max_comb_vect_el_value < vect [vect_index]) tab->max_comb_vect_el_value = vect [vect_index]; if (tab->min_comb_vect_el_value > vect [vect_index]) @@ -7643,9 +7792,8 @@ out_state_arcs_num (state_t state) result = 0; for (arc = first_out_arc (state); arc != NULL; arc = next_out_arc (arc)) { - if (arc->insn == NULL) - abort (); - if (arc->insn->first_ainsn_with_given_equialence_num) + gcc_assert (arc->insn); + if (arc->insn->first_ainsn_with_given_equivalence_num) result++; } return result; @@ -7677,8 +7825,7 @@ add_vect_el (vla_hwint_t *vect, ainsn_t ainsn, int el_value) int equiv_class_num; int vect_index; - if (ainsn == NULL) - abort (); + gcc_assert (ainsn); equiv_class_num = ainsn->insn_equiv_class_num; for (vect_index = VLA_HWINT_LENGTH (*vect); vect_index <= equiv_class_num; @@ -7726,9 +7873,8 @@ output_trans_table (automaton_t automaton) arc != NULL; arc = next_out_arc (arc)) { - if (arc->insn == NULL) - abort (); - if (arc->insn->first_ainsn_with_given_equialence_num) + gcc_assert (arc->insn); + if (arc->insn->first_ainsn_with_given_equivalence_num) add_vect_el (&transition_vect, arc->insn, arc->to_state->order_state_num); } @@ -7775,9 +7921,8 @@ output_state_alts_table (automaton_t automaton) arc != NULL; arc = next_out_arc (arc)) { - if (arc->insn == NULL) - abort (); - if (arc->insn->first_ainsn_with_given_equialence_num) + gcc_assert (arc->insn); + if (arc->insn->first_ainsn_with_given_equivalence_num) add_vect_el (&state_alts_vect, arc->insn, arc->state_alts); } add_vect (automaton->state_alts_table, (*state_ptr)->order_state_num, @@ -7886,7 +8031,7 @@ output_min_issue_delay_table (automaton_t automaton) VLA_HWINT (min_issue_delay_vect, i) = 0; automaton->max_min_delay = 0; for (ainsn = automaton->ainsn_list; ainsn != NULL; ainsn = ainsn->next_ainsn) - if (ainsn->first_ainsn_with_given_equialence_num) + if (ainsn->first_ainsn_with_given_equivalence_num) { for (state_ptr = VLA_PTR_BEGIN (output_states_vect); state_ptr <= (state_t *) VLA_PTR_LAST (output_states_vect); @@ -7973,8 +8118,7 @@ output_dead_lock_vect (automaton_t automaton) state_ptr++) { arc = first_out_arc (*state_ptr); - if (arc == NULL) - abort (); + gcc_assert (arc); VLA_HWINT (dead_lock_vect, (*state_ptr)->order_state_num) = (next_out_arc (arc) == NULL && (arc->insn->insn_reserv_decl @@ -8104,8 +8248,7 @@ output_max_insn_queue_index_def (void) } for (i = 0; (1 << i) <= max; i++) ; - if (i < 0) - abort (); + gcc_assert (i >= 0); fprintf (output_file, "\nint max_insn_queue_index = %d;\n\n", (1 << i) - 1); } @@ -8604,7 +8747,7 @@ output_min_insn_conflict_delay_func (void) "int\n%s (%s %s, rtx %s, rtx %s)\n", MIN_INSN_CONFLICT_DELAY_FUNC_NAME, STATE_TYPE_NAME, STATE_NAME, INSN_PARAMETER_NAME, INSN2_PARAMETER_NAME); - fprintf (output_file, "{\n struct %s %s;\n int %s, %s;\n", + fprintf (output_file, "{\n struct %s %s;\n int %s, %s, transition;\n", CHIP_NAME, CHIP_NAME, INTERNAL_INSN_CODE_NAME, INTERNAL_INSN2_CODE_NAME); output_internal_insn_code_evaluation (INSN_PARAMETER_NAME, @@ -8614,8 +8757,9 @@ output_min_insn_conflict_delay_func (void) fprintf (output_file, " memcpy (&%s, %s, sizeof (%s));\n", CHIP_NAME, STATE_NAME, CHIP_NAME); fprintf (output_file, " %s (&%s);\n", INTERNAL_RESET_FUNC_NAME, CHIP_NAME); - fprintf (output_file, " if (%s (%s, &%s) > 0)\n abort ();\n", + fprintf (output_file, " transition = %s (%s, &%s);\n", INTERNAL_TRANSITION_FUNC_NAME, INTERNAL_INSN_CODE_NAME, CHIP_NAME); + fprintf (output_file, " gcc_assert (transition <= 0);\n"); fprintf (output_file, " return %s (%s, &%s);\n", INTERNAL_MIN_ISSUE_DELAY_FUNC_NAME, INTERNAL_INSN2_CODE_NAME, CHIP_NAME); @@ -8638,7 +8782,7 @@ output_internal_insn_latency_func (void) { decl = description->decls[i]; if (DECL_INSN_RESERV (decl)->default_latency > UCHAR_MAX - && tabletype[0] != 'i') /* don't shrink it */ + && tabletype[0] != 'i') /* Don't shrink it. */ tabletype = "unsigned short"; if (DECL_INSN_RESERV (decl)->default_latency > USHRT_MAX) tabletype = "int"; @@ -8666,13 +8810,11 @@ output_internal_insn_latency_func (void) if ((col = (col+1) % 8) == 0) fputs ("\n ", output_file); decl = description->decls[i]; - if (j++ != DECL_INSN_RESERV (decl)->insn_num) - abort (); + gcc_assert (j++ == DECL_INSN_RESERV (decl)->insn_num); fprintf (output_file, "% 4d,", DECL_INSN_RESERV (decl)->default_latency); } - if (j != DECL_INSN_RESERV (advance_cycle_insn_decl)->insn_num) - abort (); + gcc_assert (j == DECL_INSN_RESERV (advance_cycle_insn_decl)->insn_num); fputs ("\n };\n", output_file); fprintf (output_file, " if (%s >= %s || %s >= %s)\n return 0;\n", @@ -8693,9 +8835,9 @@ output_internal_insn_latency_func (void) bypass != NULL; bypass = bypass->next) { - if (bypass->in_insn_reserv->insn_num - == DECL_INSN_RESERV (advance_cycle_insn_decl)->insn_num) - abort (); + gcc_assert (bypass->in_insn_reserv->insn_num + != (DECL_INSN_RESERV + (advance_cycle_insn_decl)->insn_num)); fprintf (output_file, " case %d:\n", bypass->in_insn_reserv->insn_num); if (bypass->bypass_guard_name == NULL) @@ -8765,15 +8907,15 @@ output_print_reservation_func (void) decl = description->decls [i]; if (decl->mode == dm_insn_reserv && decl != advance_cycle_insn_decl) { - if (j++ != DECL_INSN_RESERV (decl)->insn_num) - abort (); + gcc_assert (j == DECL_INSN_RESERV (decl)->insn_num); + j++; + fprintf (output_file, "\n \"%s\",", regexp_representation (DECL_INSN_RESERV (decl)->regexp)); finish_regexp_representation (); } } - if (j != DECL_INSN_RESERV (advance_cycle_insn_decl)->insn_num) - abort (); + gcc_assert (j == DECL_INSN_RESERV (advance_cycle_insn_decl)->insn_num); fprintf (output_file, "\n \"%s\"\n };\n int %s;\n\n", NOTHING_NAME, INTERNAL_INSN_CODE_NAME); @@ -8833,17 +8975,15 @@ output_get_cpu_unit_code_func (void) int i; unit_decl_t *units; - fprintf (output_file, "int\n%s (%s)\n\tconst char *%s;\n", - GET_CPU_UNIT_CODE_FUNC_NAME, CPU_UNIT_NAME_PARAMETER_NAME, - CPU_UNIT_NAME_PARAMETER_NAME); + fprintf (output_file, "int\n%s (const char *%s)\n", + GET_CPU_UNIT_CODE_FUNC_NAME, CPU_UNIT_NAME_PARAMETER_NAME); fprintf (output_file, "{\n struct %s {const char *%s; int %s;};\n", NAME_CODE_STRUCT_NAME, NAME_MEMBER_NAME, CODE_MEMBER_NAME); fprintf (output_file, " int %s, %s, %s, %s;\n", CMP_VARIABLE_NAME, LOW_VARIABLE_NAME, MIDDLE_VARIABLE_NAME, HIGH_VARIABLE_NAME); fprintf (output_file, " static struct %s %s [] =\n {\n", NAME_CODE_STRUCT_NAME, NAME_CODE_TABLE_NAME); - units = (unit_decl_t *) xmalloc (sizeof (unit_decl_t) - * description->units_num); + units = xmalloc (sizeof (unit_decl_t) * description->units_num); memcpy (units, units_array, sizeof (unit_decl_t) * description->units_num); qsort (units, description->units_num, sizeof (unit_decl_t), units_cmp); for (i = 0; i < description->units_num; i++) @@ -8883,11 +9023,11 @@ output_cpu_unit_reservation_p (void) { automaton_t automaton; - fprintf (output_file, "int\n%s (%s, %s)\n\t%s %s;\n\tint %s;\n", - CPU_UNIT_RESERVATION_P_FUNC_NAME, STATE_NAME, - CPU_CODE_PARAMETER_NAME, STATE_TYPE_NAME, STATE_NAME, + fprintf (output_file, "int\n%s (%s %s, int %s)\n", + CPU_UNIT_RESERVATION_P_FUNC_NAME, + STATE_TYPE_NAME, STATE_NAME, CPU_CODE_PARAMETER_NAME); - fprintf (output_file, "{\n if (%s < 0 || %s >= %d)\n abort ();\n", + fprintf (output_file, "{\n gcc_assert (%s >= 0 && %s < %d);\n", CPU_CODE_PARAMETER_NAME, CPU_CODE_PARAMETER_NAME, description->query_units_num); for (automaton = description->first_automaton; @@ -8927,7 +9067,7 @@ output_dfa_start_func (void) fprintf (output_file, "void\n%s (void)\n{\n %s = get_max_uid ();\n", DFA_START_FUNC_NAME, DFA_INSN_CODES_LENGTH_VARIABLE_NAME); - fprintf (output_file, " %s = (int *) xmalloc (%s * sizeof (int));\n", + fprintf (output_file, " %s = xmalloc (%s * sizeof (int));\n", DFA_INSN_CODES_VARIABLE_NAME, DFA_INSN_CODES_LENGTH_VARIABLE_NAME); fprintf (output_file, " %s ();\n}\n\n", DFA_CLEAN_INSN_CACHE_FUNC_NAME); } @@ -9090,7 +9230,7 @@ output_automaton_units (automaton_t automaton) int there_is_an_automaton_unit; int i; - fprintf (output_description_file, "\n Coresponding units:\n"); + fprintf (output_description_file, "\n Corresponding units:\n"); fprintf (output_description_file, " "); curr_line_length = 4; there_is_an_automaton_unit = 0; @@ -9157,8 +9297,7 @@ output_state_arcs (state_t state) for (arc = first_out_arc (state); arc != NULL; arc = next_out_arc (arc)) { ainsn = arc->insn; - if (!ainsn->first_insn_with_same_reservs) - abort (); + gcc_assert (ainsn->first_insn_with_same_reservs); fprintf (output_description_file, " "); curr_line_length = 7; fprintf (output_description_file, "%2d: ", ainsn->insn_equiv_class_num); @@ -9432,8 +9571,7 @@ make_insn_alts_attr (void) insn_num++; } } - if (description->insns_num != insn_num + 1) - abort (); + gcc_assert (description->insns_num == insn_num + 1); make_internal_attr (attr_printf (sizeof ("*") + strlen (INSN_ALTS_FUNC_NAME) + 1, "*%s", INSN_ALTS_FUNC_NAME), @@ -9468,8 +9606,7 @@ make_internal_dfa_insn_code_attr (void) insn_num++; } } - if (description->insns_num != insn_num + 1) - abort (); + gcc_assert (description->insns_num == insn_num + 1); make_internal_attr (attr_printf (sizeof ("*") + strlen (INTERNAL_DFA_INSN_CODE_FUNC_NAME) + 1, @@ -9503,8 +9640,7 @@ make_default_insn_latency_attr (void) insn_num++; } } - if (description->insns_num != insn_num + 1) - abort (); + gcc_assert (description->insns_num == insn_num + 1); make_internal_attr (attr_printf (sizeof ("*") + strlen (INSN_DEFAULT_LATENCY_FUNC_NAME) + 1, "*%s", INSN_DEFAULT_LATENCY_FUNC_NAME), @@ -9616,6 +9752,7 @@ initiate_automaton_gen (int argc, char **argv) time_flag = 0; v_flag = 0; w_flag = 0; + progress_flag = 0; for (i = 2; i < argc; i++) if (strcmp (argv [i], NO_MINIMIZATION_OPTION) == 0) no_minimization_flag = 1; @@ -9627,6 +9764,8 @@ initiate_automaton_gen (int argc, char **argv) w_flag = 1; else if (strcmp (argv [i], NDFA_OPTION) == 0) ndfa_flag = 1; + else if (strcmp (argv [i], PROGRESS_OPTION) == 0) + progress_flag = 1; else if (strcmp (argv [i], "-split") == 0) { if (i + 1 >= argc) @@ -9680,7 +9819,7 @@ check_automata_insn_issues (void) reserv_ainsn->insn_reserv_decl->name); else warning - ("Automaton `%s': Insn `%s' will never be issued", + (0, "Automaton `%s': Insn `%s' will never be issued", automaton->corresponding_automaton_decl->name, reserv_ainsn->insn_reserv_decl->name); } @@ -9690,7 +9829,7 @@ check_automata_insn_issues (void) error ("Insn `%s' will never be issued", reserv_ainsn->insn_reserv_decl->name); else - warning ("Insn `%s' will never be issued", + warning (0, "Insn `%s' will never be issued", reserv_ainsn->insn_reserv_decl->name); } } @@ -9739,8 +9878,7 @@ form_important_insn_automata_lists (void) arc = next_out_arc (arc)) if (arc->to_state != *state_ptr) { - if (!arc->insn->first_insn_with_same_reservs) - abort (); + gcc_assert (arc->insn->first_insn_with_same_reservs); for (ainsn = arc->insn; ainsn != NULL; ainsn = ainsn->next_same_reservs_insn) @@ -9797,10 +9935,11 @@ expand_automata (void) } all_time = create_ticker (); check_time = create_ticker (); - fprintf (stderr, "Check description..."); - fflush (stderr); + if (progress_flag) + fprintf (stderr, "Check description..."); check_all_description (); - fprintf (stderr, "done\n"); + if (progress_flag) + fprintf (stderr, "done\n"); ticker_off (&check_time); generation_time = create_ticker (); if (!have_error) @@ -9816,18 +9955,19 @@ expand_automata (void) if (!have_error) { form_important_insn_automata_lists (); - fprintf (stderr, "Generation of attributes..."); - fflush (stderr); + if (progress_flag) + fprintf (stderr, "Generation of attributes..."); make_internal_dfa_insn_code_attr (); make_insn_alts_attr (); make_default_insn_latency_attr (); make_bypass_attr (); - fprintf (stderr, "done\n"); + if (progress_flag) + fprintf (stderr, "done\n"); } ticker_off (&generation_time); ticker_off (&all_time); - fprintf (stderr, "All other genattrtab stuff..."); - fflush (stderr); + if (progress_flag) + fprintf (stderr, "All other genattrtab stuff..."); } /* The following is top level function to output PHR and to finish @@ -9835,18 +9975,21 @@ expand_automata (void) void write_automata (void) { - fprintf (stderr, "done\n"); + if (progress_flag) + fprintf (stderr, "done\n"); if (have_error) fatal ("Errors in DFA description"); ticker_on (&all_time); output_time = create_ticker (); - fprintf (stderr, "Forming and outputting automata tables..."); - fflush (stderr); + if (progress_flag) + fprintf (stderr, "Forming and outputting automata tables..."); output_dfa_max_issue_rate (); output_tables (); - fprintf (stderr, "done\n"); - fprintf (stderr, "Output functions to work with automata..."); - fflush (stderr); + if (progress_flag) + { + fprintf (stderr, "done\n"); + fprintf (stderr, "Output functions to work with automata..."); + } output_chip_definitions (); output_max_insn_queue_index_def (); output_internal_min_issue_delay_func (); @@ -9881,7 +10024,8 @@ write_automata (void) output_dfa_clean_insn_cache_func (); output_dfa_start_func (); output_dfa_finish_func (); - fprintf (stderr, "done\n"); + if (progress_flag) + fprintf (stderr, "done\n"); if (v_flag) { output_description_file = fopen (output_description_file_name, "w"); @@ -9890,11 +10034,12 @@ write_automata (void) perror (output_description_file_name); exit (FATAL_EXIT_CODE); } - fprintf (stderr, "Output automata description..."); - fflush (stderr); + if (progress_flag) + fprintf (stderr, "Output automata description..."); output_description (); output_automaton_descriptions (); - fprintf (stderr, "done\n"); + if (progress_flag) + fprintf (stderr, "done\n"); output_statistics (output_description_file); } output_statistics (stderr);