Quick Search:

Mode

Context

Displaying 3 lines of context. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.290
 
1.291
 
MAIN:ragge:20110721090910
 
trees.c
_>11111111 stref(NODE *p)
 11121112 {
 11131113         NODE *r;
<>1114 -        struct attr *ap;
  1114+        struct attr *ap, *xap, *yap;
11151115         union dimfun *d;
 11161116         TWORD t, q;
 11171117         int dsc;
     
 !
11251125         nfree(p->n_right);
 11261126         r = p->n_left;
 11271127         nfree(p);
<> 1128+        xap = attr_find(r->n_ap, GCC_ATYP_PACKED);
  1129+
11281130         p = pconvert(r);
 11291131 
 11301132         /* make p look like ptr to x */
     
 !
11361138         q = INCQAL(s->squal);
 11371139         d = s->sdf;
 11381140         ap = s->sap;
<> 1141+        if ((yap = attr_find(ap, GCC_ATYP_PACKED)) != NULL)
  1142+                xap = yap;
  1143+        else if (xap != NULL)
  1144+                ap = attr_add(ap, attr_dup(xap, 3));
  1145+        /* xap set if packed struct */
11391146 
 11401147         p = makety(p, t, q, d, ap);
 11411148 
     
 !
11441151         off = s->soffset;
 11451152         dsc = s->sclass;
 11461153 
<>1147 -#ifndef CAN_UNALIGN
 1148 -        /*
 1149 -         * If its a packed struct, and the target cannot do unaligned
 1150 -         * accesses, then split it up in two bitfield operations.
 1151 -         * LHS and RHS accesses are different, so must delay
 1152 -         * it until we know.  Do the bitfield construct here though.
 1153 -         */
 1154 -        if ((dsc & FIELD) == 0 && (off % talign(s->stype, s->sap))) {
 1155 -#if 0
 1156 -                int sz = tsize(s->stype, s->sdf, s->sap);
 1157 -                int al = talign(s->stype, s->sap);
 1158 -                int sz1 = al - (off % al);
 1159 -#endif
 1160 -        }
 1161 -#endif
 1162 -
11631154         if (dsc & FIELD) {
 11641155                 TWORD ftyp = s->stype;
 11651156                 int fal = talign(ftyp, ap);
 11661157                 off = (off/fal)*fal;
 11671158                 p = offplus(p, off, t, q, d, ap);
<>1168 -                p = block(FLD, p, NIL, ftyp, 0, s->sap);
  1159+                p = block(FLD, p, NIL, ftyp, 0, ap);
11691160                 p->n_qual = q;
 11701161                 p->n_rval = PKFIELD(dsc&FLDSIZ, s->soffset%fal);
<>1171 -        } else
  1162+        } else {
11721163                 p = offplus(p, off, t, q, d, ap);
<> 1164+#ifndef CAN_UNALIGN
  1165+                /* if target cannot handle unaligned addresses, fix here */
  1166+#endif
  1167+        }
11731168 
 11741169         p = clocal(p);
 11751170         return p;
     
 !
23542349         return p;
 23552350 }
 23562351 
<> 2352+/* avoid promotion to int */
  2353+#define TYPLS(p, n, t)  clocal(block(LS, p, bcon(n), t, 0, 0))
  2354+#define TYPRS(p, n, t)  clocal(block(RS, p, bcon(n), t, 0, 0))
  2355+#define TYPOR(p, q, t)  clocal(block(OR, p, q, t, 0, 0))
  2356+
  2357+#ifndef UNALIGNED_ACCESS
  2358+/*
  2359+ * Read an unaligned bitfield from position pointed to by p starting at
  2360+ * off and size fsz and return a tree of type t with resulting data.
  2361+ */
  2362+static NODE *
  2363+rdualfld(NODE *p, TWORD t, int off, int fsz)
  2364+{
  2365+        int t2f, inbits, tsz;
  2366+        NODE *q, *r;
  2367+
  2368+        p = makety(p, PTR|UCHAR, 0, 0, 0);
  2369+
  2370+        /* traverse until first data byte */
  2371+        for (t2f = 0; off > SZCHAR; t2f++, off -= SZCHAR)
  2372+                ;
  2373+        q = buildtree(UMUL, buildtree(PLUS, ccopy(p), bcon(t2f)), 0);
  2374+        q = makety(TYPRS(q, off, UCHAR), t, 0, 0, 0);
  2375+        inbits = SZCHAR - off;
  2376+        t2f++;
  2377+
  2378+        while (fsz > inbits) {
  2379+                r = buildtree(UMUL, buildtree(PLUS, ccopy(p), bcon(t2f)), 0);
  2380+                r = makety(r, t, 0, 0, 0);
  2381+                r = TYPLS(r, inbits, t);
  2382+                q = TYPOR(q, r, t);
  2383+                inbits += SZCHAR;
  2384+                t2f++;
  2385+        }
  2386+        /* fix sign/zero extend XXX - RS must sign extend */
  2387+        tsz = (int)tsize(t, 0, 0);
  2388+        q = TYPLS(q, (tsz-fsz), t);
  2389+        q = TYPRS(q, (tsz-fsz), t);
  2390+        tfree(p);
  2391+
  2392+        return q;
  2393+}
  2394+#endif
  2395+
