changeset 405:5b76a2bc1177

ARM code-gen-all passed.
author kono
date Sun, 17 Oct 2004 22:33:19 +0900
parents 95956779df2e
children 8528af42e7f7
files Changes mc-code-arm.c mc-code-mips.c mc-code-powerpc.c test/code-gen.c
diffstat 5 files changed, 53 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/Changes	Sun Oct 17 13:13:43 2004 +0900
+++ b/Changes	Sun Oct 17 22:33:19 2004 +0900
@@ -6105,3 +6105,6 @@
 Sun Oct 17 13:13:00 JST 2004
 
 なんか long long に関しては、gcc の方が結構、間違っているなぁ。
+
+signed char に関しては、ldrsb ってのがあるみたいね。なんで、
+arm-linux-gcc ではでないんだろう?
--- a/mc-code-arm.c	Sun Oct 17 13:13:43 2004 +0900
+++ b/mc-code-arm.c	Sun Oct 17 22:33:19 2004 +0900
@@ -40,6 +40,7 @@
 static char * cstore(int sz);
 static void code_int_lib(char *lib,int reg,int oreg); 
 static int caller_arg_offset_v(int arg);
+static void pcond(int op, int r2,int r1,int r0,int cond,int l1,int mode);
 #if FLOAT_CODE
 static int code_d1(double d);
 static int code_d2(double d);
@@ -48,6 +49,8 @@
 static void code_double_lib(char *lib,int to,int reg,int oreg);
 static void code_double_lib_c(char *lib,int from,int to,double value);
 static void dconst(int l,int h,double value);
+static void code_assign_input_double_long(int e1,int e2) ;
+static void code_assign_input_float_int(int e1,int e2) ;
 
 #endif
 
@@ -1509,11 +1512,17 @@
 
 
 #define cload(sz,sign) \
-    (sz==1?"ldrb":sz==SIZE_OF_SHORT?(sign?"ldrsh":"ldrh"):"ldr")
+    (sz==1?(sign?"ldrsb":"ldrb"):sz==SIZE_OF_SHORT?(sign?"ldrsh":"ldrh"):"ldr")
 
 
 #define cext(sign,sz,reg)
 
+static char *
+cext_at(int sz,int sign) 
+{
+    return ((sz==1&&!sign)?"  @ zero_extendqisi2":"");
+}
+
 void
 code_label(int labelno)
 {
@@ -1538,7 +1547,7 @@
 code_crgvar(int e1,int reg,int sign,int sz){
     use_int(reg);
     code_ld(cload(sz,sign),reg,cadr(e1),get_ptr_cache((NMTBL*)caddr(e1)),
-	sz==1?"  @ zero_extendqisi2":"");
+	cext_at(sz,sign));
     cext(sign,sz,reg);
 }
 
@@ -1596,7 +1605,7 @@
     inc_inst(1);
     lvar_intro(e2);
     printf("\t%s\t%s, ",cload(sz,sign),register_name(reg));
-    lvar(e2,sz==1?"  @ zero_extendqisi2":"");
+    lvar(e2,cext_at(sz,sign));
     cext(sign,sz,reg);
 }
 
@@ -1670,7 +1679,7 @@
     } else {
 	drn = register_name(reg);
     }
-    code_ld(cload(sz,sign),reg,0,xreg,sz==1?"  @ zero_extendqisi2":"");
+    code_ld(cload(sz,sign),reg,0,xreg,cext_at(sz,sign));
     code_add(reg,dir,reg);
     code_ldf(cstore(sz),drn,0,xreg,sz==SIZE_OF_SHORT?"  @ movhi":"");
 }
@@ -1698,7 +1707,7 @@
     } else {
 	xrn = register_name(reg);
     }
-    code_ld(cload(sz,sign),reg,0,xreg,sz==1?"  @ zero_extendqisi2":"");
+    code_ld(cload(sz,sign),reg,0,xreg,cext_at(sz,sign));
     code_add(nreg,dir,reg);
     code_ldf(cstore(sz),nrn,0,xreg,sz==SIZE_OF_SHORT?"  @ movhi":"");
 
@@ -1787,7 +1796,7 @@
 code_cmp_crgvar(int e1,int reg,int sz,int label,int cond) {
     use_int(reg);
     code_ld(cload(sz,0),reg,cadr(e1),get_ptr_cache((NMTBL*)caddr(e1)),
-	sz==1?"  @ zero_extendqisi2":"");
+	cext_at(sz,0));
     cext(0,sz,r);
     inc_inst(1);
     printf("\tcmp\t%s, #0\n",register_name(reg));
@@ -1803,7 +1812,7 @@
     lvar_intro(e2);
     inc_inst(1);
     printf("\t%s\t%s, ",cload(sz,0),crn);
