changeset 172:096559f07a70

some check
author kono
date Tue, 25 Nov 2003 11:47:41 +0900
parents 3902240d4930
children 3b33c7daae95
files Changes Makefile mc-code-powerpc.c test/arg.c test/basic.c test/call.c test/conv1.c test/fact-a.c test/fact.c test/fact0.c test/goto.c test/ifdef.c test/macro.c test/regargs.c test/short.c test/simp.c test/simp0.c test/static.c test/test1.c test/tmp.c test/tmp1.c test/tmp10.c test/tmp11.c test/tmp12.c test/tmp2.c test/tmp4.c test/tmp5.c test/tmp6.c test/tmp7.c test/tmp8.c test/tmp9.c
diffstat 31 files changed, 186 insertions(+), 85 deletions(-) [+]
line wrap: on
line diff
--- a/Changes	Mon Nov 24 20:28:19 2003 +0900
+++ b/Changes	Tue Nov 25 11:47:41 2003 +0900
@@ -3518,3 +3518,11 @@
 struct { char a[4],a; } は直しました。
 
 short の引数の扱いも修正。
+
+Mon Nov 24 22:20:29 JST 2003
+
+同じレジスタをずーっと使わずにstatementごとに
+ずらすと、ちょっと速くなるかもね。どうなんだろう?
+rename されちゃえばあんまり関係ないのかも知れないけど。
+
+二つのレジスタを交互に使うとかだと、まぁ、誤差ですね。
--- a/Makefile	Mon Nov 24 20:28:19 2003 +0900
+++ b/Makefile	Tue Nov 25 11:47:41 2003 +0900
@@ -39,7 +39,9 @@
 	perl mc-h-renum.pl mc.h > mc.h.1
 	mv mc.h.1 mc.h
 
-check-all:
+check-all:  check-all-c check-all-code
+
+check-all-c:
 	make check TARGET=test/basic
 	make check TARGET=test/call
 	make check TARGET=test/fact0
@@ -48,17 +50,33 @@
 	make check TARGET=test/int
 	make check TARGET=test/macro
 	make check TARGET=test/regargs
+	make check TARGET=test/short
 	make check TARGET=test/simp
 	make check TARGET=test/simp0
+	make check TARGET=test/static
 	make check TARGET=test/tmp
 	make check TARGET=test/tmp10
 	make check TARGET=test/tmp11
 	make check TARGET=test/tmp12
+#	make check TARGET=test/tmp5
 	make check TARGET=test/tmp7
-	make check TARGET=test/tmp8
+#	make check TARGET=test/tmp8
 	make check TARGET=test/tmp9
-	make check TARGET=test/static
-	make check TARGET=test/short
+#MK =-make
+MK=
+check-all-code:
+	make check-code$(MK) TARGET=test/arg
+	make check-code$(MK) TARGET=test/conv
+	make check-code$(MK) TARGET=test/conv1
+	make check-code$(MK) TARGET=test/fact-a
+	make check-code$(MK) TARGET=test/fact
+	make check-code$(MK) TARGET=test/goto
+#	make check-code$(MK) TARGET=test/test1
+#	make check-code$(MK) TARGET=test/tmp1
+	make check-code$(MK) TARGET=test/tmp2
+	make check-code$(MK) TARGET=test/tmp4
+#	make check-code$(MK) TARGET=test/tmp6
+
 
 check: $(MC)
 	-gcc $(TARGET).c -o b.out $(MLIB)
@@ -68,6 +86,16 @@
 	-./a.out > $(TARGET).$(MC).out
 	-diff  $(TARGET).gcc.out $(TARGET).$(MC).out
 
+check-code: $(MC)
+	-./$(MC) -s $(TARGET).c
+	-gcc $(TARGET).s $(MLIB)
+	-./a.out > $(TARGET).$(MC).out
+	-diff  $(TARGET).code-out $(TARGET).$(MC).out
+check-code-make: $(MC)
+	-./$(MC) -s $(TARGET).c
+	-gcc $(TARGET).s $(MLIB)
+	-./a.out > $(TARGET).code-out
+
 tar :
 	make clean
 	tar cBf - . | gzip > ../comp.tgz 
