From 179c1f7058b29263430f7e5c348b5bbccba2ba10 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Fri, 11 Feb 2011 15:02:51 +0900 Subject: [PATCH] Support move statements (structure copy). --- tools/qfcc/source/statements.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tools/qfcc/source/statements.c b/tools/qfcc/source/statements.c index 420405cf8..2fac851a8 100644 --- a/tools/qfcc/source/statements.c +++ b/tools/qfcc/source/statements.c @@ -325,6 +325,34 @@ expr_assign (sblock_t *sblock, expr_t *e, operand_t **op) return sblock; } +static sblock_t * +expr_move (sblock_t *sblock, expr_t *e, operand_t **op) +{ + statement_t *s; + type_t *type = e->e.expr.type; + expr_t *dst_expr = e->e.expr.e1; + expr_t *src_expr = e->e.expr.e2; + expr_t *size_expr; + operand_t *dst = 0; + operand_t *src = 0; + operand_t *size = 0; + + if (!op) + op = &dst; + size_expr = new_short_expr (type_size (type)); + sblock = statement_subexpr (sblock, dst_expr, op); + dst = *op; + sblock = statement_subexpr (sblock, src_expr, &src); + sblock = statement_subexpr (sblock, size_expr, &size); + s = new_statement ("", e); + s->opa = src; + s->opb = size; + s->opc = dst; + sblock_add_statement (sblock, s); + + return sblock; +} + static sblock_t * vector_call (sblock_t *sblock, expr_t *earg, expr_t *param, int ind, operand_t **op) @@ -476,6 +504,9 @@ expr_expr (sblock_t *sblock, expr_t *e, operand_t **op) case PAS: sblock = expr_assign (sblock, e, op); break; + case 'M': + sblock = expr_move (sblock, e, op); + break; default: opcode = convert_op (e->e.expr.op); if (!opcode) @@ -777,6 +808,9 @@ statement_expr (sblock_t *sblock, expr_t *e) case PAS: sblock = expr_assign (sblock, e, 0); break; + case 'M': + sblock = expr_move (sblock, e, 0); + break; default: if (e->e.expr.op < 256) debug (e, "e %c", e->e.expr.op);