diff mc-code-ia32.c @ 168:b1297c82e926 cpost-removal

cpostinc removal
author kono
date Mon, 24 Nov 2003 19:14:45 +0900
parents 0197ca125567
children 3b33c7daae95
line wrap: on
line diff
--- a/mc-code-ia32.c	Mon Nov 24 13:47:21 2003 +0900
+++ b/mc-code-ia32.c	Mon Nov 24 19:14:45 2003 +0900
@@ -191,7 +191,7 @@
     } else if (byte==size_of_short && rname[i] <= REG_EDX) {
 	return reg_name_w[rname[i]];
     } else {
-	return reg_name[rname[i]]; /* should be error */
+	return reg_name[rname[i]]; /* 0 or 4 means int */
     }
 }
 
@@ -617,105 +617,39 @@
 }
 
 void
-code_preinc(int e1,int e2,int reg) {
+code_preinc(int e1,int e2,int dir,int sign,int sz,int reg) {
     char *xrn;
     if (car(e2)==REGISTER) {
-	printf("\taddl $%d,%s\n",caddr(e1),register_name(cadr(e2),0));
+	printf("\taddl $%d,%s\n",dir,register_name(cadr(e2),0));
 	printf("\tmovl %s,%s\n",register_name(cadr(e2),0),register_name(reg,0));
 	regv[reg]=1;
 	return;
     } 
     g_expr(e2);
     xrn = register_name(creg,0);
-    printf("\taddl $%d,(%s)\n",caddr(e1),xrn);
-    printf("\tmovl (%s),%s\n",xrn,xrn);
+    printf("\t%s $%d,(%s)\n",(sz==1)?"addb":(sz==size_of_short)?"addw":"addl",dir,xrn);
+    printf("\t%s (%s),%s\n",cload(sign,sz),xrn,register_name(creg,0));
 }
 
 
 void
-code_postinc(int e1,int e2,int reg) {
+code_postinc(int e1,int e2,int dir,int sign,int sz,int reg) {
     char *xrn;
     if (car(e2)==REGISTER) {
 	printf("\tmovl %s,%s\n",register_name(cadr(e2),0),register_name(reg,0));
-	printf("\taddl $%d,%s\n",caddr(e1),register_name(cadr(e2),0));
+	printf("\taddl $%d,%s\n",dir,register_name(cadr(e2),0));
 	regv[reg]=1;
 	return;
     } 
     g_expr(e2);
     emit_push();  
     xrn = register_name((e2=emit_pop(0)),0);
-    printf("\tmovl (%s),%s\n",xrn,register_name(creg,0));
-    printf("\taddl $%d,(%s)\n",caddr(e1),xrn);
-    emit_pop_free(e2);
-}
-
-
-void
-code_cpostinc(int e1,int e2,int reg,int sign,int sz) {
-    char *xrn;
-    if (car(e2)==REGISTER) {
-	printf("\t%s (%s),%s\n",cload(sign,sz),register_name(cadr(e2),0),
-		register_name(reg,0));
-	printf("\taddl $%d,%s\n",caddr(e1),register_name(cadr(e2),0));
-	regv[reg]=1;
-	return;
-    } 
-    g_expr(e2);
-    emit_push();
-    xrn = register_name((e2=emit_pop(0)),1);
     printf("\t%s (%s),%s\n",cload(sign,sz),xrn,register_name(creg,0));
-    printf("\taddl $%d,(%s)\n",sz,xrn);
+    printf("\t%s $%d,(%s)\n",(sz==1)?"addb":(sz==size_of_short)?"addw":"addl",dir,xrn);
     emit_pop_free(e2);
 }
 
 
-void
-code_cpreinc(int e1,int e2,int reg,int sign,int sz) {
-    if (car(e2)==REGISTER) {
-	printf("\taddl $%d,%s\n",caddr(e1),register_name(cadr(e2),0));
-	printf("\t%s (%s),%s\n",cload(sign,sz),register_name(cadr(e2),0),
-		register_name(reg,0));
-	regv[reg]=1;
-	return;
-    } 
-    g_expr(e2);
-    printf("\taddl $%d,(%s)\n",sz,register_name(creg,0));
-    printf("\t%s (%s),%s\n",cload(sign,sz),register_name(creg,0),register_name(creg,0));
-}
-
-
-void
-code_cpostdec(int e1,int e2,int reg,int sign,int sz) {
-    if (car(e2)==REGISTER) {
-	printf("\t%s (%s),%s\n",cload(sign,sz),register_name(cadr(e2),0),
-		register_name(reg,0));
-	printf("\tsubl $%d,(%s)\n",sz,register_name(cadr(e2),0));
-	regv[reg]=1;
-	return;
-    } 
-    g_expr(e2);
-    printf("\t%s (%s),%s\n",sign?"movsbl":"movzbl",register_name(creg,0),register_name(creg,0));
-    printf("\tsubl $%d,(%s)\n",sz,register_name(creg,0));
-}
-
-
-void
-code_cpredec(int e1,int e2,int reg,int sign,int sz) {
-    if (car(e2)==REGISTER) {
-	printf("\tsubl $%d,(%s)\n",sz,register_name(cadr(e2),0));
-	printf("\t%s (%s),%s\n",cload(sign,sz),register_name(cadr(e2),0),
-		register_name(reg,0));
-	regv[reg]=1;
-	return;
-    } 
-    g_expr(e2);
-    emit_push();
-    e2 = emit_pop(0);
-    printf("\tsubl $%d,(%s)\n",sz,register_name(e2,0));
-    printf("\t%s (%s),%s\n",cload(sign,sz),register_name(e2,0),register_name(creg,0));
-    emit_pop_free(e2);
-}
-
 
 void
 code_return(int creg) {
@@ -1566,15 +1500,15 @@
 	data_mode(0);
     }
     if(car(e)==CONST) {       
-	if (t==CHAR) {
+	if (t==CHAR||t==UCHAR) {
 	    printf("\t.byte %d\n",cadr(e));
 	    if (data_alignment>0)
 		data_alignment++;
 	    gpc += 1;
-	} else if (t==SHORT) {
-	    printf("\t.word %d\n",cadr(e));
+	} else if (t==SHORT||t==USHORT) {
+	    printf("\t.short %d\n",cadr(e));
 	    if (data_alignment>0) data_alignment++;
-	    gpc += 2;
+	    gpc += size_of_short;
 	} else {
 	    printf("\t.long %d\n",cadr(e));
 	    gpc += size_of_int;
@@ -1603,7 +1537,7 @@
 	    }
 	    ascii((char *)cadr(e));
 	} else error(TYERR);
-    }
+    } else error(TYERR);
 }
 
 void