changeset 825:425768eb5e9e

code segment fix for non parse mode
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 27 Nov 2010 06:12:45 +0900
parents 2e6a95731a5e
children 313750f582dd
files mc-code-ia32.c mc-code-powerpc.c
diffstat 2 files changed, 17 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mc-code-ia32.c	Fri Nov 26 06:37:41 2010 +0900
+++ b/mc-code-ia32.c	Sat Nov 27 06:12:45 2010 +0900
@@ -997,6 +997,8 @@
         /* process in reverse order */
         n = ncadddr(args);
         type = n->ty;
+	int sz = size(type);
+	offset = code_arg_alignment(offset,n,type,sz,is_code0);
 	// n->dsp = offset;
 // printf("###  %s %d %d\n",n->nm,n->dsp,n->ty);
         if (scalar(type)) {
@@ -1007,7 +1009,6 @@
                 reg_var++;
                 caddr(args)=SIZE_OF_INT; /* why we need this? */
             }
-	    offset+=SIZE_OF_INT;
         } else if (type==FLOAT||type==DOUBLE) {
             if ((reg = get_input_dregister_var(freg_var,n,is_code0,1))) {
                 n->sc = DREGISTER;
@@ -1016,9 +1017,7 @@
                 freg_var++;
                 caddr(args)=size(type); /* why we need this? */
             }
-	    offset+=size(type);
-        } else
-	    offset+=size(type);
+        }
         args = cadr(args);
     }
 }
--- a/mc-code-powerpc.c	Fri Nov 26 06:37:41 2010 +0900
+++ b/mc-code-powerpc.c	Sat Nov 27 06:12:45 2010 +0900
@@ -838,6 +838,7 @@
     int is_code0 = is_code(fnptr);
     int dots;
     arg_offset_v = 0;
+    int offset = 0;
 
     function_type(fnptr->ty,&dots);
 
@@ -854,6 +855,8 @@
         /* process in reverse order */
         n = ncadddr(args);
         type = n->ty;
+	int sz = size(type);
+        offset = code_arg_alignment(offset,n,type,sz,is_code0);
         if (scalar(type)) {
             if ((reg = get_input_register_var(reg_var,n,is_code0))) {
                 n->sc = REGISTER;
@@ -2261,6 +2264,17 @@
     int reg_offset = 0;
     int offset = 0;
     int reg_var = 0;
+    if (!parse_mode && dots) {
+        int stype = type; int smode = mode;
+        type = INT;
+        mode = LDECL;
+        stmode = 0;
+        // lsearch defines local name
+        NMTBL *n = def(lsearch("__my_va_list",0),0);
+        n->dsp = offset;
+        type = stype; mode = smode;
+    }
+
 
     for(args = fnptr->dsp;args;args = cadr(args)) {
 	n = ncadddr(args);