update from monet: check number of arguments in pattern calls
authorSam Leffler <sam@ucbvax.Berkeley.EDU>
Tue, 25 Feb 1986 14:27:19 +0000 (06:27 -0800)
committerSam Leffler <sam@ucbvax.Berkeley.EDU>
Tue, 25 Feb 1986 14:27:19 +0000 (06:27 -0800)
SCCS-vsn: sys/tahoe/inline/Makefile 1.2
SCCS-vsn: sys/tahoe/inline/inline.h 1.2
SCCS-vsn: sys/tahoe/inline/langpats.c 1.3
SCCS-vsn: sys/tahoe/inline/libcpats.c 1.3
SCCS-vsn: sys/tahoe/inline/machdep.c 1.3
SCCS-vsn: sys/tahoe/inline/machpats.c 1.3
SCCS-vsn: sys/tahoe/inline/main.c 1.3

usr/src/sys/tahoe/inline/Makefile
usr/src/sys/tahoe/inline/inline.h
usr/src/sys/tahoe/inline/langpats.c
usr/src/sys/tahoe/inline/libcpats.c
usr/src/sys/tahoe/inline/machdep.c
usr/src/sys/tahoe/inline/machpats.c
usr/src/sys/tahoe/inline/main.c

index c40f35c..a8c71bb 100644 (file)
@@ -33,7 +33,7 @@ ${OBJS}:
        cc ${CFLAGS} ${INCPATH} -c $*.c
 
 install: ${PROG}
        cc ${CFLAGS} ${INCPATH} -c $*.c
 
 install: ${PROG}
-       install ${PROG} ../inline
+#      install ${PROG} ../inline
 
 clean:
        rm -f a.out core ${OBJS} ${PROG}
 
 clean:
        rm -f a.out core ${OBJS} ${PROG}