--- a/mc-code-powerpc.c	Mon Nov 24 20:28:19 2003 +0900
+++ b/mc-code-powerpc.c	Tue Nov 25 11:47:41 2003 +0900
@@ -300,6 +300,23 @@
 
 void
 gexpr_code_init(void){
+#if 0
+    int new_reg,old_reg,dm;
+    /* register shuffling */
+    if (is_int_reg(creg)) {
+	dm = get_register();
+	new_reg = get_register();
+	old_reg = creg;
+	ireg = creg = new_reg;
+    } else if (is_float_reg(creg)) {
+	dm = get_dregister(1);
+	new_reg = get_dregister(1);
+	old_reg = creg;
+	freg = creg = new_reg;
+    }
+    free_register(old_reg);
+    free_register(dm);
+#endif
     regv[creg]=0;
     regv[freg]=0;
 }
@@ -885,7 +902,7 @@
     dreg=get_register(); if (!dreg) error(-1);
     drn = register_name(dreg);
     printf("\t%s %s,0(%s)\n",cload(sz),drn,xrn);
-    if (sign && sz!=size_of_int) 
+    if (use && sign && sz!=size_of_int) 
 	printf("\t%s %s,%s\n",cext(sz),drn,drn);
     printf("\taddi %s,%s,%d\n",drn,drn,dir);
     printf("\t%s %s,0(%s)\n",cstore(sz),drn,xrn);
@@ -913,7 +930,7 @@
     nreg=get_register(); if (!nreg) error(-1);
     nrn = register_name(nreg);
     printf("\t%s %s,0(%s)\n",cload(sz),xrn,crn);
-    if (sign && sz!=size_of_int) 
+    if (use && sign && sz!=size_of_int) 
 	printf("\t%s %s,%s\n",cext(sz),xrn,xrn);
     printf("\taddi %s,%s,%d\n",nrn,xrn,dir);
     printf("\t%s %s,0(%s)\n",cstore(sz),nrn,crn);
--- a/test/arg.c	Mon Nov 24 20:28:19 2003 +0900
+++ b/test/arg.c	Tue Nov 25 11:47:41 2003 +0900
@@ -13,7 +13,7 @@
 code carg2(int arg0,int arg1,int arg2,int arg3,int arg4,code(*exit1)(),void *env)
 {
     struct arg args0;
-    printf("arg1: %d %d %d %d %d : %x %x\n",arg0,arg1,arg2,arg3,arg4,exit1,env);
+    printf("arg1: %d %d %d %d %d : %x %x\n",arg0,arg1,arg2,arg3,arg4,sizeof(exit1),sizeof(env));
     args0.a0 = arg0;
     args0.a1 = arg1;
     args0.a2 = arg2;
@@ -26,9 +26,9 @@
 {
     printf("args: %d %d %d %d %d : %x %x\n",
 	args0.a0,args0.a1,args0.a2,args0.a3,args0.a4,
-    exit1,env);
+    sizeof(exit1),sizeof(env));
     // goto exit1(321),env;
-    goto (*exit1)(321),env;
+    goto (*exit1)(0),env;
 }
 
 
@@ -36,7 +36,7 @@
 {
     printf("args3: %d %d %d %d %d : %x %x %x %x\n",
 	args0.a0,args0.a1,args0.a2,args0.a3,args0.a4,i,j,k,l);
-    if (args0.a0==args1.a0) exit();
+    if (args0.a0==args1.a0) exit(0);
     goto carg4(args0,args1,j,k,l,i);
 }
 
--- a/test/basic.c	Mon Nov 24 20:28:19 2003 +0900
+++ b/test/basic.c	Tue Nov 25 11:47:41 2003 +0900
@@ -158,4 +158,5 @@
     print(1.234e10);
     print(1.234e-10);
     tmp1();
+    return 0;
 }
--- a/test/call.c	Mon Nov 24 20:28:19 2003 +0900
+++ b/test/call.c	Tue Nov 25 11:47:41 2003 +0900
@@ -47,4 +47,5 @@
     printf("6 1 = %d %d\n",j,k);
     k = a5(4,a1);
     printf("6 1 = %d %d\n",j,k);
+    return 0;
 }
--- a/test/conv1.c	Mon Nov 24 20:28:19 2003 +0900
+++ b/test/conv1.c	Tue Nov 25 11:47:41 2003 +0900
@@ -182,8 +182,8 @@
 #endif
     int sw;
     int j;
