Create and use alias operands for alias expressions.

This avoids the alias expression modifying the operand used in other
expressions.
This commit is contained in:
Bill Currie 2011-03-03 13:46:07 +09:00
parent 022fde666f
commit d937172243
4 changed files with 16 additions and 5 deletions

View file

@ -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;

View file

@ -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 ("??");
}

View file

@ -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;
}

View file

@ -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;
}