index 7824d40..eda58b3 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)inline.h    1.3 (Berkeley) 6/8/85
+ *     @(#)inline.h    1.2 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -52,6 +52,7 @@ char line[QUEUESIZE][MAXLINELEN];
  * These tables specify the substitutions that are to be done.
  */
 struct pats {
  * These tables specify the substitutions that are to be done.
  */
 struct pats {
+       int     args;
        char    *name;
        char    *replace;
        struct  pats *next;
        char    *name;
        char    *replace;
        struct  pats *next;
index 63bf289..9b0c37f 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)langpats.c 1.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)langpats.c 1.3 (Berkeley) %G%";
 #endif
 
 #include "inline.h"
 #endif
 
 #include "inline.h"
@@ -16,331 +16,97 @@ static char sccsid[] = "@(#)langpats.c     1.2 (Berkeley) %G%";
  */
 struct pats language_ptab[] = {
 
  */
 struct pats language_ptab[] = {
 
-#if defined(vax)
-       { "0,_spl0\n",
-"      mfpr    $18,r0\n\
-       mtpr    $0,$18\n" },
-
-       { "0,_spl1\n",
-"      mfpr    $18,r0\n\
-       mtpr    $1,$18\n" },
-
-       { "0,_splsoftclock\n",
-"      mfpr    $18,r0\n\
-       mtpr    $0x8,$18\n" },
-
-       { "0,_splnet\n",
-"      mfpr    $18,r0\n\
-       mtpr    $0xc,$18\n" },
-
-       { "0,_splimp\n",
-"      mfpr    $18,r0\n\
-       mtpr    $0x16,$18\n" },
-
-       { "0,_spl4\n",
-"      mfpr    $18,r0\n\
-       mtpr    $0x14,$18\n" },
-
-       { "0,_splbio\n",
-"      mfpr    $18,r0\n\
-       mtpr    $0x15,$18\n" },
-
-       { "0,_spltty\n",
-"      mfpr    $18,r0\n\
-       mtpr    $0x15,$18\n" },
-
-       { "0,_spl5\n",
-"      mfpr    $18,r0\n\
-       mtpr    $0x15,$18\n" },
-
-       { "0,_splclock\n",
-"      mfpr    $18,r0\n\
-       mtpr    $0x18,$18\n" },
-
-       { "0,_spl6\n",
-"      mfpr    $18,r0\n\
-       mtpr    $0x18,$18\n" },
-
-       { "0,_splhigh\n",
-"      mfpr    $18,r0\n\
-       mtpr    $0x1f,$18\n" },
-
-       { "0,_spl7\n",
-"      mfpr    $18,r0\n\
-       mtpr    $0x1f,$18\n" },
-
-       { "1,_splx\n",
-"      movl    (sp)+,r1\n\
-       mfpr    $18,r0\n\
-       mtpr    r1,$18\n" },
-
-       { "1,_mfpr\n",
-"      movl    (sp)+,r5\n\
-       mfpr    r5,r0\n" },
-
-       { "2,_mtpr\n",
-"      movl    (sp)+,r4\n\
-       movl    (sp)+,r5\n\
-       mtpr    r5,r4\n" },
-
-       { "0,_setsoftclock\n",
-"      mtpr    $0x8,$0x14\n" },
-
-       { "1,_resume\n",
-"      movl    (sp)+,r5\n\
-       ashl    $9,r5,r0\n\
-       movpsl  -(sp)\n\
-       jsb     _Resume\n" },
-
-       { "3,_copyin\n",
-"      movl    (sp)+,r1\n\
-       movl    (sp)+,r3\n\
-       movl    (sp)+,r5\n\
-       jsb     _Copyin\n" },
-
-       { "3,_copyout\n",
-"      movl    (sp)+,r1\n\
-       movl    (sp)+,r3\n\
-       movl    (sp)+,r5\n\
-       jsb     _Copyout\n" },
-
-       { "1,_fubyte\n",
-"      movl    (sp)+,r0\n\
-       jsb     _Fubyte\n" },
-
-       { "1,_fuibyte\n",
-"      movl    (sp)+,r0\n\
-       jsb     _Fubyte\n" },
-
-       { "1,_fuword\n",
-"      movl    (sp)+,r0\n\
-       jsb     _Fuword\n" },
-
-       { "1,_fuiword\n",
-"      movl    (sp)+,r0\n\
-       jsb     _Fuword\n" },
-
-       { "2,_subyte\n",
-"      movl    (sp)+,r0\n\
-       movl    (sp)+,r1\n\
-       jsb     _Subyte\n" },
-
-       { "2,_suibyte\n",
-"      movl    (sp)+,r0\n\
-       movl    (sp)+,r1\n\
-       jsb     _Subyte\n" },
-
-       { "2,_suword\n",
-"      movl    (sp)+,r0\n\
-       movl    (sp)+,r1\n\
-       jsb     _Suword\n" },
-
-       { "2,_suiword\n",
-"      movl    (sp)+,r0\n\
-       movl    (sp)+,r1\n\
-       jsb     _Suword\n" },
-
-       { "1,_setrq\n",
-"      movl    (sp)+,r0\n\
-       jsb     _Setrq\n" },
-
-       { "1,_remrq\n",
-"      movl    (sp)+,r0\n\
-       jsb     _Remrq\n" },
-
-       { "0,_swtch\n",
-"      movpsl  -(sp)\n\
-       jsb     _Swtch\n" },
-
-       { "1,_setjmp\n",
-"      movl    (sp)+,r1\n\
-       clrl    r0\n\
-       movl    fp,(r1)+\n\
-       moval   1(pc),(r1)\n" },
-
-       { "1,_longjmp\n",
-"      movl    (sp)+,r0\n\
-       jsb     _Longjmp\n" },
-
-       { "1,_ffs\n",
-"      movl    (sp)+,r1\n\
-       ffs     $0,$32,r1,r0\n\
-       bneq    1f\n\
-       mnegl   $1,r0\n\
-1:\n\
-       incl    r0\n" },
-
-       { "1,_htons\n",
-"      movl    (sp)+,r5\n\
-       rotl    $8,r5,r0\n\
-       rotl    $-8,r5,r1\n\
-       movb    r1,r0\n\
-       movzwl  r0,r0\n" },
-
-       { "1,_ntohs\n",
-"      movl    (sp)+,r5\n\
-       rotl    $8,r5,r0\n\
-       rotl    $-8,r5,r1\n\
-       movb    r1,r0\n\
-       movzwl  r0,r0\n" },
-
-       { "1,_htonl\n",
-"      movl    (sp)+,r5\n\
-       rotl    $-8,r5,r0\n\
-       insv    r0,$16,$8,r0\n\
-       rotl    $8,r5,r1\n\
-       movb    r1,r0\n" },
-
-       { "1,_ntohl\n",
-"      movl    (sp)+,r5\n\
-       rotl    $-8,r5,r0\n\
-       insv    r0,$16,$8,r0\n\
-       rotl    $8,r5,r1\n\
-       movb    r1,r0\n" },
-
-       { "2,__insque\n",
-"      movl    (sp)+,r4\n\
-       movl    (sp)+,r5\n\
-       insque  (r4),(r5)\n" },
-
-       { "1,__remque\n",
-"      movl    (sp)+,r5\n\
-       remque  (r5),r0\n" },
-
-       { "2,__queue\n",
-"      movl    (sp)+,r0\n\
-       movl    (sp)+,r1\n\
-       insque  (r1),*4(r0)\n" },
-
-       { "1,__dequeue\n",
-"      movl    (sp)+,r0\n\
-       remque  *(r0),r0\n" },
-
-       { "2,_imin\n",
-"      movl    (sp)+,r0\n\
-       movl    (sp)+,r5\n\
-       cmpl    r0,r5\n\
-       bleq    1f\n\
-       movl    r5,r0\n\
-1:\n" },
-
-       { "2,_imax\n",
-"      movl    (sp)+,r0\n\
-       movl    (sp)+,r5\n\
-       cmpl    r0,r5\n\
-       bgeq    1f\n\
-       movl    r5,r0\n\
-1:\n" },
-
-       { "2,_min\n",
-"      movl    (sp)+,r0\n\
-       movl    (sp)+,r5\n\
-       cmpl    r0,r5\n\
-       blequ   1f\n\
-       movl    r5,r0\n\
-1:\n" },
-
-       { "2,_max\n",
-"      movl    (sp)+,r0\n\
-       movl    (sp)+,r5\n\
-       cmpl    r0,r5\n\
-       bgequ   1f\n\
-       movl    r5,r0\n\
-1:\n" },
-#endif
-
-#if defined(tahoe)
-       { "4,_spl0\n",
+       { 0, "_spl0\n",
 "      mfpr    $8,r0\n\
        mtpr    $0,$8\n" },
 
 "      mfpr    $8,r0\n\
        mtpr    $0,$8\n" },
 
-       { "4,_spl1\n",
+       { 0, "_spl1\n",
 "      mfpr    $8,r0\n\
        mtpr    $0x11,$8\n" },
 
 "      mfpr    $8,r0\n\
        mtpr    $0x11,$8\n" },
 
-       { "4,_spl3\n",
+       { 0, "_spl3\n",
 "      mfpr    $8,r0\n\
        mtpr    $0x13,$8\n" },
 
 "      mfpr    $8,r0\n\
        mtpr    $0x13,$8\n" },
 
-       { "4,_spl7\n",
+       { 0, "_spl7\n",
 "      mfpr    $8,r0\n\
        mtpr    $0x17,$8\n" },
 
 "      mfpr    $8,r0\n\
        mtpr    $0x17,$8\n" },
 
-       { "4,_spl8\n",
+       { 0, "_spl8\n",
 "      mfpr    $8,r0\n\
        mtpr    $0x18,$8\n" },
 
 "      mfpr    $8,r0\n\
        mtpr    $0x18,$8\n" },
 
-       { "4,_splimp\n",
+       { 0, "_splimp\n",
 "      mfpr    $8,r0\n\
        mtpr    $0x18,$8\n" },
 
 "      mfpr    $8,r0\n\
        mtpr    $0x18,$8\n" },
 
-       { "4,_splsoftclock\n",
+       { 0, "_splsoftclock\n",
 "      mfpr    $18,r0\n\
        mtpr    $0x8,$8\n" },
 
 "      mfpr    $18,r0\n\
        mtpr    $0x8,$8\n" },
 
-       { "4,_splnet\n",
+       { 0, "_splnet\n",
 "      mfpr    $8,r0\n\
        mtpr    $0xc,$8\n" },
 
 "      mfpr    $8,r0\n\
        mtpr    $0xc,$8\n" },
 
-       { "4,_splbio\n",
+       { 0, "_splbio\n",
 "      mfpr    $8,r0\n\
        mtpr    $0x18,$8\n" },
 
 "      mfpr    $8,r0\n\
        mtpr    $0x18,$8\n" },
 
-       { "4,_spltty\n",
+       { 0, "_spltty\n",
 "      mfpr    $8,r0\n\
        mtpr    $0x18,$8\n" },
 
 "      mfpr    $8,r0\n\
        mtpr    $0x18,$8\n" },
 
-       { "4,_splclock\n",
+       { 0, "_splclock\n",
 "      mfpr    $8,r0\n\
        mtpr    $0x18,$8\n" },
 
 "      mfpr    $8,r0\n\
        mtpr    $0x18,$8\n" },
 
-       { "4,_splhigh\n",
+       { 0, "_splhigh\n",
 "      mfpr    $8,r0\n\
        mtpr    $0x18,$8\n" },
 
 "      mfpr    $8,r0\n\
        mtpr    $0x18,$8\n" },
 
-       { "8,_splx\n",
+       { 1, "_splx\n",
 "      movl    (sp)+,r1\n\
        mfpr    $8,r0\n\
        mtpr    r1,$8\n" },
 
 "      movl    (sp)+,r1\n\
        mfpr    $8,r0\n\
        mtpr    r1,$8\n" },
 
-       { "8,_mfpr\n",
+       { 1, "_mfpr\n",
 "      movl    (sp)+,r1\n\
        mfpr    r1,r0\n" },
 
 "      movl    (sp)+,r1\n\
        mfpr    r1,r0\n" },
 
-       { "12,_mtpr\n",
+       { 2, "_mtpr\n",
 "      movl    (sp)+,r1\n\
        movl    (sp)+,r0\n\
        mtpr    r0,r1\n" },
 
 #ifdef notdef
 "      movl    (sp)+,r1\n\
        movl    (sp)+,r0\n\
        mtpr    r0,r1\n" },
 
 #ifdef notdef
-       { "8,_uncache\n",
+       { 1, "_uncache\n",
 "      movl    (sp)+,r1\n\
        mtpr    r1,$0x1c\n" },
 #endif
 
 "      movl    (sp)+,r1\n\
        mtpr    r1,$0x1c\n" },
 #endif
 
-       { "4,_setsoftclock\n",
+       { 0, "_setsoftclock\n",
 "      mtpr    $0x8,$0x10\n" },
 
 "      mtpr    $0x8,$0x10\n" },
 
-       { "8,_fuibyte\n",
+       { 1, "_fuibyte\n",
 "      callf   $8,_fubyte\n" },
 
 "      callf   $8,_fubyte\n" },
 
-       { "8,_fuiword\n",
+       { 1, "_fuiword\n",
 "      callf   $8,_fuword\n" },
 
 "      callf   $8,_fuword\n" },
 
-       { "12,_suibyte\n",
+       { 2, "_suibyte\n",
 "      callf   $12,_subyte\n" },
 
 "      callf   $12,_subyte\n" },
 
-       { "12,_suiword\n",
+       { 2, "_suiword\n",
 "      callf   $12,_suword\n" },
 
 "      callf   $12,_suword\n" },
 
-       { "8,_setjmp\n",
+       { 1, "_setjmp\n",
 "      movl    (sp)+,r1\n\
        clrl    r0\n\
        movab   (fp),(r1)\n\
        addl2   $4,r1\n\
        movab   1(pc),(r1)\n" },
 
 "      movl    (sp)+,r1\n\
        clrl    r0\n\
        movab   (fp),(r1)\n\
        addl2   $4,r1\n\
        movab   1(pc),(r1)\n" },
 
-       { "8,_ffs\n",
+       { 1, "_ffs\n",
 "      movl    (sp)+,r1\n\
        ffs     r1,r0\n\
        bgeq    1f\n\
 "      movl    (sp)+,r1\n\
        ffs     r1,r0\n\
        bgeq    1f\n\
@@ -348,16 +114,16 @@ struct pats language_ptab[] = {
 1:\n\
        incl    r0\n" },
 
 1:\n\
        incl    r0\n" },
 
-       { "12,__insque\n",
+       { 2, "__insque\n",
 "      movl    (sp)+,r0\n\
        movl    (sp)+,r1\n\
        insque  (r0),(r1)\n" },
 
 "      movl    (sp)+,r0\n\
        movl    (sp)+,r1\n\
        insque  (r0),(r1)\n" },
 
-       { "8,__remque\n",
+       { 1, "__remque\n",
 "      movl    (sp)+,r1\n\
        remque  (r1)\n" },
 
 "      movl    (sp)+,r1\n\
        remque  (r1)\n" },
 
-       { "12,_imin\n",
+       { 2, "_imin\n",
 "      movl    (sp)+,r0\n\
        movl    (sp)+,r1\n\
        cmpl    r0,r1\n\
 "      movl    (sp)+,r0\n\
        movl    (sp)+,r1\n\
        cmpl    r0,r1\n\
@@ -365,7 +131,7 @@ struct pats language_ptab[] = {
        movl    r1,r0\n\
 1:\n" },
 
        movl    r1,r0\n\
 1:\n" },
 
-       { "12,_imax\n",
+       { 2, "_imax\n",
 "      movl    (sp)+,r0\n\
        movl    (sp)+,r1\n\
        cmpl    r0,r1\n\
 "      movl    (sp)+,r0\n\
        movl    (sp)+,r1\n\
        cmpl    r0,r1\n\
@@ -373,7 +139,7 @@ struct pats language_ptab[] = {
        movl    r1,r0\n\
 1:\n" },
 
        movl    r1,r0\n\
 1:\n" },
 
-       { "12,_min\n",
+       { 2, "_min\n",
 "      movl    (sp)+,r0\n\
        movl    (sp)+,r1\n\
        cmpl    r0,r1\n\
 "      movl    (sp)+,r0\n\
        movl    (sp)+,r1\n\
        cmpl    r0,r1\n\
@@ -381,7 +147,7 @@ struct pats language_ptab[] = {
        movl    r1,r0\n\
 1:\n" },
 
        movl    r1,r0\n\
 1:\n" },
 
-       { "12,_max\n",
+       { 2, "_max\n",
 "      movl    (sp)+,r0\n\
        movl    (sp)+,r1\n\
        cmpl    r0,r1\n\
 "      movl    (sp)+,r0\n\
        movl    (sp)+,r1\n\
        cmpl    r0,r1\n\
@@ -389,20 +155,15 @@ struct pats language_ptab[] = {
        movl    r1,r0\n\
 1:\n" },
 
        movl    r1,r0\n\
 1:\n" },
 
-       { "12,__movow\n",
+       { 2, "__movow\n",
 "      movl    (sp)+,r1\n\
        movl    (sp)+,r0\n\
        movow   r0,(r1)\n" },
 
 "      movl    (sp)+,r1\n\
        movl    (sp)+,r0\n\
        movow   r0,(r1)\n" },
 
-       { "12,__movob\n",
+       { 2, "__movob\n",
 "      movl    (sp)+,r1\n\
        movl    (sp)+,r0\n\
        movob   r0,(r1)\n" },
 "      movl    (sp)+,r1\n\
        movl    (sp)+,r0\n\
        movob   r0,(r1)\n" },
-#endif
-
-#if defined(mc68000)
-/* someday... */
-#endif
 
 
-       { "", "" }
+       { 0, "", "" }
 };
 };
index 218e0c5..5a628b2 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)libcpats.c 1.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)libcpats.c 1.3 (Berkeley) %G%";
 #endif
 
 #include "inline.h"
 #endif
 
 #include "inline.h"
@@ -15,39 +15,5 @@ static char sccsid[] = "@(#)libcpats.c       1.2 (Berkeley) %G%";
  */
 struct pats libc_ptab[] = {
 
  */
 struct pats libc_ptab[] = {
 
-#if defined(vax)
-       { "1,_fgetc\n",
-"      sobgeq  *(sp),1f\n\
-       calls   $1,__filbuf\n\
-       jbr     2f\n\
-1:\n\
-       addl3   $4,(sp)+,r1\n\
-       movzbl  *(r1),r0\n\
-       incl    (r1)\n\
-2:\n" },
-
-       { "2,_fputc\n",
-"      sobgeq  *4(sp),1f\n\
-       calls   $2,__flsbuf\n\
-       jbr     2f\n\
-1:\n\
-       movq    (sp)+,r0\n\
-       movb    r0,*4(r1)\n\
-       incl    4(r1)\n\
-2:\n" },
-
-       { "1,_strlen\n",
-"      movl    (sp)+,r5\n\
-       movl    r5,r1\n\
-1:\n\
-       locc    $0,$65535,(r1)\n\
-       jeql    1b\n\
-       subl3   r5,r1,r0\n" },
-#endif
-
-#if defined(mc68000)
-/* someday... */
-#endif
-
-       { "", "" }
+       { 0, "", "" }
 };
 };
index 572d258..8a2eb2b 100644 (file)
@@ -5,75 +5,22 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)machdep.c  1.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)machdep.c  1.3 (Berkeley) %G%";
 #endif
 
 #include <stdio.h>
 #include <ctype.h>
 #include "inline.h"
 
 #endif
 
 #include <stdio.h>
 #include <ctype.h>
 #include "inline.h"
 
+extern char *strcpy();
+extern char *strcat();
+extern char *index();
+
 /*
  * The routines and tables in this file must be rewritten
  * for each new machine that this program is ported to.
  */
 
 /*
  * The routines and tables in this file must be rewritten
  * for each new machine that this program is ported to.
  */
 
-#if defined(vax)
-/*
- * Instruction stop table.
- * All instructions that implicitly modify any of the temporary
- * registers, change control flow, or implicitly loop must be
- * listed in this table. It is used to find the end of a basic
- * block when scanning backwards through the instruction stream
- * trying to merge the inline expansion.
- */
-struct inststoptbl inststoptable[] = {
-       { "jbc" }, { "jlbc" }, { "jbs" }, { "jlbs" }, { "jbcc" },
-       { "jbsc" }, { "jbcs" }, { "jbss" }, { "jbr" }, { "jcc" },
-       { "jcs" }, { "jvc" }, { "jvs" }, { "jlss" }, { "jlssu" },
-       { "jleq" }, { "jlequ" }, { "jeql" }, { "jeqlu" }, { "jneq" },
-       { "jnequ" }, { "jgeq" }, { "jgequ" }, { "jgtr" }, { "jgtru" },
-       { "chmk" }, { "chme" }, { "chms" }, { "chmu" }, { "rei" },
-       { "ldpctx" }, { "svpctx" }, { "xfc" }, { "bpt" },
-       { "bugw" }, { "bugl" }, { "halt" }, { "pushr" }, { "popr" },
-       { "polyf" }, { "polyd" }, { "polyg" }, { "polyh" },
-       { "bneq" }, { "bnequ" }, { "beql" }, { "beqlu" }, { "bgtr" },
-       { "bleq" }, { "bgeq" }, { "blss" }, { "bgtru" }, { "blequ" },
-       { "bvc" }, { "bvs" }, { "bgequ" }, { "bcc" }, { "blssu" },
-       { "bcs" }, { "brb" }, { "brw" }, { "jmp" },
-       { "bbs" }, { "bbc" }, { "bbss" }, { "bbcs" }, { "bbsc" },
-       { "bbcc" }, { "bbssi" }, { "bbcci" }, { "blbs" }, { "blbc" },
-       { "acbb" }, { "acbw" }, { "acbl" }, { "acbf" }, { "acbd" },
-       { "acbg" }, { "acbh" }, { "aoblss" }, { "aobleq" },
-       { "sobgeq" }, { "sobgtr" }, { "caseb" }, { "casew" }, { "casel" },
-       { "bsbb" }, { "bsbw" }, { "jsb" }, { "rsb" },
-       { "callg" }, { "calls" }, { "ret" },
-       { "movc3" }, { "movc5" }, { "movtc" }, { "movtuc" },
-       { "cmpc3" }, { "cmpc5" }, { "scanc" }, { "spanc" },
-       { "locc" }, { "skpc" }, { "matchc" }, { "crc" },
-       { "movp" }, { "cmpp3" }, { "cmpp4" }, { "addp4" }, { "addp6" },
-       { "subp4" }, { "subp6" }, { "mulp" }, { "divp" }, { "cvtlp" },
-       { "cvtpl" }, { "cvtpt" }, { "cvttp" }, { "cvtps" }, { "cvtsp" },
-       { "ashp" }, { "editpc" },
-       { "escd" }, { "esce" }, { "escf" },
-       { "" }
-};
-
-/*
- * Check to see if a line is a candidate for replacement.
- * Return pointer to name to be looked up in pattern table.
- */
-char *
-doreplaceon(cp)
-       char *cp;
-{
-
-       if (bcmp(cp, "calls\t$", 7) == 0)
-               return (cp + 7);
-       return (0);
-}
-#endif
-
-#if defined(tahoe)
 /*
  * Instruction stop table.
  * All instructions that implicitly modify any of the temporary
 /*
  * Instruction stop table.
  * All instructions that implicitly modify any of the temporary
@@ -118,13 +65,29 @@ doreplaceon(cp)
        char *cp;
 {
 
        char *cp;
 {
 
-       if (bcmp(cp, "callf\t$", 7) == 0)
-               return (cp + 7);
-       return (0);
+       if (bcmp(cp, "callf\t", 6))
+               return (0);
+       if ((cp = index(cp + 6, ',')) == 0)
+               return (0);
+       return (++cp);
+}
+
+/*
+ * Find out how many arguments the function is being called with.
+ * A return value of -1 indicates that the count can't be determined.
+ */
+countargs(cp)
+       char *cp;
+{
+       int i;
+
+       if ((cp = index(cp, '$')) == 0)
+               return (-1);
+       if (!isdigit(*++cp) || (i = atoi(cp)) == -1)
+               return (-1);
+       return (i/4 - 1);
 }
 }
-#endif
 
 
-#if defined(vax) || defined(tahoe)
 /*
  * Find the next argument to the function being expanded.
  */
 /*
  * Find the next argument to the function being expanded.
  */
@@ -170,7 +133,7 @@ modifies(argc, argv)
        register char *lastarg = argv[argc - 1];
 
        /*
        register char *lastarg = argv[argc - 1];
 
        /*
-        * For the VAX or TAHOE all we care about are r0 to r5
+        * For the tahoe all we care about are r0 to r5
         */
        if (lastarg[0] == 'r' && isdigit(lastarg[1]) && lastarg[2] == '\0')
                return (lastarg[1] - '0');
         */
        if (lastarg[0] == 'r' && isdigit(lastarg[1]) && lastarg[2] == '\0')
                return (lastarg[1] - '0');
@@ -237,176 +200,4 @@ cleanup(numargs)
        int numargs;
 {
 
        int numargs;
 {
 
-       return;
-}
-#endif
-
-#if defined(mc68000)
-/*
- * Instruction stop table.
- * All instructions that implicitly modify any of the temporary
- * registers, change control flow, or implicitly loop must be
- * listed in this table. It is used to find the end of a basic
- * block when scanning backwards through the instruction stream
- * trying to merge the inline expansion.
- */
-struct inststoptbl inststoptable[] = {
-       { "" }
-};
-
-/*
- * Check to see if a line is a candidate for replacement.
- * Return pointer to name to be looked up in pattern table.
- */
-char *
-doreplaceon(cp)
-       char *cp;
-{
-
-       if (bcmp(cp, "jbsr\t", 5) == 0)
-               return (cp + 5);
-       return (0);
-}
-
-/*
- * Find the next argument to the function being expanded.
- */
-nextarg(argc, argv)
-       int argc;
-       char *argv[];
-{
-       register char *lastarg = argv[2];
-
-       if (argc == 3 &&
-           bcmp(argv[0], "movl", 5) == 0 &&
-           bcmp(argv[1], "sp@+", 5) == 0 &&
-           (lastarg[1] == '0' || lastarg[1] == '1') &&
-           lastarg[2] == '\0') {
-               if (lastarg[0] == 'd')
-                       return (lastarg[1] - '0');
-               return (lastarg[1] - '0' + 8);
-       }
-       return (-1);
 }
 }
-
-/*
- * Determine whether the current line pushes an argument.
- */
- ispusharg(argc, argv)
-       int argc;
-       char *argv[];
-{
-
-       if (argc < 2)
-               return (0);
-       if (argc == 2 && bcmp(argv[0], "pea", 4) == 0)
-               return (1);
-       if (bcmp(argv[argc - 1], "sp@-", 5) == 0)
-               return (1);
-       return (0);
-}
-
-/*
- * Determine which (if any) registers are modified
- * Return register number that is modified, -1 if none are modified.
- */
-modifies(argc, argv)
-       int argc;
-       char *argv[];
-{
-       /*
-        * For the MC68000 all we care about are d0, d1, a0, and a1.
-        */
-       register char *lastarg = argv[argc - 1];
-
-       if (lastarg[0] == 'd' && isdigit(lastarg[1]) && lastarg[2] == '\0')
-               return (lastarg[1] - '0');
-       if (lastarg[0] == 'a' && isdigit(lastarg[1]) && lastarg[2] == '\0')
-               return (lastarg[1] - '0' + 8);
-       return (-1);
-}
-
-/*
- * Rewrite the instruction in (argc, argv) to store its
- * contents into arg instead of onto the stack. The new
- * instruction is placed in the buffer that is provided.
- */
-rewrite(instbuf, argc, argv, target)
-       char *instbuf;
-       int argc;
-       char *argv[];
-       int target;
-{
-       int regno;
-       char regtype;
-
-       if (target < 8) {
-               regtype = 'd';
-               regno = target;
-       } else {
-               regtype = 'a';
-               regno = target - 8;
-       }
-       switch (argc) {
-       case 0:
-               instbuf[0] = '\0';
-               fprintf(stderr, "blank line to rewrite?\n");
-               return;
-       case 1:
-               sprintf(instbuf, "\t%s\n", argv[0]);
-               fprintf(stderr, "rewrite?-> %s", instbuf);
-               return;
-       case 2:
-               if (bcmp(argv[0], "pea", 4) == 0) {
-                       if (regtype == 'a') {
-                               sprintf(instbuf, "\tlea\t%s,%c%d\n",
-                                       argv[1], regtype, regno);
-                               return;
-                       }
-                       if (argv[1][0] == '_' || isdigit(argv[1][0])) {
-                               sprintf(instbuf, "\tmovl\t#%s,%c%d\n",
-                                       argv[1], regtype, regno);
-                               return;
-                       }
-                       sprintf(instbuf,
-                               "\texg\ta0,d%d\n\tlea\t%s,a0\n\texg\ta0,d%d\n",
-                               regno, argv[1], regno);
-                       return;
-               }
-               sprintf(instbuf, "\t%s\t%c%d\n", argv[0], regtype, regno);
-               return;
-       case 3:
-               sprintf(instbuf, "\t%s\t%s,%c%d\n",
-                       argv[0], argv[1], regtype, regno);
-               return;
-       default:
-               sprintf(instbuf, "\t%s\t%s", argv[0], argv[1]);
-               argc -= 2, argv += 2;
-               while (argc-- > 0) {
-                       strcat(instbuf, ",");
-                       strcat(instbuf, *argv++);
-               }
-               strcat(instbuf, "\n");
-               fprintf(stderr, "rewrite?-> %s", instbuf);
-               return;
-       }
-}
-
-/*
- * Do any necessary post expansion cleanup.
- */
-cleanup(numargs)
-       int numargs;
-{
-       
-       if (numargs == 0)
-               return;
-       /*
-        * delete instruction to pop arguments.
-        * TODO:
-        *      CHECK FOR LABEL
-        *      CHECK THAT INSTRUCTION IS A POP
-        */
-       fgets(line[bufhead], MAXLINELEN, stdin);
-}
-#endif
index 482c598..25ef095 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)machpats.c 1.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)machpats.c 1.3 (Berkeley) %G%";
 #endif
 
 #include "inline.h"
 #endif
 
 #include "inline.h"
@@ -15,133 +15,19 @@ static char sccsid[] = "@(#)machpats.c     1.2 (Berkeley) %G%";
  */
 struct pats machine_ptab[] = {
 
  */
 struct pats machine_ptab[] = {
 
-#if defined(vax)
-       { "3,_blkcpy\n",
-"      movl    (sp)+,r1\n\
-       movl    (sp)+,r3\n\
-       jbr     2f\n\
-1:\n\
-       subl2   r0,(sp)\n\
-       movc3   r0,(r1),(r3)\n\
-2:\n\
-       movzwl  $65535,r0\n\
-       cmpl    (sp),r0\n\
-       jgtr    1b\n\
-       movl    (sp)+,r0\n\
-       movc3   r0,(r1),(r3)\n" },
-
-       { "3,_bcopy\n",
-"      movl    (sp)+,r1\n\
-       movl    (sp)+,r3\n\
-       movl    (sp)+,r5\n\
-       movc3   r5,(r1),(r3)\n" },
-
-       { "3,_ovbcopy\n",
-"      movl    (sp)+,r3\n\
-       movl    (sp)+,r4\n\
-       movl    (sp)+,r5\n\
-       movc3   r5,(r3),(r4)\n" },
-
-       { "3,_blkcmp\n",
-"      movl    (sp)+,r1\n\
-       movl    (sp)+,r3\n\
-       jbr     2f\n\
-1:\n\
-       subl2   r0,(sp)\n\
-       cmpc3   r0,(r1),(r3)\n\
-       bneq    3f\n\
-2:\n\
-       movzwl  $65535,r0\n\
-       cmpl    (sp),r0\n\
-       jgtr    1b\n\
-       movl    (sp)+,r0\n\
-       cmpc3   r0,(r1),(r3)\n\
-3:\n" },
-
-       { "3,_bcmp\n",
-"      movl    (sp)+,r1\n\
-       movl    (sp)+,r3\n\
-       movl    (sp)+,r5\n\
-       cmpc3   r5,(r1),(r3)\n" },
-
-       { "2,_blkclr\n",
-"      movl    (sp)+,r3\n\
-       jbr     2f\n\
-1:\n\
-       subl2   r0,(sp)\n\
-       movc5   $0,(r3),$0,r0,(r3)\n\
-2:\n\
-       movzwl  $65535,r0\n\
-       cmpl    (sp),r0\n\
-       jgtr    1b\n\
-       movl    (sp)+,r0\n\
-       movc5   $0,(r3),$0,r0,(r3)\n" },
-
-       { "2,_bzero\n",
-"      movl    (sp)+,r3\n\
-       movl    (sp)+,r5\n\
-       movc5   $0,(r3),$0,r5,(r3)\n" },
-
-       { "3,_llocc\n",
-"      movl    (sp)+,r4\n\
-       movl    (sp)+,r5\n\
-       movl    (sp)+,r1\n\
-1:\n\
-       movzwl  $65535,r0\n\
-       cmpl    r5,r0\n\
-       jleq    1f\n\
-       subl2   r0,r5\n\
-       locc    r4,r0,(r1)\n\
-       jeql    1b\n\
-       addl2   r5,r0\n\
-       jbr     2f\n\
-1:\n\
-       locc    r4,r5,(r1)\n\
-2:\n" },
-
-       { "3,_locc\n",
-"      movl    (sp)+,r3\n\
-       movl    (sp)+,r4\n\
-       movl    (sp)+,r5\n\
-       locc    r3,r4,(r5)\n" },
-
-       { "4,_scanc\n",
-"      movl    (sp)+,r2\n\
-       movl    (sp)+,r3\n\
-       movl    (sp)+,r4\n\
-       movl    (sp)+,r5\n\
-       scanc   r2,(r3),(r4),r5\n" },
-
-       { "3,_skpc\n",
-"      movl    (sp)+,r3\n\
-       movl    (sp)+,r4\n\
-       movl    (sp)+,r5\n\
-       skpc    r3,r4,(r5)\n" },
-
-       { "2,_insque\n",
-"      movl    (sp)+,r4\n\
-       movl    (sp)+,r5\n\
-       insque  (r4),(r5)\n" },
-
-       { "1,_remque\n",
-"      movl    (sp)+,r5\n\
-       remque  (r5),r0\n" },
-#endif
-
-#if defined(tahoe)
-       { "16,_blkcpy\n",
+       { 3, "_blkcpy\n",
 "      movl    (sp)+,r0\n\
        movl    (sp)+,r1\n\
        movl    (sp)+,r2\n\
        movblk\n" },
 
 "      movl    (sp)+,r0\n\
        movl    (sp)+,r1\n\
        movl    (sp)+,r2\n\
        movblk\n" },
 
-       { "16,_bcopy\n",
+       { 3, "_bcopy\n",
 "      movl    (sp)+,r0\n\
        movl    (sp)+,r1\n\
        movl    (sp)+,r2\n\
        movblk\n" },
 
 "      movl    (sp)+,r0\n\
        movl    (sp)+,r1\n\
        movl    (sp)+,r2\n\
        movblk\n" },
 
-       { "12,_bzero\n",
+       { 2, "_bzero\n",
 "      movl    (sp)+,r1\n\
        movl    (sp)+,r2\n\
        movab   1f,r0\n\
 "      movl    (sp)+,r1\n\
        movl    (sp)+,r2\n\
        movab   1f,r0\n\
@@ -150,7 +36,7 @@ struct pats machine_ptab[] = {
 1:     .byte   0\n\
        .text\n" },
 
 1:     .byte   0\n\
        .text\n" },
 
-       { "12,_blkclr\n",
+       { 2, "_blkclr\n",
 "      movl    (sp)+,r1\n\
        movl    (sp)+,r2\n\
        movab   1f,r0\n\
 "      movl    (sp)+,r1\n\
        movl    (sp)+,r2\n\
        movab   1f,r0\n\
@@ -158,11 +44,6 @@ struct pats machine_ptab[] = {
        .data\n\
 1:     .byte   0\n\
        .text\n" },
        .data\n\
 1:     .byte   0\n\
        .text\n" },
-#endif
-
-#if defined(mc68000)
-/* someday... */
-#endif
 
 
-       { "", "" }
+       { 0, "", "" }
 };
 };
index e1686b1..e173329 100644 (file)
@@ -11,7 +11,7 @@ char copyright[] =
 #endif
 
 #ifndef lint
 #endif
 
 #ifndef lint
-static char sccsid[] = "@(#)main.c     1.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)main.c     1.3 (Berkeley) %G%";
 #endif
 
 #include <stdio.h>
 #endif
 
 #include <stdio.h>
@@ -37,7 +37,12 @@ struct stats {
        int     lostmodified;   /* mergers inhibited by intervening mod */
        int     savedpush;      /* successful push/pop merger */
 } stats;
        int     lostmodified;   /* mergers inhibited by intervening mod */
        int     savedpush;      /* successful push/pop merger */
 } stats;
-int dflag;
+
+extern char *strcpy();
+
+char   *whoami;
+int    lineno = 0;
+int    dflag;
 
 main(argc, argv)
        int argc;
 
 main(argc, argv)
        int argc;
@@ -51,6 +56,7 @@ main(argc, argv)
        int size;
        extern char *index();
 
        int size;
        extern char *index();
 
+       whoami = argv[0];
        if (argc > 1 && bcmp(argv[1], "-d", 3) == 0)
                dflag++, argc--, argv++;
        if (argc > 1)
        if (argc > 1 && bcmp(argv[1], "-d", 3) == 0)
                dflag++, argc--, argv++;
        if (argc > 1)
@@ -83,6 +89,7 @@ main(argc, argv)
        buftail = bufhead = 0;
        bufp = line[0];
        while (fgets(bufp, MAXLINELEN, stdin)) {
        buftail = bufhead = 0;
        bufp = line[0];
        while (fgets(bufp, MAXLINELEN, stdin)) {
+               lineno++;
                lp = index(bufp, LABELCHAR);
                if (lp != NULL) {
                        for (cp = bufp; cp < lp; cp++)
                lp = index(bufp, LABELCHAR);
                if (lp != NULL) {
                        for (cp = bufp; cp < lp; cp++)
@@ -94,7 +101,7 @@ main(argc, argv)
                                        emptyqueue();
                                        continue;
                                }
                                        emptyqueue();
                                        continue;
                                }
-                               strcpy(bufp, lp);
+                               (void) strcpy(bufp, lp);
                                *lp++ = '\n';
                                *lp = '\0';
                                emptyqueue();
                                *lp++ = '\n';
                                *lp = '\0';
                                emptyqueue();
@@ -108,6 +115,11 @@ main(argc, argv)
                }
                for (pp = patshdr[hash(cp, &size)]; pp; pp = pp->next) {
                        if (pp->size == size && bcmp(pp->name, cp, size) == 0) {
                }
                for (pp = patshdr[hash(cp, &size)]; pp; pp = pp->next) {
                        if (pp->size == size && bcmp(pp->name, cp, size) == 0) {
+                               if (argcounterr(pp->args, countargs(bufp),
+                                   pp->name)) {
+                                       pp = NULL;
+                                       break;
+                               }
                                expand(pp->replace);
                                bufp = line[bufhead];
                                break;
                                expand(pp->replace);
                                bufp = line[bufhead];
                                break;
@@ -120,7 +132,8 @@ main(argc, argv)
        }
        emptyqueue();
        if (dflag)
        }
        emptyqueue();
        if (dflag)
-               fprintf(stderr, "inline: %s %d, %s %d, %s %d, %s %d\n",
+               fprintf(stderr, "%s: %s %d, %s %d, %s %d, %s %d\n",
+                       whoami,
                        "attempts", stats.attempted,
                        "finished", stats.finished,
                        "inhibited", stats.lostmodified,
                        "attempts", stats.attempted,
                        "finished", stats.finished,
                        "inhibited", stats.lostmodified,
@@ -250,6 +263,37 @@ copyline(from, to)
        return (from);
 }
 
        return (from);
 }
 
+/*
+ * Check for a disparity between the number of arguments a function
+ * is called with and the number which we expect to see.
+ * If the error is unrecoverable, return 1, otherwise 0.
+ */
+argcounterr(args, callargs, name)
+       int args, callargs;
+       char *name;
+{
+       register char *cp;
+       char namebuf[MAXLINELEN];
+
+       if (args == callargs)
+               return (0);
+       cp = strcpy(namebuf, name);
+       while (*cp != '\0' && *cp != '\n')
+               ++cp;
+       if (*cp == '\n')
+               *cp = '\0';
+       if (callargs >= 0) {
+               fprintf(stderr,
+               "%s: error: arg count mismatch, %d != %d for '%s' at line %d\n",
+                       whoami, callargs, args, namebuf, lineno);
+               return (1);
+       }
+       fprintf(stderr,
+               "%s: warning: can't verify arg count for '%s' at line %d\n",
+               whoami, namebuf, lineno);
+       return (0);
+}
+
 /*
  * open space for next line in the queue
  */
 /*
  * open space for next line in the queue
  */