changeset 670:bce312f3c0cb

*** empty log message ***
author kono
date Wed, 02 May 2007 16:41:15 +0900
parents 1530b1a636ac
children 85e0509832f1
files .gdbinit mc-code-ia32.c
diffstat 2 files changed, 22 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/.gdbinit	Wed May 02 15:31:38 2007 +0900
+++ b/.gdbinit	Wed May 02 16:41:15 2007 +0900
@@ -13,5 +13,6 @@
 x/1i $eip
 end
 b errmsg
-r -s test/code-gen-all.c
+r -s test/tmp7.c
+# r -s test/code-gen-all.c
 # r -s mc-code-powerpc.c
--- a/mc-code-ia32.c	Wed May 02 15:31:38 2007 +0900
+++ b/mc-code-ia32.c	Wed May 02 16:41:15 2007 +0900
@@ -316,7 +316,7 @@
           arg2       12 4
             see enter/enter1/leave           see code_enter
  */
-static int arg_offset;
+// static int arg_offset;
 
 static int code_disp_label;
 
@@ -417,7 +417,7 @@
 #define arg_offset1  0
 #define ARG_LVAR_OFFSET 0x10000000
 
-#define code_disp_offset0 (0)
+#define code_disp_offset0 (-8)
 
 #define CODE_LVAR(l) ((l)+code_disp_offset0)
 #define CODE_CALLER_ARG(l) ((l)+arg_offset1)
@@ -454,19 +454,25 @@
  */
 
 void
-code_offset_set()
+code_offset_set(NMTBL *fnptr)
 {
 #if 0
     int l;
 #endif
+    int code_f = is_code(fnptr);
     int lvar_offsetv = 
         round16(-disp);
     int r1_offsetv = round16(lvar_offsetv+max_func_args*SIZE_OF_INT+func_disp_offset)+8;
-    //  +8 makes esp alignment 16
-//    printf(".set %s%d,%d\n",lpfx,lvar_offset_label,lvar_offsetv);
-    if (r1_offsetv-lvar_offsetv > 65000) error(-1);
-        // too large function arguments?
-    printf(".set %s%d,%d\n",lpfx,r1_offset_label,r1_offsetv);
+
+    if (code_f) {
+	printf("\t.set _%d,%d\n",code_disp_label,r1_offsetv);
+    } else {
+	//  +8 makes esp alignment 16
+    //    printf(".set %s%d,%d\n",lpfx,lvar_offset_label,lvar_offsetv);
+	if (r1_offsetv-lvar_offsetv > 65000) error(-1);
+	    // too large function arguments?
+	printf(".set %s%d,%d\n",lpfx,r1_offset_label,r1_offsetv);
+    }
     if (max_func_arg_label) {
         printf(".set %s%d,%d\n",lpfx,max_func_arg_label,
             round16(max_func_args*SIZE_OF_INT));
@@ -1644,6 +1650,7 @@
     // try small amount copy
     /* downward direction copy */
     emit_copy(dreg,creg,length,0,0,1);
+    emit_pop_free(dreg);
     /* we have value in creg, it may be changed */
     return length/SIZE_OF_INT;
 }
@@ -1769,7 +1776,7 @@
         fn=(NMTBL *)cadr(e2);
     } else {    
         if (car(e2)==INDIRECT) e2=cadr(e2); // (*func)(i) case
-        jmp = get_register_var(0);
+        jmp = list3(REGISTER,REG_EAX,0);
 
         if (!simple_arg(e2)) {
             e3=get_register_var(0);
@@ -1777,7 +1784,6 @@
             g_expr_u(assign_expr0(e3,e2,INT,INT));
             e2=e3;
         }
-        reg_arg_list = list2(jmp,reg_arg_list);
         arg_assign = list2(assign_expr0(jmp,e2,INT,INT),arg_assign);
     }
     /* First we execute complex argument to avoid interaction with
@@ -2396,9 +2402,9 @@
 code_enter1(int args)
 {
     code_disp_label=fwdlabel();
-    printf("\tlea _%d(%%ebp),%%esp\n",code_disp_label);
-
-    printf("## args %d disp %d  code_disp_offset=%d\n",args,disp,code_disp_offset); 
+    printf("\tlea -_%d(%%ebp),%%esp\n",code_disp_label);
+
+    // printf("## args %d disp %d  code_disp_offset=%d\n",args,disp,code_disp_offset); 
 #ifdef __APPLE__
     printf("\tcall\t___i686.get_pc_thunk.bx\n");
     printf("_%d:\n",labelno);
@@ -2411,13 +2417,7 @@
 void
 code_leave(char *name)
 {
-#ifdef __APPLE__
-    disp &= -(SIZE_OF_INT*4); // 16byte alignment
-    disp -= 4;
-#else
-    disp &= -SIZE_OF_INT;
-#endif
-    printf("\t.set _%d,%d\n",code_disp_label,disp+code_disp_offset-8);
+    code_offset_set(fnptr);
 #ifndef __APPLE__
     printf("_%d:\n",labelno);
     printf("\t.size\t%s,_%d-%s\n",name,labelno,name);