-    if (ac!=2) exit(0);
-    sw = atoi(av[1]);
+    if (ac==2) sw = atoi(av[1]);
+    else sw=3;
 
     if (sw==0) {
 	for(loop=0;loop<LOOP_COUNT;loop++) {
--- a/test/fact-a.c	Mon Nov 24 20:28:19 2003 +0900
+++ b/test/fact-a.c	Tue Nov 25 11:47:41 2003 +0900
@@ -18,13 +18,14 @@
 int main( int ac, char *av[])
 {
     int n;
-    n = atoi(av[1]);
+    // n = atoi(av[1]);
+    n = 10;
     goto factorial(n,1,n,print,return,environment);
 }
 
 code print(int n,int result,int orig,code(*print)(),(*exit1)(),void*exit1env)
 {
     printf("%d! = %d\n",orig, result);
-    goto (*exit1)(1),exit1env;
+    goto (*exit1)(0),exit1env;
 }
 
--- a/test/fact.c	Mon Nov 24 20:28:19 2003 +0900
+++ b/test/fact.c	Tue Nov 25 11:47:41 2003 +0900
@@ -6,7 +6,8 @@
 char *av[];
 {
     int n;
-    n = atoi(av[1]);
+    // n = atoi(av[1]);
+    n = 10;
     goto factorial(n,1,n,print,return,environment);
 }
 
@@ -16,7 +17,7 @@
 void *exit1env;
 {
     printf("%d! = %d\n",n, result);
-    goto (*exit1)(1),exit1env;
+    goto (*exit1)(0),exit1env;
 }
 
 code factorial(n,result,orig,print,exit1,exit1env)
--- a/test/fact0.c	Mon Nov 24 20:28:19 2003 +0900
+++ b/test/fact0.c	Tue Nov 25 11:47:41 2003 +0900
@@ -4,7 +4,8 @@
 int ac;
 char *av[];
 {
-    printf("%d\n",fact(1,1,atoi(av[1])));
+    printf("%d\n",fact(1,1,10 /*atoi(av[1])*/));
+    return 0;
 }
 
 int
@@ -13,5 +14,5 @@
 {
     if (i==n)
 	return j;
-    /* return */ fact(i+1,j*i,n);
+    return fact(i+1,j*i,n);
 }
--- a/test/goto.c	Mon Nov 24 20:28:19 2003 +0900
+++ b/test/goto.c	Tue Nov 25 11:47:41 2003 +0900
@@ -62,7 +62,7 @@
 a9(int i,int j,int k,code (*conv)())
 {
     printf("a9 %d %x\n",i,conv);
-    goto (*conv)(i+1),env;
+    goto (*conv)(0),env;
 }
 
 main(int ac,char *av[]) {
--- a/test/ifdef.c	Mon Nov 24 20:28:19 2003 +0900
+++ b/test/ifdef.c	Tue Nov 25 11:47:41 2003 +0900
@@ -66,6 +66,7 @@
         printf("%s\n",test3);
         printf("%s\n",test4);
         printf("%s\n",test5);
+	return 0;
 }
 
 
--- a/test/macro.c	Mon Nov 24 20:28:19 2003 +0900
+++ b/test/macro.c	Tue Nov 25 11:47:41 2003 +0900
@@ -29,5 +29,6 @@
 #if 0
    g(car(cadr(e)),cadr(e));
 #endif
+    return 0;
 }
 
--- a/test/regargs.c	Mon Nov 24 20:28:19 2003 +0900
+++ b/test/regargs.c	Tue Nov 25 11:47:41 2003 +0900
@@ -15,4 +15,5 @@
 main()
 {
     arg0(0,1,2,3);
+    return 0;
 }
--- a/test/short.c	Mon Nov 24 20:28:19 2003 +0900
+++ b/test/short.c	Tue Nov 25 11:47:41 2003 +0900
@@ -129,7 +129,7 @@
      printf("f()=%d\n",ii);
      ii = g(i,j,k,m,a[33]); 
      printf("f()=%d\n",ii);
-  
+  return 0;  
 }
 
 short f(short i,unsigned short j,unsigned short k,short m,short a)
