Ansified lib/c2
authorNick Downing <downing.nick@gmail.com>
Fri, 3 Feb 2017 14:39:38 +0000 (01:39 +1100)
committerNick Downing <downing.nick@gmail.com>
Fri, 3 Feb 2017 14:39:38 +0000 (01:39 +1100)
lib/c2/c2.h
lib/c2/c20.c
lib/c2/c21.c
lib/c2/c22.c

index 2857121..dfe9c0b 100644 (file)
@@ -1,3 +1,6 @@
+#ifndef _C2_H_
+#define _C2_H_
+
 /*     c2.h    4.10    85/08/22        */
 
 /*
@@ -184,20 +187,20 @@ extern char       ccloc[C2_ASIZE];
 #define RT4 15
 #define        LABHS   127
 
-char *copy();
-long getnum();
-struct node *codemove();
-struct node *insertl();
-struct node *nonlab();
+/*char *copy();*/
+/*long getnum();*/
+/*struct node *codemove();*/
+/*struct node *insertl();*/
+/*struct node *nonlab();*/
 
 #ifdef notdef
 #define decref(p) \
        ((p) && --(p)->refc <= 0 ? nrlab++, delnode(p) : 0)
 #define delnode(p) \
        ((p)->back->forw = (p)->forw, (p)->forw->back = (p)->back)
-#endif notdef
+#endif
 
-char *xalloc();
+/*char *xalloc();*/
 extern char *newa;
 extern char *lasta;
 extern char *lastr;
@@ -208,3 +211,75 @@ extern char *lastr;
                 ((newa = lasta) + (n) > lastr ? \
                        xalloc(n) : \
                        (lasta += XALIGN(n), newa)))
+
+#ifndef __P
+#ifdef __STDC__
+#define __P(args) args
+#else
+#define __P(args) ()
+#endif
+#endif
+
+/* c20.c */
+char *xalloc __P((int n));
+int main __P((int argc, char **argv));
+int input __P((void));
+struct optab *getline __P((void));
+long getnum __P((register char *p));
+int locuse __P((register char *p));
+int locdef __P((register char *p));
+int output __P((void));
+char *copy __P((char *ap));
+int opsetup __P((void));
+struct optab *oplook __P((void));
+int refcount __P((void));
+int iterate __P((void));
+int xjump __P((register struct node *p1));
+struct node *insertl __P((register struct node *np));
+struct node *codemove __P((struct node *ap));
+int comjump __P((void));
+int backjmp __P((struct node *ap1, struct node *ap2));
+
+/* c21.c */
+int redun3 __P((register struct node *p, int split));
+int bmove __P((void));
+int rmove __P((void));
+char *byondrd __P((register struct node *p));
+struct node *bflow __P((register struct node *p));
+int ispow2 __P((register long n));
+int bitopt __P((register struct node *p));
+int isfield __P((register long n));
+int bixprep __P((register struct node *p, int bix));
+struct node *bicopt __P((register struct node *p));
+int jumpsw __P((void));
+int addsob __P((void));
+int equop __P((register struct node *p1, struct node *p2));
+int XXXdelnode __P((register struct node *p));
+int XXXdecref __P((register struct node *p));
+struct node *nonlab __P((struct node *ap));
+int clearuse __P((void));
+int clearreg __P((void));
+int savereg __P((int ai, register char *s, int type));
+int dest __P((register char *s, int type));
+int splitrand __P((struct node *p));
+int compat __P((int have, int want));
+int equtype __P((int t1, int t2));
+int findrand __P((char *as, int type));
+int isreg __P((register char *s));
+int check __P((void));
+int source __P((char *ap));
+int newcode __P((struct node *p));
+int repladdr __P((struct node *p));
+int redunbr __P((register struct node *p));
+char *findcon __P((int i, int type));
+int compare __P((int opc, char *acp1, char *acp2));
+int setcon __P((register char *cv, register char *cl, int type));
+int equstr __P((register char *p1, register char *p2));
+int setcc __P((char *ap, int type));
+int okio __P((register char *p));
+int indexa __P((register char *p));
+int natural __P((register char *p));
+int isstatic __P((register char *cp));
+int autoid __P((register char *p));
+
+#endif
index e13af5a..4ceff0a 100644 (file)
@@ -1,4 +1,10 @@
-#ifndef lint
+/*#include <ctype.h> gen.h*/
+#include <gen.h>
+#include <stdio.h>
+/*#include <strings.h> gen.h*/
+#include "c2.h"
+
+#if defined(DOSCCS) && !defined(lint)
 static char sccsid[] = "@(#)c20.c      4.10 (Berkeley) 8/22/85";
 #endif
 
