Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.69
 
1.70
 
MAIN:ragge:20031112164226
 
reader.c
_>3636 # include "pass2.h"
 3737 #include "external.h"
 3838 
<> 39+#include <string.h>
  40+
3941 /*      some storage declarations */
 4042 int nrecur;
 4143 int lflag;
     
 !
243245         eoftn(regs, autos, retlab);
 244246 }
 245247 
<> 248+static int gotcall; /* XXX */
246249 /*
 247250  * generate the code for p;
 248251  * order may call codgen recursively
     
 !
251254 void
 252255 codgen(NODE *p, int cookie)
 253256 {
<> 257+
  258+        /*
  259+         * Loop around to find sub-trees to store.
  260+         * This mostly applies to arguments.
  261+         */
  262+        for (;;) {
  263+                canon(p);  /* creats OREG from * if possible and does sucomp */
  264+                stotree = NIL;
  265+#ifdef PCC_DEBUG
  266+                if (e2debug) {
  267+                        printf("store called on:\n");
  268+                        fwalk(p, e2print, 0);
  269+                }
  270+#endif
  271+                store(p);
  272+                if (stotree == NIL)
  273+                        break;
  274+                geninsn(stotree, stocook);
  275+                sucomp(stotree); /* Calculate sub-tree evaluation order */
  276+                genregs(stotree); /* allocate registers for instructions */
  277+                gencode(stotree); /* Emit instructions */
  278+        }
  279+
254280         canon(p);  /* creats OREG from * if possible and does sucomp */
 255281 #ifdef PCC_DEBUG
 256282         if (e2debug) {
 257283                 printf("geninsn called on:\n");
 258284                 fwalk(p, e2print, 0);
 259285         }
 260286 #endif
<>261 -
 262 -        geninsn(p, cookie); /* Assign instructions for tree */
  287+        do {
  288+                gotcall = 0;
  289+                geninsn(p, cookie); /* Assign instructions for tree */
  290+        } while (gotcall && !(p->n_op == REG && p->n_type == VOID));
263291         sucomp(p);  /* Calculate sub-tree evaluation order */
 264292 #ifdef PCC_DEBUG
 265293         if (udebug) {
     
 !
268296         }
 269297 #endif
 270298         genregs(p); /* allocate registers for instructions */
<>271 -        gencode(p); /* Emit instructions */
  299+        if (p->n_op != REG || p->n_type != VOID) /* XXX */
  300+                gencode(p); /* Emit instructions */