-    lvar(e2,sz==1?"  @ zero_extendqisi2":"");
+    lvar(e2,cext_at(sz,0));
     cext(0,sz,reg);
     code_cmp_register(reg,label,cond);
 }
@@ -2066,8 +2075,8 @@
 	}
 	if (is_float_reg(reg)) {
 	    set_freg(reg,mode);
-	    return;
 	}
+	return;
     }
     if (reg==RET_DREGISTER) {
 	regv_l(reg) = RET_DREGISTER_L;
@@ -2540,7 +2549,7 @@
 	if (max_func_args<4) max_func_args=4;
 	g_expr_u(assign_expr0(list3(REGISTER,4,0),
 		list2(LVAR,caller_arg_offset_v(3)),INT,INT));
-	use_input_reg(3,1);
+	use_input_reg(4,1);
     }
     nargs = reg_arg = freg_arg = 0;
     for (e3 = e1; e3; 
@@ -2670,7 +2679,7 @@
     if (!is_int_reg(creg)) error(-1);
     lreg = creg;
     use_int(reg);
-    code_ld(cload(sz,sign),reg,offset,lreg,sz==1?"  @ zero_extendqisi2":"");
+    code_ld(cload(sz,sign),reg,offset,lreg,cext_at(sz,sign));
     cext(sign,sz,reg);
 }
 
@@ -3021,7 +3030,7 @@
 ld_indexx(int byte, int n, int xreg,int creg, int sign)
 {	
     use_int(creg);
-    code_ld(cload(byte,sign),creg,n,xreg,byte==1?"  @ zero_extendqisi2":"");
+    code_ld(cload(byte,sign),creg,n,xreg,cext_at(byte,sign));
 }
 
 int
