changeset 121:00df510bc116

*** empty log message ***
author kono
date Sun, 23 Mar 2003 23:10:48 +0900
parents 099518ea9cc1
children b884271bcab2
files mc-code-powerpc.c
diffstat 1 files changed, 35 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/mc-code-powerpc.c	Sun Mar 23 20:48:36 2003 +0900
+++ b/mc-code-powerpc.c	Sun Mar 23 23:10:48 2003 +0900
@@ -113,6 +113,7 @@
 static void    set_freg(int,int);
 
 int max_func_args;
+int my_func_args;
 #define ARG_LVAR_OFFSET 0x10000000
 
 /*
@@ -149,26 +150,41 @@
                           reg_save      disp       max_func_args*size_of_int
         lvar>0                         lvar<0       lvar>0x1000 0000
  */
-int arg_offset = 44; int arg_offset1 = 24;
-int disp_offset = 0;
+int arg_offset = 44; int arg_offset1 = 24; int disp_offset = -12;
 #define r1_offset 60 
 #define func_disp_offset (r1_offset-12)
-int code_disp_offset = 0;
-int jump_offset = 0;
+int code_disp_offset = 0; int jump_offset = 0;
+#define CODE_LVAR l+code_disp_offset
+#define FUNC_LVAR l+disp_offset
+#define CALLER_ARG (l-ARG_LVAR_OFFSET)+arg_offset1
+#define CALLEE_ARG l+arg_offset
 
 void
 code_offset_set()
 {
-    printf(".set L_%d,%d\n",lvar_offset_label,
-	-(disp-max_func_args*size_of_int-func_disp_offset));
-    printf(".set L_%d,%d\n",r1_offset_label,
-	-(disp-max_func_args*size_of_int+reg_save-r1_offset));
+    int l;
+    int lvar_offsetv = -disp+max_func_args*size_of_int+func_disp_offset;
+    int r1_offsetv = -disp+max_func_args*size_of_int-reg_save+r1_offset;
+    printf(".set L_%d,%d\n",lvar_offset_label,lvar_offsetv);
+    printf(".set L_%d,%d\n",r1_offset_label,r1_offsetv);
+printf("# function %s\n",fnptr->nm);
+    l = ARG_LVAR_OFFSET;
+printf("# offset call0\t%d\n",CALLER_ARG);
+    l = ARG_LVAR_OFFSET+max_func_args*size_of_int;
+printf("# offset calln\t%d\n",CALLER_ARG);
+    l = disp;
+printf("# offset lvarn\t%d\n",FUNC_LVAR+lvar_offsetv);
+    l = 0;
+printf("# offset lvar0\t%d\n",FUNC_LVAR+lvar_offsetv);
+    l = -reg_save;
+printf("# offset regs\t%d\n",FUNC_LVAR+lvar_offsetv);
+printf("# offset r1off\t%d\n",r1_offsetv);
+    l = 0;
+printf("# offset carg0\t%d\n",CALLEE_ARG+r1_offsetv);
+    l = my_func_args;
+printf("# offset cargn\t%d\n",CALLEE_ARG+r1_offsetv);
 }
 
-#define CODE_LVAR l+code_disp_offset
-#define FUNC_LVAR l+disp_offset
-#define CALLER_ARG (l-ARG_LVAR_OFFSET)+arg_offset1
-#define CALLEE_ARG l+arg_offset
 
 static void
 lvar8(int l)
@@ -180,7 +196,7 @@
     } else if (l>ARG_LVAR_OFFSET) {  /* caller's arguments */
 	printf("lo16(%d)(r30)\n",CALLER_ARG);
     } else { /* callee's arguments */
-	printf("lo16(%d+L_%d)(r30)\n",CALLEE_ARG,lvar_offset_label);
+	printf("lo16(%d+L_%d)(r30)\n",CALLEE_ARG,r1_offset_label);
     }
 }
 
@@ -204,7 +220,7 @@
 	if (CALLER_ARG>32765)
 	    printf("la r0,ha16(%d)(r30)\n",CALLER_ARG);
     } else { /* callee's arguments */
-	printf("la r0,ha16(%d+L_%d)(r30)\n",CALLEE_ARG,lvar_offset_label);
+	printf("la r0,ha16(%d+L_%d)(r30)\n",CALLEE_ARG,r1_offset_label);
     }
 }
 
@@ -221,7 +237,7 @@
 	else
 	    printf("lo16(%d)(r30)\n",CALLER_ARG);
     } else { /* callee's arguments */
-	printf("lo16(%d+L_%d)(r0)\n",CALLEE_ARG,lvar_offset_label);
+	printf("lo16(%d+L_%d)(r0)\n",CALLEE_ARG,r1_offset_label);
     }
 }
 
@@ -1200,6 +1216,7 @@
 	    free_fregister(reg);
 	}
     }
+    my_func_args = 0;
 #else
     int args;
     NMTBL *n;
@@ -1226,8 +1243,8 @@
 	    /* fregs[reg]==INPUT_REG case should be considered */
 	    n->dsp = offset;
 	    t = n->ty;
-	    if(t==FLOAT) { offset+=1; reg_offset+=1; }
-	    else if(t==DOUBLE) { offset+=2; reg_offset+=2; }
+	    if(t==FLOAT) { offset+=size_of_float; reg_offset+=1; }
+	    else if(t==DOUBLE) { offset+=size_of_double; reg_offset+=2; }
 	    else error(-1);
 	} else 
 	    continue;
@@ -1240,6 +1257,7 @@
 	    free_fregister(reg);
 	}
     }
+    my_func_args = offset;
 #endif
 }