--- a/test/simp.c	Mon Nov 24 20:28:19 2003 +0900
+++ b/test/simp.c	Tue Nov 25 11:47:41 2003 +0900
@@ -10,12 +10,13 @@
 main(int ac,char *av[]) 
 {
     int i;
+
     printf("%d\n",ac);
     for(i=0;i<ac;i++) {
-	printf("%s\n",av[i]);
+	printf("%s\n",&av[i][3]);
     }
     ch = 'E';
-    main0(ac,ch,av);
+    return main0(ac,ch,av);
 }
 
 main0(ac,ch,av) 
@@ -26,8 +27,9 @@
     int i;
     printf("%d %c\n",ac,ch);
     for(i=0;i<ac;i++) {
-	printf("%s\n",av[i]);
+	printf("%s\n",&av[i][3]);
     }
     printf("%d==1\n",alpha(ch));
+    return 0;
 }
 
--- a/test/simp0.c	Mon Nov 24 20:28:19 2003 +0900
+++ b/test/simp0.c	Tue Nov 25 11:47:41 2003 +0900
@@ -1,5 +1,6 @@
 
 main(int ac,char *av[])
 {
-    printf("%d %d %d %s\n",1,2,3,av[ac-1]);
+    printf("%d %d %d %s\n",1,2,3,&av[ac-1][3]);
+    return 0;
 }
--- a/test/static.c	Mon Nov 24 20:28:19 2003 +0900
+++ b/test/static.c	Tue Nov 25 11:47:41 2003 +0900
@@ -13,4 +13,5 @@
 {
    f();
    f();
+    return 0;
 }
--- a/test/test1.c	Mon Nov 24 20:28:19 2003 +0900
+++ b/test/test1.c	Tue Nov 25 11:47:41 2003 +0900
@@ -1,53 +1,53 @@
 #include "stdio.h"
 
-    typedef void *stack;
+typedef void *stack;
 
-    struct cont_save { /* General Return Continuation */
-	code (*ret)();
-    };
+struct cont_save { /* General Return Continuation */
+    code (*ret)();
+};
 
 /*
     code g(int,void *);
     code f_g0(int ,int ,void *);
     code f_g1(int,void *);
- */
+*/
 
-    struct f_g0_save {  /* Specialized Return Continuation */
-	code (*ret)();
-	int ii,kk,jj;
-    };
+struct f_g0_save {  /* Specialized Return Continuation */
+    code (*ret)();
+    int ii,kk,jj;
+};
 
-    code g(int i,void *sp) {
-	goto (* ((struct cont_save *)sp)->ret)(i+4,sp);
-    }
+code g(int i,void *sp) {
+    goto (* ((struct cont_save *)sp)->ret)(i+4,sp);
+}
 
-    code f_g1(int j,void *sp) {  /* Continuation  */
-	int k;
-	struct f_g0_save *c;
+code f_g1(int j,void *sp) {  /* Continuation  */
+    int k;
+    struct f_g0_save *c;
 
-        c = sp;
-        k = c->kk;
-	sp += sizeof(struct f_g0_save);
-	goto (* ((struct cont_save *)sp)->ret)(k+4+j,sp);
-    }
+    c = sp;
+    k = c->kk;
+    sp += sizeof(struct f_g0_save);
+    goto (* ((struct cont_save *)sp)->ret)(k+4+j,sp);
+}
 
-    code f(int i,void *sp) {
-	int k,j;
-	struct f_g0_save *c;
-    printf("f 0 sp: %x\n",sp);
+code f(int i,void *sp) {
+    int k,j;
+    struct f_g0_save *c;
+printf("f 0 sp: %x\n",sp);
 
-	k = 3+i;
+    k = 3+i;
 
-    printf("f 1 sp: %x\n",sp);
-	sp -= sizeof(struct f_g0_save);
-    printf("f 2 sp: %x\n",sp);
-	c = sp;
-	c->kk = k;
-	c->ii = i;
-	c->jj = j;
-	c->ret = f_g1;
-	goto g(i,sp);
-    }
+printf("f 1 sp: %x\n",sp);
+    sp -= sizeof(struct f_g0_save);
+printf("f 2 sp: %x\n",sp);
+    c = sp;
+    c->kk = k;
+    c->ii = i;
+    c->jj = j;
+    c->ret = f_g1;
+    goto g(i,sp);
+}
 
 
 void *stack0;
