Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.127
 
1.128
 
MAIN:ragge:20050521145433
 
reader.c
_>105105 int asgops(NODE *p, int);
 106106 NODE *store(NODE *);
 107107 void rcount(void);
<>108 -#ifdef NEW_READER
109108 void compile2(struct interpass *ip);
 110109 void compile3(struct interpass *ip);
 111110 void compile4(struct interpass *ip);
 112111 struct interpass delayq;
<>113 -#endif
114112 
 115113 static void gencode(NODE *p, int cookie);
 116114 
     
 !
143141 }
 144142 #endif
 145143 
<>146 -#ifndef NEW_READER
 147 -static void
 148 -p2compile(NODE *p)
 149 -{
 150 -        int i;
 151 -
 152 -#if !defined(MULTIPASS)
 153 -        extern char *ftitle;
 154 -#endif
 155 -
 156 -        if (lflag)
 157 -                lineid(lineno, ftitle);
 158 -
 159 -        /* generate code for the tree p */
 160 -#ifdef PCC_DEBUG
 161 -        walkf(p, cktree);
 162 -        if (e2debug) {
 163 -                fprintf(stderr, "Entering pass2\n");
 164 -                fwalk(p, e2print, 0);
 165 -        }
 166 -#endif
 167 -
 168 -        nrecur = 0;
 169 -        deli = 0;
 170 -        delay(p);
 171 -        codgen(p, FOREFF);
 172 -        for (i = 0; i < deli; ++i)
 173 -                codgen(deltrees[i], FOREFF);  /* do the rest */
 174 -        tfree(p);
 175 -}
 176 -#endif
 177 -
 178 -
179144 /* look for delayable ++ and -- operators */
 180145 void
 181146 delay(NODE *p)
 182147 {
<>183 -#ifdef NEW_READER
184148         struct interpass *ip;
 185149         NODE *q;
<>186 -#endif
  150+
187151         int ty = optype(p->n_op);
 188152 
 189153         switch (p->n_op) {
     
 !
206170         case DECR:
 207171                 break;
 208172                 if( deltest( p ) ){
<>209 -#ifdef NEW_READER
210173                         ip = ipnode(tcopy(p));
 211174                         DLIST_INSERT_BEFORE(&delayq, ip, qelem);
 212175                         q = p->n_left;
 213176                         nfree(p->n_right); /* zap constant */
 214177                         *p = *q;
 215178                         nfree(q);
 216179                         return;
<>217 -#else
 218 -                        if( deli < DELAYS ){
 219 -                                register NODE *q;
 220 -                                deltrees[deli++] = tcopy(p);
 221 -                                q = p->n_left;
 222 -                                nfree(p->n_right); /* zap constant */
 223 -                                *p = *q;
 224 -                                nfree(q);
 225 -                                return;
 226 -                        }
 227 -#endif
228180                 }
 229181 
 230182         }
     
 !
303255         return NULL;
 304256 }
 305257 
<>306 -#ifdef NEW_READER
307258 /*
 308259  * Receives interpass structs from pass1.
 309260  */
     
 !
430381         }
 431382 }
 432383 
