From d1427a17a7d98f096ee0b199ef8caf993c8f2e0e Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Wed, 5 Aug 2015 15:46:02 +0000 Subject: [PATCH] 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 --- gcc/ChangeLog | 10 ++++++++++ gcc/genconditions.c | 10 +--------- gcc/genrecog.c | 28 +++++++++++----------------- gcc/gensupport.c | 23 +++++++++++++++++++++++ gcc/gensupport.h | 4 ++++ 5 files changed, 49 insertions(+), 26 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ac7b170932f..75ed73bd7e9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2015-08-05 Richard Sandiford + + * 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 * gensupport.h (get_num_insn_codes): Declare. diff --git a/gcc/genconditions.c b/gcc/genconditions.c index 23109eeb595..001e58eff8a 100644 --- a/gcc/genconditions.c +++ b/gcc/genconditions.c @@ -222,25 +222,17 @@ main (int argc, char **argv) while (read_md_rtx (&info)) { rtx def = info.def; - /* N.B. define_insn_and_split, define_cond_exec are handled - entirely within read_md_rtx; we never see them. */ + add_c_test (get_c_test (def), -1); switch (GET_CODE (def)) { case DEFINE_INSN: case DEFINE_EXPAND: - add_c_test (XSTR (def, 2), -1); /* except.h needs to know whether there is an eh_return pattern in the machine description. */ if (!strcmp (XSTR (def, 0), "eh_return")) saw_eh_return = 1; break; - case DEFINE_SPLIT: - case DEFINE_PEEPHOLE: - case DEFINE_PEEPHOLE2: - add_c_test (XSTR (def, 1), -1); - break; - default: break; } diff --git a/gcc/genrecog.c b/gcc/genrecog.c index 4275bd2e641..599121fb693 100644 --- a/gcc/genrecog.c +++ b/gcc/genrecog.c @@ -519,10 +519,7 @@ validate_pattern (rtx pattern, md_rtx_info *info, rtx set, int set_code) const struct pred_data *pred; const char *c_test; - if (GET_CODE (info->def) == DEFINE_INSN) - c_test = XSTR (info->def, 2); - else - c_test = XSTR (info->def, 1); + c_test = get_c_test (info->def); if (pred_name[0] != 0) { @@ -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 (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 to match, otherwise it is a single instruction pattern. */ 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) { if (acceptance.type == PEEPHOLE2) @@ -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. */ + const char *c_test = get_c_test (info->def); if (maybe_eval_c_test (c_test) != 1) 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, backtracking. */ 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) { if (merge_states_p) @@ -4140,11 +4138,11 @@ match_pattern (state *s, md_rtx_info *info, rtx pattern, const char *c_test, state root; /* Add the decisions to a fresh state and then merge the full tree 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); } else - match_pattern_1 (s, info, pattern, c_test, acceptance); + match_pattern_1 (s, info, pattern, acceptance); } /* Begin the output file. */ @@ -5256,15 +5254,13 @@ main (int argc, char **argv) acceptance.u.full.u.num_clobbers = 0; pattern = add_implicit_parallel (XVEC (def, 1)); validate_pattern (pattern, &info, NULL_RTX, 0); - match_pattern (&insn_root, &info, pattern, - XSTR (def, 2), acceptance); + match_pattern (&insn_root, &info, pattern, acceptance); /* If the pattern is a PARALLEL with trailing CLOBBERs, allow recog_for_combine to match without the clobbers. */ if (GET_CODE (pattern) == PARALLEL && remove_clobbers (&acceptance, &pattern)) - match_pattern (&insn_root, &info, pattern, - XSTR (def, 2), acceptance); + match_pattern (&insn_root, &info, pattern, acceptance); break; } @@ -5272,8 +5268,7 @@ main (int argc, char **argv) acceptance.type = SPLIT; pattern = add_implicit_parallel (XVEC (def, 0)); validate_pattern (pattern, &info, NULL_RTX, 0); - match_pattern (&split_root, &info, pattern, - XSTR (def, 1), acceptance); + match_pattern (&split_root, &info, pattern, acceptance); /* Declare the gen_split routine that we'll call if the pattern matches. The definition comes from insn-emit.c. */ @@ -5285,8 +5280,7 @@ main (int argc, char **argv) acceptance.type = PEEPHOLE2; pattern = get_peephole2_pattern (&info); validate_pattern (pattern, &info, NULL_RTX, 0); - match_pattern (&peephole2_root, &info, pattern, - XSTR (def, 1), acceptance); + match_pattern (&peephole2_root, &info, pattern, acceptance); /* Declare the gen_peephole2 routine that we'll call if the pattern matches. The definition comes from insn-emit.c. */ diff --git a/gcc/gensupport.c b/gcc/gensupport.c index 714af03dc56..687005808a7 100644 --- a/gcc/gensupport.c +++ b/gcc/gensupport.c @@ -2610,6 +2610,29 @@ get_num_insn_codes () 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. */ /* Compute a hash function of a c_test structure, which is keyed diff --git a/gcc/gensupport.h b/gcc/gensupport.h index c37ec367c53..a15c36a1016 100644 --- a/gcc/gensupport.h +++ b/gcc/gensupport.h @@ -50,6 +50,10 @@ extern unsigned int get_num_insn_codes (); Must be set before calling init_md_reader. */ 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 time, return its truth value; else return -1. The test must have appeared somewhere in the machine description when genconditions -- 2.30.2