Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.10
 
1.11
 
MAIN:ragge:20050218164859
 
optim2.c
_>2727  */
 2828 
 2929 #include "pass2.h"
<>30 -#include "external.h"
3130 
 3231 #include <string.h>
 3332 #include <stdlib.h>
     
 !
4948 void deltemp(NODE *p);
 5049 void optdump(struct interpass *ip);
 5150 
<>52 -static SIMPLEQ_HEAD(, interpass) ipole = SIMPLEQ_HEAD_INITIALIZER(ipole);
  51+static struct interpass ipole;
5352 
 5453 static struct rsv {
 5554         struct rsv *next;
     
 !
6968 void computeDF(struct basicblock *bblock, struct bblockinfo *bbinfo);
 7069 
 7170 
<>72 -static CIRCLEQ_HEAD(, basicblock) bblocks = CIRCLEQ_HEAD_INITIALIZER(bblocks);
  71+static struct basicblock bblocks;
7372 
 7473 static void
 7574 addcand(TWORD type, int off, int avoid)
     
 !
230229         rsv = NULL;
 231230 
 232231         /* Loop over the function to do a usage count */
<>233 -        SIMPLEQ_FOREACH(ip, &ipole, sqelem) {
  232+        DLIST_FOREACH(ip, &ipole, qelem) {
234233                 if (ip->type != IP_NODE)
 235234                         continue;
 236235                 cntuse(ip->ip_node);
     
 !
249248         }
 250249 
 251250         /* Convert found nodes to registers */
<>252 -        SIMPLEQ_FOREACH(ip, &ipole, sqelem) {
  251+        DLIST_FOREACH(ip, &ipole, qelem) {
253252                 if (ip->type != IP_NODE)
 254253                         continue;
 255254                 rconvert(ip->ip_node, saved, maxregs);
     
 !
271270         struct labelinfo labinfo;
 272271         struct bblockinfo bbinfo;
 273272 
<>274 -        SIMPLEQ_INSERT_TAIL(&ipole, ip, sqelem);
  273+        if (ip->type == IP_PROLOG)
  274+                DLIST_INIT(&ipole, qelem);
275275 
<> 276+        DLIST_INSERT_BEFORE(&ipole, ip, qelem);
  277+
276278         if (ip->type != IP_EPILOG)
 277279                 return;
 278280         epp = (struct interpass_prolog *)ip;
 279281         saving = -1;
 280282 
 281283         //              deljumps();     /* Delete redundant jumps and dead code */
 282284         if (xssaflag) {
<>283 -                CIRCLEQ_INIT(&bblocks);
  285+                DLIST_INIT(&bblocks, bbelem);
284286                 if (bblocks_build(&labinfo, &bbinfo)) {
 285287                         cfg_build(&labinfo);
 286288                         dominators(&bbinfo);
<>287 -                        computeDF(CIRCLEQ_FIRST(&bblocks), &bbinfo);
  289+                        computeDF(DLIST_NEXT(&bblocks, bbelem), &bbinfo);
288290 #if 0
 289291                         if (xssaflag) {
 290292                                 dfg = dfg_build(cfg);
     
 !
303305                 comperr("register error");
 304306 #endif
 305307 
<>306 -        ipp = (struct interpass_prolog *)SIMPLEQ_FIRST(&ipole);
  308+        ipp = (struct interpass_prolog *)DLIST_NEXT(&ipole, qelem);
307309         ipp->ipp_autos = epp->ipp_autos;
 308310         ipp->ipp_regs = epp->ipp_regs; // = regs;
 309311 
 310312 #ifdef MYOPTIM
 311313         myoptim((struct interpass *)ipp);
 312314 #endif
 313315 
<>314 -        while ((ip = SIMPLEQ_FIRST(&ipole))) {
 315 -                SIMPLEQ_REMOVE_HEAD(&ipole, sqelem);
  316+        DLIST_FOREACH(ip, &ipole, qelem) {
316317                 pass2_compile(ip);
 317318         }
<> 319+        DLIST_INIT(&ipole, qelem);
318320 }
 319321 
 320322 void
     
 !
325327 
 326328 again:  gotone = 0;
 327329 
<>328 -        SIMPLEQ_FOREACH(ip, &ipole, sqelem) {
  330+        DLIST_FOREACH(ip, &ipole, qelem) {
329331                 if (ip->type == IP_EPILOG)
 330332                         return;
 331333                 if (ip->type != IP_NODE)
 332334                         continue;
<>333 -                n = ip->sqelem.sqe_next;
  335+                n = DLIST_NEXT(ip, qelem);
334336                 /* Check for nodes without side effects */
 335337                 if (ip->ip_node->n_op != GOTO)
 336338                         continue;
 337339                 switch (n->type) {
 338340                 case IP_NODE:
 339341                         tfree(n->ip_node);
<>340 -                        ip->sqelem.sqe_next = n->sqelem.sqe_next;
  342+                        DLIST_REMOVE(n, qelem);
341343                         break;
 342344                 case IP_DEFLAB:
 343345                         if (ip->ip_node->n_left->n_lval != n->ip_lbl)
     
 !
396398          * Any statement that immediately follows a jump is a leader.
 397399          */
 398400 
<>399 -        SIMPLEQ_FOREACH(ip, &ipole, sqelem) {
  401+        DLIST_FOREACH(ip, &ipole, qelem) {
400402                 /* Garbage, skip it */
<>401 -                if ((ip->type == IP_LOCCTR) || (ip->type == IP_NEWBLK))
  403+                if (ip->type == IP_NEWBLK)
402404                         continue;
 403405 
 404406                 if (leader) {
 405407                         bb = tmpalloc(sizeof(struct basicblock));
 406408                         bb->first = bb->last = ip;
<>407 -                        SIMPLEQ_INIT(&bb->children);
 408 -                        SIMPLEQ_INIT(&bb->parents);
  409+                        SLIST_INIT(&bb->children);
  410+                        SLIST_INIT(&bb->parents);
409411                         bb->dfnum = 0;
 410412                         bb->dfparent = 0;
 411413                         bb->semi = 0;
     
 !
415417                         bb->bucket = NULL;
 416418                         bb->df = NULL;
 417419                         bb->dfchildren = NULL;
<>418 -                        CIRCLEQ_INSERT_TAIL(&bblocks, bb, bbelem);
  420+                        DLIST_INSERT_BEFORE(&bblocks, bb, bbelem);
419421                         leader = 0;
 420422                         count++;
 421423                 }
     
 !
440442                     bb->first != ip) {
 441443                         bb = tmpalloc(sizeof(struct basicblock));
 442444                         bb->first = bb->last = ip;
<>443 -                        SIMPLEQ_INIT(&bb->children);
 444 -                        SIMPLEQ_INIT(&bb->parents);
  445+                        SLIST_INIT(&bb->children);
  446+                        SLIST_INIT(&bb->parents);
445447                         bb->dfnum = 0;
 446448                         bb->dfparent = 0;
 447449                         bb->semi = 0;
     
 !
451453                         bb->bucket = NULL;
 452454                         bb->df = NULL;
 453455                         bb->dfchildren = NULL;
<>454 -                        CIRCLEQ_INSERT_TAIL(&bblocks, bb, bbelem);
  456+                        DLIST_INSERT_BEFORE(&bblocks, bb, bbelem);
455457                         count++;
 456458                         continue;
 457459                 }
     
 !
536538         }
 537539 
 538540         /* Build the label table */
<>539 -        CIRCLEQ_FOREACH(bb, &bblocks, bbelem) {
  541+        DLIST_FOREACH(bb, &bblocks, bbelem) {
540542                 if (bb->first->type == IP_DEFLAB) {
 541543                         labinfo->arr[bb->first->ip_lbl - low] = bb;
 542544                 }
     
 !
560562         struct cfgnode *pnode;
 561563         struct basicblock *bb;
 562564         
<>563 -        CIRCLEQ_FOREACH(bb, &bblocks, bbelem) {
  565+        DLIST_FOREACH(bb, &bblocks, bbelem) {
564566 
 565567                 if (bb->first->type == IP_EPILOG) {
 566568                         break;
     
 !
579581                                         labinfo->low);
 580582                         }
 581583                         cnode->bblock = labinfo->arr[bb->last->ip_node->n_left->n_lval - labinfo->low];
<>582 -                        SIMPLEQ_INSERT_TAIL(&cnode->bblock->parents, pnode, cfgelem);
 583 -                        SIMPLEQ_INSERT_TAIL(&bb->children, cnode, cfgelem);
  584+                        SLIST_INSERT_LAST(&cnode->bblock->parents, pnode, cfgelem);
  585+                        SLIST_INSERT_LAST(&bb->children, cnode, cfgelem);
584586                         continue;
 585587                 }
 586588                 if ((bb->last->type == IP_NODE) &&
     
 !
591593                                         bb->last->ip_node->n_left->n_lval);
 592594                         
 593595                         cnode->bblock = labinfo->arr[bb->last->ip_node->n_right->n_lval - labinfo->low];
<>594 -                        SIMPLEQ_INSERT_TAIL(&cnode->bblock->parents, pnode, cfgelem);
 595 -                        SIMPLEQ_INSERT_TAIL(&bb->children, cnode, cfgelem);
  596+                        SLIST_INSERT_LAST(&cnode->bblock->parents, pnode, cfgelem);
  597+                        SLIST_INSERT_LAST(&bb->children, cnode, cfgelem);
596598                         cnode = tmpalloc(sizeof(struct cfgnode));
 597599                         pnode = tmpalloc(sizeof(struct cfgnode));
 598600                         pnode->bblock = bb;
 599601                 }
 600602 
<>601 -                cnode->bblock = CIRCLEQ_NEXT(bb, bbelem);
 602 -                SIMPLEQ_INSERT_TAIL(&cnode->bblock->parents, pnode, cfgelem);
 603 -                SIMPLEQ_INSERT_TAIL(&bb->children, cnode, cfgelem);
  603+                cnode->bblock = DLIST_NEXT(bb, bbelem);
  604+                SLIST_INSERT_LAST(&cnode->bblock->parents, pnode, cfgelem);
  605+                SLIST_INSERT_LAST(&bb->children, cnode, cfgelem);
604606         }
 605607 }
 606608 
     
 !
615617         bb->dfnum = ++dfsnum;
 616618         bb->dfparent = parent;
 617619         bbinfo->arr[bb->dfnum] = bb;
<>618 -        SIMPLEQ_FOREACH(cnode, &bb->children, cfgelem) {
  620+        SLIST_FOREACH(cnode, &bb->children, cfgelem) {
619621                 cfg_dfs(cnode->bblock, bb->dfnum, bbinfo);
 620622         }
 621623 }
 622624 
<> 625+static bittype *
  626+setalloc(int nelem)
  627+{
  628+        bittype *b;
  629+        int sz = (nelem+NUMBITS-1)/NUMBITS;
  630+
  631+        b = tmpalloc(sz * sizeof(bittype));
  632+        memset(b, 0, sz * sizeof(bittype));
  633+        return b;
  634+}
  635+
623636 /*
 624637  * Algorithm 19.9, pp 414 from Appel.
 625638  */
     
 !
632645         struct basicblock *s, *sprime, *p;
 633646         int h, i;
 634647 
<>635 -        CIRCLEQ_FOREACH(bb, &bblocks, bbelem) {
 636 -                bb->bucket = tmpalloc((bbinfo->size + 7)/8);
 637 -                memset(bb->bucket, 0, (bbinfo->size + 7)/8);
 638 -
 639 -                bb->df = tmpalloc((bbinfo->size + 7)/8);
 640 -                memset(bb->df, 0, (bbinfo->size + 7)/8);
 641 -
 642 -
 643 -                bb->dfchildren = tmpalloc((bbinfo->size + 7)/8);
 644 -                memset(bb->dfchildren, 0, (bbinfo->size + 7)/8);
  648+        DLIST_FOREACH(bb, &bblocks, bbelem) {
  649+                bb->bucket = setalloc(bbinfo->size);
  650+                bb->df = setalloc(bbinfo->size);
  651+                bb->dfchildren = setalloc(bbinfo->size);
645652         }
 646653 
 647654         dfsnum = 0;
<>648 -        cfg_dfs(CIRCLEQ_FIRST(&bblocks), 0, bbinfo);
  655+        cfg_dfs(DLIST_NEXT(&bblocks, bbelem), 0, bbinfo);
649656 
 650657         for(h = bbinfo->size - 1; h > 1; h--) {
 651658                 bb = bbinfo->arr[h];
 652659                 p = s = bbinfo->arr[bb->dfparent];
<>653 -                SIMPLEQ_FOREACH(cnode, &bb->parents, cfgelem) {
  660+                SLIST_FOREACH(cnode, &bb->parents, cfgelem) {
654661                         if (cnode->bblock->dfnum <= bb->dfnum)
 655662                                 sprime = cnode->bblock;
 656663                         else
     
 !
686693                         bb->idom = bbinfo->arr[bb->samedom]->idom;
 687694                 }
 688695         }
<>689 -        CIRCLEQ_FOREACH(bb, &bblocks, bbelem) {
  696+        DLIST_FOREACH(bb, &bblocks, bbelem) {
690697                 if (bb->idom != 0 && bb->idom != bb->dfnum) {
 691698 #if 0
 692699 
     
 !
726733         struct cfgnode *cnode;
 727734         int h, i;
 728735         
<>729 -        SIMPLEQ_FOREACH(cnode, &bblock->children, cfgelem) {
  736+        SLIST_FOREACH(cnode, &bblock->children, cfgelem) {
<_730737                 if (cnode->bblock->idom != bblock->dfnum)
 731738                         BITSET(bblock->df, cnode->bblock->dfnum);
 732739         }
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-11-01 02:09 +0100