Generate _x,_y,_z defs/fields

This commit is contained in:
Wolfgang (Blub) Bumiller 2012-12-18 12:41:38 +01:00
parent 2a94fe9731
commit 116d744823

60
ir.c
View file

@ -3147,6 +3147,58 @@ static bool gen_global_function_code(ir_builder *ir, ir_value *global)
return true; return true;
} }
static void gen_vector_defs(prog_section_def def, const char *name)
{
char *component;
size_t len, i;
if (!name)
return;
len = strlen(name);
component = (char*)mem_a(len+3);
memcpy(component, name, len);
len += 2;
component[len-0] = 0;
component[len-2] = '_';
component[len-1] = 'x';
for (i = 0; i < 3; ++i) {
def.name = code_genstring(component);
vec_push(code_defs, def);
def.offset++;
component[len-1]++;
}
}
static void gen_vector_fields(prog_section_field fld, const char *name)
{
char *component;
size_t len, i;
if (!name)
return;
len = strlen(name);
component = (char*)mem_a(len+3);
memcpy(component, name, len);
len += 2;
component[len-0] = 0;
component[len-2] = '_';
component[len-1] = 'x';
for (i = 0; i < 3; ++i) {
fld.name = code_genstring(component);
vec_push(code_fields, fld);
fld.offset++;
component[len-1]++;
}
}
static bool ir_builder_gen_global(ir_builder *self, ir_value *global, bool islocal) static bool ir_builder_gen_global(ir_builder *self, ir_value *global, bool islocal)
{ {
size_t i; size_t i;
@ -3198,6 +3250,7 @@ static bool ir_builder_gen_global(ir_builder *self, ir_value *global, bool isloc
return gen_global_pointer(global); return gen_global_pointer(global);
case TYPE_FIELD: case TYPE_FIELD:
vec_push(code_defs, def); vec_push(code_defs, def);
gen_vector_defs(def, global->name);
return gen_global_field(global); return gen_global_field(global);
case TYPE_ENTITY: case TYPE_ENTITY:
/* fall through */ /* fall through */
@ -3253,6 +3306,8 @@ static bool ir_builder_gen_global(ir_builder *self, ir_value *global, bool isloc
def.type |= DEF_SAVEGLOBAL; def.type |= DEF_SAVEGLOBAL;
vec_push(code_defs, def); vec_push(code_defs, def);
def.type &= ~DEF_SAVEGLOBAL;
gen_vector_defs(def, global->name);
return global->code.globaladdr >= 0; return global->code.globaladdr >= 0;
} }
case TYPE_FUNCTION: case TYPE_FUNCTION:
@ -3352,6 +3407,11 @@ static bool ir_builder_gen_field(ir_builder *self, ir_value *field)
vec_push(code_globals, fld.offset+2); vec_push(code_globals, fld.offset+2);
} }
if (field->fieldtype == TYPE_VECTOR) {
gen_vector_defs(def, field->name);
gen_vector_fields(fld, field->name);
}
return field->code.globaladdr >= 0; return field->code.globaladdr >= 0;
} }