Give reusable temps their own linked list.

The next field is used for linking all defs in a space. Oops.
This commit is contained in:
Bill Currie 2012-11-19 10:33:03 +09:00
parent 1af4d5eeed
commit 158e261a8f
2 changed files with 4 additions and 3 deletions

View file

@ -37,6 +37,7 @@
typedef struct def_s { typedef struct def_s {
struct def_s *next; ///< general purpose linking struct def_s *next; ///< general purpose linking
struct def_s *temp_next; ///< linked list of "free" temp defs
struct type_s *type; struct type_s *type;
const char *name; const char *name;
struct defspace_s *space; struct defspace_s *space;

View file

@ -163,8 +163,8 @@ temp_def (etype_t type, int size)
defspace_t *space = current_func->symtab->space; defspace_t *space = current_func->symtab->space;
if ((temp = current_func->temp_defs[size - 1])) { if ((temp = current_func->temp_defs[size - 1])) {
current_func->temp_defs[size - 1] = temp->next; current_func->temp_defs[size - 1] = temp->temp_next;
temp->next = 0; temp->temp_next = 0;
} else { } else {
ALLOC (16384, def_t, defs, temp); ALLOC (16384, def_t, defs, temp);
temp->offset = defspace_alloc_loc (space, size); temp->offset = defspace_alloc_loc (space, size);
@ -185,7 +185,7 @@ void
free_temp_def (def_t *temp) free_temp_def (def_t *temp)
{ {
int size = type_size (temp->type) - 1; int size = type_size (temp->type) - 1;
temp->next = current_func->temp_defs[size]; temp->temp_next = current_func->temp_defs[size];
current_func->temp_defs[size] = temp; current_func->temp_defs[size] = temp;
} }