changes for single precision floats; lint cleanups
authorRalph Campbell <ralph@ucbvax.Berkeley.EDU>
Sat, 19 Jan 1985 08:16:39 +0000 (00:16 -0800)
committerRalph Campbell <ralph@ucbvax.Berkeley.EDU>
Sat, 19 Jan 1985 08:16:39 +0000 (00:16 -0800)
SCCS-vsn: old/pcc/ccom.vax/local2.c 1.8
SCCS-vsn: old/pcc/mip/allo.c 4.3
SCCS-vsn: old/pcc/mip/cgram.y 4.2
SCCS-vsn: old/pcc/mip/common 4.2
SCCS-vsn: old/pcc/mip/fort.c 4.3
SCCS-vsn: old/pcc/mip/manifest 4.3
SCCS-vsn: old/pcc/mip/match.c 4.2
SCCS-vsn: old/pcc/mip/mfile1 4.3
SCCS-vsn: old/pcc/mip/mfile2 4.2
SCCS-vsn: old/pcc/mip/optim.c 4.3
SCCS-vsn: old/pcc/mip/pftn.c 1.6
SCCS-vsn: old/pcc/mip/reader.c 4.2
SCCS-vsn: old/pcc/mip/scan.c 1.5
SCCS-vsn: old/pcc/mip/trees.c 4.6
SCCS-vsn: old/pcc/mip/xdefs.c 4.2

15 files changed:
usr/src/old/pcc/ccom.vax/local2.c
usr/src/old/pcc/mip/allo.c
usr/src/old/pcc/mip/cgram.y
usr/src/old/pcc/mip/common
usr/src/old/pcc/mip/fort.c
usr/src/old/pcc/mip/manifest
usr/src/old/pcc/mip/match.c
usr/src/old/pcc/mip/mfile1
usr/src/old/pcc/mip/mfile2
usr/src/old/pcc/mip/optim.c
usr/src/old/pcc/mip/pftn.c
usr/src/old/pcc/mip/reader.c
usr/src/old/pcc/mip/scan.c
usr/src/old/pcc/mip/trees.c
usr/src/old/pcc/mip/xdefs.c

index d645b67..d91381f 100644 (file)
@@ -1,4 +1,7 @@
-static char *sccsid ="@(#)local2.c     1.7 (Berkeley) %G%";
+# ifndef lint
+static char *sccsid ="@(#)local2.c     1.8 (Berkeley) %G%";
+# endif
+
 # include "mfile2"
 # include "ctype.h"
 # ifdef FORT
 # include "mfile2"
 # include "ctype.h"
 # ifdef FORT
