changeset 581:ad9ef203f95b

*** empty log message ***
author kono
date Sun, 15 Jan 2006 22:40:23 +0900
parents 31b736fb4516
children 3f60e599cc04
files Makefile Makefile.ia32 Makefile.linuxzaurus Makefile.mips Makefile.powerpc mc-codegen.c mc-parse.c test/throw.c test/throw.code-out
diffstat 9 files changed, 308 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Sun Jan 15 22:32:17 2006 +0900
+++ b/Makefile	Sun Jan 15 22:40:23 2006 +0900
@@ -120,6 +120,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/throw
 	make check-code$(MK) TARGET=test/too-long-argument
 
 check-nkf:
--- a/Makefile.ia32	Sun Jan 15 22:32:17 2006 +0900
+++ b/Makefile.ia32	Sun Jan 15 22:40:23 2006 +0900
@@ -117,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/throw
 	make check-code$(MK) TARGET=test/too-long-argument
 
 check-nkf:
--- a/Makefile.linuxzaurus	Sun Jan 15 22:32:17 2006 +0900
+++ b/Makefile.linuxzaurus	Sun Jan 15 22:40:23 2006 +0900
@@ -118,6 +118,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/throw
 	make check-code$(MK) TARGET=test/too-long-argument
 
 check-nkf:
--- a/Makefile.mips	Sun Jan 15 22:32:17 2006 +0900
+++ b/Makefile.mips	Sun Jan 15 22:40:23 2006 +0900
@@ -116,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/throw
 	make check-code$(MK) TARGET=test/too-long-argument
 
 check-nkf:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Makefile.powerpc	Sun Jan 15 22:40:23 2006 +0900