@@ -95,7 +95,8 @@
     int i,j;
     int *sp;
 
-    i = atoi(av[1]);
+    // i = atoi(av[1]);
+    i = 1;
     stack0 = ((char *)malloc(1024)+1024);
     sp = stack0;
     j = i;
@@ -107,6 +108,6 @@
 code print(int i,int j,(*exit1)(),void*exit1env)
 {
     printf("%d %d\n",i,j);
-    goto (*exit1)(1),exit1env;
+    goto (*exit1)(0),exit1env;
 }
 
--- a/test/tmp.c	Mon Nov 24 20:28:19 2003 +0900
+++ b/test/tmp.c	Tue Nov 25 11:47:41 2003 +0900
@@ -28,4 +28,5 @@
     p = p+i;
     printf("%d %s\n",i,p-i);
     printf("%d\n",main1(ac,av,g,g));
+    return 0;
 }
--- a/test/tmp1.c	Mon Nov 24 20:28:19 2003 +0900
+++ b/test/tmp1.c	Tue Nov 25 11:47:41 2003 +0900
@@ -5,7 +5,12 @@
 {
     if (ac>1)
 	goto code1(av,return);
-    goto code1(ac,av);
+    goto code1(ac,av,exit1);
+}
+
+code exit1(int ac,int av)
+{
+    exit(0);
 }
 
 code code3(a,b,c,d,e,f)
@@ -36,12 +41,12 @@
     goto code0(ac,av);
 }
 
-code code1(ac,av)
-int ac;
+code code1(ac,av,exit)
+int ac,exit;
 char *av[];
 {
     code (*f)();
-    f = ac;
+    f = exit;
     if (ac>3)
 	goto code1(ac,av);
     else if (ac>2)
--- a/test/tmp10.c	Mon Nov 24 20:28:19 2003 +0900
+++ b/test/tmp10.c	Tue Nov 25 11:47:41 2003 +0900
@@ -11,4 +11,5 @@
      i=p[0];
      bbb.a[55]=1;
      ccc.a[55]=1;
+    return 0;
 }
--- a/test/tmp11.c	Mon Nov 24 20:28:19 2003 +0900
+++ b/test/tmp11.c	Tue Nov 25 11:47:41 2003 +0900
@@ -12,7 +12,7 @@
 int
 test0(int a,int b,int c) {
     printf("a %d b %d c %d\n",a,b,c);
-    return 4;
+    return 0;
 }
 
 int
--- a/test/tmp12.c	Mon Nov 24 20:28:19 2003 +0900
+++ b/test/tmp12.c	Tue Nov 25 11:47:41 2003 +0900
@@ -13,4 +13,5 @@
     x1.a = 1;
     a = 133;
     printf("%d %d\n",x1.a,a);
+    return 0;
 }
--- a/test/tmp2.c	Mon Nov 24 20:28:19 2003 +0900
+++ b/test/tmp2.c	Tue Nov 25 11:47:41 2003 +0900
@@ -7,8 +7,8 @@
 {
     int i;
     i=main0(ac,av);
-    fprintf(stderr,"1: %s %d\n",av[0],i);
-    return i;
+    fprintf(stdout,"1: %s %d\n",av[0],i);
+    return 0;
 }
 
 int
@@ -16,7 +16,7 @@
 int ac;
 char *av[];
 {
-    fprintf(stderr,"2: %s\n",av[0]);
+    fprintf(stdout,"2: %s\n",av[0]);
     goto code0(av,return,environment);
 }
 
@@ -27,7 +27,7 @@
 {
     char *p;
     p = av[0];
-    fprintf(stderr,"3: %s\n",p);
+    fprintf(stdout,"3: %s\n",p);
     goto code1(av,ret,retenv);
 }
 
@@ -36,6 +36,6 @@
 code (*ret)();
 void *retenv;
 {
-    fprintf(stderr,"4: %s\n",av[0]);
+    fprintf(stdout,"4: %s\n",av[0]);
     goto (*ret)(1234),retenv;
 }