@@ -211,7 +214,7 @@ zzzcode( p, c ) register NODE *p; {
                        l = getlr(p, 'L');
                else if (p->in.op == SCONV) {
                        l = resc;
                        l = getlr(p, 'L');
                else if (p->in.op == SCONV) {
                        l = resc;
-#ifdef FORT
+#if defined(FORT) || defined(SPRECC)
                        l->in.type = r->in.type;
 #else
                        l->in.type = r->in.type==FLOAT ? DOUBLE : r->in.type;
                        l->in.type = r->in.type;
 #else
                        l->in.type = r->in.type==FLOAT ? DOUBLE : r->in.type;
@@ -220,7 +223,7 @@ zzzcode( p, c ) register NODE *p; {
                        }
                else {          /* OPLTYPE */
                        l = resc;
                        }
                else {          /* OPLTYPE */
                        l = resc;
-#ifdef FORT
+#if defined(FORT) || defined(SPRECC)
                        l->in.type = (r->in.type==FLOAT || r->in.type==DOUBLE ? r->in.type : INT);
 #else
                        l->in.type = (r->in.type==FLOAT || r->in.type==DOUBLE ? DOUBLE : INT);
                        l->in.type = (r->in.type==FLOAT || r->in.type==DOUBLE ? r->in.type : INT);
 #else
                        l->in.type = (r->in.type==FLOAT || r->in.type==DOUBLE ? DOUBLE : INT);
@@ -284,7 +287,20 @@ zzzcode( p, c ) register NODE *p; {
                if (!mixtypes(l,r)) {
                        if (tlen(l) == tlen(r)) {
                                printf("mov");
                if (!mixtypes(l,r)) {
                        if (tlen(l) == tlen(r)) {
                                printf("mov");
+#ifdef FORT
+                               if (Oflag)
+                                       prtype(l);
+                               else {
+                                       if (l->in.type == DOUBLE)
+                                               printf("q");
+                                       else if(l->in.type == FLOAT)
+                                               printf("l");
+                                       else
+                                               prtype(l);
+                                       }
+#else
                                prtype(l);
                                prtype(l);
+#endif FORT
                                goto ops;
                                }
                        else if (tlen(l) > tlen(r) && ISUNSIGNED(r->in.type))
                                goto ops;
                                }
                        else if (tlen(l) > tlen(r) && ISUNSIGNED(r->in.type))
@@ -460,8 +476,11 @@ zzzcode( p, c ) register NODE *p; {
                }
        }
 
                }
        }
 
-rmove( rt, rs, t ){
+rmove( rt, rs, t ) TWORD t; {
        printf( "       %s      %s,%s\n",
        printf( "       %s      %s,%s\n",
+#ifdef FORT
+               !Oflag ? (t==DOUBLE ? "movq" : "movl") :
+#endif
                (t==FLOAT ? "movf" : (t==DOUBLE ? "movd" : "movl")),
                rnames[rs], rnames[rt] );
        }
                (t==FLOAT ? "movf" : (t==DOUBLE ? "movd" : "movl")),
                rnames[rs], rnames[rt] );
        }
@@ -480,8 +499,8 @@ setregs(){ /* set up temporary registers */
        ;
        }
 
        ;
        }
 
-szty(t){ /* size, in registers, needed to hold thing of type t */
-#ifdef FORT
+szty(t) TWORD t; { /* size, in registers, needed to hold thing of type t */
+#if defined(FORT) || defined(SPRECC)
        return( (t==DOUBLE) ? 2 : 1 );
 #else
        return( (t==DOUBLE||t==FLOAT) ? 2 : 1 );
        return( (t==DOUBLE) ? 2 : 1 );
 #else
        return( (t==DOUBLE||t==FLOAT) ? 2 : 1 );
@@ -636,7 +655,8 @@ shumul( p ) register NODE *p; {
                                break;
 
                        default:
                                break;
 
                        default:
-                               if ( ISPTR(p->in.type) ) {
+                               if ( ISPTR(p->in.type) &&
+                                    ISPTR(DECREF(p->in.type)) ) {
                                        o = 4;
                                        break;
                                        }
                                        o = 4;
                                        break;
                                        }
@@ -746,6 +766,8 @@ adrput( p ) register NODE *p; {
                                }
    tbl */
                        q = p->in.left;
                                }
    tbl */
                        q = p->in.left;
+                       if( q->in.right->tn.lval != tlen(p) )
+                               cerror("adrput: bad auto-increment/decrement");
                        printf("%s(%s)%s", (q->in.op==INCR ? "" : "-"),
                                rnames[q->in.left->tn.rval], 
                                (q->in.op==INCR ? "+" : "") );
                        printf("%s(%s)%s", (q->in.op==INCR ? "" : "-"),
                                rnames[q->in.left->tn.rval], 
                                (q->in.op==INCR ? "+" : "") );
@@ -976,7 +998,7 @@ optim2( p ) register NODE *p; {
                break;
 
        case SCONV:
                break;
 
        case SCONV:
-#ifdef FORT
+#if defined(FORT) || defined(SPRECC)
                if( p->in.type == FLOAT || p->in.type == DOUBLE ||
                    (l = p->in.left)->in.type == FLOAT || l->in.type == DOUBLE )
                        break;
                if( p->in.type == FLOAT || p->in.type == DOUBLE ||
                    (l = p->in.left)->in.type == FLOAT || l->in.type == DOUBLE )
                        break;
@@ -1008,7 +1030,7 @@ optim2( p ) register NODE *p; {
                }
        }
 
                }
        }
 
-NODE * addroreg(l)
+NODE * addroreg(l) NODE *l;
                                /* OREG was built in clocal()
                                 * for an auto or formal parameter
                                 * now its address is being taken
                                /* OREG was built in clocal()
                                 * for an auto or formal parameter
                                 * now its address is being taken
@@ -1018,6 +1040,7 @@ NODE * addroreg(l)
                                 */
 {
        cerror("address of OREG taken");
                                 */
 {
        cerror("address of OREG taken");
+       /*NOTREACHED*/
 }
 
 
 }
 
 
@@ -1046,11 +1069,13 @@ hardops(p)  register NODE *p; {
        register NODE *q;
        register struct functbl *f;
        register o;
        register NODE *q;
        register struct functbl *f;
        register o;
-       register TWORD t;
+       NODE *old,*temp;
 
        o = p->in.op;
 
        o = p->in.op;
-       t = p->in.type;
-       if( t!=UNSIGNED && t!=ULONG ) return;
+       if( ! (optype(o)==BITYPE &&
+              (ISUNSIGNED(p->in.left->in.type) ||
+               ISUNSIGNED(p->in.right->in.type))) )
+               return;
 
        for( f=opfunc; f->fop; f++ ) {
                if( o==f->fop ) goto convert;
 
        for( f=opfunc; f->fop; f++ ) {
                if( o==f->fop ) goto convert;
@@ -1059,7 +1084,32 @@ hardops(p)  register NODE *p; {
 
        convert:
        if( asgop( o ) ) {
 
        convert:
        if( asgop( o ) ) {
+               old = NIL;
                switch( p->in.left->in.op ){
                switch( p->in.left->in.op ){
+               case FLD:
+                       q = p->in.left->in.left;
+                       /*
+                        * rewrite (lval.fld /= rval); as
+                        *  ((*temp).fld = udiv((*(temp = &lval)).fld,rval));
+                        * else the compiler will evaluate lval twice.
+                        */
+                       if( q->in.op == UNARY MUL ){
+                               /* first allocate a temp storage */
+                               temp = talloc();
+                               temp->in.op = OREG;
+                               temp->tn.rval = TMPREG;
+                               temp->tn.lval = BITOOR(freetemp(1));
+                               temp->in.type = INCREF(p->in.type);
+#ifdef FLEXNAMES
+                               temp->in.name = "";
+#else
+                               temp->in.name[0] = '\0';
+#endif
+                               old = q->in.left;
+                               q->in.left = temp;
+                       }
+                       /* fall thru ... */
+
                case REG:
                case NAME:
                case OREG:
                case REG:
                case NAME:
                case OREG:
@@ -1074,6 +1124,22 @@ hardops(p)  register NODE *p; {
                        p->in.right = q;
                        p = q;
                        f -= 2; /* Note: this depends on the table order */
                        p->in.right = q;
                        p = q;
                        f -= 2; /* Note: this depends on the table order */
+                       /* on the right side only - replace *temp with
+                        *(temp = &lval), build the assignment node */
+                       if( old ){
+                               temp = q->in.left->in.left; /* the "*" node */
+                               q = talloc();
+                               q->in.op = ASSIGN;
+                               q->in.left = temp->in.left;
+                               q->in.right = old;
+                               q->in.type = old->in.type;
+#ifdef FLEXNAMES
+                               q->in.name = "";
+#else
+                               q->in.name[0] = '\0';
+#endif
+                               temp->in.left = q;
+                       }
                        break;
 
                case UNARY MUL:
                        break;
 
                case UNARY MUL:
@@ -1086,8 +1152,7 @@ hardops(p)  register NODE *p; {
                default:
                        cerror( "hardops: can't compute & LHS" );
                        }
                default:
                        cerror( "hardops: can't compute & LHS" );
                        }
-
-       }
+               }
 
        /* build comma op for args to function */
        q = talloc();
 
        /* build comma op for args to function */
        q = talloc();
@@ -1114,11 +1179,53 @@ hardops(p)  register NODE *p; {
 
        }
 
 
        }
 
+zappost(p) NODE *p; {
+       /* look for ++ and -- operators and remove them */
+
+       register o, ty;
+       register NODE *q;
+       o = p->in.op;
+       ty = optype( o );
+
+       switch( o ){
+
+       case INCR:
+       case DECR:
+                       q = p->in.left;
+                       p->in.right->in.op = FREE;  /* zap constant */
+                       ncopy( p, q );
+                       q->in.op = FREE;
+                       return;
+
+               }
+
+       if( ty == BITYPE ) zappost( p->in.right );
+       if( ty != LTYPE ) zappost( p->in.left );
+}
+
+fixpre(p) NODE *p; {
+
+       register o, ty;
+       o = p->in.op;
+       ty = optype( o );
+
+       switch( o ){
+
+       case ASG PLUS:
+                       p->in.op = PLUS;
+                       break;
+       case ASG MINUS:
+                       p->in.op = MINUS;
+                       break;
+               }
+
+       if( ty == BITYPE ) fixpre( p->in.right );
+       if( ty != LTYPE ) fixpre( p->in.left );
+}
+
 myreader(p) register NODE *p; {
 myreader(p) register NODE *p; {
+       canon( p );             /* expands r-vals for fields */
        walkf( p, hardops );    /* convert ops to function calls */
        walkf( p, hardops );    /* convert ops to function calls */
-       canon( p );             /* expands r-vals for fileds */
        walkf( p, optim2 );
        /* jwf toff = 0;  /* stack offset swindle */
        }
        walkf( p, optim2 );
        /* jwf toff = 0;  /* stack offset swindle */
        }
-
-
index 9dc4b14..6d2c029 100644 (file)
@@ -1,4 +1,7 @@
-static char *sccsid ="@(#)allo.c       4.2 (Berkeley) %G%";
+#ifndef lint
+static char *sccsid ="@(#)allo.c       4.3 (Berkeley) %G%";
+#endif lint
+
 # include "mfile2"
 
 NODE resc[3];
 # include "mfile2"
 
 NODE resc[3];
@@ -471,7 +474,7 @@ 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;
-#ifndef FORT
+#if !defined(FORT) && !defined(SPRECC)
                        else if( p->in.type == FLOAT ) p->in.type = DOUBLE;
 #endif
                        }
                        else if( p->in.type == FLOAT ) p->in.type = DOUBLE;
 #endif
                        }
index 21b0e41..46d5a48 100644 (file)
@@ -1,85 +1,58 @@
-%term NAME  2
-%term STRING  3
-%term ICON  4
-%term FCON  5
-%term PLUS   6
-%term MINUS   8
-%term MUL   11
-%term AND   14
-%term OR   17
-%term ER   19
-%term QUEST  21
-%term COLON  22
-%term ANDAND  23
-%term OROR  24
-
-/*     special interfaces for yacc alone */
-/*     These serve as abbreviations of 2 or more ops:
-       ASOP    =, = ops
-       RELOP   LE,LT,GE,GT
-       EQUOP   EQ,NE
-       DIVOP   DIV,MOD
-       SHIFTOP LS,RS
-       ICOP    ICR,DECR
-       UNOP    NOT,COMPL
-       STROP   DOT,STREF
-
-       */
-%term ASOP  25
-%term RELOP  26
-%term EQUOP  27
-%term DIVOP  28
-%term SHIFTOP  29
-%term INCOP  30
-%term UNOP  31
-%term STROP  32
-
-/*     reserved words, etc */
-%term TYPE  33
-%term CLASS  34
-%term STRUCT  35
-%term RETURN  36
-%term GOTO  37
-%term IF  38
-%term ELSE  39
-%term SWITCH  40
-%term BREAK  41
-%term CONTINUE  42
-%term WHILE  43
-%term DO  44
-%term FOR  45
-%term DEFAULT  46
-%term CASE  47
-%term SIZEOF  48
-%term ENUM 49
-
-
-/*     little symbols, etc. */
-/*     namely,
-
-       LP      (
-       RP      )
-
-       LC      {
-       RC      }
-
-       LB      [
-       RB      ]
-
-       CM      ,
-       SM      ;
-
-       */
-
-%term LP  50
-%term RP  51
-%term LC  52
-%term RC  53
-%term LB  54
-%term RB  55
-%term CM  56
-%term SM  57
-%term ASSIGN  58
+%term NAME     2               /* identifier */
+%term STRING   3               /* string constant, "..." */
+%term ICON     4               /* integer constant */
+%term FCON     5               /* single precision floating point constant */
+%term DCON     6               /* double precision floating point constant */
+/* 8 is used in the 2nd pass reader for BITYPE */
+%term PLUS     9               /* + */
+%term MINUS    11              /* - */
+%term MUL      14              /* * */
+%term AND      17              /* & */
+%term OR       20              /* | */
+%term ER       22              /* ^ */
+%term QUEST    24              /* ? */
+%term COLON    25              /* : */
+%term ANDAND   26              /* && */
+%term OROR     27              /* || */
+
+%term ASOP     28              /* =, =ops */
+%term RELOP    29              /* LE, LT, GE, GT */
+%term EQUOP    30              /* EQ, NE */
+%term DIVOP    31              /* DIV, MOD */
+%term SHIFTOP  32              /* LS, RS */
+%term INCOP    33              /* INCR, DECR */
+%term UNOP     34              /* NOT, COMPL */
+%term STROP    35              /* DOT, STREF */
+
+/* reserved words, etc */
+%term TYPE     36              /* symbol type */
+%term CLASS    37              /* storage type */
+%term STRUCT   38              /* struct */
+%term RETURN   39              /* return */
+%term GOTO     40              /* goto */
+%term IF       41              /* if */
+%term ELSE     42              /* else */
+%term SWITCH   43              /* switch */
+%term BREAK    44              /* break */
+%term CONTINUE 45              /* continue */
+%term WHILE    46              /* while */
+%term DO       47              /* do */
+%term FOR      48              /* for */
+%term DEFAULT  49              /* default */
+%term CASE     50              /* case */
+%term SIZEOF   51              /* sizeof */
+%term ENUM     52              /* enum */
+
+/* little symbols, etc. */
+%term LP       53              /* ( */
+%term RP       54              /* ) */
+%term LC       55              /* { */
+%term RC       56              /* } */
+%term LB       57              /* [ */
+%term RB       58              /* ] */
+%term CM       59              /* , */
+%term SM       60              /* ; */
+%term ASSIGN   61              /* = */
 
 /* at last count, there were 7 shift/reduce, 1 reduce/reduce conflicts
 /* these involved:
 
 /* at last count, there were 7 shift/reduce, 1 reduce/reduce conflicts
 /* these involved:
@@ -396,6 +369,10 @@ init_declarator:   nfdeclarator
                        ={  nidcl( tymerge($<nodep>0,$1) ); }
                |  fdeclarator
                        ={  defid( tymerge($<nodep>0,$1), uclass(curclass) );
                        ={  nidcl( tymerge($<nodep>0,$1) ); }
                |  fdeclarator
                        ={  defid( tymerge($<nodep>0,$1), uclass(curclass) );
+                           if( paramno > 0 ){
+                               uerror( "illegal argument" );
+                               paramno = 0;
+                               }
                        }
                |  xnfdeclarator optasgn e
                        %prec CM
                        }
                |  xnfdeclarator optasgn e
                        %prec CM
@@ -792,7 +769,11 @@ term:                 term INCOP
                            }
                |  FCON
                        ={  $$=buildtree(FCON,NIL,NIL);
                            }
                |  FCON
                        ={  $$=buildtree(FCON,NIL,NIL);
-                           $$->fpn.dval = dcon;
+                           $$->fpn.fval = fcon;
+                           }
+               |  DCON
+                       ={  $$=buildtree(DCON,NIL,NIL);
+                           $$->dpn.dval = dcon;
                            }
                |  STRING
                        ={  $$ = getstr(); /* get string contents */ }
                            }
                |  STRING
                        ={  $$ = getstr(); /* get string contents */ }
index 13028f5..8dae0f9 100644 (file)
@@ -21,7 +21,7 @@ unsigned caloff(){
        do {
                temp <<= 1;
                ++i;
        do {
                temp <<= 1;
                ++i;
-               } while( temp > 0 );
+               } while( temp != 0 );
        off = 1 << (i-1);
        return (off);
        }
        off = 1 << (i-1);
        return (off);
        }
@@ -170,6 +170,7 @@ struct dopest { int dopeop; char opst[8]; int dopeval; } indope[] = {
        OREG, "OREG", LTYPE,
        ICON, "ICON", LTYPE,
        FCON, "FCON", LTYPE,
        OREG, "OREG", LTYPE,
        ICON, "ICON", LTYPE,
        FCON, "FCON", LTYPE,
+       DCON, "DCON", LTYPE,
        CCODES, "CCODES", LTYPE,
        UNARY MINUS, "U-", UTYPE,
        UNARY MUL, "U*", UTYPE,
        CCODES, "CCODES", LTYPE,
        UNARY MINUS, "U-", UTYPE,
        UNARY MUL, "U*", UTYPE,
index 39f2bce..05ca569 100644 (file)
@@ -1,4 +1,7 @@
-static char *sccsid ="@(#)fort.c       4.2 (Berkeley) %G%";
+#ifndef lint
+static char *sccsid ="@(#)fort.c       4.3 (Berkeley) %G%";
+#endif lint
+
 # define FORT
 /* this forces larger trees, etc. */
 # include "mfile2"
 # define FORT
 /* this forces larger trees, etc. */
 # include "mfile2"
index 47d6b48..a53641e 100644 (file)
@@ -1,6 +1,7 @@
-/*     manifest        4.2     84/12/03        */
+/*     manifest        4.3     85/01/18        */
 
 # include <stdio.h>
 
 # include <stdio.h>
+
 /*     manifest constant file for the lex/yacc interface */
 
 # define ERROR 1
 /*     manifest constant file for the lex/yacc interface */
 
 # define ERROR 1
@@ -8,39 +9,39 @@
 # define STRING 3
 # define ICON 4
 # define FCON 5
 # define STRING 3
 # define ICON 4
 # define FCON 5
-# define PLUS 6
-# define MINUS 8
-# define MUL 11
-# define AND 14
-# define OR 17
-# define ER 19
-# define QUEST 21
-# define COLON 22
-# define ANDAND 23
-# define OROR 24
+# define DCON 6
+# define PLUS 9
+# define MINUS 11
+# define MUL 14
+# define AND 17
+# define OR 20
+# define ER 22
+# define QUEST 24
+# define COLON 25
+# define ANDAND 26
+# define OROR 27
 
 /* the defines for ASOP, RELOP, EQUOP, DIVOP,
    SHIFTOP, ICOP, UNOP, and STROP have been
    moved to mfile1                             */
 /*     reserved words, etc */
 
 /* the defines for ASOP, RELOP, EQUOP, DIVOP,
    SHIFTOP, ICOP, UNOP, and STROP have been
    moved to mfile1                             */
 /*     reserved words, etc */
-# define TYPE 33
-# define CLASS 34
-# define STRUCT 35
-# define RETURN 36
-# define GOTO 37
-# define IF 38
-# define ELSE 39
-# define SWITCH 40
-# define BREAK 41
-# define CONTINUE 42
-# define WHILE 43
-# define DO 44
-# define FOR 45
-# define DEFAULT 46
-# define CASE 47
-# define SIZEOF 48
-# define ENUM 49
-
+# define TYPE 36
+# define CLASS 37
+# define STRUCT 38
+# define RETURN 39
+# define GOTO 40
+# define IF 41
+# define ELSE 42
+# define SWITCH 43
+# define BREAK 44
+# define CONTINUE 45
+# define WHILE 46
+# define DO 47
+# define FOR 48
+# define DEFAULT 49
+# define CASE 50
+# define SIZEOF 51
+# define ENUM 52
 
 /*     little symbols, etc. */
 /*     namely,
 
 /*     little symbols, etc. */
 /*     namely,
 
 /*  These defines are being moved to mfile1
     to alleviate preprocessor problems with
 
 /*  These defines are being moved to mfile1
     to alleviate preprocessor problems with
-    second pass files.  
-# define LP 50
-# define RP 51
-# define LC 52
-# define RC 53
-*/
-# define LB 54
-# define RB 55
-# define CM 56
-# define SM 57
-# define ASSIGN 58
+    second pass files: LP, RP, LC, RC */
+# define LB 57
+# define RB 58
+# define CM 59
+# define SM 60
+# define ASSIGN 61
 
 /*     END OF YACC */
 
 /*     left over tree building operators */
 
 /*     END OF YACC */
 
 /*     left over tree building operators */
-# define COMOP 59
-# define DIV 60
-# define MOD 62
-# define LS 64
-# define RS 66
-# define DOT 68
-# define STREF 69
-# define CALL 70
-# define FORTCALL 73
-# define NOT 76
-# define COMPL 77
-# define INCR 78
-# define DECR 79
-# define EQ 80
-# define NE 81
-# define LE 82
-# define LT 83
-# define GE 84
-# define GT 85
-# define ULE 86
-# define ULT 87
-# define UGE 88
-# define UGT 89
-# define SETBIT 90
-# define TESTBIT 91
-# define RESETBIT 92
-# define ARS 93
-# define REG 94
-# define OREG 95
-# define CCODES 96
-# define FREE 97
-# define STASG 98
-# define STARG 99
-# define STCALL 100
-
-/*     some conversion operators */
-# define FLD 103
-# define SCONV 104
-# define PCONV 105
-# define PMCONV 106
-# define PVCONV 107
-
-/*     special node operators, used for special contexts */
-# define FORCE 108
-# define CBRANCH 109
-# define INIT 110
-# define CAST 111
+#define COMOP  62              /* , operator */
+#define DIV    63              /* / */
+#define MOD    65              /* % */
+#define LS     67              /* << */
+#define RS     69              /* >> */
+#define DOT    71              /* . */
+#define STREF  72              /* -> */
+#define CALL   73              /* C function call */
+#define FORTCALL 76            /* Fortran function call */
+#define NOT    79              /* ! */
+#define COMPL  80              /* ~ */
+#define INCR   81              /* ++ */
+#define DECR   82              /* -- */
+#define EQ     83              /* == */
+#define NE     84              /* != */
+#define LE     85              /* <= */
+#define LT     86              /* < */
+#define GE     87              /* >= */
+#define GT     88              /* > */
+#define ULE    89              /* unsigned <= */
+#define ULT    90              /* unsigned < */
+#define UGE    91              /* unsigned >= */
+#define UGT    92              /* unsigned > */
+#define        SETBIT  93              /* unused */
+#define TESTBIT        94              /* unused */
+#define RESETBIT 95            /* unused */
+#define ARS    96              /* arithmetic >> */
+#define REG    97              /* register */
+#define OREG   98              /* offset from register */
+#define CCODES 99              /* condition codes */
+#define FREE   100             /* free node */
+#define STASG  101             /* structure assignment */
+#define STARG  102             /* structure parameter */
+#define STCALL 103             /* call to function returning structure */
+
+/* some conversion operators */
+#define FLD    106             /* field */
+#define SCONV  107             /* storage conversion */
+#define PCONV  108             /* pointer conversion */
+#define PMCONV 109             /* pointer multiply conversion (from +) */
+#define PVCONV 110             /* pointer divide conversion (from -) */
+
+/* special node operators, used for special contexts */
+#define FORCE  111             /* force result, for return values */
+#define CBRANCH        112             /* condition branch */
+#define INIT   113             /* data initialization */
+#define CAST   114             /* type cast */
 
 /*     node types */
 # define LTYPE 02
 
 /*     node types */
 # define LTYPE 02
@@ -303,14 +299,24 @@ union ndu {
                }fn; /* front node */
        
        struct {
                }fn; /* front node */
        
        struct {
-               /* this structure is used when a floating point constant
+               /* this structure is used when a single precision constant
+                  is being computed */
+               int op;
+               int cdim;
+               TWORD type;
+               int csiz;
+               float fval;
+               }fpn; /* FCON node */
+
+       struct {
+               /* this structure is used when a double precision constant
                   is being computed */
                int op;
                int cdim;
                TWORD type;
                int csiz;
                double dval;
                   is being computed */
                int op;
                int cdim;
                TWORD type;
                int csiz;
                double dval;
-               }fpn; /* floating point node */
+               }dpn; /* DCON node */
 
        };
 # endif
 
        };
 # endif
index 4982a21..1859967 100644 (file)
@@ -1,4 +1,7 @@
-static char *sccsid ="@(#)match.c      4.1 (Berkeley) %G%";
+#ifndef lint
+static char *sccsid ="@(#)match.c      4.2 (Berkeley) %G%";
+#endif lint
+
 # include "mfile2"
 
 # ifdef WCARD1
 # include "mfile2"
 
 # ifdef WCARD1
@@ -317,7 +320,9 @@ int rtyflg = 0;
 expand( p, cookie, cp ) NODE *p;  register char *cp; {
        /* generate code by interpreting table entry */
 
 expand( p, cookie, cp ) NODE *p;  register char *cp; {
        /* generate code by interpreting table entry */
 
+# ifdef NEWZZZ
        register char c;
        register char c;
+# endif
        CONSZ val;
 
        rtyflg = 0;
        CONSZ val;
 
        rtyflg = 0;
index 387e39c..af4ad0f 100644 (file)
@@ -1,4 +1,4 @@
-/*     @(#)mfile1      4.2     (Berkeley)      83/04/04        */
+/*     @(#)mfile1      4.3     (Berkeley)      85/01/18        */
 
 # include "macdefs"
 # include "manifest"
 
 # include "macdefs"
 # include "manifest"
@@ -110,15 +110,24 @@ union ndu {
                CONSZ lval;
                int rval;
                }tn; /* terminal node */
                CONSZ lval;
                int rval;
                }tn; /* terminal node */
-       
+
+       struct {
+               /* this structure is used when a single precision constant
+                  is being computed */
+               int op;
+               TWORD type;
+               int cdim, csiz;
+               float fval;
+               }fpn; /* FCON node */
+
        struct {
        struct {
-               /* this structure is used when a floating point constant
+               /* this structure is used when a double precision constant
                   is being computed */
                int op;
                TWORD type;
                int cdim, csiz;
                double dval;
                   is being computed */
                int op;
                TWORD type;
                int cdim, csiz;
                double dval;
-               }fpn; /* floating point node */
+               }dpn; /* DCON node */
 
        };
 # endif
 
        };
 # endif
