Patch to enable checking IR of genautomata
Vladimir Makarov
vmakarov@redhat.com
Wed Jun 19 16:01:00 GMT 2002
The following patch permits to check correctness of IR of
genautomata. Checking is switched on by --enable-checking in
configure. With the aid of the patch I found some incorrect access to
IR (in 4 places). The most serious problem is described in Jeff Law's
email
http://gcc.gnu.org/ml/gcc/2002-06/msg01232.html
The patch also fixes the found problems. The patch was tested for
alpha, i386, sh, sparc, and pa with checking and without checking. I've
committed the patch into the main line.
Vlad
2002-06-19 Vladimir Makarov <vmakarov@redhat.com>
* genautomata.c (DECL_UNIT, DECL_BYPASS, DECL_AUTOMATON,
DECL_EXCL, DECL_PRESENCE, DECL_ABSENCE, DECL_RESERV,
DECL_INSN_RESERV, REGEXP_UNIT, REGEXP_RESERV, REGEXP_SEQUENCE,
REGEXP_REPEAT, REGEXP_ALLOF, REGEXP_ONEOF): New macros with
checking and without it.
(decl_name, decl_mode_check_failed, regexp_name,
regexp_mode_check_failed): New functions.
(gen_cpu_unit, gen_query_cpu_unit, gen_bypass, gen_excl_set,
gen_presence_set, gen_absence_set, gen_automaton,
gen_regexp_repeat, gen_regexp_allof, gen_regexp_oneof,
gen_regexp_sequence, gen_reserv, gen_insn_reserv,
automaton_decl_hash, automaton_decl_eq_p): Use the macros.
(find_automaton_decl): Ditto. Set up mode of
work_automaton_decl.
(insn_decl_hash, insn_decl_hash, insn_decl_eq_p): Use the
macros.
(find_insn_decl): Ditto. Set up mode of work_insn_decl.
(decl_hash, decl_eq_p): Use the macros.
(find_decl): Ditto. Set up mode of work_decl.
(process_excls, process_presence_absence, process_decls,
check_automaton_usage, process_regexp, process_regexp_decls,
check_usage, loop_in_regexp, check_loops_in_regexps,
process_regexp_cycles, add_advance_cycle_insn_decl,
initiate_states, initiate_excl_sets,
initiate_presence_absence_sets, copy_insn_regexp, transform_1,
transform_2): Use the macros.
(transform_3): Ditto. Check mode before making transformations
of
ALLOF.
(regexp_transform_func, transform_insn_regexps,
process_unit_to_form_the_same_automaton_unit_lists,
form_the_same_automaton_unit_lists_from_regexp,
form_the_same_automaton_unit_lists,
process_seq_for_forming_states, process_alts_for_forming_states,
create_alt_states, form_ainsn_with_same_reservs, make_automaton,
form_arcs_marked_by_insn, NDFA_to_DFA, set_new_cycle_flags,
estimate_one_automaton_bound, compare_max_occ_cycle_nums,
units_to_automata_heuristic_distr, create_ainsns,
units_to_automata_distr, create_automata): Use the macros.
(form_regexp): Ditto. Fix typo in access to fields of ALLOF.
(longest_path_length, min_issue_delay_pass_states,
output_dead_lock_vect, output_tables, output_insn_code_cases,
output_internal_insn_latency_func,
output_print_reservation_func,
output_description, output_automaton_units, generate): Use the
macros.
(make_insn_alts_attr): Ditto. Check case when there are not
alternatives in the reservation.
(make_internal_dfa_insn_code_attr,
make_default_insn_latency_attr,
make_bypass_attr, form_important_insn_automata_lists,
expand_automata): Use the macros.
-------------- next part --------------
Index: genautomata.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/genautomata.c,v
retrieving revision 1.16
diff -c -p -r1.16 genautomata.c
*** genautomata.c 18 Jun 2002 16:18:12 -0000 1.16
--- genautomata.c 19 Jun 2002 22:14:42 -0000
*************** struct state_ainsn_table
*** 1238,1243 ****
--- 1238,1465 ----
int min_base_vect_el_value, max_base_vect_el_value;
};
+ /* Macros to access members of unions. Use only them for access to
+ union members of declarations and regexps. */
+
+ #if defined ENABLE_CHECKING && (GCC_VERSION >= 2007)
+
+ #define DECL_UNIT(d) __extension__ \
+ (({ struct decl *_decl = (d); \
+ if (_decl->mode != dm_unit) \
+ decl_mode_check_failed (_decl->mode, "dm_unit", \
+ __FILE__, __LINE__, __FUNCTION__); \
+ &(_decl)->decl.unit; }))
+
+ #define DECL_BYPASS(d) __extension__ \
+ (({ struct decl *_decl = (d); \
+ if (_decl->mode != dm_bypass) \
+ decl_mode_check_failed (_decl->mode, "dm_bypass", \
+ __FILE__, __LINE__, __FUNCTION__); \
+ &(_decl)->decl.bypass; }))
+
+ #define DECL_AUTOMATON(d) __extension__ \
+ (({ struct decl *_decl = (d); \
+ if (_decl->mode != dm_automaton) \
+ decl_mode_check_failed (_decl->mode, "dm_automaton", \
+ __FILE__, __LINE__, __FUNCTION__); \
+ &(_decl)->decl.automaton; }))
+
+ #define DECL_EXCL(d) __extension__ \
+ (({ struct decl *_decl = (d); \
+ if (_decl->mode != dm_excl) \
+ decl_mode_check_failed (_decl->mode, "dm_excl", \
+ __FILE__, __LINE__, __FUNCTION__); \
+ &(_decl)->decl.excl; }))
+
+ #define DECL_PRESENCE(d) __extension__ \
+ (({ struct decl *_decl = (d); \
+ if (_decl->mode != dm_presence) \
+ decl_mode_check_failed (_decl->mode, "dm_presence", \
+ __FILE__, __LINE__, __FUNCTION__); \
+ &(_decl)->decl.presence; }))
+
+ #define DECL_ABSENCE(d) __extension__ \
+ (({ struct decl *_decl = (d); \
+ if (_decl->mode != dm_absence) \
+ decl_mode_check_failed (_decl->mode, "dm_absence", \
+ __FILE__, __LINE__, __FUNCTION__); \
+ &(_decl)->decl.absence; }))
+
+ #define DECL_RESERV(d) __extension__ \
+ (({ struct decl *_decl = (d); \
+ if (_decl->mode != dm_reserv) \
+ decl_mode_check_failed (_decl->mode, "dm_reserv", \
+ __FILE__, __LINE__, __FUNCTION__); \
+ &(_decl)->decl.reserv; }))
+
+ #define DECL_INSN_RESERV(d) __extension__ \
+ (({ struct decl *_decl = (d); \
+ if (_decl->mode != dm_insn_reserv) \
+ decl_mode_check_failed (_decl->mode, "dm_insn_reserv", \
+ __FILE__, __LINE__, __FUNCTION__); \
+ &(_decl)->decl.insn_reserv; }))
+
+ static const char *decl_name PARAMS ((enum decl_mode));
+ static void decl_mode_check_failed PARAMS ((enum decl_mode, const char *,
+ const char *, int, const char *));
+
+ /* Return string representation of declaration mode MODE. */
+ static const char *
+ decl_name (mode)
+ enum decl_mode mode;
+ {
+ static char str [100];
+
+ if (mode == dm_unit)
+ return "dm_unit";
+ else if (mode == dm_bypass)
+ return "dm_bypass";
+ else if (mode == dm_automaton)
+ return "dm_automaton";
+ else if (mode == dm_excl)
+ return "dm_excl";
+ else if (mode == dm_presence)
+ return "dm_presence";
+ else if (mode == dm_absence)
+ return "dm_absence";
+ else if (mode == dm_reserv)
+ return "dm_reserv";
+ else if (mode == dm_insn_reserv)
+ return "dm_insn_reserv";
+ else
+ sprintf (str, "unknown (%d)", (int) mode);
+ return str;
+ }
+
+ /* The function prints message about unexpected declaration and finish
+ the program. */
+ static void
+ decl_mode_check_failed (mode, expected_mode_str, file, line, func)
+ enum decl_mode mode;
+ const char *expected_mode_str;
+ const char *file;
+ int line;
+ const char *func;
+ {
+ fprintf
+ (stderr,
+ "\n%s: %d: error in %s: DECL check: expected decl %s, have %s\n",
+ file, line, func, expected_mode_str, decl_name (mode));
+ exit (1);
+ }
+
+
+ #define REGEXP_UNIT(r) __extension__ \
+ (({ struct regexp *_regexp = (r); \
+ if (_regexp->mode != rm_unit) \
+ regexp_mode_check_failed (_regexp->mode, "rm_unit", \
+ __FILE__, __LINE__, __FUNCTION__); \
+ &(_regexp)->regexp.unit; }))
+
+ #define REGEXP_RESERV(r) __extension__ \
+ (({ struct regexp *_regexp = (r); \
+ if (_regexp->mode != rm_reserv) \
+ regexp_mode_check_failed (_regexp->mode, "rm_reserv", \
+ __FILE__, __LINE__, __FUNCTION__); \
+ &(_regexp)->regexp.reserv; }))
+
+ #define REGEXP_SEQUENCE(r) __extension__ \
+ (({ struct regexp *_regexp = (r); \
+ if (_regexp->mode != rm_sequence) \
+ regexp_mode_check_failed (_regexp->mode, "rm_sequence", \
+ __FILE__, __LINE__, __FUNCTION__); \
+ &(_regexp)->regexp.sequence; }))
+
+ #define REGEXP_REPEAT(r) __extension__ \
+ (({ struct regexp *_regexp = (r); \
+ if (_regexp->mode != rm_repeat) \
+ regexp_mode_check_failed (_regexp->mode, "rm_repeat", \
+ __FILE__, __LINE__, __FUNCTION__); \
+ &(_regexp)->regexp.repeat; }))
+
+ #define REGEXP_ALLOF(r) __extension__ \
+ (({ struct regexp *_regexp = (r); \
+ if (_regexp->mode != rm_allof) \
+ regexp_mode_check_failed (_regexp->mode, "rm_allof", \
+ __FILE__, __LINE__, __FUNCTION__); \
+ &(_regexp)->regexp.allof; }))
+
+ #define REGEXP_ONEOF(r) __extension__ \
+ (({ struct regexp *_regexp = (r); \
+ if (_regexp->mode != rm_oneof) \
+ regexp_mode_check_failed (_regexp->mode, "rm_oneof", \
+ __FILE__, __LINE__, __FUNCTION__); \
+ &(_regexp)->regexp.oneof; }))
+
+ static const char *regexp_name PARAMS ((enum regexp_mode));
+ static void regexp_mode_check_failed PARAMS ((enum regexp_mode, const char *,
+ const char *, int,
+ const char *));
+
+
+ /* Return string representation of regexp mode MODE. */
+ static const char *
+ regexp_name (mode)
+ 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;
+ }
+
+ /* The function prints message about unexpected regexp and finish the
+ program. */
+ static void
+ regexp_mode_check_failed (mode, expected_mode_str, file, line, func)
+ enum regexp_mode mode;
+ const char *expected_mode_str;
+ const char *file;
+ int line;
+ const char *func;
+ {
+ fprintf
+ (stderr,
+ "\n%s: %d: error in %s: REGEXP check: expected decl %s, have %s\n",
+ file, line, func, expected_mode_str, regexp_name (mode));
+ exit (1);
+ }
+
+ #else /* #if defined ENABLE_RTL_CHECKING && (GCC_VERSION >= 2007) */
+
+ #define DECL_UNIT(d) (&(d)->decl.unit)
+ #define DECL_BYPASS(d) (&(d)->decl.bypass)
+ #define DECL_AUTOMATON(d) (&(d)->decl.automaton)
+ #define DECL_EXCL(d) (&(d)->decl.excl)
+ #define DECL_PRESENCE(d) (&(d)->decl.presence)
+ #define DECL_ABSENCE(d) (&(d)->decl.absence)
+ #define DECL_RESERV(d) (&(d)->decl.reserv)
+ #define DECL_INSN_RESERV(d) (&(d)->decl.insn_reserv)
+
+ #define REGEXP_UNIT(r) (&(r)->regexp.unit)
+ #define REGEXP_RESERV(r) (&(r)->regexp.reserv)
+ #define REGEXP_SEQUENCE(r) (&(r)->regexp.sequence)
+ #define REGEXP_REPEAT(r) (&(r)->regexp.repeat)
+ #define REGEXP_ALLOF(r) (&(r)->regexp.allof)
+ #define REGEXP_ONEOF(r) (&(r)->regexp.oneof)
+
+ #endif /* #if defined ENABLE_RTL_CHECKING && (GCC_VERSION >= 2007) */
+
/* Create IR structure (node). */
static void *
create_node (size)
*************** gen_cpu_unit (def)
*** 1412,1420 ****
decl = create_node (sizeof (struct decl));
decl->mode = dm_unit;
decl->pos = 0;
! decl->decl.unit.name = check_name (str_cpu_units [i], decl->pos);
! decl->decl.unit.automaton_name = (char *) XSTR (def, 1);
! decl->decl.unit.query_p = 0;
VLA_PTR_ADD (decls, decl);
num_dfa_decls++;
}
--- 1634,1642 ----
decl = create_node (sizeof (struct decl));
decl->mode = dm_unit;
decl->pos = 0;
! DECL_UNIT (decl)->name = check_name (str_cpu_units [i], decl->pos);
! DECL_UNIT (decl)->automaton_name = (char *) XSTR (def, 1);
! DECL_UNIT (decl)->query_p = 0;
VLA_PTR_ADD (decls, decl);
num_dfa_decls++;
}
*************** gen_query_cpu_unit (def)
*** 1441,1449 ****
decl = create_node (sizeof (struct decl));
decl->mode = dm_unit;
decl->pos = 0;
! decl->decl.unit.name = check_name (str_cpu_units [i], decl->pos);
! decl->decl.unit.automaton_name = (char *) XSTR (def, 1);
! decl->decl.unit.query_p = 1;
VLA_PTR_ADD (decls, decl);
num_dfa_decls++;
}
--- 1663,1671 ----
decl = create_node (sizeof (struct decl));
decl->mode = dm_unit;
decl->pos = 0;
! DECL_UNIT (decl)->name = check_name (str_cpu_units [i], decl->pos);
! DECL_UNIT (decl)->automaton_name = (char *) XSTR (def, 1);
! DECL_UNIT (decl)->query_p = 1;
VLA_PTR_ADD (decls, decl);
num_dfa_decls++;
}
*************** gen_bypass (def)
*** 1477,1486 ****
decl = create_node (sizeof (struct decl));
decl->mode = dm_bypass;
decl->pos = 0;
! decl->decl.bypass.latency = XINT (def, 0);
! decl->decl.bypass.out_insn_name = out_insns [i];
! decl->decl.bypass.in_insn_name = in_insns [j];
! decl->decl.bypass.bypass_guard_name = (char *) XSTR (def, 3);
VLA_PTR_ADD (decls, decl);
num_dfa_decls++;
}
--- 1699,1708 ----
decl = create_node (sizeof (struct decl));
decl->mode = dm_bypass;
decl->pos = 0;
! DECL_BYPASS (decl)->latency = XINT (def, 0);
! DECL_BYPASS (decl)->out_insn_name = out_insns [i];
! DECL_BYPASS (decl)->in_insn_name = in_insns [j];
! DECL_BYPASS (decl)->bypass_guard_name = (char *) XSTR (def, 3);
VLA_PTR_ADD (decls, decl);
num_dfa_decls++;
}
*************** gen_excl_set (def)
*** 1514,1526 ****
decl = create_node (sizeof (struct decl) + (length - 1) * sizeof (char *));
decl->mode = dm_excl;
decl->pos = 0;
! decl->decl.excl.names_num = length;
! decl->decl.excl.first_list_length = first_vect_length;
for (i = 0; i < length; i++)
if (i < first_vect_length)
! decl->decl.excl.names [i] = first_str_cpu_units [i];
else
! decl->decl.excl.names [i] = second_str_cpu_units [i - first_vect_length];
VLA_PTR_ADD (decls, decl);
num_dfa_decls++;
}
--- 1736,1749 ----
decl = create_node (sizeof (struct decl) + (length - 1) * sizeof (char *));
decl->mode = dm_excl;
decl->pos = 0;
! DECL_EXCL (decl)->names_num = length;
! DECL_EXCL (decl)->first_list_length = first_vect_length;
for (i = 0; i < length; i++)
if (i < first_vect_length)
! DECL_EXCL (decl)->names [i] = first_str_cpu_units [i];
else
! DECL_EXCL (decl)->names [i]
! = second_str_cpu_units [i - first_vect_length];
VLA_PTR_ADD (decls, decl);
num_dfa_decls++;
}
*************** gen_presence_set (def)
*** 1553,1565 ****
decl = create_node (sizeof (struct decl) + (length - 1) * sizeof (char *));
decl->mode = dm_presence;
decl->pos = 0;
! decl->decl.presence.names_num = length;
! decl->decl.presence.first_list_length = first_vect_length;
for (i = 0; i < length; i++)
if (i < first_vect_length)
! decl->decl.presence.names [i] = first_str_cpu_units [i];
else
! decl->decl.presence.names [i]
= second_str_cpu_units [i - first_vect_length];
VLA_PTR_ADD (decls, decl);
num_dfa_decls++;
--- 1776,1788 ----
decl = create_node (sizeof (struct decl) + (length - 1) * sizeof (char *));
decl->mode = dm_presence;
decl->pos = 0;
! DECL_PRESENCE (decl)->names_num = length;
! DECL_PRESENCE (decl)->first_list_length = first_vect_length;
for (i = 0; i < length; i++)
if (i < first_vect_length)
! DECL_PRESENCE (decl)->names [i] = first_str_cpu_units [i];
else
! DECL_PRESENCE (decl)->names [i]
= second_str_cpu_units [i - first_vect_length];
VLA_PTR_ADD (decls, decl);
num_dfa_decls++;
*************** gen_absence_set (def)
*** 1593,1605 ****
decl = create_node (sizeof (struct decl) + (length - 1) * sizeof (char *));
decl->mode = dm_absence;
decl->pos = 0;
! decl->decl.absence.names_num = length;
! decl->decl.absence.first_list_length = first_vect_length;
for (i = 0; i < length; i++)
if (i < first_vect_length)
! decl->decl.absence.names [i] = first_str_cpu_units [i];
else
! decl->decl.absence.names [i]
= second_str_cpu_units [i - first_vect_length];
VLA_PTR_ADD (decls, decl);
num_dfa_decls++;
--- 1816,1828 ----
decl = create_node (sizeof (struct decl) + (length - 1) * sizeof (char *));
decl->mode = dm_absence;
decl->pos = 0;
! DECL_ABSENCE (decl)->names_num = length;
! DECL_ABSENCE (decl)->first_list_length = first_vect_length;
for (i = 0; i < length; i++)
if (i < first_vect_length)
! DECL_ABSENCE (decl)->names [i] = first_str_cpu_units [i];
else
! DECL_ABSENCE (decl)->names [i]
= second_str_cpu_units [i - first_vect_length];
VLA_PTR_ADD (decls, decl);
num_dfa_decls++;
*************** gen_automaton (def)
*** 1627,1633 ****
decl = create_node (sizeof (struct decl));
decl->mode = dm_automaton;
decl->pos = 0;
! decl->decl.automaton.name = check_name (str_automata [i], decl->pos);
VLA_PTR_ADD (decls, decl);
num_dfa_decls++;
}
--- 1850,1856 ----
decl = create_node (sizeof (struct decl));
decl->mode = dm_automaton;
decl->pos = 0;
! DECL_AUTOMATON (decl)->name = check_name (str_automata [i], decl->pos);
VLA_PTR_ADD (decls, decl);
num_dfa_decls++;
}
*************** gen_regexp_el (str)
*** 1687,1693 ****
{
regexp = create_node (sizeof (struct decl));
regexp->mode = rm_unit;
! regexp->regexp.unit.name = str;
}
return regexp;
}
--- 1910,1916 ----
{
regexp = create_node (sizeof (struct decl));
regexp->mode = rm_unit;
! REGEXP_UNIT (regexp)->name = str;
}
return regexp;
}
*************** gen_regexp_repeat (str)
*** 1713,1721 ****
{
repeat = create_node (sizeof (struct regexp));
repeat->mode = rm_repeat;
! repeat->regexp.repeat.regexp = regexp;
! repeat->regexp.repeat.repeat_num = atoi (repeat_vect [i]);
! if (repeat->regexp.repeat.repeat_num <= 1)
fatal ("repetition `%s' <= 1 in reservation `%s'",
str, reserv_str);
regexp = repeat;
--- 1936,1944 ----
{
repeat = create_node (sizeof (struct regexp));
repeat->mode = rm_repeat;
! REGEXP_REPEAT (repeat)->regexp = regexp;
! REGEXP_REPEAT (repeat)->repeat_num = atoi (repeat_vect [i]);
! if (REGEXP_REPEAT (repeat)->repeat_num <= 1)
fatal ("repetition `%s' <= 1 in reservation `%s'",
str, reserv_str);
regexp = repeat;
*************** gen_regexp_allof (str)
*** 1744,1752 ****
allof = create_node (sizeof (struct regexp)
+ sizeof (regexp_t) * (els_num - 1));
allof->mode = rm_allof;
! allof->regexp.allof.regexps_num = els_num;
for (i = 0; i < els_num; i++)
! allof->regexp.allof.regexps [i] = gen_regexp_repeat (allof_vect [i]);
return allof;
}
else
--- 1967,1975 ----
allof = create_node (sizeof (struct regexp)
+ sizeof (regexp_t) * (els_num - 1));
allof->mode = rm_allof;
! REGEXP_ALLOF (allof)->regexps_num = els_num;
for (i = 0; i < els_num; i++)
! REGEXP_ALLOF (allof)->regexps [i] = gen_regexp_repeat (allof_vect [i]);
return allof;
}
else
*************** gen_regexp_oneof (str)
*** 1771,1779 ****
oneof = create_node (sizeof (struct regexp)
+ sizeof (regexp_t) * (els_num - 1));
oneof->mode = rm_oneof;
! oneof->regexp.oneof.regexps_num = els_num;
for (i = 0; i < els_num; i++)
! oneof->regexp.oneof.regexps [i] = gen_regexp_allof (oneof_vect [i]);
return oneof;
}
else
--- 1994,2002 ----
oneof = create_node (sizeof (struct regexp)
+ sizeof (regexp_t) * (els_num - 1));
oneof->mode = rm_oneof;
! REGEXP_ONEOF (oneof)->regexps_num = els_num;
for (i = 0; i < els_num; i++)
! REGEXP_ONEOF (oneof)->regexps [i] = gen_regexp_allof (oneof_vect [i]);
return oneof;
}
else
*************** gen_regexp_sequence (str)
*** 1796,1804 ****
sequence = create_node (sizeof (struct regexp)
+ sizeof (regexp_t) * (els_num - 1));
sequence->mode = rm_sequence;
! sequence->regexp.sequence.regexps_num = els_num;
for (i = 0; i < els_num; i++)
! sequence->regexp.sequence.regexps [i]
= gen_regexp_oneof (sequence_vect [i]);
return sequence;
}
--- 2019,2027 ----
sequence = create_node (sizeof (struct regexp)
+ sizeof (regexp_t) * (els_num - 1));
sequence->mode = rm_sequence;
! REGEXP_SEQUENCE (sequence)->regexps_num = els_num;
for (i = 0; i < els_num; i++)
! REGEXP_SEQUENCE (sequence)->regexps [i]
= gen_regexp_oneof (sequence_vect [i]);
return sequence;
}
*************** gen_reserv (def)
*** 1829,1836 ****
decl = create_node (sizeof (struct decl));
decl->mode = dm_reserv;
decl->pos = 0;
! decl->decl.reserv.name = check_name ((char *) XSTR (def, 0), decl->pos);
! decl->decl.reserv.regexp = gen_regexp ((char *) XSTR (def, 1));
VLA_PTR_ADD (decls, decl);
num_dfa_decls++;
}
--- 2052,2059 ----
decl = create_node (sizeof (struct decl));
decl->mode = dm_reserv;
decl->pos = 0;
! DECL_RESERV (decl)->name = check_name ((char *) XSTR (def, 0), decl->pos);
! DECL_RESERV (decl)->regexp = gen_regexp ((char *) XSTR (def, 1));
VLA_PTR_ADD (decls, decl);
num_dfa_decls++;
}
*************** gen_insn_reserv (def)
*** 1849,1858 ****
decl = create_node (sizeof (struct decl));
decl->mode = dm_insn_reserv;
decl->pos = 0;
! decl->decl.insn_reserv.name = check_name ((char *) XSTR (def, 0), decl->pos);
! decl->decl.insn_reserv.default_latency = XINT (def, 1);
! decl->decl.insn_reserv.condexp = XEXP (def, 2);
! decl->decl.insn_reserv.regexp = gen_regexp ((char *) XSTR (def, 3));
VLA_PTR_ADD (decls, decl);
num_dfa_decls++;
}
--- 2072,2082 ----
decl = create_node (sizeof (struct decl));
decl->mode = dm_insn_reserv;
decl->pos = 0;
! DECL_INSN_RESERV (decl)->name
! = check_name ((char *) XSTR (def, 0), decl->pos);
! DECL_INSN_RESERV (decl)->default_latency = XINT (def, 1);
! DECL_INSN_RESERV (decl)->condexp = XEXP (def, 2);
! DECL_INSN_RESERV (decl)->regexp = gen_regexp ((char *) XSTR (def, 3));
VLA_PTR_ADD (decls, decl);
num_dfa_decls++;
}
*************** automaton_decl_hash (automaton_decl)
*** 1887,1895 ****
{
const decl_t decl = (decl_t) automaton_decl;
! if (decl->mode == dm_automaton && decl->decl.automaton.name == NULL)
abort ();
! return string_hash (decl->decl.automaton.name);
}
/* The function tests automaton declarations on equality of their
--- 2111,2119 ----
{
const decl_t decl = (decl_t) automaton_decl;
! if (decl->mode == dm_automaton && DECL_AUTOMATON (decl)->name == NULL)
abort ();
! return string_hash (DECL_AUTOMATON (decl)->name);
}
/* The function tests automaton declarations on equality of their
*************** automaton_decl_eq_p (automaton_decl_1, a
*** 1904,1913 ****
const decl_t decl1 = (decl_t) automaton_decl_1;
const decl_t decl2 = (decl_t) automaton_decl_2;
! if (decl1->mode != dm_automaton || decl1->decl.automaton.name == NULL
! || decl2->mode != dm_automaton || decl2->decl.automaton.name == NULL)
abort ();
! return strcmp (decl1->decl.automaton.name, decl2->decl.automaton.name) == 0;
}
/* The automaton declaration table itself is represented by the
--- 2128,2138 ----
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 ();
! return strcmp (DECL_AUTOMATON (decl1)->name,
! DECL_AUTOMATON (decl2)->name) == 0;
}
/* The automaton declaration table itself is represented by the
*************** find_automaton_decl (name)
*** 1946,1952 ****
{
void *entry;
! work_automaton_decl.decl.automaton.name = name;
entry = htab_find (automaton_decl_table, &work_automaton_decl);
return (decl_t) entry;
}
--- 2171,2178 ----
{
void *entry;
! work_automaton_decl.mode = dm_automaton;
! DECL_AUTOMATON (&work_automaton_decl)->name = name;
entry = htab_find (automaton_decl_table, &work_automaton_decl);
return (decl_t) entry;
}
*************** insn_decl_hash (insn_decl)
*** 1989,1997 ****
{
const decl_t decl = (decl_t) insn_decl;
! if (decl->mode != dm_insn_reserv || decl->decl.insn_reserv.name == NULL)
abort ();
! return string_hash (decl->decl.insn_reserv.name);
}
/* The function tests insn declarations on equality of their keys.
--- 2215,2223 ----
{
const decl_t decl = (decl_t) insn_decl;
! if (decl->mode != dm_insn_reserv || DECL_INSN_RESERV (decl)->name == NULL)
abort ();
! return string_hash (DECL_INSN_RESERV (decl)->name);
}
/* The function tests insn declarations on equality of their keys.
*************** insn_decl_eq_p (insn_decl_1, insn_decl_2
*** 2005,2015 ****
const decl_t decl1 = (decl_t) insn_decl_1;
const decl_t decl2 = (decl_t) insn_decl_2;
! if (decl1->mode != dm_insn_reserv || decl1->decl.insn_reserv.name == NULL
! || decl2->mode != dm_insn_reserv || decl2->decl.insn_reserv.name == NULL)
abort ();
! return strcmp (decl1->decl.insn_reserv.name,
! decl2->decl.insn_reserv.name) == 0;
}
/* The insn declaration table itself is represented by the following
--- 2231,2242 ----
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 ();
! return strcmp (DECL_INSN_RESERV (decl1)->name,
! DECL_INSN_RESERV (decl2)->name) == 0;
}
/* The insn declaration table itself is represented by the following
*************** find_insn_decl (name)
*** 2048,2054 ****
{
void *entry;
! work_insn_decl.decl.insn_reserv.name = name;
entry = htab_find (insn_decl_table, &work_insn_decl);
return (decl_t) entry;
}
--- 2275,2282 ----
{
void *entry;
! work_insn_decl.mode = dm_insn_reserv;
! DECL_INSN_RESERV (&work_insn_decl)->name = name;
entry = htab_find (insn_decl_table, &work_insn_decl);
return (decl_t) entry;
}
*************** decl_hash (decl)
*** 2090,2100 ****
{
const decl_t d = (const decl_t) decl;
! if ((d->mode != dm_unit || d->decl.unit.name == NULL)
! && (d->mode != dm_reserv || d->decl.reserv.name == NULL))
abort ();
return string_hash (d->mode == dm_unit
! ? d->decl.unit.name : d->decl.reserv.name);
}
/* The function tests declarations on equality of their keys. The
--- 2318,2328 ----
{
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 ();
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
*************** decl_eq_p (decl_1, decl_2)
*** 2108,2122 ****
const decl_t d1 = (const decl_t) decl_1;
const decl_t d2 = (const decl_t) decl_2;
! if (((d1->mode != dm_unit || d1->decl.unit.name == NULL)
! && (d1->mode != dm_reserv || d1->decl.reserv.name == NULL))
! || ((d2->mode != dm_unit || d2->decl.unit.name == NULL)
! && (d2->mode != dm_reserv || d2->decl.reserv.name == NULL)))
abort ();
return strcmp ((d1->mode == dm_unit
! ? d1->decl.unit.name : d1->decl.reserv.name),
(d2->mode == dm_unit
! ? d2->decl.unit.name : d2->decl.reserv.name)) == 0;
}
/* The declaration table itself is represented by the following
--- 2336,2350 ----
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 ();
return strcmp ((d1->mode == dm_unit
! ? DECL_UNIT (d1)->name : DECL_RESERV (d1)->name),
(d2->mode == dm_unit
! ? DECL_UNIT (d2)->name : DECL_RESERV (d2)->name)) == 0;
}
/* The declaration table itself is represented by the following
*************** find_decl (name)
*** 2154,2160 ****
{
void *entry;
! work_decl.decl.unit.name = name;
entry = htab_find (decl_table, &work_decl);
return (decl_t) entry;
}
--- 2382,2389 ----
{
void *entry;
! work_decl.mode = dm_unit;
! DECL_UNIT (&work_decl)->name = name;
entry = htab_find (decl_table, &work_decl);
return (decl_t) entry;
}
*************** process_excls (names, num, excl_pos)
*** 2209,2215 ****
else
{
new_el = create_node (sizeof (struct unit_set_el));
! new_el->unit_decl = &decl_in_table->decl.unit;
new_el->next_unit_set_el = NULL;
if (last_el == NULL)
el_list = last_el = new_el;
--- 2438,2444 ----
else
{
new_el = create_node (sizeof (struct unit_set_el));
! new_el->unit_decl = DECL_UNIT (decl_in_table);
new_el->next_unit_set_el = NULL;
if (last_el == NULL)
el_list = last_el = new_el;
*************** process_presence_absence (names, num, re
*** 2305,2311 ****
else
{
new_el = create_node (sizeof (struct unit_set_el));
! new_el->unit_decl = &decl_in_table->decl.unit;
new_el->next_unit_set_el = NULL;
if (last_el == NULL)
el_list = last_el = new_el;
--- 2534,2540 ----
else
{
new_el = create_node (sizeof (struct unit_set_el));
! new_el->unit_decl = DECL_UNIT (decl_in_table);
new_el->next_unit_set_el = NULL;
if (last_el == NULL)
el_list = last_el = new_el;
*************** process_decls ()
*** 2471,2480 ****
{
if (!w_flag)
error ("repeated declaration of automaton `%s'",
! decl->decl.automaton.name);
else
warning ("repeated declaration of automaton `%s'",
! decl->decl.automaton.name);
}
}
}
--- 2700,2709 ----
{
if (!w_flag)
error ("repeated declaration of automaton `%s'",
! DECL_AUTOMATON (decl)->name);
else
warning ("repeated declaration of automaton `%s'",
! DECL_AUTOMATON (decl)->name);
}
}
}
*************** process_decls ()
*** 2486,2549 ****
decl = description->decls [i];
if (decl->mode == dm_insn_reserv)
{
! decl->decl.insn_reserv.condexp
! = check_attr_test (decl->decl.insn_reserv.condexp, 0, 0);
! if (decl->decl.insn_reserv.default_latency < 0)
error ("define_insn_reservation `%s' has negative latency time",
! decl->decl.insn_reserv.name);
! decl->decl.insn_reserv.insn_num = description->insns_num;
description->insns_num++;
decl_in_table = insert_insn_decl (decl);
if (decl_in_table != decl)
error ("`%s' is already used as insn reservation name",
! decl->decl.insn_reserv.name);
}
else if (decl->mode == dm_bypass)
{
! if (decl->decl.bypass.latency < 0)
error ("define_bypass `%s - %s' has negative latency time",
! decl->decl.bypass.out_insn_name,
! decl->decl.bypass.in_insn_name);
}
else if (decl->mode == dm_unit || decl->mode == dm_reserv)
{
if (decl->mode == dm_unit)
{
! decl->decl.unit.automaton_decl = NULL;
! if (decl->decl.unit.automaton_name != NULL)
{
automaton_decl
! = find_automaton_decl (decl->decl.unit.automaton_name);
if (automaton_decl == NULL)
error ("automaton `%s' is not declared",
! decl->decl.unit.automaton_name);
else
{
! automaton_decl->decl.automaton.automaton_is_used = 1;
! decl->decl.unit.automaton_decl
! = &automaton_decl->decl.automaton;
}
}
else if (automaton_presence)
error ("define_unit `%s' without automaton when one defined",
! decl->decl.unit.name);
! decl->decl.unit.unit_num = description->units_num;
description->units_num++;
! if (strcmp (decl->decl.unit.name, NOTHING_NAME) == 0)
{
error ("`%s' is declared as cpu unit", NOTHING_NAME);
continue;
}
! decl_in_table = find_decl (decl->decl.unit.name);
}
else
{
! if (strcmp (decl->decl.reserv.name, NOTHING_NAME) == 0)
{
error ("`%s' is declared as cpu reservation", NOTHING_NAME);
continue;
}
! decl_in_table = find_decl (decl->decl.reserv.name);
}
if (decl_in_table == NULL)
decl_in_table = insert_decl (decl);
--- 2715,2778 ----
decl = description->decls [i];
if (decl->mode == dm_insn_reserv)
{
! DECL_INSN_RESERV (decl)->condexp
! = check_attr_test (DECL_INSN_RESERV (decl)->condexp, 0, 0);
! if (DECL_INSN_RESERV (decl)->default_latency < 0)
error ("define_insn_reservation `%s' has negative latency time",
! DECL_INSN_RESERV (decl)->name);
! DECL_INSN_RESERV (decl)->insn_num = description->insns_num;
description->insns_num++;
decl_in_table = insert_insn_decl (decl);
if (decl_in_table != decl)
error ("`%s' is already used as insn reservation name",
! DECL_INSN_RESERV (decl)->name);
}
else if (decl->mode == dm_bypass)
{
! if (DECL_BYPASS (decl)->latency < 0)
error ("define_bypass `%s - %s' has negative latency time",
! DECL_BYPASS (decl)->out_insn_name,
! DECL_BYPASS (decl)->in_insn_name);
}
else if (decl->mode == dm_unit || decl->mode == dm_reserv)
{
if (decl->mode == dm_unit)
{
! DECL_UNIT (decl)->automaton_decl = NULL;
! if (DECL_UNIT (decl)->automaton_name != NULL)
{
automaton_decl
! = find_automaton_decl (DECL_UNIT (decl)->automaton_name);
if (automaton_decl == NULL)
error ("automaton `%s' is not declared",
! DECL_UNIT (decl)->automaton_name);
else
{
! DECL_AUTOMATON (automaton_decl)->automaton_is_used = 1;
! DECL_UNIT (decl)->automaton_decl
! = DECL_AUTOMATON (automaton_decl);
}
}
else if (automaton_presence)
error ("define_unit `%s' without automaton when one defined",
! DECL_UNIT (decl)->name);
! DECL_UNIT (decl)->unit_num = description->units_num;
description->units_num++;
! if (strcmp (DECL_UNIT (decl)->name, NOTHING_NAME) == 0)
{
error ("`%s' is declared as cpu unit", NOTHING_NAME);
continue;
}
! decl_in_table = find_decl (DECL_UNIT (decl)->name);
}
else
{
! if (strcmp (DECL_RESERV (decl)->name, NOTHING_NAME) == 0)
{
error ("`%s' is declared as cpu reservation", NOTHING_NAME);
continue;
}
! decl_in_table = find_decl (DECL_RESERV (decl)->name);
}
if (decl_in_table == NULL)
decl_in_table = insert_decl (decl);
*************** process_decls ()
*** 2551,2560 ****
{
if (decl->mode == dm_unit)
error ("repeated declaration of unit `%s'",
! decl->decl.unit.name);
else
error ("repeated declaration of reservation `%s'",
! decl->decl.reserv.name);
}
}
}
--- 2780,2789 ----
{
if (decl->mode == dm_unit)
error ("repeated declaration of unit `%s'",
! DECL_UNIT (decl)->name);
else
error ("repeated declaration of reservation `%s'",
! DECL_RESERV (decl)->name);
}
}
}
*************** process_decls ()
*** 2565,2613 ****
decl = description->decls [i];
if (decl->mode == dm_bypass)
{
! out_insn_reserv = find_insn_decl (decl->decl.bypass.out_insn_name);
! in_insn_reserv = find_insn_decl (decl->decl.bypass.in_insn_name);
if (out_insn_reserv == NULL)
error ("there is no insn reservation `%s'",
! decl->decl.bypass.out_insn_name);
else if (in_insn_reserv == NULL)
error ("there is no insn reservation `%s'",
! decl->decl.bypass.in_insn_name);
else
{
! decl->decl.bypass.out_insn_reserv
! = &out_insn_reserv->decl.insn_reserv;
! decl->decl.bypass.in_insn_reserv
! = &in_insn_reserv->decl.insn_reserv;
bypass
! = find_bypass (out_insn_reserv->decl.insn_reserv.bypass_list,
! decl->decl.bypass.in_insn_reserv);
if (bypass != NULL)
{
! if (decl->decl.bypass.latency == bypass->latency)
{
if (!w_flag)
error
("the same bypass `%s - %s' is already defined",
! decl->decl.bypass.out_insn_name,
! decl->decl.bypass.in_insn_name);
else
warning
("the same bypass `%s - %s' is already defined",
! decl->decl.bypass.out_insn_name,
! decl->decl.bypass.in_insn_name);
}
else
error ("bypass `%s - %s' is already defined",
! decl->decl.bypass.out_insn_name,
! decl->decl.bypass.in_insn_name);
}
else
{
! decl->decl.bypass.next
! = out_insn_reserv->decl.insn_reserv.bypass_list;
! out_insn_reserv->decl.insn_reserv.bypass_list
! = &decl->decl.bypass;
}
}
}
--- 2794,2842 ----
decl = description->decls [i];
if (decl->mode == dm_bypass)
{
! out_insn_reserv = find_insn_decl (DECL_BYPASS (decl)->out_insn_name);
! in_insn_reserv = find_insn_decl (DECL_BYPASS (decl)->in_insn_name);
if (out_insn_reserv == NULL)
error ("there is no insn reservation `%s'",
! DECL_BYPASS (decl)->out_insn_name);
else if (in_insn_reserv == NULL)
error ("there is no insn reservation `%s'",
! DECL_BYPASS (decl)->in_insn_name);
else
{
! DECL_BYPASS (decl)->out_insn_reserv
! = DECL_INSN_RESERV (out_insn_reserv);
! DECL_BYPASS (decl)->in_insn_reserv
! = DECL_INSN_RESERV (in_insn_reserv);
bypass
! = find_bypass (DECL_INSN_RESERV (out_insn_reserv)->bypass_list,
! DECL_BYPASS (decl)->in_insn_reserv);
if (bypass != NULL)
{
! if (DECL_BYPASS (decl)->latency == bypass->latency)
{
if (!w_flag)
error
("the same bypass `%s - %s' is already defined",
! DECL_BYPASS (decl)->out_insn_name,
! DECL_BYPASS (decl)->in_insn_name);
else
warning
("the same bypass `%s - %s' is already defined",
! DECL_BYPASS (decl)->out_insn_name,
! DECL_BYPASS (decl)->in_insn_name);
}
else
error ("bypass `%s - %s' is already defined",
! DECL_BYPASS (decl)->out_insn_name,
! DECL_BYPASS (decl)->in_insn_name);
}
else
{
! DECL_BYPASS (decl)->next
! = DECL_INSN_RESERV (out_insn_reserv)->bypass_list;
! DECL_INSN_RESERV (out_insn_reserv)->bypass_list
! = DECL_BYPASS (decl);
}
}
}
*************** process_decls ()
*** 2623,2635 ****
unit_set_el_t unit_set_el_list_2;
unit_set_el_list
! = process_excls (decl->decl.excl.names,
! decl->decl.excl.first_list_length, decl->pos);
unit_set_el_list_2
! = process_excls (&decl->decl.excl.names
! [decl->decl.excl.first_list_length],
! decl->decl.excl.names_num
! - decl->decl.excl.first_list_length,
decl->pos);
add_excls (unit_set_el_list, unit_set_el_list_2, decl->pos);
add_excls (unit_set_el_list_2, unit_set_el_list, decl->pos);
--- 2852,2864 ----
unit_set_el_t unit_set_el_list_2;
unit_set_el_list
! = process_excls (DECL_EXCL (decl)->names,
! DECL_EXCL (decl)->first_list_length, decl->pos);
unit_set_el_list_2
! = process_excls (&DECL_EXCL (decl)->names
! [DECL_EXCL (decl)->first_list_length],
! DECL_EXCL (decl)->names_num
! - DECL_EXCL (decl)->first_list_length,
decl->pos);
add_excls (unit_set_el_list, unit_set_el_list_2, decl->pos);
add_excls (unit_set_el_list_2, unit_set_el_list, decl->pos);
*************** process_decls ()
*** 2647,2660 ****
unit_set_el_list
= process_presence_absence
! (decl->decl.presence.names,
! decl->decl.presence.first_list_length, decl->pos, 1);
unit_set_el_list_2
= process_presence_absence
! (&decl->decl.presence.names
! [decl->decl.presence.first_list_length],
! decl->decl.presence.names_num
! - decl->decl.presence.first_list_length,
decl->pos, 1);
add_presence_absence (unit_set_el_list, unit_set_el_list_2,
decl->pos, 1);
--- 2876,2889 ----
unit_set_el_list
= process_presence_absence
! (DECL_PRESENCE (decl)->names,
! DECL_PRESENCE (decl)->first_list_length, decl->pos, 1);
unit_set_el_list_2
= process_presence_absence
! (&DECL_PRESENCE (decl)->names
! [DECL_PRESENCE (decl)->first_list_length],
! DECL_PRESENCE (decl)->names_num
! - DECL_PRESENCE (decl)->first_list_length,
decl->pos, 1);
add_presence_absence (unit_set_el_list, unit_set_el_list_2,
decl->pos, 1);
*************** process_decls ()
*** 2672,2685 ****
unit_set_el_list
= process_presence_absence
! (decl->decl.presence.names,
! decl->decl.presence.first_list_length, decl->pos, 0);
unit_set_el_list_2
= process_presence_absence
! (&decl->decl.presence.names
! [decl->decl.presence.first_list_length],
! decl->decl.presence.names_num
! - decl->decl.presence.first_list_length,
decl->pos, 0);
add_presence_absence (unit_set_el_list, unit_set_el_list_2,
decl->pos, 0);
--- 2901,2914 ----
unit_set_el_list
= process_presence_absence
! (DECL_ABSENCE (decl)->names,
! DECL_ABSENCE (decl)->first_list_length, decl->pos, 0);
unit_set_el_list_2
= process_presence_absence
! (&DECL_ABSENCE (decl)->names
! [DECL_ABSENCE (decl)->first_list_length],
! DECL_ABSENCE (decl)->names_num
! - DECL_ABSENCE (decl)->first_list_length,
decl->pos, 0);
add_presence_absence (unit_set_el_list, unit_set_el_list_2,
decl->pos, 0);
*************** check_automaton_usage ()
*** 2700,2711 ****
{
decl = description->decls [i];
if (decl->mode == dm_automaton
! && !decl->decl.automaton.automaton_is_used)
{
if (!w_flag)
! error ("automaton `%s' is not used", decl->decl.automaton.name);
else
! warning ("automaton `%s' is not used", decl->decl.automaton.name);
}
}
}
--- 2929,2941 ----
{
decl = description->decls [i];
if (decl->mode == dm_automaton
! && !DECL_AUTOMATON (decl)->automaton_is_used)
{
if (!w_flag)
! error ("automaton `%s' is not used", DECL_AUTOMATON (decl)->name);
else
! warning ("automaton `%s' is not used",
! DECL_AUTOMATON (decl)->name);
}
}
}
*************** process_regexp (regexp)
*** 2725,2767 ****
if (regexp->mode == rm_unit)
{
! decl_in_table = find_decl (regexp->regexp.unit.name);
if (decl_in_table == NULL)
error ("undeclared unit or reservation `%s'",
! regexp->regexp.unit.name);
else if (decl_in_table->mode == dm_unit)
{
! decl_in_table->decl.unit.unit_is_used = 1;
! regexp->regexp.unit.unit_decl = &decl_in_table->decl.unit;
}
else if (decl_in_table->mode == dm_reserv)
{
! decl_in_table->decl.reserv.reserv_is_used = 1;
new_regexp = create_node (sizeof (struct regexp));
new_regexp->mode = rm_reserv;
new_regexp->pos = regexp->pos;
! new_regexp->regexp.reserv.name = regexp->regexp.unit.name;
! new_regexp->regexp.reserv.reserv_decl = &decl_in_table->decl.reserv;
regexp = new_regexp;
}
else
abort ();
}
else if (regexp->mode == rm_sequence)
! for (i = 0; i < regexp->regexp.sequence.regexps_num; i++)
! regexp->regexp.sequence.regexps [i]
! = process_regexp (regexp->regexp.sequence.regexps [i]);
else if (regexp->mode == rm_allof)
! for (i = 0; i < regexp->regexp.allof.regexps_num; i++)
! regexp->regexp.allof.regexps [i]
! = process_regexp (regexp->regexp.allof.regexps [i]);
else if (regexp->mode == rm_oneof)
! for (i = 0; i < regexp->regexp.oneof.regexps_num; i++)
! regexp->regexp.oneof.regexps [i]
! = process_regexp (regexp->regexp.oneof.regexps [i]);
else if (regexp->mode == rm_repeat)
! regexp->regexp.repeat.regexp
! = process_regexp (regexp->regexp.repeat.regexp);
else if (regexp->mode != rm_nothing)
abort ();
return regexp;
--- 2955,2998 ----
if (regexp->mode == 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 ();
}
else if (regexp->mode == rm_sequence)
! for (i = 0; i <REGEXP_SEQUENCE (regexp)->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;
*************** process_regexp_decls ()
*** 2780,2789 ****
{
decl = description->decls [i];
if (decl->mode == dm_reserv)
! decl->decl.reserv.regexp = process_regexp (decl->decl.reserv.regexp);
else if (decl->mode == dm_insn_reserv)
! decl->decl.insn_reserv.regexp
! = process_regexp (decl->decl.insn_reserv.regexp);
}
}
--- 3011,3021 ----
{
decl = description->decls [i];
if (decl->mode == dm_reserv)
! DECL_RESERV (decl)->regexp
! = process_regexp (DECL_RESERV (decl)->regexp);
else if (decl->mode == dm_insn_reserv)
! DECL_INSN_RESERV (decl)->regexp
! = process_regexp (DECL_INSN_RESERV (decl)->regexp);
}
}
*************** check_usage ()
*** 2800,2818 ****
for (i = 0; i < description->decls_num; i++)
{
decl = description->decls [i];
! if (decl->mode == dm_unit && !decl->decl.unit.unit_is_used)
{
if (!w_flag)
! error ("unit `%s' is not used", decl->decl.unit.name);
else
! warning ("unit `%s' is not used", decl->decl.unit.name);
}
! else if (decl->mode == dm_reserv && !decl->decl.reserv.reserv_is_used)
{
if (!w_flag)
! error ("reservation `%s' is not used", decl->decl.reserv.name);
else
! warning ("reservation `%s' is not used", decl->decl.reserv.name);
}
}
}
--- 3032,3050 ----
for (i = 0; i < description->decls_num; i++)
{
decl = description->decls [i];
! if (decl->mode == dm_unit && !DECL_UNIT (decl)->unit_is_used)
{
if (!w_flag)
! error ("unit `%s' is not used", DECL_UNIT (decl)->name);
else
! warning ("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);
}
}
}
*************** loop_in_regexp (regexp, start_decl)
*** 2838,2880 ****
else if (regexp->mode == rm_reserv)
{
if (start_decl->mode == dm_reserv
! && regexp->regexp.reserv.reserv_decl == &start_decl->decl.reserv)
return 1;
! else if (regexp->regexp.reserv.reserv_decl->loop_pass_num
== curr_loop_pass_num)
/* declaration has been processed. */
return 0;
else
{
! regexp->regexp.reserv.reserv_decl->loop_pass_num
= curr_loop_pass_num;
! return loop_in_regexp (regexp->regexp.reserv.reserv_decl->regexp,
start_decl);
}
}
else if (regexp->mode == rm_sequence)
{
! for (i = 0; i < regexp->regexp.sequence.regexps_num; i++)
! if (loop_in_regexp (regexp->regexp.sequence.regexps [i], start_decl))
return 1;
return 0;
}
else if (regexp->mode == rm_allof)
{
! for (i = 0; i < regexp->regexp.allof.regexps_num; i++)
! if (loop_in_regexp (regexp->regexp.allof.regexps [i], start_decl))
return 1;
return 0;
}
else if (regexp->mode == rm_oneof)
{
! for (i = 0; i < regexp->regexp.oneof.regexps_num; i++)
! if (loop_in_regexp (regexp->regexp.oneof.regexps [i], start_decl))
return 1;
return 0;
}
else if (regexp->mode == rm_repeat)
! return loop_in_regexp (regexp->regexp.repeat.regexp, start_decl);
else
{
if (regexp->mode != rm_nothing)
--- 3070,3112 ----
else if (regexp->mode == rm_reserv)
{
if (start_decl->mode == dm_reserv
! && REGEXP_RESERV (regexp)->reserv_decl == DECL_RESERV (start_decl))
return 1;
! else if (REGEXP_RESERV (regexp)->reserv_decl->loop_pass_num
== curr_loop_pass_num)
/* declaration has been processed. */
return 0;
else
{
! REGEXP_RESERV (regexp)->reserv_decl->loop_pass_num
= curr_loop_pass_num;
! return loop_in_regexp (REGEXP_RESERV (regexp)->reserv_decl->regexp,
start_decl);
}
}
else if (regexp->mode == rm_sequence)
{
! for (i = 0; i <REGEXP_SEQUENCE (regexp)->regexps_num; i++)
! if (loop_in_regexp (REGEXP_SEQUENCE (regexp)->regexps [i], start_decl))
return 1;
return 0;
}
else if (regexp->mode == 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)
{
! 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)
*************** check_loops_in_regexps ()
*** 2895,2901 ****
{
decl = description->decls [i];
if (decl->mode == dm_reserv)
! decl->decl.reserv.loop_pass_num = 0;
}
for (i = 0; i < description->decls_num; i++)
{
--- 3127,3133 ----
{
decl = description->decls [i];
if (decl->mode == dm_reserv)
! DECL_RESERV (decl)->loop_pass_num = 0;
}
for (i = 0; i < description->decls_num; i++)
{
*************** check_loops_in_regexps ()
*** 2904,2916 ****
if (decl->mode == dm_reserv)
{
! decl->decl.reserv.loop_pass_num = curr_loop_pass_num;
! if (loop_in_regexp (decl->decl.reserv.regexp, decl))
{
! if (decl->decl.reserv.regexp == NULL)
abort ();
error ("cycle in definition of reservation `%s'",
! decl->decl.reserv.name);
}
}
}
--- 3136,3148 ----
if (decl->mode == dm_reserv)
{
! 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 ();
error ("cycle in definition of reservation `%s'",
! DECL_RESERV (decl)->name);
}
}
}
*************** process_regexp_cycles (regexp, start_cyc
*** 2928,2952 ****
if (regexp->mode == rm_unit)
{
! if (regexp->regexp.unit.unit_decl->max_occ_cycle_num < start_cycle)
! regexp->regexp.unit.unit_decl->max_occ_cycle_num = start_cycle;
return start_cycle;
}
else if (regexp->mode == rm_reserv)
! return process_regexp_cycles (regexp->regexp.reserv.reserv_decl->regexp,
start_cycle);
else if (regexp->mode == rm_repeat)
{
! for (i = 0; i < regexp->regexp.repeat.repeat_num; i++)
! start_cycle = process_regexp_cycles (regexp->regexp.repeat.regexp,
start_cycle) + 1;
return start_cycle;
}
else if (regexp->mode == rm_sequence)
{
! for (i = 0; i < regexp->regexp.sequence.regexps_num; i++)
start_cycle
! = process_regexp_cycles (regexp->regexp.sequence.regexps [i],
start_cycle) + 1;
return start_cycle;
}
--- 3160,3184 ----
if (regexp->mode == rm_unit)
{
! if (REGEXP_UNIT (regexp)->unit_decl->max_occ_cycle_num < start_cycle)
! REGEXP_UNIT (regexp)->unit_decl->max_occ_cycle_num = start_cycle;
return start_cycle;
}
else if (regexp->mode == rm_reserv)
! return process_regexp_cycles (REGEXP_RESERV (regexp)->reserv_decl->regexp,
start_cycle);
else if (regexp->mode == rm_repeat)
{
! for (i = 0; i < REGEXP_REPEAT (regexp)->repeat_num; i++)
! start_cycle = process_regexp_cycles (REGEXP_REPEAT (regexp)->regexp,
start_cycle) + 1;
return start_cycle;
}
else if (regexp->mode == rm_sequence)
{
! for (i = 0; i <REGEXP_SEQUENCE (regexp)->regexps_num; i++)
start_cycle
! = process_regexp_cycles (REGEXP_SEQUENCE (regexp)->regexps [i],
start_cycle) + 1;
return start_cycle;
}
*************** process_regexp_cycles (regexp, start_cyc
*** 2955,2963 ****
int finish_cycle = 0;
int cycle;
! for (i = 0; i < regexp->regexp.allof.regexps_num; i++)
{
! cycle = process_regexp_cycles (regexp->regexp.allof.regexps [i],
start_cycle);
if (finish_cycle < cycle)
finish_cycle = cycle;
--- 3187,3195 ----
int finish_cycle = 0;
int cycle;
! for (i = 0; i < REGEXP_ALLOF (regexp)->regexps_num; i++)
{
! cycle = process_regexp_cycles (REGEXP_ALLOF (regexp)->regexps [i],
start_cycle);
if (finish_cycle < cycle)
finish_cycle = cycle;
*************** process_regexp_cycles (regexp, start_cyc
*** 2969,2977 ****
int finish_cycle = 0;
int cycle;
! for (i = 0; i < regexp->regexp.oneof.regexps_num; i++)
{
! cycle = process_regexp_cycles (regexp->regexp.oneof.regexps [i],
start_cycle);
if (finish_cycle < cycle)
finish_cycle = cycle;
--- 3201,3209 ----
int finish_cycle = 0;
int cycle;
! for (i = 0; i < REGEXP_ONEOF (regexp)->regexps_num; i++)
{
! cycle = process_regexp_cycles (REGEXP_ONEOF (regexp)->regexps [i],
start_cycle);
if (finish_cycle < cycle)
finish_cycle = cycle;
*************** evaluate_max_reserv_cycles ()
*** 3002,3008 ****
if (decl->mode == dm_insn_reserv)
{
max_insn_cycles_num
! = process_regexp_cycles (decl->decl.insn_reserv.regexp, 0);
if (description->max_insn_reserv_cycles < max_insn_cycles_num)
description->max_insn_reserv_cycles = max_insn_cycles_num;
}
--- 3234,3240 ----
if (decl->mode == dm_insn_reserv)
{
max_insn_cycles_num
! = process_regexp_cycles (DECL_INSN_RESERV (decl)->regexp, 0);
if (description->max_insn_reserv_cycles < max_insn_cycles_num)
description->max_insn_reserv_cycles = max_insn_cycles_num;
}
*************** add_advance_cycle_insn_decl ()
*** 3148,3156 ****
advance_cycle_insn_decl = create_node (sizeof (struct decl));
advance_cycle_insn_decl->mode = dm_insn_reserv;
advance_cycle_insn_decl->pos = no_pos;
! advance_cycle_insn_decl->decl.insn_reserv.regexp = NULL;
! advance_cycle_insn_decl->decl.insn_reserv.name = (char *) "$advance_cycle";
! advance_cycle_insn_decl->decl.insn_reserv.insn_num = description->insns_num;
description->decls [description->decls_num] = advance_cycle_insn_decl;
description->decls_num++;
description->insns_num++;
--- 3380,3389 ----
advance_cycle_insn_decl = create_node (sizeof (struct decl));
advance_cycle_insn_decl->mode = dm_insn_reserv;
advance_cycle_insn_decl->pos = no_pos;
! DECL_INSN_RESERV (advance_cycle_insn_decl)->regexp = NULL;
! DECL_INSN_RESERV (advance_cycle_insn_decl)->name = (char *) "$advance_cycle";
! DECL_INSN_RESERV (advance_cycle_insn_decl)->insn_num
! = description->insns_num;
description->decls [description->decls_num] = advance_cycle_insn_decl;
description->decls_num++;
description->insns_num++;
*************** initiate_states ()
*** 3913,3919 ****
{
decl = description->decls [i];
if (decl->mode == dm_unit)
! units_array [decl->decl.unit.unit_num] = &decl->decl.unit;
}
max_cycles_num = description->max_insn_reserv_cycles;
els_in_cycle_reserv
--- 4146,4152 ----
{
decl = description->decls [i];
if (decl->mode == dm_unit)
! units_array [DECL_UNIT (decl)->unit_num] = DECL_UNIT (decl);
}
max_cycles_num = description->max_insn_reserv_cycles;
els_in_cycle_reserv
*************** initiate_excl_sets ()
*** 4263,4273 ****
unit_excl_set = (reserv_sets_t) obstack_base (&irp);
obstack_finish (&irp);
memset (unit_excl_set, 0, els_in_cycle_reserv * sizeof (set_el_t));
! for (el = decl->decl.unit.excl_list;
el != NULL;
el = el->next_unit_set_el)
SET_BIT (unit_excl_set, el->unit_decl->unit_num);
! unit_excl_set_table [decl->decl.unit.unit_num] = unit_excl_set;
}
}
}
--- 4496,4506 ----
unit_excl_set = (reserv_sets_t) obstack_base (&irp);
obstack_finish (&irp);
memset (unit_excl_set, 0, els_in_cycle_reserv * sizeof (set_el_t));
! for (el = DECL_UNIT (decl)->excl_list;
el != NULL;
el = el->next_unit_set_el)
SET_BIT (unit_excl_set, el->unit_decl->unit_num);
! unit_excl_set_table [DECL_UNIT (decl)->unit_num] = unit_excl_set;
}
}
}
*************** initiate_presence_absence_sets ()
*** 4349,4369 ****
unit_set = (reserv_sets_t) obstack_base (&irp);
obstack_finish (&irp);
memset (unit_set, 0, els_in_cycle_reserv * sizeof (set_el_t));
! for (el = decl->decl.unit.presence_list;
el != NULL;
el = el->next_unit_set_el)
SET_BIT (unit_set, el->unit_decl->unit_num);
! unit_presence_set_table [decl->decl.unit.unit_num] = unit_set;
obstack_blank (&irp, els_in_cycle_reserv * sizeof (set_el_t));
unit_set = (reserv_sets_t) obstack_base (&irp);
obstack_finish (&irp);
memset (unit_set, 0, els_in_cycle_reserv * sizeof (set_el_t));
! for (el = decl->decl.unit.absence_list;
el != NULL;
el = el->next_unit_set_el)
SET_BIT (unit_set, el->unit_decl->unit_num);
! unit_absence_set_table [decl->decl.unit.unit_num] = unit_set;
}
}
}
--- 4582,4602 ----
unit_set = (reserv_sets_t) obstack_base (&irp);
obstack_finish (&irp);
memset (unit_set, 0, els_in_cycle_reserv * sizeof (set_el_t));
! for (el = DECL_UNIT (decl)->presence_list;
el != NULL;
el = el->next_unit_set_el)
SET_BIT (unit_set, el->unit_decl->unit_num);
! unit_presence_set_table [DECL_UNIT (decl)->unit_num] = unit_set;
obstack_blank (&irp, els_in_cycle_reserv * sizeof (set_el_t));
unit_set = (reserv_sets_t) obstack_base (&irp);
obstack_finish (&irp);
memset (unit_set, 0, els_in_cycle_reserv * sizeof (set_el_t));
! for (el = DECL_UNIT (decl)->absence_list;
el != NULL;
el = el->next_unit_set_el)
SET_BIT (unit_set, el->unit_decl->unit_num);
! unit_absence_set_table [DECL_UNIT (decl)->unit_num] = unit_set;
}
}
}
*************** copy_insn_regexp (regexp)
*** 4426,4466 ****
int i;
if (regexp->mode == rm_reserv)
! result = copy_insn_regexp (regexp->regexp.reserv.reserv_decl->regexp);
else if (regexp->mode == rm_unit)
result = copy_node (regexp, sizeof (struct regexp));
else if (regexp->mode == rm_repeat)
{
result = copy_node (regexp, sizeof (struct regexp));
! result->regexp.repeat.regexp
! = copy_insn_regexp (regexp->regexp.repeat.regexp);
}
else if (regexp->mode == rm_sequence)
{
result = copy_node (regexp,
sizeof (struct regexp) + sizeof (regexp_t)
! * (regexp->regexp.sequence.regexps_num - 1));
! for (i = 0; i < regexp->regexp.sequence.regexps_num; i++)
! result->regexp.sequence.regexps [i]
! = copy_insn_regexp (regexp->regexp.sequence.regexps [i]);
}
else if (regexp->mode == rm_allof)
{
result = copy_node (regexp,
sizeof (struct regexp) + sizeof (regexp_t)
! * (regexp->regexp.allof.regexps_num - 1));
! for (i = 0; i < regexp->regexp.allof.regexps_num; i++)
! result->regexp.allof.regexps [i]
! = copy_insn_regexp (regexp->regexp.allof.regexps [i]);
}
else if (regexp->mode == rm_oneof)
{
result = copy_node (regexp,
sizeof (struct regexp) + sizeof (regexp_t)
! * (regexp->regexp.oneof.regexps_num - 1));
! for (i = 0; i < regexp->regexp.oneof.regexps_num; i++)
! result->regexp.oneof.regexps [i]
! = copy_insn_regexp (regexp->regexp.oneof.regexps [i]);
}
else
{
--- 4659,4699 ----
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)
{
result = copy_node (regexp, sizeof (struct regexp));
! REGEXP_REPEAT (result)->regexp
! = copy_insn_regexp (REGEXP_REPEAT (regexp)->regexp);
}
else if (regexp->mode == rm_sequence)
{
result = copy_node (regexp,
sizeof (struct regexp) + sizeof (regexp_t)
! * (REGEXP_SEQUENCE (regexp)->regexps_num - 1));
! for (i = 0; i <REGEXP_SEQUENCE (regexp)->regexps_num; i++)
! REGEXP_SEQUENCE (result)->regexps [i]
! = copy_insn_regexp (REGEXP_SEQUENCE (regexp)->regexps [i]);
}
else if (regexp->mode == 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)
{
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
{
*************** transform_1 (regexp)
*** 4488,4505 ****
if (regexp->mode == rm_repeat)
{
! repeat_num = regexp->regexp.repeat.repeat_num;
if (repeat_num <= 1)
abort ();
! operand = regexp->regexp.repeat.regexp;
pos = regexp->mode;
regexp = create_node (sizeof (struct regexp) + sizeof (regexp_t)
* (repeat_num - 1));
regexp->mode = rm_sequence;
regexp->pos = pos;
! regexp->regexp.sequence.regexps_num = repeat_num;
for (i = 0; i < repeat_num; i++)
! regexp->regexp.sequence.regexps [i] = copy_insn_regexp (operand);
regexp_transformed_p = 1;
}
return regexp;
--- 4721,4738 ----
if (regexp->mode == rm_repeat)
{
! repeat_num = REGEXP_REPEAT (regexp)->repeat_num;
if (repeat_num <= 1)
abort ();
! operand = REGEXP_REPEAT (regexp)->regexp;
pos = regexp->mode;
regexp = create_node (sizeof (struct regexp) + sizeof (regexp_t)
* (repeat_num - 1));
regexp->mode = rm_sequence;
regexp->pos = pos;
! REGEXP_SEQUENCE (regexp)->regexps_num = repeat_num;
for (i = 0; i < repeat_num; i++)
! REGEXP_SEQUENCE (regexp)->regexps [i] = copy_insn_regexp (operand);
regexp_transformed_p = 1;
}
return regexp;
*************** transform_2 (regexp)
*** 4520,4559 ****
int sequence_index = 0;
int i, j;
! for (i = 0; i < regexp->regexp.sequence.regexps_num; i++)
! if (regexp->regexp.sequence.regexps [i]->mode == rm_sequence)
{
sequence_index = i;
! sequence = regexp->regexp.sequence.regexps [i];
break;
}
! if (i < regexp->regexp.sequence.regexps_num)
{
! if (sequence->regexp.sequence.regexps_num <= 1
! || regexp->regexp.sequence.regexps_num <= 1)
abort ();
result = create_node (sizeof (struct regexp)
+ sizeof (regexp_t)
! * (regexp->regexp.sequence.regexps_num
! + sequence->regexp.sequence.regexps_num
- 2));
result->mode = rm_sequence;
result->pos = regexp->pos;
! result->regexp.sequence.regexps_num
! = (regexp->regexp.sequence.regexps_num
! + sequence->regexp.sequence.regexps_num - 1);
! for (i = 0; i < regexp->regexp.sequence.regexps_num; i++)
if (i < sequence_index)
! result->regexp.sequence.regexps [i]
! = copy_insn_regexp (regexp->regexp.sequence.regexps [i]);
else if (i > sequence_index)
! result->regexp.sequence.regexps
! [i + sequence->regexp.sequence.regexps_num - 1]
! = copy_insn_regexp (regexp->regexp.sequence.regexps [i]);
else
! for (j = 0; j < sequence->regexp.sequence.regexps_num; j++)
! result->regexp.sequence.regexps [i + j]
! = copy_insn_regexp (sequence->regexp.sequence.regexps [j]);
regexp_transformed_p = 1;
regexp = result;
}
--- 4753,4792 ----
int sequence_index = 0;
int i, j;
! for (i = 0; i < REGEXP_SEQUENCE (regexp)->regexps_num; i++)
! if (REGEXP_SEQUENCE (regexp)->regexps [i]->mode == rm_sequence)
{
sequence_index = i;
! sequence = REGEXP_SEQUENCE (regexp)->regexps [i];
break;
}
! if (i < REGEXP_SEQUENCE (regexp)->regexps_num)
{
! if ( REGEXP_SEQUENCE (sequence)->regexps_num <= 1
! || REGEXP_SEQUENCE (regexp)->regexps_num <= 1)
abort ();
result = create_node (sizeof (struct regexp)
+ sizeof (regexp_t)
! * (REGEXP_SEQUENCE (regexp)->regexps_num
! + REGEXP_SEQUENCE (sequence)->regexps_num
- 2));
result->mode = rm_sequence;
result->pos = regexp->pos;
! REGEXP_SEQUENCE (result)->regexps_num
! = (REGEXP_SEQUENCE (regexp)->regexps_num
! + REGEXP_SEQUENCE (sequence)->regexps_num - 1);
! for (i = 0; i < REGEXP_SEQUENCE (regexp)->regexps_num; i++)
if (i < sequence_index)
! REGEXP_SEQUENCE (result)->regexps [i]
! = copy_insn_regexp (REGEXP_SEQUENCE (regexp)->regexps [i]);
else if (i > sequence_index)
! REGEXP_SEQUENCE (result)->regexps
! [i + REGEXP_SEQUENCE (sequence)->regexps_num - 1]
! = copy_insn_regexp (REGEXP_SEQUENCE (regexp)->regexps [i]);
else
! for (j = 0; j < REGEXP_SEQUENCE (sequence)->regexps_num; j++)
! REGEXP_SEQUENCE (result)->regexps [i + j]
! = copy_insn_regexp (REGEXP_SEQUENCE (sequence)->regexps [j]);
regexp_transformed_p = 1;
regexp = result;
}
*************** transform_2 (regexp)
*** 4565,4603 ****
int allof_index = 0;
int i, j;
! for (i = 0; i < regexp->regexp.allof.regexps_num; i++)
! if (regexp->regexp.allof.regexps [i]->mode == rm_allof)
{
allof_index = i;
! allof = regexp->regexp.allof.regexps [i];
break;
}
! if (i < regexp->regexp.allof.regexps_num)
{
! if (allof->regexp.allof.regexps_num <= 1
! || regexp->regexp.allof.regexps_num <= 1)
abort ();
result = create_node (sizeof (struct regexp)
+ sizeof (regexp_t)
! * (regexp->regexp.allof.regexps_num
! + allof->regexp.allof.regexps_num - 2));
result->mode = rm_allof;
result->pos = regexp->pos;
! result->regexp.allof.regexps_num
! = (regexp->regexp.allof.regexps_num
! + allof->regexp.allof.regexps_num - 1);
! for (i = 0; i < regexp->regexp.allof.regexps_num; i++)
if (i < allof_index)
! result->regexp.allof.regexps [i]
! = copy_insn_regexp (regexp->regexp.allof.regexps [i]);
else if (i > allof_index)
! result->regexp.allof.regexps
! [i + allof->regexp.allof.regexps_num - 1]
! = copy_insn_regexp (regexp->regexp.allof.regexps [i]);
else
! for (j = 0; j < allof->regexp.allof.regexps_num; j++)
! result->regexp.allof.regexps [i + j]
! = copy_insn_regexp (allof->regexp.allof.regexps [j]);
regexp_transformed_p = 1;
regexp = result;
}
--- 4798,4836 ----
int allof_index = 0;
int i, j;
! for (i = 0; i < REGEXP_ALLOF (regexp)->regexps_num; i++)
! if (REGEXP_ALLOF (regexp)->regexps [i]->mode == rm_allof)
{
allof_index = i;
! allof = REGEXP_ALLOF (regexp)->regexps [i];
break;
}
! if (i < REGEXP_ALLOF (regexp)->regexps_num)
{
! if (REGEXP_ALLOF (allof)->regexps_num <= 1
! || REGEXP_ALLOF (regexp)->regexps_num <= 1)
abort ();
result = create_node (sizeof (struct regexp)
+ sizeof (regexp_t)
! * (REGEXP_ALLOF (regexp)->regexps_num
! + REGEXP_ALLOF (allof)->regexps_num - 2));
result->mode = rm_allof;
result->pos = regexp->pos;
! REGEXP_ALLOF (result)->regexps_num
! = (REGEXP_ALLOF (regexp)->regexps_num
! + REGEXP_ALLOF (allof)->regexps_num - 1);
! for (i = 0; i < REGEXP_ALLOF (regexp)->regexps_num; i++)
if (i < allof_index)
! REGEXP_ALLOF (result)->regexps [i]
! = copy_insn_regexp (REGEXP_ALLOF (regexp)->regexps [i]);
else if (i > allof_index)
! REGEXP_ALLOF (result)->regexps
! [i + REGEXP_ALLOF (allof)->regexps_num - 1]
! = copy_insn_regexp (REGEXP_ALLOF (regexp)->regexps [i]);
else
! for (j = 0; j < REGEXP_ALLOF (allof)->regexps_num; j++)
! REGEXP_ALLOF (result)->regexps [i + j]
! = copy_insn_regexp (REGEXP_ALLOF (allof)->regexps [j]);
regexp_transformed_p = 1;
regexp = result;
}
*************** transform_2 (regexp)
*** 4609,4647 ****
int oneof_index = 0;
int i, j;
! for (i = 0; i < regexp->regexp.oneof.regexps_num; i++)
! if (regexp->regexp.oneof.regexps [i]->mode == rm_oneof)
{
oneof_index = i;
! oneof = regexp->regexp.oneof.regexps [i];
break;
}
! if (i < regexp->regexp.oneof.regexps_num)
{
! if (oneof->regexp.oneof.regexps_num <= 1
! || regexp->regexp.oneof.regexps_num <= 1)
abort ();
result = create_node (sizeof (struct regexp)
+ sizeof (regexp_t)
! * (regexp->regexp.oneof.regexps_num
! + oneof->regexp.oneof.regexps_num - 2));
result->mode = rm_oneof;
result->pos = regexp->pos;
! result->regexp.oneof.regexps_num
! = (regexp->regexp.oneof.regexps_num
! + oneof->regexp.oneof.regexps_num - 1);
! for (i = 0; i < regexp->regexp.oneof.regexps_num; i++)
if (i < oneof_index)
! result->regexp.oneof.regexps [i]
! = copy_insn_regexp (regexp->regexp.oneof.regexps [i]);
else if (i > oneof_index)
! result->regexp.oneof.regexps
! [i + oneof->regexp.oneof.regexps_num - 1]
! = copy_insn_regexp (regexp->regexp.oneof.regexps [i]);
else
! for (j = 0; j < oneof->regexp.oneof.regexps_num; j++)
! result->regexp.oneof.regexps [i + j]
! = copy_insn_regexp (oneof->regexp.oneof.regexps [j]);
regexp_transformed_p = 1;
regexp = result;
}
--- 4842,4880 ----
int oneof_index = 0;
int i, j;
! for (i = 0; i < REGEXP_ONEOF (regexp)->regexps_num; i++)
! if (REGEXP_ONEOF (regexp)->regexps [i]->mode == rm_oneof)
{
oneof_index = i;
! oneof = REGEXP_ONEOF (regexp)->regexps [i];
break;
}
! if (i < REGEXP_ONEOF (regexp)->regexps_num)
{
! if (REGEXP_ONEOF (oneof)->regexps_num <= 1
! || REGEXP_ONEOF (regexp)->regexps_num <= 1)
abort ();
result = create_node (sizeof (struct regexp)
+ sizeof (regexp_t)
! * (REGEXP_ONEOF (regexp)->regexps_num
! + REGEXP_ONEOF (oneof)->regexps_num - 2));
result->mode = rm_oneof;
result->pos = regexp->pos;
! REGEXP_ONEOF (result)->regexps_num
! = (REGEXP_ONEOF (regexp)->regexps_num
! + REGEXP_ONEOF (oneof)->regexps_num - 1);
! for (i = 0; i < REGEXP_ONEOF (regexp)->regexps_num; i++)
if (i < oneof_index)
! REGEXP_ONEOF (result)->regexps [i]
! = copy_insn_regexp (REGEXP_ONEOF (regexp)->regexps [i]);
else if (i > oneof_index)
! REGEXP_ONEOF (result)->regexps
! [i + REGEXP_ONEOF (oneof)->regexps_num - 1]
! = copy_insn_regexp (REGEXP_ONEOF (regexp)->regexps [i]);
else
! for (j = 0; j < REGEXP_ONEOF (oneof)->regexps_num; j++)
! REGEXP_ONEOF (result)->regexps [i + j]
! = copy_insn_regexp (REGEXP_ONEOF (oneof)->regexps [j]);
regexp_transformed_p = 1;
regexp = result;
}
*************** transform_3 (regexp)
*** 4666,4707 ****
regexp_t sequence;
int i, j;
! for (i = 0; i < regexp->regexp.sequence.regexps_num; i++)
! if (regexp->regexp.sequence.regexps [i]->mode == rm_oneof)
{
oneof_index = i;
! oneof = regexp->regexp.sequence.regexps [i];
break;
}
! if (i < regexp->regexp.sequence.regexps_num)
{
! if (oneof->regexp.oneof.regexps_num <= 1
! || regexp->regexp.sequence.regexps_num <= 1)
abort ();
result = create_node (sizeof (struct regexp)
+ sizeof (regexp_t)
! * (oneof->regexp.oneof.regexps_num - 1));
result->mode = rm_oneof;
result->pos = regexp->pos;
! result->regexp.oneof.regexps_num = oneof->regexp.oneof.regexps_num;
! for (i = 0; i < result->regexp.oneof.regexps_num; i++)
{
sequence
= create_node (sizeof (struct regexp)
+ sizeof (regexp_t)
! * (regexp->regexp.sequence.regexps_num - 1));
sequence->mode = rm_sequence;
sequence->pos = regexp->pos;
! sequence->regexp.sequence.regexps_num
! = regexp->regexp.sequence.regexps_num;
! result->regexp.oneof.regexps [i] = sequence;
! for (j = 0; j < sequence->regexp.sequence.regexps_num; j++)
if (j != oneof_index)
! sequence->regexp.sequence.regexps [j]
! = copy_insn_regexp (regexp->regexp.sequence.regexps [j]);
else
! sequence->regexp.sequence.regexps [j]
! = copy_insn_regexp (oneof->regexp.oneof.regexps [i]);
}
regexp_transformed_p = 1;
regexp = result;
--- 4899,4941 ----
regexp_t sequence;
int i, j;
! for (i = 0; i <REGEXP_SEQUENCE (regexp)->regexps_num; i++)
! if (REGEXP_SEQUENCE (regexp)->regexps [i]->mode == rm_oneof)
{
oneof_index = i;
! oneof = REGEXP_SEQUENCE (regexp)->regexps [i];
break;
}
! if (i < REGEXP_SEQUENCE (regexp)->regexps_num)
{
! if (REGEXP_ONEOF (oneof)->regexps_num <= 1
! || REGEXP_SEQUENCE (regexp)->regexps_num <= 1)
abort ();
result = create_node (sizeof (struct regexp)
+ sizeof (regexp_t)
! * (REGEXP_ONEOF (oneof)->regexps_num - 1));
result->mode = rm_oneof;
result->pos = regexp->pos;
! REGEXP_ONEOF (result)->regexps_num
! = REGEXP_ONEOF (oneof)->regexps_num;
! for (i = 0; i < REGEXP_ONEOF (result)->regexps_num; i++)
{
sequence
= create_node (sizeof (struct regexp)
+ sizeof (regexp_t)
! * (REGEXP_SEQUENCE (regexp)->regexps_num - 1));
sequence->mode = rm_sequence;
sequence->pos = regexp->pos;
! REGEXP_SEQUENCE (sequence)->regexps_num
! = REGEXP_SEQUENCE (regexp)->regexps_num;
! REGEXP_ONEOF (result)->regexps [i] = sequence;
! for (j = 0; j < REGEXP_SEQUENCE (sequence)->regexps_num; j++)
if (j != oneof_index)
! REGEXP_SEQUENCE (sequence)->regexps [j]
! = copy_insn_regexp (REGEXP_SEQUENCE (regexp)->regexps [j]);
else
! REGEXP_SEQUENCE (sequence)->regexps [j]
! = copy_insn_regexp (REGEXP_ONEOF (oneof)->regexps [i]);
}
regexp_transformed_p = 1;
regexp = result;
*************** transform_3 (regexp)
*** 4712,4802 ****
regexp_t oneof = NULL, seq;
int oneof_index = 0, max_seq_length, allof_length;
regexp_t result;
! regexp_t allof = NULL, allof_op;
int i, j;
! for (i = 0; i < regexp->regexp.allof.regexps_num; i++)
! if (regexp->regexp.allof.regexps [i]->mode == rm_oneof)
{
oneof_index = i;
! oneof = regexp->regexp.allof.regexps [i];
break;
}
! if (i < regexp->regexp.allof.regexps_num)
{
! if (oneof->regexp.oneof.regexps_num <= 1
! || regexp->regexp.allof.regexps_num <= 1)
abort ();
result = create_node (sizeof (struct regexp)
+ sizeof (regexp_t)
! * (oneof->regexp.oneof.regexps_num - 1));
result->mode = rm_oneof;
result->pos = regexp->pos;
! result->regexp.oneof.regexps_num = oneof->regexp.oneof.regexps_num;
! for (i = 0; i < result->regexp.oneof.regexps_num; i++)
{
allof
= create_node (sizeof (struct regexp)
+ sizeof (regexp_t)
! * (regexp->regexp.allof.regexps_num - 1));
allof->mode = rm_allof;
allof->pos = regexp->pos;
! allof->regexp.allof.regexps_num
! = regexp->regexp.allof.regexps_num;
! result->regexp.oneof.regexps [i] = allof;
! for (j = 0; j < allof->regexp.allof.regexps_num; j++)
if (j != oneof_index)
! allof->regexp.allof.regexps [j]
! = copy_insn_regexp (regexp->regexp.allof.regexps [j]);
else
! allof->regexp.allof.regexps [j]
! = copy_insn_regexp (oneof->regexp.oneof.regexps [i]);
}
regexp_transformed_p = 1;
regexp = result;
}
max_seq_length = 0;
! for (i = 0; i < regexp->regexp.allof.regexps_num; i++)
! if (regexp->regexp.allof.regexps [i]->mode == rm_sequence)
! {
! seq = regexp->regexp.allof.regexps [i];
! if (max_seq_length < seq->regexp.sequence.regexps_num)
! max_seq_length = seq->regexp.sequence.regexps_num;
! }
! else if (regexp->regexp.allof.regexps [i]->mode != rm_unit)
! {
! max_seq_length = 0;
! break;
! }
if (max_seq_length != 0)
{
! if (max_seq_length == 1 || regexp->regexp.allof.regexps_num <= 1)
abort ();
result = create_node (sizeof (struct regexp)
+ sizeof (regexp_t) * (max_seq_length - 1));
result->mode = rm_sequence;
result->pos = regexp->pos;
! result->regexp.sequence.regexps_num = max_seq_length;
for (i = 0; i < max_seq_length; i++)
{
allof_length = 0;
! for (j = 0; j < regexp->regexp.allof.regexps_num; j++)
! if (regexp->regexp.allof.regexps [j]->mode == rm_sequence
! && (i < (regexp->regexp.allof.regexps [j]
! ->regexp.sequence.regexps_num)))
{
! allof_op = (regexp->regexp.allof.regexps [j]
! ->regexp.sequence.regexps [i]);
allof_length++;
}
else if (i == 0
! && regexp->regexp.allof.regexps [j]->mode == rm_unit)
{
! allof_op = regexp->regexp.allof.regexps [j];
allof_length++;
}
if (allof_length == 1)
! result->regexp.sequence.regexps [i] = allof_op;
else
{
allof = create_node (sizeof (struct regexp)
--- 4946,5040 ----
regexp_t oneof = NULL, seq;
int oneof_index = 0, max_seq_length, allof_length;
regexp_t result;
! regexp_t allof = NULL, allof_op = NULL;
int i, j;
! for (i = 0; i < REGEXP_ALLOF (regexp)->regexps_num; i++)
! if (REGEXP_ALLOF (regexp)->regexps [i]->mode == rm_oneof)
{
oneof_index = i;
! oneof = REGEXP_ALLOF (regexp)->regexps [i];
break;
}
! if (i < REGEXP_ALLOF (regexp)->regexps_num)
{
! if (REGEXP_ONEOF (oneof)->regexps_num <= 1
! || REGEXP_ALLOF (regexp)->regexps_num <= 1)
abort ();
result = create_node (sizeof (struct regexp)
+ sizeof (regexp_t)
! * (REGEXP_ONEOF (oneof)->regexps_num - 1));
result->mode = rm_oneof;
result->pos = regexp->pos;
! REGEXP_ONEOF (result)->regexps_num
! = REGEXP_ONEOF (oneof)->regexps_num;
! for (i = 0; i < REGEXP_ONEOF (result)->regexps_num; i++)
{
allof
= create_node (sizeof (struct regexp)
+ sizeof (regexp_t)
! * (REGEXP_ALLOF (regexp)->regexps_num - 1));
allof->mode = rm_allof;
allof->pos = regexp->pos;
! REGEXP_ALLOF (allof)->regexps_num
! = REGEXP_ALLOF (regexp)->regexps_num;
! REGEXP_ONEOF (result)->regexps [i] = allof;
! for (j = 0; j < REGEXP_ALLOF (allof)->regexps_num; j++)
if (j != oneof_index)
! REGEXP_ALLOF (allof)->regexps [j]
! = copy_insn_regexp (REGEXP_ALLOF (regexp)->regexps [j]);
else
! REGEXP_ALLOF (allof)->regexps [j]
! = copy_insn_regexp (REGEXP_ONEOF (oneof)->regexps [i]);
}
regexp_transformed_p = 1;
regexp = result;
}
max_seq_length = 0;
! if (regexp->mode == rm_allof)
! for (i = 0; i < REGEXP_ALLOF (regexp)->regexps_num; i++)
! if (REGEXP_ALLOF (regexp)->regexps [i]->mode == 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)
! {
! max_seq_length = 0;
! break;
! }
if (max_seq_length != 0)
{
! if (max_seq_length == 1 || REGEXP_ALLOF (regexp)->regexps_num <= 1)
abort ();
result = create_node (sizeof (struct regexp)
+ sizeof (regexp_t) * (max_seq_length - 1));
result->mode = rm_sequence;
result->pos = regexp->pos;
! REGEXP_SEQUENCE (result)->regexps_num = max_seq_length;
for (i = 0; i < max_seq_length; i++)
{
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)))
{
! 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))
{
! allof_op = REGEXP_ALLOF (regexp)->regexps [j];
allof_length++;
}
if (allof_length == 1)
! REGEXP_SEQUENCE (result)->regexps [i] = allof_op;
else
{
allof = create_node (sizeof (struct regexp)
*************** transform_3 (regexp)
*** 4804,4829 ****
* (allof_length - 1));
allof->mode = rm_allof;
allof->pos = regexp->pos;
! allof->regexp.allof.regexps_num = allof_length;
! result->regexp.sequence.regexps [i] = allof;
allof_length = 0;
! for (j = 0; j < regexp->regexp.allof.regexps_num; j++)
! if (regexp->regexp.allof.regexps [j]->mode == rm_sequence
! && (i < (regexp->regexp.allof.regexps [j]
! ->regexp.sequence.regexps_num)))
{
! allof_op = (regexp->regexp.allof.regexps [j]
! ->regexp.sequence.regexps [i]);
! allof->regexp.allof.regexps [allof_length] = allof_op;
!
allof_length++;
}
else if (i == 0
! && (regexp->regexp.allof.regexps [j]->mode
== rm_unit))
{
! allof_op = regexp->regexp.allof.regexps [j];
! allof->regexp.allof.regexps [allof_length] = allof_op;
allof_length++;
}
}
--- 5042,5070 ----
* (allof_length - 1));
allof->mode = rm_allof;
allof->pos = regexp->pos;
! REGEXP_ALLOF (allof)->regexps_num = allof_length;
! REGEXP_SEQUENCE (result)->regexps [i] = allof;
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)))
{
! allof_op = (REGEXP_SEQUENCE (REGEXP_ALLOF (regexp)
! ->regexps [j])
! ->regexps [i]);
! REGEXP_ALLOF (allof)->regexps [allof_length]
! = allof_op;
allof_length++;
}
else if (i == 0
! && (REGEXP_ALLOF (regexp)->regexps [j]->mode
== rm_unit))
{
! allof_op = REGEXP_ALLOF (regexp)->regexps [j];
! REGEXP_ALLOF (allof)->regexps [allof_length]
! = allof_op;
allof_length++;
}
}
*************** regexp_transform_func (regexp, func)
*** 4845,4864 ****
int i;
if (regexp->mode == rm_sequence)
! for (i = 0; i < regexp->regexp.sequence.regexps_num; i++)
! regexp->regexp.sequence.regexps [i]
! = regexp_transform_func (regexp->regexp.sequence.regexps [i], func);
else if (regexp->mode == rm_allof)
! for (i = 0; i < regexp->regexp.allof.regexps_num; i++)
! regexp->regexp.allof.regexps [i]
! = regexp_transform_func (regexp->regexp.allof.regexps [i], func);
else if (regexp->mode == rm_oneof)
! for (i = 0; i < regexp->regexp.oneof.regexps_num; i++)
! regexp->regexp.oneof.regexps [i]
! = regexp_transform_func (regexp->regexp.oneof.regexps [i], func);
else if (regexp->mode == rm_repeat)
! regexp->regexp.repeat.regexp
! = regexp_transform_func (regexp->regexp.repeat.regexp, func);
else if (regexp->mode != rm_nothing && regexp->mode != rm_unit)
abort ();
return (*func) (regexp);
--- 5086,5105 ----
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 ();
return (*func) (regexp);
*************** transform_insn_regexps ()
*** 4897,4905 ****
{
decl = description->decls [i];
if (decl->mode == dm_insn_reserv && decl != advance_cycle_insn_decl)
! decl->decl.insn_reserv.transformed_regexp
= transform_regexp (copy_insn_regexp
! (decl->decl.insn_reserv.regexp));
}
fprintf (stderr, "done\n");
ticker_off (&transform_time);
--- 5138,5146 ----
{
decl = description->decls [i];
if (decl->mode == dm_insn_reserv && decl != advance_cycle_insn_decl)
! DECL_INSN_RESERV (decl)->transformed_regexp
= transform_regexp (copy_insn_regexp
! (DECL_INSN_RESERV (decl)->regexp));
}
fprintf (stderr, "done\n");
ticker_off (&transform_time);
*************** process_unit_to_form_the_same_automaton_
*** 4929,4970 ****
if (regexp == NULL || regexp->mode != rm_oneof)
abort ();
! unit_decl = unit->regexp.unit.unit_decl;
! for (i = regexp->regexp.oneof.regexps_num - 1; i >= 0; i--)
{
! seq = regexp->regexp.oneof.regexps [i];
if (seq->mode == rm_sequence)
{
! if (cycle >= seq->regexp.sequence.regexps_num)
break;
! allof = seq->regexp.sequence.regexps [cycle];
if (allof->mode == rm_allof)
{
! for (k = 0; k < allof->regexp.allof.regexps_num; k++)
! if (allof->regexp.allof.regexps [k]->mode == rm_unit
! && (allof->regexp.allof.regexps [k]->regexp.unit.unit_decl
! == unit_decl))
break;
! if (k >= allof->regexp.allof.regexps_num)
break;
}
else if (allof->mode == rm_unit
! && allof->regexp.unit.unit_decl != unit_decl)
break;
}
else if (cycle != 0)
break;
else if (seq->mode == rm_allof)
{
! for (k = 0; k < seq->regexp.allof.regexps_num; k++)
! if (seq->regexp.allof.regexps [k]->mode == rm_unit
! && (seq->regexp.allof.regexps [k]->regexp.unit.unit_decl
== unit_decl))
break;
! if (k >= seq->regexp.allof.regexps_num)
break;
}
! else if (seq->mode == rm_unit && seq->regexp.unit.unit_decl != unit_decl)
break;
}
if (i >= 0)
--- 5170,5212 ----
if (regexp == NULL || regexp->mode != rm_oneof)
abort ();
! unit_decl = REGEXP_UNIT (unit)->unit_decl;
! for (i = REGEXP_ONEOF (regexp)->regexps_num - 1; i >= 0; i--)
{
! seq = REGEXP_ONEOF (regexp)->regexps [i];
if (seq->mode == rm_sequence)
{
! if (cycle >= REGEXP_SEQUENCE (seq)->regexps_num)
break;
! allof = REGEXP_SEQUENCE (seq)->regexps [cycle];
if (allof->mode == rm_allof)
{
! for (k = 0; k < REGEXP_ALLOF (allof)->regexps_num; k++)
! if (REGEXP_ALLOF (allof)->regexps [k]->mode == rm_unit
! && (REGEXP_UNIT (REGEXP_ALLOF (allof)->regexps [k])
! ->unit_decl == unit_decl))
break;
! if (k >= REGEXP_ALLOF (allof)->regexps_num)
break;
}
else if (allof->mode == rm_unit
! && REGEXP_UNIT (allof)->unit_decl != unit_decl)
break;
}
else if (cycle != 0)
break;
else if (seq->mode == rm_allof)
{
! for (k = 0; k < REGEXP_ALLOF (seq)->regexps_num; k++)
! if (REGEXP_ALLOF (seq)->regexps [k]->mode == rm_unit
! && (REGEXP_UNIT (REGEXP_ALLOF (seq)->regexps [k])->unit_decl
== unit_decl))
break;
! if (k >= REGEXP_ALLOF (seq)->regexps_num)
break;
}
! else if (seq->mode == rm_unit
! && REGEXP_UNIT (seq)->unit_decl != unit_decl)
break;
}
if (i >= 0)
*************** form_the_same_automaton_unit_lists_from_
*** 5002,5018 ****
return;
for (i = 0; i < description->max_insn_reserv_cycles; i++)
the_same_automaton_lists [i] = NULL;
! for (i = regexp->regexp.oneof.regexps_num - 1; i >= 0; i--)
{
! seq = regexp->regexp.oneof.regexps [i];
if (seq->mode == rm_sequence)
! for (j = 0; j < seq->regexp.sequence.regexps_num; j++)
{
! allof = seq->regexp.sequence.regexps [j];
if (allof->mode == rm_allof)
! for (k = 0; k < allof->regexp.allof.regexps_num; k++)
{
! unit = allof->regexp.allof.regexps [k];
if (unit->mode == rm_unit)
process_unit_to_form_the_same_automaton_unit_lists
(unit, regexp, j);
--- 5244,5260 ----
return;
for (i = 0; i < description->max_insn_reserv_cycles; i++)
the_same_automaton_lists [i] = NULL;
! 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++)
{
! unit = REGEXP_ALLOF (allof)->regexps [k];
if (unit->mode == rm_unit)
process_unit_to_form_the_same_automaton_unit_lists
(unit, regexp, j);
*************** form_the_same_automaton_unit_lists_from_
*** 5026,5034 ****
abort ();
}
else if (seq->mode == rm_allof)
! for (k = 0; k < seq->regexp.allof.regexps_num; k++)
{
! unit = seq->regexp.allof.regexps [k];
if (unit->mode == rm_unit)
process_unit_to_form_the_same_automaton_unit_lists
(unit, regexp, 0);
--- 5268,5276 ----
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)
process_unit_to_form_the_same_automaton_unit_lists
(unit, regexp, 0);
*************** form_the_same_automaton_unit_lists ()
*** 5060,5067 ****
decl = description->decls [i];
if (decl->mode == dm_unit)
{
! decl->decl.unit.the_same_automaton_message_reported_p = FALSE;
! decl->decl.unit.the_same_automaton_unit = &decl->decl.unit;
}
}
for (i = 0; i < description->decls_num; i++)
--- 5302,5309 ----
decl = description->decls [i];
if (decl->mode == dm_unit)
{
! DECL_UNIT (decl)->the_same_automaton_message_reported_p = FALSE;
! DECL_UNIT (decl)->the_same_automaton_unit = DECL_UNIT (decl);
}
}
for (i = 0; i < description->decls_num; i++)
*************** form_the_same_automaton_unit_lists ()
*** 5069,5075 ****
decl = description->decls [i];
if (decl->mode == dm_insn_reserv)
form_the_same_automaton_unit_lists_from_regexp
! (decl->decl.insn_reserv.transformed_regexp);
}
free (the_same_automaton_lists);
}
--- 5311,5317 ----
decl = description->decls [i];
if (decl->mode == dm_insn_reserv)
form_the_same_automaton_unit_lists_from_regexp
! (DECL_INSN_RESERV (decl)->transformed_regexp);
}
free (the_same_automaton_lists);
}
*************** check_unit_distributions_to_automata ()
*** 5089,5095 ****
decl = description->decls [i];
if (decl->mode == dm_unit)
{
! start_unit_decl = &decl->decl.unit;
if (!start_unit_decl->the_same_automaton_message_reported_p)
for (unit_decl = start_unit_decl->the_same_automaton_unit;
unit_decl != start_unit_decl;
--- 5331,5337 ----
decl = description->decls [i];
if (decl->mode == dm_unit)
{
! start_unit_decl = DECL_UNIT (decl);
if (!start_unit_decl->the_same_automaton_message_reported_p)
for (unit_decl = start_unit_decl->the_same_automaton_unit;
unit_decl != start_unit_decl;
*************** process_seq_for_forming_states (regexp,
*** 5131,5148 ****
return curr_cycle;
else if (regexp->mode == rm_unit)
{
! if (regexp->regexp.unit.unit_decl->corresponding_automaton_num
== automaton->automaton_order_num)
set_state_reserv (state_being_formed, curr_cycle,
! regexp->regexp.unit.unit_decl->unit_num);
return curr_cycle;
}
else if (regexp->mode == rm_sequence)
{
! for (i = 0; i < regexp->regexp.sequence.regexps_num; i++)
curr_cycle
= process_seq_for_forming_states
! (regexp->regexp.sequence.regexps [i], automaton, curr_cycle) + 1;
return curr_cycle;
}
else if (regexp->mode == rm_allof)
--- 5373,5390 ----
return curr_cycle;
else if (regexp->mode == 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)
{
! 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)
*************** process_seq_for_forming_states (regexp,
*** 5150,5160 ****
int finish_cycle = 0;
int cycle;
! for (i = 0; i < regexp->regexp.allof.regexps_num; i++)
{
! cycle
! = process_seq_for_forming_states (regexp->regexp.allof.regexps [i],
! automaton, curr_cycle);
if (finish_cycle < cycle)
finish_cycle = cycle;
}
--- 5392,5402 ----
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;
}
*************** process_alts_for_forming_states (regexp,
*** 5222,5229 ****
/* We processes it in reverse order to get list with the same
order as in the description. See also the previous
commentary. */
! for (i = regexp->regexp.oneof.regexps_num - 1; i >= 0; i--)
! process_alts_for_forming_states (regexp->regexp.oneof.regexps [i],
automaton, 1);
}
}
--- 5464,5471 ----
/* We processes it in reverse order to get list with the same
order as in the description. See also the previous
commentary. */
! for (i = REGEXP_ONEOF (regexp)->regexps_num - 1; i >= 0; i--)
! process_alts_for_forming_states (REGEXP_ONEOF (regexp)->regexps [i],
automaton, 1);
}
}
*************** create_alt_states (automaton)
*** 5240,5246 ****
curr_ainsn = curr_ainsn->next_ainsn)
{
reserv_decl = curr_ainsn->insn_reserv_decl;
! if (reserv_decl != &advance_cycle_insn_decl->decl.insn_reserv)
{
curr_ainsn->alt_states = NULL;
process_alts_for_forming_states (reserv_decl->transformed_regexp,
--- 5482,5488 ----
curr_ainsn = curr_ainsn->next_ainsn)
{
reserv_decl = curr_ainsn->insn_reserv_decl;
! if (reserv_decl != DECL_INSN_RESERV (advance_cycle_insn_decl))
{
curr_ainsn->alt_states = NULL;
process_alts_for_forming_states (reserv_decl->transformed_regexp,
*************** form_ainsn_with_same_reservs (automaton)
*** 5273,5279 ****
curr_ainsn != NULL;
curr_ainsn = curr_ainsn->next_ainsn)
if (curr_ainsn->insn_reserv_decl
! == &advance_cycle_insn_decl->decl.insn_reserv)
{
curr_ainsn->next_same_reservs_insn = NULL;
curr_ainsn->first_insn_with_same_reservs = 1;
--- 5515,5521 ----
curr_ainsn != NULL;
curr_ainsn = curr_ainsn->next_ainsn)
if (curr_ainsn->insn_reserv_decl
! == DECL_INSN_RESERV (advance_cycle_insn_decl))
{
curr_ainsn->next_same_reservs_insn = NULL;
curr_ainsn->first_insn_with_same_reservs = 1;
*************** make_automaton (automaton)
*** 5337,5343 ****
if (ainsn->first_insn_with_same_reservs)
{
insn_reserv_decl = ainsn->insn_reserv_decl;
! if (insn_reserv_decl != &advance_cycle_insn_decl->decl.insn_reserv)
{
/* We process alt_states in the same order as they are
present in the description. */
--- 5579,5585 ----
if (ainsn->first_insn_with_same_reservs)
{
insn_reserv_decl = ainsn->insn_reserv_decl;
! if (insn_reserv_decl != DECL_INSN_RESERV (advance_cycle_insn_decl))
{
/* We process alt_states in the same order as they are
present in the description. */
*************** form_arcs_marked_by_insn (state)
*** 5404,5410 ****
{
decl = description->decls [i];
if (decl->mode == dm_insn_reserv)
! decl->decl.insn_reserv.arcs_marked_by_insn = NULL;
}
for (arc = first_out_arc (state); arc != NULL; arc = next_out_arc (arc))
{
--- 5646,5652 ----
{
decl = description->decls [i];
if (decl->mode == dm_insn_reserv)
! DECL_INSN_RESERV (decl)->arcs_marked_by_insn = NULL;
}
for (arc = first_out_arc (state); arc != NULL; arc = next_out_arc (arc))
{
*************** NDFA_to_DFA (automaton)
*** 5536,5542 ****
decl = description->decls [i];
if (decl->mode == dm_insn_reserv)
create_composed_state
! (state, decl->decl.insn_reserv.arcs_marked_by_insn,
&state_stack);
}
}
--- 5778,5784 ----
decl = description->decls [i];
if (decl->mode == dm_insn_reserv)
create_composed_state
! (state, DECL_INSN_RESERV (decl)->arcs_marked_by_insn,
&state_stack);
}
}
*************** set_new_cycle_flags (state)
*** 5917,5923 ****
for (arc = first_out_arc (state); arc != NULL; arc = next_out_arc (arc))
if (arc->insn->insn_reserv_decl
! == &advance_cycle_insn_decl->decl.insn_reserv)
arc->to_state->new_cycle_p = 1;
}
--- 6159,6165 ----
for (arc = first_out_arc (state); arc != NULL; arc = next_out_arc (arc))
if (arc->insn->insn_reserv_decl
! == DECL_INSN_RESERV (advance_cycle_insn_decl))
arc->to_state->new_cycle_p = 1;
}
*************** estimate_one_automaton_bound ()
*** 6207,6213 ****
decl = description->decls [i];
if (decl->mode == dm_unit)
{
! root_value = exp (log (decl->decl.unit.max_occ_cycle_num + 1.0)
/ automata_num);
if (MAX_FLOATING_POINT_VALUE_FOR_AUTOMATON_BOUND / root_value
> one_automaton_estimation_bound)
--- 6449,6455 ----
decl = description->decls [i];
if (decl->mode == dm_unit)
{
! root_value = exp (log (DECL_UNIT (decl)->max_occ_cycle_num + 1.0)
/ automata_num);
if (MAX_FLOATING_POINT_VALUE_FOR_AUTOMATON_BOUND / root_value
> one_automaton_estimation_bound)
*************** compare_max_occ_cycle_nums (unit_decl_1,
*** 6224,6234 ****
const void *unit_decl_1;
const void *unit_decl_2;
{
! if (((*(decl_t *) unit_decl_1)->decl.unit.max_occ_cycle_num)
! < ((*(decl_t *) unit_decl_2)->decl.unit.max_occ_cycle_num))
return 1;
! else if (((*(decl_t *) unit_decl_1)->decl.unit.max_occ_cycle_num)
! == ((*(decl_t *) unit_decl_2)->decl.unit.max_occ_cycle_num))
return 0;
else
return -1;
--- 6466,6476 ----
const void *unit_decl_1;
const void *unit_decl_2;
{
! if ((DECL_UNIT (*(decl_t *) unit_decl_1)->max_occ_cycle_num)
! < (DECL_UNIT (*(decl_t *) unit_decl_2)->max_occ_cycle_num))
return 1;
! else if ((DECL_UNIT (*(decl_t *) unit_decl_1)->max_occ_cycle_num)
! == (DECL_UNIT (*(decl_t *) unit_decl_2)->max_occ_cycle_num))
return 0;
else
return -1;
*************** units_to_automata_heuristic_distr ()
*** 6262,6269 ****
sizeof (decl_t), compare_max_occ_cycle_nums);
automaton_num = 0;
unit_decl_ptr = VLA_PTR_BEGIN (unit_decls);
! bound_value = (*unit_decl_ptr)->decl.unit.max_occ_cycle_num;
! (*unit_decl_ptr)->decl.unit.corresponding_automaton_num = automaton_num;
for (unit_decl_ptr++;
unit_decl_ptr <= (decl_t *) VLA_PTR_LAST (unit_decls);
unit_decl_ptr++)
--- 6504,6511 ----
sizeof (decl_t), compare_max_occ_cycle_nums);
automaton_num = 0;
unit_decl_ptr = VLA_PTR_BEGIN (unit_decls);
! bound_value = DECL_UNIT (*unit_decl_ptr)->max_occ_cycle_num;
! DECL_UNIT (*unit_decl_ptr)->corresponding_automaton_num = automaton_num;
for (unit_decl_ptr++;
unit_decl_ptr <= (decl_t *) VLA_PTR_LAST (unit_decls);
unit_decl_ptr++)
*************** units_to_automata_heuristic_distr ()
*** 6276,6289 ****
&& ((automata_num - automaton_num - 1 == rest_units_num)
|| (bound_value
> (estimation_bound
! / ((*unit_decl_ptr)->decl.unit.max_occ_cycle_num)))))
{
! bound_value = (*unit_decl_ptr)->decl.unit.max_occ_cycle_num;
automaton_num++;
}
else
! bound_value *= (*unit_decl_ptr)->decl.unit.max_occ_cycle_num;
! (*unit_decl_ptr)->decl.unit.corresponding_automaton_num = automaton_num;
}
if (automaton_num != automata_num - 1)
abort ();
--- 6518,6531 ----
&& ((automata_num - automaton_num - 1 == rest_units_num)
|| (bound_value
> (estimation_bound
! / (DECL_UNIT (*unit_decl_ptr)->max_occ_cycle_num)))))
{
! bound_value = DECL_UNIT (*unit_decl_ptr)->max_occ_cycle_num;
automaton_num++;
}
else
! 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 ();
*************** create_ainsns ()
*** 6310,6316 ****
if (decl->mode == dm_insn_reserv)
{
curr_ainsn = create_node (sizeof (struct ainsn));
! curr_ainsn->insn_reserv_decl = &decl->decl.insn_reserv;
curr_ainsn->important_p = FALSE;
curr_ainsn->next_ainsn = NULL;
if (prev_ainsn == NULL)
--- 6552,6558 ----
if (decl->mode == dm_insn_reserv)
{
curr_ainsn = create_node (sizeof (struct ainsn));
! curr_ainsn->insn_reserv_decl = DECL_INSN_RESERV (decl);
curr_ainsn->important_p = FALSE;
curr_ainsn->next_ainsn = NULL;
if (prev_ainsn == NULL)
*************** units_to_automata_distr ()
*** 6336,6349 ****
decl = description->decls [i];
if (decl->mode == dm_unit)
{
! if (decl->decl.unit.automaton_decl == NULL
! || (decl->decl.unit.automaton_decl->corresponding_automaton
== NULL))
/* Distribute to the first automaton. */
! decl->decl.unit.corresponding_automaton_num = 0;
else
! decl->decl.unit.corresponding_automaton_num
! = (decl->decl.unit.automaton_decl
->corresponding_automaton->automaton_order_num);
}
}
--- 6578,6591 ----
decl = description->decls [i];
if (decl->mode == dm_unit)
{
! if (DECL_UNIT (decl)->automaton_decl == NULL
! || (DECL_UNIT (decl)->automaton_decl->corresponding_automaton
== NULL))
/* Distribute to the first automaton. */
! DECL_UNIT (decl)->corresponding_automaton_num = 0;
else
! DECL_UNIT (decl)->corresponding_automaton_num
! = (DECL_UNIT (decl)->automaton_decl
->corresponding_automaton->automaton_order_num);
}
}
*************** create_automata ()
*** 6386,6399 ****
{
decl = description->decls [i];
if (decl->mode == dm_automaton
! && decl->decl.automaton.automaton_is_used)
{
curr_automaton = create_node (sizeof (struct automaton));
curr_automaton->ainsn_list = create_ainsns ();
curr_automaton->corresponding_automaton_decl
! = &decl->decl.automaton;
curr_automaton->next_automaton = NULL;
! decl->decl.automaton.corresponding_automaton = curr_automaton;
curr_automaton->automaton_order_num = curr_automaton_num;
if (prev_automaton == NULL)
description->first_automaton = curr_automaton;
--- 6628,6641 ----
{
decl = description->decls [i];
if (decl->mode == dm_automaton
! && DECL_AUTOMATON (decl)->automaton_is_used)
{
curr_automaton = create_node (sizeof (struct automaton));
curr_automaton->ainsn_list = create_ainsns ();
curr_automaton->corresponding_automaton_decl
! = DECL_AUTOMATON (decl);
curr_automaton->next_automaton = NULL;
! DECL_AUTOMATON (decl)->corresponding_automaton = curr_automaton;
curr_automaton->automaton_order_num = curr_automaton_num;
if (prev_automaton == NULL)
description->first_automaton = curr_automaton;
*************** form_regexp (regexp)
*** 6459,6518 ****
if (regexp->mode == rm_unit || regexp->mode == rm_reserv)
{
const char *name = (regexp->mode == rm_unit
! ? regexp->regexp.unit.name
! : regexp->regexp.reserv.name);
obstack_grow (&irp, name, strlen (name));
}
else if (regexp->mode == rm_sequence)
! for (i = 0; i < regexp->regexp.sequence.regexps_num; i++)
{
if (i != 0)
obstack_1grow (&irp, ',');
! form_regexp (regexp->regexp.sequence.regexps [i]);
}
else if (regexp->mode == rm_allof)
{
obstack_1grow (&irp, '(');
! for (i = 0; i < regexp->regexp.allof.regexps_num; i++)
{
if (i != 0)
obstack_1grow (&irp, '+');
! if (regexp->regexp.allof.regexps[i]->mode == rm_sequence
! || regexp->regexp.oneof.regexps[i]->mode == rm_oneof)
obstack_1grow (&irp, '(');
! form_regexp (regexp->regexp.allof.regexps [i]);
! if (regexp->regexp.allof.regexps[i]->mode == rm_sequence
! || regexp->regexp.oneof.regexps[i]->mode == rm_oneof)
obstack_1grow (&irp, ')');
}
obstack_1grow (&irp, ')');
}
else if (regexp->mode == rm_oneof)
! for (i = 0; i < regexp->regexp.oneof.regexps_num; i++)
{
if (i != 0)
obstack_1grow (&irp, '|');
! if (regexp->regexp.oneof.regexps[i]->mode == rm_sequence)
obstack_1grow (&irp, '(');
! form_regexp (regexp->regexp.oneof.regexps [i]);
! if (regexp->regexp.oneof.regexps[i]->mode == rm_sequence)
obstack_1grow (&irp, ')');
}
else if (regexp->mode == rm_repeat)
{
char digits [30];
! if (regexp->regexp.repeat.regexp->mode == rm_sequence
! || regexp->regexp.repeat.regexp->mode == rm_allof
! || regexp->regexp.repeat.regexp->mode == rm_oneof)
obstack_1grow (&irp, '(');
! form_regexp (regexp->regexp.repeat.regexp);
! if (regexp->regexp.repeat.regexp->mode == rm_sequence
! || regexp->regexp.repeat.regexp->mode == rm_allof
! || regexp->regexp.repeat.regexp->mode == rm_oneof)
obstack_1grow (&irp, ')');
! sprintf (digits, "*%d", regexp->regexp.repeat.repeat_num);
obstack_grow (&irp, digits, strlen (digits));
}
else if (regexp->mode == rm_nothing)
--- 6701,6760 ----
if (regexp->mode == rm_unit || regexp->mode == rm_reserv)
{
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++)
{
if (i != 0)
obstack_1grow (&irp, ',');
! form_regexp (REGEXP_SEQUENCE (regexp)->regexps [i]);
}
else if (regexp->mode == rm_allof)
{
obstack_1grow (&irp, '(');
! for (i = 0; i < REGEXP_ALLOF (regexp)->regexps_num; i++)
{
if (i != 0)
obstack_1grow (&irp, '+');
! if (REGEXP_ALLOF (regexp)->regexps[i]->mode == rm_sequence
! || REGEXP_ALLOF (regexp)->regexps[i]->mode == rm_oneof)
obstack_1grow (&irp, '(');
! form_regexp (REGEXP_ALLOF (regexp)->regexps [i]);
! if (REGEXP_ALLOF (regexp)->regexps[i]->mode == rm_sequence
! || REGEXP_ALLOF (regexp)->regexps[i]->mode == rm_oneof)
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)
obstack_1grow (&irp, ')');
}
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)
*************** longest_path_length (state)
*** 6602,6608 ****
/* Ignore cycles containing one state and `cycle advance' arcs. */
if (arc->to_state != state
&& (arc->insn->insn_reserv_decl
! != &advance_cycle_insn_decl->decl.insn_reserv))
{
length = longest_path_length (arc->to_state);
if (length > result)
--- 6844,6850 ----
/* Ignore cycles containing one state and `cycle advance' arcs. */
if (arc->to_state != state
&& (arc->insn->insn_reserv_decl
! != DECL_INSN_RESERV (advance_cycle_insn_decl)))
{
length = longest_path_length (arc->to_state);
if (length > result)
*************** min_issue_delay_pass_states (state, ains
*** 7457,7463 ****
if (insn_issue_delay != -1)
{
if (arc->insn->insn_reserv_decl
! == &advance_cycle_insn_decl->decl.insn_reserv)
insn_issue_delay++;
if (min_insn_issue_delay == -1
|| min_insn_issue_delay > insn_issue_delay)
--- 7699,7705 ----
if (insn_issue_delay != -1)
{
if (arc->insn->insn_reserv_decl
! == DECL_INSN_RESERV (advance_cycle_insn_decl))
insn_issue_delay++;
if (min_insn_issue_delay == -1
|| min_insn_issue_delay > insn_issue_delay)
*************** output_dead_lock_vect (automaton)
*** 7614,7620 ****
VLA_HWINT (dead_lock_vect, (*state_ptr)->order_state_num)
= (next_out_arc (arc) == NULL
&& (arc->insn->insn_reserv_decl
! == &advance_cycle_insn_decl->decl.insn_reserv) ? 1 : 0);
#ifndef NDEBUG
if (VLA_HWINT (dead_lock_vect, (*state_ptr)->order_state_num))
locked_states_num++;
--- 7856,7862 ----
VLA_HWINT (dead_lock_vect, (*state_ptr)->order_state_num)
= (next_out_arc (arc) == NULL
&& (arc->insn->insn_reserv_decl
! == DECL_INSN_RESERV (advance_cycle_insn_decl)) ? 1 : 0);
#ifndef NDEBUG
if (VLA_HWINT (dead_lock_vect, (*state_ptr)->order_state_num))
locked_states_num++;
*************** output_tables ()
*** 7715,7721 ****
}
}
fprintf (output_file, "\n#define %s %d\n\n", ADVANCE_CYCLE_VALUE_NAME,
! advance_cycle_insn_decl->decl.insn_reserv.insn_num);
}
/* The function outputs definition and value of PHR interface variable
--- 7957,7963 ----
}
}
fprintf (output_file, "\n#define %s %d\n\n", ADVANCE_CYCLE_VALUE_NAME,
! DECL_INSN_RESERV (advance_cycle_insn_decl)->insn_num);
}
/* The function outputs definition and value of PHR interface variable
*************** static void
*** 7739,7773 ****
output_insn_code_cases (output_automata_list_code)
void (*output_automata_list_code) (automata_list_el_t);
{
! decl_t decl, decl_2;
int i, j;
for (i = 0; i < description->decls_num; i++)
{
decl = description->decls [i];
if (decl->mode == dm_insn_reserv)
! decl->decl.insn_reserv.processed_p = FALSE;
}
for (i = 0; i < description->decls_num; i++)
{
decl = description->decls [i];
! if (decl->mode == dm_insn_reserv && !decl->decl.insn_reserv.processed_p)
{
for (j = i; j < description->decls_num; j++)
{
! decl_2 = description->decls [j];
! if (decl_2->mode == dm_insn_reserv
! && (decl_2->decl.insn_reserv.important_automata_list
! == decl->decl.insn_reserv.important_automata_list))
{
! decl_2->decl.insn_reserv.processed_p = TRUE;
fprintf (output_file, " case %d: /* %s */\n",
! decl_2->decl.insn_reserv.insn_num,
! decl_2->decl.insn_reserv.name);
}
}
(*output_automata_list_code)
! (decl->decl.insn_reserv.important_automata_list);
}
}
}
--- 7981,8016 ----
output_insn_code_cases (output_automata_list_code)
void (*output_automata_list_code) (automata_list_el_t);
{
! decl_t decl, decl2;
int i, j;
for (i = 0; i < description->decls_num; i++)
{
decl = description->decls [i];
if (decl->mode == dm_insn_reserv)
! DECL_INSN_RESERV (decl)->processed_p = FALSE;
}
for (i = 0; i < description->decls_num; i++)
{
decl = description->decls [i];
! if (decl->mode == dm_insn_reserv
! && !DECL_INSN_RESERV (decl)->processed_p)
{
for (j = i; j < description->decls_num; j++)
{
! decl2 = description->decls [j];
! if (decl2->mode == dm_insn_reserv
! && (DECL_INSN_RESERV (decl2)->important_automata_list
! == DECL_INSN_RESERV (decl)->important_automata_list))
{
! DECL_INSN_RESERV (decl2)->processed_p = TRUE;
fprintf (output_file, " case %d: /* %s */\n",
! DECL_INSN_RESERV (decl2)->insn_num,
! DECL_INSN_RESERV (decl2)->name);
}
}
(*output_automata_list_code)
! (DECL_INSN_RESERV (decl)->important_automata_list);
}
}
}
*************** output_internal_insn_latency_func ()
*** 8278,8293 ****
if (decl->mode == dm_insn_reserv)
{
fprintf (output_file, " case %d:\n",
! decl->decl.insn_reserv.insn_num);
! if (decl->decl.insn_reserv.bypass_list == NULL)
fprintf (output_file, " return (%s != %s ? %d : 0);\n",
INTERNAL_INSN2_CODE_NAME, ADVANCE_CYCLE_VALUE_NAME,
! decl->decl.insn_reserv.default_latency);
else
{
fprintf (output_file, " switch (%s)\n {\n",
INTERNAL_INSN2_CODE_NAME);
! for (bypass = decl->decl.insn_reserv.bypass_list;
bypass != NULL;
bypass = bypass->next)
{
--- 8521,8536 ----
if (decl->mode == dm_insn_reserv)
{
fprintf (output_file, " case %d:\n",
! DECL_INSN_RESERV (decl)->insn_num);
! if (DECL_INSN_RESERV (decl)->bypass_list == NULL)
fprintf (output_file, " return (%s != %s ? %d : 0);\n",
INTERNAL_INSN2_CODE_NAME, ADVANCE_CYCLE_VALUE_NAME,
! DECL_INSN_RESERV (decl)->default_latency);
else
{
fprintf (output_file, " switch (%s)\n {\n",
INTERNAL_INSN2_CODE_NAME);
! for (bypass = DECL_INSN_RESERV (decl)->bypass_list;
bypass != NULL;
bypass = bypass->next)
{
*************** output_internal_insn_latency_func ()
*** 8301,8313 ****
" return (%s (%s, %s) ? %d : %d);\n",
bypass->bypass_guard_name, INSN_PARAMETER_NAME,
INSN2_PARAMETER_NAME, bypass->latency,
! decl->decl.insn_reserv.default_latency);
}
fprintf (output_file, " default:\n");
fprintf (output_file,
" return (%s != %s ? %d : 0);\n }\n",
INTERNAL_INSN2_CODE_NAME, ADVANCE_CYCLE_VALUE_NAME,
! decl->decl.insn_reserv.default_latency);
}
}
--- 8544,8556 ----
" return (%s (%s, %s) ? %d : %d);\n",
bypass->bypass_guard_name, INSN_PARAMETER_NAME,
INSN2_PARAMETER_NAME, bypass->latency,
! DECL_INSN_RESERV (decl)->default_latency);
}
fprintf (output_file, " default:\n");
fprintf (output_file,
" return (%s != %s ? %d : 0);\n }\n",
INTERNAL_INSN2_CODE_NAME, ADVANCE_CYCLE_VALUE_NAME,
! DECL_INSN_RESERV (decl)->default_latency);
}
}
*************** output_print_reservation_func ()
*** 8366,8376 ****
if (decl->mode == dm_insn_reserv && decl != advance_cycle_insn_decl)
{
fprintf (output_file,
! " case %d:\n", decl->decl.insn_reserv.insn_num);
fprintf (output_file,
" fprintf (%s, \"%s\");\n break;\n",
FILE_PARAMETER_NAME,
! regexp_representation (decl->decl.insn_reserv.regexp));
finish_regexp_representation ();
}
}
--- 8609,8619 ----
if (decl->mode == dm_insn_reserv && decl != advance_cycle_insn_decl)
{
fprintf (output_file,
! " case %d:\n", DECL_INSN_RESERV (decl)->insn_num);
fprintf (output_file,
" fprintf (%s, \"%s\");\n break;\n",
FILE_PARAMETER_NAME,
! regexp_representation (DECL_INSN_RESERV (decl)->regexp));
finish_regexp_representation ();
}
}
*************** output_description ()
*** 8557,8581 ****
decl = description->decls [i];
if (decl->mode == dm_unit)
{
! if (decl->decl.unit.excl_list != NULL)
{
fprintf (output_description_file, "unit %s exlusion_set: ",
! decl->decl.unit.name);
! output_unit_set_el_list (decl->decl.unit.excl_list);
fprintf (output_description_file, "\n");
}
! if (decl->decl.unit.presence_list != NULL)
{
fprintf (output_description_file, "unit %s presence_set: ",
! decl->decl.unit.name);
! output_unit_set_el_list (decl->decl.unit.presence_list);
fprintf (output_description_file, "\n");
}
! if (decl->decl.unit.absence_list != NULL)
{
fprintf (output_description_file, "unit %s absence_set: ",
! decl->decl.unit.name);
! output_unit_set_el_list (decl->decl.unit.absence_list);
fprintf (output_description_file, "\n");
}
}
--- 8800,8824 ----
decl = description->decls [i];
if (decl->mode == dm_unit)
{
! if (DECL_UNIT (decl)->excl_list != NULL)
{
fprintf (output_description_file, "unit %s exlusion_set: ",
! DECL_UNIT (decl)->name);
! output_unit_set_el_list (DECL_UNIT (decl)->excl_list);
fprintf (output_description_file, "\n");
}
! if (DECL_UNIT (decl)->presence_list != NULL)
{
fprintf (output_description_file, "unit %s presence_set: ",
! DECL_UNIT (decl)->name);
! output_unit_set_el_list (DECL_UNIT (decl)->presence_list);
fprintf (output_description_file, "\n");
}
! if (DECL_UNIT (decl)->absence_list != NULL)
{
fprintf (output_description_file, "unit %s absence_set: ",
! DECL_UNIT (decl)->name);
! output_unit_set_el_list (DECL_UNIT (decl)->absence_list);
fprintf (output_description_file, "\n");
}
}
*************** output_description ()
*** 8587,8610 ****
if (decl->mode == dm_reserv)
{
fprintf (output_description_file, "reservation ");
! fprintf (output_description_file, decl->decl.reserv.name);
fprintf (output_description_file, ": ");
! output_regexp (decl->decl.reserv.regexp);
fprintf (output_description_file, "\n");
}
else if (decl->mode == dm_insn_reserv && decl != advance_cycle_insn_decl)
{
fprintf (output_description_file, "insn reservation %s ",
! decl->decl.insn_reserv.name);
! print_rtl (output_description_file, decl->decl.insn_reserv.condexp);
fprintf (output_description_file, ": ");
! output_regexp (decl->decl.insn_reserv.regexp);
fprintf (output_description_file, "\n");
}
else if (decl->mode == dm_bypass)
fprintf (output_description_file, "bypass %d %s %s\n",
! decl->decl.bypass.latency, decl->decl.bypass.out_insn_name,
! decl->decl.bypass.in_insn_name);
}
fprintf (output_description_file, "\n\f\n");
}
--- 8830,8855 ----
if (decl->mode == dm_reserv)
{
fprintf (output_description_file, "reservation ");
! fprintf (output_description_file, DECL_RESERV (decl)->name);
fprintf (output_description_file, ": ");
! output_regexp (DECL_RESERV (decl)->regexp);
fprintf (output_description_file, "\n");
}
else if (decl->mode == dm_insn_reserv && decl != advance_cycle_insn_decl)
{
fprintf (output_description_file, "insn reservation %s ",
! DECL_INSN_RESERV (decl)->name);
! print_rtl (output_description_file,
! DECL_INSN_RESERV (decl)->condexp);
fprintf (output_description_file, ": ");
! output_regexp (DECL_INSN_RESERV (decl)->regexp);
fprintf (output_description_file, "\n");
}
else if (decl->mode == dm_bypass)
fprintf (output_description_file, "bypass %d %s %s\n",
! DECL_BYPASS (decl)->latency,
! DECL_BYPASS (decl)->out_insn_name,
! DECL_BYPASS (decl)->in_insn_name);
}
fprintf (output_description_file, "\n\f\n");
}
*************** output_automaton_units (automaton)
*** 8644,8654 ****
{
decl = description->decls [i];
if (decl->mode == dm_unit
! && (decl->decl.unit.corresponding_automaton_num
== automaton->automaton_order_num))
{
there_is_an_automaton_unit = 1;
! name = decl->decl.unit.name;
if (curr_line_length + strlen (name) + 1 > MAX_LINE_LENGTH )
{
curr_line_length = strlen (name) + 4;
--- 8889,8899 ----
{
decl = description->decls [i];
if (decl->mode == dm_unit
! && (DECL_UNIT (decl)->corresponding_automaton_num
== automaton->automaton_order_num))
{
there_is_an_automaton_unit = 1;
! name = DECL_UNIT (decl)->name;
if (curr_line_length + strlen (name) + 1 > MAX_LINE_LENGTH )
{
curr_line_length = strlen (name) + 4;
*************** generate ()
*** 8953,8960 ****
! /* The following function creates attribute which order number of insn
! in pipeline hazard description translator. */
static void
make_insn_alts_attr ()
{
--- 9198,9205 ----
! /* The following function creates insn attribute whose values are
! number alternatives in insn reservations. */
static void
make_insn_alts_attr ()
{
*************** make_insn_alts_attr ()
*** 8970,8979 ****
decl = description->decls [i];
if (decl->mode == dm_insn_reserv && decl != advance_cycle_insn_decl)
{
! XVECEXP (condexp, 0, 2 * insn_num) = decl->decl.insn_reserv.condexp;
XVECEXP (condexp, 0, 2 * insn_num + 1)
! = make_numeric_value (decl->decl.insn_reserv.transformed_regexp
! ->regexp.oneof.regexps_num);
insn_num++;
}
}
--- 9215,9227 ----
decl = description->decls [i];
if (decl->mode == dm_insn_reserv && decl != advance_cycle_insn_decl)
{
! XVECEXP (condexp, 0, 2 * insn_num)
! = DECL_INSN_RESERV (decl)->condexp;
XVECEXP (condexp, 0, 2 * insn_num + 1)
! = make_numeric_value
! (DECL_INSN_RESERV (decl)->transformed_regexp->mode != rm_oneof
! ? 1 : REGEXP_ONEOF (DECL_INSN_RESERV (decl)
! ->transformed_regexp)->regexps_num);
insn_num++;
}
}
*************** make_internal_dfa_insn_code_attr ()
*** 8998,9013 ****
condexp = rtx_alloc (COND);
XVEC (condexp, 0) = rtvec_alloc ((description->insns_num - 1) * 2);
! XEXP (condexp, 1) = make_numeric_value (advance_cycle_insn_decl
! ->decl.insn_reserv.insn_num + 1);
for (i = insn_num = 0; i < description->decls_num; i++)
{
decl = description->decls [i];
if (decl->mode == dm_insn_reserv && decl != advance_cycle_insn_decl)
{
! XVECEXP (condexp, 0, 2 * insn_num) = decl->decl.insn_reserv.condexp;
XVECEXP (condexp, 0, 2 * insn_num + 1)
! = make_numeric_value (decl->decl.insn_reserv.insn_num);
insn_num++;
}
}
--- 9246,9263 ----
condexp = rtx_alloc (COND);
XVEC (condexp, 0) = rtvec_alloc ((description->insns_num - 1) * 2);
! XEXP (condexp, 1)
! = make_numeric_value (DECL_INSN_RESERV (advance_cycle_insn_decl)
! ->insn_num + 1);
for (i = insn_num = 0; i < description->decls_num; i++)
{
decl = description->decls [i];
if (decl->mode == dm_insn_reserv && decl != advance_cycle_insn_decl)
{
! XVECEXP (condexp, 0, 2 * insn_num)
! = DECL_INSN_RESERV (decl)->condexp;
XVECEXP (condexp, 0, 2 * insn_num + 1)
! = make_numeric_value (DECL_INSN_RESERV (decl)->insn_num);
insn_num++;
}
}
*************** make_default_insn_latency_attr ()
*** 9039,9047 ****
decl = description->decls [i];
if (decl->mode == dm_insn_reserv && decl != advance_cycle_insn_decl)
{
! XVECEXP (condexp, 0, 2 * insn_num) = decl->decl.insn_reserv.condexp;
XVECEXP (condexp, 0, 2 * insn_num + 1)
! = make_numeric_value (decl->decl.insn_reserv.default_latency);
insn_num++;
}
}
--- 9289,9298 ----
decl = description->decls [i];
if (decl->mode == dm_insn_reserv && decl != advance_cycle_insn_decl)
{
! XVECEXP (condexp, 0, 2 * insn_num)
! = DECL_INSN_RESERV (decl)->condexp;
XVECEXP (condexp, 0, 2 * insn_num + 1)
! = make_numeric_value (DECL_INSN_RESERV (decl)->default_latency);
insn_num++;
}
}
*************** make_bypass_attr ()
*** 9069,9076 ****
{
decl = description->decls [i];
if (decl->mode == dm_insn_reserv
! && decl->decl.insn_reserv.condexp != NULL
! && decl->decl.insn_reserv.bypass_list != NULL)
bypass_insns_num++;
}
if (bypass_insns_num == 0)
--- 9320,9327 ----
{
decl = description->decls [i];
if (decl->mode == dm_insn_reserv
! && DECL_INSN_RESERV (decl)->condexp != NULL
! && DECL_INSN_RESERV (decl)->bypass_list != NULL)
bypass_insns_num++;
}
if (bypass_insns_num == 0)
*************** make_bypass_attr ()
*** 9085,9095 ****
{
decl = description->decls [i];
if (decl->mode == dm_insn_reserv
! && decl->decl.insn_reserv.condexp != NULL
! && decl->decl.insn_reserv.bypass_list != NULL)
{
XVECEXP (result_rtx, 0, 2 * bypass_insn)
! = decl->decl.insn_reserv.condexp;
XVECEXP (result_rtx, 0, 2 * bypass_insn + 1)
= make_numeric_value (1);
bypass_insn++;
--- 9336,9346 ----
{
decl = description->decls [i];
if (decl->mode == dm_insn_reserv
! && DECL_INSN_RESERV (decl)->condexp != NULL
! && DECL_INSN_RESERV (decl)->bypass_list != NULL)
{
XVECEXP (result_rtx, 0, 2 * bypass_insn)
! = DECL_INSN_RESERV (decl)->condexp;
XVECEXP (result_rtx, 0, 2 * bypass_insn + 1)
= make_numeric_value (1);
bypass_insn++;
*************** form_important_insn_automata_lists ()
*** 9310,9321 ****
ainsn != NULL;
ainsn = ainsn->next_ainsn)
if (ainsn->important_p
! && ainsn->insn_reserv_decl == &decl->decl.insn_reserv)
{
automata_list_add (automaton);
break;
}
! decl->decl.insn_reserv.important_automata_list
= automata_list_finish ();
}
}
--- 9561,9572 ----
ainsn != NULL;
ainsn = ainsn->next_ainsn)
if (ainsn->important_p
! && ainsn->insn_reserv_decl == DECL_INSN_RESERV (decl))
{
automata_list_add (automaton);
break;
}
! DECL_INSN_RESERV (decl)->important_automata_list
= automata_list_finish ();
}
}
*************** expand_automata ()
*** 9338,9345 ****
{
description->decls [i] = VLA_PTR (decls, i);
if (description->decls [i]->mode == dm_unit
! && description->decls [i]->decl.unit.query_p)
! description->decls [i]->decl.unit.query_num
= description->query_units_num++;
}
all_time = create_ticker ();
--- 9589,9596 ----
{
description->decls [i] = VLA_PTR (decls, i);
if (description->decls [i]->mode == dm_unit
! && DECL_UNIT (description->decls [i])->query_p)
! DECL_UNIT (description->decls [i])->query_num
= description->query_units_num++;
}
all_time = create_ticker ();
More information about the Gcc-patches
mailing list