BSD 4_3 release
[unix-history] / usr / src / lib / mip / allo.c
index 41d2c9c..ba1fa42 100644 (file)
@@ -1,5 +1,8 @@
-static char *sccsid ="%W% (Berkeley) %G%";
-# include "mfile2"
+#ifndef lint
+static char *sccsid ="@(#)allo.c       4.8 (Berkeley) 1/8/86";
+#endif lint
+
+# include "pass2.h"
 
 NODE resc[3];
 
 
 NODE resc[3];
 
@@ -29,8 +32,6 @@ allo0(){ /* free everything */
        }
 # endif
 
        }
 # endif
 
-# define TBUSY 01000
-
 # ifndef ALLO
 allo( p, q ) NODE *p; struct optab *q; {
 
 # ifndef ALLO
 allo( p, q ) NODE *p; struct optab *q; {
 
@@ -197,8 +198,23 @@ usable( p, n, r ) NODE *p; {
        else {
                if( n & NBMASK ) return(0);
                }
        else {
                if( n & NBMASK ) return(0);
                }
-       if( (n&NAMASK) && (szty(p->in.type) == 2) ){ /* only do the pairing for real regs */
+       /*
+        * Some special cases that require register pairs...
+        * Have to check for ==, <=, etc. because the result is type int
+        * but need a register pair temp if either side is wide.
+        * For +=, *= etc. where lhs is narrow and rhs is wide, the temp
+        * register must be wide.
+        */
+       if( (n&NAMASK) &&
+           (szty(p->in.type) == 2 ||
+            (logop(p->in.op) && (szty(p->in.left->in.type) == 2 ||
+             szty(p->in.right->in.type) == 2)) ||
+            (asgop(p->in.op) && szty(p->in.right->in.type) == 2 &&
+             szty(p->in.left->in.type) == 1))
+       ){
+#ifndef NOEVENODD
                if( r&01 ) return(0);
                if( r&01 ) return(0);
+#endif
                if( !istreg(r+1) ) return( 0 );
                if( busy[r+1] > 1 ) return( 0 );
                if( busy[r] == 0 && busy[r+1] == 0  ||
                if( !istreg(r+1) ) return( 0 );
                if( busy[r+1] > 1 ) return( 0 );
                if( busy[r] == 0 && busy[r+1] == 0  ||
@@ -292,7 +308,11 @@ rfree( r, t ) TWORD t; {
        if( istreg(r) ){
                if( --busy[r] < 0 ) cerror( "register overfreed");
                if( szty(t) == 2 ){
        if( istreg(r) ){
                if( --busy[r] < 0 ) cerror( "register overfreed");
                if( szty(t) == 2 ){
+#ifdef NOEVENODD
+                       if( istreg(r) ^ istreg(r+1) ) cerror( "illegal free" );
+#else
                        if( (r&01) || (istreg(r)^istreg(r+1)) ) cerror( "illegal free" );
                        if( (r&01) || (istreg(r)^istreg(r+1)) ) cerror( "illegal free" );
+#endif
                        if( --busy[r+1] < 0 ) cerror( "register overfreed" );
                        }
                }
                        if( --busy[r+1] < 0 ) cerror( "register overfreed" );
                        }
                }
@@ -313,7 +333,11 @@ rbusy(r,t) TWORD t; {
        if( istreg(r) ) ++busy[r];
        if( szty(t) == 2 ){
                if( istreg(r+1) ) ++busy[r+1];
        if( istreg(r) ) ++busy[r];
        if( szty(t) == 2 ){
                if( istreg(r+1) ) ++busy[r+1];
+#ifdef NOEVENODD
+               if( istreg(r) ^ istreg(r+1) ) cerror( "illegal register pair freed" );
+#else
                if( (r&01) || (istreg(r)^istreg(r+1)) ) cerror( "illegal register pair freed" );
                if( (r&01) || (istreg(r)^istreg(r+1)) ) cerror( "illegal register pair freed" );
+#endif
                }
        }
 # endif
                }
        }
 # endif
@@ -461,7 +485,9 @@ reclaim( p, rw, cookie ) NODE *p; {
                        /* the "T" command in match supresses this type changing */
                        if( p->in.type == CHAR || p->in.type == SHORT ) p->in.type = INT;
                        else if( p->in.type == UCHAR || p->in.type == USHORT ) p->in.type = UNSIGNED;
                        /* the "T" command in match supresses this type changing */
                        if( p->in.type == CHAR || p->in.type == SHORT ) p->in.type = INT;
                        else if( p->in.type == UCHAR || p->in.type == USHORT ) p->in.type = UNSIGNED;
+#if !defined(FORT) && !defined(SPRECC)
                        else if( p->in.type == FLOAT ) p->in.type = DOUBLE;
                        else if( p->in.type == FLOAT ) p->in.type = DOUBLE;
+#endif
                        }
                if( ! (p->in.rall & MUSTDO ) ) return;  /* unless necessary, ignore it */
                i = p->in.rall & ~MUSTDO;
                        }
                if( ! (p->in.rall & MUSTDO ) ) return;  /* unless necessary, ignore it */
                i = p->in.rall & ~MUSTDO;
@@ -488,6 +514,7 @@ reclaim( p, rw, cookie ) NODE *p; {
 
        }
 
 
        }
 
+#ifndef ncopy
 ncopy( q, p ) NODE *p, *q; {
        /* copy the contents of p into q, without any feeling for
           the contents */
 ncopy( q, p ) NODE *p, *q; {
        /* copy the contents of p into q, without any feeling for
           the contents */
@@ -511,6 +538,7 @@ ncopy( q, p ) NODE *p, *q; {
 #endif
 
        }
 #endif
 
        }
+#endif
 
 NODE *
 tcopy( p ) register NODE *p; {
 
 NODE *
 tcopy( p ) register NODE *p; {