23572396 #ifndef FIELDOPS
 23582397 /*
 23592398  * Rewrite bitfield operations to shifts.
     
 !
23722411                 fsz = UPKFSZ(p->n_rval);
 23732412                 foff = UPKFOFF(p->n_rval);
 23742413                 tsz = tsize(q->n_type, 0, 0);
<> 2414+                /*
  2415+                                can_ua          no_ua
  2416+                normal          typeread        typeread
  2417+                packed          typeread        charread
  2418+                toobig (packed) dual typeread   charread
  2419+                 */
  2420+#ifdef UNALIGNED_ACCESS
  2421+                /* target can do unaligned access */
  2422+                if (fsz + foff < tsz) {
  2423+                        /* normal access of a type */
23752424 #if TARGET_ENDIAN == TARGET_BE
<>2376 -                foff = tsz - fsz - foff;
  2425+                        foff = tsz - fsz - foff;
23772426 #endif
<>2378 -                q = clocal(block(LS, q, bcon(tsz-fsz-foff), p->n_type, 0, 0));
 2379 -                q = clocal(block(RS, q, bcon(tsz-fsz), p->n_type, 0, 0));
  2427+                        q = clocal(block(LS, q,
  2428+                            bcon(tsz-fsz-foff), p->n_type, 0, 0));
  2429+                        q = clocal(block(RS, q, /* Assumed sign-extend RS */
  2430+                            bcon(tsz-fsz), p->n_type, 0, 0));
  2431+                } else {
  2432+                        int t2f;
  2433+
  2434+                        if (TARGET_ENDIAN == TARGET_BE)
  2435+                                uerror("no support for big-endian packed yet");
  2436+                        /* read type twice */
  2437+                        t1 = buildtree(ADDROF, q, NIL);
  2438+                        t2 = tempnode(0, t1->n_type, 0, 0);
  2439+                        t3 = ccopy(t2);
  2440+                        t4 = ccopy(t2);
  2441+                        t1 = buildtree(ASSIGN, t2, t1);
  2442+
  2443+                        /* Get first part of type */
  2444+                        t3 = cast(buildtree(UMUL, t3, NIL),
  2445+                             ENUNSIGN(p->n_type), 0);
  2446+                        t3 = clocal(block(RS, t3, bcon(foff),
  2447+                            ENUNSIGN(p->n_type), 0, 0));
  2448+
  2449+                        /* second part */
  2450+                        t2f = tsz+tsz-foff-fsz;
  2451+                        t4 = buildtree(UMUL, buildtree(PLUS, t4, bcon(1)), 0);
  2452+                        t4 = clocal(block(LS, t4, bcon(t2f), p->n_type, 0, 0));
  2453+                        t4 = clocal(block(RS, t4,
  2454+                             bcon(t2f-(tsz-foff)), p->n_type, 0, 0));
  2455+
  2456+                        /* merge */
  2457+                        q = buildtree(COMOP, t1,
  2458+                            clocal(block(OR, t3, t4 , p->n_type, 0, 0)));
  2459+                }
  2460+#else
  2461+                if (attr_find(p->n_ap, GCC_ATYP_PACKED) == 0) {
  2462+                        /* normal access of a type */
  2463+#if TARGET_ENDIAN == TARGET_BE
  2464+                        foff = tsz - fsz - foff;
  2465+#endif
  2466+                        q = clocal(block(LS, q,
  2467+                            bcon(tsz-fsz-foff), p->n_type, 0, 0));
  2468+                        q = clocal(block(RS, q, /* Assumed sign-extend RS */
  2469+                            bcon(tsz-fsz), p->n_type, 0, 0));
  2470+                } else {
  2471+                        /* Create an unsigned char byte pointer */
  2472+                        t1 = makety(buildtree(ADDROF, q, NIL),
  2473+                            PTR|UCHAR, 0, 0, 0);
  2474+                        t2 = tempnode(0, t1->n_type, 0, 0);
  2475+                        t3 = ccopy(t2);
  2476+                        t1 = buildtree(ASSIGN, t2, t1);
  2477+
  2478+                        q = rdualfld(t3, p->n_type, foff, fsz);
  2479+                        q = buildtree(COMOP, t1, q);
  2480+                }
  2481+#endif
<_23802482                 if (q->n_type != p->n_type)
 23812483                         q = cast(q, p->n_type, p->n_qual);
 23822484                 nfree(p);
FishEye: Open Source License registered to PCC.
Your maintenance has expired. You can renew your license at http://www.atlassian.com/fisheye/renew
Atlassian FishEye, CVS analysis. (Version:1.6.3 Build:build-336 2008-11-04) - Administration - Page generated 2014-09-30 12:16 +0200