@@ -144,6 +153,7 @@ typedef union {
 extern YYSTYPE yylval;
 
 extern CONSZ lastcon;
 extern YYSTYPE yylval;
 
 extern CONSZ lastcon;
+extern float fcon;
 extern double dcon;
 
 extern char ftitle[];
 extern double dcon;
 
 extern char ftitle[];
@@ -236,7 +246,7 @@ extern NODE
        *doszof(),
        *talloc(),
        *optim(),
        *doszof(),
        *talloc(),
        *optim(),
-       *strargs(),
+       *fixargs(),
        *clocal();
 
 OFFSZ  tsize(),
        *clocal();
 
 OFFSZ  tsize(),
@@ -274,16 +284,16 @@ char *exname(), *exdcon();
        STROP   DOT,STREF
 
        */
        STROP   DOT,STREF
 
        */
-# define ASOP 25
-# define RELOP 26
-# define EQUOP 27
-# define DIVOP 28
-# define SHIFTOP 29
-# define INCOP 30
-# define UNOP 31
-# define STROP 32
-
-# define LP 50
-# define RP 51
-# define LC 52
-# define RC 53
+# define ASOP 28
+# define RELOP 29
+# define EQUOP 30
+# define DIVOP 31
+# define SHIFTOP 32
+# define INCOP 33
+# define UNOP 34
+# define STROP 35
+
+# define LP 53
+# define RP 54
+# define LC 55
+# define RC 56
index 36fbc3c..802c6a1 100644 (file)
@@ -161,12 +161,12 @@ union ndu {
                int rall;
                TWORD type;
                int su;
                int rall;
                TWORD type;
                int su;
-               int stalign;  /* alignment of structure objects */
 #ifndef FLEXNAMES
                char name[NCHNAM];
 #else
                char *name;
 #endif
 #ifndef FLEXNAMES
                char name[NCHNAM];
 #else
                char *name;
 #endif
+               int stalign;  /* alignment of structure objects */
                NODE *left;
                NODE *right;
                }in; /* interior node */
                NODE *left;
                NODE *right;
                }in; /* interior node */