<>433 -#else
 434 -
 435 -#ifdef TAILCALL
 436 -int earlylab, retlab2;
 437 -char *cftname;
 438 -#endif
 439 -
 440 -void
 441 -pass2_compile(struct interpass *ip)
 442 -{
 443 -#ifdef TAILCALL
 444 -        NODE *p;
 445 -#endif
 446 -
 447 -#ifdef TAILCALL
 448 -        if (xtailcallflag) {
 449 -                if (earlylab == -1) {
 450 -                        if (ip->type != IP_DEFLAB)
 451 -                                comperr("missing deflab");
 452 -                        earlylab = ip->ip_lbl;
 453 -                } else if (ip->type == IP_PROLOG) {
 454 -                        earlylab = -1;
 455 -                        retlab2 = ip->ip_lbl;
 456 -                        cftname = ((struct interpass_prolog *)ip)->ipp_name;
 457 -                } else if (ip->type == IP_EPILOG)
 458 -                        earlylab = 0;
 459 -        }
 460 -#endif
 461 -
 462 -        if (ip->type == IP_NODE) {
 463 -                thisline = ip->lineno;
464384 #ifdef PCC_DEBUG
<>465 -                if (e2debug) {
 466 -                        fprintf(stderr, "pass2 called on:\n");
 467 -                        fwalk(ip->ip_node, e2print, 0);
 468 -                }
 469 -#endif
 470 -                ip->ip_node = deluseless(ip->ip_node);
 471 -                if (ip->ip_node == NULL)
 472 -                        return;
 473 -
 474 -# ifdef MYREADER
 475 -        MYREADER(ip->ip_node);  /* do your own laundering of the input */
 476 -# endif
 477 -
 478 -#ifdef TAILCALL
 479 -                /* Check for tail call optimization early */
 480 -                if (xtailcallflag) {
 481 -                        static struct interpass *ipp;
 482 -                        static int passany;
 483 -
 484 -                        if (passany == 0) {
 485 -                                p = ip->ip_node;
 486 -                                if (ipp) {
 487 -                                        if (p->n_op == GOTO &&
 488 -                                            p->n_left->n_lval == retlab2) {
 489 -                                                passany = 1;
 490 -                                                mktailopt(ipp, ip);
 491 -                                                passany = 0;
 492 -                                                ipp = NULL;
 493 -                                                return;
 494 -                                        } else {
 495 -                                                passany = 1;
 496 -                                                pass2_compile(ipp);
 497 -                                                passany = 0;
 498 -                                        }
 499 -                                        ipp = NULL;
 500 -                                } else if (p->n_op == FORCE &&
 501 -                                    callop(p->n_left->n_op)) {
 502 -                                        ipp = ip;
 503 -                                        return;
 504 -                                }
 505 -                        }
 506 -                }
 507 -#endif
 508 -
 509 -                mkhardops(ip->ip_node);
 510 -//printf("gencall...\n");
 511 -//fwalk(ip->ip_node, e2print, 0);
 512 -                gencall(ip->ip_node, NIL);
 513 -#ifdef notyet
 514 -                optim1(ip->ip_node);
 515 -#endif
 516 -        }
 517 -        if (Oflag) {
 518 -                if (ip->type == IP_PROLOG)
 519 -                        saving++;
 520 -                if (saving)
 521 -                        return saveip(ip);
 522 -        }
 523 -        switch (ip->type) {
 524 -        case IP_NODE:
 525 -                p2compile(ip->ip_node);
 526 -                tfree(ip->ip_node);
 527 -                break;
 528 -        case IP_PROLOG:
 529 -                prologue((struct interpass_prolog *)ip);
 530 -                break;
 531 -        case IP_EPILOG:
 532 -                eoftn((struct interpass_prolog *)ip);
 533 -                tmpsave = NULL/* Always forget old nodes */
 534 -                p2maxautooff = p2autooff = AUTOINIT;
 535 -                break;
 536 -        case IP_STKOFF:
 537 -                p2autooff = ip->ip_off;
 538 -                if (p2autooff > p2maxautooff)
 539 -                        p2maxautooff = p2autooff;
 540 -                break;
 541 -        case IP_DEFLAB:
 542 -                deflab(ip->ip_lbl);
 543 -                break;
 544 -        case IP_ASM:
 545 -                printf("\t%s\n", ip->ip_asm);
 546 -                break;
 547 -        default:
 548 -                cerror("pass2_compile %d", ip->type);
 549 -        }
 550 -}
 551 -
 552 -#endif
 553 -
 554 -#ifndef NEW_READER
 555 -/*
 556 - * generate the code for p;
 557 - * store may call codgen recursively
 558 - * cookie is used to describe the context
 559 - */
 560 -void
 561 -codgen(NODE *p, int cookie)
 562 -{
 563 -        int o;
 564 -
 565 -        rcount();
 566 -        nodepole = p;
 567 -        canon(p);  /* creats OREG from * if possible */
 568 -#ifdef PCC_DEBUG
 569 -        if (e2debug) {
 570 -                fprintf(stderr, "geninsn called on:\n");
 571 -                fwalk(p, e2print, 0);
 572 -        }
 573 -#endif
 574 -
 575 -if (xnewreg == 0) {
 576 -        do {
 577 -                geninsn(p, cookie); /* Assign instructions for tree */
 578 -#ifdef PCC_DEBUG
 579 -                if (udebug) {
 580 -                        fprintf(stderr, "sucomp called on:\n");
 581 -                        fwalk(p, e2print, 0);
 582 -                }
 583 -#endif
 584 -        } while (sucomp(p) < 0);  /* Calculate sub-tree evaluation order */
 585 -} else {
 586 -        geninsn(p, cookie);     /* Assign instructions for tree */
 587 -#ifdef PCC_DEBUG
 588 -                if (udebug) {
 589 -                        fprintf(stderr, "nsucomp called on:\n");
 590 -                        fwalk(p, e2print, 0);
 591 -                }
 592 -#endif
 593 -        nsucomp(p);             /* Calculate evaluation order */
 594 -}
 595 -
 596 -#ifdef PCC_DEBUG
 597 -        if (udebug) {
 598 -                fprintf(stderr, "genregs called on:\n");
 599 -                fwalk(p, e2print, 0);
 600 -        }
 601 -#endif
 602 -if (xnewreg == 0) {
 603 -        /*
 604 -         * When here it is known that the tree can be evaluated.
 605 -         * Assign registers for all instructions.
 606 -         */
 607 -        genregs(p); /* allocate registers for instructions */
 608 -        mygenregs(p);
 609 -} else {
 610 -        ngenregs(p);
 611 -}
 612 -
 613 -#ifdef PCC_DEBUG
 614 -        if (udebug) {
 615 -                fprintf(stderr, "gencode called on:\n");
 616 -                fwalk(p, e2print, 0);
 617 -        }
 618 -#endif
 619 -        switch (p->n_op) {
 620 -        case CBRANCH:
 621 -                /* Only emit branch insn if RESCC */
 622 -                if (table[TBLIDX(p->n_left->n_su)].rewrite & RESCC) {
 623 -                        o = p->n_left->n_op;
 624 -                        gencode(p, FORCC);
 625 -                        cbgen(o, p->n_right->n_lval);
 626 -                } else
 627 -                        gencode(p, FORCC);
 628 -                break;
 629 -        case FORCE:
 630 -                gencode(p->n_left, INTAREG|INTBREG);
 631 -                break;
 632 -        default:
 633 -                if (p->n_op != REG || p->n_type != VOID) /* XXX */
 634 -                        gencode(p, FOREFF); /* Emit instructions */
 635 -        }
 636 -}
 637 -#endif
 638 -
 639 -#ifdef PCC_DEBUG
640385 char *cnames[] = {
 641386         "SANY",
 642387         "SAREG",
     
 !
945690         s->n_name = "";
 946691         s->n_left = q;
 947692         s->n_right = p;
<>948 -#ifdef NEW_READER
949693         if (Oflag) {
 950694                 extern struct interpass *storesave;
 951695                 storesave = ipnode(s);
 952696         } else
 953697                 emit(ipnode(s));
<>954 -#else
 955 -        codgen(s, FOREFF);
 956 -        tfree(s);
 957 -#endif
<_958698         return r;
 959699 }
 960700 
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-01 10:17 +0200