Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.149
 
1.150
 
MAIN:ragge:20050917075840
 
reader.c
_>9595 void mkhardops(NODE *p);
 9696 void optdump(struct interpass *ip);
 9797 void cvtemps(struct interpass *epil);
<>98 -int findops(NODE *p, int);
 99 -int findasg(NODE *p, int);
 100 -int finduni(NODE *p, int);
 101 -int findleaf(NODE *p, int);
 102 -int relops(NODE *p);
 103 -int asgops(NODE *p, int);
10498 NODE *store(NODE *);
 10599 void rcount(void);
 106100 void compile2(struct interpass *ip);
     
 !
110104 
 111105 static void gencode(NODE *p, int cookie);
 112106 
<>113 -static char *ltyp[] = { "", "LREG", "LOREG", "LTEMP" };
 114 -static char *rtyp[] = { "", "RREG", "ROREG", "RTEMP" };
  107+char *ltyp[] = { "", "LREG", "LOREG", "LTEMP" };
  108+char *rtyp[] = { "", "RREG", "ROREG", "RTEMP" };
115109 
 116110 /* used when removing nodes */
 117111 struct tmpsave {
     
 !
310304         compile4(ip);
 311305 }
 312306 
<>313 -#ifdef OLDSTYLE
 314 -void
 315 -compile4(struct interpass *ip)
 316 -{
 317 -        if (xsaveip)
 318 -                return saveip(ip);
 319 -
 320 -        emit(ip);
 321 -}
 322 -#else
 323 -
324307 static struct interpass ipole;
 325308 /*
 326309  * Save a complete function before doing anything with it in both the
     
 !
352335         DLIST_FOREACH(ip, &ipole, qelem)
 353336                 emit(ip);
 354337 }
<>355 -#endif
356338 
 357339 void
 358340 emit(struct interpass *ip)
     
 !
364346         case IP_NODE:
 365347                 p = ip->ip_node;
 366348 
<>367 -#ifdef OLDSTYLE
 368 -                if (xsaveip == 0) {
 369 -                        int savautooff = p2autooff;
 370 -if (xnewreg == 0) {
 371 -                        do {
 372 -                                geninsn(p, FOREFF);
 373 -                        } while (sucomp(p) < 0);
 374 -
 375 -                        genregs(p); /* allocate registers for instructions */
 376 -                        mygenregs(p);
 377 -} else {
 378 -                        do {
 379 -                                extern int tempmin, tempfe, tempmax;
 380 -
 381 -                                geninsn(ip->ip_node, FOREFF);
 382 -                                tempfe = tempmin = tempmax = REGSZ;
 383 -                                nsucomp(ip->ip_node);
 384 -                        } while (ngenregs(ip));
 385 -}
 386 -                        p2autooff = savautooff;
 387 -                }
 388 -#endif
 389 -
390349                 nodepole = p;
 391350                 switch (p->n_op) {
 392351                 case CBRANCH:
     
 !
416375                 tmpsave = NULL/* Always forget old nodes */
 417376                 p2maxautooff = p2autooff = AUTOINIT;
 418377                 break;
<>419 -#ifdef OLDSTYLE
 420 -        case IP_STKOFF:
 421 -                if (xsaveip == 0) {
 422 -                        p2autooff = ip->ip_off;
 423 -                        if (p2autooff > p2maxautooff)
 424 -                                p2maxautooff = p2autooff;
 425 -                }
 426 -                break;
 427 -#endif
428378         case IP_DEFLAB:
 429379                 deflab(ip->ip_lbl);
 430380                 break;
 431381         case IP_ASM:
 432382                 printf("\t%s\n", ip->ip_asm);
 433383                 break;
<>434 -#ifdef OLDSTYLE
 435 -        case IPSTK:
 436 -                break;
 437 -#endif
438384         default:
 439385                 cerror("compile4 %d", ip->type);
 440386         }
     
 !
