Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.308
 
1.309
 
MAIN:ragge:20120620200110
 
trees.c
_>7878 static NODE *strargs(NODE *);
 7979 static void rmcops(NODE *p);
 8080 static NODE *tymatch(NODE *p);
<> 81+static NODE *rewincop(NODE *p1, NODE *p2, int op);
8182 void putjops(NODE *, void *);
<> 83+static int has_se(NODE *p);
8284 static struct symtab *findmember(struct symtab *, char *);
 8385 int inftn; /* currently between epilog/prolog */
 8486 
     
 !
338340                         nfree(l);
 339341                         return bcon(n);
 340342                 }
<> 343+        } else if ((cdope(o)&ASGOPFLG) && o != RETURN && o != CAST) {
  344+                /*
  345+                 * Handle side effects by storing address in temporary q.
  346+                 * Side effect nodes always have an UMUL.
  347+                 */
  348+                if (has_se(l)) {
  349+                        ll = l->n_left;
  350+
  351+                        q = cstknode(ll->n_type, ll->n_df, ll->n_ap);
  352+                        l->n_left = ccopy(q);
  353+                        q = buildtree(ASSIGN, q, ll);
  354+                } else
  355+                        q = bcon(0); /* No side effects */
  356+
  357+                /*
  358+                 * Modify the trees so that the compound op is rewritten.
  359+                 */
  360+                /* avoid casting of LHS */
  361+                if ((cdope(o) & SIMPFLG) && ISINTEGER(l->n_type))
  362+                        r = ccast(r, l->n_type, l->n_qual, l->n_df, l->n_ap);
  363+
  364+                r = buildtree(UNASG o, ccopy(l), r);
  365+                r = buildtree(ASSIGN, l, r);
  366+                l = q;
  367+                o = COMOP;
  368+        } else if (o == INCR || o == DECR) {
  369+                /*
  370+                 * Rewrite to (t=d,d=d+1,t)
  371+                 */
  372+                if (has_se(l)) {
  373+                        ll = l->n_left;
  374+
  375+                        q = cstknode(ll->n_type, ll->n_df, ll->n_ap);
  376+                        l->n_left = ccopy(q);
  377+                        q = buildtree(ASSIGN, q, ll);
  378+                } else
  379+                        q = bcon(0); /* No side effects */
  380+
  381+                /* Boolean has special syntax. */
  382+                if (l->n_type == BOOL) {
  383+                        r = rewincop(l, r, o == INCR ? ASSIGN : EREQ);
  384+                } else
  385+                        r = rewincop(l, r, o == INCR ? PLUSEQ : MINUSEQ);
  386+                l = q;
  387+                o = COMOP;
341388         }
<> 389+
  390+
342391 #ifndef CC_DIV_0
 343392 runtime:
 344393 #endif
     
 !
493542                         p->n_qual = l->n_qual;
 494543                         p->n_df = l->n_df;
 495544                         p->n_ap = l->n_ap;
<>496 -
 497 -                        /* FALLTHROUGH */
 498 -                case LSEQ:
 499 -                case RSEQ: /* ...but not for assigned types */
500545                         if(tsize(r->n_type, r->n_df, r->n_ap) > SZINT)
 501546                                 p->n_right = makety(r, INT, 0, 0, 0);
 502547                         break;
     
 !
599644 
 600645         }
 601646 
<>602 -/* Find a member in a struct or union.  May be an unnamed member */
  647+/*                     
  648+ * Rewrite ++/-- to (t=p, p++, t) ops on types that do not act act as usual.
  649+ */
  650+static NODE *
  651+rewincop(NODE *p1, NODE *p2, int op)
  652+{
  653+        NODE *t, *r;
  654+                
  655+        t = cstknode(p1->n_type, p1->n_df, p1->n_ap);
  656+        r = buildtree(ASSIGN, ccopy(t), ccopy(p1));
  657+        r = buildtree(COMOP, r, buildtree(op, p1, eve(p2)));
  658+        return buildtree(COMOP, r, t);
  659+}
  660+
  661+
  662+/* Find a member in a struct or union.  May be an unnamed member */
603663 static struct symtab *
 604664 findmember(struct symtab *sp, char *s)
 605665 {
     
 !
17241784                 else if( mt12 & MPTI ) return( TYPL+LVAL+TYMATCH+PUN );
 17251785                 break;
 17261786 
<>1727 -        case LSEQ:
 1728 -        case RSEQ:
 1729 -                if( mt12 & MINT ) return( TYPL+LVAL+OTHER );
 1730 -                break;
 1731 -
 1732 -        case MULEQ:
 1733 -        case DIVEQ:
 1734 -                if( mt12 & MDBI ) return( LVAL+TYMATCH );
 1735 -                break;
 1736 -
 1737 -        case MODEQ:
 1738 -        case ANDEQ:
 1739 -        case OREQ:
 1740 -        case EREQ:
 1741 -                if (mt12 & MINT)
 1742 -                        return(LVAL+TYMATCH);
 1743 -                break;
 1744 -
 1745 -        case PLUSEQ:
 1746 -        case MINUSEQ:
 1747 -        case INCR:
 1748 -        case DECR:
 1749 -                if (mt12 & MDBI)
 1750 -                        return(TYMATCH+LVAL);
 1751 -                else if ((mt1&MPTR) && (mt2&MINT))
 1752 -                        return(TYPL+LVAL+CVTR);
 1753 -                break;
 1754 -
17551787         case MINUS:
 17561788                 if (mt12 & MPTR)
 17571789                         return(CVTO+PTMATCH+PUN);
     
 !
22842316         return 0;
 22852317 }
 22862318 
