Skip to content

Commit

Permalink
More work on IR.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.parrot.org/parrot/trunk@1596 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information
Melvin Smith committed Jun 4, 2002
1 parent 0a5b31d commit 7419273
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions imcc/imc.c
Expand Up @@ -57,6 +57,7 @@ SymReg * mk_const(const char * name, char t) {
r->reg = str_dup(name);
r->first = -1;
r->color = -1;
r->set = t;
r->type = VTCONST;
if(name[0])
store_symreg(r);
Expand Down Expand Up @@ -248,6 +249,9 @@ void compute_du_chain(SymReg * r) {
fprintf(stderr, "Internal error: symreg %s not referenced\n", r->name);
abort();
}
/* Symbol was never used in a statement, ignore for register allocation */
if(r->first < 0) return;

r->last = r->first;
i = r->first;
for(ins = instructions[i++]; ins; ins = instructions[i++]) {
Expand All @@ -271,6 +275,9 @@ int interferes(SymReg * r0, SymReg * r1) {
if(r0->first > r1->last) return 0;
else if(r0->last < r1->first) return 0;

/* If symbol was never used in a statment, it can't interfere */
if(r0->first < 0 || r1->first < 0) return 0;

return 1;
}

Expand Down
7 changes: 7 additions & 0 deletions languages/imcc/imc.c
Expand Up @@ -57,6 +57,7 @@ SymReg * mk_const(const char * name, char t) {
r->reg = str_dup(name);
r->first = -1;
r->color = -1;
r->set = t;
r->type = VTCONST;
if(name[0])
store_symreg(r);
Expand Down Expand Up @@ -248,6 +249,9 @@ void compute_du_chain(SymReg * r) {
fprintf(stderr, "Internal error: symreg %s not referenced\n", r->name);
abort();
}
/* Symbol was never used in a statement, ignore for register allocation */
if(r->first < 0) return;

r->last = r->first;
i = r->first;
for(ins = instructions[i++]; ins; ins = instructions[i++]) {
Expand All @@ -271,6 +275,9 @@ int interferes(SymReg * r0, SymReg * r1) {
if(r0->first > r1->last) return 0;
else if(r0->last < r1->first) return 0;

/* If symbol was never used in a statment, it can't interfere */
if(r0->first < 0 || r1->first < 0) return 0;

return 1;
}

Expand Down

0 comments on commit 7419273

Please sign in to comment.