Use value for pointer operands.

This allows daglabels on pointer operands without a redundant daglabel
pointer.
This commit is contained in:
Bill Currie 2012-07-19 10:51:44 +09:00
parent 0c58cd9067
commit a22260030a
4 changed files with 13 additions and 14 deletions

View file

@ -55,7 +55,6 @@ typedef struct operand_s {
struct symbol_s *symbol; struct symbol_s *symbol;
struct ex_value_s *value; struct ex_value_s *value;
struct ex_label_s *label; struct ex_label_s *label;
struct ex_pointer_s *pointer;
tempop_t tempop; tempop_t tempop;
struct operand_s *alias; struct operand_s *alias;
} o; } o;

View file

@ -109,16 +109,13 @@ operand_label (operand_t *op)
label = new_label (); label = new_label ();
label->op = op; label->op = op;
sym->daglabel = label; sym->daglabel = label;
} else if (o->op_type == op_value) { } else if (o->op_type == op_value || o->op_type == op_pointer) {
val = o->o.value; val = o->o.value;
if (val->daglabel) if (val->daglabel)
return val->daglabel; return val->daglabel;
label = new_label (); label = new_label ();
label->op = op; label->op = op;
val->daglabel = label; val->daglabel = label;
} else if (o->op_type == op_pointer) {
label = new_label ();
label->op = op;
} else { } else {
internal_error (0, "unexpected operand type: %d", o->op_type); internal_error (0, "unexpected operand type: %d", o->op_type);
} }

View file

@ -111,10 +111,10 @@ get_operand_def (expr_t *expr, operand_t *op)
op->o.tempop.def = temp_def (op->type, op->size); op->o.tempop.def = temp_def (op->type, op->size);
return op->o.tempop.def; return op->o.tempop.def;
case op_pointer: case op_pointer:
def = op->o.pointer->def; def = op->o.value->v.pointer.def;
if (op->o.pointer->val || op->type != def->type->type) { if (op->o.value->v.pointer.val || op->type != def->type->type) {
def = alias_def (def, ev_types[op->type]); def = alias_def (def, ev_types[op->type]);
def->offset = op->o.pointer->val; def->offset = op->o.value->v.pointer.val;
def->offset_reloc = 1; def->offset_reloc = 1;
} }
return def; return def;

View file

@ -109,15 +109,16 @@ operand_string (operand_t *op)
case op_temp: case op_temp:
return va ("tmp %p", op); return va ("tmp %p", op);
case op_pointer: case op_pointer:
type = op->o.pointer->type; type = op->o.value->v.pointer.type;
if (op->o.pointer->def) if (op->o.value->v.pointer.def)
return va ("(%s)[%d]<%s>", return va ("(%s)[%d]<%s>",
type ? pr_type_name[type->type] : "???", type ? pr_type_name[type->type] : "???",
op->o.pointer->val, op->o.pointer->def->name); op->o.value->v.pointer.val,
op->o.value->v.pointer.def->name);
else else
return va ("(%s)[%d]", return va ("(%s)[%d]",
type ? pr_type_name[type->type] : "???", type ? pr_type_name[type->type] : "???",
op->o.pointer->val); op->o.value->v.pointer.val);
case op_alias: case op_alias:
return operand_string (op->o.alias);//FIXME better output return operand_string (op->o.alias);//FIXME better output
} }
@ -184,7 +185,9 @@ print_operand (operand_t *op)
printf ("tmp (%s) %p", pr_type_name[op->type], op); printf ("tmp (%s) %p", pr_type_name[op->type], op);
break; break;
case op_pointer: case op_pointer:
printf ("ptr %p", op->o.pointer); printf ("ptr (%s)[%d]",
pr_type_name[op->o.value->v.pointer.type->type],
op->o.value->v.pointer.val);
break; break;
case op_alias: case op_alias:
printf ("alias %s ", pr_type_name[op->type]); printf ("alias %s ", pr_type_name[op->type]);
@ -662,7 +665,7 @@ expr_deref (sblock_t *sblock, expr_t *deref, operand_t **op)
} else if (e->type == ex_value && e->e.value->type == ev_pointer) { } else if (e->type == ex_value && e->e.value->type == ev_pointer) {
*op = new_operand (op_pointer); *op = new_operand (op_pointer);
(*op)->type = low_level_type (e->e.value->v.pointer.type); (*op)->type = low_level_type (e->e.value->v.pointer.type);
(*op)->o.pointer = &e->e.value->v.pointer; (*op)->o.value = e->e.value;
} else { } else {
statement_t *s; statement_t *s;
operand_t *ptr = 0; operand_t *ptr = 0;