@@ -3035,14 +3044,17 @@
 {
     /* used in dosiwtch() */
     int sign,reg=-1;
+    int regsv;
     char *rn,*crn;
     if(chk) return;
     crn = register_name(csreg);
 
     inc_inst(2);
     if (!(sign=is_stage1_const(e,CMP))) {
+	regsv = regs[csreg]; regs[csreg]=1;
 	rn = register_name(reg= get_register());
-	code_const(list2(CONST,e),reg);
+	regs[csreg] = regsv;
+	code_const(e,reg);
 	printf("\tcmp\t%s, %s\n",crn,rn);
     } else {
 	printf("\t%s\t%s, #%d\n",sign?"cmp":"cmn",crn,e);
@@ -4805,12 +4817,12 @@
     e3h =  regv_h(e3);  e3l = regv_l(e3);
     switch(op) {
     case LOP+GT: case LOP+GE:
-	pcond(GT,  e3h,regh,0,1,cond?l1:l2,COND_BRANCH);
-	pcond(NEQ, e3h,regh,0,1,cond?l2:l1,COND_BRANCH);
+	pcond(GT,  regh,e3h,0,1,cond?l1:l2,COND_BRANCH);
+	pcond(NEQ, regh,e3h,0,1,cond?l2:l1,COND_BRANCH);
         break;
     case LOP+UGT: case LOP+UGE:
-	pcond(UGT, e3h,regh,0,1,cond?l1:l2,COND_BRANCH);
-	pcond(NEQ, e3h,regh,0,1,cond?l2:l1,COND_BRANCH);
+	pcond(UGT, regh,e3h,0,1,cond?l1:l2,COND_BRANCH);
+	pcond(NEQ, regh,e3h,0,1,cond?l2:l1,COND_BRANCH);
         break;
     case LOP+EQ:
 	pcond(EQ, regh,e3h,0,0,cond?l2:l1,COND_BRANCH);
@@ -4821,7 +4833,7 @@
     default:
         error(-1);
     }
-    pcond(op%LOP,e3l,regl,0,cond,l1,COND_BRANCH);
+    pcond(op%LOP,regl,e3l,0,cond,l1,COND_BRANCH);
     fwddef(l2);  
     emit_lpop_free(e3);
 }
@@ -5327,7 +5339,8 @@
 code_d2ll(int reg)
 {
     // fixdfdi$stub
-    set_dreg(DREGISTER_OPERAND,1);
+    code_assign_input_double_long(
+	list2(LREGISTER,LREGISTER_OPERAND),list2(FREGISTER,freg)) ;
     extern_conv("__fixdfdi");
     set_lreg(RET_LREGISTER,0);
     if (reg!=USE_CREG&&reg!=RET_LREGISTER) {
@@ -5338,31 +5351,35 @@
 void
 code_d2ull(int reg)
 {
-    set_dreg(DREGISTER_OPERAND,1);
+    code_assign_input_double_long(
+	list2(LREGISTER,LREGISTER_OPERAND),list2(FREGISTER,freg)) ;
     extern_conv("__fixunsdfdi");
     set_lreg(RET_LREGISTER,0);
-    if (reg!=USE_CREG&&reg!=RET_LREGISTER)
+    if (reg!=USE_CREG&&reg!=RET_LREGISTER) {
 	use_longlong(reg);
+    }
 }
 
 void
 code_f2ll(int reg)
 {
-    set_freg(FREGISTER_OPERAND,1);
+    code_assign_input_float_int(list2(REGISTER,REGISTER_OPERAND),list2(FREGISTER,freg));
     extern_conv("__fixsfdi");
     set_lreg(RET_LREGISTER,0);
-    if (reg!=USE_CREG&&reg!=RET_LREGISTER)
+    if (reg!=USE_CREG&&reg!=RET_LREGISTER) {
 	use_longlong(reg);
+    }
 }
 
 void
 code_f2ull(int reg)
 {
-    set_freg(FREGISTER_OPERAND,1);
+    code_assign_input_float_int(list2(REGISTER,REGISTER_OPERAND),list2(FREGISTER,freg));
     extern_conv("__fixunssfdi");
     set_lreg(RET_LREGISTER,0);
-    if (reg!=USE_CREG&&reg!=RET_LREGISTER)
+    if (reg!=USE_CREG&&reg!=RET_LREGISTER) {
 	use_longlong(reg);
+    }
 }
 
 void
--- a/mc-code-mips.c	Sun Oct 17 13:13:43 2004 +0900
+++ b/mc-code-mips.c	Sun Oct 17 22:33:19 2004 +0900
@@ -2695,7 +2695,7 @@
 
     if (e<-32767||32766<e) {
 	rn = register_name(reg= get_register());
-	code_const(list2(CONST,e),reg);
+	code_const(e,reg);
 	switch(cond) {
 	case 1:
 	    printf("\tbne\t%s,%s,$L_%d\n",crn,rn,label); break;
--- a/mc-code-powerpc.c	Sun Oct 17 13:13:43 2004 +0900
+++ b/mc-code-powerpc.c	Sun Oct 17 22:33:19 2004 +0900
@@ -2628,7 +2628,7 @@
 	jcond(label,cond);
     } else {
 	reg = get_register();
-	code_const(list2(CONST,e),reg);
+	code_const(e,reg);
 	printf("\tcmpw cr%d,%s,%s\n",cmpflag,register_name(csreg),register_name(reg));
 	jcond(label,cond);
 	free_register(reg);
--- a/test/code-gen.c	Sun Oct 17 13:13:43 2004 +0900
+++ b/test/code-gen.c	Sun Oct 17 22:33:19 2004 +0900
@@ -1861,6 +1861,7 @@
     printf("ltosop u 6 %llu\n",u);
     u = u1 ^ u2;
     printf("ltosop u 7 %llu\n",u);
+    u2 = 3;
     u = u1 << u2;
     printf("ltosop u 8 %llu\n",u);
     u = u1 >> u2;
@@ -1882,6 +1883,7 @@
     printf("litosop 6 %lld\n",i);
     i = i1 ^ ii2;
     printf("litosop 7 %lld\n",i);
+    ii2 = 3;
     i = i1 << ii2;
     printf("litosop 8 %lld\n",i);
     i = i1 >> ii2;
@@ -1903,6 +1905,7 @@
     printf("litosop u 6 %llu\n",u);
     u = u1 ^ uu2;
     printf("litosop u 7 %llu\n",u);
+    uu2 = 3;
     u = u1 << uu2;
     printf("litosop u 8 %llu\n",u);
     u = u1 >> uu2;
@@ -1992,6 +1995,7 @@
     printf("ltosop r 6 %lld\n",i);
     i = i1 ^ i2;
     printf("ltosop r 7 %lld\n",i);
+    i2 = 3;
     i = i1 << i2;
     printf("ltosop r 8 %lld\n",i);
     i = i1 >> i2;
@@ -2013,6 +2017,7 @@
     printf("ltosop r u 6 %llu\n",u);
     u = u1 ^ u2;
     printf("ltosop r u 7 %llu\n",u);
+    u2 = 3;
     u = u1 << u2;
     printf("ltosop r u 8 %llu\n",u);
     u = u1 >> u2;
@@ -2034,6 +2039,7 @@
     printf("litosop r 6 %lld\n",i);
     i = i1 ^ ii2;
     printf("litosop r 7 %lld\n",i);
+    ii2 = 3;
     i = i1 << ii2;
     printf("litosop r 8 %lld\n",i);
     i = i1 >> ii2;
@@ -2055,6 +2061,7 @@
     printf("litosop r u 6 %llu\n",u);
     u = u1 ^ uu2;
     printf("litosop r u 7 %llu\n",u);
+    uu2 = 3;
     u = u1 << uu2;
     printf("litosop r u 8 %llu\n",u);
     u = u1 >> uu2;