From bd5a7904566a0d8bad2eeeb231eaca2e9e0f9775 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Fri, 16 Nov 2012 20:12:13 +0900 Subject: [PATCH] Support statement labels in dags. While the code is broken in places, switch.r generates code again. --- tools/qfcc/include/expr.h | 1 + tools/qfcc/source/dags.c | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/qfcc/include/expr.h b/tools/qfcc/include/expr.h index 805af9784..ff70d40f4 100644 --- a/tools/qfcc/include/expr.h +++ b/tools/qfcc/include/expr.h @@ -75,6 +75,7 @@ typedef struct ex_label_s { struct sblock_s *dest; ///< the location of this label if known const char *name; ///< the name of this label int used; ///< label is used as a target + struct daglabel_s *daglabel; } ex_label_t; typedef struct { diff --git a/tools/qfcc/source/dags.c b/tools/qfcc/source/dags.c index 6f99c0171..083be6385 100644 --- a/tools/qfcc/source/dags.c +++ b/tools/qfcc/source/dags.c @@ -71,6 +71,8 @@ flush_daglabels (void) op->o.tempop.daglabel = 0; else if (op->op_type == op_value || op->op_type == op_pointer) op->o.value->daglabel = 0; + else if (op->op_type == op_label) + op->o.label->daglabel = 0; else internal_error (0, "unexpected operand type"); } @@ -154,8 +156,14 @@ operand_label (operand_t *op) label = new_label (); label->op = op; val->daglabel = label; + } else if (op->op_type == op_label) { + if (op->o.label->daglabel) + return op->o.label->daglabel; + label = new_label (); + label->op = op; + op->o.label->daglabel = label; } else { - //internal_error (0, "unexpected operand type: %d", op->op_type); + internal_error (0, "unexpected operand type: %d", op->op_type); } return label; }