changeset 714:5fad4649bed8

*** empty log message ***
author kono
date Sun, 11 Nov 2007 20:11:35 +0900
parents 88e364604533
children 83e18db76c96
files Changes Makefile mc-code-ia32.c mc-macro.c mc-parse.c mc-parse.h test/switch.c
diffstat 7 files changed, 50 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/Changes	Mon Oct 29 17:26:43 2007 +0900
+++ b/Changes	Sun Nov 11 20:11:35 2007 +0900
@@ -9650,3 +9650,13 @@
 
 けっこう、スムースだな... macro のと、ST_DECL あたりに、
 なんか残っているらしい。
+
+Thu Nov  8 21:16:12 JST 2007
+
+switch 文が const で inline された時の処理が間違っているようだ....
+
+
+
+
+
+
--- a/Makefile	Mon Oct 29 17:26:43 2007 +0900
+++ b/Makefile	Sun Nov 11 20:11:35 2007 +0900
@@ -31,14 +31,6 @@
 mc:   mc-$(ARCH)
 	cp mc-$(ARCH) mc
 
-TAGS:
-	ctags mc-code-*.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 :conv/conv.h mc-include.c mc-code-powerpc.o $(COMPLIB) $(CONVERTER)
 	$(CC) $(LDFLAGS) -g mc-code-powerpc.o $(COMPLIB) $(CONVERTER) -o $@
 
@@ -206,7 +198,9 @@
 
 tags-$(ARCH):  
 	ctags mc.h mc-code.h mc-code-$(ARCH).c  mc-codegen.c mc-codegen.h \
-		mc-parse.c mc-tree.c \
+		mc-parse.h mc-tree.c mc-inline.h mc-switch.h \
+		mc-parse.c mc-tree.c mc-inline.c mc-switch.c \
+		mc-macro.h mc-macro.c \
 	    conv/c.c conv/c.h \
 	    conv/conv.h conv/convdef.h 
 
@@ -225,7 +219,7 @@
                 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 mc-include.c
+	-rm -f mc mc-spu 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 mc-include.c
 
 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)
--- a/mc-code-ia32.c	Mon Oct 29 17:26:43 2007 +0900
+++ b/mc-code-ia32.c	Sun Nov 11 20:11:35 2007 +0900
@@ -1729,38 +1729,44 @@
 {
     if(scalar(t)) {
         if (mode==AS_SAVE) {
+	    if (parse_mode)
+		return get_register_var(0);
 	    return list3n(LVAR,new_lvar(size(t)),0);
-            // return get_register_var(0);
         } else 
             return list3n(LVAR,caller_arg_offset_v(nargs),0);
     } else if (t==LONGLONG||t==ULONGLONG) {
         if (mode==AS_SAVE) {
+	    if (parse_mode)
+		return get_lregister_var(0);
 	    return list3n(LVAR,new_lvar(size(t)),0);
-            // return get_lregister_var(0);
         } else 
             return list3n(LVAR,caller_arg_offset_v(nargs),0);
     } else if (t==FLOAT) {
         if (mode==AS_SAVE) {
+	    if (parse_mode)
+		return get_dregister_var(0,0);
 	    return list3n(LVAR,new_lvar(size(t)),0);
-            // return get_dregister_var(0,0);
         } else
             return list3n(LVAR,caller_arg_offset_v(nargs),0);
     } else if (t==DOUBLE) {
         if (mode==AS_SAVE) {
+	    if (parse_mode)
+		return get_dregister_var(0,1);
 	    return list3n(LVAR,new_lvar(size(t)),0);
-            // return get_dregister_var(0,1);
         } else
             return list3n(LVAR,caller_arg_offset_v(nargs),0);
     } else if (t>=0&&(car(t)==STRUCT||car(t)==UNION)) {
         if (mode==AS_SAVE) {
+	    if (parse_mode)
+		return get_register_var(0);
 	    return list3n(LVAR,new_lvar(size(t)),0);
-            // return get_register_var(0);
         } else
             return list3n(LVAR,caller_arg_offset_v(nargs),0);
     } else {
         error(-1);
+	if (parse_mode)
+	    return get_register_var(0);
 	return list3n(LVAR,new_lvar(size(t)),0);
-        // return get_register_var(0);
     }
 }
 
