summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChristoph Mallon <christoph.mallon@gmx.de>2018-04-16 13:23:17 +0200
committerChristoph Mallon <christoph.mallon@gmx.de>2018-05-31 07:00:55 +0200
commit694810d15570df2be4f91af03c64cbe67d9f28f3 (patch)
tree86b9fdd57a131dffe6e4c5e3e4a0a0a8f4e02084
parent23500c5cb0ae01b23019231cc05265ea882f9195 (diff)
Factor out code to jump to a label.
-rw-r--r--src/firm/ast2firm.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/firm/ast2firm.c b/src/firm/ast2firm.c
index 591b6b8..cfb9439 100644
--- a/src/firm/ast2firm.c
+++ b/src/firm/ast2firm.c
@@ -4497,15 +4497,23 @@ static ir_node *case_label_to_firm(const case_label_statement_t *statement)
return statement_to_firm(statement->statement);
}
-static ir_node *label_to_firm(const label_statement_t *statement)
+static jump_target *jump_to_label(label_t *const label)
{
- label_t *const label = statement->label;
prepare_label_target(label);
- jump_to_target(&label->target);
+ jump_target *tgt = &label->target;
+ jump_to_target(tgt);
if (--label->n_users == 0) {
- enter_jump_target(&label->target);
- } else {
- enter_immature_jump_target(&label->target);
+ enter_jump_target(tgt);
+ tgt = NULL;
+ }
+ return tgt;
+}
+
+static ir_node *label_to_firm(const label_statement_t *statement)
+{
+ jump_target *const imm_target = jump_to_label(statement->label);
+ if (imm_target) {
+ enter_immature_jump_target(imm_target);
keep_loop();
}
@@ -4514,11 +4522,7 @@ static ir_node *label_to_firm(const label_statement_t *statement)
static ir_node *goto_statement_to_firm(goto_statement_t *const stmt)
{
- label_t *const label = stmt->label;
- prepare_label_target(label);
- jump_to_target(&label->target);
- if (--label->n_users == 0)
- enter_jump_target(&label->target);
+ jump_to_label(stmt->label);
set_unreachable_now();
return NULL;
}