diff mc-code-mips.c @ 337:694cdf15c5bd

MIPS bit-field done.
author kono
date Fri, 25 Jun 2004 05:37:09 +0900
parents d488b72254fb
children 7fe7ce0a791f
line wrap: on
line diff
--- a/mc-code-mips.c	Fri Jun 25 03:56:48 2004 +0900
+++ b/mc-code-mips.c	Fri Jun 25 05:37:09 2004 +0900
@@ -5432,8 +5432,8 @@
     case UCHAR: 		bitsz= 8; align=1;break; 
     case SHORT:         sign=1; bitsz=16; align=2;break; 
     case USHORT:        sign=1; bitsz=16; align=2;break; 
-    case LONGLONG:      sign=1; bitsz=64; align=4;l=1; break; 
-    case ULONGLONG:            	bitsz=64; align=4;l=1; break; 
+    case LONGLONG:      sign=1; bitsz=64; align=8;l=1; break; 
+    case ULONGLONG:            	bitsz=64; align=8;l=1; break; 
     default: error(-1);
     }
     *psign = sign;
@@ -5508,18 +5508,18 @@
     if (l==1) {
 	use_longlong(reg);
 	/* shift left */
-	if (bitpos) 
-	    loprtc(LLSHIFT,reg,list2(CONST,bitpos));
+	if ((i=bitsz-bitsize-bitpos)) 
+	    loprtc(LLSHIFT,reg,list2(CONST,i));
 	/* shift right */
 	if ((i=bitsz-bitsize)) 
 	    loprtc(sign?LRSHIFT:LURSHIFT,reg,list2(CONST,i));
     } else {
 	use_int(reg);
 	/* shift left */
-	if ((i=bitpos+(32-bitsz))) 
+	if ((i=32-bitsize-bitpos)) 
 	    oprtc(LSHIFT,reg,list2(CONST,i));
 	/* shift right */
-	if ((i=bitsz-bitsize+(32-bitsz))) 
+	if ((i=32-bitsize)) 
 	    oprtc(sign?RSHIFT:URSHIFT,reg,list2(CONST,i));
     }
 }
@@ -5548,12 +5548,15 @@
     int bitsize = cadddr(type);
     int mask = 0;
     int tmp = -1;
+#if 0
     int i;
+#endif
     char *crn,*lrn,*trn;
     set_bitsz(type,&sign,&bitsz,&align,&l);
 // printf("# %d: bitpos=%d bitsize=%d bitsz=%d\n",lineno,bitpos,bitsize,bitsz);
     if (l) {
 	use_longlong(value);
+#if 0
 	crn = lregister_name_low(value);
 	lrn = lregister_name_low(lvalue);
 	/* shift left */
@@ -5572,16 +5575,44 @@
 	    mask = make_mask(bitpos,bitpos+bitsize>=32?31:bitpos+bitsize-1);
 	    make_mask_and_or(mask,tmp,trn,crn,lrn);
 	}
+#else
+	crn = lregister_name_high(value);
+	lrn = lregister_name_high(lvalue);
+	/* shift left */
+	if (bitpos) 
+	    loprtc(LLSHIFT,value,list2(CONST,bitpos));
+	trn = register_name(tmp = get_register());
+	if (bitpos+bitsize>=32) {
+	    /* make and-mask upper */
+	    mask = make_mask(64-bitpos-bitsize,bitpos>=32?63-bitpos:31);
+	    make_mask_and_or(mask,tmp,trn,crn,lrn);
+	}
+	crn = lregister_name_low(value);
+	lrn = lregister_name_low(lvalue);
+	if (bitpos<32) {
+	    /* make and-mask lower */
+	    mask = make_mask(bitpos+bitsize>=32?0:32-bitpos-bitsize,31-bitpos);
+	    make_mask_and_or(mask,tmp,trn,crn,lrn);
+	}
+#endif
     } else {
 	use_int(value);
 	crn = register_name(value);
 	lrn = register_name(lvalue);
 	/* shift left */
+#if 0
 	if ((i=bitsz-bitsize-bitpos)) 
 	    oprtc(LSHIFT,value,list2(CONST,i));
 	trn = register_name(tmp = get_register());
 	/* make and-mask */
 	mask = make_mask(bitpos+(32-bitsz),bitpos+bitsize-1+(32-bitsz));
+#else
+	if (bitpos) 
+	    oprtc(LSHIFT,value,list2(CONST,bitpos));
+	trn = register_name(tmp = get_register());
+	/* make and-mask */
+	mask = make_mask(32-bitpos-bitsize,31-bitpos);
+#endif
 	make_mask_and_or(mask,tmp,trn,crn,lrn);
     }
     if (tmp!=-1) free_register(tmp);