Commit 1651ab85 by Alexandre Oliva Committed by Alexandre Oliva

genrecog.c (write_switch): Return the first condition that needs a label.

* genrecog.c (write_switch): Return the first condition that needs a
label.

From-SVN: r36903
parent a9117427
2000-10-17 Alexandre Oliva <aoliva@redhat.com>
* genrecog.c (write_switch): Return the first condition that needs a
label.
2000-10-17 Bernd Schmidt <bernds@redhat.co.uk> 2000-10-17 Bernd Schmidt <bernds@redhat.co.uk>
* c-tree.h (warn_sequence_point): Move declaration to... * c-tree.h (warn_sequence_point): Move declaration to...
......
...@@ -1650,6 +1650,7 @@ write_switch (start, depth) ...@@ -1650,6 +1650,7 @@ write_switch (start, depth)
{ {
struct decision *p = start; struct decision *p = start;
enum decision_type type = p->tests->type; enum decision_type type = p->tests->type;
struct decision *needs_label = NULL;
/* If we have two or more nodes in sequence that test the same one /* If we have two or more nodes in sequence that test the same one
thing, we may be able to use a switch statement. */ thing, we may be able to use a switch statement. */
...@@ -1674,6 +1675,9 @@ write_switch (start, depth) ...@@ -1674,6 +1675,9 @@ write_switch (start, depth)
code = p->tests->u.code; code = p->tests->u.code;
do do
{ {
if (p != start && p->need_label && needs_label == NULL)
needs_label = p;
printf (" case "); printf (" case ");
print_code (code); print_code (code);
printf (":\n goto L%d;\n", p->success.first->number); printf (":\n goto L%d;\n", p->success.first->number);
...@@ -1697,7 +1701,10 @@ write_switch (start, depth) ...@@ -1697,7 +1701,10 @@ write_switch (start, depth)
we don't actually write the test here, as it gets kinda messy. we don't actually write the test here, as it gets kinda messy.
It is trivial to leave this to later by telling our caller that It is trivial to leave this to later by telling our caller that
we only processed the CODE tests. */ we only processed the CODE tests. */
ret = p; if (needs_label != NULL)
ret = needs_label;
else
ret = p;
while (p && p->tests->type == DT_pred while (p && p->tests->type == DT_pred
&& p->tests->u.pred.index >= 0) && p->tests->u.pred.index >= 0)
...@@ -1774,6 +1781,9 @@ write_switch (start, depth) ...@@ -1774,6 +1781,9 @@ write_switch (start, depth)
do do
{ {
if (p != start && p->need_label && needs_label == NULL)
needs_label = p;
printf (" case "); printf (" case ");
switch (type) switch (type)
{ {
...@@ -1800,7 +1810,7 @@ write_switch (start, depth) ...@@ -1800,7 +1810,7 @@ write_switch (start, depth)
printf (" default:\n break;\n }\n"); printf (" default:\n break;\n }\n");
return p; return needs_label != NULL ? needs_label : p;
} }
else else
{ {
......
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