some fixes: fix order in which registers are allocated, make sure that
authorceriel <none@none>
Fri, 17 Mar 1989 16:49:58 +0000 (16:49 +0000)
committerceriel <none@none>
Fri, 17 Mar 1989 16:49:58 +0000 (16:49 +0000)
a pattern chosen by the distance routine can be made from the stack if the
fakestack does not contain enough tokens

mach/proto/ncg/codegen.c
mach/proto/ncg/equiv.c
mach/proto/ncg/subr.c

index 2b1391b..06c7e69 100644 (file)
@@ -848,9 +848,14 @@ normalfailed:      if (stackpad!=tokpatlen) {
     doreturn:
 #ifdef ALLOW_NEXTEM
        if (toplevel && totalcost == INFINITY && ! paniced) {
+               DEBUG("PANIC!");
                totalcost += stackupto(&fakestack[stackheight-1], ply, toplevel);
+#ifndef NDEBUG
+               if (Debug > 2)
+                       fprintf(stderr, "Stackheight = %d\n", stackheight);
+#endif
                paniced = 1;
-               DEBUG("PANIC!");
+               tokpatlen = 0;
                goto panic;
        }
 #endif
index ad1437f..41966e9 100644 (file)
@@ -36,10 +36,10 @@ tuples(regls,nregneeded) rl_p *regls; {
         * First compute equivalence classes of registers.
         */
 
-       for (i=0;i<NREGS;i++) {
+       for (i=NREGS;--i>=0;) {
                regclass[i] = class++;
                if (getrefcount(i, FALSE) == 0) {
-                       for (j=0;j<i;j++) {
+                       for (j=NREGS;--j>i;) {
                                if (eqregclass(i,j) &&
                                    eqtoken(&machregs[i].r_contents,
                                            &machregs[j].r_contents)) {
@@ -86,8 +86,8 @@ permute(index) {
                perms = pp;
        } else {
                rlp=lar[index];
-               for (i=rlp->rl_n-1; i>=0; i--) {
-                       rar[index] = rlp->rl_list[i];
+               for (i=rlp->rl_n; i>0; i--) {
+                       rar[index] = rlp->rl_list[rlp->rl_n-i];
                        permute(index+1);
                }
        }
index d7a4eec..e5f6cca 100644 (file)
@@ -327,6 +327,15 @@ distance(cindex) {
                } else
                        exact++;
        }
+       for (;i<tpl+fromstackneeded;i++) {
+               /*      Make sure that any pattern we pick can be
+                       made from the stack
+               */
+               getint(tokexp,bp);
+               if (! from_stack(&machsets[tokexp])) {
+                       return(MAXINT);
+               }
+       }
        if (exact==tpl && ! fromstackneeded) {
                if (xsekt)
                        return(0);
@@ -335,6 +344,19 @@ distance(cindex) {
        return(20-2*exact+fromstackneeded);
 }
 
+extern set_t unstackset;
+
+int from_stack(s1)
+       register set_p s1;
+{
+       register set_p s2 = &unstackset;
+       register int i;
+       for (i = 0; i < SETSIZE; i++) {
+               if ((s1->set_val[i] & s2->set_val[i]) != 0) return 1;
+       }
+       return 0;
+}
+
 unsigned costcalc(cost) cost_t cost; {
        extern unsigned cc1,cc2,cc3,cc4;