@@ -176,12 +176,12 @@ union ndu {
                int rall;
                TWORD type;
                int su;
                int rall;
                TWORD type;
                int su;
-               int stalign;  /* alignment of structure objects */
 #ifndef FLEXNAMES
                char name[NCHNAM];
 #else
                char *name;
 #endif
 #ifndef FLEXNAMES
                char name[NCHNAM];
 #else
                char *name;
 #endif
+               int stalign;  /* alignment of structure objects */
                CONSZ lval;
                int rval;
                }tn; /* terminal node */
                CONSZ lval;
                int rval;
                }tn; /* terminal node */
@@ -190,7 +190,6 @@ union ndu {
                int op, rall;
                TWORD type;
                int su;
                int op, rall;
                TWORD type;
                int su;
-               int stalign;  /* alignment of structure objects */
                int label;  /* for use with branching */
                }bn; /* branch node */
 
                int label;  /* for use with branching */
                }bn; /* branch node */
 
@@ -198,8 +197,8 @@ union ndu {
                int op, rall;
                TWORD type;
                int su;
                int op, rall;
                TWORD type;
                int su;
-               int stalign;  /* alignment of structure objects */
                int stsize;  /* sizes of structure objects */
                int stsize;  /* sizes of structure objects */
+               int stalign;  /* alignment of structure objects */
                }stn; /* structure node */
 
        };
                }stn; /* structure node */
 
        };
@@ -250,6 +249,9 @@ extern int lineno;
 extern char filename[];
 extern int fldshf, fldsz;
 extern int lflag, xdebug, udebug, edebug, odebug, rdebug, radebug, tdebug, sdebug;
 extern char filename[];
 extern int fldshf, fldsz;
 extern int lflag, xdebug, udebug, edebug, odebug, rdebug, radebug, tdebug, sdebug;
+#ifdef FORT
+extern int Oflag;
+#endif
 
 #ifndef callchk
 #define callchk(x) allchk()
 
 #ifndef callchk
 #define callchk(x) allchk()
index cbdb82c..8b573d3 100644 (file)
@@ -1,4 +1,7 @@
-static char *sccsid ="@(#)optim.c      4.2 (Berkeley) %G%";
+#ifndef lint
+static char *sccsid ="@(#)optim.c      4.3 (Berkeley) %G%";
+#endif lint
+
 # include "mfile1"
 
 # define SWAP(p,q) {sp=p; p=q; q=sp;}
 # include "mfile1"
 
 # define SWAP(p,q) {sp=p; p=q; q=sp;}
index 9817942..cfca367 100644 (file)
@@ -1,4 +1,7 @@
-static char *sccsid ="@(#)pftn.c       1.5 (Berkeley) %G%";
+#ifndef lint
+static char *sccsid ="@(#)pftn.c       1.6 (Berkeley) %G%";
+#endif lint
+
 # include "mfile1"
 
 unsigned int offsz;
 # include "mfile1"
 
 unsigned int offsz;
