changeset 744:c9d4390b2b4e

i64 continue...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Fri, 12 Nov 2010 15:06:42 +0900
parents 78f57ff5c86e
children a396b346308a
files .gdbinit .gdbinit.i64 Makefile mc-code-i64.c mc-codegen.c mc-codegen.h
diffstat 6 files changed, 60 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/.gdbinit	Fri Nov 12 13:26:13 2010 +0900
+++ b/.gdbinit	Fri Nov 12 15:06:42 2010 +0900
@@ -1,6 +1,6 @@
 tb main
 define regs 
-call (void)printf("eax=%08x ebx=%08x ecx=%08x edx=%08x\nesi=%08x edi=%08x ebp=%08x esp=%08x eip=%08x\n",$eax,$ebx,$ecx,$edx,$esi,$edi,$ebp,$esp,$eip)
+call (void)printf("eax=%08lx ebx=%08lx ecx=%08lx edx=%08lx\nesi=%08lx edi=%08lx ebp=%08lx esp=%08lx eip=%08lx\n",$eax,$ebx,$ecx,$edx,$esi,$edi,$ebp,$esp,$eip)
 end
 define si
 stepi
@@ -18,10 +18,10 @@
 # r -s test/call.c
 # r -s test/static.c
 # r -s test/tmpa.c
-# r -s test/code-gen-all.c
+r -s test/code-gen-all.c
 # r -s mc-code-powerpc.c
 # r -s test/macro.c
-r -s test/basic.c
+# r -s test/basic.c
 # r -s test/strinit.c
 # r -s test/arg.c
 # r -s -DINLINE=inline test/strinit.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.gdbinit.i64	Fri Nov 12 15:06:42 2010 +0900
@@ -0,0 +1,28 @@
+tb main
+define regs 
+call (void)printf("eax=%08lx ebx=%08lx ecx=%08lx edx=%08lx\nesi=%08lx edi=%08lx ebp=%08lx esp=%08lx eip=%08lx\n",$eax,$ebx,$ecx,$edx,$esi,$edi,$ebp,$esp,$eip)
+end
+define si
+stepi
+regs
+x/1i $eip
+end
+define ni
+nexti
+regs
+x/1i $eip
+end
+b errmsg
+# r -s test/tmp7.c
+# r -s test/tmp6.c
+# r -s test/call.c
+# r -s test/static.c
+# r -s test/tmpa.c
+r -s test/code-gen-all.c
+# r -s mc-code-powerpc.c
+# r -s test/macro.c
+# r -s test/basic.c
+# r -s test/strinit.c
+# r -s test/arg.c
+# r -s -DINLINE=inline test/strinit.c
+# r -s test/fact-a.c
--- a/Makefile	Fri Nov 12 13:26:13 2010 +0900
+++ b/Makefile	Fri Nov 12 15:06:42 2010 +0900
@@ -1,7 +1,7 @@
 CC = gcc -std=c99 $(CCEXT) $(M)
 # -O3
-MCFLAGS = -DUSE_CODE_KEYWORD
-CFLAGS = -g -O -Wall -I. $(MCFLAGS)
+# MCFLAGS = -DUSE_CODE_KEYWORD
+CFLAGS = -g -Wall -I. $(MCFLAGS) # -O
 # CFLAGS = -g -Wall -I. -pg -fprofile-arcs -ftest-coverage
 # LDFLAGS = -pg
 # for Linux Zaurus
--- a/mc-code-i64.c	Fri Nov 12 13:26:13 2010 +0900
+++ b/mc-code-i64.c	Fri Nov 12 15:06:42 2010 +0900
@@ -2302,7 +2302,9 @@
 code_drindirect(int e1, int reg,int offset, int d)
 {
     g_expr(e1);
-    printf("\t%s %d(%s),%s\n",fload(d),offset,register_name(creg,0),register_name(reg,0));
+    int p = creg;
+    use_float(d,reg);
+    printf("\t%s %d(%s),%s\n",fload(d),offset,register_name(p,0),fregister_name(reg));
     return DOUBLE;
 }
 #endif
@@ -2439,7 +2441,7 @@
         oreg = ox;
     }
 