--- a/test/tmp4.c	Mon Nov 24 20:28:19 2003 +0900
+++ b/test/tmp4.c	Tue Nov 25 11:47:41 2003 +0900
@@ -7,8 +7,8 @@
 {
     int i;
     i=main0(ac,av);
-    fprintf(stderr,"1: %s %d\n",av[0],i);
-    return i;
+    fprintf(stdout,"1: %s %d\n",av[0],i);
+    return 0;
 }
 
 int
@@ -20,7 +20,7 @@
     i=123;
     j=456;
     k=789;
-    fprintf(stderr,"2: av=%x av[0]=%x %s\n",av,av[0],av[0]);
+    fprintf(stdout,"2: av=%x av[0]=%x %s\n",av,av[0],av[0]);
     goto code0(i,j,k,av,return,environment);
 }
 
@@ -32,7 +32,7 @@
 {
     char *p;
     p = av[0];
-    fprintf(stderr,"3: i=%d j=%d k=%d av=%x p=%s\n",i,j,k,av,p);
+    fprintf(stdout,"3: i=%d j=%d k=%d av=%x p=%s\n",i,j,k,av,p);
     goto code1(i,j,k,av,ret,retenv);
 }
 
@@ -42,7 +42,7 @@
 code (*ret)();
 void *retenv;
 {
-    fprintf(stderr,"4: %s\n",av[0]);
+    fprintf(stdout,"4: %s\n",av[0]);
     goto code2(i,j,k,av,ret,retenv);
 }
 
@@ -52,7 +52,7 @@
 code (*ret)();
 void *retenv;
 {
-    fprintf(stderr,"5: %s\n",av[0]);
-    fprintf(stderr,"5: i=%d j=%d k=%d av=%x\n",i,j,k,av);
+    fprintf(stdout,"5: %s\n",av[0]);
+    fprintf(stdout,"5: i=%d j=%d k=%d av=%x\n",i,j,k,av);
     goto (*ret)(1234),retenv;
 }
--- a/test/tmp5.c	Mon Nov 24 20:28:19 2003 +0900
+++ b/test/tmp5.c	Tue Nov 25 11:47:41 2003 +0900
@@ -2,8 +2,9 @@
 int gpc=3;
 main() {
     gpc += 1;
-    if(gpc) goto next;
+    if(gpc) goto next0;
     gpc /= 10;
-next:
+next0:
     ;
+    return 0;
 }
--- a/test/tmp6.c	Mon Nov 24 20:28:19 2003 +0900
+++ b/test/tmp6.c	Tue Nov 25 11:47:41 2003 +0900
@@ -13,7 +13,7 @@
     }
     i=main0(ac,av,return,environment);
     fprintf(stderr,"1: %s %d\n",av[0],i);
-    return i;
+    return 0;
 }
 
 int
--- a/test/tmp7.c	Mon Nov 24 20:28:19 2003 +0900
+++ b/test/tmp7.c	Tue Nov 25 11:47:41 2003 +0900
@@ -100,7 +100,8 @@
     i = p[1];
     p = p+i;
 /* 47 ./a.out */
-    printf("%d %s\n",i,p-i);
+    printf("%d %s\n",i,p-i+3);
+    return 0;
 }
 
 void
--- a/test/tmp8.c	Mon Nov 24 20:28:19 2003 +0900
+++ b/test/tmp8.c	Tue Nov 25 11:47:41 2003 +0900
@@ -1,7 +1,32 @@
 
+int asize = 100;
+
+int f(int i,int j,int k,int *l);
+int g();
+
+int
+main()
+{
+    int a[0] ;
+   printf("%d %d\n",g(),f(0,1,2,a));
+   return 0; 
+}
 
 int
-f(int i,int j,int k,void *l)
+g()
 {
-    return f(i,j,k,alloca(i));
+   int k = 0,i;
+
+   char *p = alloca(asize);
+   for(i=0;i<100;i++) p[i]=i;
+   for(i=0;i<100;i++) k += p[i];
+   return k;
 }
+
+int
+f(int i,int j,int k,int *l)
+{
+    *l = 3;
+    if (i++ >20) return *l;
+    return f(i,j,k,(int*)alloca(asize));
+}
--- a/test/tmp9.c	Mon Nov 24 20:28:19 2003 +0900
+++ b/test/tmp9.c	Tue Nov 25 11:47:41 2003 +0900
@@ -1,4 +1,4 @@
 main()
 {
-   return 5;
+   return 0;
 }