272301 #if 0
 273302         for (;;) {
 274303                 canon(p);  /* creats OREG from * if possible and does sucomp */
     
 !
313342 /*
 314343  * print a nice-looking description of cookie
 315344  */
<>316 -void
  345+char *
317346 prcook(int cookie)
 318347 {
<> 348+        static char buf[50];
319349         int i, flag;
 320350 
<>321 -        if( cookie & SPECIAL ){
 322 -                if( cookie == SZERO ) printf( "SZERO" );
 323 -                else if( cookie == SONE ) printf( "SONE" );
 324 -                else if( cookie == SMONE ) printf( "SMONE" );
 325 -                else printf( "SPECIAL+%d", cookie & ~SPECIAL );
 326 -                return;
  351+        if (cookie & SPECIAL) {
  352+                switch (cookie) {
  353+                case SZERO:
  354+                        return "SZERO";
  355+                case SONE:
  356+                        return "SONE";
  357+                case SMONE:
  358+                        return "SMONE";
  359+                default:
  360+                        sprintf(buf, "SPECIAL+%d", cookie & ~SPECIAL);
  361+                        return buf;
327362                 }
<> 363+        }
328364 
 329365         flag = 0;
<>330 -        for( i=0; cnames[i]; ++i ){
 331 -                if( cookie & (1<<i) ){
 332 -                        if( flag ) printf( "|" );
  366+        buf[0] = 0;
  367+        for (i = 0; cnames[i]; ++i) {
  368+                if (cookie & (1<<i)) {
  369+                        if (flag)
  370+                                strcat(buf, "|");
333371                         ++flag;
<>334 -                        printf( cnames[i] );
 335 -                        }
  372+                        strcat(buf, cnames[i]);
336373                 }
<>337 -
  374+        }
  375+        return buf;
338376 }
<> 377+
339378 #endif
 340379 
 341380 int odebug = 0;
     
 !
347386 
 348387 #ifdef PCC_DEBUG
 349388         if (odebug) {
<>350 -                printf("geninsn(%p, ", p);
 351 -                prcook(cookie);
 352 -                printf(")\n");
  389+                printf("geninsn(%p, %s)\n", p, prcook(cookie));
353390                 fwalk(p, e2print, 0);
 354391         }
 355392 #endif
     
 !
424461                 break;
 425462 
 426463         case UMUL:
<> 464+        case GOTO:
  465+        case FUNARG:
427466                 if ((rv = finduni(p, cookie)) < 0) {
 428467                         if (setuni(p, cookie))
 429468                                 goto again;
     
 !
433472                 case LREG:
 434473                         geninsn(p->n_left, INTAREG|INTBREG);
 435474                         break;
<> 475+                case LOREG:
  476+                        offstar(p->n_left->n_left);
  477+                        p->n_left->n_su = -1;
  478+                        break;
  479+                case LTEMP:
  480+                        geninsn(p->n_left, INTEMP);
  481+                        break;
436482                 }
 437483                 p->n_su = rv;
 438484                 break;
 439485 
<> 486+        case UCALL:
  487+                p->n_right = NIL;
  488+        case CALL:
  489+                p->n_op = UCALL;
  490+                if (gencall(p, cookie))
  491+                        goto failed;
  492+                if (cookie == FOREFF)
  493+                        p->n_type = VOID; /* XXX */
  494+                gotcall = 1;
  495+                break;
  496+
440497         default:
 441498                 cerror("geninsn: bad op %d", o);
 442499         }
     
 !
449506         cerror("Cannot generate code for op %d\n", o);
 450507 }
 451508 
<> 509+#if 0
452510 void
 453511 order(NODE *p, int cook)
 454512 {
     
 !
876934         goto nomat;
 877935 }
 878936 
<> 937+#endif
  938+
879939 /*
 880940  * Count the number of registers needed to evaluate a tree.
 881941  * This is the trivial implementation, for machines with symmetric
     
 !
11351195                 else printf( "PREF " );
 11361196                 printf( "%s", rnames[p->n_rall&~MUSTDO]);
 11371197                 }
<>1138 -        printf( ", SU= %d\n", p->n_su );
  1198+        printf( ", SU= %d(%s,%s,%s)\n", TBLIDX(p->n_su), ltyp[LMASK&p->n_su],
  1199+            rtyp[(p->n_su&RMASK) >> 2], p->n_su & DORIGHT ? "DORIGHT" : "");
11391200         return 0;
 11401201 }
 11411202 #endif
     
 !
17371798 
 17381799 #ifdef PCC_DEBUG
 17391800         if (f2debug) {
<>1740 -                printf("findasg tree: ");
 1741 -                prcook(cookie);
 1742 -                printf("\n");
  1801+                printf("findasg tree: %s\n", prcook(cookie));
17431802                 fwalk(p, e2print, 0);
 17441803         }
 17451804 #endif
     
 !
18401899 
 18411900 #ifdef PCC_DEBUG
 18421901         if (f2debug) {
<>1843 -                printf("findleaf tree: ");
 1844 -                prcook(cookie);
 1845 -                printf("\n");
  1902+                printf("findleaf tree: %s\n", prcook(cookie));
18461903                 fwalk(p, e2print, 0);
 18471904         }
 18481905 #endif
     
 !
18941951 
 18951952 #ifdef PCC_DEBUG
 18961953         if (f2debug) {
<>1897 -                printf("finduni tree: ");
 1898 -                prcook(cookie);
 1899 -                printf("\n");
  1954+                printf("finduni tree: %s\n", prcook(cookie));
<_19001955                 fwalk(p, e2print, 0);
 19011956         }
 19021957 #endif
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:14 +0100