changeset 554:dc677ac7a744

emit_pop_free kills creg after emit_copy.
author kono
date Thu, 05 Jan 2006 23:37:19 +0900
parents 293f827ccfb2
children ac181d7f9c82
files Changes Makefile.ia32 Makefile.mips mc-code-arm.c mc-code-mips.c mc-code-powerpc.c mc-codegen.c mc-inline.c mc-parse.h stdio.h
diffstat 10 files changed, 64 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/Changes	Thu Jan 05 21:29:55 2006 +0900
+++ b/Changes	Thu Jan 05 23:37:19 2006 +0900
@@ -7889,4 +7889,19 @@
 やらないとだめだね。code_bit_replace とかに interpreter mode
 をつければいいんだよな。
 
-
+Thu Jan  5 22:18:50 JST 2006
+
+linux kernelは一応、通りました。IA32 でinlineで関数の引数の
+呼ばれる順序が変わる。あと、scope.c のinlineがだめだな。
+なにか、まずいことをやっているのか? signed?
+
+IA32のis_writableに RLVAR が入るのは何故?
+
+xreg と creg を変更するコード生成があると、
+emit_pop_free で creg が regs[creg]=0 されちゃうときがある。
+emit_copy の後とかね。すると code_set_fixed_creg で、creg が切替えられてしまう。
+そして、値が伝わらない。
+
+ia32 では emit_pop_free で creg かどうか見てるみたいね。それでも
+いいんだけど...
+
--- a/Makefile.ia32	Thu Jan 05 21:29:55 2006 +0900
+++ b/Makefile.ia32	Thu Jan 05 23:37:19 2006 +0900
@@ -1,4 +1,5 @@
 # CC = gcc -std=c99
+CC = cc 
 # -O3
 CFLAGS = -g -Wall -I.
 # CFLAGS = -g -Wall -I. -pg -fprofile-arcs -ftest-coverage
@@ -11,7 +12,7 @@
 MFLAGS=$(MFALGS) BASE=$(BASE) STAGE=$(STAGE)
 ARCH=ia32
 MC=mc-$(ARCH)
-MLIB = -lm
+# MLIB = -lm
 PRINTF= # printf.c
 CONVERTER=conv/c.o conv/null.o
 # conv/c2cbc.o conv/cbc2c.o
@@ -61,6 +62,7 @@
 
 check-all-c:
 	make check TARGET=test/basic
+	make check-inline TARGET=test/basic
 	make check TARGET=test/call
 	make check TARGET=test/fact0
 	make check TARGET=test/float
@@ -89,14 +91,16 @@
 	make check TARGET=test/switch
 	make check TARGET=test/strinit
 	make check TARGET=test/code-gen-all
+	make check-inline TARGET=test/code-gen-all
 	make check TARGET=test/bitfield
 	make check TARGET=test/bitfield1
 	make check TARGET=test/cext
 	make check TARGET=test/const
 	make check TARGET=test/void_code
+	make check TARGET=test/putenemy
 	make check TARGET=test/inline
-	make check TARGET=test/putenemy
 #	make check TARGET=test/scope STDFLAG="-std=gnu99"
+#	make check-inline TARGET=test/scope STDFLAG="-std=gnu99"
 #MK =-make
 MK=
 check-all-code:
@@ -113,6 +117,7 @@
 	make check-code$(MK) TARGET=test/tmp4
 	make check-code$(MK) TARGET=test/tmp6
 	make check-code$(MK) TARGET=test/scope
+	make check-code$(MK) TARGET=test/too-long-argument
 
 check-nkf:
 	( cd nkf203; $(CC) -g -o nkf1 nkf.c utf8tbl.c )
@@ -122,7 +127,7 @@
 
 #	-./$(MC) -Itest/ -s $(TARGET).c
 
-check: $(MC) $(TARGET).c
+check: mc $(MC) $(TARGET).c
 	-$(CC) $(CFLAGS1) $(STDFLAG) $(TARGET).c -o b.out $(MLIB)
 	-./b.out > $(TARGET).gcc.out
 	-./$(MC) -s $(TARGET).c
@@ -130,12 +135,20 @@
 	-./a.out > $(TARGET).$(MC).out
 	-diff $(TARGET).gcc.out $(TARGET).$(MC).out
 
