changeset 727:13e540e7d9bf goto-with-env-syntax

Undebug fix for arm/mips/spu
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 20 Aug 2009 17:23:23 +0900
parents f3fccac64cbe
children c02a35845a70
files mc-code-arm.c mc-code-mips.c mc-code-spu.c
diffstat 3 files changed, 127 insertions(+), 86 deletions(-) [+]
line wrap: on
line diff
--- a/mc-code-arm.c	Thu Aug 20 17:03:35 2009 +0900
+++ b/mc-code-arm.c	Thu Aug 20 17:23:23 2009 +0900
@@ -3449,10 +3449,52 @@
 	control=0;
 }
 
+static void 
+make_return_continuation()
+{
+    fwddef(retcont);
+    if (cadr(fnptr->ty)==FLOAT) {
+#if FLOAT_CODE
+	creg = freg = cadr(get_input_dregister_var(0,0,1,0));
+	set_freg(RET_FREGISTER,1);
+#endif
+	printf("\tmov\t%s, %s\n",register_name(
+		cadr(get_input_register_var(1,0,1,0));
+		),register_name(REG_fp));
+    } else if (cadr(fnptr->ty)==DOUBLE) {
+#if FLOAT_CODE
+	creg = lreg = cadr(get_input_dregister_var(0,0,1,1));
+	set_dreg(RET_DREGISTER,1);
+	printf("\tmov\t%s, %s\n",register_name(
+		cadr(get_input_register_var(2,0,1,0));
+		),register_name(REG_fp));
+#endif
+    } else if (cadr(fnptr->ty)>0&&(
+	car(cadr(fnptr->ty))==STRUCT ||
+	car(cadr(fnptr->ty))==UNION)) {
+	int sz = size(cadr(fnptr->ty));
+	inc_inst(3);
+	code_const(sz,REGISTER_OPERAND);
+	printf("\tsub\tr1, r2, fp\n");
+	printf("\tldr\tr0, [fp, #%d]\n",(my_func_args-1)*SIZE_OF_INT);
+	printf("\tmov\t%s, %s\n",register_name(
+		cadr(get_input_register_var(1,0,1,0));
+		),register_name(REG_fp));
+	// emit_copy(6,3,sz,0,1,1);
+    } else if (cadr(fnptr->ty)!=VOID) {
+	creg = ireg = cadr(get_input_register_var(0,0,1));
+	if (creg!=RET_REGISTER)
+	    set_ireg(RET_REGISTER,1);
+	printf("\tmov\t%s, %s\n",register_name(
+		cadr(get_input_register_var(1,0,1,0));
+		),register_name(REG_fp));
+    }
+    code_unfix_frame_pointer();
+}
+
 void
 leave(int control0, char *name)
 {
-    int retcont1=0,sz;
 
     if (control0) {
 	code_set_return_register(1);
@@ -3461,33 +3503,7 @@
     if (retcont) { 
 	/* return from CbC segement */
 	if (control0) gen_jmp(retlabel);
-	retcont1 = fwdlabel();
-	fwddef(retcont);
-	if (cadr(fnptr->ty)==FLOAT) {
-#if FLOAT_CODE
-	    creg = freg = cadr(get_input_dregister_var(0,0,1,0));
-	    set_freg(RET_FREGISTER,1);
-#endif
-	} else if (cadr(fnptr->ty)==DOUBLE) {
-#if FLOAT_CODE
-	    creg = lreg = cadr(get_input_dregister_var(0,0,1,1));
-	    set_dreg(RET_DREGISTER,1);
-#endif
-	} else if (cadr(fnptr->ty)>0&&(
-	    car(cadr(fnptr->ty))==STRUCT ||
-	    car(cadr(fnptr->ty))==UNION)) {
-	    sz = size(cadr(fnptr->ty));
-	    inc_inst(3);
-	    code_const(sz,REGISTER_OPERAND);
-	    printf("\tsub\tr1, r2, fp\n");
-	    printf("\tldr\tr0, [fp, #%d]\n",(my_func_args-1)*SIZE_OF_INT);
-	    emit_copy(6,3,sz,0,1,1);
-	} else if (cadr(fnptr->ty)!=VOID) {
-	    creg = ireg = cadr(get_input_register_var(0,0,1));
-	    if (creg!=RET_REGISTER)
-		set_ireg(RET_REGISTER,1);
-	}
-	code_unfix_frame_pointer();
+	make_return_continuation();
     }
     fwddef(retlabel);
 
--- a/mc-code-mips.c	Thu Aug 20 17:03:35 2009 +0900
+++ b/mc-code-mips.c	Thu Aug 20 17:23:23 2009 +0900
@@ -3121,10 +3121,48 @@
     control=1;
 }
 
+static void 
+make_return_continuation()
+{
+    // retcont1 = fwdlabel();
+    fwddef(retcont);
+    if (cadr(fnptr->ty)==FLOAT) {
+	creg = freg = cadr(get_input_dregister_var(0,0,1,0));
+	set_freg(RET_FREGISTER,1);
+	printf("\tmove    $fp,$21\n");
+    } else if (cadr(fnptr->ty)==DOUBLE) {
+	creg = lreg = cadr(get_input_dregister_var(0,0,1,1));
+	set_dreg(RET_DREGISTER,1);
+	printf("\tmove    $fp,$19\n");
+    } else if (cadr(fnptr->ty)>0&&(
+	car(cadr(fnptr->ty))==STRUCT ||
+	car(cadr(fnptr->ty))==UNION)) {
+	int sz = size(cadr(fnptr->ty));
+	printf("\tli $4,%d\n",sz);
+	printf("\tsubl $5,$4,$fp\n");
+	printf("\tlw $3,(%d)($fp)\n",(my_func_args-1)*SIZE_OF_INT);
+	printf("\tmove    $fp,$20\n");
+	// emit_copy(6,3,sz,0,1,1);
+    } else if (cadr(fnptr->ty)!=VOID) {
+	creg = ireg = cadr(get_input_register_var(0,0,1));
+	if (creg!=RET_REGISTER)
+	    set_ireg(RET_REGISTER,1);
+	printf("\tmove    $fp,$20\n");
+    }
+#if R1SAVE
+#else
+#if 0
+    printf("\tsubu $fp,");
+    printf("$fp,%d+$L_%d\n",FUNC_LVAR(0),lvar_offset_label);
+    // printf("\tj $L_%d\n",retcont1);
+#endif
+#endif
+}
+
 void
 leave(int control, char *name)
 {
-    int retcont1=0,sz;
+    // int retcont1=0;
     int r1_offsetv;
 
     if (control) {
@@ -3134,35 +3172,7 @@
     if (retcont) { 
 	/* return from CbC segement */
 	if (control) jmp(retlabel);
-	retcont1 = fwdlabel();
-	fwddef(retcont);
-	if (cadr(fnptr->ty)==FLOAT) {
-	    creg = freg = cadr(get_input_dregister_var(0,0,1,0));
-	    set_freg(RET_FREGISTER,1);
-	} else if (cadr(fnptr->ty)==DOUBLE) {
-	    creg = lreg = cadr(get_input_dregister_var(0,0,1,1));
-	    set_dreg(RET_DREGISTER,1);
-	} else if (cadr(fnptr->ty)>0&&(
-	    car(cadr(fnptr->ty))==STRUCT ||
-	    car(cadr(fnptr->ty))==UNION)) {
-	    sz = size(cadr(fnptr->ty));
-	    printf("\tli $4,%d\n",sz);
-	    printf("\tsubl $5,$4,$fp\n");
-	    printf("\tlw $3,(%d)($fp)\n",(my_func_args-1)*SIZE_OF_INT);
-	    emit_copy(6,3,sz,0,1,1);
-	} else if (cadr(fnptr->ty)!=VOID) {
-	    creg = ireg = cadr(get_input_register_var(0,0,1));
-	    if (creg!=RET_REGISTER)
-		set_ireg(RET_REGISTER,1);
-	}
-#if R1SAVE
-#else
-#if 0
-	printf("\tsubu $fp,");
-	printf("$fp,%d+$L_%d\n",FUNC_LVAR(0),lvar_offset_label);
-	// printf("\tj $L_%d\n",retcont1);
-#endif
-#endif
+	make_return_continuation();
     }
     fwddef(retlabel);
     // if (retcont) {
--- a/mc-code-spu.c	Thu Aug 20 17:03:35 2009 +0900
+++ b/mc-code-spu.c	Thu Aug 20 17:23:23 2009 +0900
@@ -2605,11 +2605,51 @@
 	control=0;
 }
 
+static void 
+make_return_continuation()
+{
+    fwddef(retcont);
+    if (cadr(fnptr->ty)==FLOAT) {
+#if FLOAT_CODE
+	creg = cadr(get_input_dregister_var(0,0,1,0));
+	set_ireg(RET_REGISTER,1);
+#endif
+	printf("\t%s\t%s, %s, 0\n",movef(0),
+	    register_name(REG_fp),register_name(
+		cadr(get_input_register_var(1,0,1,0)));
+    } else if (cadr(fnptr->ty)==DOUBLE) {
+#if FLOAT_CODE
+	creg = cadr(get_input_dregister_var(0,0,1,1));
+	set_ireg(RET_REGISTER,1);
+	printf("\t%s\t%s, %s, 0\n",movef(0),
+	    register_name(REG_fp),register_name(
+		cadr(get_input_register_var(1,0,1,0)));
+#endif
+    } else if (cadr(fnptr->ty)>0&&(
+	car(cadr(fnptr->ty))==STRUCT ||
+	car(cadr(fnptr->ty))==UNION)) {
+	sz = size(cadr(fnptr->ty));
+	code_const(sz,REGISTER_OPERAND);
+	printf("\tsf\t$1, $2, $sp\n");
+	printf("\tlqd\t$1, %d($sp)\n",(my_func_args-1)*SIZE_OF_INT);
+	// emit_copy(6,3,sz,0,1,1);
+	printf("\t%s\t%s, %s, 0\n",movef(0),
+	    register_name(REG_fp),register_name(
+		cadr(get_input_register_var(1,0,1,0)));
+    } else if (cadr(fnptr->ty)!=VOID) {
+	creg = cadr(get_input_register_var(0,0,1));
+	if (creg!=RET_REGISTER)
+	    set_ireg(RET_REGISTER,1);
+	printf("\t%s\t%s, %s, 0\n",movef(0),
+	    register_name(REG_fp),register_name(
+		cadr(get_input_register_var(1,0,1,0)));
+    }
+    code_unfix_frame_pointer();
+}
+
 void
 leave(int control0, char *name)
 {
-    int retcont1=0,sz;
-
     if (control0) {
 	code_set_return_register(1);
     } else
@@ -2617,32 +2657,7 @@
     if (retcont) { 
 	/* return from CbC segement */
 	if (control0) gen_jmp(retlabel);
-	retcont1 = fwdlabel();
-	fwddef(retcont);
-	if (cadr(fnptr->ty)==FLOAT) {
-#if FLOAT_CODE
-	    creg = cadr(get_input_dregister_var(0,0,1,0));
-	    set_ireg(RET_REGISTER,1);
-#endif
-	} else if (cadr(fnptr->ty)==DOUBLE) {
-#if FLOAT_CODE
-	    creg = cadr(get_input_dregister_var(0,0,1,1));
-	    set_ireg(RET_REGISTER,1);
-#endif
-	} else if (cadr(fnptr->ty)>0&&(
-	    car(cadr(fnptr->ty))==STRUCT ||
-	    car(cadr(fnptr->ty))==UNION)) {
-	    sz = size(cadr(fnptr->ty));
-	    code_const(sz,REGISTER_OPERAND);
-	    printf("\tsf\t$1, $2, $sp\n");
-	    printf("\tlqd\t$1, %d($sp)\n",(my_func_args-1)*SIZE_OF_INT);
-	    emit_copy(6,3,sz,0,1,1);
-	} else if (cadr(fnptr->ty)!=VOID) {
-	    creg = cadr(get_input_register_var(0,0,1));
-	    if (creg!=RET_REGISTER)
-		set_ireg(RET_REGISTER,1);
-	}
-	code_unfix_frame_pointer();
+	make_return_continuation();
     }
     fwddef(retlabel);