Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.280
 
1.281
 
MAIN:ragge:20110529131404
 
trees.c
_>24082408         return p;
 24092409 }
 24102410 
<> 2411+#ifndef FIELDOPS
  2412+/*
  2413+ * Rewrite bitfield operations to shifts.
  2414+ */
  2415+static NODE *
  2416+rmfldops(NODE *p)
  2417+{
  2418+        CONSZ msk;
  2419+        TWORD t;
  2420+        NODE *q, *r, *t1, *t2, *bt, *t3, *t4;
  2421+        int fsz, foff, tsz;
  2422+
  2423+        if (p->n_op == FLD) {
  2424+                /* Rewrite a field read operation */
  2425+                q = p->n_left;
  2426+                fsz = UPKFSZ(p->n_rval);
  2427+                foff = UPKFOFF(p->n_rval);
  2428+                tsz = tsize(q->n_type, 0, 0);
  2429+#ifndef RTOLBYTES
  2430+                foff = tsz - fsz - foff;
  2431+#endif
  2432+                q = clocal(block(LS, q, bcon(tsz-fsz-foff), p->n_type, 0, 0));
  2433+                q = clocal(block(RS, q, bcon(tsz-fsz), p->n_type, 0, 0));
  2434+                if (q->n_type != p->n_type)
  2435+                        q = cast(q, p->n_type, p->n_qual);
  2436+                nfree(p);
  2437+                p = q;
  2438+        } else if (((cdope(p->n_op)&ASGOPFLG) || p->n_op == ASSIGN ||
  2439+            p->n_op == INCR || p->n_op == DECR) && p->n_left->n_op == FLD) {
  2440+                /*
  2441+                 * Rewrite a field write operation
  2442+                 * More difficult than a read op since we must care
  2443+                 * about side effects.
  2444+                 */
  2445+                q = p->n_left;
  2446+                fsz = UPKFSZ(q->n_rval);
  2447+                foff = UPKFOFF(q->n_rval);
  2448+                t = q->n_left->n_type;
  2449+                tsz = tsize(t, 0, 0);
  2450+#ifndef RTOLBYTES
  2451+                foff = tsz - fsz - foff;
  2452+#endif
  2453+                msk = (((1LL << (fsz-1))-1) << 1) | 1;
  2454+                bt = NULL;
  2455+                if (p->n_right->n_op != ICON && p->n_right->n_op != NAME) {
  2456+                        t2 = tempnode(0, p->n_right->n_type, 0, 0);
  2457+                        bt = buildtree(ASSIGN, ccopy(t2), p->n_right);
  2458+                } else
  2459+                        t2 = p->n_right;
  2460+
  2461+                if (q->n_left->n_op == UMUL) {
  2462+                        /* LHS of assignment may have side effects */
  2463+                        q = q->n_left;
  2464+                        t1 = tempnode(0, q->n_left->n_type, 0, 0);
  2465+                        r = buildtree(ASSIGN, ccopy(t1), q->n_left);
  2466+                        
  2467+                        bt = bt ? block(COMOP, bt, r, INT, 0, 0) : r;
  2468+                        q->n_left = t1;
  2469+                }
  2470+                t1 = p->n_left->n_left;
  2471+
  2472+                if (p->n_op == ASSIGN) {
  2473+                        q = clocal(block(AND, ccopy(t1),
  2474+                            xbcon(~(msk << foff), 0, t), t, 0,0));
  2475+
  2476+                        r = clocal(block(AND, ccopy(t2),
  2477+                            xbcon(msk, 0, t), t, 0, 0));
  2478+                        r = clocal(block(LS, r, bcon(foff), t, 0, 0));
  2479+                        q = clocal(block(OR, q, r, t, 0, 0));
  2480+                        q = block(ASSIGN, t1, q, t, 0, 0);
  2481+                        if (bt)
  2482+                                q = block(COMOP, bt, q, t, 0, 0);
  2483+                        nfree(p->n_left);
  2484+                        p->n_left = q;
  2485+                        p->n_right = t2;
  2486+                        p->n_op = COMOP;
  2487+                } else if ((cdope(p->n_op)&ASGOPFLG)) {
  2488+                        /* And here is the asgop-specific code */
  2489+                        t3 = tempnode(0, t, 0, 0);
  2490+                        q = buildtree(ASSIGN, ccopy(t3), ccopy(t1));
  2491+                        if (bt)
  2492+                                bt = block(COMOP, bt, q, t, 0, 0);
  2493+                        else
  2494+                                bt = q;
  2495+
  2496+                        q = clocal(block(LS, t3, bcon(tsz-fsz-foff), t, 0, 0));
  2497+                        q = clocal(block(RS, q, bcon(tsz-fsz), t, 0, 0));
  2498+                        nfree(p->n_left);
  2499+                        p->n_right = t2;
  2500+                        p->n_left = q;
  2501+                        p->n_op = UNASG p->n_op;
  2502+
  2503+                        q = clocal(block(AND, ccopy(t1),
  2504+                            xbcon(~(msk << foff), 0, t), t, 0,0));
  2505+                        r = clocal(block(AND, p, xbcon(msk, 0, t), t, 0, 0));
  2506+                        r = clocal(block(LS, r, bcon(foff), t, 0, 0));
  2507+                        q = clocal(block(OR, q, r, t, 0, 0));
  2508+                        q = block(ASSIGN, ccopy(t1), q, t, 0, 0);
  2509+                        q = block(COMOP, bt, q, t, 0, 0);
  2510+                        p = buildtree(COMOP, q, t1);
  2511+                } else {
  2512+                        t3 = tempnode(0, t, 0, 0);
  2513+                        q = buildtree(ASSIGN, ccopy(t3), ccopy(t1));
  2514+                        if (bt)
  2515+                                bt = block(COMOP, bt, q, t, 0, 0);
  2516+                        else
  2517+                                bt = q;
  2518+
  2519+                        q = clocal(block(LS, t3, bcon(tsz-fsz-foff), t, 0, 0));
  2520+                        q = clocal(block(RS, q, bcon(tsz-fsz), t, 0, 0));
  2521+                        t4 = tempnode(0, t, 0, 0);
  2522+                        q = buildtree(ASSIGN, ccopy(t4), q);
  2523+
  2524+                        nfree(p->n_left);
  2525+                        p->n_right = t2;
  2526+                        p->n_left = q;
  2527+                        p->n_op = p->n_op == INCR ? PLUS : MINUS;
  2528+
  2529+                        q = clocal(block(AND, ccopy(t1),
  2530+                            xbcon(~(msk << foff), 0, t), t, 0,0));
  2531+                        r = clocal(block(AND, p, xbcon(msk, 0, t), t, 0, 0));
  2532+                        r = clocal(block(LS, r, bcon(foff), t, 0, 0));
  2533+                        q = clocal(block(OR, q, r, t, 0, 0));
  2534+                        q = block(ASSIGN, t1, q, t, 0, 0);
  2535+                        q = block(COMOP, bt, q, t, 0, 0);
  2536+                        p = buildtree(COMOP, q, t4);
  2537+                }
  2538+        }
  2539+        if (coptype(p->n_op) != LTYPE)
  2540+                p->n_left = rmfldops(p->n_left);
  2541+        if (coptype(p->n_op) == BITYPE)
  2542+                p->n_right = rmfldops(p->n_right);
  2543+        return p;
  2544+}
  2545+#endif
  2546+
24112547 int edebug = 0;
 24122548 void
 24132549 ecomp(NODE *p)
     
 !
24222558                 reached = 1;
 24232559         }
 24242560         p = optim(p);
<> 2561+#ifndef FIELDOPS
  2562+        p = rmfldops(p);
  2563+#endif
<_24252564         comops(p);
 24262565         rmcops(p);
 24272566         p = delasgop(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-19 17:50 +0200