changeset 686:7e0c5c1f1e97

IA32 arg evaluation order
author kono
date Fri, 05 Oct 2007 16:43:53 +0900
parents 3e3cf02297e4
children 1ed8cb78cf9b
files mc-code-ia32.c
diffstat 1 files changed, 38 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mc-code-ia32.c	Fri Oct 05 16:06:41 2007 +0900
+++ b/mc-code-ia32.c	Fri Oct 05 16:43:53 2007 +0900
@@ -1663,12 +1663,23 @@
 
 #define caller_arg_offset_v(arg) (ARG_LVAR_OFFSET+(arg)*SIZE_OF_INT)
 
+#define ARG_ORDER 1
+#if (ARG_ORDER==1)
+
+static int delayed_arg;
+
+#endif
+
 static int
 compute_complex_arg(int e3,int reg_arg_list,int arg) {
     int t=caddr(e3);
     int e4 = car(e3);
     reg_arg_list = list2(arg,reg_arg_list);
+#if ARG_ORDER==1
+    delayed_arg = list2(assign_expr0(arg,e4,t,t),delayed_arg);
+#else
     g_expr_u(assign_expr0(arg,e4,t,t));
+#endif
 
 
 
@@ -1771,6 +1782,10 @@
     int pnargs,preg_arg,pfreg_arg;
     int stargs;
     int half_register = 0;
+#if (ARG_ORDER==1)
+    int save_delayed_arg = delayed_arg;
+    delayed_arg = 0;
+#endif
 
     special_lvar = -1;
     ret_type = function_type(cadddr(e1),&dots);
@@ -1823,7 +1838,13 @@
                     // Calculate complex struct address here.
                     // If simple, leave it.
                     arg = get_register_var(0);
+#if ARG_ORDER==1
+		    delayed_arg = list2(
+			assign_expr0(arg,list2(ADDRESS,car(e3)),INT,INT),
+			delayed_arg);
+#else
                     g_expr_u(assign_expr0(arg,list2(ADDRESS,car(e3)),INT,INT));
+#endif
                     car(e3)=arg;
                     reg_arg_list = list2(arg,reg_arg_list);
 
@@ -1834,6 +1855,16 @@
         }
         increment_function_arg(e3,&nargs,&reg_arg,&freg_arg);
     }
+#if (ARG_ORDER==1)
+    if (complex_) {
+	arg = get_input_arg(caddr(complex_),AS_SAVE,
+				pnargs,preg_arg,pfreg_arg);
+	reg_arg_list = compute_complex_arg(complex_,reg_arg_list,arg);
+    }
+    for(;delayed_arg;delayed_arg = cadr(delayed_arg)) {
+	g_expr_u(car(delayed_arg));
+    }
+#endif
 
     /* now all input register vars are free */
     code_save_stacks();
@@ -1849,11 +1880,13 @@
     //  complex_.
 
     if (stargs) {
+#if (ARG_ORDER!=1)
         if (complex_) {
             arg = get_input_arg(caddr(complex_),AS_SAVE,
                                     pnargs,preg_arg,pfreg_arg);
             reg_arg_list = compute_complex_arg(complex_,reg_arg_list,arg);
         }
+#endif
         for(stargs=reverse0(stargs);stargs;stargs = cadr(stargs)) {
             e3 = car(stargs);
             e4 = car(e3);
@@ -1864,6 +1897,7 @@
 
 
         }
+#if (ARG_ORDER!=1)
     } else {
         //  last complex argument can use input register
         if (complex_) {
@@ -1875,6 +1909,7 @@
 
 
         }
+#endif
     }
 
     nargs = reg_arg = freg_arg = 0;
@@ -1913,6 +1948,9 @@
         else
             set_ireg(CREG_REGISTER,0);
     }
+#if (ARG_ORDER==1)
+    delayed_arg = save_delayed_arg;
+#endif
     return ret_type;
 }