BSD 4_4 release
[unix-history] / usr / src / old / pcc / mip / reader.c
index 98531d0..e84339a 100644 (file)
@@ -1,5 +1,8 @@
-static char *sccsid ="@(#)reader.c     4.1 (Berkeley) %G%";
-# include "mfile2"
+#ifndef lint
+static char *sccsid ="@(#)reader.c     4.8 (Berkeley) 12/10/87";
+#endif lint
+
+# include "pass2.h"
 
 /*     some storage declarations */
 
 
 /*     some storage declarations */
 
@@ -14,6 +17,9 @@ int lineno;
 
 int nrecur;
 int lflag;
 
 int nrecur;
 int lflag;
+#ifdef FORT
+int Oflag = 0;
+#endif
 extern int Wflag;
 int edebug = 0;
 int xdebug = 0;
 extern int Wflag;
 int edebug = 0;
 int xdebug = 0;
@@ -96,6 +102,12 @@ p2init( argc, argv ) char *argv[];{
                                        ++Wflag;
                                        break;
 
                                        ++Wflag;
                                        break;
 
+#ifdef FORT
+                               case 'O':  /* optimizing */
+                                       ++Oflag;
+                                       break;
+#endif
+
                                default:
                                        cerror( "bad option: %c", *cp );
                                        }
                                default:
                                        cerror( "bad option: %c", *cp );
                                        }
@@ -200,9 +212,6 @@ mainp2( argc, argv ) char *argv[]; {
                tcheck();
                continue;
 
                tcheck();
                continue;
 
-       default:
-               cerror( "intermediate file format error" );
-
                }
 
        /* EOF */
                }
 
        /* EOF */
@@ -332,7 +341,7 @@ delay2( p ) register NODE *p; {
        case UNARY FORTCALL:
        case COMOP:
        case CBRANCH:
        case UNARY FORTCALL:
        case COMOP:
        case CBRANCH:
-               /* for the moment, don7t delay past a conditional context, or
+               /* for the moment, don't delay past a conditional context, or
                /* inside of a call */
                return;
 
                /* inside of a call */
                return;
 
@@ -405,7 +414,7 @@ char *cnames[] = {
 # else
        "STARNM",
 # endif
 # else
        "STARNM",
 # endif
-# ifdef WCARD2"
+# ifdef WCARD2
        "WCARD2",
 # else
        "STARREG",
        "WCARD2",
 # else
        "STARREG",
@@ -426,6 +435,9 @@ prcook( cookie ){
                if( cookie == SZERO ) printf( "SZERO" );
                else if( cookie == SONE ) printf( "SONE" );
                else if( cookie == SMONE ) printf( "SMONE" );
                if( cookie == SZERO ) printf( "SZERO" );
                else if( cookie == SONE ) printf( "SONE" );
                else if( cookie == SMONE ) printf( "SMONE" );
+               else if( cookie == SCCON ) printf( "SCCON" );
+               else if( cookie == SSCON ) printf( "SSCON" );
+               else if( cookie == SSOREG ) printf( "SSOREG" );
                else printf( "SPECIAL+%d", cookie & ~SPECIAL );
                return;
                }
                else printf( "SPECIAL+%d", cookie & ~SPECIAL );
                return;
                }
@@ -444,12 +456,12 @@ prcook( cookie ){
 
 int odebug = 0;
 
 
 int odebug = 0;
 
-order(p,cook) NODE *p; {
+order(p,cook) register NODE *p; {
 
        register o, ty, m;
        int m1;
        int cookie;
 
        register o, ty, m;
        int m1;
        int cookie;
-       NODE *p1, *p2;
+       register NODE *p1, *p2;
 
        cookie = cook;
        rcount();
 
        cookie = cook;
        rcount();
@@ -597,12 +609,12 @@ order(p,cook) NODE *p; {
 
        case FLD:       /* fields of funny type */
                if ( p1->in.op == UNARY MUL ){
 
        case FLD:       /* fields of funny type */
                if ( p1->in.op == UNARY MUL ){
-                       offstar( p1->in.left, cook );
+                       offstar( p1->in.left );
                        goto again;
                        }
 
        case UNARY MINUS:
                        goto again;
                        }
 
        case UNARY MINUS:
-               order( p1, INBREG|INAREG );
+               order( p1, INBREG|INAREG|SOREG );
                goto again;
 
        case NAME:
                goto again;
 
        case NAME:
@@ -646,11 +658,27 @@ order(p,cook) NODE *p; {
                        p->in.op = FREE;
                        return;
                        }
                        p->in.op = FREE;
                        return;
                        }
-               offstar( p->in.left, cook );
+#ifdef R2REGS
+               /* try to coax a tree into a doubly indexed OREG */
+               p1 = p->in.left;
+               if( p1->in.op == PLUS ) {
+                       if( ISPTR(p1->in.left->in.type) &&
+                           offset(p1->in.right, tlen(p)) >= 0 ) {
+                               order( p1->in.left, INAREG|INTAREG );
+                               goto again;
+                               }
+                       if( ISPTR(p1->in.right->in.type) &&
+                           offset(p1->in.left, tlen(p)) >= 0 ) {
+                               order( p1->in.right, INAREG|INTAREG );
+                               goto again;
+                               }
+                       }
+#endif
+               offstar( p->in.left );
                goto again;
 
        case INCR:  /* INCR and DECR */
                goto again;
 
        case INCR:  /* INCR and DECR */
-               if( setincr(p, cook) ) goto again;
+               if( setincr(p) ) goto again;
 
                /* x++ becomes (x += 1) -1; */
 
 
                /* x++ becomes (x += 1) -1; */
 
@@ -668,11 +696,11 @@ order(p,cook) NODE *p; {
                goto again;
 
        case STASG:
                goto again;
 
        case STASG:
-               if( setstr( p, cook ) ) goto again;
+               if( setstr( p ) ) goto again;
                goto nomat;
 
        case ASG PLUS:  /* and other assignment ops */
                goto nomat;
 
        case ASG PLUS:  /* and other assignment ops */
-               if( setasop(p, cook) ) goto again;
+               if( setasop(p) ) goto again;
 
                /* there are assumed to be no side effects in LHS */
 
 
                /* there are assumed to be no side effects in LHS */
 
@@ -692,12 +720,12 @@ order(p,cook) NODE *p; {
                goto again;
 
        case ASSIGN:
                goto again;
 
        case ASSIGN:
-               if( setasg( p, cook ) ) goto again;
+               if( setasg( p ) ) goto again;
                goto nomat;
 
 
        case BITYPE:
                goto nomat;
 
 
        case BITYPE:
-               if( setbin( p, cook ) ) goto again;
+               if( setbin( p ) ) goto again;
                /* try to replace binary ops by =ops */
                switch(o){
 
                /* try to replace binary ops by =ops */
                switch(o){