diff mc-code-ia32.c @ 128:d497c39add36 args-works

arg.c works (?)
author kono
date Thu, 03 Apr 2003 03:04:16 +0900
parents eb4d8975926c
children 7d436c08e949
line wrap: on
line diff
--- a/mc-code-ia32.c	Tue Apr 01 10:31:40 2003 +0900
+++ b/mc-code-ia32.c	Thu Apr 03 03:04:16 2003 +0900
@@ -35,13 +35,13 @@
 int MAX_CODE_INPUT_DREGISTER_VAR = 0;
 
 /*
-                                           -16  -8 local2
-                                           -12  -4 local1
-                                            -8  8  arg3
-                                            -4  4  arg2
-                                             0  0  arg1
-         local2     -20 4                    0    (%edi)
-         local1 <-- -16 0 local variable     0    (%esi)
+                                           -28  -8 local2
+                                           -24  -4 local1
+                                           -20  8  arg3
+                                           -16  4  arg2
+                                           -12  0  arg1
+         local2     -20 4                   -8    (%edi)
+         local1 <-- -16 0 local variable    -4    (%esi)
         %edi        -12  <- disp_offset          %ebp
         %esi         -8
         %ebx         -4
@@ -1392,20 +1392,31 @@
 void
 leave(int control, char *name)
 {
+    int sz;
+
+    disp &= -size_of_int;
     if (control)
         code_set_return_register(1);
     if (retcont) {
 	if (control)
 	    jmp(retlabel);
 	fwddef(retcont);
-	use_register(creg,REG_EAX,0);
-	printf("\tmovl %s,%s\n",reg_name[REG_ESI],register_name(creg,0));
-	/* printf("\tleave\n"); */
+        if (cadr(fnptr->ty)==FLOAT||cadr(fnptr->ty)==DOUBLE) {
+	    printf("\tfldl %d(%%ebp)\n",-size_of_double);
+        } else if (cadr(fnptr->ty)>0&&(
+            car(cadr(fnptr->ty))==STRUCT ||
+            car(cadr(fnptr->ty))==UNION)) {
+            sz = size(cadr(fnptr->ty));
+            printf("\tlea %d(%%ebp),%s\n",-sz,register_name(dreg,0));
+            printf("\tmovl %d(%%ebp),%s\n",disp-size_of_int,
+		register_name(creg,0));
+            emit_copy(dreg,creg,sz,0,1,1);
+        } else if (cadr(fnptr->ty)!=VOID) {
+	    use_register(creg,REG_EAX,0);
+	    printf("\tmovl %s,%s\n",reg_name[REG_ESI],register_name(creg,0));
+        }
     }
     fwddef(retlabel);
-    /* use_register(creg,REG_EAX,0); too late */
-    /* if(disp) printf("\taddl $%d,%%esp\n",-disp);  */
-    disp &= -size_of_int;
 
     printf("\tlea %d(%%ebp),%%esp\n",disp_offset);
     printf("\tpopl %%edi\n");