Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.29
 
1.30
 
MAIN:ragge:20050630135917
 
optim2.c
_>3939 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
 4040 #endif
 4141 
<> 42+#define BDEBUG(x)       if (b2debug) printf x
  43+
4244 static int dfsnum;
 4345 
 4446 void saveip(struct interpass *ip);
     
 !
5052 static struct varinfo defsites;
 5153 static struct interpass ipole;
 5254 struct interpass *storesave;
<> 55+static struct interpass_prolog *ipp, *epp; /* prolog/epilog */
5356 
<>54 -int bblocks_build(struct labelinfo *labinfo, struct bblockinfo *bbinfo);
  57+void bblocks_build(struct labelinfo *labinfo, struct bblockinfo *bbinfo);
5558 void cfg_build(struct labelinfo *labinfo);
 5659 void cfg_dfs(struct basicblock *bb, unsigned int parent,
 5760              struct bblockinfo *bbinfo);
     
 !
6972 void
 7073 saveip(struct interpass *ip)
 7174 {
<>72 -        struct interpass_prolog *ipp, *epp;
7375         static int inftn;
 7476 
 7577 #if 0
     
 !
8991         if (ip->type != IP_EPILOG)
 9092                 return;
 9193         inftn = 0;
<> 94+        ipp = (struct interpass_prolog *)DLIST_NEXT(&ipole, qelem);
9295         epp = (struct interpass_prolog *)ip;
 9396 
<> 97+        if (b2debug) {
  98+                printf("initial links\n");
  99+                printip(&ipole);
  100+        }
  101+
94102         if (xdeljumps)
 95103                 deljumps();     /* Delete redundant jumps and dead code */
 96104 
<> 105+        if (b2debug) {
  106+                printf("links after deljumps\n");
  107+                printip(&ipole);
  108+        }
97109         if (xssaflag) {
 98110                 DLIST_INIT(&bblocks, bbelem);
<>99 -                if (bblocks_build(&labinfo, &bbinfo)) {
 100 -                        cfg_build(&labinfo);
 101 -                        dominators(&bbinfo);
 102 -                        computeDF(DLIST_NEXT(&bblocks, bbelem), &bbinfo);
 103 -                        remunreach();
  111+                bblocks_build(&labinfo, &bbinfo);
  112+                cfg_build(&labinfo);
  113+                dominators(&bbinfo);
  114+                computeDF(DLIST_NEXT(&bblocks, bbelem), &bbinfo);
  115+                remunreach();
104116 #if 0
<>105 -                        if (xssaflag) {
 106 -                                dfg = dfg_build(cfg);
 107 -                                ssa = ssa_build(cfg, dfg);
 108 -                        }
  117+                dfg = dfg_build(cfg);
  118+                ssa = ssa_build(cfg, dfg);
109119 #endif
<>110 -                }
 111 - 
112120         }
 113121 
 114122 #ifdef PCC_DEBUG
 115123         if (epp->ipp_regs != MAXRVAR)
 116124                 comperr("register error");
 117125 #endif
 118126 
<>119 -        ipp = (struct interpass_prolog *)DLIST_NEXT(&ipole, qelem);
120127         ipp->ipp_autos = epp->ipp_autos;
 121128         ipp->ipp_regs = epp->ipp_regs; // = regs;
 122129 
     
 !
210217 void
 211218 deljumps()
 212219 {
<>213 -        struct interpass_prolog *ipp, *epp;
214220         struct interpass *ip, *n, *ip2;
 215221         int gotone,low, high;
 216222         int *lblary, sz, o, i;
 217223 
<>218 -        ipp = (struct interpass_prolog *)DLIST_NEXT(&ipole, qelem);
 219 -        epp = (struct interpass_prolog *)DLIST_PREV(&ipole, qelem);
 220 -
221224         low = ipp->ip_lblnum;
 222225         high = epp->ip_lblnum;
 223226 
     
 !
337340  * that contain which label.
 338341  */
 339342 
<>340 -int
  343+void
341344 bblocks_build(struct labelinfo *labinfo, struct bblockinfo *bbinfo)
 342345 {
 343346         struct interpass *ip;
 344347         struct basicblock *bb = NULL;
 345348         int leader = 1;
<>346 -        unsigned int low, high = 0;
  349+        int low, high;
347350         int count = 0;
 348351         int i;
 349352 
<>350 -        low = sizeof(int) == 2 ? 65000 : 1000000000;
  353+        BDEBUG(("bblocks_build (%p, %p)\n", labinfo, bbinfo));
  354+        low = ipp->ip_lblnum;
  355+        high = epp->ip_lblnum;
  356+
351357         /*
 352358          * First statement is a leader.
 353359          * Any statement that is target of a jump is a leader.
     
 !
386392                         continue;
 387393                 }
 388394                 
<>389 -                /* Keep track of highest and lowest label number */
 390 -                if (ip->type == IP_DEFLAB) {
 391 -                        low = MIN(ip->ip_lbl, low);
 392 -                        high = MAX(ip->ip_lbl, high);
 393 -                }
 394 -
395395                 /* Make sure each label is in a unique bblock */
 396396                 if (((ip->type == IP_DEFLAB) || (ip->type == IP_DEFNAM)) &&
 397397                     bb->first != ip) {
     
 !
415415                         continue;
 416416                 }
 417417 
<>418 -                if (ip->type == IP_ASM)
 419 -                        return 0;
 420 -
421418                 if (ip->type == IP_NODE) {
 422419                         switch(ip->ip_node->n_op) {
 423420                         case CBRANCH:
     
 !
476473 
 477474                 bb->last = ip;
 478475         }
<>479 -#if 0
 480 -        printf("Basic blocks in func: %d\n", count);
 481 -        printf("Label range in func: %d\n", high - low + 1);
 482 -#endif
483476 
<> 477+        BDEBUG(("Basic blocks in func: %d\n", count));
  478+        BDEBUG(("Label range in func: %d\n", high - low + 1));
  479+
  480+
484481         labinfo->low = low;
 485482         labinfo->size = high - low + 1;
 486483         labinfo->arr = tmpalloc(labinfo->size * sizeof(struct basicblock *));
     
 !
503500                         labinfo->arr[bb->first->ip_lbl - low] = bb;
 504501                 }
 505502         }
<>506 -
 507 -        return 1;
508503 }
 509504 
 510505 /*
     
 !
613608         dfsnum = 0;
 614609         cfg_dfs(DLIST_NEXT(&bblocks, bbelem), 0, bbinfo);
 615610 
<>616 -#if 0
 617 -        { struct basicblock *bbb; struct cfgnode *ccnode;
 618 -        DLIST_FOREACH(bbb, &bblocks, bbelem) {
 619 -                printf("Basic block %d, parents: ", bbb->dfnum);
 620 -                SLIST_FOREACH(ccnode, &bbb->parents, cfgelem) {
 621 -                        printf("%d, ", ccnode->bblock->dfnum);
  611+        if (b2debug) {
  612+                struct basicblock *bbb;
  613+                struct cfgnode *ccnode;
  614+
  615+                DLIST_FOREACH(bbb, &bblocks, bbelem) {
  616+                        printf("Basic block %d, parents: ", bbb->dfnum);
  617+                        SLIST_FOREACH(ccnode, &bbb->parents, cfgelem) {
  618+                                printf("%d, ", ccnode->bblock->dfnum);
  619+                        }
  620+                        printf("\nChildren: ");
  621+                        SLIST_FOREACH(ccnode, &bbb->children, cfgelem) {
  622+                                printf("%d, ", ccnode->bblock->dfnum);
  623+                        }
  624+                        printf("\n");
622625                 }
<>623 -                printf("\nChildren: ");
 624 -                SLIST_FOREACH(ccnode, &bbb->children, cfgelem) {
 625 -                        printf("%d, ", ccnode->bblock->dfnum);
 626 -                }
 627 -                printf("\n");
628626         }
<>629 -        }
 630 -#endif
631627 
 632628         for(h = bbinfo->size - 1; h > 1; h--) {
 633629                 bb = bbinfo->arr[h];
     
 !
656652                 }
 657653                 memset(p->bucket, 0, (bbinfo->size + 7)/8);
 658654         }
<>659 -#if 0
 660 -        printf("Num\tSemi\tAncest\tidom\n");
 661 -        CIRCLEQ_FOREACH(bb, &bblocks, bbelem) {
 662 -                printf("%d\t%d\t%d\t%d\n", bb->dfnum, bb->semi, bb->ancestor, bb->idom);
  655+
  656+        if (b2debug) {
  657+                printf("Num\tSemi\tAncest\tidom\n");
  658+                DLIST_FOREACH(bb, &bblocks, bbelem) {
  659+                        printf("%d\t%d\t%d\t%d\n", bb->dfnum, bb->semi,
  660+                            bb->ancestor, bb->idom);
  661+                }
663662         }
<>664 -#endif
  663+
665664         for(h = 2; h < bbinfo->size; h++) {
 666665                 bb = bbinfo->arr[h];
 667666                 if (bb->samedom != 0) {
     
 !
670669         }
 671670         DLIST_FOREACH(bb, &bblocks, bbelem) {
 672671                 if (bb->idom != 0 && bb->idom != bb->dfnum) {
<>673 -#if 0
 674 -
 675 -                        printf("Setting child %d of %d\n", bb->dfnum, bbinfo->arr[bb->idom]->dfnum);
 676 -#endif
 677 -
  672+                        BDEBUG(("Setting child %d of %d\n",
  673+                            bb->dfnum, bbinfo->arr[bb->idom]->dfnum));
<_678674                         BITSET(bbinfo->arr[bb->idom]->dfchildren, bb->dfnum);
 679675                 }
 680676         }
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 12:23 +0200