[qfcc] Point pointer tempop to the operand

It turns out I need the operand itself, not just the tempop.
This commit is contained in:
Bill Currie 2020-03-17 15:28:15 +09:00
parent 0de011d0bf
commit 6ec92fb83b
5 changed files with 14 additions and 12 deletions

View file

@ -127,7 +127,7 @@ typedef struct ex_pointer_s {
int val; int val;
struct type_s *type; struct type_s *type;
struct def_s *def; struct def_s *def;
struct tempop_s *tempop; struct operand_s *tempop;
} ex_pointer_t; } ex_pointer_t;
typedef struct ex_func_s { typedef struct ex_func_s {

View file

@ -51,7 +51,7 @@ struct ex_value_s *new_field_val (int field_val, struct type_s *type,
struct ex_value_s *new_func_val (int func_val, struct type_s *type); struct ex_value_s *new_func_val (int func_val, struct type_s *type);
struct ex_value_s *new_pointer_val (int val, struct type_s *type, struct ex_value_s *new_pointer_val (int val, struct type_s *type,
struct def_s *def, struct def_s *def,
struct tempop_s *tempop); struct operand_s *tempop);
struct ex_value_s *new_quaternion_val (const float *quaternion_val); struct ex_value_s *new_quaternion_val (const float *quaternion_val);
struct ex_value_s *new_integer_val (int integer_val); struct ex_value_s *new_integer_val (int integer_val);
struct ex_value_s *new_uinteger_val (int uinteger_val); struct ex_value_s *new_uinteger_val (int uinteger_val);

View file

@ -63,8 +63,9 @@ static def_t zero_def;
static def_t *get_operand_def (expr_t *expr, operand_t *op); static def_t *get_operand_def (expr_t *expr, operand_t *op);
static def_t * static def_t *
get_tempop_def (expr_t *expr, tempop_t *tempop, type_t *type) get_tempop_def (expr_t *expr, operand_t *tmpop, type_t *type)
{ {
tempop_t *tempop = &tmpop->o.tempop;
if (tempop->def) { if (tempop->def) {
return tempop->def; return tempop->def;
} }
@ -115,7 +116,7 @@ get_operand_def (expr_t *expr, operand_t *op)
zero_def.type = &type_short; zero_def.type = &type_short;
return &zero_def; //FIXME return &zero_def; //FIXME
case op_temp: case op_temp:
return get_tempop_def (expr, &op->o.tempop, op->type); return get_tempop_def (expr, op, op->type);
case op_alias: case op_alias:
return get_operand_def (expr, op->o.alias); return get_operand_def (expr, op->o.alias);
case op_nil: case op_nil:

View file

@ -78,18 +78,19 @@ optype_str (op_type_e type)
} }
static const char * static const char *
tempop_string (tempop_t *tempop) tempop_string (operand_t *tmpop)
{ {
tempop_t *tempop = &tmpop->o.tempop;
if (tempop->alias) { if (tempop->alias) {
return va ("<tmp %s %p:%d:%p:%d:%d>", return va ("<tmp %s %p:%d:%p:%d:%d>",
pr_type_name[tempop->type->type], pr_type_name[tempop->type->type],
tempop, tempop->users, tmpop, tempop->users,
&tempop->alias->o.tempop, tempop->alias,
tempop->offset, tempop->offset,
tempop->alias->o.tempop.users); tempop->alias->o.tempop.users);
} }
return va ("<tmp %s %p:%d>", pr_type_name[tempop->type->type], return va ("<tmp %s %p:%d>", pr_type_name[tempop->type->type],
&tempop, tempop->users); tmpop, tempop->users);
} }
const char * const char *
@ -126,7 +127,7 @@ operand_string (operand_t *op)
op->o.value->v.pointer.def->name, op->o.value->v.pointer.def->name,
op->o.value->v.pointer.val); op->o.value->v.pointer.val);
} else if(op->o.value->v.pointer.tempop) { } else if(op->o.value->v.pointer.tempop) {
tempop_t *tempop = op->o.value->v.pointer.tempop; operand_t *tempop = op->o.value->v.pointer.tempop;
return va ("ptr %s+%d", tempop_string (tempop), return va ("ptr %s+%d", tempop_string (tempop),
op->o.value->v.pointer.val); op->o.value->v.pointer.val);
} else { } else {
@ -155,7 +156,7 @@ operand_string (operand_t *op)
case op_label: case op_label:
return op->o.label->name; return op->o.label->name;
case op_temp: case op_temp:
return tempop_string (&op->o.tempop); return tempop_string (op);
case op_alias: case op_alias:
{ {
const char *alias = operand_string (op->o.alias); const char *alias = operand_string (op->o.alias);
@ -703,7 +704,7 @@ operand_address (operand_t *reference, expr_t *e)
reference = reference->o.tempop.alias; reference = reference->o.tempop.alias;
} }
return value_operand (new_pointer_val (offset, type, 0, return value_operand (new_pointer_val (offset, type, 0,
&reference->o.tempop), e); reference), e);
case op_alias: case op_alias:
//op_alias comes only from alias_operand and that is called //op_alias comes only from alias_operand and that is called
// by dags, so not expected // by dags, so not expected

View file

@ -198,7 +198,7 @@ new_func_val (int func_val, type_t *type)
ex_value_t * ex_value_t *
new_pointer_val (int pointer_val, type_t *type, def_t *def, new_pointer_val (int pointer_val, type_t *type, def_t *def,
struct tempop_s *tempop) struct operand_s *tempop)
{ {
ex_value_t val; ex_value_t val;
if (!type) { if (!type) {