--- a/mc-macro.c	Mon Oct 29 17:26:43 2007 +0900
+++ b/mc-macro.c	Sun Nov 11 20:11:35 2007 +0900
@@ -394,7 +394,8 @@
 
 	*chptr = '\0';
 	if (lsrc && !asmf && !macro_if_skip && linebuf[0]) {
-	    gen_comment(linebuf);  // #if ed line will not be commented
+	    if (!inmode)
+		gen_comment(linebuf);  // #if ed line will not be commented
 	    if (inmode) {
 		// inline mode 
 
--- a/mc-parse.c	Mon Oct 29 17:26:43 2007 +0900
+++ b/mc-parse.c	Sun Nov 11 20:11:35 2007 +0900
@@ -46,7 +46,7 @@
 extern double strtod(const char *nptr, char **endptr);
 #endif
 
-static int parse_mode = 1; // generate parse tree for all code
+int parse_mode = 1; // generate parse tree for all code
 
 static int HEAP_REPORT = 0;
 static int lfree_type_limit;     // debugging purpose
@@ -4563,21 +4563,28 @@
     char *p,*q,*from,*to;
     int i;
     if (cheap->ptr >= cheap->last-1) {
+	// running out of cheap area
 	if (!cheap->next) { 
+	    // no previously freed cheap create new one
 	    cheap->next = new_cheap();
 	}
 	if (save) {
+	    // string in cheap have to be continuous.
+	    // prepare move from old cheap
 	    cheap->ptr = from = *save;
 	    i = cheap->last - from;
 	    to   = *save = cheap->next->first;
-	    if (i>CHEAPSIZE) error(NMERR);
+	    if (i>CHEAPSIZE) error(NMERR); // a string is larger than cheap size
 	    if (to<=chptr && chptr<=to+i) {
+		// we are going to destory the line just we are
+		// reading... move reading line to the next cheap
 		if (!cheap->next->next) { 
 		    cheap->next->next = new_cheap();
 		}
 		q = chptr;
 		p = chptr = cheap->next->next->ptr;
 		while((*p++ = *q++));
+		// now save to move overflowed string
 	    }
 	    while(i-->0) {
 		*to++ = *from++;
@@ -4604,6 +4611,7 @@
 reset_cheap(struct cheap *scheap)
 {
     // go back to the kept curret cheap pointer
+    //   (should be while loop
     if (cheap==scheap->next) {
 	cheap->ptr = scheap->ptr;
     } else {
@@ -4636,6 +4644,7 @@
 
     eptr = iptr= &htable[hash % GSYMS];
     for(i=0;(hptr=*iptr) && hptr->sc!=0 && neqnamel(hptr->nm,name,len);i++) {
+	// open hash
 	if (++iptr== &htable[GSYMS])
 	    iptr=&htable[0];
 	if (eptr==iptr) error(GSERR);
@@ -4701,6 +4710,7 @@
 
 /*
      All strings are kept in hash table, and shared.
+          float/long long should be shared too.
  */
 static void
 getstring(void)
--- a/mc-parse.h	Mon Oct 29 17:26:43 2007 +0900
+++ b/mc-parse.h	Sun Nov 11 20:11:35 2007 +0900
@@ -97,6 +97,7 @@
 /* used in mc-code-* */
 
 extern  NMTBL null_nptr;
+extern  int parse_mode;
 
 extern char * make_filename_with_extension(char *filename,char *ext);
 
--- a/test/switch.c	Mon Oct 29 17:26:43 2007 +0900
+++ b/test/switch.c	Sun Nov 11 20:11:35 2007 +0900
@@ -5,7 +5,7 @@
 #endif
 
 INLINE void
-main1(int i)
+main1(const int i)
 {
    switch(i) {
 case 19: printf("#0024:case 1 19\n"); break;
@@ -392,7 +392,7 @@
    }
 }
 INLINE void
-main2(int i)
+main2(const int i)
 {
    switch(i) {
 case -205: printf("#0411:case 2 -205\n"); break;
@@ -720,7 +720,7 @@
    }
 }
 INLINE void
-main3(int i)
+main3(const int i)
 {
    switch(i) {
 case -223: printf("#0739:case 3 -223\n"); break;
@@ -1111,7 +1111,7 @@
    }
 }
 INLINE void
-main4(int i)
+main4(const int i)
 {
    switch(i) {
 /*
@@ -1244,6 +1244,11 @@
 main(int ac,char *av[])
 {
     int i;
+	main1(15);
+	main2(16);
+	main3(17);
+	main4(19);
+	main5(19);
     for(i=-1000;i<3000;i++) {
 	main1(i);
 	main2(i);