-check-code: $(MC)
+check-inline: mc $(MC) $(TARGET).c
+	-$(CC) $(CFLAGS1) $(STDFLAG) $(TARGET).c -o b.out $(MLIB)
+	-./b.out > $(TARGET).gcc.out
+	-./$(MC) -s -DINLINE=inline $(TARGET).c
+	-$(CC) $(TARGET).s $(MLIB)
+	-./a.out > $(TARGET).$(MC).out
+	-diff $(TARGET).gcc.out $(TARGET).$(MC).out
+
+check-code: mc $(MC)
 	-./$(MC) -s $(TARGET).c
 	-$(CC) $(TARGET).s $(MLIB)
 	-./a.out > $(TARGET).$(MC).out
 	-diff  $(TARGET).code-out $(TARGET).$(MC).out
-check-code-make: $(MC)
+check-code-make: mc $(MC)
 	-./$(MC) -s $(TARGET).c
 	-$(CC) $(TARGET).s $(MLIB)
 	-./a.out > $(TARGET).code-out
--- a/Makefile.mips	Thu Jan 05 21:29:55 2006 +0900
+++ b/Makefile.mips	Thu Jan 05 23:37:19 2006 +0900
@@ -61,6 +61,7 @@
 
 check-all-c:
 	make check TARGET=test/basic
+	make check-inline TARGET=test/basic
 	make check TARGET=test/call
 	make check TARGET=test/fact0
 	make check TARGET=test/float
@@ -89,14 +90,16 @@
 	make check TARGET=test/switch
 	make check TARGET=test/strinit
 	make check TARGET=test/code-gen-all
+	make check-inline TARGET=test/code-gen-all
 	make check TARGET=test/bitfield
 	make check TARGET=test/bitfield1
 	make check TARGET=test/cext
 	make check TARGET=test/const
 	make check TARGET=test/void_code
+	make check TARGET=test/putenemy
 	make check TARGET=test/inline
-	make check TARGET=test/putenemy
 #	make check TARGET=test/scope STDFLAG="-std=gnu99"
+#	make check-inline TARGET=test/scope STDFLAG="-std=gnu99"
 #MK =-make
 MK=
 check-all-code:
@@ -113,6 +116,7 @@
 	make check-code$(MK) TARGET=test/tmp4
 	make check-code$(MK) TARGET=test/tmp6
 	make check-code$(MK) TARGET=test/scope
+	make check-code$(MK) TARGET=test/too-long-argument
 
 check-nkf:
 	( cd nkf203; $(CC) -g -o nkf1 nkf.c utf8tbl.c )
@@ -122,7 +126,7 @@
 
 #	-./$(MC) -Itest/ -s $(TARGET).c
 
-check: $(MC) $(TARGET).c
+check: mc $(MC) $(TARGET).c
 	-$(CC) $(CFLAGS1) $(STDFLAG) $(TARGET).c -o b.out $(MLIB)
 	-./b.out > $(TARGET).gcc.out
 	-./$(MC) -s $(TARGET).c
@@ -130,12 +134,20 @@
 	-./a.out > $(TARGET).$(MC).out
 	-diff $(TARGET).gcc.out $(TARGET).$(MC).out
 
-check-code: $(MC)
+check-inline: mc $(MC) $(TARGET).c
+	-$(CC) $(CFLAGS1) $(STDFLAG) $(TARGET).c -o b.out $(MLIB)
+	-./b.out > $(TARGET).gcc.out
+	-./$(MC) -s -DINLINE=inline $(TARGET).c
+	-$(CC) $(TARGET).s $(MLIB)
+	-./a.out > $(TARGET).$(MC).out
+	-diff $(TARGET).gcc.out $(TARGET).$(MC).out
+
+check-code: mc $(MC)
 	-./$(MC) -s $(TARGET).c
 	-$(CC) $(TARGET).s $(MLIB)
 	-./a.out > $(TARGET).$(MC).out
 	-diff  $(TARGET).code-out $(TARGET).$(MC).out
-check-code-make: $(MC)
+check-code-make: mc $(MC)
 	-./$(MC) -s $(TARGET).c
 	-$(CC) $(TARGET).s $(MLIB)
 	-./a.out > $(TARGET).code-out
@@ -223,7 +235,6 @@
 	-diff b03.s b23.s
 	-diff b04.s b24.s
 
-
 # DO NOT DELETE
 
 mc-code-ia32.o: /usr/include/stdio.h /usr/include/features.h
--- a/mc-code-arm.c	Thu Jan 05 21:29:55 2006 +0900
+++ b/mc-code-arm.c	Thu Jan 05 23:37:19 2006 +0900
@@ -856,7 +856,7 @@
 void
 emit_pop_free(int xreg)
 {
-    if (xreg>=0)
+    if (xreg>=0 && xreg!=creg)
 	free_register(xreg);
 }
 
