Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.19
 
1.20
 
MAIN:pj:20050430083010
 
optim2.c
_>6767 ancestorwithlowestsemi(struct basicblock *bblock, struct bblockinfo *bbinfo);
 6868 void link(struct basicblock *parent, struct basicblock *child);
 6969 void computeDF(struct basicblock *bblock, struct bblockinfo *bbinfo);
<> 70+void findTemps(struct interpass *ip, struct varinfo *defsites);
  71+void placePhiFunctions(struct bblockinfo *bbinfo);
7072 void remunreach(void);
 7173 
<>72 -
7374 static struct basicblock bblocks;
 7475 
 7576 static void
     
 !
594595 
 595596                 bb->last = ip;
 596597         }
<>597 -#ifdef PCC_DEBUG
  598+#if 0
598599         printf("Basic blocks in func: %d\n", count);
 599600         printf("Label range in func: %d\n", high - low + 1);
 600601 #endif
     
 !
612613                 bbinfo->arr[i] = NULL;
 613614         }
 614615 
<>615 -        /* Build the label table */
616616         DLIST_FOREACH(bb, &bblocks, bbelem) {
<> 617+                /* Build the label table */
617618                 if (bb->first->type == IP_DEFLAB) {
 618619                         labinfo->arr[bb->first->ip_lbl - low] = bb;
 619620                 }
     
 !
696697                 cfg_dfs(cnode->bblock, bb->dfnum, bbinfo);
 697698         }
 698699         /* Don't bring in unreachable nodes in the future */
<>699 -        bbinfo->size = dfsnum + 1;
  700+        bbinfo->size = dfsnum + 1;
700701 }
 701702 
 702703 static bittype *
     
 !
731732         dfsnum = 0;
 732733         cfg_dfs(DLIST_NEXT(&bblocks, bbelem), 0, bbinfo);
 733734 
<> 735+#if 0
  736+        { struct basicblock *bbb; struct cfgnode *ccnode;
  737+        DLIST_FOREACH(bbb, &bblocks, bbelem) {
  738+                printf("Basic block %d, parents: ", bbb->dfnum);
  739+                SLIST_FOREACH(ccnode, &bbb->parents, cfgelem) {
  740+                        printf("%d, ", ccnode->bblock->dfnum);
  741+                }
  742+                printf("\nChildren: ");
  743+                SLIST_FOREACH(ccnode, &bbb->children, cfgelem) {
  744+                        printf("%d, ", ccnode->bblock->dfnum);
  745+                }
  746+                printf("\n");
  747+        }
  748+        }
  749+#endif
  750+
734751         for(h = bbinfo->size - 1; h > 1; h--) {
 735752                 bb = bbinfo->arr[h];
 736753                 p = s = bbinfo->arr[bb->dfparent];
     
 !
827844         }
 828845 }
 829846 
<> 847+void findTemps(struct interpass *ip, struct varinfo *defsites)
  848+{
  849+        if (ip->type != IP_NODE)
  850+                return;
  851+
  852+        
  853+}
  854+
830855 /*
<> 856+ * Algorithm 19.6 from Appel.
  857+ */
  858+
  859+void
  860+placePhiFunctions(struct bblockinfo *bbinfo)
  861+{
  862+        struct basicblock *bb;
  863+        struct interpass *ip;
  864+        int maxtmp, i, j, k, l;
  865+        struct pvarinfo *n;
  866+        struct varinfo defsites;
  867+        struct cfgnode *cnode;
  868+        TWORD ntype;
  869+        NODE *p;
  870+
  871+        bb = DLIST_NEXT(&bblocks, bbelem);
  872+        defsites.low = ((struct interpass_prolog *)bb->first)->ip_tmpnum;
  873+        bb = DLIST_PREV(&bblocks, bbelem);
  874+        maxtmp = ((struct interpass_prolog *)bb->first)->ip_tmpnum;
  875+        defsites.size = maxtmp - defsites.low + 1;
  876+        defsites.arr = tmpcalloc(defsites.size*sizeof(struct pvarinfo *));
  877+
  878+        DLIST_FOREACH(bb, &bblocks, bbelem) {
  879+                ip = bb->first;
  880+
  881+                while (ip != bb->last) {
  882+                        findTemps(ip, &defsites);
  883+                        ip = DLIST_NEXT(ip, qelem);
  884+                }
  885+                /* Make sure we get the last statement in the bblock */
  886+                findTemps(ip, &defsites);
  887+        }
  888+        for (i = defsites.low; i < defsites.size; i++) {
  889+                while (defsites.arr[i] != NULL) {
  890+                        n = defsites.arr[i];
  891+                        defsites.arr[i] = n->next;
  892+                        for (j = 0; j < bbinfo->size; j++) {
  893+                                if(!TESTBIT(n->bb->df, j))
  894+                                        continue;
  895+                                ntype = n->n->n_type;
  896+                                k = 0;
  897+                                SLIST_FOREACH(cnode, &n->bb->parents, cfgelem)
  898+                                        k++;
  899+                                p = mklnode(TEMP, i, 0, ntype);
  900+                                for (l = 0; l < k-1; l++)
  901+                                        p = mkbinode(PHI, p,
  902+                                            mklnode(TEMP, i, 0, ntype), ntype);
  903+                                ip = ipnode(mkbinode(ASSIGN,
  904+                                    mklnode(TEMP, i, 0, ntype), p, ntype));
  905+                                DLIST_INSERT_BEFORE(((struct interpass*)&n->bb->first), ip, qelem);
  906+                                n->bb->first = ip;
  907+
  908+                        }
  909+                }
  910+        }
  911+}
  912+
  913+/*
<_831914  * Remove unreachable nodes in the CFG.
 832915  */
 833916 
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-02 16:11 +0200