@@ -6,10 +12,10 @@ static       char sccsid[] = "@(#)c20.c      4.10 (Berkeley) 8/22/85";
  *      C object code improver
  */
 
-#include "c2.h"
-#include <stdio.h>
-#include <ctype.h>
-#include <sys/types.h>
+/*#include "c2.h"*/
+/*#include <stdio.h>*/
+/*#include <ctype.h>*/
+/*#include <sys/types.h>*/
 
 /* moved here from c2.h which now just declares them extern */
 char   line[512];
@@ -40,7 +46,7 @@ char  conloc[C2_ASIZE];
 char   conval[C2_ASIZE];
 char   ccloc[C2_ASIZE];
 
-char *malloc();
+/*char *malloc();*/
 char firstr[sizeof (char *)];
 char *currentb;
 char *newa;
@@ -53,8 +59,8 @@ int fflag;
 
 long   isn     = 2000000;
 
-struct optab *oplook();
-struct optab *getline();
+/*struct optab *oplook();*/
+/*struct optab *getline();*/
 
 long lgensym[10] =
   {100000L,200000L,300000L,400000L,500000L,600000L,700000L,800000L,900000L,1000000L};
@@ -66,10 +72,7 @@ long lgensym[10] =
  * and doesn't clash with stdio.  Assumes that no one requests more than
  * ALLOCSIZE bytes at a time.
  */
