diff options
author | Ian Lance Taylor <iant@golang.org> | 2021-09-13 10:37:49 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2021-09-13 10:37:49 -0700 |
commit | e252b51ccde010cbd2a146485d8045103cd99533 (patch) | |
tree | e060f101cdc32bf5e520de8e5275db9d4236b74c /gcc/genmatch.c | |
parent | f10c7c4596dda99d2ee872c995ae4aeda65adbdf (diff) | |
parent | 104c05c5284b7822d770ee51a7d91946c7e56d50 (diff) | |
download | gcc-e252b51ccde010cbd2a146485d8045103cd99533.zip gcc-e252b51ccde010cbd2a146485d8045103cd99533.tar.gz gcc-e252b51ccde010cbd2a146485d8045103cd99533.tar.bz2 |
Merge from trunk revision 104c05c5284b7822d770ee51a7d91946c7e56d50.
Diffstat (limited to 'gcc/genmatch.c')
-rw-r--r-- | gcc/genmatch.c | 75 |
1 files changed, 37 insertions, 38 deletions
diff --git a/gcc/genmatch.c b/gcc/genmatch.c index 8311f5d..9524845 100644 --- a/gcc/genmatch.c +++ b/gcc/genmatch.c @@ -605,10 +605,10 @@ get_operator (const char *id, bool allow_null = false) for (unsigned int i = 0; id2[i]; ++i) id2[i] = TOUPPER (id2[i]); } - else if (all_upper && strncmp (id, "IFN_", 4) == 0) + else if (all_upper && startswith (id, "IFN_")) /* Try CFN_ instead of IFN_. */ id2 = ACONCAT (("CFN_", id + 4, NULL)); - else if (all_upper && strncmp (id, "BUILT_IN_", 9) == 0) + else if (all_upper && startswith (id, "BUILT_IN_")) /* Try prepending CFN_. */ id2 = ACONCAT (("CFN_", id, NULL)); else @@ -1210,7 +1210,7 @@ lower_opt (simplify *s, vec<simplify *>& simplifiers) } } -/* Lower the compare operand of COND_EXPRs and VEC_COND_EXPRs to a +/* Lower the compare operand of COND_EXPRs to a GENERIC and a GIMPLE variant. */ static vec<operand *> @@ -1257,8 +1257,7 @@ lower_cond (operand *o) /* If this is a COND with a captured expression or an expression with two operands then also match a GENERIC form on the compare. */ - if ((*e->operation == COND_EXPR - || *e->operation == VEC_COND_EXPR) + if (*e->operation == COND_EXPR && ((is_a <capture *> (e->ops[0]) && as_a <capture *> (e->ops[0])->what && is_a <expr *> (as_a <capture *> (e->ops[0])->what) @@ -1296,7 +1295,7 @@ lower_cond (operand *o) return ro; } -/* Lower the compare operand of COND_EXPRs and VEC_COND_EXPRs to a +/* Lower the compare operand of COND_EXPRs to a GENERIC and a GIMPLE variant. */ static void @@ -1307,6 +1306,7 @@ lower_cond (simplify *s, vec<simplify *>& simplifiers) { simplify *ns = new simplify (s->kind, s->id, matchers[i], s->result, s->for_vec, s->capture_ids); + ns->for_subst_vec.safe_splice (s->for_subst_vec); simplifiers.safe_push (ns); } } @@ -1544,24 +1544,27 @@ static void lower (vec<simplify *>& simplifiers, bool gimple) { auto_vec<simplify *> out_simplifiers; - for (unsigned i = 0; i < simplifiers.length (); ++i) - lower_opt (simplifiers[i], out_simplifiers); + for (auto s: simplifiers) + lower_opt (s, out_simplifiers); simplifiers.truncate (0); - for (unsigned i = 0; i < out_simplifiers.length (); ++i) - lower_commutative (out_simplifiers[i], simplifiers); + for (auto s: out_simplifiers) + lower_commutative (s, simplifiers); + /* Lower for needs to happen before lowering cond + to support (for cnd (cond vec_cond)). This is + safe as substitution delay does not happen for + cond or vec_cond. */ out_simplifiers.truncate (0); - if (gimple) - for (unsigned i = 0; i < simplifiers.length (); ++i) - lower_cond (simplifiers[i], out_simplifiers); - else - out_simplifiers.safe_splice (simplifiers); - + for (auto s: simplifiers) + lower_for (s, out_simplifiers); simplifiers.truncate (0); - for (unsigned i = 0; i < out_simplifiers.length (); ++i) - lower_for (out_simplifiers[i], simplifiers); + if (gimple) + for (auto s: out_simplifiers) + lower_cond (s, simplifiers); + else + simplifiers.safe_splice (out_simplifiers); } @@ -1629,8 +1632,9 @@ public: void gen_kids (FILE *, int, bool, int); void gen_kids_1 (FILE *, int, bool, int, - vec<dt_operand *>, vec<dt_operand *>, vec<dt_operand *>, - vec<dt_operand *>, vec<dt_operand *>, vec<dt_node *>); + const vec<dt_operand *> &, const vec<dt_operand *> &, + const vec<dt_operand *> &, const vec<dt_operand *> &, + const vec<dt_operand *> &, const vec<dt_node *> &); void analyze (sinfo_map_t &); }; @@ -2132,9 +2136,7 @@ capture_info::capture_info (simplify *s, operand *result, bool gimple_) (i != 0 && *e->operation == COND_EXPR) || *e->operation == TRUTH_ANDIF_EXPR || *e->operation == TRUTH_ORIF_EXPR, - i == 0 - && (*e->operation == COND_EXPR - || *e->operation == VEC_COND_EXPR)); + i == 0 && *e->operation == COND_EXPR); walk_result (s->result, false, result); } @@ -2197,8 +2199,7 @@ capture_info::walk_match (operand *o, unsigned toplevel_arg, || *e->operation == TRUTH_ORIF_EXPR) cond_p = true; if (i == 0 - && (*e->operation == COND_EXPR - || *e->operation == VEC_COND_EXPR)) + && *e->operation == COND_EXPR) expr_cond_p = true; walk_match (e->ops[i], toplevel_arg, cond_p, expr_cond_p); } @@ -2391,7 +2392,7 @@ get_operand_type (id_base *op, unsigned pos, else if (*op == COND_EXPR && pos == 0) return "boolean_type_node"; - else if (strncmp (op->id, "CFN_COND_", 9) == 0) + else if (startswith (op->id, "CFN_COND_")) { /* IFN_COND_* operands 1 and later by default have the same type as the result. The type of operand 0 needs to be specified @@ -2464,7 +2465,7 @@ expr::gen_transform (FILE *f, int indent, const char *dest, bool gimple, } else if (*opr == COND_EXPR || *opr == VEC_COND_EXPR - || strncmp (opr->id, "CFN_COND_", 9) == 0) + || startswith (opr->id, "CFN_COND_")) { /* Conditions are of the same type as their first alternative. */ snprintf (optype, sizeof (optype), "TREE_TYPE (_o%d[1])", depth); @@ -2494,8 +2495,7 @@ expr::gen_transform (FILE *f, int indent, const char *dest, bool gimple, i == 0 ? NULL : op0type); ops[i]->gen_transform (f, indent, dest1, gimple, depth + 1, optype1, cinfo, indexes, - (*opr == COND_EXPR - || *opr == VEC_COND_EXPR) && i == 0 ? 1 : 2); + *opr == COND_EXPR && i == 0 ? 1 : 2); } const char *opr_name; @@ -2984,12 +2984,12 @@ dt_node::gen_kids (FILE *f, int indent, bool gimple, int depth) void dt_node::gen_kids_1 (FILE *f, int indent, bool gimple, int depth, - vec<dt_operand *> gimple_exprs, - vec<dt_operand *> generic_exprs, - vec<dt_operand *> fns, - vec<dt_operand *> generic_fns, - vec<dt_operand *> preds, - vec<dt_node *> others) + const vec<dt_operand *> &gimple_exprs, + const vec<dt_operand *> &generic_exprs, + const vec<dt_operand *> &fns, + const vec<dt_operand *> &generic_fns, + const vec<dt_operand *> &preds, + const vec<dt_node *> &others) { char buf[128]; char *kid_opname = buf; @@ -3417,8 +3417,7 @@ dt_simplify::gen_1 (FILE *f, int indent, bool gimple, operand *result) into COND_EXPRs. */ int cond_handling = 0; if (!is_predicate) - cond_handling = ((*opr == COND_EXPR - || *opr == VEC_COND_EXPR) && j == 0) ? 1 : 2; + cond_handling = (*opr == COND_EXPR && j == 0) ? 1 : 2; e->ops[j]->gen_transform (f, indent, dest, true, 1, optype, &cinfo, indexes, cond_handling); } @@ -5033,7 +5032,7 @@ parser::parse_pattern () recursively. */ static void -walk_captures (operand *op, vec<vec<capture *> > cpts) +walk_captures (operand *op, vec<vec<capture *> > &cpts) { if (! op) return; |