changeset 228:21b311266011

*** empty log message ***
author kono
date Tue, 27 Apr 2004 23:16:02 +0900
parents ed92cef127f1
children d793c84b3679
files mc-code-powerpc.c test/code-gen.c
diffstat 2 files changed, 38 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/mc-code-powerpc.c	Tue Apr 27 18:32:28 2004 +0900
+++ b/mc-code-powerpc.c	Tue Apr 27 23:16:02 2004 +0900
@@ -640,6 +640,7 @@
 			regs[REG_VAR_BASE-j]=USING_REG; 
 			if (j>max_reg_var) max_reg_var=j;
 			/* その場所を表す番号を返す */
+			regs[ll]=USING_REG;
 			regv_l(ll) = REG_VAR_BASE-j;
 			regv_h(ll) = REG_VAR_BASE-i;
 			return list3(LREGISTER,ll,(int)n); 
@@ -1534,9 +1535,9 @@
     if (!is_longlong_reg(reg)) { error(-1); return; }
     if (mode) {
 	if (regv_l(reg)!=5)
-	    printf("\tmr r5,%s\n", lregister_name_low(reg));
+	    printf("\tmr r5,%s\n", lregister_name_high(reg));
 	if (regv_l(reg)!=6)
-	    printf("\tmr r6,%s\n", lregister_name_high(reg));
+	    printf("\tmr r6,%s\n", lregister_name_low(reg));
     }
 }
 
@@ -1549,10 +1550,10 @@
     clear_ptr_cache_reg(arg);
     regs[arg]=USING_REG;
     if (is_longlong_reg(arg)) {
+	clear_ptr_cache_reg(regv_l(arg));
 	regs[regv_l(arg)]=USING_REG;
-	clear_ptr_cache_reg(regv_l(arg));
+	clear_ptr_cache_reg(regv_h(arg));
 	regs[regv_h(arg)]=USING_REG;
-	clear_ptr_cache_reg(regv_h(arg));
     }
 }
 
@@ -1606,16 +1607,17 @@
     my_func_args = offset;
 }
 
-int
-simple_p(int e3)
+static int
+not_simple_p(int e3)
 {
-    return (e3==FUNCTION||e3==CONV||e3==RSTRUCT||e3==STASS|| (e3&LOP));
+    return (e3==FUNCTION||e3==CONV||e3==RSTRUCT||e3==STASS|| 
+	(((e3/100)==LOP)&&(e3!=LREGISTER||e3!=LADD||e3!=LSUB)));
 }
 
 int
 simple_args(int e3)
 {
-    return !contains_in_list_p(e3,simple_p);
+    return !contains_in_list_p(e3,not_simple_p);
 }
 
 int
@@ -2986,7 +2988,7 @@
     u2d_lib_used = 1;
     set_ireg(RET_REGISTER,1);
     printf("\tbl u2d_\n");
-    set_freg(FREG_FREGISTER,0);
+    set_freg(RET_FREGISTER,0);
 }
 
 void
@@ -3254,7 +3256,7 @@
     int tmp;
     if (regv_h(to)==regv_l(from)&&(regv_l(to)==regv_h(from))) {
 	tmp = get_register();
-	printf("\tmr %s,%s\n",lregister_name_low(tmp),lregister_name_low(from));
+	printf("\tmr %s,%s\n",register_name(tmp),lregister_name_low(from));
 	printf("\tmr %s,%s\n",lregister_name_high(to),lregister_name_high(from));
 	printf("\tmr %s,%s\n",lregister_name_low(to),register_name(tmp));
 	free_register(tmp);
@@ -3656,7 +3658,9 @@
     clear_ptr_cache();
     asld_lib_used = 1;
     set_lreg(RET_LREGISTER,1);
-    set_lreg_operand(oreg,1);
+    if (regv_l(oreg)!=5) {
+	printf("\tmr r5,%s\n", lregister_name_low(oreg));
+    }
     printf("\tbl asld__\n");
 }
 
@@ -3667,7 +3671,9 @@
     clear_ptr_cache();
     asrd_lib_used = 1;
     set_lreg(RET_LREGISTER,1);
-    set_lreg_operand(oreg,1);
+    if (regv_l(oreg)!=5) {
+	printf("\tmr r5,%s\n", lregister_name_low(oreg));
+    }
     printf("\tbl asrd__\n");
 }
 
@@ -3767,8 +3773,8 @@
 	printf("\tadde %s,%s,%s\n",crn_h,crn_h,orn_h);
 	break;
     case LSUB:
-	printf("\tsubfc %s,%s,%s\n",crn_l,crn_l,orn_l);
-	printf("\tsubfe %s,%s,%s\n",crn_h,crn_h,orn_h);
+	printf("\tsubfc %s,%s,%s\n",crn_l,orn_l,crn_l);
+	printf("\tsubfe %s,%s,%s\n",crn_h,orn_h,crn_h);
 	break;
     case LCMP:
 	error(-1);
@@ -3802,13 +3808,13 @@
 	    crn_h = drn_h + crn_l;
 	    crn_l = drn_l;
         */