-char *
-xalloc(n)
-int n;
-{
+char *xalloc(n) int n; {
        register char *nextb = * (char **) currentb;
 
        if (n == 0) {   /* Free everything */
@@ -93,9 +96,7 @@ int n;
        return(newa);
 }
 
-main(argc, argv)
-char **argv;
-{
+int main(argc, argv) int argc; char **argv; {
        register int niter, maxiter, isend;
        int nflag,infound;
 
@@ -165,8 +166,7 @@ char **argv;
        fflush(stdout); exit(0);
 }
 
-input()
-{
+int input() {
        register struct node *p, *lastp;
        struct optab *opp; register char *cp1;
        static struct optab F77JSW = {".long", T(JSW,1)};
@@ -284,9 +284,7 @@ input()
        }
 }
 
-struct optab *
-getline()
-{
+struct optab *getline() {
        register char *lp;
        register c;
        static struct optab OPLABEL={"",LABEL};
@@ -310,10 +308,7 @@ getline()
        return(&OPEND);
 }
 
-long
-getnum(p)
-register char *p;
-{
+long getnum(p) register char *p; {
        register c; int neg; register long n;
 
        n = 0; neg=0; if (*p=='-') {++neg; ++p;}
@@ -325,23 +320,18 @@ register char *p;
        return(n);
 }
 
-locuse(p)
-register char *p;
-{
+int locuse(p) register char *p; {
        if (!isdigit(p[0]) || p[1] != 'f' && p[1] != 'b' || p[2]) return(0);
        return (lgensym[p[0] - '0'] - (p[1] == 'b'));
 }
 
-locdef(p)
-register char *p;
-{
+int locdef(p) register char *p; {
 
        if (!isdigit(p[0]) || p[1]) return(0);
        return (lgensym[p[0] - '0']++);
 }
 
-output()
-{
+int output() {
        register struct node *t;
        int casebas;
 
@@ -393,18 +383,15 @@ output()
                if (!fflag) goto std;
                if (t->forw) if(t->forw->op == CBR) goto std;
                if (*t->code == '$') goto std;
-               if (t->subop == FFLOAT)
-                       {
+               if (t->subop == FFLOAT) {
                        printf("movl\t%s\n", t->code);
                        continue;
                        }
-               if (t->subop == DFLOAT || t->subop == GFLOAT)
-                       {
+               if (t->subop == DFLOAT || t->subop == GFLOAT) {
                        printf("movq\t%s\n", t->code);
                        continue;
                        }
-               if (t->subop == HFLOAT)
-                       {
+               if (t->subop == HFLOAT) {
                        printf("movo\t%s\n", t->code);
                        continue;
                        }
@@ -413,10 +400,7 @@ output()
        }
 }
 
-char *
-copy(ap)
-char *ap;
-{
+char *copy(ap) char *ap; {
 #if 1 /* in this application there is never more than one argument */
        int len;
        char *strcpy();
@@ -457,8 +441,7 @@ char *ap;
 #define        OPHS    560
 struct optab *ophash[OPHS];
 
-opsetup()
-{
+int opsetup() {
        register struct optab *optp, **ophp;
        register int i,t;
 
@@ -477,9 +460,7 @@ opsetup()
        }
 }
 
-struct optab *
-oplook()
-{
+struct optab *oplook() {
        register struct optab *optp,**ophp;
        register char *p,*p2;
        register int t;
@@ -497,8 +478,7 @@ oplook()
        return(&OPNULL);
 }
 
-refcount()
-{
+int refcount() {
        register struct node *p, *lp, *tp;
        struct node *labhash[LABHS];
        register struct node **hp;
@@ -538,8 +518,7 @@ refcount()
                        decref(p);
 }
 
-iterate()
-{
+int iterate() {
        register struct node *p, *rp, *p1;
 
        nchange = 0;
@@ -612,9 +591,7 @@ iterate()
        }
 }
 
-xjump(p1)
-register struct node *p1;
-{
+int xjump(p1) register struct node *p1; {
        register struct node *p2, *p3;
 
        if ((p2 = p1->ref)==0)
@@ -635,10 +612,7 @@ register struct node *p1;
        }
 }
 
-struct node *
-insertl(np)
-register struct node *np;
-{
+struct node *insertl(np) register struct node *np; {
        register struct node *lp;
 
        if (np->op == LABEL) {
@@ -663,10 +637,7 @@ register struct node *np;
        return(lp);
 }
 
-struct node *
-codemove(ap)
-struct node *ap;
-{
+struct node *codemove(ap) struct node *ap; {
        register struct node *p1, *p2, *p3;
        struct node *t, *tl;
        int n;
@@ -750,8 +721,7 @@ ivloop:
        return(p3);
 }
 
-comjump()
-{
+int comjump() {
        register struct node *p1, *p2, *p3;
 
        for (p1 = first.forw; p1!=0; p1 = p1->forw)
@@ -762,9 +732,7 @@ comjump()
                                        backjmp(p1, p3);
 }
 
-backjmp(ap1, ap2)
-struct node *ap1, *ap2;
-{
+int backjmp(ap1, ap2) struct node *ap1; struct node *ap2; {
        register struct node *p1, *p2, *p3;
 
        p1 = ap1;
index 99cac69..2df7ec1 100644 (file)
@@ -1,4 +1,10 @@
-#ifndef lint
+/*#include <ctype.h> gen.h*/
+#include <gen.h>
+#include <stdio.h>
+/*#include <strings.h> gen.h*/
+#include "c2.h"
+
+#if defined(DOSCCS) && !defined(lint)
 static char sccsid[] = "@(#)c21.c 4.19 4/27/86";
 #endif
 /* char C21[] = {"@(#)c21.c 1.83 80/10/16 21:18:22 JFR"}; /* sccs ident */
@@ -7,9 +13,9 @@ static char sccsid[] = "@(#)c21.c 4.19 4/27/86";
  * C object code improver-- second part
  */
 
-#include "c2.h"
-#include <stdio.h>
-#include <ctype.h>
+/*#include "c2.h"*/
+/*#include <stdio.h>*/
+/*#include <ctype.h>*/
 
 #define NUSE 6
 int ioflag;
@@ -33,12 +39,12 @@ int bitsize[] = {   /* index by type codes */
 int pos,siz; long f; /* for bit field communication */
 struct node *uses[NUSE]; /* for backwards flow analysis */
 char *lastrand; /* last operand of instruction */
-struct node *bflow();
-struct node *bicopt();
-char *findcon();
-char *strcpy();
+/*struct node *bflow();*/
+/*struct node *bicopt();*/
+/*char *findcon();*/
+/*char *strcpy();*/
 
-redun3(p,split) register struct node *p; int split; {
+int redun3(p, split) register struct node *p; int split; {
 /* check for 3 addr instr which should be 2 addr */
        if (OP3==((p->subop>>4)&0xF)) {
                if (split) splitrand(p);
@@ -53,7 +59,7 @@ redun3(p,split) register struct node *p; int split; {
        } return(0);
 }
 
-bmove() {
+int bmove() {
        register struct node *p, *lastp; register char *cp1,*cp2; register int r;
        refcount();
        for (p=lastp= &first; 0!=(p=p->forw); lastp=p);
@@ -103,8 +109,7 @@ bmove() {
        case ADD:
                if ((p->subop&0xF)!=LONG) goto std; cp1=p->code;
                if (*cp1++!='$') goto std; splitrand(p);
-               if (isstatic(cp1) && (r=isreg(regs[RT2]))>=0 && r<NUSE && uses[r]==p->forw)
-               {
+               if (isstatic(cp1) && (r=isreg(regs[RT2]))>=0 && r<NUSE && uses[r]==p->forw) {
                        /* address comp:
                        **      addl2   $_foo,r0  \     movab   _foo[r0],bar
                        **      movl    r0,bar    /
@@ -112,13 +117,11 @@ bmove() {
                        register struct node    *pnext = p->forw;
                        char    buf[C2_ASIZE];
 
-                       if (pnext->op == MOV && pnext->subop == LONG)
-                       {
+                       if (pnext->op == MOV && pnext->subop == LONG) {
                                cp1 = &regs[RT1][1]; cp2 = &buf[0];
                                while (*cp2++ = *cp1++) ; cp2--;
                                splitrand(pnext);
-                               if (r == isreg(regs[RT1]))
-                               {
+                               if (r == isreg(regs[RT1])) {
                                        delnode(p); p = pnext;
                                        p->op = MOVA; p->subop = BYTE;
                                        p->pop = 0;
@@ -143,8 +146,7 @@ bmove() {
        case CASE:
        default: std:
                p=bflow(p); break;
-       case MUL:
-       {
+       case MUL: {
                /*
                ** Change multiplication by constant powers of 2 to
                **      shifts.
@@ -152,38 +154,31 @@ bmove() {
                splitrand(p);
                if (regs[RT1][0] != '$' || regs[RT1][1] == '-') goto std;
                if ((r = ispow2(getnum(&regs[RT1][1]))) < 0) goto std;
-               switch (r)
-               {
+               switch (r) {
                case 0:         /* mull3 $1,x,y */
-                       if (p->subop == U(LONG,OP3))
-                       {
-                               if (equstr(regs[RT2], regs[RT3]))
-                               {
+                       if (p->subop == U(LONG,OP3)) {
+                               if (equstr(regs[RT2], regs[RT3])) {
                                        delnode(p); p = p->forw;
                                }
-                               else
-                               {
+                               else {
                                        p->op = MOV; p->subop = LONG;
                                        p->pop = 0; newcode(p); nchange++;
                                }
                        }
                        else
-                       if (p->subop == U(LONG,OP2))
-                       {
+                       if (p->subop == U(LONG,OP2)) {
                                delnode(p); p = p->forw;
                        }
                        goto std;
 
                case 1:         /* mull2 $2,x */
-                       if (p->subop == U(LONG, OP2) && !source(regs[RT2]))
-                       {
+                       if (p->subop == U(LONG, OP2) && !source(regs[RT2])) {
                                strcpy(regs[RT1], regs[RT2]);
                                p->op = ADD; p->pop = 0; newcode(p); nchange++;
                        }
                        goto std;
                }
-               if(p->subop==U(LONG,OP3)||(p->subop==U(LONG,OP2)&&!source(regs[RT2])))
-               {
+               if(p->subop==U(LONG,OP3)||(p->subop==U(LONG,OP2)&&!source(regs[RT2]))) {
                        if (p->subop == U(LONG,OP2))
                                strcpy(regs[RT3], regs[RT2]);
                        sprintf(regs[RT1], "$%d", r);
@@ -192,8 +187,7 @@ bmove() {
                }
                goto std;
        }
-       case ASH:
-       {
+       case ASH: {
                /* address comp:
                **      ashl    $1,bar,r0  \    movl    bar,r0
                **      movab   _foo[r0]   /    movaw   _foo[r0]
@@ -211,8 +205,7 @@ bmove() {
                if ((shcnt = getnum(&regs[RT1][1])) < 1 || shcnt > 3) goto std;
                if ((shfrom = isreg(regs[RT2])) >= 0)
                        regfrom = copy(regs[RT2]);
-               if ((shto = isreg(regs[RT3])) >= 0 && shto<NUSE)
-               {
+               if ((shto = isreg(regs[RT3])) >= 0 && shto<NUSE) {
                        int     regnum;
 
                        if (uses[shto] != (pf = p->forw)) goto ashadd;
@@ -225,17 +218,14 @@ bmove() {
                        while (*cp2++ != '[') ;
                        if (*cp2++ != 'r' || !isdigit(*cp2)) goto std;
                        regnum = *cp2++ - '0';
-                       if (isdigit(*cp2))
-                       {
+                       if (isdigit(*cp2)) {
                                if (cp2[1] != ']') goto std;
                                regnum *= 10; regnum += *cp2 - '0';
                        }
                        if (regnum != shto) goto std;
-                       if (shfrom >= 0)        /* ashl $N,r*,r0 */
-                       {
+                       if (shfrom >= 0)        /* ashl $N,r*,r0 */ {
                                delnode(p);
-                               if (shfrom != shto)
-                               {
+                               if (shfrom != shto) {
                                        uses[shto] = NULL; splitrand(pf);
                                        cp2=regs[RT1]; while (*cp2++!='[');
                                        cp1=regfrom; while (*cp2++= *cp1++);
@@ -244,16 +234,14 @@ bmove() {
                                        newcode(pf);
                                }
                        }
-                       else
-                       {
+                       else {
                                p->op = MOV; splitrand(p);
                                strcpy(regs[RT1], regs[RT2]);
                                strcpy(regs[RT2], regs[RT3]);
                                regs[RT3][0] = '\0';
                                p->pop = 0; newcode(p);
                        }
-                       switch (shcnt)
-                       {
+                       switch (shcnt) {
                        case 1: pf->subop = WORD; break;
                        case 2: pf->subop = LONG; break;
                        case 3: pf->subop = QUAD; break;
@@ -263,8 +251,7 @@ bmove() {
                }
 ashadd:
                /* at this point, RT2 and RT3 are guaranteed to be simple regs*/
-               if (shcnt == 1 && equstr(regs[RT2], regs[RT3]))
-               {
+               if (shcnt == 1 && equstr(regs[RT2], regs[RT3])) {
                        /*
                        ** quickie:
                        **      ashl    $1,A,A  >       addl2   A,A
@@ -277,8 +264,7 @@ ashadd:
        }
 
        case EXTV:
-       case EXTZV:
-       {
+       case EXTZV: {
                /* bit tests:
                **      extv    A,$1,B,rC  \
                **      tstl    rC          >   jbc     A,B,D
@@ -297,8 +283,7 @@ ashadd:
                splitrand(p);
                if (regs[RT2][0] != '$') goto std;
                if ((flen = getnum(&regs[RT2][1])) < 0) goto std;
-               if (flen == 1)
-               {
+               if (flen == 1) {
                        register int    extreg;         /* reg extracted to */
 
                        extreg = isreg(regs[RT4]);
@@ -318,8 +303,7 @@ ashadd:
                        uses[extreg] = NULL;
                }
                else
-               if (flen == 8 || flen == 16)
-               {
+               if (flen == 8 || flen == 16) {
                        register int    boff;   /* bit offset */
                        register int    coff;   /* chunk (byte or word) offset*/
 
@@ -345,8 +329,7 @@ ashadd:
                goto std;
        }
 
-       case CMP:
-       {
+       case CMP: {
                /* comparison to -63 to -1:
                **      cmpl    r0,$-1  >       incl    r0
                **      jeql    ...
@@ -365,8 +348,7 @@ ashadd:
                reg = r = isreg(regs[RT1]);
                if (r < 0) goto std;
                if (r < NUSE && uses[r] != 0) goto std;
-               if (r >= NUSE && regp->op == MOV && p->subop == regp->subop)
-               {
+               if (r >= NUSE && regp->op == MOV && p->subop == regp->subop) {
                        if (*regp->code != 'r') goto std;
                        reg = regp->code[1] - '0';
                        if (isdigit(regp->code[2]) || reg >= NUSE || uses[reg])
@@ -376,12 +358,10 @@ ashadd:
                if (reg != r)
                        sprintf(regs[RT1], "r%d", reg);
                if ((num = getnum(&regs[RT2][2])) <= 0 || num > 63) goto std;
-               if (num == 1)
-               {
+               if (num == 1) {
                        p->op = INC; regs[RT2][0] = '\0';
                }
-               else
-               {
+               else {
                        register char   *t;
 
                        t=regs[RT1];regs[RT1]=regs[RT2];regs[RT2]=t;
@@ -412,8 +392,7 @@ ashadd:
                if (p->op==LABEL || p->op==DLABEL) p->ref=0;    /* erase our tracks */
 }
 
-rmove()
-{
+int rmove() {
        register struct node *p;
        register int r;
        int r1;
@@ -551,8 +530,7 @@ mov:
        }
 }
 
-char *
-byondrd(p) register struct node *p; {
+char *byondrd(p) register struct node *p; {
 /* return pointer to register which is "beyond last read/modify operand" */
        if (OP2==(p->subop>>4)) return(regs[RT3]);
        switch (p->op) {
@@ -568,10 +546,7 @@ byondrd(p) register struct node *p; {
        return(lastrand);
 }
 
-struct node *
-bflow(p)
-register struct node *p;
-{
+struct node *bflow(p) register struct node *p; {
        register char *cp1,*cp2,**preg; register int r;
        int flow= -1;
        struct node *olduse=0;
@@ -733,13 +708,13 @@ register struct node *p;
        return(p);
 }
 
-ispow2(n) register long n; {/* -1 -> no; else -> log to base 2 */
+int ispow2(n) register long n; {/* -1 -> no; else -> log to base 2 */
        register int log;
        if (n==0 || n&(n-1)) return(-1); log=0;
        for (;;) {n >>= 1; if (n==0) return(log); ++log; if (n== -1) return(log);}
 }
 
-bitopt(p) register struct node *p; {
+int bitopt(p) register struct node *p; {
        /* change "bitx $<power_of_2>,a" followed by JEQ or JNE
        /* into JBC or JBS.  watch out for I/O registers. (?)
        /* assumes that 'splitrand' has already been called.
@@ -779,7 +754,7 @@ bitopt(p) register struct node *p; {
        p->pop=0;
 }
 
-isfield(n) register long n; {/* -1 -> no; else -> position of low bit */
+int isfield(n) register long n; {/* -1 -> no; else -> position of low bit */
        register int p; register long t;
        t= ((n-1)|n) +1;
        if (n!=0 && (0==t || 0<=ispow2(t))) {
@@ -787,7 +762,7 @@ isfield(n) register long n; {/* -1 -> no; else -> position of low bit */
        } else return(-1);
 }
 
-bixprep(p,bix) register struct node *p; {
+int bixprep(p, bix) register struct node *p; int bix; {
 /* initial setup, single-bit checking for bisopt, bicopt.
 /* return: 0->don't bother any more; 1->worthwhile trying
 */
@@ -807,9 +782,7 @@ bixprep(p,bix) register struct node *p; {
        return(1);
 }
 
-
-struct node *
-bicopt(p) register struct node *p; {
+struct node *bicopt(p) register struct node *p; {
 /* use field operations or MOVZ if possible.  done as part of 'bflow'.
 */
        register char *cp1,*cp2; int r;
@@ -886,8 +859,7 @@ bicopt(p) register struct node *p; {
        return(p);
 }
 
-jumpsw()
-{
+int jumpsw() {
        register struct node *p, *p1;
        register struct node *tp;
        long tl;
@@ -927,8 +899,7 @@ jumpsw()
        return(nj);
 }
 
-addsob()
-{
+int addsob() {
        register struct node *p, *p1, *p2, *p3;
 
        for (p = &first; (p1 = p->forw)!=0; p = p1) {
@@ -978,10 +949,7 @@ addsob()
        }
 }
 
-equop(p1, p2)
-register struct node *p1;
-struct node *p2;
-{
+int equop(p1, p2) register struct node *p1; struct node *p2; {
        register char *cp1, *cp2;
 
        if (p1->combop != p2->combop)
@@ -1010,16 +978,14 @@ struct node *p2;
 }
 
 #ifndef delnode
-XXXdelnode(p) register struct node *p; {
+int XXXdelnode(p) register struct node *p; {
        p->back->forw = p->forw;
        p->forw->back = p->back;
 }
 #endif
 
 #ifndef decref
-XXXdecref(p)
-register struct node *p;
-{
+int XXXdecref(p) register struct node *p; {
        if (p && --p->refc <= 0) {
                nrlab++;
                delnode(p);
@@ -1027,10 +993,7 @@ register struct node *p;
 }
 #endif
 
-struct node *
-nonlab(ap)
-struct node *ap;
-{
+struct node *nonlab(ap) struct node *ap; {
        register struct node *p;
 
        p = ap;
@@ -1039,12 +1002,12 @@ struct node *ap;
        return(p);
 }
 
-clearuse() {
+int clearuse() {
        register struct node **i;
        for (i=uses+NUSE; i>uses;) *--i=0;
 }
 
-clearreg() {
+int clearreg() {
        register char **i;
        for (i=regs; i<regs+NREG; ++i) {
                **i = 0;
@@ -1054,9 +1017,7 @@ clearreg() {
        ccloc[0] = 0;
 }
 
-savereg(ai, s, type)
-register char *s;
-{
+int savereg(ai, s, type) int ai; register char *s; int type; {
        register char *p, *sp;
 
        sp = p = regs[ai];
@@ -1069,9 +1030,7 @@ register char *s;
                if (*s=='[' || *s++=='(' && *s!='a' && *s!='f') {*sp = 0; return;}
 }
 
-dest(s,type)
-register char *s;
-{
+int dest(s, type) register char *s; int type; {
        register int i;
 
        (void) source(s); /* handle addressing side effects */
@@ -1122,7 +1081,7 @@ register char *s;
 }
 
 /* separate operands at commas, set up 'regs' and 'lastrand' */
-splitrand(p) struct node *p; {
+int splitrand(p) struct node *p; {
        register char *p1, *p2;
        register char **preg;
 
@@ -1141,7 +1100,7 @@ splitrand(p) struct node *p; {
                *(*preg++) = 0;
 }
 
-compat(have, want) {
+int compat(have, want) int have; int want; {
 register int hsrc, hdst;
 if (0==(want &= 0xF)) return(1); /* anything satisfies a wildcard want */
 hsrc=have&0xF;
@@ -1151,11 +1110,9 @@ if (want>=FFLOAT) return(hdst==want && hsrc==want);
 return(hsrc>=want && hdst>=want && hdst<FFLOAT);
 }
 
-equtype(t1,t2) {return(compat(t1,t2) && compat(t2,t1));}
+int equtype(t1, t2) int t1; int t2; {return(compat(t1,t2) && compat(t2,t1));}
 
-findrand(as, type)
-char *as;
-{
+int findrand(as, type) char *as; int type; {
        register char **i;
        for (i = regs+NREG; --i>=regs;) {
                if (**i && equstr(*i+1, as) && compat(**i,type))
@@ -1164,17 +1121,14 @@ char *as;
        return(-1);
 }
 
-isreg(s)
-register char *s;
-{
+int isreg(s) register char *s; {
        if (*s++!='r' || !isdigit(*s++)) return(-1);
        if (*s==0) return(*--s-'0');
        if (*(s-1)=='1' && isdigit(*s++) && *s==0) return(10+*--s-'0');
        return(-1);
 }
 
-check()
-{
+int check() {
        register struct node *p, *lp;
 
        lp = &first;
@@ -1187,9 +1141,7 @@ check()
        }
 }
 
-source(ap)
-char *ap;
-{
+int source(ap) char *ap; {
        register char *p1, *p2;
 
        p1 = ap;
@@ -1213,7 +1165,7 @@ char *ap;
        return(0);
 }
 
-newcode(p) struct node *p; {
+int newcode(p) struct node *p; {
        register char *p1,*p2,**preg;
        preg=regs+RT1; p2=line;
        while (*(p1= *preg++)) {while (*p2++= *p1++); *(p2-1)=',';}
@@ -1221,9 +1173,7 @@ newcode(p) struct node *p; {
        p->code=copy(line);
 }
 
-repladdr(p)
-struct node *p;
-{
+int repladdr(p) struct node *p; {
        register r;
        register char *p1;
        char **preg; int nrepl;
@@ -1286,9 +1236,7 @@ struct node *p;
 /* }
 */
 
-redunbr(p)
-register struct node *p;
-{
+int redunbr(p) register struct node *p; {
        register struct node *p1;
        register char *ap1;
        char *ap2;
@@ -1327,9 +1275,7 @@ register struct node *p;
        }
 }
 
-char *
-findcon(i, type)
-{
+char *findcon(i, type) int i; int type; {
        register char *p;
        register r;
 
@@ -1343,9 +1289,7 @@ findcon(i, type)
        return(p);
 }
 
-compare(opc, acp1, acp2)
-char *acp1, *acp2;
-{
+int compare(opc, acp1, acp2) int opc; char *acp1; char *acp2; {
        register char *cp1, *cp2;
        register n1;
        int n2; int sign;
@@ -1393,9 +1337,7 @@ char *acp1, *acp2;
        return(0);
 }
 
-setcon(cv, cl, type)
-register char *cv, *cl;
-{
+int setcon(cv, cl, type) register char *cv; register char *cl; int type; {
        register char *p;
 
        if (*cv != '$')
@@ -1409,9 +1351,7 @@ register char *cv, *cl;
        while (*p++ = *cv++);
 }
 
-equstr(p1, p2)
-register char *p1, *p2;
-{
+int equstr(p1, p2) register char *p1; register char *p2; {
        do {
                if (*p1++ != *p2)
                        return(0);
@@ -1419,9 +1359,7 @@ register char *p1, *p2;
        return(1);
 }
 
-setcc(ap,type)
-char *ap;
-{
+int setcc(ap, type) char *ap; int type; {
        register char *p, *p1;
 
        p = ap;
@@ -1434,19 +1372,17 @@ char *ap;
        while (*p1++ = *p++);
 }
 
-okio(p) register char *p; {/* 0->probable I/O space address; 1->not */
+int okio(p) register char *p; {/* 0->probable I/O space address; 1->not */
        if (ioflag && (!natural(p) || 0>getnum(p))) return(0);
        return(1);
 }
 
-indexa(p) register char *p; {/* 1-> uses [r] addressing mode; 0->doesn't */
+int indexa(p) register char *p; {/* 1-> uses [r] addressing mode; 0->doesn't */
        while (*p) if (*p++=='[') return(1);
        return(0);
 }
 
-natural(p)
-register char *p;
-{/* 1->simple local, parameter, global, or register; 0->otherwise */
+int natural(p) register char *p; {/* 1->simple local, parameter, global, or register; 0->otherwise */
        if (*p=='*' || *p=='(' || *p=='-'&&p[1]=='(' || *p=='$'&&getnum(p+1))
                return(0);
        while (*p++);
@@ -1460,15 +1396,13 @@ register char *p;
 ** Tell if an argument is most likely static.
 */
 
-isstatic(cp)
-register char  *cp;
-{
+int isstatic(cp) register char *cp; {
        if (*cp == '_' || *cp == 'L' || (*cp++ == 'v' && *cp == '.'))
                return (1);
        return (0);
 }
 
-autoid(p) register char *p; {/* 1-> uses autoincrement/autodecrement; 0->doesn't */
+int autoid(p) register char *p; {/* 1-> uses autoincrement/autodecrement; 0->doesn't */
        if (*p == '-' && *(p+1) == '(') return(1);
        while (*p) p++;
        if (*--p == '+' && *--p == ')') return(1);
index ac41797..f4bf834 100644 (file)
@@ -1,8 +1,10 @@
-#ifndef lint
+#include "c2.h"
+
+#if defined(DOSCCS) && !defined(lint)
 static char sccsid[] = "@(#)c22.c 4.3 3/19/85";
 #endif
 
-#include "c2.h"
+/*#include "c2.h"*/
 
 char revbr[] = {
        JNE, JEQ, JGT, JLT, JGE, JLE,