mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-27 22:22:17 +00:00
don't set globaladdr directly, use a setter, the setter will update the member values used for vector access too
This commit is contained in:
parent
b5bee640d0
commit
9b2e26a189
1 changed files with 22 additions and 14 deletions
36
ir.c
36
ir.c
|
@ -519,6 +519,14 @@ bool ir_instr_op(ir_instr *self, int op, ir_value *v, bool writing)
|
||||||
*IR Value
|
*IR Value
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
void ir_value_code_setaddr(ir_value *self, int32_t gaddr)
|
||||||
|
{
|
||||||
|
self->code.globaladdr = gaddr;
|
||||||
|
if (self->members[0]) self->members[0]->code.globaladdr = gaddr;
|
||||||
|
if (self->members[1]) self->members[1]->code.globaladdr = gaddr;
|
||||||
|
if (self->members[2]) self->members[2]->code.globaladdr = gaddr;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t ir_value_code_addr(const ir_value *self)
|
int32_t ir_value_code_addr(const ir_value *self)
|
||||||
{
|
{
|
||||||
return self->code.globaladdr + self->code.addroffset;
|
return self->code.globaladdr + self->code.addroffset;
|
||||||
|
@ -2110,11 +2118,11 @@ static bool gen_global_field(ir_value *global)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* copy the field's value */
|
/* copy the field's value */
|
||||||
global->code.globaladdr = code_globals_add(code_globals_data[fld->code.globaladdr]);
|
ir_value_code_setaddr(global, code_globals_add(code_globals_data[fld->code.globaladdr]));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
global->code.globaladdr = code_globals_add(0);
|
ir_value_code_setaddr(global, code_globals_add(0));
|
||||||
}
|
}
|
||||||
if (global->code.globaladdr < 0)
|
if (global->code.globaladdr < 0)
|
||||||
return false;
|
return false;
|
||||||
|
@ -2147,11 +2155,11 @@ static bool gen_global_pointer(ir_value *global)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
global->code.globaladdr = code_globals_add(target->code.globaladdr);
|
ir_value_code_setaddr(global, code_globals_add(target->code.globaladdr));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
global->code.globaladdr = code_globals_add(0);
|
ir_value_code_setaddr(global, code_globals_add(0));
|
||||||
}
|
}
|
||||||
if (global->code.globaladdr < 0)
|
if (global->code.globaladdr < 0)
|
||||||
return false;
|
return false;
|
||||||
|
@ -2434,7 +2442,7 @@ static bool gen_global_function(ir_builder *ir, ir_value *global)
|
||||||
{
|
{
|
||||||
/* generate code.globaladdr for ssa values */
|
/* generate code.globaladdr for ssa values */
|
||||||
ir_value *v = irfun->values[i];
|
ir_value *v = irfun->values[i];
|
||||||
v->code.globaladdr = local_var_end + v->code.local;
|
ir_value_code_setaddr(v, local_var_end + v->code.local);
|
||||||
}
|
}
|
||||||
for (i = 0; i < irfun->locals_count; ++i) {
|
for (i = 0; i < irfun->locals_count; ++i) {
|
||||||
/* fill the locals with zeros */
|
/* fill the locals with zeros */
|
||||||
|
@ -2483,9 +2491,9 @@ static bool ir_builder_gen_global(ir_builder *self, ir_value *global)
|
||||||
|
|
||||||
if (global->isconst) {
|
if (global->isconst) {
|
||||||
iptr = (int32_t*)&global->constval.vfloat;
|
iptr = (int32_t*)&global->constval.vfloat;
|
||||||
global->code.globaladdr = code_globals_add(*iptr);
|
ir_value_code_setaddr(global, code_globals_add(*iptr));
|
||||||
} else
|
} else
|
||||||
global->code.globaladdr = code_globals_add(0);
|
ir_value_code_setaddr(global, code_globals_add(0));
|
||||||
|
|
||||||
return global->code.globaladdr >= 0;
|
return global->code.globaladdr >= 0;
|
||||||
}
|
}
|
||||||
|
@ -2494,9 +2502,9 @@ static bool ir_builder_gen_global(ir_builder *self, ir_value *global)
|
||||||
if (code_defs_add(def) < 0)
|
if (code_defs_add(def) < 0)
|
||||||
return false;
|
return false;
|
||||||
if (global->isconst)
|
if (global->isconst)
|
||||||
global->code.globaladdr = code_globals_add(code_cachedstring(global->constval.vstring));
|
ir_value_code_setaddr(global, code_globals_add(code_cachedstring(global->constval.vstring)));
|
||||||
else
|
else
|
||||||
global->code.globaladdr = code_globals_add(0);
|
ir_value_code_setaddr(global, code_globals_add(0));
|
||||||
return global->code.globaladdr >= 0;
|
return global->code.globaladdr >= 0;
|
||||||
}
|
}
|
||||||
case TYPE_VECTOR:
|
case TYPE_VECTOR:
|
||||||
|
@ -2507,7 +2515,7 @@ static bool ir_builder_gen_global(ir_builder *self, ir_value *global)
|
||||||
|
|
||||||
if (global->isconst) {
|
if (global->isconst) {
|
||||||
iptr = (int32_t*)&global->constval.vvec;
|
iptr = (int32_t*)&global->constval.vvec;
|
||||||
global->code.globaladdr = code_globals_add(iptr[0]);
|
ir_value_code_setaddr(global, code_globals_add(iptr[0]));
|
||||||
if (global->code.globaladdr < 0)
|
if (global->code.globaladdr < 0)
|
||||||
return false;
|
return false;
|
||||||
for (d = 1; d < type_sizeof[global->vtype]; ++d)
|
for (d = 1; d < type_sizeof[global->vtype]; ++d)
|
||||||
|
@ -2516,7 +2524,7 @@ static bool ir_builder_gen_global(ir_builder *self, ir_value *global)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
global->code.globaladdr = code_globals_add(0);
|
ir_value_code_setaddr(global, code_globals_add(0));
|
||||||
if (global->code.globaladdr < 0)
|
if (global->code.globaladdr < 0)
|
||||||
return false;
|
return false;
|
||||||
for (d = 1; d < type_sizeof[global->vtype]; ++d)
|
for (d = 1; d < type_sizeof[global->vtype]; ++d)
|
||||||
|
@ -2530,12 +2538,12 @@ static bool ir_builder_gen_global(ir_builder *self, ir_value *global)
|
||||||
case TYPE_FUNCTION:
|
case TYPE_FUNCTION:
|
||||||
if (code_defs_add(def) < 0)
|
if (code_defs_add(def) < 0)
|
||||||
return false;
|
return false;
|
||||||
global->code.globaladdr = code_globals_elements;
|
ir_value_code_setaddr(global, code_globals_elements);
|
||||||
code_globals_add(code_functions_elements);
|
code_globals_add(code_functions_elements);
|
||||||
return gen_global_function(self, global);
|
return gen_global_function(self, global);
|
||||||
case TYPE_VARIANT:
|
case TYPE_VARIANT:
|
||||||
/* assume biggest type */
|
/* assume biggest type */
|
||||||
global->code.globaladdr = code_globals_add(0);
|
ir_value_code_setaddr(global, code_globals_add(0));
|
||||||
for (i = 1; i < type_sizeof[TYPE_VARIANT]; ++i)
|
for (i = 1; i < type_sizeof[TYPE_VARIANT]; ++i)
|
||||||
code_globals_add(0);
|
code_globals_add(0);
|
||||||
return true;
|
return true;
|
||||||
|
@ -2573,7 +2581,7 @@ static bool ir_builder_gen_field(ir_builder *self, ir_value *field)
|
||||||
if (!code_globals_add(code_alloc_field(type_sizeof[field->fieldtype])))
|
if (!code_globals_add(code_alloc_field(type_sizeof[field->fieldtype])))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
field->code.globaladdr = code_globals_add(fld.offset);
|
ir_value_code_setaddr(field, code_globals_add(fld.offset));
|
||||||
return field->code.globaladdr >= 0;
|
return field->code.globaladdr >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue