Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.55
 
1.56
 
MAIN:ragge:20081116115241
 
optim2.c
_>4646 static int dfsnum;
 4747 
 4848 void saveip(struct interpass *ip);
<>49 -void deljumps(struct interpass *);
  49+void deljumps(struct p2env *);
5050 void optdump(struct interpass *ip);
 5151 void printip(struct interpass *pole);
 5252 
 5353 static struct varinfo defsites;
 5454 struct interpass *storesave;
<>55 -static struct interpass_prolog *ipp, *epp; /* prolog/epilog */
5655 
<>57 -void bblocks_build(struct interpass *, struct labelinfo *, struct bblockinfo *);
 58 -void cfg_build(struct labelinfo *labinfo);
  56+void bblocks_build(struct p2env *, struct labelinfo *, struct bblockinfo *);
  57+void cfg_build(struct p2env *, struct labelinfo *labinfo);
5958 void cfg_dfs(struct basicblock *bb, unsigned int parent,
 6059              struct bblockinfo *bbinfo);
<>61 -void dominators(struct bblockinfo *bbinfo);
  60+void dominators(struct p2env *, struct bblockinfo *bbinfo);
6261 struct basicblock *
 6362 ancestorwithlowestsemi(struct basicblock *bblock, struct bblockinfo *bbinfo);
 6463 void link(struct basicblock *parent, struct basicblock *child);
 6564 void computeDF(struct basicblock *bblock, struct bblockinfo *bbinfo);
 6665 void findTemps(struct interpass *ip);
<>67 -void placePhiFunctions(struct bblockinfo *bbinfo);
 68 -void remunreach(void);
  66+void placePhiFunctions(struct p2env *, struct bblockinfo *bbinfo);
  67+void remunreach(struct p2env *);
6968 
<> 69+#if 0
7070 struct basicblock bblocks;
 7171 int nbblocks;
<> 72+#endif
7273 static struct interpass *cvpole;
 7374 
 7475 struct addrof {
     
 !
171172 }
 172173 
 173174 void
<>174 -optimize(struct interpass *ipole)
  175+optimize(struct p2env *p2e)
175176 {
<> 177+        struct interpass *ipole = &p2e->ipole;
176178         struct interpass *ip;
 177179         struct labelinfo labinfo;
 178180         struct bblockinfo bbinfo;
 179181 
<>180 -        ipp = (struct interpass_prolog *)DLIST_NEXT(ipole, qelem);
 181 -        epp = (struct interpass_prolog *)DLIST_PREV(ipole, qelem);
 182 -
183182         if (b2debug) {
 184183                 printf("initial links\n");
 185184                 printip(ipole);
     
 !
206205         }
 207206                 
 208207         if (xdeljumps)
<>209 -                deljumps(ipole); /* Delete redundant jumps and dead code */
  208+                deljumps(p2e); /* Delete redundant jumps and dead code */
210209 
 211210 #ifdef PCC_DEBUG
 212211         if (b2debug) {
     
 !
215214         }
 216215 #endif
 217216         if (xssaflag || xtemps) {
<>218 -                DLIST_INIT(&bblocks, bbelem);
 219 -                bblocks_build(ipole, &labinfo, &bbinfo);
  217+                DLIST_INIT(&p2e->bblocks, bbelem);
  218+                bblocks_build(p2e, &labinfo, &bbinfo);
220219                 BDEBUG(("Calling cfg_build\n"));
<>221 -                cfg_build(&labinfo);
  220+                cfg_build(p2e, &labinfo);
222221         }
 223222         if (xssaflag) {
 224223                 BDEBUG(("Calling dominators\n"));
<>225 -                dominators(&bbinfo);
  224+                dominators(p2e, &bbinfo);
226225                 BDEBUG(("Calling computeDF\n"));
<>227 -                computeDF(DLIST_NEXT(&bblocks, bbelem), &bbinfo);
  226+                computeDF(DLIST_NEXT(&p2e->bblocks, bbelem), &bbinfo);
228227                 BDEBUG(("Calling remunreach\n"));
<>229 -                remunreach();
  228+                remunreach(p2e);
230229 #if 0
 231230                 dfg = dfg_build(cfg);
 232231                 ssa = ssa_build(cfg, dfg);
     
 !
237236         {
 238237                 int i;
 239238                 for (i = NIPPREGS; i--; )
<>240 -                        if (epp->ipp_regs[i] != 0)
  239+                        if (p2e->epp->ipp_regs[i] != 0)
241240                                 comperr("register error");
 242241         }
 243242 #endif
     
 !
250249  * This routine can be made much more efficient.
 251250  */
 252251 void
<>253 -deljumps(struct interpass *ipole)
  252+deljumps(struct p2env *p2e)
254253 {
<> 254+        struct interpass *ipole = &p2e->ipole;
255255         struct interpass *ip, *n, *ip2, *start;
 256256         int gotone,low, high;
 257257         int *lblary, *jmpary, sz, o, i, j, lab1, lab2;
 258258         int del;
 259259         extern int negrel[];
 260260         extern size_t negrelsize;
 261261 
<>262 -        low = ipp->ip_lblnum;
 263 -        high = epp->ip_lblnum;
  262+        low = p2e->ipp->ip_lblnum;
  263+        high = p2e->epp->ip_lblnum;
264264 
 265265 #ifdef notyet
 266266         mark = tmpmark(); /* temporary used memory */
     
 !
497497  */
 498498 
 499499 void
<>500 -bblocks_build(struct interpass *ipole, struct labelinfo *labinfo,
  500+bblocks_build(struct p2env *p2e, struct labelinfo *labinfo,
501501     struct bblockinfo *bbinfo)
 502502 {
<> 503+        struct interpass *ipole = &p2e->ipole;
503504         struct interpass *ip;
 504505         struct basicblock *bb = NULL;
 505506         int low, high;
 506507         int count = 0;
 507508         int i;
 508509 
 509510         BDEBUG(("bblocks_build (%p, %p)\n", labinfo, bbinfo));
<>510 -        low = ipp->ip_lblnum;
 511 -        high = epp->ip_lblnum;
  511+        low = p2e->ipp->ip_lblnum;
  512+        high = p2e->epp->ip_lblnum;
512513 
 513514         /*
 514515          * First statement is a leader.
     
 !
534535                         bb->Aorig = NULL;
 535536                         bb->Aphi = NULL;
 536537                         bb->bbnum = count;
<>537 -                        DLIST_INSERT_BEFORE(&bblocks, bb, bbelem);
  538+                        DLIST_INSERT_BEFORE(&p2e->bblocks, bb, bbelem);
538539                         count++;
 539540                 }
 540541                 bb->last = ip;
     
 !
544545                 if (ip->type == IP_PROLOG)
 545546                         bb = NULL;
 546547         }
<>547 -        nbblocks = count;
  548+        p2e->nbblocks = count;
548549 
 549550         if (b2debug) {
 550551                 printf("Basic blocks in func: %d, low %d, high %d\n",
 551552                     count, low, high);
<>552 -                DLIST_FOREACH(bb, &bblocks, bbelem) {
  553+                DLIST_FOREACH(bb, &p2e->bblocks, bbelem) {
553554                         printf("bb %p: first %p last %p\n", bb,
 554555                             bb->first, bb->last);
 555556                 }
     
 !
569570         }
 570571 
 571572         /* Build the label table */
<>572 -        DLIST_FOREACH(bb, &bblocks, bbelem) {
  573+        DLIST_FOREACH(bb, &p2e->bblocks, bbelem) {
573574                 if (bb->first->type == IP_DEFLAB)
 574575                         labinfo->arr[bb->first->ip_lbl - low] = bb;
 575576         }
     
 !
588589  */
 589590 
 590591 void
<>591 -cfg_build(struct labelinfo *labinfo)
  592+cfg_build(struct p2env *p2e, struct labelinfo *labinfo)
592593 {
 593594         /* Child and parent nodes */
 594595         struct cfgnode *cnode;
 595596         struct cfgnode *pnode;
 596597         struct basicblock *bb;
 597598         
<>598 -        DLIST_FOREACH(bb, &bblocks, bbelem) {
  599+        DLIST_FOREACH(bb, &p2e->bblocks, bbelem) {
599600 
 600601                 if (bb->first->type == IP_EPILOG) {
 601602                         break;
     
 !
674675  */
 675676 
 676677 void
<>677 -dominators(struct bblockinfo *bbinfo)
  678+dominators(struct p2env *p2e, struct bblockinfo *bbinfo)
678679 {
 679680         struct cfgnode *cnode;
 680681         struct basicblock *bb, *y, *v;
 681682         struct basicblock *s, *sprime, *p;
 682683         int h, i;
 683684 
<>684 -        DLIST_FOREACH(bb, &bblocks, bbelem) {
  685+        DLIST_FOREACH(bb, &p2e->bblocks, bbelem) {
685686                 bb->bucket = setalloc(bbinfo->size);
 686687                 bb->df = setalloc(bbinfo->size);
 687688                 bb->dfchildren = setalloc(bbinfo->size);
 688689         }
 689690 
 690691         dfsnum = 0;
<>691 -        cfg_dfs(DLIST_NEXT(&bblocks, bbelem), 0, bbinfo);
  692+        cfg_dfs(DLIST_NEXT(&p2e->bblocks, bbelem), 0, bbinfo);
692693 
 693694         if (b2debug) {
 694695                 struct basicblock *bbb;
 695696                 struct cfgnode *ccnode;
 696697 
<>697 -                DLIST_FOREACH(bbb, &bblocks, bbelem) {
  698+                DLIST_FOREACH(bbb, &p2e->bblocks, bbelem) {
698699                         printf("Basic block %d, parents: ", bbb->dfnum);
 699700                         SLIST_FOREACH(ccnode, &bbb->parents, cfgelem) {
 700701                                 printf("%d, ", ccnode->bblock->dfnum);
     
 !
737738 
 738739         if (b2debug) {
 739740                 printf("Num\tSemi\tAncest\tidom\n");
<>740 -                DLIST_FOREACH(bb, &bblocks, bbelem) {
  741+                DLIST_FOREACH(bb, &p2e->bblocks, bbelem) {
741742                         printf("%d\t%d\t%d\t%d\n", bb->dfnum, bb->semi,
 742743                             bb->ancestor, bb->idom);
 743744                 }
     
 !
749750                         bb->idom = bbinfo->arr[bb->samedom]->idom;
 750751                 }
 751752         }
<>752 -        DLIST_FOREACH(bb, &bblocks, bbelem) {
  753+        DLIST_FOREACH(bb, &p2e->bblocks, bbelem) {
753754                 if (bb->idom != 0 && bb->idom != bb->dfnum) {
 754755                         BDEBUG(("Setting child %d of %d\n",
 755756                             bb->dfnum, bbinfo->arr[bb->idom]->dfnum));
     
 !
844845  */
 845846 
 846847 void
<>847 -placePhiFunctions(struct bblockinfo *bbinfo)
  848+placePhiFunctions(struct p2env *p2e, struct bblockinfo *bbinfo)
848849 {
 849850         struct basicblock *bb;
 850851         struct interpass *ip;
     
 !
855856         NODE *p;
 856857         struct pvarinfo *pv;
 857858 
<>858 -        bb = DLIST_NEXT(&bblocks, bbelem);
  859+        bb = DLIST_NEXT(&p2e->bblocks, bbelem);
859860         defsites.low = ((struct interpass_prolog *)bb->first)->ip_tmpnum;
<>860 -        bb = DLIST_PREV(&bblocks, bbelem);
  861+        bb = DLIST_PREV(&p2e->bblocks, bbelem);
861862         maxtmp = ((struct interpass_prolog *)bb->first)->ip_tmpnum;
 862863         defsites.size = maxtmp - defsites.low + 1;
 863864         defsites.arr = tmpcalloc(defsites.size*sizeof(struct pvarinfo *));
 864865 
 865866         /* Find all defsites */
<>866 -        DLIST_FOREACH(bb, &bblocks, bbelem) {
  867+        DLIST_FOREACH(bb, &p2e->bblocks, bbelem) {
867868                 currbb = bb;
 868869                 ip = bb->first;
 869870                 bb->Aorig = setalloc(defsites.size);
     
 !
927928  */
 928929 
 929930 void
<>930 -remunreach(void)
  931+remunreach(struct p2env *p2e)
931932 {
 932933         struct basicblock *bb, *nbb;
 933934         struct interpass *next, *ctree;
 934935 
<>935 -        bb = DLIST_NEXT(&bblocks, bbelem);
 936 -        while (bb != &bblocks) {
  936+        bb = DLIST_NEXT(&p2e->bblocks, bbelem);
  937+        while (bb != &p2e->bblocks) {
<_937938                 nbb = DLIST_NEXT(bb, bbelem);
 938939 
 939940                 /* Code with dfnum 0 is unreachable */
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-21 04:01 +0200