-	printf("\tmullw %s,%s,%s\n",drn_l,crn_l,orn_l);
 	printf("\tmulhwu %s,%s,%s\n",drn_h,crn_l,orn_l);
-	printf("\tmullw %s,%s,%s\n",orn_l,crn_h,orn_l);
-	printf("\tadd %s,%s,%s\n",drn_h,drn_h,orn_l);
-	printf("\tmullw %s,%s,%s\n",crn_l,orn_h,crn_l);
-	printf("\tadd %s,%s,%s\n",crn_l,drn_h,crn_h);
-	printf("\tmr %s,%s\n",crn_l,drn_l);
+	printf("\tmullw %s,%s,%s\n", drn_l,crn_l,orn_l);
+	printf("\tmullw %s,%s,%s\n", orn_l,crn_h,orn_l);
+	printf("\tadd %s,%s,%s\n",   drn_h,drn_h,orn_l);
+	printf("\tmullw %s,%s,%s\n", crn_l,orn_h,crn_l);
+	printf("\tadd %s,%s,%s\n",   crn_h,drn_h,crn_l);
+	printf("\tmr %s,%s\n",       crn_l,drn_l);
 	break;
     case LDIV:
 	code_ldiv_lib(oreg); // ___divdi3$stub
--- a/test/code-gen.c	Tue Apr 27 18:32:28 2004 +0900
+++ b/test/code-gen.c	Tue Apr 27 23:16:02 2004 +0900
@@ -142,7 +142,7 @@
 {
     int i,j;
     i = 123123123;j = 0;
-    printf("code_preinc %d %d\n",++i,--j);
+    printf("code_preinc i %d %d\n",++i,--j);
 }
 
 // code_postinc(int e1,int e2,int dir,int sign,int sz,int reg) 
@@ -151,7 +151,7 @@
 {
     unsigned int i,j;
     i = 123123123;j = 0;
-    printf("code_upreinc %d %d\n",i++,j--);
+    printf("code_upreinc u %d %d\n",i++,j--);
 }
 
 // code_postinc(int e1,int e2,int dir,int sign,int sz,int reg) 
@@ -160,7 +160,7 @@
 {
     int i,j;
     i = 123123123;j = 0;
-    printf("code_preinc %d %d\n",i++,j--);
+    printf("code_postinc i %d %d\n",i++,j--);
 }
 
 // code_preinc(int e1,int e2,int dir,int sign,int sz,int reg) 
@@ -169,7 +169,7 @@
 {
     unsigned int i,j;
     i = 123123123;j = 0;
-    printf("code_upreinc %d %d\n",++i,--j);
+    printf("code_upreinc u %d %d\n",++i,--j);
 }
 
 // code_return(int creg) 
@@ -990,9 +990,9 @@
     double i,j;
     float ui,uj;
     i = 123123123;j = 0;
-    printf("code_dpreinc %g %g\n",++i,--j);
+    printf("code_dpreinc d %g %g\n",++i,--j);
     ui = 123123123;uj = 0;
-    printf("code_dpreinc %g %g\n",++ui,--uj);
+    printf("code_dpreinc f %g %g\n",++ui,--uj);
 }
 
 // code_dpostinc(int e1,int e2,int d,int reg) 
@@ -1002,9 +1002,9 @@
     double i,j;
     float ui,uj;
     i = 123123123;j = 0;
-    printf("code_dpreinc %g %g\n",i--,j--);
+    printf("code_dpostinc d %g %g\n",i--,j--);
     ui = 123123123;uj = 0;
-    printf("code_dpreinc %g %g\n",ui++,uj--);
+    printf("code_dpostinc f %g %g\n",ui++,uj--);
 }
 
 // drexpr(int e1, int e2,int l1, int op)
@@ -1540,7 +1540,7 @@
 {
     long long i,j;
     i = 123123123;j = 0;
-    printf("code_preinc %lld %lld\n",++i,--j);
+    printf("code_preinc l %lld %lld\n",++i,--j);
 }
 
 // code_lpostinc(int e1,int e2,int reg)
@@ -1549,7 +1549,7 @@
 {
     long long i,j;
     i = 123123123;j = 0;
-    printf("code_preinc %lld %lld\n",i++,j--);
+    printf("code_postinc l %lld %lld\n",i++,j--);
 }
 
 // code_lpreinc(int e1,int e2,int reg)
@@ -1558,7 +1558,7 @@
 {
     unsigned long long i,j;
     i = 123123123;j = 0;
-    printf("code_preinc %llu %llu\n",++i,--j);
+    printf("code_preinc l %llu %llu\n",++i,--j);
 }
 
 // code_lpostinc(int e1,int e2,int reg)
@@ -1567,7 +1567,7 @@
 {
     unsigned long long i,j;
     i = 123123123;j = 0;
-    printf("code_preinc %llu %llu\n",i++,j--);
+    printf("code_postinc lu %llu %llu\n",i++,j--);
 }
 
 // code_lassop(int op)