--- a/mc-code-mips.c	Thu Jan 05 21:29:55 2006 +0900
+++ b/mc-code-mips.c	Thu Jan 05 23:37:19 2006 +0900
@@ -785,7 +785,7 @@
 void
 emit_pop_free(int xreg)
 {
-    if (xreg>=0)
+    if (xreg>=0 && xreg!=creg)
 	free_register(xreg);
 }
 
@@ -1600,9 +1600,6 @@
 	}
 	extern_define(memmove,0,FUNCTION,1);
 	set_ireg(RET_REGISTER,0);
-	if (creg!=to) {
-	    free_register(to); to = creg;
-	}
 	break;
     }
     if (value) {
@@ -1610,7 +1607,8 @@
     /* this code is necessary for the value of assignment or function call */
     /* otherwise we don't need this */
 	if(creg!=to) {
-	    free_register(creg); creg=to; ireg=to;
+	    free_register(to);
+	    // set_ireg(to,1);
 	}
     }
     free_register(dreg);
--- a/mc-code-powerpc.c	Thu Jan 05 21:29:55 2006 +0900
+++ b/mc-code-powerpc.c	Thu Jan 05 23:37:19 2006 +0900
@@ -749,7 +749,7 @@
 void
 emit_pop_free(int xreg)
 {
-    if (xreg>=0)
+    if (xreg>=0 && xreg!=creg)
 	free_register(xreg);
 }
 
@@ -1546,7 +1546,6 @@
     char *frn;
     char *trn;
     char *drn;
-    int fix = 0;
     char *memmove = "memmove";
     int dreg = get_register(); if (!dreg) error(-1);
 
@@ -1600,20 +1599,19 @@
         /* overrap must be allowed */
 	printf("\tbl L_%s$stub\n",memmove);
 	extern_define(memmove,0,FUNCTION,1);
-        fix=0;
 	set_ireg(RET_REGISTER,0);
-	if (creg!=to) {
-	    free_register(to); to = creg;
-	}
+	//if (creg!=to) {
+	//    free_register(to); to = creg;
+	//}
 	break;
     }
     if (value) {
     /* creg must point top of the destination data */
     /* this code is necessary for the value of assignment or function call */
     /* otherwise we don't need this */
-	if (fix) printf("\taddi %s,%s,%d\n",trn,trn,fix);
 	if(creg!=to) {
-	    free_register(creg); creg=to; ireg=to;
+	    free_register(to);
+	    // set_ireg(to,1);
 	}
     }
     free_register(dreg);
--- a/mc-codegen.c	Thu Jan 05 21:29:55 2006 +0900
+++ b/mc-codegen.c	Thu Jan 05 23:37:19 2006 +0900
@@ -1207,6 +1207,7 @@
     switch(car(e1)) {
     case GVAR :
     case LVAR :
+    case RLVAR :        // this is wrong, but ia32 generates this.
     case REGISTER :
 	return size_of_int;
     case FREGISTER :
--- a/mc-inline.c	Thu Jan 05 21:29:55 2006 +0900
+++ b/mc-inline.c	Thu Jan 05 23:37:19 2006 +0900
@@ -556,7 +556,7 @@
 p_decl(int e)
 {
     // list4(ST_DECL,parse,(int)n,list3(mode,stmode,ctmode));
-    int ctmode=cadddr(e);;
+    int ctmode=cadddr(e);
     NMTBL *n=(NMTBL*)caddr(e);
     int dsp = n->dsp;
     int v;
--- a/mc-parse.h	Thu Jan 05 21:29:55 2006 +0900
+++ b/mc-parse.h	Thu Jan 05 23:37:19 2006 +0900
@@ -96,7 +96,7 @@
 
 /* used in mc-codegen.c */
 
-extern NMTBL * anonymous_nptr();;
+extern NMTBL * anonymous_nptr();
 extern int append4(int p,int a1,int a2,int a3);
 extern void display_ntable(NMTBL *n, char *s);
 extern NMTBL * lsearch(char *name,int sc);
--- a/stdio.h	Thu Jan 05 21:29:55 2006 +0900
+++ b/stdio.h	Thu Jan 05 23:37:19 2006 +0900
@@ -1,4 +1,4 @@
-#ifndef __micro_c___
+#ifndef __micro_c__
 #include "/usr/include/stdio.h"
 long long strtoll(const char *, char **, int);
 char *malloc(int);