ir_block_create_storep for storing through pointers, the IR does not implicitly create conversions for now when using pointers, but it could

This commit is contained in:
Wolfgang Bumiller 2012-05-01 11:58:52 +02:00
parent 95152c1f5c
commit 340daeabc4
2 changed files with 51 additions and 0 deletions

50
ir.c
View file

@ -623,6 +623,56 @@ bool ir_block_create_store(ir_block *self, ir_value *target, ir_value *what)
op = INSTR_STORE_ENT;
#endif
break;
default:
/* Unknown type */
return false;
}
return ir_block_create_store_op(self, op, target, what);
}
bool ir_block_create_storep(ir_block *self, ir_value *target, ir_value *what)
{
int op = 0;
int vtype;
if (target->vtype == TYPE_VARIANT)
vtype = what->vtype;
else
vtype = target->vtype;
if (vtype != what->vtype)
{
/* Cannot implicitly convert when storing through a pointer */
return false;
}
switch (vtype) {
case TYPE_FLOAT:
op = INSTR_STOREP_F;
break;
case TYPE_VECTOR:
op = INSTR_STOREP_V;
break;
case TYPE_ENTITY:
op = INSTR_STOREP_ENT;
break;
case TYPE_STRING:
op = INSTR_STOREP_S;
break;
#if 0
case TYPE_INTEGER:
op = INSTR_STOREP_I;
break;
#endif
case TYPE_POINTER:
#if 0
op = INSTR_STOREP_I;
#else
op = INSTR_STOREP_ENT;
#endif
break;
default:
/* Unknown type */
return false;
}
return ir_block_create_store_op(self, op, target, what);
}

1
ir.h
View file

@ -150,6 +150,7 @@ ir_value* ir_block_create_binop(ir_block*, const char *label, int op,
ir_value *left, ir_value *right);
bool GMQCC_WARN ir_block_create_store_op(ir_block*, int op, ir_value *target, ir_value *what);
bool GMQCC_WARN ir_block_create_store(ir_block*, ir_value *target, ir_value *what);
bool GMQCC_WARN ir_block_create_storep(ir_block*, ir_value *target, ir_value *what);
ir_value* ir_block_create_add(ir_block*, const char *label, ir_value *l, ir_value *r);
ir_value* ir_block_create_sub(ir_block*, const char *label, ir_value *l, ir_value *r);