Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.179
 
1.180
 
MAIN:ragge:20060408072224
 
reader.c
_>314314                 emit(ip);
 315315 }
 316316 
<>317 -#if 0
 318 -/*
 319 - * Receives interpass structs from pass1.
 320 - */
321317 void
<>322 -pass2_compile(struct interpass *ip)
 323 -{
 324 -
 325 -        if (ip->type == IP_NODE) {
 326 -                myreader(ip->ip_node); /* local massage of input */
 327 -                mkhardops(ip->ip_node);
 328 -                gencall(ip->ip_node, NIL);
 329 -                if (xtemps == 0)
 330 -                        walkf(ip->ip_node, deltemp);
 331 -                compile2(ip);
 332 -        } else
 333 -                compile4(ip);
 334 -}
 335 -
 336 -void
 337 -compile2(struct interpass *ip)
 338 -{
 339 -        DLIST_INIT(&delayq, qelem);
 340 -        delay(ip->ip_node);
 341 -        compile3(ip);
 342 -        while (DLIST_NEXT(&delayq, qelem) != &delayq) {
 343 -                ip = DLIST_NEXT(&delayq, qelem);
 344 -                DLIST_REMOVE(ip, qelem);
 345 -                compile3(ip);
 346 -        }
 347 -}
 348 -
 349 -void
 350 -compile3(struct interpass *ip)
 351 -{
 352 -        NODE *p = ip->ip_node;
 353 -
 354 -        canon(p);
 355 -        if ((p = deluseless(p)) == NULL)
 356 -                return; /* nothing to do */
 357 -#ifdef PCC_DEBUG
 358 -        walkf(p, cktree);
 359 -        if (e2debug) {
 360 -                printf("Entering pass2\n");
 361 -                fwalk(p, e2print, 0);
 362 -        }
 363 -#endif
 364 -        ip->ip_node = p;
 365 -        compile4(ip);
 366 -}
 367 -
 368 -/*
 369 - * Save a complete function before doing anything with it in both the
 370 - * optimized and unoptimized case.
 371 - */
 372 -void
 373 -compile4(struct interpass *ip)
 374 -{
 375 -        struct interpass_prolog *epp;
 376 -
 377 -        if (ip->type == IP_PROLOG) {
 378 -                tmpsave = NULL;
 379 -                DLIST_INIT(&ipole, qelem);
 380 -        }
 381 -
 382 -        DLIST_INSERT_BEFORE(&ipole, ip, qelem);
 383 -
 384 -        if (ip->type != IP_EPILOG)
 385 -                return;
 386 -
 387 -#ifdef PCC_DEBUG
 388 -        if (e2debug)
 389 -                printip(&ipole);
 390 -#endif
 391 -        epp = (struct interpass_prolog *)DLIST_PREV(&ipole, qelem);
 392 -        p2maxautooff = p2autooff = epp->ipp_autos;
 393 -
 394 -        optimize(&ipole);
 395 -        ngenregs(&ipole);
 396 -
 397 -        DLIST_FOREACH(ip, &ipole, qelem)
 398 -                emit(ip);
 399 -}
 400 -#endif
 401 -
 402 -void
403318 emit(struct interpass *ip)
 404319 {
 405320         NODE *p;
     
 !
410325                 p = ip->ip_node;
 411326 
 412327                 nodepole = p;
<> 328+//printf("bu:\n");
  329+//fwalk(p, e2print, 0);
  330+                canon(p); /* may convert stuff after genregs */
  331+//fwalk(p, e2print, 0);
413332                 switch (p->n_op) {
 414333                 case CBRANCH:
 415334                         /* Only emit branch insn if RESCC */
     
 !
599518                 rv = findleaf(p, cookie);
 600519                 break;
 601520 
<>602 -#if 0
 603 -        case UMUL:
 604 -
 605 -                /*
 606 -                 * If we end up here with an UMUL, try to fold it into
 607 -                 * an OREG anyway.
 608 -                 */
 609 -                if (p->n_type == STRTY) {
 610 -                        /* XXX - what to do here? */
 611 -                        geninsn(p->n_left, cookie);
 612 -                        p->n_su = DOWNL;
 613 -                        break;
 614 -                }
 615 -#if 0
 616 -                if (offstar(p->n_left, 0)) {
 617 -                        p->n_op = OREG;
 618 -                        if ((rv = findleaf(p, cookie)) < 0)
 619 -                                comperr("bad findleaf"); /* XXX */
 620 -                        p->n_su |= LOREG;
 621 -                        p->n_op = UMUL;
 622 -                        break;
 623 -                }
 624 -                /* FALLTHROUGH */
 625 -#else
 626 -                /* create oreg anyway */
 627 -                (void)offstar(p->n_left, 0);
 628 -                p->n_op = OREG;
 629 -                if ((rv = findleaf(p, cookie)) < 0)
 630 -                        comperr("bad findleaf"); /* XXX */
 631 -                p->n_su |= LOREG;
 632 -                p->n_op = UMUL;
 633 -                break;
 634 -#endif
 635 -#endif
 636 -
637521         case STCALL:
 638522         case CALL:
 639523                 /* CALL arguments are handled special */
     
 !
1064948         }
 1065949 }
 1066950 
