diff mc-nop-386.c @ 46:b1c8ac8c308d

fix cascading struct retrun. Now it should be compatible with gcc calling sequence.
author kono
date Sat, 15 Feb 2003 17:54:30 +0900
parents b9266c88495c
children f6b5e4f1a962
line wrap: on
line diff
--- a/mc-nop-386.c	Thu Feb 13 22:14:21 2003 +0900
+++ b/mc-nop-386.c	Sat Feb 15 17:54:30 2003 +0900
@@ -913,22 +913,30 @@
     if (register_full()) {
 	/* this is wrong assumption */
 	save = 1;
-	for(lreg=0;lreg!=creg&&lreg!=dreg;lreg++);
+	for(lreg=0;lreg==creg||lreg==dreg;lreg++);
 	printf("\tpushl %s\n",register_name(lreg,0));
-	xreg = lreg;
+	xreg = lreg; regv[xreg]=0;
     } else {
 	save=0;
 	xreg = get_register();
     }
-    printf("\tmovl %%esp,%s\n",register_name(xreg,0));
+    if (save) 
+	printf("\tlea %d(%%esp),%s\n",size_of_int,register_name(xreg,0));
+    else
+	printf("\tmovl %%esp,%s\n",register_name(xreg,0));
     regv[xreg]=1;
     emit_copy(creg,xreg,length,0);
-    /* we have value in creg */
+    /* we have value in creg, it may be changed */
     if (save) {
-	printf("\tpopl %s\n",register_name(lreg,0));
+	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;
     } else
 	free_register(xreg);
-    regv[xreg]=0;
     return length/size_of_int;
 }