@@ -0,0 +1,288 @@
+CC = gcc -std=c99
+#  -O2
+#  -O99
+CFLAGS = -g -Wall -I. 
+# CFLAGS = -g -Wall -I. -pg -fprofile-arcs -ftest-coverage
+# LDFLAGS = -pg
+# for Linux Zaurus
+# CFLAGS = -fsigned-char -pipe -g -I. -I/home/zaurus/develop/include
+CFLAGS1 = -g  -I.
+BASE=0
+STAGE=1
+MFLAGS=$(MFALGS) BASE=$(BASE) STAGE=$(STAGE)
+ARCH=powerpc
+MC=mc-$(ARCH)
+MLIB = -lm
+PRINTF= # printf.c
+CONVERTER=conv/c.o conv/null.o
+# conv/c2cbc.o conv/cbc2c.o
+COMPLIB = mc-parse.o mc-codegen.o mc-switch.o mc-macro.o mc-tree.o mc-inline.o
+# CODE=mc-code-ia32.c
+CODE=mc-code-$(ARCH).c
+#
+TARGET=test/simp
+
+all: mc mc-ia32 mc-powerpc mc-mips mc-arm
+
+mc:  mc-$(ARCH)
+	cp mc-$(ARCH) mc
+
+TAGS:
+	ctags mc-code-powerpc.c mc-code.h mc-codegen.c mc-codegen.h \
+		mc-macro.c \
+		mc-parse.c mc-tree.c mc-switch.c mc-switch.h \
+		mc.h conv/c.c conv/c.h \
+		mc-inline.h mc-inline.c \
+		conv/conv.h conv/convdef.h conv/null.c
+
+mc-powerpc : mc-code-powerpc.o $(COMPLIB) $(CONVERTER)
+	$(CC) $(LDFLAGS) -g mc-code-powerpc.o $(COMPLIB) $(CONVERTER) -o $@
+
+mc-ia32 : mc-code-ia32.o $(COMPLIB) $(CONVERTER)
+	$(CC) $(LDFLAGS) -g mc-code-ia32.o $(COMPLIB) $(CONVERTER) -o $@
+
+mc-mips : mc-code-mips.o $(COMPLIB) $(CONVERTER)
+	$(CC) $(LDFLAGS) -g mc-code-mips.o $(COMPLIB) $(CONVERTER) -o $@
+
+mc-arm : mc-code-arm.o $(COMPLIB) $(CONVERTER)
+	$(CC) $(LDFLAGS) -g mc-code-arm.o $(COMPLIB) $(CONVERTER) -o $@
+
+conv/conv.h: conv_func.tbl tools/conv_func.pl
+	perl tools/conv_func.pl
+conv/convdef.h: conv_func.tbl tools/conv_func.pl
+	perl tools/conv_func.pl
+conv/null.c: conv_func.tbl tools/conv_func.pl
+	perl tools/conv_func.pl
+
+mc.h-new:
+	perl tools/mc-h-renum.pl mc.h > mc.h.1
+	mv mc.h.1 mc.h
+
+check-all:  check-all-c check-all-code
+
+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
+	make check TARGET=test/ifdef
+	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/simp1
+	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/tmp7
+	make check-inline TARGET=test/tmp8
+	make check TARGET=test/tmp9
+	make check TARGET=test/enum
+	make check TARGET=test/obsf
+	make check TARGET=test/obsf2
+	make check TARGET=test/long
+	make check TARGET=test/tstdarg
+	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-inline 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/offset
+#	make check TARGET=test/scope STDFLAG="-std=gnu99"
+#	make check-inline TARGET=test/scope STDFLAG="-std=gnu99"
+#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/tmpa
+	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
+	make check-code$(MK) TARGET=test/scope
+	make check-code$(MK) TARGET=test/throw
+	make check-code$(MK) TARGET=test/too-long-argument
+
+check-nkf:
+	( cd nkf203; $(CC) -g -o nkf1 nkf.c utf8tbl.c )
+	( cd nkf203; ../mc-$(ARCH) -s nkf.c utf8tbl.c )
+	( cd nkf203; $(CC) -g -o nkf nkf.s utf8tbl.s )
+	( cd nkf203; perl test.pl )
+
+#	-./$(MC) -Itest/ -s $(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
+	-$(CC) $(TARGET).s $(MLIB)
+	-./a.out > $(TARGET).$(MC).out
+	-diff $(TARGET).gcc.out $(TARGET).$(MC).out
+
+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 $(MC)
+	-./$(MC) -s $(TARGET).c
+	-$(CC) $(TARGET).s $(MLIB)
+	-./a.out > $(TARGET).code-out
+
+test/code-gen-all.c: test/code-gen.pl test/code-gen.c
+	perl test/code-gen.pl < test/code-gen.c > test/code-gen-all.c
+
+incpri:
+	perl tools/incpri.pl test/*.c
+
+tags:   tags-$(ARCH)
+
+tags-$(ARCH):  
+	ctags mc.h mc-code.h mc-code-$(ARCH).c  mc-codegen.c mc-codegen.h \
+		mc-parse.c mc-tree.c \
+	    conv/c.c conv/c.h \
+	    conv/conv.h conv/convdef.h 
+
+tar :
+	make clean
+	tar cBf - . | gzip > ../comp.tgz 
+
+depend :
+	makedepend mc-code-ia32.c mc-code.h mc-codegen.c mc-codegen.h \
+		mc-parse.c mc-tree.c mc-switch.c mc-switch.h mc.h \
+		mc-macro.c mc-macro.h mc-parse.h \
+	    conv/c.c conv/c.h conv/c2cbc.c conv/c2cbc.h conv/cbc2c.c \
+	    conv/cbc2c.h conv/conv.h conv/convdef.h conv/null.c conv/null.h \
+                mc-code-powerpc.c \
+                mc-code-mips.c
+
+clean :
+	-rm -f mc mc-ia32 mc-powerpc mc-mips mc-arm *.bak *.s *.o *.cc mc mc1 mc2 a.out *~ core* */*.o *.bak test/*.s test/*.cc test/*.o test/*.bak test/*~ conv/*.s conv/*.cc conv/*.o conv/*.bak conv/*~ *.out */*.out *.i */*.i
+
+mc1 : b00.s b01.s mc-codegen.o mc-tree.o mc-switch.o mc-macro.o mc-inline.o $(CONVERTER)
+	$(CC) -g -o $@ $(PRINTF) b00.s b01.s mc-codegen.o mc-tree.o mc-switch.o mc-macro.o mc-inline.o $(CONVERTER)
+
+mc2 : b00.s b01.s b02.s b03.s mc-macro.o  mc-inline.o $(CONVERTER)
+	$(CC) -g -o $@ $(PRINTF) b00.s b01.s b02.s b03.s b04.s mc-macro.o mc-inline.o $(CONVERTER)
+
+b00.s : mc-parse.c $(MC)
+	./$(MC) -s -ob00.s mc-parse.c
+b01.s : $(CODE) $(MC)
+	./$(MC) -s -ob01.s $(CODE)
+b02.s : mc-codegen.c $(MC)
+	./$(MC) -s -ob02.s mc-codegen.c
+b03.s : mc-tree.c $(MC)
+	./$(MC) -s -ob03.s mc-tree.c
+b04.s : mc-switch.c $(MC)
+	./$(MC) -s -ob04.s mc-switch.c
+
+b10.s : mc-parse.c mc1
+	./mc1 -s -ob10.s mc-parse.c
+b11.s : $(CODE) $(PRINTF) mc1
+	./mc1 -s -ob11.s $(CODE)
+b12.s : mc-codegen.c mc1
+	./mc1 -s -ob12.s mc-codegen.c
+b13.s : mc-tree.c mc1
+	./mc1 -s -ob13.s mc-tree.c
+b14.s : mc-switch.c mc1
+	./mc1 -s -ob14.s mc-switch.c
+
+b20.s : mc-parse.c mc2
+	./mc2 -s -ob20.s mc-parse.c
+b21.s : $(CODE) $(PRINTF) mc2
+	./mc2 -s -ob21.s $(CODE)
+b22.s : mc-codegen.c mc2
+	./mc2 -s -ob22.s mc-codegen.c
+b23.s : mc-tree.c mc2
+	./mc2 -s -ob23.s mc-tree.c
+b24.s : mc-switch.c mc1
+	./mc2 -s -ob24.s mc-switch.c
+
+diff :  b00.s b01.s b02.s b03.s b04.s b10.s b11.s b12.s b13.s b14.s
+	-diff b00.s b10.s
+	-diff b01.s b11.s
+	-diff b02.s b12.s
+	-diff b03.s b13.s
+	-diff b04.s b14.s
+
+diff2 :  b00.s b01.s b02.s b03.s b04.s b20.s b21.s b22.s b23.s b24.s
+	-diff b00.s b20.s
+	-diff b01.s b21.s
+	-diff b02.s b22.s
+	-diff b03.s b23.s
+	-diff b04.s b24.s
+
+
+# DO NOT DELETE
+
+mc-code-ia32.o: /usr/include/stdio.h /usr/include/_types.h
+mc-code-ia32.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
+mc-code-ia32.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h mc.h
+mc-code-ia32.o: mc-parse.h mc-codegen.h mc-code.h
+mc-codegen.o: /usr/include/stdio.h /usr/include/_types.h
+mc-codegen.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
+mc-codegen.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h mc.h
+mc-codegen.o: mc-parse.h mc-codegen.h mc-code.h mc-switch.h mc-inline.h
+mc-parse.o: /usr/include/stdio.h /usr/include/_types.h
+mc-parse.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
+mc-parse.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h mc.h
+mc-parse.o: mc-parse.h mc-codegen.h mc-switch.h mc-macro.h mc-inline.h
+mc-parse.o: conv/conv.h
+mc-tree.o: /usr/include/stdio.h /usr/include/_types.h
+mc-tree.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
+mc-tree.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h mc.h
+mc-tree.o: mc-parse.h
+mc-switch.o: /usr/include/stdio.h /usr/include/_types.h
+mc-switch.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
+mc-switch.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h mc.h
+mc-switch.o: mc-parse.h mc-codegen.h mc-code.h
+mc-macro.o: /usr/include/stdio.h /usr/include/_types.h
+mc-macro.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
+mc-macro.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h mc.h
+mc-macro.o: mc-parse.h mc-macro.h mc-codegen.h mc-code.h
+conv/c.o: /usr/include/stdio.h /usr/include/_types.h
+conv/c.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
+conv/c.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h mc.h
+conv/c.o: mc-parse.h conv/conv.h conv/convdef.h conv/c.h
+conv/c2cbc.o: mc.h
+conv/cbc2c.o: mc.h
+conv/null.o: /usr/include/stdio.h /usr/include/_types.h
+conv/null.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
+conv/null.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h mc.h
+conv/null.o: mc-parse.h conv/conv.h conv/convdef.h conv/null.h
+mc-code-powerpc.o: /usr/include/stdio.h /usr/include/_types.h
+mc-code-powerpc.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
+mc-code-powerpc.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h
+mc-code-powerpc.o: mc.h mc-parse.h mc-code.h mc-codegen.h
+mc-code-mips.o: /usr/include/stdio.h /usr/include/_types.h
+mc-code-mips.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
+mc-code-mips.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h mc.h
+mc-code-mips.o: mc-parse.h mc-code.h mc-codegen.h
--- a/mc-codegen.c	Sun Jan 15 22:32:17 2006 +0900
+++ b/mc-codegen.c	Sun Jan 15 22:40:23 2006 +0900
@@ -1528,13 +1528,9 @@
     }
 
     if (car(e2) == FNAME) {	
-	if (is_function(fnptr))
-	    code_fix_frame_pointer(disp_offset);
 	code_jmp(code0->nm);
     } else {
 	e2 = emit_pop(0);
-	if (is_function(fnptr))
-	    code_fix_frame_pointer(disp_offset);
 	code_indirect_jmp(e2);
 	emit_pop_free(e2);
     }
--- a/mc-parse.c	Sun Jan 15 22:32:17 2006 +0900
+++ b/mc-parse.c	Sun Jan 15 22:40:23 2006 +0900
@@ -1961,7 +1961,7 @@
 	inline_funcs = list2((int)n,inline_funcs);
 	inmode = 0;
     } else {
-#if 1
+#if 0
 	if (type_value(cadr(fnptr->ty))!=VOID) {
 	    if (control && !retpending && !pending_jmp) 
 		error(ENERR); // function has return value but reached to the end
--- a/test/throw.c	Sun Jan 15 22:32:17 2006 +0900
+++ b/test/throw.c	Sun Jan 15 22:40:23 2006 +0900
@@ -24,17 +24,17 @@
 throw1(interface1 arg,int i,int j)
 {
     printf("%d %d %d %d\n",arg.last,arg.a,arg.c[99],j);
-    arg.last=97;
-    goto throw2(arg,i,77);
+    arg.last=96;
+    goto throw2(arg,i,74);
 }
 
 code
 throw(interface1 arg,int i,int j)
 {
-    char *space = (char *)malloc(ENVSIZE)+ENVSIZE/2;
+    char *space = (char *)malloc(ENVSIZE)+ENVSIZE;
     printf("%d %d %d %d\n",arg.last,arg.a,arg.c[99],j);
-    arg.last=98;
-    goto throw1(arg,i,77),space;
+    arg.last=97;
+    goto throw1(arg,i,75),space;
 }
 
 void
@@ -58,7 +58,7 @@
     ret = return;
     env = environment;
 
-    goto throw(arg,1,0);
+    goto throw(arg,1,76);
 }
 
 int
@@ -67,19 +67,19 @@
     int dummy;
     int dummy1;
     interface1 arg;
-    char *space = (char *)malloc(ENVSIZE)+ENVSIZE/2;
+    char *space = (char *)malloc(ENVSIZE)+ENVSIZE;
 
     arg.a = 3;
     arg.b = 55;
     setup(&arg);
     arg.c[99] = 66;
-    arg.last=99;
+    arg.last=98;
 
     printf("main1\n");
     ret = return;
     env = environment;
 
-    goto throw1(arg,1,0),space;
+    goto throw1(arg,1,77),space;
 }
 
 int
@@ -87,7 +87,7 @@
 {
     int dummy;
     interface1 arg;
-    char *space = (char *)malloc(ENVSIZE)+ENVSIZE/2;
+    char *space = (char *)malloc(ENVSIZE)+ENVSIZE;
 
     arg.a = 3;
     arg.b = 55;
@@ -99,7 +99,7 @@
     ret = return;
     env = environment;
 
-    goto throw1(arg,1,0);
+    goto throw1(arg,1,78);
 }
 
 int
--- a/test/throw.code-out	Sun Jan 15 22:32:17 2006 +0900
+++ b/test/throw.code-out	Sun Jan 15 22:40:23 2006 +0900
@@ -1,7 +1,7 @@
 main0
-96 3 66 0
-98 3 66 77
+96 3 66 76
+97 3 66 75
 main1
-99 3 66 0
+98 3 66 77
 main2
-99 3 66 0
+99 3 66 78