-    switch(op) {
+    switch(OP(op)) {
     case LSHIFT:
     case ULSHIFT:
 	shift(sz<=SIZE_OF_INT?"sall":"salq",oreg,reg);
@@ -2500,14 +2502,16 @@
 	    printf((op==DIV||op==MOD)?
 		"\tcltd\n\tidivl %s\n":
 		"\txorl %%edx,%%edx\n\tdivl %s\n",orn);
+	    set_ireg((op==MOD||op==UMOD)?REG_EDX:REG_EAX,0);
+	    set_ireg(reg,1);
         } else {
 	    orn = register_name(oreg,0);
-	    printf((op==DIV||op==MOD)?
+	    printf((op==LDIV||op==LMOD)?
 		"\tcltq\n\tidivq %s\n":
 		"\txorl %%edx,%%edx\n\tdivq %s\n",orn);
+	    set_lreg((op==LMOD||op==LUMOD)?REG_EDX:REG_EAX,0);
+	    set_lreg(reg,1);
         }
-	set_ireg((op==MOD||op==UMOD)?REG_EDX:REG_EAX,0);
-	set_ireg(reg,1);
 	break;
     }
     if(ox && ox!=ireg) free_register(ox);
@@ -2543,7 +2547,7 @@
 
     datareg=is_data_reg(reg);
 
-    switch(op) {
+    switch(OP(op)) {
     case LSHIFT:
     case ULSHIFT:
 	printf("\tsal%s $%ld,%s\n",q,orn,crn);
@@ -3922,8 +3926,8 @@
 int
 lrexpr(int e1, int e2,int l1, int op,int cond)
 {
-    g_expr(list3(LCMP,cadr(e1),caddr(e1)));
-    printf("\tj%s\t_%d\n",code_cond(car(e1),cond),l1);
+    g_expr(list3(LCMP,e1,e2));
+    printf("\tj%s\t_%d\n",code_cond(op,cond),l1);
     return l1;
 }
 
@@ -4076,11 +4080,13 @@
 
 void code_i2ull(int reg)
 {
+    use_longlong(reg);
     code_i2ll(reg);
 }
 
 void code_u2ll(int reg)
 {
+    use_longlong(reg);
     printf("\tmovslq %s,%s",register_name(reg,SIZE_OF_INT),register_name(reg,0));
     //printf("\tshlq $32,%s",regisnter_name(reg,0));
     //printf("\tshrq $32,%s",regisnter_name(reg,0));
@@ -4088,58 +4094,62 @@
 
 void code_u2ull(int reg)
 {
+    use_longlong(reg);
     code_u2ll(reg);
 }
 
 void code_ll2i(int reg)
 {
+    use_longlong(reg);
 }
 
 void code_ll2u(int reg)
 {
+    use_longlong(reg);
 }
 
 void code_ull2i(int reg)
 {
+    use_longlong(reg);
 }
 
 void code_ull2u(int reg)
 {
+    use_longlong(reg);
 }
 
 #if FLOAT_CODE
 void code_d2ll(int reg)
 {
-    char *f = register_name(reg,0);
+    char *f = fregister_name(reg);
     use_longlong(reg);
     printf("\tcvttsd2siq      %s,%s\n",f,register_name(reg,0));
 }
 
 void code_d2ull(int reg)
 {
-    char *f = register_name(reg,0);
+    char *f = fregister_name(reg);
     use_longlong(reg);
     printf("\tcvttsd2siq      %s,%s\n",f,register_name(reg,0));
-    use_longlong(reg);
 }
 
 void code_f2ll(int reg)
 {
-    char *f = register_name(reg,0);
+    char *f = fregister_name(reg);
     use_longlong(reg);
     printf("\tcvttss2siq      %s,%s\n",f,register_name(reg,0));
 }
 
 void code_f2ull(int reg)
 {
-    char *f = register_name(reg,0);
+    char *f = fregister_name(reg);
     use_longlong(reg);
     printf("\tcvttss2siq      %s,%s\n",f,register_name(reg,0));
 }
 
 void code_ll2d(int reg)
 {
-    char *f = register_name(reg,0);
+    char *f = fregister_name(reg);
     use_float(1,reg);
     printf("\tcvtsi2sdq      %s,%s\n",f,register_name(reg,0));
 }
--- a/mc-codegen.c	Fri Nov 12 13:26:13 2010 +0900
+++ b/mc-codegen.c	Fri Nov 12 15:06:42 2010 +0900
@@ -2200,6 +2200,7 @@
 	case ULONGLONG: break;
 	default:
 	    if(integral(type)) e2 = list3(CONV,rvalue(e2),I2LL);
+            if(lp64);
 	    else { error(TYERR); e2 = llist2(LCONST,0LL); }
 	}
     }
@@ -2228,6 +2229,7 @@
 	case ULONGLONG: break;
 	default:
 	    if(integral(type)) e2 = list3(CONV,rvalue(e2),I2ULL);
+            if(lp64);
 	    else { error(TYERR); e2 = llist2(LCONST,0LL); }
 	}
     }
--- a/mc-codegen.h	Fri Nov 12 13:26:13 2010 +0900
+++ b/mc-codegen.h	Fri Nov 12 15:06:42 2010 +0900
@@ -36,6 +36,7 @@
 extern int bit_of_byte;
 extern int endian;
 extern int struct_align;
+extern int lp64;
 
 
 #define USE_CREG (-1)