changeset 685:3e3cf02297e4

before intel function call order fix
author kono
date Fri, 05 Oct 2007 16:06:41 +0900
parents 6e2f1e7f9fc3
children 7e0c5c1f1e97
files .gdbinit mc-code-ia32.c mc-codegen.c mc-parse.c test/tmp6.c tools/incpri.pl
diffstat 6 files changed, 19 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/.gdbinit	Tue Oct 02 21:18:12 2007 +0900
+++ b/.gdbinit	Fri Oct 05 16:06:41 2007 +0900
@@ -14,8 +14,9 @@
 end
 b errmsg
 # r -s test/tmp7.c
+r -s test/tmp6.c
 # r -s test/code-gen-all.c
 # r -s mc-code-powerpc.c
 # r -s test/strinit.c
 # r -s -DINLINE=inline test/strinit.c
-r -s test/fact-a.c
+# r -s test/fact-a.c
--- a/mc-code-ia32.c	Tue Oct 02 21:18:12 2007 +0900
+++ b/mc-code-ia32.c	Fri Oct 05 16:06:41 2007 +0900
@@ -1022,12 +1022,12 @@
 void 
 gexpr_init(void)
 {
+    text_mode(0);
     if (reg_sp>0) error(-1);
     if (freg_sp>0) error(-1);
     reg_sp = 0;
     freg_sp = 0;
     stack_depth = 0;
-    text_mode(0);
     gexpr_code_init();
     regs[creg]=1;
     register_usage("gexpr_init");
--- a/mc-codegen.c	Tue Oct 02 21:18:12 2007 +0900
+++ b/mc-codegen.c	Fri Oct 05 16:06:41 2007 +0900
@@ -1763,9 +1763,9 @@
     } else if(car(e1)==GVAR) {
 	return(list3(GVAR,cadr(e1)+cadr(e),caddr(e1)));
     } else if(car(e1)==LVAR) {
-	return(list3(LVAR,cadr(e1)+cadr(e),caddr(e)));
-    } else if(car(e1)==RLVAR) {
-	return(list3(RLVAR,cadr(e1)+cadr(e),caddr(e)));
+	return(list3(LVAR,cadr(e1)+cadr(e),caddr(e1)));
+//    } else if(car(e1)==RLVAR) {  this is not correct
+//	return(list3(RLVAR,cadr(e1)+cadr(e),caddr(e1)));
     }
     return e0;
 }
--- a/mc-parse.c	Tue Oct 02 21:18:12 2007 +0900
+++ b/mc-parse.c	Fri Oct 05 16:06:41 2007 +0900
@@ -2056,8 +2056,8 @@
     /* local variable declaration */
     control=1;
     cslabel = -1;
+    local_decl(1);
     if(!inmode && !chk) gen_code_enter1(args);
-    local_decl(1);
     emit_init_vars();
     // lfree_type_limit = lfree;
     while(sym!=RC) statement(0);
@@ -2130,9 +2130,9 @@
 
     control=1;
     cslabel = -1;
-    if (!inmode && !chk) gen_enter1();
     /* local variable declaration */
     local_decl(1);
+    if (!inmode && !chk) gen_enter1();
     emit_init_vars();
     lfree_type_limit  = lfree;
     while(sym!=RC) statement(0);
@@ -2310,7 +2310,7 @@
     typedefed=0;
     init_vars=0;
 
-    if(!chk) gen_enter1();
+    if(!chk) gen_code_enter1(args);
 
     control=1;
     cslabel = -1;
@@ -4118,11 +4118,11 @@
 	    if (inmode) {
 		int sparse = parse; parse=0;
 		docomp(1);
+		// wrong parse tree fix me!
 		e1 = list3(COMMA,reverse0(parse),lastexp);
 		parse = sparse;
 		lastexp = 0;
 	    } else {
-#if 1
 		int l,b,l2,cntl=control;
 		// if COMMA expr is not gexpred by !control, 
 		// l2 is not defined and generates undefined error.
@@ -4141,17 +4141,6 @@
 		lastexp = 0;
 		if (l) fwddef(l);
 		control=cntl;
-#else
-		// we already have parse tree mode, why don't we?
-		int sparse = parse; parse=0;
-		inmode = INLINE+1;
-		// this does not work well... we need some work later
-		docomp(1);
-		e1 = list3(COMMA,reverse0(parse),lastexp);
-		parse = sparse;
-		lastexp = 0;
-		inmode = 0;
-#endif
 	    }
 	} else {
 	    e1=expr0();
--- a/test/tmp6.c	Tue Oct 02 21:18:12 2007 +0900
+++ b/test/tmp6.c	Fri Oct 05 16:06:41 2007 +0900
@@ -10,13 +10,13 @@
     int i;
 
     if(ac!=2)	{
-	fprintf(stdout,"a used.\n");
+	fprintf(stdout,"#0012:a used.\n");
 	// return(0);
 	i=main0(2,a,return,environment);
         return 0;
     }
     i=main0(ac,av,return,environment);
-    fprintf(stdout,"1: %s %d\n",av[0],i);
+    fprintf(stdout,"#0018:1: %s %d\n",av[0],i);
     return 0;
 }
 
@@ -31,7 +31,7 @@
     i=123;
     j=456;
     k = atoi(av[1]);
-    fprintf(stdout,"2: av=%x av[0]=%x %s\n",av==a,av[0]==a[0],av[0]);
+    fprintf(stdout,"#0033:2: av=%x av[0]=%x %s\n",av==a,av[0]==a[0],av[0]);
     goto code0(i,j,k,av,ret,retenv,return,environment);
 }
 
@@ -45,7 +45,7 @@
 {
     char *p;
     p = av[0];
-    fprintf(stdout,"code0\n",av[0]);
+    fprintf(stdout,"#0047:code0\n",av[0]);
     goto code1(i,j,k,av,ret,retenv,ret1,ret1env);
 }
 
@@ -57,7 +57,7 @@
 __code (*ret1)();
 void *ret1env;
 {
-    fprintf(stdout,"4: %s\n",av[0]);
+    fprintf(stdout,"#0059:4: %s\n",av[0]);
     goto code2(i,j,k,av,ret,retenv,ret1,ret1env);
 }
 
@@ -69,8 +69,8 @@
 __code (*ret1)();
 void *ret1env;
 {
-    fprintf(stdout,"5: %s\n",av[0]);
-    fprintf(stdout,"5: i=%d j=%d k=%d av=%x\n",i,j,k,av==a);
+    fprintf(stdout,"#0071:5: %s\n",av[0]);
+    fprintf(stdout,"#0072:5: i=%d j=%d k=%d av=%x\n",i,j,k,av==a);
     if (k>3)
 	goto (*ret1)(1234),ret1env;
     goto (*ret)(1234),retenv;
--- a/tools/incpri.pl	Tue Oct 02 21:18:12 2007 +0900
+++ b/tools/incpri.pl	Fri Oct 05 16:06:41 2007 +0900
@@ -27,6 +27,8 @@
     open(OUT,">$filename");
     $d = "0000";
     while(<IN>) {
+       s/fprintf\(([^,]+,)\"\#\d+\:/fprintf\($1\"\#$d\:/;
+       s/fprintf\(([^,]+,)\"([^#])/fprintf\($1\"\#$d\:$2/;
        s/printf\(\"\#\d+\:/printf\(\"\#$d\:/;
        s/printf\(\"([^#])/printf\(\"\#$d\:$1/;
        $d++;