diff mc-code-powerpc.c @ 335:4f98dc4b5fd8

bit-field continue... code-generation debug
author kono
date Fri, 25 Jun 2004 01:01:41 +0900
parents dc81596066df
children d488b72254fb
line wrap: on
line diff
--- a/mc-code-powerpc.c	Thu Jun 24 20:50:17 2004 +0900
+++ b/mc-code-powerpc.c	Fri Jun 25 01:01:41 2004 +0900
@@ -5093,8 +5093,8 @@
     switch(cadr(type)) { 
     case INT:		sign=1; bitsz=32; align=4;break; 
     case UNSIGNED:		bitsz=32; align=4;break; 
-    case CHAR:          sign=1; bitsz=24; align=1;break; 
-    case UCHAR: 		bitsz=24; align=1;break; 
+    case CHAR:          sign=1; bitsz= 8; align=1;break; 
+    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; 
@@ -5132,22 +5132,22 @@
 
 	i= offset-(bitpos+7)/8;
 
-	if ((i & (align-1)) && bitpos+bitsize < bitsz) {
-
-	    /* alignment is correct and space remains */
-
-	    *poffset=offset=i;
-	    i = bitpos+bitsize;
-	    *bfd = i;
-	    *sz = (i+7)/8;
-	    return bitpos;
-	} 
+	for(l = bitpos;l>0;l -= 8,i++) {
+	    if ((i & (align-1))==0 && l+bitsize < bitsz) {
+		/* alignment is correct and space remains */
+		*poffset=offset=i;
+		i = l+bitsize;
+		*bfd = i;
+		*sz = (i+7)/8;
+		return l;
+	    } 
+	}
     }
 
     /* first bit-field */
 
     if ((i=(offset & (align-1)))) {
-	*poffset = (offset += i);
+	*poffset = (offset += (align-i));
     }
     bitpos = 0;
     *bfd = bitsize;
@@ -5171,18 +5171,18 @@
 	use_longlong(reg);
 	/* shift left */
 	if (bitpos) 
-	    loprtc(LLSHIFT,reg,bitpos);
+	    loprtc(LLSHIFT,reg,list2(CONST,bitpos));
 	/* shift right */
 	if ((i=bitsz-bitsize)) 
-	    loprtc(sign?LRSHIFT:LURSHIFT,reg,i);
+	    loprtc(sign?LRSHIFT:LURSHIFT,reg,list2(CONST,i));
     } else {
 	use_int(reg);
 	/* shift left */
 	if (bitpos) 
-	    oprtc(LSHIFT,reg,bitpos);
+	    oprtc(LSHIFT,reg,list2(CONST,bitpos));
 	/* shift right */
 	if ((i=bitsz-bitsize)) 
-	    oprtc(sign?RSHIFT:URSHIFT,reg,i);
+	    oprtc(sign?RSHIFT:URSHIFT,reg,list2(CONST,i));
     }
 }
 
@@ -5233,7 +5233,7 @@
 	lrn = lregister_name_low(lvalue);
 	/* shift left */
 	if ((i=bitsz-bitsize-bitpos)) 
-	    loprtc(LLSHIFT,value,i);
+	    loprtc(LLSHIFT,value,list2(CONST,i));
 	trn = register_name(tmp = get_register());
 	if (bitpos+bitsize>32) {
 	    /* make and-mask lower */
@@ -5253,7 +5253,7 @@
 	lrn = register_name(lvalue);
 	/* shift left */
 	if ((i=bitsz-bitsize-bitpos)) 
-	    oprtc(LSHIFT,value,i);
+	    oprtc(LSHIFT,value,list2(CONST,i));
 	trn = register_name(tmp = get_register());
 	/* make and-mask */
 	mask = make_mask(bitpos+(32-bitsz),bitpos+bitsize);