<> 951+/* It is OK to have these as externals */
  952+static int oregr;
  953+static CONSZ oregtemp;
  954+static char *oregcp;
1067955 /*
 1068956  * look for situations where we can turn * into OREG
<> 957+ * If sharp then do not allow temps.
1069958  */
 1070959 int
<>1071 -oregok(NODE *p, int *r, CONSZ *temp, char **cp)
  960+oregok(NODE *p, int sharp)
1072961 {
 1073962 
 1074963         NODE *q;
 1075964         NODE *ql, *qr;
<> 965+        int r;
  966+        CONSZ temp;
  967+        char *cp;
1076968 
 1077969         q = p->n_left;
<>1078 -        if (q->n_op == REG && q->n_rval == DECRA(q->n_reg, 0)) {
 1079 -                *temp = q->n_lval;
 1080 -                *r = q->n_rval;
 1081 -                *cp = q->n_name;
  970+        if ((q->n_op == REG || (q->n_op == TEMP && !sharp)) &&
  971+            q->n_rval == DECRA(q->n_reg, 0)) {
  972+                temp = q->n_lval;
  973+                r = q->n_rval;
  974+                cp = q->n_name;
1082975                 goto ormake;
 1083976         }
 1084977 
     
 !
11071000 #endif
 11081001 
 11091002         if( (q->n_op==PLUS || q->n_op==MINUS) && qr->n_op == ICON &&
<>1110 -                        ql->n_op==REG && szty(qr->n_type)==1 &&
  1003+                        (ql->n_op==REG || (ql->n_op==TEMP && !sharp)) &&
  1004+                        szty(qr->n_type)==1 &&
11111005                         (ql->n_rval == DECRA(ql->n_reg, 0) ||
 11121006                         /* XXX */
 11131007                          ql->n_rval == FPREG || ql->n_rval == STKREG)) {
<>1114 -                *temp = qr->n_lval;
 1115 -                if( q->n_op == MINUS ) *temp = -*temp;
 1116 -                *r = ql->n_rval;
 1117 -                *temp += ql->n_lval;
 1118 -                *cp = qr->n_name;
 1119 -                if( **cp && ( q->n_op == MINUS || *ql->n_name ) )
  1008+                temp = qr->n_lval;
  1009+                if( q->n_op == MINUS ) temp = -temp;
  1010+                r = ql->n_rval;
  1011+                temp += ql->n_lval;
  1012+                cp = qr->n_name;
  1013+                if( *cp && ( q->n_op == MINUS || *ql->n_name ) )
11201014                         return 0;
<>1121 -                if( !**cp ) *cp = ql->n_name;
  1015+                if( !*cp ) cp = ql->n_name;
11221016 
 11231017                 ormake:
<>1124 -                if( notoff( p->n_type, *r, *temp, *cp ) == 0)
 1125 -                        return 1;
  1018+                if( notoff( p->n_type, r, temp, cp ))
  1019+                        return 0;
  1020+                oregtemp = temp;
  1021+                oregr = r;
  1022+                oregcp = cp;
  1023+                return 1;
11261024         }
 11271025         return 0;
 11281026 }
 11291027 
 11301028 static void
<>1131 -ormake(NODE *p, int r, CONSZ temp, char *cp)
  1029+ormake(NODE *p)
11321030 {
<> 1031+        NODE *q = p->n_left;
  1032+
11331033         p->n_op = OREG;
<>1134 -        p->n_rval = r;
 1135 -        p->n_lval = temp;
 1136 -        p->n_name = cp;
  1034+        p->n_rval = oregr;
  1035+        p->n_lval = oregtemp;
  1036+        p->n_name = oregcp;
11371037         /* stop gencode traversal */
 11381038         if (p->n_su == DOWNL)
 11391039                 p->n_su = 0;
 11401040         else
 11411041                 p->n_su &= ~(LMASK|RMASK|DORIGHT);
<>1142 -        tfree(p->n_left);
  1042+        tfree(q);
11431043 }
 11441044 
 11451045 /*
     
 !
11481048 void
 11491049 oreg2(NODE *p)
 11501050 {
<>1151 -        int r;
 1152 -        CONSZ temp;
 1153 -        char *cp;
 1154 -
11551051         if (p->n_op != UMUL)
 11561052                 return;
<>1157 -        if (oregok(p, &r, &temp, &cp) == 0)
  1053+        if (oregok(p, 1) == 0)
11581054                 return;
<>1159 -        ormake(p, r, temp, cp);
  1055+        ormake(p);
<_11601056 }
 11611057 
 11621058 void
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-19 09:48 +0200