}
+/* The current label failing the current matched pattern during
+ code generation. */
+static char *fail_label;
+
/* Code generation off the decision tree and the refered AST nodes. */
bool
"_r%d = maybe_push_res_to_seq (&tem_op, %s);\n", depth,
!force_leaf ? "lseq" : "NULL");
fprintf_indent (f, indent,
- "if (!_r%d) return false;\n",
- depth);
+ "if (!_r%d) goto %s;\n",
+ depth, fail_label);
if (*opr == CONVERT_EXPR)
{
indent -= 4;
if (opr->kind != id_base::CODE)
{
fprintf_indent (f, indent, " if (!_r%d)\n", depth);
- fprintf_indent (f, indent, " return NULL_TREE;\n");
+ fprintf_indent (f, indent, " goto %s;\n", fail_label);
fprintf_indent (f, indent, "}\n");
}
if (*opr == CONVERT_EXPR)
/* We need to be defensive against bogus prototypes allowing
calls with not enough arguments. */
fprintf_indent (f, indent,
- " if (gimple_call_num_args (_c%d) == %d)\n"
- " {\n", depth, e->ops.length ());
+ " if (gimple_call_num_args (_c%d) == %d)\n",
+ depth, e->ops.length ());
+ fprintf_indent (f, indent, " {\n");
fns[i]->gen (f, indent + 6, true, depth);
- fprintf_indent (f, indent,
- " }\n"
- " break;\n");
+ fprintf_indent (f, indent, " }\n");
+ fprintf_indent (f, indent, " break;\n");
}
fprintf_indent (f, indent, "default:;\n");
}
}
+ static unsigned fail_label_cnt;
+ char local_fail_label[256];
+ snprintf (local_fail_label, 256, "next_after_fail%u", ++fail_label_cnt);
+ fail_label = local_fail_label;
+
/* Analyze captures and perform early-outs on the incoming arguments
that cover cases we cannot handle. */
capture_info cinfo (s, result, gimple);
if (cinfo.force_no_side_effects & (1 << i))
{
fprintf_indent (f, indent,
- "if (TREE_SIDE_EFFECTS (_p%d)) return NULL_TREE;\n",
- i);
+ "if (TREE_SIDE_EFFECTS (_p%d)) goto %s;\n",
+ i, fail_label);
if (verbose >= 1)
warning_at (as_a <expr *> (s->match)->ops[i]->location,
"forcing toplevel operand to have no "
{
fprintf_indent (f, indent,
"if (TREE_SIDE_EFFECTS (captures[%d])) "
- "return NULL_TREE;\n", i);
+ "goto %s;\n", i, fail_label);
if (verbose >= 1)
warning_at (cinfo.info[i].c->location,
"forcing captured operand to have no "
}
if (s->kind == simplify::SIMPLIFY)
- fprintf_indent (f, indent, "if (__builtin_expect (!dbg_cnt (match), 0)) return %s;\n",
- gimple ? "false" : "NULL_TREE");
+ fprintf_indent (f, indent, "if (__builtin_expect (!dbg_cnt (match), 0)) goto %s;\n", fail_label);
fprintf_indent (f, indent, "if (__builtin_expect (dump_file && (dump_flags & TDF_FOLDING), 0)) "
"fprintf (dump_file, \"%s ",
true);
fprintf (f, ", __FILE__, __LINE__);\n");
+ fprintf_indent (f, indent, "{\n");
+ indent += 2;
if (!result)
{
/* If there is no result then this is a predicate implementation. */
> cinfo.info[i].match_use_count)
fprintf_indent (f, indent,
"if (! tree_invariant_p (captures[%d])) "
- "return NULL_TREE;\n", i);
+ "goto %s;\n", i, fail_label);
}
for (unsigned j = 0; j < e->ops.length (); ++j)
{
if (!is_a <operator_id *> (opr))
{
fprintf_indent (f, indent, "if (!_r)\n");
- fprintf_indent (f, indent, " return NULL_TREE;\n");
+ fprintf_indent (f, indent, " goto %s;\n", fail_label);
}
}
}
fprintf_indent (f, indent, "return _r;\n");
}
}
+ indent -= 2;
+ fprintf_indent (f, indent, "}\n");
+ fprintf (f, "%s:;\n", fail_label);
+ fail_label = NULL;
}
/* Generate code for the '(if ...)', '(with ..)' and actual transform