changeset 47:f6b5e4f1a962

*** empty log message ***
author kono
date Sat, 15 Feb 2003 18:19:27 +0900
parents b1c8ac8c308d
children 8575ec496cd4
files Idea mc-nop-386.c
diffstat 2 files changed, 19 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/Idea	Sat Feb 15 17:54:30 2003 +0900
+++ b/Idea	Sat Feb 15 18:19:27 2003 +0900
@@ -1525,3 +1525,6 @@
 び出すときにtypeを変更する必要がある。このrvalueのtype の扱
 いは、かなりはまったことがあるので、rvalue(int e,int type)の
 方が良いことは確かなんだが... 
+
+struct_push のregisterの扱いが複雑すぎ。なんか、もっと
+簡単にならないの?
--- a/mc-nop-386.c	Sat Feb 15 17:54:30 2003 +0900
+++ b/mc-nop-386.c	Sat Feb 15 18:19:27 2003 +0900
@@ -55,7 +55,7 @@
 static void tosop(int op,int reg);
 static void edx_cleanup();
 static void use_register(int virt, int real, int move);
-static void emit_copy(int from,int to,int length,int offset);
+static void emit_copy(int from,int to,int length,int offset,int value);
 
 extern int error(int n);
 extern int fwdlabel(void);
@@ -840,7 +840,7 @@
 #define MAX_COPY_LEN 20
 
 void 
-emit_copy(int from,int  to,int length,int offset)
+emit_copy(int from,int  to,int length,int offset,int value)
 {
     int fix = 0;
     if (length<=0) return;
@@ -861,11 +861,11 @@
     default:
 	if (length <=MAX_COPY_LEN) {
 	    for(;length>=4;length-=4,offset+=4)
-		emit_copy(from,to,4,offset);
+		emit_copy(from,to,4,offset,0);
 	    for(;length>=2;length-=2,offset+=2)
-		emit_copy(from,to,2,offset);
+		emit_copy(from,to,2,offset,0);
 	    if(length>0)
-		emit_copy(from,to,length,offset);
+		emit_copy(from,to,length,offset,0);
 	    break;
 	}
 	use_register(from,REG_ESI,1);
@@ -875,17 +875,19 @@
 	fix = (length/4)*4;
 	printf("\tcld\n\trep\n\tmovsl\n");
 	if(length%4) {
-	    emit_copy(from,to,length,offset+length/4);
+	    emit_copy(from,to,length,offset+length/4,0);
 	}
     }
+    if (value) {
     /* this code is necessary for the value of assignment or function call */
     /* otherwise we don't need this */
-    if (fix) printf("\tsubl $%d,%s\n",fix,register_name(to,0));
-    if(creg!=to) {
-	if (to==dreg) 
-	    printf("\tmovl %s,%s\n",register_name(to,0),register_name(creg,0));
-	else {
-	    free_register(creg); creg=to;
+	if (fix) printf("\tsubl $%d,%s\n",fix,register_name(to,0));
+	if(creg!=to) {
+	    if (to==dreg) 
+		printf("\tmovl %s,%s\n",register_name(to,0),register_name(creg,0));
+	    else {
+		free_register(creg); creg=to;
+	    }
 	}
     }
     regv[from]=regv[to]=regv[dreg]=0;
@@ -925,13 +927,11 @@
     else
 	printf("\tmovl %%esp,%s\n",register_name(xreg,0));
     regv[xreg]=1;
-    emit_copy(creg,xreg,length,0);
+    emit_copy(creg,xreg,length,0,0);
     /* we have value in creg, it may be changed */
     if (save) {
 	if(creg==xreg) {
 	    creg = get_register();   /* creg is freed in emit_copy */
-	    printf("\tmovl %s,%s\n",register_name(xreg,0),register_name(creg,0));
-	    regv[creg]=1;
 	}
 	printf("\tpopl %s\n",register_name(xreg,0));
 	regv[xreg]=1;
@@ -1255,7 +1255,7 @@
     emit_push();
     g_expr(e2);
     xreg = emit_pop(0);
-    emit_copy(xreg,creg,sz,0);
+    emit_copy(xreg,creg,sz,0,1);
     emit_pop_free(xreg);
     return;
 }