<>2287 -/*
 2288 - * Find and convert asgop's to separate statements.
 2289 - * Be careful about side effects.
 2290 - * assign tells whether ASSIGN should be considered giving
 2291 - * side effects or not.
 2292 - */
 2293 -static NODE *
 2294 -delasgop(NODE *p)
 2295 -{
 2296 -        NODE *q, *r;
 2297 -        int tval;
 2298 -
 2299 -        if (p->n_op == INCR || p->n_op == DECR) {
 2300 -                /*
 2301 -                 * Rewrite x++ to (x += 1) -1; and deal with it further down.
 2302 -                 * Pass2 will remove -1 if unnecessary.
 2303 -                 */
 2304 -                q = ccopy(p);
 2305 -                tfree(p->n_left);
 2306 -                q->n_op = (p->n_op==INCR)?PLUSEQ:MINUSEQ;
 2307 -                p->n_op = (p->n_op==INCR)?MINUS:PLUS;
 2308 -                p->n_left = delasgop(q);
 2309 -
 2310 -        } else if ((cdope(p->n_op)&ASGOPFLG) &&
 2311 -            p->n_op != RETURN && p->n_op != CAST) {
 2312 -                NODE *l = p->n_left;
 2313 -                NODE *ll = l->n_left;
 2314 -
 2315 -                if (has_se(l)) {
 2316 -                        q = tempnode(0, ll->n_type, ll->n_df, ll->n_ap);
 2317 -                        tval = regno(q);
 2318 -                        r = tempnode(tval, ll->n_type, ll->n_df,ll->n_ap);
 2319 -                        l->n_left = q;
 2320 -                        /* Now the left side of node p has no side effects. */
 2321 -                        /* side effects on the right side must be obeyed */
 2322 -                        p = delasgop(p);
 2323 -                        
 2324 -                        r = buildtree(ASSIGN, r, ll);
 2325 -                        r = delasgop(r);
 2326 -                        ecode(r);
 2327 -                } else {
 2328 -#if 0 /* Cannot call buildtree() here, it would invoke double add shifts */
 2329 -                        p->n_right = buildtree(UNASG p->n_op, ccopy(l),
 2330 -                            p->n_right);
 2331 -#else
 2332 -                        p->n_right = block(UNASG p->n_op, ccopy(l),
 2333 -                            p->n_right, p->n_type, p->n_df, p->n_ap);
 2334 -#endif
 2335 -                        p->n_op = ASSIGN;
 2336 -                        p->n_right = delasgop(p->n_right);
 2337 -                        p->n_right = clocal(p->n_right);
 2338 -                }
 2339 -                
 2340 -        } else {
 2341 -                if (coptype(p->n_op) == LTYPE)
 2342 -                        return p;
 2343 -                p->n_left = delasgop(p->n_left);
 2344 -                if (coptype(p->n_op) == BITYPE)
 2345 -                        p->n_right = delasgop(p->n_right);
 2346 -        }
 2347 -        return p;
 2348 -}
 2349 -
23502319 #ifndef FIELDOPS
 23512320 
 23522321 /* avoid promotion to int */
     
 !
26442613 #endif
 26452614         comops(p);
 26462615         rmcops(p);
<>2647 -        p = delasgop(p);
26482616         if (p->n_op == ICON && p->n_type == VOID)
 26492617                 tfree(p);
 26502618         else
     
 !
29012869         case PCONV:
 29022870                 return p;
 29032871 
<>2904 -        case PLUSEQ:
29052872         case PLUS:
<>2906 -        case INCR:
 2907 -        case DECR:
29082873                 if (!ISPTR(p->n_left->n_type)) {
 29092874                         if (!ISPTR(p->n_right->n_type))
 29102875                                 cerror("no * in PLUS");
     
 !
29132878                         p->n_left = pprop(p->n_left, t, ap);
 29142879                 return p;
 29152880 
<>2916 -        case MINUSEQ:
29172881         case MINUS:
 29182882                 if (ISPTR(p->n_left->n_type)) {
 29192883                         if (ISPTR(p->n_right->n_type))
     
 !
30232987         p = rmpconv(p);
 30242988 #endif
 30252989         p = optim(p);
<>3026 -        p = delasgop(p);
<_30272990         p = deldcall(p, 0);
 30282991         walkf(p, delvoid, 0);
 30292992 #ifdef PCC_DEBUG
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-10-31 06:38 +0100