changeset 775:a2a7b2835fa3

ia32 regression test
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 18 Nov 2010 21:25:30 +0900
parents 9f663c87b8eb
children d32ae7119cf1
files .gdbinit Makefile Makefile.ia32 mc-codegen.c test/int.c
diffstat 5 files changed, 43 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/.gdbinit	Thu Nov 18 20:01:00 2010 +0900
+++ b/.gdbinit	Thu Nov 18 21:25:30 2010 +0900
@@ -14,7 +14,7 @@
 end
 b errmsg
 # r -s test/tmp7.c
-r -s -DINLINE=inline test/tmp7.c
+# r -s -DINLINE=inline test/tmp7.c
 # r -s test/int.c
 # r -s test/tmp6.c
 # r -s test/call.c
@@ -28,6 +28,6 @@
 # r -s test/strinit.c
 # r -s test/arg.c
 # r -s test/putenemy.c
-# r -s -DINLINE=inline test/code-gen-all.c
+r -s -DINLINE=inline test/code-gen-all.c
 # r -s -DINLINE=inline test/strinit.c
 # r -s test/fact-a.c
--- a/Makefile	Thu Nov 18 20:01:00 2010 +0900
+++ b/Makefile	Thu Nov 18 21:25:30 2010 +0900
@@ -32,6 +32,9 @@
 ppc:
 	make ARCH=powerpc CCEXT="-arch ppc" check-all
 
+ia32:
+	make ARCH=ia32 CCEXT="-m32" check-all
+
 mc:   mc-$(ARCH)
 	cp mc-$(ARCH) mc
 
--- a/Makefile.ia32	Thu Nov 18 20:01:00 2010 +0900
+++ b/Makefile.ia32	Thu Nov 18 21:25:30 2010 +0900
@@ -1,4 +1,4 @@
-CC = gcc -std=c99 $(CCEXT)
+CC = gcc $(M) -std=c99 $(CCEXT)
 # -O3
 MCFLAGS = -DUSE_CODE_KEYWORD
 CFLAGS = -g -O -Wall -I. $(MCFLAGS)
@@ -9,7 +9,7 @@
 CFLAGS1 = -g -I.
 BASE=0
 STAGE=1
-MFLAGS=$(MFALGS) BASE=$(BASE) STAGE=$(STAGE)
+MFLAGS=$(MFALGS) BASE=$(BASE) STAGE=$(STAGE) M=$(M) 
 ARCH=ia32
 MC=mc-$(ARCH)
 MLIB = -lm
--- a/mc-codegen.c	Thu Nov 18 20:01:00 2010 +0900
+++ b/mc-codegen.c	Thu Nov 18 21:25:30 2010 +0900
@@ -2250,7 +2250,7 @@
 	case ULONGLONG: break;
 	default:
 	    if(integral(type)) e2 = list3(CONV,rvalue(e2),I2LL);
-            if(lp64);
+            else if(lp64);
 	    else { error(TYERR); e2 = llist2(LCONST,0LL); }
 	}
     }
@@ -2286,7 +2286,7 @@
 	case ULONGLONG: break;
 	default:
 	    if(integral(type)) e2 = list3(CONV,rvalue(e2),I2ULL);
-            if(lp64);
+            else if(lp64);
 	    else { error(TYERR); e2 = llist2(LCONST,0LL); }
 	}
     }
@@ -3634,6 +3634,31 @@
 //
 // generate constant on global memory
 //
+static int
+emit_name(int e,NMTBL *n) 
+{
+	switch(car(e)) {
+	case CONST:
+	    emit_int(cadr(e));
+	    return 1;
+	case ADDRESS:
+	    if (car(cadr(e))==GVAR)
+		emit_address((ncaddr(cadr(e)))->nm,cadr(cadr(e)));
+	    else error(INERR);
+	    return 1;
+	case FNAME:
+	    emit_address((ncaddr(e))->nm,0);
+	    return 1;
+	case GVAR:
+	    emit_address((ncaddr(e))->nm,0);
+	    return 1;
+	case STRING:
+	    emit_string((ncaddr(e))->nm,n->ty);
+	    return 1;
+	}
+    // if (lsrc)fprintf(stderr,"## type= %d\n",t);
+	return 0;
+}
 
 static void
 emit_data(int e, int t, NMTBL *n)
@@ -3671,6 +3696,13 @@
 	emit_float(e);
 	data_alignment++;
 	return;
+    case LONGLONG: case ULONGLONG:
+	if (!(car(e)!=LCONST&&car(e)!=CONST)) {
+	    emit_longlong(e); 
+	    return;
+	}
+	if (lp64 && emit_name(e,n)) return;
+	break;
     default:
 	if (t<0) error(-1);
 	if (car(t)==BIT_FIELD) {
@@ -3679,34 +3711,9 @@
 	    return;
 	}
 	if (car(t)!=POINTER&&car(t)!=ARRAY) error(-1);
-    case LONGLONG: case ULONGLONG:
-	if (!(car(e)!=LCONST&&car(e)!=CONST)) {
-	    emit_longlong(e); 
-	    return;
-	}
-	if (!lp64) error(INERR);
     case INT: case UNSIGNED:   /* including address case */
     case ENUM:
-	switch(car(e)) {
-	case CONST:
-	    emit_int(cadr(e));
-	    return;
-	case ADDRESS:
-	    if (car(cadr(e))==GVAR)
-		emit_address((ncaddr(cadr(e)))->nm,cadr(cadr(e)));
-	    else error(INERR);
-	    return;
-	case FNAME:
-	    emit_address((ncaddr(e))->nm,0);
-	    return;
-	case GVAR:
-	    emit_address((ncaddr(e))->nm,0);
-	    return;
-	case STRING:
-	    emit_string((ncaddr(e))->nm,n->ty);
-	    return;
-	}
-    // if (lsrc)fprintf(stderr,"## type= %d\n",t);
+	if (emit_name(e,n)) return;
     }
     error(INERR);
 }
--- a/test/int.c	Thu Nov 18 20:01:00 2010 +0900
+++ b/test/int.c	Thu Nov 18 21:25:30 2010 +0900
@@ -180,7 +180,7 @@
     g1 = g>>f;
     printf("#0180:>> %d:%d\t",n++,g1);
     g = g%g1;
-    printf("#0182:% %d:%d\t",n++,g);
+    printf("#0182:%% %d:%d\t",n++,g);
     g = g|g1;
     printf("#0184:| %d:%d\t",n++,g);
     g = g&g1;