changeset 434:6927ec51c1d7 struct-div

Struct division in Parallel Assignment
author kono
date Wed, 03 Nov 2004 18:50:51 +0900
parents b9566a04b6e2
children d3e6359f8501
files .gdbinit Changes mc-code-arm.c mc-codegen.c
diffstat 4 files changed, 49 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/.gdbinit	Wed Nov 03 13:28:09 2004 +0900
+++ b/.gdbinit	Wed Nov 03 18:50:51 2004 +0900
@@ -1,5 +1,5 @@
 tb main
-run  -s test/bitfield.c
+run  -s test/arg.c
 # run  -s mc-parse.c
 # run  -s mc-codegen.c
 # run  -s nkf203/nkf.c
--- a/Changes	Wed Nov 03 13:28:09 2004 +0900
+++ b/Changes	Wed Nov 03 18:50:51 2004 +0900
@@ -6406,3 +6406,12 @@
 らしいのだが、他のmips/powerpc では、そういうことは起きない。
 なんでだろう?
 
+Wed Nov  3 18:31:28 JST 2004
+
+やっぱり構造体をint単位に分解すると並列代入は良くなるね。し
+かし、それだと、巨大な構造体ではコンパイル時間がかかりすぎる
+のと、コードがでかくなってしまう。
+
+並列代入も、もう少し考えるべきだな。
+
+(MIPSが、このコードだとうまく動かないみたいだね...)
--- a/mc-code-arm.c	Wed Nov 03 13:28:09 2004 +0900
+++ b/mc-code-arm.c	Wed Nov 03 18:50:51 2004 +0900
@@ -565,7 +565,7 @@
 void
 code_gexpr(int e){
      if (is_int_reg(creg) && creg!=ireg) error(-1);
-  register_usage("code_gexpr");
+//  register_usage("code_gexpr");
 }
 
 
--- a/mc-codegen.c	Wed Nov 03 13:28:09 2004 +0900
+++ b/mc-codegen.c	Wed Nov 03 18:50:51 2004 +0900
@@ -1099,6 +1099,8 @@
     return 0;
 }
 
+#define ASSIGN_STRUCT_DIVIDE 40
+
 static void
 jump(int e1, int env)
 {
@@ -1169,16 +1171,51 @@
                 /* we should check size also (but currently useless) */
                 remove0(&target,t0);
                 /* still we keep source to avoid overwrite */
+		if(is_memory(s0)) {
+		    source=list3(s0,source,sz);
+		    continue;
+		}
 	    }
         }
 	if(is_memory(s0)) {
+	    if (sz>8 && car(s0)==LVAR && car(t0)==LVAR 
+		    &&sz<ASSIGN_STRUCT_DIVIDE) {
+		/* large struct generate large save/restore */
+		/* divide it to avoid large copy */
+#if DEBUG_PARALLEL_ASSIGN
+printf("# division sz %d\n",sz);
+#endif
+		caddr(e2) = UNSIGNED;
+		source=list3( cadddr(e2), source,4);
+#if DEBUG_PARALLEL_ASSIGN
+printf("# div 0 source %d ty %d+%d sz %d\n",car(car(source)),ty,cadr(car(source)),4);
+#endif
+		for(e4=4;e4<sz;) {
+		    cadr(e2) = list4(car(e2),cadr(e2),caddr(e2),cadddr(e2));
+		    switch(sz-e4) {
+		    case 1: caddr(e2) = UCHAR; r = 1; break;
+		    case 2:
+		    case 3: caddr(e2) = USHORT; r = 2; break;
+		    default: caddr(e2) = UNSIGNED; r = 4;
+		    }
+		    if (e4==4) e3=cadr(e2);
+		    car(e2) =  list2(LVAR,cadr(t0)+e4);
+		    cadddr(e2) = list2(LVAR,cadr(s0)+e4);
+		    source=list3( cadddr(e2), source,r);
+		    e4 += r;
+#if DEBUG_PARALLEL_ASSIGN
+printf("# div 1 source %d ty %d+%d sz %d\n",car(car(source)),ty,cadr(car(source)),r);
+#endif
+		}
+		e2 = e3;
+		continue;
+	    }
 	    source=list3(s0,source,sz);
 #if DEBUG_PARALLEL_ASSIGN
 printf("# source %d ty %d+%d sz %d\n",car(car(source)),ty,cadr(car(source)),sz);
 #endif
 	}
     }
-
     /* compute jump address */
     e2 = cadr(e1);
     if (car(e2) == FNAME) {