Commit d1427a17 by Richard Sandiford Committed by Richard Sandiford

gensupport.h (get_c_test): Declare.

gcc/
	* gensupport.h (get_c_test): Declare.
	* gensupport.c (get_c_test): New function.
	* genconditions.c (main): Use it.
	* genrecog.c (validate_pattern): Likewise.
	(match_pattern_1): Likewise.  Remove c_test argument.
	(match_pattern): Update accordingly and remove c_test argument.
	(main): Update accordingly.

From-SVN: r226634
parent ba0ee63d
2015-08-05 Richard Sandiford <richard.sandiford@arm.com> 2015-08-05 Richard Sandiford <richard.sandiford@arm.com>
* gensupport.h (get_c_test): Declare.
* gensupport.c (get_c_test): New function.
* genconditions.c (main): Use it.
* genrecog.c (validate_pattern): Likewise.
(match_pattern_1): Likewise. Remove c_test argument.
(match_pattern): Update accordingly and remove c_test argument.
(main): Update accordingly.
2015-08-05 Richard Sandiford <richard.sandiford@arm.com>
* gensupport.h (get_num_insn_codes): Declare. * gensupport.h (get_num_insn_codes): Declare.
* gensupport.c (get_num_insn_codes): New function. * gensupport.c (get_num_insn_codes): New function.
* genattrtab.c (optimize_attrs): Rename max_insn_code to * genattrtab.c (optimize_attrs): Rename max_insn_code to
......
...@@ -222,25 +222,17 @@ main (int argc, char **argv) ...@@ -222,25 +222,17 @@ main (int argc, char **argv)
while (read_md_rtx (&info)) while (read_md_rtx (&info))
{ {
rtx def = info.def; rtx def = info.def;
/* N.B. define_insn_and_split, define_cond_exec are handled add_c_test (get_c_test (def), -1);
entirely within read_md_rtx; we never see them. */
switch (GET_CODE (def)) switch (GET_CODE (def))
{ {
case DEFINE_INSN: case DEFINE_INSN:
case DEFINE_EXPAND: case DEFINE_EXPAND:
add_c_test (XSTR (def, 2), -1);
/* except.h needs to know whether there is an eh_return /* except.h needs to know whether there is an eh_return
pattern in the machine description. */ pattern in the machine description. */
if (!strcmp (XSTR (def, 0), "eh_return")) if (!strcmp (XSTR (def, 0), "eh_return"))
saw_eh_return = 1; saw_eh_return = 1;
break; break;
case DEFINE_SPLIT:
case DEFINE_PEEPHOLE:
case DEFINE_PEEPHOLE2:
add_c_test (XSTR (def, 1), -1);
break;
default: default:
break; break;
} }
......
...@@ -519,10 +519,7 @@ validate_pattern (rtx pattern, md_rtx_info *info, rtx set, int set_code) ...@@ -519,10 +519,7 @@ validate_pattern (rtx pattern, md_rtx_info *info, rtx set, int set_code)
const struct pred_data *pred; const struct pred_data *pred;
const char *c_test; const char *c_test;
if (GET_CODE (info->def) == DEFINE_INSN) c_test = get_c_test (info->def);
c_test = XSTR (info->def, 2);
else
c_test = XSTR (info->def, 1);
if (pred_name[0] != 0) if (pred_name[0] != 0)
{ {
...@@ -4080,13 +4077,13 @@ match_pattern_2 (state *s, md_rtx_info *info, position *pos, rtx pattern) ...@@ -4080,13 +4077,13 @@ match_pattern_2 (state *s, md_rtx_info *info, position *pos, rtx pattern)
(1) the rtx doesn't match anything already matched by S (1) the rtx doesn't match anything already matched by S
(2) the rtx matches TOP_PATTERN and (2) the rtx matches TOP_PATTERN and
(3) C_TEST is true. (3) the C test required by INFO->def is true
For peephole2, TOP_PATTERN is a SEQUENCE of the instruction patterns For peephole2, TOP_PATTERN is a SEQUENCE of the instruction patterns
to match, otherwise it is a single instruction pattern. */ to match, otherwise it is a single instruction pattern. */
static void static void
match_pattern_1 (state *s, md_rtx_info *info, rtx pattern, const char *c_test, match_pattern_1 (state *s, md_rtx_info *info, rtx pattern,
acceptance_type acceptance) acceptance_type acceptance)
{ {
if (acceptance.type == PEEPHOLE2) if (acceptance.type == PEEPHOLE2)
...@@ -4120,6 +4117,7 @@ match_pattern_1 (state *s, md_rtx_info *info, rtx pattern, const char *c_test, ...@@ -4120,6 +4117,7 @@ match_pattern_1 (state *s, md_rtx_info *info, rtx pattern, const char *c_test,
} }
/* Make sure that the C test is true. */ /* Make sure that the C test is true. */
const char *c_test = get_c_test (info->def);
if (maybe_eval_c_test (c_test) != 1) if (maybe_eval_c_test (c_test) != 1)
s = add_decision (s, rtx_test::c_test (c_test), true, false); s = add_decision (s, rtx_test::c_test (c_test), true, false);
...@@ -4132,7 +4130,7 @@ match_pattern_1 (state *s, md_rtx_info *info, rtx pattern, const char *c_test, ...@@ -4132,7 +4130,7 @@ match_pattern_1 (state *s, md_rtx_info *info, rtx pattern, const char *c_test,
backtracking. */ backtracking. */
static void static void
match_pattern (state *s, md_rtx_info *info, rtx pattern, const char *c_test, match_pattern (state *s, md_rtx_info *info, rtx pattern,
acceptance_type acceptance) acceptance_type acceptance)
{ {
if (merge_states_p) if (merge_states_p)
...@@ -4140,11 +4138,11 @@ match_pattern (state *s, md_rtx_info *info, rtx pattern, const char *c_test, ...@@ -4140,11 +4138,11 @@ match_pattern (state *s, md_rtx_info *info, rtx pattern, const char *c_test,
state root; state root;
/* Add the decisions to a fresh state and then merge the full tree /* Add the decisions to a fresh state and then merge the full tree
into the existing one. */ into the existing one. */
match_pattern_1 (&root, info, pattern, c_test, acceptance); match_pattern_1 (&root, info, pattern, acceptance);
merge_into_state (s, &root); merge_into_state (s, &root);
} }
else else
match_pattern_1 (s, info, pattern, c_test, acceptance); match_pattern_1 (s, info, pattern, acceptance);
} }
/* Begin the output file. */ /* Begin the output file. */
...@@ -5256,15 +5254,13 @@ main (int argc, char **argv) ...@@ -5256,15 +5254,13 @@ main (int argc, char **argv)
acceptance.u.full.u.num_clobbers = 0; acceptance.u.full.u.num_clobbers = 0;
pattern = add_implicit_parallel (XVEC (def, 1)); pattern = add_implicit_parallel (XVEC (def, 1));
validate_pattern (pattern, &info, NULL_RTX, 0); validate_pattern (pattern, &info, NULL_RTX, 0);
match_pattern (&insn_root, &info, pattern, match_pattern (&insn_root, &info, pattern, acceptance);
XSTR (def, 2), acceptance);
/* If the pattern is a PARALLEL with trailing CLOBBERs, /* If the pattern is a PARALLEL with trailing CLOBBERs,
allow recog_for_combine to match without the clobbers. */ allow recog_for_combine to match without the clobbers. */
if (GET_CODE (pattern) == PARALLEL if (GET_CODE (pattern) == PARALLEL
&& remove_clobbers (&acceptance, &pattern)) && remove_clobbers (&acceptance, &pattern))
match_pattern (&insn_root, &info, pattern, match_pattern (&insn_root, &info, pattern, acceptance);
XSTR (def, 2), acceptance);
break; break;
} }
...@@ -5272,8 +5268,7 @@ main (int argc, char **argv) ...@@ -5272,8 +5268,7 @@ main (int argc, char **argv)
acceptance.type = SPLIT; acceptance.type = SPLIT;
pattern = add_implicit_parallel (XVEC (def, 0)); pattern = add_implicit_parallel (XVEC (def, 0));
validate_pattern (pattern, &info, NULL_RTX, 0); validate_pattern (pattern, &info, NULL_RTX, 0);
match_pattern (&split_root, &info, pattern, match_pattern (&split_root, &info, pattern, acceptance);
XSTR (def, 1), acceptance);
/* Declare the gen_split routine that we'll call if the /* Declare the gen_split routine that we'll call if the
pattern matches. The definition comes from insn-emit.c. */ pattern matches. The definition comes from insn-emit.c. */
...@@ -5285,8 +5280,7 @@ main (int argc, char **argv) ...@@ -5285,8 +5280,7 @@ main (int argc, char **argv)
acceptance.type = PEEPHOLE2; acceptance.type = PEEPHOLE2;
pattern = get_peephole2_pattern (&info); pattern = get_peephole2_pattern (&info);
validate_pattern (pattern, &info, NULL_RTX, 0); validate_pattern (pattern, &info, NULL_RTX, 0);
match_pattern (&peephole2_root, &info, pattern, match_pattern (&peephole2_root, &info, pattern, acceptance);
XSTR (def, 1), acceptance);
/* Declare the gen_peephole2 routine that we'll call if the /* Declare the gen_peephole2 routine that we'll call if the
pattern matches. The definition comes from insn-emit.c. */ pattern matches. The definition comes from insn-emit.c. */
......
...@@ -2610,6 +2610,29 @@ get_num_insn_codes () ...@@ -2610,6 +2610,29 @@ get_num_insn_codes ()
return sequence_num; return sequence_num;
} }
/* Return the C test that says whether definition rtx DEF can be used,
or "" if it can be used unconditionally. */
const char *
get_c_test (rtx x)
{
switch (GET_CODE (x))
{
case DEFINE_INSN:
case DEFINE_EXPAND:
case DEFINE_SUBST:
return XSTR (x, 2);
case DEFINE_SPLIT:
case DEFINE_PEEPHOLE:
case DEFINE_PEEPHOLE2:
return XSTR (x, 1);
default:
return "";
}
}
/* Helper functions for insn elision. */ /* Helper functions for insn elision. */
/* Compute a hash function of a c_test structure, which is keyed /* Compute a hash function of a c_test structure, which is keyed
......
...@@ -50,6 +50,10 @@ extern unsigned int get_num_insn_codes (); ...@@ -50,6 +50,10 @@ extern unsigned int get_num_insn_codes ();
Must be set before calling init_md_reader. */ Must be set before calling init_md_reader. */
extern int insn_elision; extern int insn_elision;
/* Return the C test that says whether a definition rtx can be used,
or "" if it can be used unconditionally. */
extern const char *get_c_test (rtx);
/* If the C test passed as the argument can be evaluated at compile /* If the C test passed as the argument can be evaluated at compile
time, return its truth value; else return -1. The test must have time, return its truth value; else return -1. The test must have
appeared somewhere in the machine description when genconditions appeared somewhere in the machine description when genconditions
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment