changes to merge f2 and c2. Added -f flag to act as f2.
[unix-history] / usr / src / old / pcc / c2.vax / c20.c
index d1fbd47..eef1a77 100644 (file)
@@ -1,6 +1,7 @@
-#
-static char sccsid[] = "@(#)c20.c 4.3 %G%";
-/* char C20[] = {"@(#)c20.c 1.35 80/08/26 14:13:40"}; /* sccs ident */
+#ifndef lint
+static char sccsid[] = "@(#)c20.c      4.8 (Berkeley) %G%";
+#endif
+
 /*
  *      C object code improver
  */
 /*
  *      C object code improver
  */
@@ -11,6 +12,7 @@ static        char sccsid[] = "@(#)c20.c 4.3 %G%";
 
 char _sibuf[BUFSIZ], _sobuf[BUFSIZ];
 int ioflag;
 
 char _sibuf[BUFSIZ], _sobuf[BUFSIZ];
 int ioflag;
+int fflag;
 long   isn     = 2000000;
 struct optab *oplook();
 struct optab *getline();
 long   isn     = 2000000;
 struct optab *oplook();
 struct optab *getline();
@@ -48,20 +50,23 @@ char **argv;
        while (argc>0) {/* get flags */
                if (**argv=='+') debug++;
                else if (**argv=='-') {
        while (argc>0) {/* get flags */
                if (**argv=='+') debug++;
                else if (**argv=='-') {
-                       if ((*argv)[1]=='i') ioflag++; else nflag++;
+                       if ((*argv)[1]=='i') ioflag++;
+                       else if ((*argv)[1]=='f') fflag++;
+                       else nflag++;
                } else if (infound==0) {
                        if (freopen(*argv, "r", stdin) ==NULL) {
                                fprintf(stderr,"C2: can't find %s\n", *argv);
                                exit(1);
                        }
                } else if (infound==0) {
                        if (freopen(*argv, "r", stdin) ==NULL) {
                                fprintf(stderr,"C2: can't find %s\n", *argv);
                                exit(1);
                        }
-                       setbuf(stdin,_sibuf); ++infound;
+                       ++infound;
                } else if (freopen(*argv, "w", stdout) ==NULL) {
                        fprintf(stderr,"C2: can't create %s\n", *argv);
                        exit(1);
                }
                } else if (freopen(*argv, "w", stdout) ==NULL) {
                        fprintf(stderr,"C2: can't create %s\n", *argv);
                        exit(1);
                }
-               setbuf(stdout,_sobuf);
                argc--; argv++;
        }
                argc--; argv++;
        }
+       setbuf(stdin, _sibuf);
+       setbuf(stdout, _sobuf);
        lasta = lastr = sbrk(2);
        opsetup();
        lasta = firstr = lastr = alloc(0);
        lasta = lastr = sbrk(2);
        opsetup();
        lasta = firstr = lastr = alloc(0);
@@ -331,6 +336,26 @@ output()
                if (casebas==0) printf("L%d:\n",casebas=isn++);
                printf(".word   L%d-L%d\n", t->labno, casebas);
                continue;
                if (casebas==0) printf("L%d:\n",casebas=isn++);
                printf(".word   L%d-L%d\n", t->labno, casebas);
                continue;
+       case MOV:
+               if (!fflag) goto std;
+               if (t->forw) if(t->forw->op == CBR) goto std;
+               if (*t->code == '$') goto std;
+               if (t->subop == FFLOAT)
+                       {
+                       printf("movl\t%s\n", t->code);
+                       continue;
+                       }
+               if (t->subop == DFLOAT || t->subop == GFLOAT)
+                       {
+                       printf("movq\t%s\n", t->code);
+                       continue;
+                       }
+               if (t->subop == HFLOAT)
+                       {
+                       printf("movo\t%s\n", t->code);
+                       continue;
+                       }
+               goto std;
 
        }
 }
 
        }
 }
@@ -376,7 +401,7 @@ opsetup()
        register struct optab *optp, **ophp;
        register int i,t;
 
        register struct optab *optp, **ophp;
        register int i,t;
 
-       for(i=NREG+5;--i>=0;) regs[i]=alloc(20);
+       for(i=NREG+5;--i>=0;) regs[i]=alloc(C2_ASIZE);
        for (optp = optab; optp->opstring[0]; optp++) {
                t=7; i=0; while (--t>=0) i+= i+optp->opstring[t];
                ophp = &ophash[i % OPHS];
        for (optp = optab; optp->opstring[0]; optp++) {
                t=7; i=0; while (--t>=0) i+= i+optp->opstring[t];
                ophp = &ophash[i % OPHS];