changeset 380:c9ae2ea267c2

ARM continue...
author kono
date Sun, 18 Jul 2004 20:47:25 +0900
parents c7abd48191b3
children 5a9a27fadb9b
files Changes mc-code-arm.c
diffstat 2 files changed, 119 insertions(+), 49 deletions(-) [+]
line wrap: on
line diff
--- a/Changes	Sun Jul 18 12:26:30 2004 +0900
+++ b/Changes	Sun Jul 18 20:47:25 2004 +0900
@@ -5875,4 +5875,6 @@
 
 (はぁ、めんどくさい... 一週間かかってるし...)
 
-
+Sun Jul 18 20:45:48 JST 2004
+
+なかなか終らないね。GBAとLinux Zaurus と両方だからな。
--- a/mc-code-arm.c	Sun Jul 18 12:26:30 2004 +0900
+++ b/mc-code-arm.c	Sun Jul 18 20:47:25 2004 +0900
@@ -3695,7 +3695,7 @@
 	    disp = search_double_const(DCONST,
 		code_d2(value),code_d1(value),&label);
 #endif
-	    disp = printf("\tldfd\t%s, .L%d+%d\n",frn,label,disp);
+	    printf("\tldfd\t%s, .L%d+%d\n",frn,label,disp);
 	} else {
 	    disp = search_const(CONST,*((int*)f),freg,&label);
 	    printf("\tldfs\t%s, .L%d+%d\n",frn,label,disp);
@@ -3734,82 +3734,150 @@
 void
 code_d2i(int reg)
 { 
-    use_float(1,reg);
-    code_save_stacks();
-    clear_ptr_cache();
-    set_dreg(DREGISTER_OPERAND,1);
-    extern_conv("dptoli");
-    set_ireg(RET_REGISTER,0);
+    int lreg;
+    if (!(arch_mode&UseFPP)) {
+	use_float(1,reg);
+	code_save_stacks();
+	clear_ptr_cache();
+	set_dreg(DREGISTER_OPERAND,1);
+	extern_conv("__fixdfsi");
+	set_ireg(RET_REGISTER,0);
+    } else {
+	use_float(1,reg);
+	lreg = get_register();
+	printf("\tfixz\t%s, %s\n",register_name(lreg),register_name(reg));
+	set_ireg(lreg,0);
+    }
     return;
 }
 
 void
 code_i2d(int reg)
 { 
-    set_ireg(REGISTER_OPERAND,1);
-    code_save_stacks();
-    clear_ptr_cache();
-    extern_conv("litodp");
-    set_dreg(RET_DREGISTER,0);
-    use_float(1,reg);
+    int lreg;
+    if (!(arch_mode&UseFPP)) {
+	set_ireg(REGISTER_OPERAND,1);
+	code_save_stacks();
+	clear_ptr_cache();
+	extern_conv("__floatsidf");
+	set_dreg(RET_DREGISTER,0);
+	use_float(1,reg);
+    } else {
+	use_int(reg);
+	lreg = get_dregister(1);
+	printf("\tfltd\t%s, %s\n",register_name(lreg),register_name(reg));
+	set_dreg(lreg,0);
+    }
     return;
 }
 
 void
 code_d2u(int reg)
 { 
-    use_float(1,reg);
-    code_save_stacks();
-    clear_ptr_cache();
-    set_dreg(DREGISTER_OPERAND,1);
-    extern_conv("dptoul");
-    set_ireg(RET_REGISTER,0);
+    int lreg,label,disp,reg;
+    char *lrn,*frn,*crn;
+    if (!(arch_mode&UseFPP)) {
+	use_float(1,reg);
+	code_save_stacks();
+	clear_ptr_cache();
+	set_dreg(DREGISTER_OPERAND,1);
+	extern_conv("__fixunsdfsi");
+	set_ireg(RET_REGISTER,0);
+    } else {
+	//   u = (d>2.1e9)?((int)(d-2.1e9)^2147483648):(int)d
+	emit_dpush(1);
+	code_dconst(dlist2(DCONST,2.147483648e9),USE_CREG,1);
+	lrn = register_name(lreg = emit_dpop());
+	frn = register_name(freg);
+	set_ireg(reg=get_register(),0);
+	crn = register_name(reg);
+        printf("\tcmfe    %s, %s\n",lrn,frn);
+        printf("\tbge\t1f\n");
+        printf("\tfixz\t%s, %s\n",crn,lrn);
+        printf("\tb\t2f\n");
+	printf("1:\n");
+        printf("\tsufd\t%s, %s, %s\n",lrn,lrn,frn);
+        printf("\tfixz\t%s, %s\n",crn,lrn);
+        printf("\teor\t%s, %s, #-2147483648\n",crn,crn);
+	printf("2:\n");
+	emit_dpop_free(lreg);
+    }
     return;
 }
 
 void
 code_u2d(int reg)
 { 
-    int tmp=new_lvar(SIZE_OF_INT);
-    set_ireg(REGISTER_OPERAND,1);
-    code_assign_lvar(tmp,REGISTER_OPERAND,0);
-    code_save_stacks();
-    clear_ptr_cache();
-    extern_conv("litodp");
-    code_rlvar(tmp,REGISTER_OPERAND);
-    printf("\tbgez\t%s,1f\n",register_name(REGISTER_OPERAND));
-    code_double_lib_c("dpadd",RET_DREGISTER,RET_DREGISTER,4.29496729600000000000e9);
-    printf("1:\n");
-    set_dreg(RET_DREGISTER,0);
-    if (reg!=USE_CREG) {
-	use_float(1,reg);
-	if (reg!=RET_DREGISTER) {
-	    lmove(reg,RET_DREGISTER);
+    int tmp;
+    if (!(arch_mode&UseFPP)) {
+	tmp=new_lvar(SIZE_OF_INT);
+	set_ireg(REGISTER_OPERAND,1);
+	code_assign_lvar(tmp,REGISTER_OPERAND,0);
+	code_save_stacks();
+	clear_ptr_cache();
+	extern_conv("__floatsidf");
+	code_rlvar(tmp,REGISTER_OPERAND);
+	printf("\tcmp\t%s, #0\n",register_name(REGISTER_OPERAND));
+	printf("\tbge\t1f\n");
+	code_double_lib_c("__adddf3",RET_DREGISTER,RET_DREGISTER,4.29496729600000000000e9);
+	printf("1:\n");
+	set_dreg(RET_DREGISTER,0);
+	if (reg!=USE_CREG) {
+	    use_float(1,reg);
+	    if (reg!=RET_DREGISTER) {
+		lmove(reg,RET_DREGISTER);
+	    }
 	}
-    }
-    free_lvar(tmp);
+	free_lvar(tmp);
+    } else {
+	use_int(reg,1);
+	crn = register_name(reg);
+	set_dreg(reg=get_dregister(1),0);
+	frn = register_name(reg);
+	printf("\tfltd\t%s, %s\n",frn,crn);
+	printf("\tcmp\t%s, #0\n",crn);
+        printf("\tbge\t1f\n");
+	emit_dpush(1);
+	code_dconst(dlist2(DCONST,2.147483648e9),USE_CREG,1);
+	lrn = register_name(lreg = emit_dpop());
+	printf("\tadfd\t%s, %s, %s\n",frn,frn,lrn);
+	printf("1:\n");
+	emit_dpop_free(lreg);
+    }
     return;
 }
 
 void
 code_d2f(int reg) { 
-    set_dreg(DREGISTER_OPERAND,1);
-    code_save_stacks();
-    clear_ptr_cache();
-    extern_conv("dptofp");
-    set_freg(RET_FREGISTER,0);
-    use_float(0,reg);
+    char *frn;
+    if (!(arch_mode&UseFPP)) {
+	set_dreg(DREGISTER_OPERAND,1);
+	code_save_stacks();
+	clear_ptr_cache();
+	extern_conv("__truncdfsf2");
+	set_freg(RET_FREGISTER,0);
+	use_float(0,reg);
+    } else {
+	frn = register_name(freg);
+	printf("\tmvfs\t%s,%s\n",frn,frn);
+    }
     return;
 }
 
 void
 code_f2d(int reg) { 
-    set_freg(FREGISTER_OPERAND,1);
-    code_save_stacks();
-    clear_ptr_cache();
-    extern_conv("fptodp");
-    set_dreg(RET_DREGISTER,0);
-    use_float(1,reg);
+    char *frn;
+    if (!(arch_mode&UseFPP)) {
+	set_freg(FREGISTER_OPERAND,1);
+	code_save_stacks();
+	clear_ptr_cache();
+	extern_conv("__extendsfdf2");
+	set_dreg(RET_DREGISTER,0);
+	use_float(1,reg);
+    } else {
+	frn = register_name(freg);
+	printf("\tmvfd\t%s,%s\n",frn,frn);
+    }
     return;
 }