Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.56
 
1.57
 
MAIN:ragge:20030908082733
 
reader.c
_>6060 void optdump(struct interpass *ip);
 6161 void cvtemps(struct interpass *epil);
 6262 static int findops(NODE *p);
<> 63+static int relops(NODE *p);
6364 
 6465 #define DELAYS 20
 6566 NODE *deltrees[DELAYS];
     
 !
292293 void
 293294 order(NODE *p, int cook)
 294295 {
<>295 -        int o, ty, m;
  296+        int o, ty, m, rv;
296297         int cookie;
 297298         NODE *p1, *p2;
 298299 
     
 !
337338         case RS:
 338339                 {
 339340                         struct optab *q;
<>340 -                        int rv;
341341 
 342342                         /*
 343343                          * Be sure that both sides are addressable.
     
 !
365365                          */
 366366 #define LTMP    1
 367367 #define RTMP    2
<> 368+                        m = INTAREG|INTBREG;
368369                         rv = findops(p);
<>369 -                        if (rv < 0) {
  370+foo:                    if (rv < 0) {
370371                                 if (setnbin(p))
 371372                                         goto again;
 372373                                 goto nomat;
     
 !
396397                                 }
 397398                                 cerror("allo failed");
 398399                         }
<>399 -                        expand(p, INTAREG|INTBREG, q->cstring);
 400 -                        reclaim(p, q->rewrite, INTAREG|INTBREG);
  400+                        expand(p, m, q->cstring);
  401+                        reclaim(p, q->rewrite, m);
401402 //printf("newstyle ute %p\n", p);
 402403                 }
 403404                 goto cleanup;
 404405 
<>405 -        default:
 406 -#ifdef notyet
 407 -                if ((cookie & (INTAREG|INTBREG)) && optype(m) == LTYPE) {
 408 -                        /*
 409 -                         * Search for an ASSIGN op instead of OPLTYPE.
 410 -                         */
  406+                /*
  407+                 * For now just be sure that the trees on each side
  408+                 * are adressable.
  409+                 */
  410+        case EQ:
  411+        case NE:
  412+        case LE:
  413+        case LT:
  414+        case GE:
  415+        case GT:
  416+        case ULE:
  417+        case ULT:
  418+        case UGE:
  419+        case UGT:
  420+                if (!canaddr(p->n_left)) {
  421+                        if (p->n_left->n_op == UNARY MUL) {
  422+                                offstar(p->n_left->n_left);
  423+                                goto again;
  424+                        }
  425+                        order(p->n_left, INTAREG|INTBREG);
411426                 }
<>412 -#endif
  427+                if (!canaddr(p->n_right)) {
  428+                        if (p->n_right->n_op == UNARY MUL) {
  429+                                offstar(p->n_right->n_left);
  430+                                goto again;
  431+                        }
  432+                        order(p->n_right, INTAREG|INTBREG);
  433+                }
  434+                rv = relops(p);
  435+                m = FORCC;
  436+                goto foo;
  437+
  438+        default:
413439                 /* look for op in table */
 414440                 for (;;) {
 415441                         if ((m = match(p, cookie)) == MDONE)
     
 !
12551281 if (f2debug) { if (rv == -1) printf("findops failed\n"); else printf("findops entry %d, %s %s\n", rv >> 2, rv & RTMP ? "RTMP" : "", rv & LTMP ? "LTMP" : ""); }
 12561282         return rv;
 12571283 }
<_ 1284+
  1285+/*
  1286+ * Find the best relation op for matching the two trees it has.
  1287+ * This is a sub-version of the function findops() above.
  1288+ * The instruction with the lowest grading is emitted.
  1289+ */
  1290+int
  1291+relops(NODE *p)
  1292+{
  1293+        extern int *qtable[];
  1294+        struct optab *q;
  1295+        int i, shl, shr, rsr, rsl;
  1296+        NODE *l, *r;
  1297+        int *ixp;
  1298+        int rv = -1, mtchno = 10;
  1299+
  1300+if (f2debug) printf("relops tree:\n");
  1301+if (f2debug) fwalk(p, e2print, 0);
  1302+
  1303+        ixp = qtable[p->n_op];
  1304+        for (i = 0; ixp[i] != 0; i++) {
  1305+                q = &table[ixp[i]];
  1306+
  1307+if (f2debug) printf("relops: ixp %d\n", ixp[i]);
  1308+                l = getlr(p, 'L');
  1309+                r = getlr(p, 'R');
  1310+                if (ttype(l->n_type, q->ltype) == 0 ||
  1311+                    ttype(r->n_type, q->rtype) == 0)
  1312+                        continue; /* Types must be correct */
  1313+
  1314+if (f2debug) printf("relops got types\n");
  1315+                shl = tshape(l, q->lshape);
  1316+                rsl = (q->lshape & (SAREG|STAREG)) != 0;
  1317+                if (shl == 0 && rsl == 0)
  1318+                        continue; /* useless */
  1319+if (f2debug) printf("relops lshape %d\n", shl);
  1320+if (f2debug) fwalk(l, e2print, 0);
  1321+                shr = tshape(r, q->rshape);
  1322+                rsr = (q->rshape & (SAREG|STAREG)) != 0;
  1323+                if (shr == 0 && rsr == 0)
  1324+                        continue; /* useless */
  1325+if (f2debug) printf("relops rshape %d\n", shr);
  1326+if (f2debug) fwalk(r, e2print, 0);
  1327+                if (q->needs & REWRITE)
  1328+                        break;  /* Done here */
  1329+
  1330+                if (shl && shr) {
  1331+                        /*
  1332+                         * Both shapes matches directly. For relops this
  1333+                         * is the best match; just return.
  1334+                         */
  1335+                        return ixp[i] << 2;
  1336+                }
  1337+if (f2debug) printf("second\n");
  1338+                if (shr) {
  1339+                        /*
  1340+                         * Right shape matched. If left node can be put into
  1341+                         * a temporary register, and the current op matches,
  1342+                         * be happy.
  1343+                         */
  1344+                        if (4 < mtchno) {
  1345+                                mtchno = 4;
  1346+                                rv = (ixp[i] << 2) | LTMP;
  1347+                        }
  1348+                        continue; /* nothing more to do */
  1349+                }
  1350+if (f2debug) printf("third\n");
  1351+                if (shl) {
  1352+                        /*
  1353+                         * Left shape matched. If right node can be put into
  1354+                         * a temporary register, and the current op matches,
  1355+                         * be happy.
  1356+                         */
  1357+                        if (4 < mtchno) {
  1358+                                mtchno = 4;
  1359+                                rv = (ixp[i] << 2) | RTMP;
  1360+                        }
  1361+                        continue; /* nothing more to do */
  1362+                }
  1363+                if (6 < mtchno) {
  1364+                        mtchno = 6;
  1365+                        rv = (ixp[i] << 2) | RTMP|LTMP;
  1366+                }
  1367+        }
  1368+if (f2debug) { if (rv == -1) printf("relops failed\n"); else printf("relops entry %d, %s %s\n", rv >> 2, rv & RTMP ? "RTMP" : "", rv & LTMP ? "LTMP" : ""); }
  1369+        return rv;
  1370+}
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-03 06:41 +0200