From d9371722430206706cd8b8592b89064ceab91f43 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 3 Mar 2011 13:46:07 +0900 Subject: [PATCH] Create and use alias operands for alias expressions. This avoids the alias expression modifying the operand used in other expressions. --- tools/qfcc/include/statements.h | 2 ++ tools/qfcc/source/dot_flow.c | 2 ++ tools/qfcc/source/emit.c | 4 ++++ tools/qfcc/source/statements.c | 13 ++++++++----- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/tools/qfcc/include/statements.h b/tools/qfcc/include/statements.h index 3352462b7..d4b5da79a 100644 --- a/tools/qfcc/include/statements.h +++ b/tools/qfcc/include/statements.h @@ -37,6 +37,7 @@ typedef enum { op_label, op_temp, op_pointer, + op_alias, } op_type_e; typedef struct operand_s { @@ -49,6 +50,7 @@ typedef struct operand_s { struct ex_label_s *label; struct ex_pointer_s *pointer; struct def_s *def; + struct operand_s *alias; } o; } operand_t; diff --git a/tools/qfcc/source/dot_flow.c b/tools/qfcc/source/dot_flow.c index 1a0cf6c7c..89c33a2bc 100644 --- a/tools/qfcc/source/dot_flow.c +++ b/tools/qfcc/source/dot_flow.c @@ -146,6 +146,8 @@ get_operand (operand_t *op) return va ("(%s)[%d]", type ? pr_type_name[type->type] : "???", op->o.pointer->val); + case op_alias: + return get_operand (op->o.alias);//FIXME better output } return ("??"); } diff --git a/tools/qfcc/source/emit.c b/tools/qfcc/source/emit.c index bcd76b14a..630bb3cc9 100644 --- a/tools/qfcc/source/emit.c +++ b/tools/qfcc/source/emit.c @@ -125,6 +125,10 @@ get_operand_def (expr_t *expr, operand_t *op) def->offset_reloc = 1; } return def; + case op_alias: + def = alias_def (get_operand_def (expr, op->o.alias), + ev_types[op->type]); + return def; } return 0; } diff --git a/tools/qfcc/source/statements.c b/tools/qfcc/source/statements.c index a1760d2c4..ebb98aa61 100644 --- a/tools/qfcc/source/statements.c +++ b/tools/qfcc/source/statements.c @@ -115,6 +115,11 @@ print_operand (operand_t *op) break; case op_pointer: printf ("ptr %p", op->o.pointer); + break; + case op_alias: + printf ("alias %s ", pr_type_name[op->type]); + print_operand (op->o.alias); + break; } } @@ -554,11 +559,9 @@ expr_expr (sblock_t *sblock, expr_t *e, operand_t **op) static sblock_t * expr_alias (sblock_t *sblock, expr_t *e, operand_t **op) { - operand_t *src = 0; - - sblock = statement_subexpr (sblock, e->e.expr.e1, &src); - src->type = low_level_type (e->e.expr.type); - *op = src; + *op = new_operand (op_alias); + (*op)->type = low_level_type (e->e.expr.type); + sblock = statement_subexpr (sblock, e->e.expr.e1, &(*op)->o.alias); return sblock; }