444390 char *cnames[] = {
 445391         "SANY",
 446392         "SAREG",
<>447 -        "STAREG",
  393+        "xxxxxx",
448394         "SBREG",
<>449 -        "STBREG",
  395+        "xxxxxx",
450396         "SCC",
 451397         "SNAME",
 452398         "SCON",
     
 !
627573                 break;
 628574 
 629575         case REG:
<>630 -                if (istnode(p))
 631 -                        comperr("geninsn REG");
 632 -                /* FALLTHROUGH */
633576         case TEMP:
 634577         case NAME:
 635578         case ICON:
     
 !
744687         r = mklnode(OREG, s, FPREG, p->n_type);
 745688         ip = ipnode(mkbinode(ASSIGN, q, p, p->n_type));
 746689 
<>747 -#ifdef OLDSTYLE
 748 -        if (xsaveip || xnewreg)
 749 -                storesave = ip;
 750 -        else
 751 -                emit(ip);
 752 -#else
753690         storesave = ip;
<>754 -#endif
755691         return r;
 756692 }
 757693 
     
 !
815751         if (p->n_su == -1) /* For OREGs and similar */
 816752                 return gencode(p->n_left, cookie);
 817753 
<>818 -#ifdef OLDSTYLE
 819 -        if (xnewreg) {
 820 -                if (p->n_op == REG && p->n_rall == p->n_rval)
 821 -                        return; /* pointless move to itself */
 822 -                if (p->n_op == ASSIGN && p->n_left->n_op == REG &&
 823 -                    p->n_left->n_rval == p->n_rall &&
 824 -                    p->n_right->n_rall == p->n_rall) {
 825 -                        gencode(p->n_right, INTAREG|INTBREG);
 826 -                        return; /* pointless assign */
 827 -                }
 828 -        }
 829 -#else
830754         if (p->n_op == REG && p->n_rall == p->n_rval)
 831755                 return; /* meaningless move to itself */
 832756         if (p->n_op == ASSIGN && p->n_left->n_op == REG &&
     
 !
835759                 gencode(p->n_right, INTAREG|INTBREG);
 836760                 return; /* meaningless assign */
 837761         }
<>838 -#endif
839762 
 840763         if (p->n_su & DORIGHT) {
 841764                 gencode(p->n_right, INTAREG|INTBREG);
     
 !
852775                 if ((p->n_su & RMASK) == ROREG)
 853776                         canon(p);
 854777         }
