Skip to content

Commit

Permalink
Allow getting a new version of an in-use temp
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Aug 10, 2018
1 parent b9ffe79 commit a7a2ca6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/spesh/graph.h
Expand Up @@ -118,6 +118,9 @@ struct MVMSpeshTemporary {
MVMuint16 orig;
MVMuint16 i;

/* The SSA index currently loaned out. */
MVMuint16 used_i;

/* What kind of register is it? */
MVMuint16 kind;

Expand Down
5 changes: 3 additions & 2 deletions src/spesh/manipulate.c
Expand Up @@ -281,7 +281,7 @@ MVMSpeshOperand MVM_spesh_manipulate_get_temp_reg(MVMThreadContext *tc, MVMSpesh

/* Produce and return result. */
result.reg.orig = orig;
result.reg.i = g->temps[i].i;
result.reg.i = g->temps[i].used_i = g->temps[i].i;
return result;
}
}
Expand All @@ -299,6 +299,7 @@ MVMSpeshOperand MVM_spesh_manipulate_get_temp_reg(MVMThreadContext *tc, MVMSpesh
/* Allocate temporary and set up result. */
g->temps[g->num_temps].orig = result.reg.orig = g->num_locals;
g->temps[g->num_temps].i = result.reg.i = 0;
g->temps[g->num_temps].used_i = 0;
g->temps[g->num_temps].kind = kind;
g->temps[g->num_temps].in_use = 1;
g->num_temps++;
Expand Down Expand Up @@ -332,7 +333,7 @@ MVMSpeshOperand MVM_spesh_manipulate_get_temp_reg(MVMThreadContext *tc, MVMSpesh
void MVM_spesh_manipulate_release_temp_reg(MVMThreadContext *tc, MVMSpeshGraph *g, MVMSpeshOperand temp) {
MVMuint16 i;
for (i = 0; i < g->num_temps; i++) {
if (g->temps[i].orig == temp.reg.orig && g->temps[i].i == temp.reg.i) {
if (g->temps[i].orig == temp.reg.orig && g->temps[i].used_i == temp.reg.i) {
if (g->temps[i].in_use)
g->temps[i].in_use = 0;
else
Expand Down

0 comments on commit a7a2ca6

Please sign in to comment.