Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.95
 
1.96
 
MAIN:ragge:20040520132618
 
reader.c
_>502502                 if ((rv = findops(p, cookie)) < 0) {
 503503                         if (setbin(p))
 504504                                 goto again;
<>505 -                } else
 506 -                        goto sw;
 507 -
  505+                } else {
  506+                        /* Do tree rewriting to ensure correct incr */
  507+                        if ((rv & LMASK) != LREG)
  508+                                goto sw;
  509+                }
508510                 /*
 509511                  * Rewrite x++ to (x = x + 1) -1;
 510512                  */
     
 !
11311133 {
 11321134         extern int *qtable[];
 11331135         struct optab *q;
<>1134 -        int i, shl, shr, tl, tr, is3, rsr, rsl, osr, osl;
  1136+        int i, shl, shr, tl, tr, is3;
11351137         NODE *l, *r;
 11361138         int *ixp;
 11371139         int rv = -1, mtchno = 10;
     
 !
11511153                         continue; /* Types must be correct */
 11521154 
 11531155 if (f2debug) printf("findop got types\n");
<>1154 -                shl = tshape(l, q->lshape);
 1155 -if (shl != SRDIR) shl = 0;
 1156 -                if ((q->lshape & SPECIAL) == 0) {
 1157 -                        rsl = (q->lshape & (SAREG|STAREG)) != 0;
 1158 -                        osl = (q->lshape & SOREG) && l->n_op == UMUL;
 1159 -                } else
 1160 -                        rsl = osl = 0;
 1161 -                
 1162 -                if (shl == 0 && rsl == 0)
  1156+                if ((shl = tshape(l, q->lshape)) == SRNOPE)
11631157                         continue; /* useless */
 11641158 if (f2debug) printf("findop lshape %d\n", shl);
 11651159 if (f2debug) fwalk(l, e2print, 0);
<>1166 -                shr = tshape(r, q->rshape);
 1167 -if (shr != SRDIR) shr = 0;
 1168 -                if ((q->rshape & SPECIAL) == 0) {
 1169 -                        rsr = (q->rshape & (SAREG|STAREG)) != 0;
 1170 -                        osr = (q->rshape & SOREG) && r->n_op == UMUL;
 1171 -                } else
 1172 -                        rsl = osl = 0;
 1173 -                if (shr == 0 && rsr == 0)
  1160+                if ((shr = tshape(r, q->rshape)) == SRNOPE)
11741161                         continue; /* useless */
 11751162 if (f2debug) printf("findop rshape %d\n", shr);
 11761163 if (f2debug) fwalk(r, e2print, 0);
     
 !
11811168                 tr = istnode(p->n_right);
 11821169                 is3 = ((q->rewrite & (RLEFT|RRIGHT)) == 0);
 11831170 
<>1184 -                if (shl && shr) {
  1171+                if (shl == SRDIR && shr== SRDIR ) {
11851172                         int got = 10;
 11861173                         /*
<>1187 -                         * Both shapes matches. If one of them is in a
 1188 -                         * temp register and there is a corresponding
  1174+                         * Both shapes matches direct. If one of them is
  1175+                         * in a temp register and there is a corresponding
11891176                          * 2-op instruction, be very happy. If not, but
 11901177                          * there is a 3-op instruction that ends in a reg,
 11911178                          * be quite happy. If neither, cannot do anything.
     
 !
12051192                                 continue;
 12061193                 }
 12071194 if (f2debug) printf("second\n");
<>1208 -                if (shr) {
  1195+                if (shr == SRDIR) {
12091196                         /*
 12101197                          * Right shape matched. If left node can be put into
 12111198                          * a temporary register, and the current op matches,
     
 !
12151202                                 /* put left in temp, add to right */
 12161203                                 if (4 < mtchno) {
 12171204                                         mtchno = 4;
<>1218 -                                        rv = MKIDX(ixp[i], LREG);
  1205+                                        rv = MKIDX(ixp[i], shltab[shl]);
12191206                                 }
 12201207                         } else if (q->rewrite & RLEFT) {
 12211208                                 if (4 < mtchno) {
     
 !
12261213                         } else if (is3) {
 12271214                                 if (5 < mtchno) {
 12281215                                         mtchno = 5;
<>1229 -                                        rv = MKIDX(ixp[i], LREG);
  1216+                                        rv = MKIDX(ixp[i], shltab[shl]);
12301217                                 }
 12311218                                 continue; /* Can't do anything else */
 12321219                         }
 12331220                 }
 12341221 if (f2debug) printf("third\n");
<>1235 -                if (shl) {
  1222+                if (shl == SRDIR) {
12361223                         /*
 12371224                          * Left shape matched. If right node can be put into
 12381225                          * a temporary register, and the current op matches,
     
 !
12421229                                 /* put right in temp, add to left */
 12431230                                 if (4 < mtchno) {
 12441231                                         mtchno = 4;
<>1245 -                                        rv = MKIDX(ixp[i], RREG);
  1232+                                        rv = MKIDX(ixp[i], shrtab[shr]);
12461233                                 }
 12471234                         } else if (q->rewrite & RRIGHT) {
 12481235                                 if (4 < mtchno) {
     
 !
12531240                         } else if (is3) {
 12541241                                 if (5 < mtchno) {
 12551242                                         mtchno = 5;
<>1256 -                                        rv = MKIDX(ixp[i], RREG);
  1243+                                        rv = MKIDX(ixp[i], shrtab[shr]);
12571244                                 }
 12581245                                 continue; /* Can't do anything */
 12591246                         }
     
 !
12621249                  * Neither of the shapes matched. Put both args in
 12631250                  * regs and be done with it.
 12641251                  */
<>1265 -                if (rsr && rsl) { /* both can be in reg */
 1266 -                        if (is3) {
 1267 -                                if (7 < mtchno) {
 1268 -                                        mtchno = 7;
 1269 -                                        rv = MKIDX(ixp[i], RREG|LREG);
 1270 -                                }
 1271 -                        } else {
 1272 -                                if (6 < mtchno) {
 1273 -                                        mtchno = 6;
 1274 -                                        rv = MKIDX(ixp[i], RREG|LREG);
 1275 -                                }
  1252+                if (is3) {
  1253+                        if (7 < mtchno) {
  1254+                                mtchno = 7;
  1255+                                rv = MKIDX(ixp[i], shltab[shl]|shrtab[shr]);
12761256                         }
<> 1257+                } else {
  1258+                        if (6 < mtchno) {
  1259+                                mtchno = 6;
  1260+                                if (q->rewrite & RLEFT)
  1261+                                        rv = MKIDX(ixp[i], shrtab[shr]|LREG);
  1262+                                else
  1263+                                        rv = MKIDX(ixp[i], shltab[shl]|RREG);
  1264+                        }
12771265                 }
 12781266         }
 12791267 #ifdef PCC_DEBUG
     
 !
13111299 {
 13121300         extern int *qtable[];
 13131301         struct optab *q;
<>1314 -        int i, shl, shr/* , rsr, rsl */;
  1302+        int i, shl, shr;
13151303         NODE *l, *r;
 13161304         int *ixp;
 13171305         int rv = -1, mtchno = 10;
     
 !
13321320 
 13331321 if (f2debug) printf("relops got types\n");
 13341322                 shl = tshape(l, q->lshape);
<>1335 -#if 0
 1336 -                rsl = (q->lshape & (SAREG|STAREG)) != 0 &&
 1337 -                    (q->lshape & SPECIAL) == 0;
 1338 -                if (rsl == 0 && l->n_op == UMUL && (q->lshape & SOREG))
 1339 -                        rsl = 2;
 1340 -                if (shl == 0 && rsl == 0)
 1341 -                        continue; /* useless */
 1342 -#else
13431323                 if (shl == 0)
 13441324                         continue; /* useless */
<>1345 -#endif
13461325 if (f2debug) printf("relops lshape %d\n", shl);
 13471326 if (f2debug) fwalk(l, e2print, 0);
 13481327                 shr = tshape(r, q->rshape);
<>1349 -#if 0
 1350 -                rsr = (q->rshape & (SAREG|STAREG)) != 0 &&
 1351 -                    (q->rshape & SPECIAL) == 0;
 1352 -                if (shr == 0 && rsr == 0)
 1353 -                        continue; /* useless */
 1354 -#else
13551328                 if (shr == 0)
 13561329                         continue; /* useless */
<>1357 -#endif
13581330 if (f2debug) printf("relops rshape %d\n", shr);
 13591331 if (f2debug) fwalk(r, e2print, 0);
 13601332                 if (q->needs & REWRITE)
     
 !
13641336                         mtchno = shl+shr;
 13651337                         rv = MKIDX(ixp[i], shltab[shl]|shrtab[shr]);
 13661338                 }
<>1367 -#if 0
 1368 -                if (shl && shr) {
 1369 -                        /*
 1370 -                         * Both shapes matches directly. For relops this
 1371 -                         * is the best match; just return.
 1372 -                         */
 1373 -                        rv = MKIDX(ixp[i], 0);
 1374 -                        break;
 1375 -                }
 1376 -if (f2debug) printf("second\n");
 1377 -                if (shr) {
 1378 -                        /*
 1379 -                         * Right shape matched. If left node can be put into
 1380 -                         * a temporary register, and the current op matches,
 1381 -                         * be happy.
 1382 -                         */
 1383 -                        if (4 < mtchno) {
 1384 -                                mtchno = 4;
 1385 -                                rv = MKIDX(ixp[i], LREG);
 1386 -                        }
 1387 -                        continue; /* nothing more to do */
 1388 -                }
 1389 -if (f2debug) printf("third\n");
 1390 -                if (shl) {
 1391 -                        /*
 1392 -                         * Left shape matched. If right node can be put into
 1393 -                         * a temporary register, and the current op matches,
 1394 -                         * be happy.
 1395 -                         */
 1396 -                        if (4 < mtchno) {
 1397 -                                mtchno = 4;
 1398 -                                rv = MKIDX(ixp[i], RREG);
 1399 -                        }
 1400 -                        continue; /* nothing more to do */
 1401 -                }
 1402 -                if (6 < mtchno) {
 1403 -                        mtchno = 6;
 1404 -                        rv = MKIDX(ixp[i], RREG|LREG);
 1405 -                }
 1406 -#endif
14071339         }
 14081340 #ifdef PCC_DEBUG
 14091341         if (f2debug) {
     
 !
14351367 {
 14361368         extern int *qtable[];
 14371369         struct optab *q;
<>1438 -        int i, shl, shr, rsr, lvl = 10;
  1370+        int i, shl, shr, lvl = 10;
14391371         NODE *l, *r;
 14401372         int *ixp;
 14411373         int rv = -1;
     
 !
14631395                         continue; /* must get a result somehere */
 14641396 
 14651397 if (f2debug) printf("asgop got types\n");
<>1466 -                shl = tshape(l, q->lshape);
 1467 -if (shl != SRDIR) shl = 0;
 1468 -                if (shl == 0) {
 1469 -                        /* See if this can end up as an OREG */
 1470 -                        if (p->n_left->n_op != UMUL)
 1471 -                                continue;
 1472 -                        if ((q->lshape & SOREG) == 0)
 1473 -                                continue;
 1474 -                }
 1475 -
  1398+                if ((shl = tshape(l, q->lshape)) == SRNOPE || shl == SRREG)
  1399+                        continue;
14761400 if (f2debug) printf("asgop lshape %d\n", shl);
 14771401 if (f2debug) fwalk(l, e2print, 0);
 14781402 
<>1479 -                shr = tshape(r, q->rshape);
 1480 -if (shr != SRDIR) shr = 0;
 1481 -                rsr = (q->rshape & (SAREG|STAREG)) != 0 &&
 1482 -                    (q->rshape & SPECIAL) == 0;
 1483 -                if (shr == 0 && rsr == 0)
  1403+                if ((shr = tshape(r, q->rshape)) == SRNOPE)
14841404                         continue; /* useless */
<> 1405+
14851406 if (f2debug) printf("asgop rshape %d\n", shr);
 14861407 if (f2debug) fwalk(r, e2print, 0);
 14871408                 if (q->needs & REWRITE)
 14881409                         break;  /* Done here */
 14891410 
<>1490 -                if (shl && shr) {
 1491 -                        /*
 1492 -                         * Both shapes matches.
 1493 -                         * Ideal situation, encode and be done with it.
 1494 -                         */
 1495 -                        rv = MKIDX(ixp[i], 0);
 1496 -                        break;
 1497 -                }
 1498 -if (f2debug) printf("second\n");
 1499 -                if (shl) {
 1500 -                        /*
 1501 -                         * Left shape matched. Right node must be put into
 1502 -                         * a temporary register.
 1503 -                         */
 1504 -                        if (lvl < 3)
 1505 -                                continue;
 1506 -                        lvl = 3;
 1507 -                        rv = MKIDX(ixp[i], RREG);
  1411+                if (lvl < (shl + shr))
15081412                         continue;
<>1509 -                }
 1510 -                if (shr) {
 1511 -                        if (lvl < 4)
 1512 -                                continue;
 1513 -                        lvl = 4;
 1514 -                        rv = MKIDX(ixp[i], LOREG);
 1515 -                        continue;
 1516 -                }
 1517 -                if (lvl < 6)
 1518 -                        continue;
 1519 -                lvl = 6;
 1520 -                rv = MKIDX(ixp[i], LOREG|RREG);
  1413+                lvl = shl + shr;
  1414+                
  1415+                rv = MKIDX(ixp[i], shltab[shl]|shrtab[shr]);
15211416         }
 15221417 #ifdef PCC_DEBUG
 15231418         if (f2debug) {
     
 !
15591454                         continue; /* Type must be correct */
 15601455 
 15611456 if (f2debug) printf("findleaf got types\n");
<>1562 -                shl = tshape(p, q->rshape);
 1563 -if (shl != SRDIR) shl = 0;
 1564 -                if (shl == 0)
  1457+                if ((shl = tshape(p, q->rshape)) != SRDIR)
15651458                         continue; /* shape must match */
 15661459 
 15671460 if (f2debug) printf("findleaf got shapes %d\n", shl);
     
 !
15941487         extern int *qtable[];
 15951488         struct optab *q;
 15961489         NODE *l, *r;
<>1597 -        int i, shl, rsl;
  1490+        int i, shl, num = 4;
15981491         int *ixp;
 15991492         int rv = -1;
 16001493 
     
 !
16201513                         continue; /* Type must be correct */
 16211514 
 16221515 if (f2debug) printf("finduni got types\n");
<>1623 -                shl = tshape(l, q->lshape);
 1624 -if (shl != SRDIR) shl = 0;
 1625 -                rsl = (q->lshape & (SAREG|STAREG)) != 0 &&
 1626 -                    (q->lshape & SPECIAL) == 0;
 1627 -                if (shl == 0 && rsl == 0)
 1628 -                        continue; /* shape or regs must match */
  1516+                if ((shl = tshape(l, q->lshape)) == SRNOPE)
  1517+                        continue; /* shape must match */
16291518 
 16301519                 if (q->rewrite & RLEFT) {
 16311520                         /* left node must be in a temp register */
 16321521                         if (l->n_op == REG && !istreg(l->n_rval))
<>1633 -                                shl = 0;
  1522+                                shl = SRREG;
16341523                 }
 16351524 
 16361525 if (f2debug) printf("finduni got shapes %d\n", shl);
 16371526                 if (q->needs & REWRITE)
 16381527                         break;  /* Done here */
 16391528 
<>1640 -                rv = MKIDX(ixp[i], shl ? 0 : LREG);
 1641 -                if (shl)
  1529+                if (shl >= num)
  1530+                        continue;
  1531+                num = shl;
  1532+                rv = MKIDX(ixp[i], shltab[shl]);
  1533+                if (shl == SRDIR)
<_16421534                         break;
 16431535         }
 16441536 #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-09-19 19:52 +0200