Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.36
 
1.37
 
MAIN:ragge:20030803211559
 
reader.c
_>4646 int udebug = 0;
 4747 int ftnno;
 4848 
<>49 -OFFSZ tmpoff/* offset for first temporary, in bits for current block */
 50 -OFFSZ maxoff/* maximum temporary offset over all blocks in current ftn, in bits */
 51 -int maxtreg;
 52 -
5349 NODE *stotree;
 5450 int stocook;
<> 51+static int saving;
5552 
<>56 -OFFSZ baseoff = 0;
 57 -OFFSZ maxtemp = 0;
 58 -
5953 static struct templst {
 6054         struct templst *next;
 6155         int tempnr;
 6256         int tempoff;
 6357 } *templst;
 6458 
 6559 int e2print(NODE *p, int down, int *a, int *b);
<> 60+void saveip(struct interpass *ip);
  61+void deljumps(void);
  62+void optdump(struct interpass *ip);
6663 
<> 64+
6765 #ifdef PCC_DEBUG
 6866 static void
 6967 cktree(NODE *p)
     
 !
9997         codgen(p, FOREFF);
 10098         reclaim( p, RNULL, 0 );
 10199         allchk();
<>102 -        /* can't do tcheck here; some stuff (e.g., attributes) may be around from first pass */
 103 -        /* first pass will do it... */
104100 }
 105101 
 106102 static void newblock(int myreg, int aoff);
     
 !
109105 void
 110106 pass2_compile(struct interpass *ip)
 111107 {
<> 108+        if (Oflag) {
  109+                if (ip->type == IP_PROLOG)
  110+                        saving++;
  111+                if (saving)
  112+                        return saveip(ip);
  113+        }
112114         switch (ip->type) {
 113115         case IP_NODE:
 114116                 p2compile(ip->ip_node);
     
 !
140142 static void
 141143 newblock(int myreg, int aoff)
 142144 {
<>143 -        static int myftn = -1;
 144 -
 145 -        tmpoff = baseoff = aoff;
 146 -        maxtreg = myreg;
 147 -        if( myftn != ftnno ){ /* beginning of function */
 148 -                maxoff = baseoff;
 149 -                myftn = ftnno;
 150 -                maxtemp = 0;
 151 -                }
 152 -        else {
 153 -                if( baseoff > maxoff ) maxoff = baseoff;
 154 -                /* maxoff at end of ftn is max of autos and temps over all blocks */
 155 -                }
156145         setregs();
 157146 }
 158147 
 159148 static void
 160149 epilogue(int regs, int autos, int retlab)
 161150 {
<>162 -        SETOFF(maxoff, ALSTACK);
163151         templst = NULL;
 164152         eoftn(regs, autos, retlab);
 165153 }
     
 !
866854 
 867855 }
 868856 
<_ 857+static SIMPLEQ_HEAD(, interpass) ipole = SIMPLEQ_HEAD_INITIALIZER(ipole);
  858+
  859+void
  860+saveip(struct interpass *ip)
  861+{
  862+        SIMPLEQ_INSERT_TAIL(&ipole, ip, sqelem);
  863+
  864+        if (ip->type != IP_EPILOG)
  865+                return;
  866+        saving = -1;
  867+
  868+        deljumps();
  869+
  870+        while ((ip = SIMPLEQ_FIRST(&ipole))) {
  871+                SIMPLEQ_REMOVE_HEAD(&ipole, sqelem);
  872+                pass2_compile(ip);
  873+        }
  874+}
  875+
  876+void
  877+deljumps()
  878+{
  879+        struct interpass *ip, *n;
  880+        int gotone;
  881+
  882+again:  gotone = 0;
  883+
  884+        SIMPLEQ_FOREACH(ip, &ipole, sqelem) {
  885+                if (ip->type == IP_EPILOG)
  886+                        return;
  887+                if (ip->type != IP_NODE)
  888+                        continue;
  889+                if (ip->ip_node->n_op != GOTO)
  890+                        continue;
  891+                n = ip->sqelem.sqe_next;
  892+                switch (n->type) {
  893+                case IP_NODE:
  894+                        tfree(n->ip_node);
  895+                        ip->sqelem.sqe_next = n->sqelem.sqe_next;
  896+                        break;
  897+                case IP_DEFLAB:
  898+                        if (ip->ip_node->n_left->n_lval != n->ip_lbl)
  899+                                continue;
  900+                        tfree(ip->ip_node);
  901+                        *ip = *n;
  902+                        break;
  903+                default:
  904+                        continue;
  905+                }
  906+                gotone = 1;
  907+        }
  908+        if (gotone)
  909+                goto again;
  910+}
  911+
  912+void
  913+optdump(struct interpass *ip)
  914+{
  915+        static char *nm[] = { "node", "prolog", "newblk", "epilog", "locctr",
  916+                "deflab", "defnam" };
  917+        printf("type %s\n", nm[ip->type-1]);
  918+        switch (ip->type) {
  919+        case IP_NODE:
  920+                fwalk(ip->ip_node, e2print, 0);
  921+                break;
  922+        case IP_DEFLAB:
  923+                printf("label" LABFMT "\n", ip->ip_lbl);
  924+                break;
  925+        }
  926+}
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-08-28 13:06 +0200