changeset 259:18837238e306 complex-arg-precalc

complex argument pre-calcuration done for power pc
author kono
date Sat, 15 May 2004 21:11:01 +0900
parents 22949117768f
children 9843979a270e
files Changes mc-code-mips.c mc-code-powerpc.c
diffstat 3 files changed, 39 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/Changes	Sat May 15 20:07:24 2004 +0900
+++ b/Changes	Sat May 15 21:11:01 2004 +0900
@@ -4224,4 +4224,5 @@
 なんか方法が悪いんじゃないの? 本来、lreg は値渡しできるべきだよね。
 まぁねぇ。
 
-
+複雑なものから計算する方が良いってことは、スタックに積む
+引数から計算した方が良いってことか。
--- a/mc-code-mips.c	Sat May 15 20:07:24 2004 +0900
+++ b/mc-code-mips.c	Sat May 15 21:11:01 2004 +0900
@@ -1409,14 +1409,16 @@
 	printf("\tsw %s,%d(%s)\n",drn,offset,trn);
 	break;
     default:
-	if (-MAX_COPY_LEN<length && length <0) {
-	    for(;length<=4;length+=4,offset-=4)
-		emit_copy(from,to,4,offset,0,det);
-	    for(;length<=2;length+=2,offset-=2)
-		emit_copy(from,to,2,offset,0,det);
-	    if(length>0)
-		emit_copy(from,to,length,offset,0,det);
-	    break;
+        if (length <0) {
+            if (length > -MAX_COPY_LEN) {
+                for(;length<=-4;length+=4,offset-=4)
+                    emit_copy(from,to,-4,offset-4,0,det);
+                for(;length<=-2;length+=2,offset-=2)
+                    emit_copy(from,to,-2,offset-2,0,det);
+                if(length<0)
+                    emit_copy(from,to,length,offset-1,0,det);
+                break;
+            }
 	} else if (length <=MAX_COPY_LEN) {
 	    for(;length>=4;length-=4,offset+=4)
 		emit_copy(from,to,4,offset,0,det);
--- a/mc-code-powerpc.c	Sat May 15 20:07:24 2004 +0900
+++ b/mc-code-powerpc.c	Sat May 15 21:11:01 2004 +0900
@@ -1753,7 +1753,7 @@
     } else if (t==LONGLONG||t==ULONGLONG) {
 	if (mode==AS_SAVE) {
 	    return get_lregister_var(0);
-	} else if (reg_arg>=MAX_INPUT_REGISTER_VAR)  {
+	} else if (reg_arg+1>=MAX_INPUT_REGISTER_VAR)  {
 	    return list2(LVAR,caller_arg_offset_v(nargs));
 	} else
 	    return get_input_lregister_var(reg_arg,0,0);
@@ -1826,7 +1826,7 @@
        input variables */
     stargs = 0;
     complex_ = 0;
-    nargs = reg_arg = freg_arg = arg_assign = 0;
+    nargs = reg_arg = freg_arg = 0;
     for (e3 = e1 = reverse0(caddr(e1)); e3; e3 = cadr(e3)) {	
 	t=caddr(e3);
 	if ((e5= !simple_arg(car(e3)))) {
@@ -1875,9 +1875,32 @@
 	t  = caddr(e3);
 	arg = get_input_arg(t,AS_ARG,caddr(stargs),cadddr(stargs),0);
 	struct_push(e4,t,arg);
+	car(e3)=0;  // done
     }
 
     nargs = reg_arg = freg_arg = arg_assign = 0;
+    // calc stack arguments first
+    for (e3 = e1; e3; 
+		increment_function_arg(e3,&nargs,&reg_arg,&freg_arg),
+		e3 = cadr(e3)) {	
+	if (!(e4=car(e3))) continue;
+	t=caddr(e3);
+	arg = get_input_arg(t,AS_ARG,nargs,reg_arg,freg_arg);
+	if (car(arg)!=LVAR) continue;
+	g_expr_u(assign_expr0(arg,e4,t,t));
+	if (t==LONGLONG||t==ULONGLONG) {
+	    if (reg_arg+1==MAX_INPUT_REGISTER_VAR) {
+		// half register, half memory case
+		arg_assign = list2(
+		    assign_expr0(r0=get_input_register_var(reg_arg,0,0),
+			arg,INT,INT),
+		    arg_assign);
+		use_input_reg(cadr(r0),1);
+	    }
+	}
+	car(e3)=0;  // done
+    }
+    nargs = reg_arg = freg_arg = 0;
     for (e3 = e1; e3; 
 		increment_function_arg(e3,&nargs,&reg_arg,&freg_arg),
 		e3 = cadr(e3)) {	
@@ -1890,10 +1913,8 @@
 	    if (car(arg)==REGISTER)
 		use_input_reg(cadr(arg),1);
 	    g_expr_u(assign_expr0(arg,e4,t,t));
-	    continue;
 	} else if (t==LONGLONG||t==ULONGLONG) {
-	    if (reg_arg>=MAX_INPUT_REGISTER_VAR) { 
-	    } else if (reg_arg+1>=MAX_INPUT_REGISTER_VAR) { 
+	    if (reg_arg+1==MAX_INPUT_REGISTER_VAR) { 
 		// half register, half memory case
 		// put whole long long anyway
 		arg_assign = list2(
@@ -1907,7 +1928,6 @@
 	    }
 	    reg_arg_list = list2(arg,reg_arg_list);
 	    g_expr_u(assign_expr0(arg,e4,t,t));
-	    continue;
 	} else if (t==DOUBLE||t==FLOAT) {
 	    if (reg_arg<MAX_INPUT_REGISTER_VAR) {
 		/* sigh... 
@@ -1955,12 +1975,8 @@
 	    if (car(arg)==DREGISTER)
 		use_input_reg(cadr(arg),1); /* protect from input register free */
 	    g_expr_u(assign_expr0(arg,e4,t,t)); /* XXX */
-	    continue;
-	} else if (t>=0&&(car(t)==STRUCT||car(t)==UNION)) {
-	    continue;
-	} else {
-	    error(TYERR);
 	}
+	// structs are finished
     }
     if (max_func_args<nargs) max_func_args=nargs;
     for(;arg_assign;arg_assign=cadr(arg_assign)) {