<>855 -#define F(x) (ffs(x)-1)
 856 -#ifdef OLDSTYLE
 857 -        if (xnewreg && (p->n_su & RMASK) == RREG) {
 858 -#else
859778         if ((p->n_su & RMASK) == RREG) {
<>860 -#endif
861779                 if (q->needs & NSPECIAL) {
<>862 -                        int left, right, res, mask;
  780+                        struct rspecial *s = nspecial(q);
863781 
<>864 -                        nspecial(q, &left, &right, &res, &mask);
 865 -                        if (right && F(right) != p->n_right->n_rall) {
 866 -                                rmove(p->n_right->n_rall, F(right), p->n_type);
 867 -                                p->n_right->n_rall = F(right);
 868 -                                p->n_right->n_rval = F(right);
  782+                        if (s->right && s->right[0] != p->n_right->n_rall) {
  783+                                rmove(p->n_right->n_rall,
  784+                                    s->right[0], p->n_type);
  785+                                p->n_right->n_rall = s->right[0];
  786+                                p->n_right->n_rval = s->right[0];
869787                         }
 870788                 } else if ((q->rewrite & RRIGHT) &&
 871789                     p->n_right->n_rall != p->n_rall) {
     
 !
874792                         p->n_right->n_rval = p->n_rall;
 875793                 }
 876794         }
<>877 -#ifdef OLDSTYLE
 878 -        if (xnewreg && (p->n_su & LMASK) == LREG) {
 879 -#else
880795         if ((p->n_su & LMASK) == LREG) {
<>881 -#endif
882796                 if (q->needs & NSPECIAL) {
<>883 -                        int left, right, res, mask;
  797+                        struct rspecial *s = nspecial(q);
884798 
<>885 -                        nspecial(q, &left, &right, &res, &mask);
 886 -                        if (left && F(left) != p->n_left->n_rall) {
 887 -                                rmove(p->n_left->n_rall, F(left), p->n_type);
 888 -                                p->n_left->n_rall = F(left);
 889 -                                p->n_left->n_rval = F(left);
  799+                        if (s->left && s->left[0] != p->n_left->n_rall) {
  800+                                rmove(p->n_left->n_rall, s->left[0], p->n_type);
  801+                                p->n_left->n_rall = s->left[0];
  802+                                p->n_left->n_rval = s->left[0];
890803                         }
 891804                 } else if ((q->rewrite & RLEFT) &&
 892805                     p->n_left->n_rall != p->n_rall) {
     
 !
897810         }
 898811 
 899812         expand(p, cookie, q->cstring);
<>900 -#ifdef OLDSTYLE
 901 -        if (xnewreg) {
 902 -                if (callop(p->n_op) && p->n_rall != RETREG)
 903 -                        rmove(RETREG, p->n_rall, p->n_type);
 904 -                else if (q->needs & NSPECIAL) {
 905 -                        int left, right, res, mask;
 906 -                        nspecial(q, &left, &right, &res, &mask);
 907 -                        if (p->n_rall != ffs(res)-1)
 908 -                                rmove(ffs(res)-1, p->n_rall, p->n_type);
 909 -                }
 910 -        }
 911 -#else
912813         if (callop(p->n_op) && p->n_rall != RETREG)
 913814                 rmove(RETREG, p->n_rall, p->n_type);
 914815         else if (q->needs & NSPECIAL) {
<>915 -                int left, right, res, mask;
 916 -                nspecial(q, &left, &right, &res, &mask);
 917 -                if (p->n_rall != ffs(res)-1)
 918 -                        rmove(ffs(res)-1, p->n_rall, p->n_type);
  816+                struct rspecial *s = nspecial(q);
  817+
  818+                if (s->res && p->n_rall != s->res[0])
  819+                        rmove(s->res[0], p->n_rall, p->n_type);
919820         }
<>920 -#endif
921821         rewrite(p, q->rewrite);
 922822 }
 923823 
     
 !
11711071 canon(p) NODE *p; {
 11721072         /* put p in canonical form */
 11731073 
<>1174 -#ifdef OLDSTYLE
 1175 -        if (xsaveip == 0)
 1176 -                walkf(p, deltemp);
 1177 -#else
11781074 //      if (xssaflag == 0)
 11791075 //              walkf(p, deltemp);
<>1180 -#endif
11811076         walkf(p, setleft);      /* ptrs at left node for arithmetic */
 11821077         walkf(p, oreg2);        /* look for and create OREG nodes */
 11831078 #ifndef FIELDOPS
     
 !
11891084 
 11901085 }
 11911086 
<>1192 -static int shltab[] = { 0, 0, LOREG, LREG };
 1193 -static int shrtab[] = { 0, 0, ROREG, RREG };
 1194 -
 1195 -/*
 1196 - * Find the best ops for a given tree.
 1197 - * Different instruction sequences are graded as:
 1198 -        add2 reg,reg     = 0
 1199 -        add2 mem,reg     = 1
 1200 -        add3 mem,reg,reg = 2
 1201 -        add3 reg,mem,reg = 2
 1202 -        add3 mem,mem,reg = 3
 1203 -        move mem,reg ; add2 mem,reg     = 4
 1204 -        move mem,reg ; add3 mem,reg,reg = 5
 1205 -        move mem,reg ; move mem,reg ; add2 reg,reg = 6
 1206 -        move mem,reg ; move mem,reg ; add3 reg,reg,reg = 7
 1207 - * The instruction with the lowest grading is emitted.
 1208 - */
 1209 -int
 1210 -findops(NODE *p, int cookie)
 1211 -{
 1212 -        extern int *qtable[];
 1213 -        struct optab *q;
 1214 -        int i, shl, shr, tl, tr, is3;
 1215 -        NODE *l, *r;
 1216 -        int *ixp;
 1217 -        int rv = -1, mtchno = 10;
 1218 -
 1219 -if (f2debug) printf("findops tree:\n");
 1220 -if (f2debug) fwalk(p, e2print, 0);
 1221 -
 1222 -        ixp = qtable[p->n_op];
 1223 -        for (i = 0; ixp[i] >= 0; i++) {
 1224 -                q = &table[ixp[i]];
 1225 -
 1226 -if (f2debug) printf("findop: ixp %d\n", ixp[i]);
 1227 -                l = getlr(p, 'L');
 1228 -                r = getlr(p, 'R');
 1229 -                if (ttype(l->n_type, q->ltype) == 0 ||
 1230 -                    ttype(r->n_type, q->rtype) == 0)
 1231 -                        continue; /* Types must be correct */
 1232 -
 1233 -if (f2debug) printf("findop got types\n");
 1234 -                if ((shl = tshape(l, q->lshape)) == SRNOPE)
 1235 -                        continue; /* useless */
 1236 -if (f2debug) printf("findop lshape %d\n", shl);
 1237 -if (f2debug) fwalk(l, e2print, 0);
 1238 -                if ((shr = tshape(r, q->rshape)) == SRNOPE)
 1239 -                        continue; /* useless */
 1240 -if (f2debug) printf("findop rshape %d\n", shr);
 1241 -if (f2debug) fwalk(r, e2print, 0);
 1242 -                if (q->needs & REWRITE)
 1243 -                        break;  /* Done here */
 1244 -
 1245 -#ifdef OLDSTYLE
 1246 -                if (xnewreg == 0) {
 1247 -                        tl = istnode(p->n_left);
 1248 -                        tr = istnode(p->n_right);
 1249 -                } else
 1250 -                        tl = tr = 0;
 1251 -#else
 1252 -                tl = tr = 0/* XXX remove later */
 1253 -#endif
 1254 -                is3 = ((q->rewrite & (RLEFT|RRIGHT)) == 0);
 1255 -
 1256 -                if (shl == SRDIR && shr== SRDIR ) {
 1257 -                        int got = 10;
 1258 -                        /*
 1259 -                         * Both shapes matches direct. If one of them is
 1260 -                         * in a temp register and there is a corresponding
 1261 -                         * 2-op instruction, be very happy. If not, but
 1262 -                         * there is a 3-op instruction that ends in a reg,
 1263 -                         * be quite happy. If neither, cannot do anything.
 1264 -                         */
 1265 -                        if (tl && (q->rewrite & RLEFT)) {
 1266 -                                got = 1;
 1267 -                        } else if (tr && (q->rewrite & RRIGHT)) {
 1268 -                                got = 1;
 1269 -                        } else if ((q->rewrite & (RLEFT|RRIGHT)) == 0) {
 1270 -                                got = 3;
 1271 -                        }
 1272 -                        if (got < mtchno) {
 1273 -                                mtchno = got;
 1274 -                                rv = MKIDX(ixp[i], 0);
 1275 -                        }
 1276 -                        if (got != 10)
 1277 -                                continue;
 1278 -                }
 1279 -if (f2debug) printf("second\n");
 1280 -                if (shr == SRDIR) {
 1281 -                        /*
 1282 -                         * Right shape matched. If left node can be put into
 1283 -                         * a temporary register, and the current op matches,
 1284 -                         * be happy.
 1285 -                         */
 1286 -#ifdef OLDSTYLE
 1287 -                        if ((q->rewrite & RRIGHT) && (istnode(r) && !xnewreg)) {
 1288 -                                /* put left in temp, add to right */
 1289 -                                if (4 < mtchno) {
 1290 -                                        mtchno = 4;
 1291 -                                        rv = MKIDX(ixp[i], shltab[shl]);
 1292 -                                }
 1293 -                        } else
 1294 -#endif
 1295 -                        if (q->rewrite & RLEFT) {
 1296 -                                if (4 < mtchno) {
 1297 -                                        mtchno = 4;
 1298 -                                        rv = MKIDX(ixp[i], LREG);
 1299 -                                }
 1300 -                                continue; /* Can't do anything else */
 1301 -                        } else if (is3) {
 1302 -                                if (5 < mtchno) {
 1303 -                                        mtchno = 5;
 1304 -                                        rv = MKIDX(ixp[i], shltab[shl]);
 1305 -                                }
 1306 -                                continue; /* Can't do anything else */
 1307 -                        }
 1308 -                }
 1309 -if (f2debug) printf("third\n");
 1310 -                if (shl == SRDIR) {
 1311 -                        /*
 1312 -                         * Left shape matched. If right node can be put into
 1313 -                         * a temporary register, and the current op matches,
 1314 -                         * be happy.
 1315 -                         */
 1316 -#ifdef OLDSTYLE
 1317 -                        if ((q->rewrite & RLEFT) && (istnode(l) && !xnewreg)) {
 1318 -                                /* put right in temp, add to left */
 1319 -                                if (4 < mtchno) {
 1320 -                                        mtchno = 4;
 1321 -                                        rv = MKIDX(ixp[i], shrtab[shr]);
 1322 -                                }
 1323 -                        } else
 1324 -#endif
 1325 -                        if (q->rewrite & RRIGHT) {
 1326 -                                if (4 < mtchno) {
 1327 -                                        mtchno = 4;
 1328 -                                        rv = MKIDX(ixp[i], RREG);
 1329 -                                }
 1330 -                                continue; /* Can't do anything */
 1331 -                        } else if (is3) {
 1332 -                                if (5 < mtchno) {
 1333 -                                        mtchno = 5;
 1334 -                                        rv = MKIDX(ixp[i], shrtab[shr]);
 1335 -                                }
 1336 -                                continue; /* Can't do anything */
 1337 -                        }
 1338 -                }
 1339 -                /*
 1340 -                 * Neither of the shapes matched. Put both args in
 1341 -                 * regs and be done with it.
 1342 -                 */
 1343 -                if (is3) {
 1344 -                        if (7 < mtchno) {
 1345 -                                mtchno = 7;
 1346 -                                rv = MKIDX(ixp[i], shltab[shl]|shrtab[shr]);
 1347 -                        }
 1348 -                } else {
 1349 -                        if (6 < mtchno) {
 1350 -                                mtchno = 6;
 1351 -                                if (q->rewrite & RLEFT)
 1352 -                                        rv = MKIDX(ixp[i], shrtab[shr]|LREG);
 1353 -                                else
 1354 -                                        rv = MKIDX(ixp[i], shltab[shl]|RREG);
 1355 -                        }
 1356 -                }
 1357 -        }
 1358 -#ifdef PCC_DEBUG
 1359 -        if (f2debug) {
 1360 -                if (rv == -1)
 1361 -                        printf("findops failed\n");
 1362 -                else
 1363 -                        printf("findops entry %d(%s %s)\n",
 1364 -                            TBLIDX(rv), ltyp[rv & LMASK], rtyp[(rv&RMASK)>>2]);
 1365 -        }
 1366 -#endif
 1367 -        return rv;
 1368 -}
 1369 -
 1370 -/*
 1371 - * Find the best relation op for matching the two trees it has.
 1372 - * This is a sub-version of the function findops() above.
 1373 - * The instruction with the lowest grading is emitted.
 1374 - *
 1375 - * Level assignment for priority:
 1376 - *      left    right   prio
 1377 - *      -       -       -
 1378 - *      direct  direct  1
 1379 - *      direct  OREG    2       # make oreg
 1380 - *      OREG    direct  2       # make oreg
 1381 - *      OREG    OREG    2       # make both oreg
 1382 - *      direct  REG     3       # put in reg
 1383 - *      OREG    REG     3       # put in reg, make oreg
 1384 - *      REG     direct  3       # put in reg
 1385 - *      REG     OREG    3       # put in reg, make oreg
 1386 - *      REG     REG     4       # put both in reg
 1387 - */
 1388 -int
 1389 -relops(NODE *p)
 1390 -{
 1391 -        extern int *qtable[];
 1392 -        struct optab *q;
 1393 -        int i, shl, shr;
 1394 -        NODE *l, *r;
 1395 -        int *ixp;
 1396 -        int rv = -1, mtchno = 10;
 1397 -
 1398 -if (f2debug) printf("relops tree:\n");
 1399 -if (f2debug) fwalk(p, e2print, 0);
 1400 -
 1401 -        ixp = qtable[p->n_op];
 1402 -        for (i = 0; ixp[i] >= 0; i++) {
 1403 -                q = &table[ixp[i]];
 1404 -
 1405 -if (f2debug) printf("relops: ixp %d\n", ixp[i]);
 1406 -                l = getlr(p, 'L');
 1407 -                r = getlr(p, 'R');
 1408 -                if (ttype(l->n_type, q->ltype) == 0 ||
 1409 -                    ttype(r->n_type, q->rtype) == 0)
 1410 -                        continue; /* Types must be correct */
 1411 -
 1412 -if (f2debug) printf("relops got types\n");
 1413 -                shl = tshape(l, q->lshape);
 1414 -                if (shl == 0)
 1415 -                        continue; /* useless */
 1416 -if (f2debug) printf("relops lshape %d\n", shl);
 1417 -if (f2debug) fwalk(l, e2print, 0);
 1418 -                shr = tshape(r, q->rshape);
 1419 -                if (shr == 0)
 1420 -                        continue; /* useless */
 1421 -if (f2debug) printf("relops rshape %d\n", shr);
 1422 -if (f2debug) fwalk(r, e2print, 0);
 1423 -                if (q->needs & REWRITE)
 1424 -                        break;  /* Done here */
 1425 -
 1426 -                if (shl+shr < mtchno) {
 1427 -                        mtchno = shl+shr;
 1428 -                        rv = MKIDX(ixp[i], shltab[shl]|shrtab[shr]);
 1429 -                }
 1430 -        }
 1431 -#ifdef PCC_DEBUG
 1432 -        if (f2debug) {
 1433 -                if (rv == -1)
 1434 -                        printf("relops failed\n");
 1435 -                else
 1436 -                        printf("relops entry %d(%s %s)\n",
 1437 -                            TBLIDX(rv), ltyp[rv & LMASK], rtyp[(rv&RMASK)>>2]);
 1438 -        }
 1439 -#endif
 1440 -        return rv;
 1441 -}
 1442 -
 1443 -/*
 1444 - * Find a matching assign op.
 1445 - *
 1446 - * Level assignment for priority:
 1447 - *      left    right   prio
 1448 - *      -       -       -
 1449 - *      direct  direct  1
 1450 - *      direct  REG     2
 1451 - *      direct  OREG    3
 1452 - *      OREG    direct  4
 1453 - *      OREG    REG     5
 1454 - *      OREG    OREG    6
 1455 - */
 1456 -int
 1457 -findasg(NODE *p, int cookie)
 1458 -{
 1459 -        extern int *qtable[];
 1460 -        struct optab *q;
 1461 -        int i, shl, shr, lvl = 10;
 1462 -        NODE *l, *r;
 1463 -        int *ixp;
 1464 -        int rv = -1;
 1465 -
 1466 -#ifdef PCC_DEBUG
 1467 -        if (f2debug) {
 1468 -                printf("findasg tree: %s\n", prcook(cookie));
 1469 -                fwalk(p, e2print, 0);
 1470 -        }
 1471 -#endif
 1472 -
 1473 -        ixp = qtable[p->n_op];
 1474 -        for (i = 0; ixp[i] >= 0; i++) {
 1475 -                q = &table[ixp[i]];
 1476 -
 1477 -if (f2debug) printf("asgop: ixp %d\n", ixp[i]);
 1478 -                l = getlr(p, 'L');
 1479 -                r = getlr(p, 'R');
 1480 -                if (ttype(l->n_type, q->ltype) == 0 ||
 1481 -                    ttype(r->n_type, q->rtype) == 0)
 1482 -                        continue; /* Types must be correct */
 1483 -
 1484 -                if ((cookie & (INTAREG|INTBREG)) &&
 1485 -                    (q->rewrite & (RLEFT|RRIGHT)) == 0)
 1486 -                        continue; /* must get a result somehere */
 1487 -
 1488 -if (f2debug) printf("asgop got types\n");
 1489 -                if ((shl = tshape(l, q->lshape)) == SRNOPE)
 1490 -                        continue;
 1491 -
 1492 -                if (p->n_left->n_op == TEMP)
 1493 -                        shl = SRDIR;
 1494 -                else if (shl == SRREG)
 1495 -                        continue;
 1496 -
 1497 -if (f2debug) printf("asgop lshape %d\n", shl);
 1498 -if (f2debug) fwalk(l, e2print, 0);
 1499 -
 1500 -                if ((shr = tshape(r, q->rshape)) == SRNOPE)
 1501 -                        continue; /* useless */
 1502 -
 1503 -if (f2debug) printf("asgop rshape %d\n", shr);
 1504 -if (f2debug) fwalk(r, e2print, 0);
 1505 -                if (q->needs & REWRITE)
 1506 -                        break;  /* Done here */
 1507 -
 1508 -                if (lvl <= (shl + shr))
 1509 -                        continue;
 1510 -                lvl = shl + shr;
 1511 -                
 1512 -                rv = MKIDX(ixp[i], shltab[shl]|shrtab[shr]);
 1513 -        }
 1514 -#ifdef PCC_DEBUG
 1515 -        if (f2debug) {
 1516 -                if (rv == -1)
 1517 -                        printf("findasg failed\n");
 1518 -                else
 1519 -                        printf("findasg entry %d(%s %s)\n",
 1520 -                            TBLIDX(rv), ltyp[rv & LMASK], rtyp[(rv&RMASK)>>2]);
 1521 -        }
 1522 -#endif
 1523 -        return rv;
 1524 -}
 1525 -
 1526 -/*
 1527 - * Find an ASSIGN node that puts the value into a register.
 1528 - */
 1529 -int
 1530 -findleaf(NODE *p, int cookie)
 1531 -{
 1532 -        extern int *qtable[];
 1533 -        struct optab *q;
 1534 -        int i, shl;
 1535 -        int *ixp;
 1536 -        int rv = -1;
 1537 -
 1538 -#ifdef PCC_DEBUG
 1539 -        if (f2debug) {
 1540 -                printf("findleaf tree: %s\n", prcook(cookie));
 1541 -                fwalk(p, e2print, 0);
 1542 -        }
 1543 -#endif
 1544 -
 1545 -        ixp = qtable[p->n_op];
 1546 -        for (i = 0; ixp[i] >= 0; i++) {
 1547 -                q = &table[ixp[i]];
 1548 -
 1549 -if (f2debug) printf("findleaf: ixp %d\n", ixp[i]);
 1550 -                if (ttype(p->n_type, q->rtype) == 0)
 1551 -                        continue; /* Type must be correct */
 1552 -
 1553 -if (f2debug) printf("findleaf got types\n");
 1554 -                if ((shl = tshape(p, q->rshape)) != SRDIR && p->n_op != TEMP)
 1555 -                        continue; /* shape must match */
 1556 -
 1557 -                if ((q->visit & cookie) == 0)
 1558 -                        continue; /* wrong registers */
 1559 -
 1560 -if (f2debug) printf("findleaf got shapes %d\n", shl);
 1561 -
 1562 -                if (q->needs & REWRITE)
 1563 -                        break;  /* Done here */
 1564 -
 1565 -                rv = MKIDX(ixp[i], 0);
 1566 -                break;
 1567 -        }
 1568 -        if (f2debug) {
 1569 -                if (rv == -1)
 1570 -                        printf("findleaf failed\n");
 1571 -                else
 1572 -                        printf("findleaf entry %d(%s %s)\n",
 1573 -                            TBLIDX(rv), ltyp[rv & LMASK], rtyp[(rv&RMASK)>>2]);
 1574 -        }
 1575 -        return rv;
 1576 -}
 1577 -
 1578 -/*
 1579 - * Find a UNARY op that satisfy the needs.
 1580 - * For now, the destination is always a register.
 1581 - * Both source and dest types must match, but only source (left)
 1582 - * shape is of interest.
 1583 - */
 1584 -int
 1585 -finduni(NODE *p, int cookie)
 1586 -{
 1587 -        extern int *qtable[];
 1588 -        struct optab *q;
 1589 -        NODE *l, *r;
 1590 -        int i, shl, num = 4;
 1591 -        int *ixp;
 1592 -        int rv = -1;
 1593 -
 1594 -#ifdef PCC_DEBUG
 1595 -        if (f2debug) {
 1596 -                printf("finduni tree: %s\n", prcook(cookie));
 1597 -                fwalk(p, e2print, 0);
 1598 -        }
 1599 -#endif
 1600 -
 1601 -        l = getlr(p, 'L');
 1602 -        r = getlr(p, 'R');
 1603 -        ixp = qtable[p->n_op];
 1604 -        for (i = 0; ixp[i] >= 0; i++) {
 1605 -                q = &table[ixp[i]];
 1606 -
 1607 -if (f2debug) printf("finduni: ixp %d\n", ixp[i]);
 1608 -                if (ttype(l->n_type, q->ltype) == 0)
 1609 -                        continue; /* Type must be correct */
 1610 -
 1611 -if (f2debug) printf("finduni got left type\n");
 1612 -                if (ttype(r->n_type, q->rtype) == 0)
 1613 -                        continue; /* Type must be correct */
 1614 -
 1615 -if (f2debug) printf("finduni got types\n");
 1616 -                if ((shl = tshape(l, q->lshape)) == SRNOPE)
 1617 -                        continue; /* shape must match */
 1618 -
 1619 -if (f2debug) printf("finduni got shapes %d\n", shl);
 1620 -                if (q->rewrite & RLEFT) {
 1621 -                        /* left node must be in a temp register */
 1622 -                        if (l->n_op == REG && !istreg(l->n_rval))
 1623 -                                shl = SRREG;
 1624 -                }
 1625 -
 1626 -                if ((cookie & q->visit) == 0)   /* check correct return value */
 1627 -                        continue;               /* XXX - should check needs */
 1628 -
 1629 -if (f2debug) printf("finduni got cookie\n");
 1630 -                if (q->needs & REWRITE)
 1631 -                        break;  /* Done here */
 1632 -
 1633 -                if (shl >= num)
 1634 -                        continue;
 1635 -                num = shl;
 1636 -                rv = MKIDX(ixp[i], shltab[shl]);
 1637 -                if ((q->lshape & (SBREG|STBREG)) &&
 1638 -                    !(q->lshape & (SAREG|STAREG)))
 1639 -                        rv |= LBREG;
 1640 -                if (shl == SRDIR)
 1641 -                        break;
 1642 -        }
 1643 -#ifdef PCC_DEBUG
 1644 -        if (f2debug) {
 1645 -                if (rv == -1)
 1646 -                        printf("finduni failed\n");
 1647 -                else
 1648 -                        printf("finduni entry %d(%s %s)\n",
 1649 -                            TBLIDX(rv), ltyp[rv & LMASK], rtyp[(rv&RMASK)>>2]);
 1650 -        }
 1651 -#endif
 1652 -        return rv;
 1653 -}
 1654 -
<_16551087 void
 16561088 comperr(char *str, ...)
 16571089 {
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-23 16:25 +0200