@@ -1013,6 +1016,7 @@ doinit( p ) register NODE *p; {
 
        register sz, d, s;
        register TWORD t;
 
        register sz, d, s;
        register TWORD t;
+       int o;
 
        /* note: size of an individual initializer is assumed to fit into an int */
 
 
        /* note: size of an individual initializer is assumed to fit into an int */
 
@@ -1061,18 +1065,22 @@ doinit( p ) register NODE *p; {
        p->in.left = p->in.right;
        p->in.right = NIL;
        p->in.left = optim( p->in.left );
        p->in.left = p->in.right;
        p->in.right = NIL;
        p->in.left = optim( p->in.left );
-       if( p->in.left->in.op == UNARY AND ){
-               p->in.left->in.op = FREE;
+       o = p->in.left->in.op;
+       if( o == UNARY AND ){
+               o = p->in.left->in.op = FREE;
                p->in.left = p->in.left->in.left;
                }
        p->in.op = INIT;
 
        if( sz < SZINT ){ /* special case: bit fields, etc. */
                p->in.left = p->in.left->in.left;
                }
        p->in.op = INIT;
 
        if( sz < SZINT ){ /* special case: bit fields, etc. */
-               if( p->in.left->in.op != ICON ) uerror( "illegal initialization" );
+               if( o != ICON ) uerror( "illegal initialization" );
                else incode( p->in.left, sz );
                }
                else incode( p->in.left, sz );
                }
-       else if( p->in.left->in.op == FCON ){
-               fincode( p->in.left->fpn.dval, sz );
+       else if( o == FCON ){
+               fincode( p->in.left->fpn.fval, sz );
+               }
+       else if( o == DCON ){
+               fincode( p->in.left->dpn.dval, sz );
                }
        else {
                p = optim(p);
                }
        else {
                p = optim(p);
index 98531d0..182706f 100644 (file)
@@ -1,4 +1,7 @@
-static char *sccsid ="@(#)reader.c     4.1 (Berkeley) %G%";
+#ifndef lint
+static char *sccsid ="@(#)reader.c     4.2 (Berkeley) %G%";
+#endif lint
+
 # include "mfile2"
 
 /*     some storage declarations */
 # include "mfile2"
 
 /*     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 );
                                        }
@@ -405,7 +417,7 @@ char *cnames[] = {
 # else
        "STARNM",
 # endif
 # else
        "STARNM",
 # endif
-# ifdef WCARD2"
+# ifdef WCARD2
        "WCARD2",
 # else
        "STARREG",
        "WCARD2",
 # else
        "STARREG",
@@ -597,7 +609,7 @@ 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;
                        }
 
                        goto again;
                        }
 
@@ -646,11 +658,11 @@ order(p,cook) NODE *p; {
                        p->in.op = FREE;
                        return;
                        }
                        p->in.op = FREE;
                        return;
                        }
-               offstar( p->in.left, cook );
+               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 +680,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 +704,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){
 
index a6ee87a..6489e43 100644 (file)
@@ -1,4 +1,7 @@
-static char *sccsid ="@(#)scan.c       1.4 (Berkeley) %G%";
+#ifndef lint
+static char *sccsid ="@(#)scan.c       1.5 (Berkeley) %G%";
+#endif lint
+
 # include "mfile1"
 # include <a.out.h>
 # include <stab.h>
 # include "mfile1"
 # include <a.out.h>
 # include <stab.h>
@@ -69,7 +72,8 @@ mainp1( argc, argv ) int argc; char *argv[]; {  /* control multiple files */
 
        register i;
        register char *cp;
 
        register i;
        register char *cp;
-       extern int idebug, bdebug, tdebug, edebug, ddebug, xdebug, gdebug;
+       extern int idebug, bdebug, tdebug, edebug;
+       extern int ddebug, xdebug, gdebug, adebug;
        extern unsigned int offsz;
        int fdef = 0;
        char *release = "PCC/364r1 vax uts3.0";
        extern unsigned int offsz;
        int fdef = 0;
        char *release = "PCC/364r1 vax uts3.0";
@@ -109,6 +113,9 @@ mainp1( argc, argv ) int argc; char *argv[]; {  /* control multiple files */
                                case 'g':
                                        ++gdebug;
                                        break;
                                case 'g':
                                        ++gdebug;
                                        break;
+                               case 'a':
+                                       ++adebug;
+                                       break;
                                case 'G':
                                        ++gdebug;
                                        oldway = 1;
                                case 'G':
                                        ++gdebug;
                                        oldway = 1;
@@ -999,11 +1006,13 @@ lxtitle(){
                for( c=getchar(); isdigit(c); c=getchar() ){
                        val = val*10+ c - '0';
                        }
                for( c=getchar(); isdigit(c); c=getchar() ){
                        val = val*10+ c - '0';
                        }
+               if( c == EOF )
+                       continue;
                ungetc( c, stdin );
                lineno = val;
                lxget( ' ', LEXWS );
                ungetc( c, stdin );
                lineno = val;
                lxget( ' ', LEXWS );
-               if( (c=getchar()) != '\n' ){
-                       for( cp=ftitle; c!='\n'; c=getchar(),++cp ){
+               if( (c=getchar()) != '\n' && c != EOF ){
+                       for( cp=ftitle; c!=EOF && c!='\n'; c=getchar(),++cp ){
                                *cp = c;
                                }
                        *cp = '\0';
                                *cp = c;
                                }
                        *cp = '\0';
index 3bef80f..37c60a4 100644 (file)
@@ -1,6 +1,14 @@
-static char *sccsid ="@(#)trees.c      4.5 (Berkeley) %G%";
+#ifndef lint
+static char *sccsid ="@(#)trees.c      4.6 (Berkeley) %G%";
+#endif
+
 # include "mfile1"
 
 # include "mfile1"
 
+int bdebug = 0;
+int adebug = 0;
+extern ddebug;
+extern eprint();
+
            /* corrections when in violation of lint */
 
 /*     some special actions, used in finding the type of nodes */
            /* corrections when in violation of lint */
 
 /*     some special actions, used in finding the type of nodes */
@@ -17,6 +25,46 @@ static char *sccsid ="@(#)trees.c    4.5 (Berkeley) %G%";
 # define OTHER 04000
 # define NCVTR 010000
 
 # define OTHER 04000
 # define NCVTR 010000
 
+#ifndef BUG1
+printact(t, acts)
+       NODE *t;
+       int acts;
+{
+       static struct actions {
+               int     a_bit;
+               char    *a_name;
+       } actions[] = {
+               { PUN,          "PUN" },
+               { CVTL,         "CVTL" },
+               { CVTR,         "CVTR" },
+               { TYPL,         "TYPL" },
+               { TYPR,         "TYPR" },
+               { TYMATCH,      "TYMATCH" },
+               { PTMATCH,      "PTMATCH" },
+               { LVAL,         "LVAL" },
+               { CVTO,         "CVTO" },
+               { NCVT,         "NCVT" },
+               { OTHER,        "OTHER" },
+               { NCVTR,        "NCVTR" },
+               { 0 }
+       };
+       register struct actions *p;
+       char *sep = " ";
+
+       printf("actions");
+       for (p = actions; p->a_name; p++)
+               if (p->a_bit & acts) {
+                       printf("%s%s", sep, p->a_name);
+                       sep = "|";
+               }
+       if (!bdebug) {
+               printf(" for:\n");
+               fwalk(t, eprint, 0);
+       } else
+               putchar('\n');
+}
+#endif
+
 /* node conventions:
 
        NAME:   rval>0 is stab index for external
 /* node conventions:
 
        NAME:   rval>0 is stab index for external
@@ -30,9 +78,6 @@ static char *sccsid ="@(#)trees.c     4.5 (Berkeley) %G%";
 
        */
 
 
        */
 
-int bdebug = 0;
-extern ddebug;
-
 NODE *
 buildtree( o, l, r ) register NODE *l, *r; {
        register NODE *p, *q;
 NODE *
 buildtree( o, l, r ) register NODE *l, *r; {
        register NODE *p, *q;
@@ -40,8 +85,8 @@ buildtree( o, l, r ) register NODE *l, *r; {
        register opty;
        register struct symtab *sp;
        register NODE *lr, *ll;
        register opty;
        register struct symtab *sp;
        register NODE *lr, *ll;
+       NODE *fixargs();
        int i;
        int i;
-       extern int eprint();
 
 # ifndef BUG1
        if( bdebug ) printf( "buildtree( %s, %o, %o )\n", opst[o], l, r );
 
 # ifndef BUG1
        if( bdebug ) printf( "buildtree( %s, %o, %o )\n", opst[o], l, r );
@@ -65,7 +110,12 @@ buildtree( o, l, r ) register NODE *l, *r; {
                }
 
        else if( o==UNARY MINUS && l->in.op==FCON ){
                }
 
        else if( o==UNARY MINUS && l->in.op==FCON ){
-               l->fpn.dval = -l->fpn.dval;
+               l->fpn.fval = -l->fpn.fval;
+               return(l);
+               }
+
+       else if( o==UNARY MINUS && l->in.op==DCON ){
+               l->dpn.dval = -l->dpn.dval;
                return(l);
                }
 
                return(l);
                }
 
@@ -122,46 +172,92 @@ buildtree( o, l, r ) register NODE *l, *r; {
                        break;
                        }
                }
                        break;
                        }
                }
+       else if (opty == BITYPE) {
+               if ((l->in.op == FCON || l->in.op == ICON) &&
+                   (r->in.op == FCON || r->in.op == ICON))
+                       switch (o) {
 
 
-       else if( opty == BITYPE && (l->in.op==FCON||l->in.op==ICON) &&
-               (r->in.op==FCON||r->in.op==ICON) ){
-               switch(o){
-               case PLUS:
-               case MINUS:
-               case MUL:
-               case DIV:
-                       if( l->in.op == ICON ){
-                               l->fpn.dval = l->tn.lval;
-                               }
-                       if( r->in.op == ICON ){
-                               r->fpn.dval = r->tn.lval;
+                       case PLUS:
+                       case MINUS:
+                       case MUL:
+                       case DIV:
+                               if (l->in.op == ICON)
+                                       l->fpn.fval = l->tn.lval;
+                               if (r->in.op == ICON)
+                                       r->fpn.fval = r->tn.lval;
+                               l->in.op = FCON;
+                               l->in.type = l->fn.csiz = FLOAT;
+                               r->in.op = FREE;
+                               switch (o) {
+
+                               case PLUS:
+                                       l->fpn.fval += r->fpn.fval;
+                                       return (l);
+
+                               case MINUS:
+                                       l->fpn.fval -= r->fpn.fval;
+                                       return (l);
+
+                               case MUL:
+                                       l->fpn.fval *= r->fpn.fval;
+                                       return (l);
+
+                               case DIV:
+                                       if (r->fpn.fval == 0)
+                                               uerror("division by 0.");
+                                       else
+                                               l->fpn.fval /= r->fpn.fval;
+                                       return (l);
                                }
                                }
-                       l->in.op = FCON;
-                       l->in.type = l->fn.csiz = DOUBLE;
-                       r->in.op = FREE;
-                       switch(o){
+                       }
+               else if ((l->in.op == DCON || l->in.op == ICON) &&
+                   (r->in.op == DCON || r->in.op == ICON))
+                       switch (o) {
+
                        case PLUS:
                        case PLUS:
-                               l->fpn.dval += r->fpn.dval;
-                               return(l);
                        case MINUS:
                        case MINUS:
-                               l->fpn.dval -= r->fpn.dval;
-                               return(l);
                        case MUL:
                        case MUL:
-                               l->fpn.dval *= r->fpn.dval;
-                               return(l);
                        case DIV:
                        case DIV:
-                               if( r->fpn.dval == 0 ) uerror( "division by 0." );
-                               else l->fpn.dval /= r->fpn.dval;
-                               return(l);
+                               if (l->in.op == ICON)
+                                       l->dpn.dval = l->tn.lval;
+                               if (r->in.op == ICON)
+                                       r->dpn.dval = r->tn.lval;
+                               l->in.op = DCON;
+                               l->in.type = l->fn.csiz = DOUBLE;
+                               r->in.op = FREE;
+                               switch (o) {
+
+                               case PLUS:
+                                       l->dpn.dval += r->dpn.dval;
+                                       return (l);
+
+                               case MINUS:
+                                       l->dpn.dval -= r->dpn.dval;
+                                       return (l);
+
+                               case MUL:
+                                       l->dpn.dval *= r->dpn.dval;
+                                       return (l);
+
+                               case DIV:
+                                       if (r->dpn.dval == 0)
+                                               uerror("division by 0.");
+                                       else
+                                               l->dpn.dval /= r->dpn.dval;
+                                       return (l);
                                }
                        }
                                }
                        }
-               }
+       }
 
        /* its real; we must make a new node */
 
        p = block( o, l, r, INT, 0, INT );
 
        actions = opact(p);
 
        /* its real; we must make a new node */
 
        p = block( o, l, r, INT, 0, INT );
 
        actions = opact(p);
+#ifndef        BUG1
+       if (adebug)
+               printact(p, actions);
+#endif
 
        if( actions&LVAL ){ /* check left descendent */
                if( notlval(p->in.left) ) {
 
        if( actions&LVAL ){ /* check left descendent */
                if( notlval(p->in.left) ) {
@@ -253,6 +349,14 @@ buildtree( o, l, r ) register NODE *l, *r; {
                        break;
 
                case FCON:
                        break;
 
                case FCON:
+                       p->tn.lval = 0;
+                       p->tn.rval = 0;
+                       p->in.type = FLOAT;
+                       p->fn.cdim = 0;
+                       p->fn.csiz = FLOAT;
+                       break;
+
+               case DCON:
                        p->tn.lval = 0;
                        p->tn.rval = 0;
                        p->in.type = DOUBLE;
                        p->tn.lval = 0;
                        p->tn.rval = 0;
                        p->in.type = DOUBLE;
@@ -442,7 +546,7 @@ buildtree( o, l, r ) register NODE *l, *r; {
                        break;
 
                case CALL:
                        break;
 
                case CALL:
-                       p->in.right = r = strargs( p->in.right );
+                       p->in.right = r = fixargs( p->in.right );
                case UNARY CALL:
                        if( !ISPTR(l->in.type)) uerror("illegal function");
                        p->in.type = DECREF(l->in.type);
                case UNARY CALL:
                        if( !ISPTR(l->in.type)) uerror("illegal function");
                        p->in.type = DECREF(l->in.type);
@@ -483,12 +587,19 @@ buildtree( o, l, r ) register NODE *l, *r; {
 
        }
 
 
        }
 
+/*
+ * Rewrite arguments in a function call.
+ * Structure arguments are massaged, single
+ * precision floating point constants are
+ * cast to double (to eliminate convert code).
+ */
 NODE *
 NODE *
-strargs( p ) register NODE *p;  { /* rewrite structure flavored arguments */
+fixargs( p ) register NODE *p;  {
+       int o = p->in.op;
 
 
-       if( p->in.op == CM ){
-               p->in.left = strargs( p->in.left );
-               p->in.right = strargs( p->in.right );
+       if( o == CM ){
+               p->in.left = fixargs( p->in.left );
+               p->in.right = fixargs( p->in.right );
                return( p );
                }
 
                return( p );
                }
 
@@ -497,6 +608,8 @@ strargs( p ) register NODE *p;  { /* rewrite structure flavored arguments */
                p->in.left = buildtree( UNARY AND, p->in.left, NIL );
                p = clocal(p);
                }
                p->in.left = buildtree( UNARY AND, p->in.left, NIL );
                p = clocal(p);
                }
+       else if( o == FCON )
+               p = makety(p, DOUBLE, 0, 0);
        return( p );
        }
 
        return( p );
        }
 
@@ -575,10 +688,12 @@ conval( p, o, q ) register NODE *p, *q; {
                break;
        case DIV:
                if( val == 0 ) uerror( "division by 0" );
                break;
        case DIV:
                if( val == 0 ) uerror( "division by 0" );
+               else if ( u ) p->tn.lval = (unsigned) p->tn.lval / val;
                else p->tn.lval /= val;
                break;
        case MOD:
                if( val == 0 ) uerror( "division by 0" );
                else p->tn.lval /= val;
                break;
        case MOD:
                if( val == 0 ) uerror( "division by 0" );
+               else if ( u ) p->tn.lval = (unsigned) p->tn.lval % val;
                else p->tn.lval %= val;
                break;
        case AND:
                else p->tn.lval %= val;
                break;
        case AND:
@@ -588,7 +703,7 @@ conval( p, o, q ) register NODE *p, *q; {
                p->tn.lval |= val;
                break;
        case ER:
                p->tn.lval |= val;
                break;
        case ER:
-               p->tn.lval ^=  val;
+               p->tn.lval ^= val;
                break;
        case LS:
                i = val;
                break;
        case LS:
                i = val;
@@ -596,7 +711,8 @@ conval( p, o, q ) register NODE *p, *q; {
                break;
        case RS:
                i = val;
                break;
        case RS:
                i = val;
-               p->tn.lval = p->tn.lval >> i;
+               if ( u ) p->tn.lval = (unsigned) p->tn.lval >> i;
+               else p->tn.lval = p->tn.lval >> i;
                break;
 
        case UNARY MINUS:
                break;
 
        case UNARY MINUS:
@@ -1009,7 +1125,15 @@ tymatch(p)  register NODE *p; {
        if( ( t1 == CHAR || t1 == SHORT ) && o!= RETURN ) t1 = INT;
        if( t2 == CHAR || t2 == SHORT ) t2 = INT;
 
        if( ( t1 == CHAR || t1 == SHORT ) && o!= RETURN ) t1 = INT;
        if( t2 == CHAR || t2 == SHORT ) t2 = INT;
 
-       if( t1==DOUBLE || t1==FLOAT || t2==DOUBLE || t2==FLOAT ) t = DOUBLE;
+#ifdef SPRECC
+       if( t1 == DOUBLE || t2 == DOUBLE )
+               t = DOUBLE;
+       else if( t1 == FLOAT || t2 == FLOAT )
+               t = FLOAT;
+#else
+       if (t1 == DOUBLE || t1 == FLOAT || t2 == DOUBLE || t2 == FLOAT)
+               t = DOUBLE;
+#endif
        else if( t1==LONG || t2==LONG ) t = LONG;
        else t = INT;
 
        else if( t1==LONG || t2==LONG ) t = LONG;
        else t = INT;
 
@@ -1065,19 +1189,49 @@ makety( p, t, d, s ) register NODE *p; TWORD t; {
                }
 
        if( p->in.op == ICON ){
                }
 
        if( p->in.op == ICON ){
-               if( t==DOUBLE||t==FLOAT ){
+               if (t == DOUBLE) {
+                       p->in.op = DCON;
+                       if (ISUNSIGNED(p->in.type))
+                               p->dpn.dval = /* (unsigned CONSZ) */ p->tn.lval;
+                       else
+                               p->dpn.dval = p->tn.lval;
+                       p->in.type = p->fn.csiz = t;
+                       return (clocal(p));
+               }
+               if (t == FLOAT) {
                        p->in.op = FCON;
                        if( ISUNSIGNED(p->in.type) ){
                        p->in.op = FCON;
                        if( ISUNSIGNED(p->in.type) ){
-                               p->fpn.dval = /* (unsigned CONSZ) */ p->tn.lval;
+                               p->fpn.fval = /* (unsigned CONSZ) */ p->tn.lval;
                                }
                        else {
                                }
                        else {
-                               p->fpn.dval = p->tn.lval;
+                               p->fpn.fval = p->tn.lval;
                                }
 
                        p->in.type = p->fn.csiz = t;
                        return( clocal(p) );
                        }
                }
                                }
 
                        p->in.type = p->fn.csiz = t;
                        return( clocal(p) );
                        }
                }
+       else if (p->in.op == FCON && t == DOUBLE) {
+               double db;
+
+               p->in.op = DCON;
+               db = p->fpn.fval;
+               p->dpn.dval = db;
+               p->in.type = p->fn.csiz = t;
+               return (clocal(p));
+       } else if (p->in.op == DCON && t == FLOAT) {
+               float fl;
+
+               p->in.op = FCON;
+               fl = p->dpn.dval;
+#ifdef notdef
+               if (fl != p->dpn.dval)
+                       werror("float conversion loses precision");
+#endif
+               p->fpn.fval = fl;
+               p->in.type = p->fn.csiz = t;
+               return (clocal(p));
+       }
 
        return( clocal( block( SCONV, p, NIL, t, d, s ) ) );
 
 
        return( clocal( block( SCONV, p, NIL, t, d, s ) ) );
 
@@ -1169,6 +1323,7 @@ opact( p )  NODE *p; {
        case STRING :
        case ICON :
        case FCON :
        case STRING :
        case ICON :
        case FCON :
+       case DCON :
        case CALL :
        case UNARY CALL:
        case UNARY MUL:
        case CALL :
        case UNARY CALL:
        case UNARY MUL:
@@ -1368,16 +1523,19 @@ eprint( p, down, a, b ) register NODE *p; int *a, *b; {
 # endif
 
 prtdcon( p ) register NODE *p; {
 # endif
 
 prtdcon( p ) register NODE *p; {
-       int i;
+       int o = p->in.op, i;
 
 
-       if( p->in.op == FCON ){
+       if( o == DCON || o == FCON ){
                locctr( DATA );
                locctr( DATA );
-               defalign( ALDOUBLE );
+               defalign( o == DCON ? ALDOUBLE : ALFLOAT );
                deflab( i = getlab() );
                deflab( i = getlab() );
-               fincode( p->fpn.dval, SZDOUBLE );
+               if( o == FCON )
+                       fincode( p->fpn.fval, SZFLOAT );
+               else
+                       fincode( p->dpn.dval, SZDOUBLE );
                p->tn.lval = 0;
                p->tn.rval = -i;
                p->tn.lval = 0;
                p->tn.rval = -i;
-               p->in.type = DOUBLE;
+               p->in.type = (o == DCON ? DOUBLE : FLOAT);
                p->in.op = NAME;
                }
        }
                p->in.op = NAME;
                }
        }
index 54971bc..411c674 100644 (file)
@@ -1,4 +1,7 @@
-static char *sccsid ="@(#)xdefs.c      4.1 (Berkeley) %G%";
+#ifndef lint
+static char *sccsid ="@(#)xdefs.c      4.2 (Berkeley) %G%";
+#endif lint
+
 # include "mfile1"
 
 /*     communication between lexical routines  */
 # include "mfile1"
 
 /*     communication between lexical routines  */
@@ -8,6 +11,7 @@ char   ititle[100] = "";       /* title of initial file */
 int    lineno;         /* line number of the input file */
 
 CONSZ lastcon;  /* the last constant read by the lexical analyzer */
 int    lineno;         /* line number of the input file */
 
 CONSZ lastcon;  /* the last constant read by the lexical analyzer */
+float fcon;   /* the last float read by the lexical analyzer */
 double dcon;   /* the last double read by the lexical analyzer */
 
 
 double dcon;   /* the last double read by the lexical analyzer */