Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.70
 
1.71
 
MAIN:ragge:20031113155946
 
reader.c
_>3737 #include "external.h"
 3838 
 3939 #include <string.h>
<> 40+#include <stdarg.h>
4041 
 4142 /*      some storage declarations */
 4243 int nrecur;
 4344 int lflag;
 4445 int x2debug;
 4546 int udebug = 0;
 4647 int ftnno;
<> 48+static int thisline;
4749 
<>48 -NODE *stotree;
  50+NODE *stotree, *nodepole;
4951 int stocook;
 5052 static int saving;
 5153 
     
 !
203205         }
 204206         switch (ip->type) {
 205207         case IP_NODE:
<> 208+                thisline = ip->lineno;
206209                 p2compile(ip->ip_node);
 207210                 tfree(ip->ip_node);
 208211                 break;
     
 !
254257 void
 255258 codgen(NODE *p, int cookie)
 256259 {
<> 260+        int o;
257261 
 258262         /*
 259263          * Loop around to find sub-trees to store.
 260264          * This mostly applies to arguments.
 261265          */
 262266         for (;;) {
<> 267+                nodepole = p;
263268                 canon(p);  /* creats OREG from * if possible and does sucomp */
 264269                 stotree = NIL;
 265270 #ifdef PCC_DEBUG
     
 !
277282                 gencode(stotree); /* Emit instructions */
 278283         }
 279284 
<> 285+        nodepole = p;
280286         canon(p);  /* creats OREG from * if possible and does sucomp */
 281287 #ifdef PCC_DEBUG
 282288         if (e2debug) {
     
 !
296302         }
 297303 #endif
 298304         genregs(p); /* allocate registers for instructions */
<>299 -        if (p->n_op != REG || p->n_type != VOID) /* XXX */
 300 -                gencode(p); /* Emit instructions */
  305+        switch (p->n_op) {
  306+        case CBRANCH:
  307+                o = p->n_left->n_op;
  308+                gencode(p);
  309+                cbgen(o, p->n_right->n_lval);
  310+                reclaim(p, RNULL, 0);
  311+                break;
  312+        case FORCE:
  313+                gencode(p->n_left);
  314+                reclaim(p, RLEFT, INTAREG|INTBREG);
  315+                break;
  316+        default:
  317+                if (p->n_op != REG || p->n_type != VOID) /* XXX */
  318+                        gencode(p); /* Emit instructions */
  319+        }
301320 #if 0
 302321         for (;;) {
 303322                 canon(p);  /* creats OREG from * if possible and does sucomp */
     
 !
382401 void
 383402 geninsn(NODE *p, int cookie)
 384403 {
<> 404+        NODE *p1, *p2;
385405         int o, rv;
 386406 
 387407 #ifdef PCC_DEBUG
     
 !
392412 #endif
 393413 
 394414 again:  switch (o = p->n_op) {
<> 415+        case EQ:
  416+        case NE:
  417+        case LE:
  418+        case LT:
  419+        case GE:
  420+        case GT:
  421+        case ULE:
  422+        case ULT:
  423+        case UGE:
  424+        case UGT:
  425+                if ((rv = relops(p)) < 0) {
  426+                        if (setbin(p))
  427+                                goto again;
  428+                        goto failed;
  429+                }
  430+                goto sw;
  431+
395432         case PLUS:
 396433         case MINUS:
 397434         case MUL:
     
 !
407444                                 goto again;
 408445                         goto failed;
 409446                 }
<> 447+                goto sw;
  448+
410449         case ASSIGN:
<>411 -                if (o == ASSIGN)
 412 -                    if ((rv = findasg(p, cookie)) < 0) {
  450+                if ((rv = findasg(p, cookie)) < 0) {
413451                         if (setasg(p, cookie))
 414452                                 goto again;
 415453                         goto failed;
 416454                 }
 417455                 /*
 418456                  * Do subnodes conversions (if needed).
 419457                  */
<>420 -                switch (rv & LMASK) {
  458+sw:             switch (rv & LMASK) {
421459                 case LREG:
 422460                         geninsn(p->n_left, INTAREG|INTBREG);
 423461                         break;
     
 !
447485 
 448486         case REG:
 449487                 if (istnode(p))
<>450 -                        cerror("geninsn REG");
  488+                        comperr("geninsn REG");
451489                 /* FALLTHROUGH */
<> 490+        case ICON:
452491         case OREG:
 453492                 if ((cookie & (INTAREG|INTBREG)) == 0)
<>454 -                        cerror("geninsn OREG");
  493+                        comperr("geninsn OREG, node %p", p);
455494                 if ((rv = findleaf(p, cookie)) < 0) {
 456495                         if (setasg(p, cookie))
 457496                                 goto again;
     
 !
460499                 p->n_su = rv;
 461500                 break;
 462501 
<> 502+        case PCONV:
  503+        case SCONV:
463504         case UMUL:
<> 505+        case INIT:
464506         case GOTO:
 465507         case FUNARG:
 466508                 if ((rv = finduni(p, cookie)) < 0) {
     
 !
494536                 gotcall = 1;
 495537                 break;
 496538 
<> 539+        case CBRANCH:
  540+                p1 = p->n_left;
  541+                p2 = p->n_right;
  542+                p1->n_label = p2->n_lval;
  543+                o = p1->n_op;
  544+                geninsn(p1, FORCC);
  545+                p->n_su = -1; /* su calculations traverse left */
  546+                break;
  547+
  548+        case FORCE:
  549+                geninsn(p->n_left, INTAREG|INTBREG);
  550+                p->n_su = -1; /* su calculations traverse left */
  551+                break;
  552+
497553         default:
 498554                 cerror("geninsn: bad op %d", o);
 499555         }
     
 !
10171073         if (!allo(p, q))
 10181074                 cerror("failed register allocation");
 10191075         expand(p, FOREFF, q->cstring);
<>1020 -        reclaim(p, q->rewrite, INTAREG);
  1076+        if ((dope[p->n_op] & LOGFLG))
  1077+                reclaim(p, q->rewrite, FORCC); /* XXX */
  1078+        else
  1079+                reclaim(p, q->rewrite, INTAREG); /* XXX */
10211080 }
 10221081 
 10231082 
     
 !
11531212 
 11541213         *a = *b = down+1;
 11551214         while( down >= 2 ){
<>1156 -                printf( "\t" );
  1215+                fprintf(stderr, "\t");
11571216                 down -= 2;
 11581217                 }
<>1159 -        if( down-- ) printf( "    " );
  1218+        if( down-- ) fprintf(stderr, "    " );
11601219 
 11611220 
<>1162 -        printf( "%p) %s", p, opst[p->n_op] );
  1221+        fprintf(stderr, "%p) %s", p, opst[p->n_op] );
11631222         switch( p->n_op ) { /* special cases */
 11641223 
 11651224         case REG:
<>1166 -                printf( " %s", rnames[p->n_rval] );
  1225+                fprintf(stderr, " %s", rnames[p->n_rval] );
11671226                 break;
 11681227 
 11691228         case TEMP:
<>1170 -                printf(" %d", (int)p->n_lval);
  1229+                fprintf(stderr," %d", (int)p->n_lval);
11711230                 break;
 11721231 
 11731232         case ICON:
 11741233         case NAME:
 11751234         case OREG:
<>1176 -                printf( " " );
 1177 -                adrput( p );
  1235+                fprintf(stderr, " " );
  1236+                adrput(stderr, p );
11781237                 break;
 11791238 
 11801239         case STCALL:
 11811240         case USTCALL:
 11821241         case STARG:
 11831242         case STASG:
<>1184 -                printf( " size=%d", p->n_stsize );
 1185 -                printf( " align=%d", p->n_stalign );
  1243+                fprintf(stderr, " size=%d", p->n_stsize );
  1244+                fprintf(stderr, " align=%d", p->n_stalign );
11861245                 break;
 11871246                 }
 11881247 
<>1189 -        printf( ", " );
 1190 -        tprint( p->n_type, p->n_qual);
 1191 -        printf( ", " );
 1192 -        if( p->n_rall == NOPREF ) printf( "NOPREF" );
  1248+        fprintf(stderr, ", " );
  1249+        tprint(stderr, p->n_type, p->n_qual);
  1250+        fprintf(stderr, ", " );
  1251+        if( p->n_rall == NOPREF ) fprintf(stderr, "NOPREF" );
11931252         else {
<>1194 -                if( p->n_rall & MUSTDO ) printf( "MUSTDO " );
 1195 -                else printf( "PREF " );
 1196 -                printf( "%s", rnames[p->n_rall&~MUSTDO]);
  1253+                if( p->n_rall & MUSTDO ) fprintf(stderr, "MUSTDO " );
  1254+                else fprintf(stderr, "PREF " );
  1255+                fprintf(stderr, "%s", rnames[p->n_rall&~MUSTDO]);
11971256                 }
<>1198 -        printf( ", SU= %d(%s,%s,%s)\n", TBLIDX(p->n_su), ltyp[LMASK&p->n_su],
  1257+        fprintf(stderr, ", SU= %d(%s,%s,%s)\n",
  1258+            TBLIDX(p->n_su), ltyp[LMASK&p->n_su],
11991259             rtyp[(p->n_su&RMASK) >> 2], p->n_su & DORIGHT ? "DORIGHT" : "");
 12001260         return 0;
 12011261 }
     
 !
17361796                          * Both shapes matches directly. For relops this
 17371797                          * is the best match; just return.
 17381798                          */
<>1739 -                        return ixp[i] << 2;
  1799+                        rv = MKIDX(ixp[i], 0);
  1800+                        break;
17401801                 }
 17411802 if (f2debug) printf("second\n");
 17421803                 if (shr) {
     
 !
17471808                          */
 17481809                         if (4 < mtchno) {
 17491810                                 mtchno = 4;
<>1750 -                                rv = (ixp[i] << 2) | LREG;
  1811+                                rv = MKIDX(ixp[i], LREG);
17511812                         }
 17521813                         continue; /* nothing more to do */
 17531814                 }
     
 !
17601821                          */
 17611822                         if (4 < mtchno) {
 17621823                                 mtchno = 4;
<>1763 -                                rv = (ixp[i] << 2) | RREG;
  1824+                                rv = MKIDX(ixp[i], RREG);
17641825                         }
 17651826                         continue; /* nothing more to do */
 17661827                 }
 17671828                 if (6 < mtchno) {
 17681829                         mtchno = 6;
<>1769 -                        rv = (ixp[i] << 2) | RREG|LREG;
  1830+                        rv = MKIDX(ixp[i], RREG|LREG);
17701831                 }
 17711832         }
<>1772 -if (f2debug) { if (rv == -1) printf("relops failed\n"); else printf("relops entry %d, %s %s\n", rv >> 2, rv & RREG ? "RREG" : "", rv & LREG ? "LREG" : ""); }
  1833+#ifdef PCC_DEBUG
  1834+        if (f2debug) {
  1835+                if (rv == -1)
  1836+                        printf("relops failed\n");
  1837+                else
  1838+                        printf("relops entry %d(%s %s)\n",
  1839+                            TBLIDX(rv), ltyp[rv & LMASK], rtyp[(rv&RMASK)>>2]);
  1840+        }
  1841+#endif
17731842         return rv;
 17741843 }
 17751844 
     
 !
19912060 #endif
 19922061         return rv;
 19932062 }
<_ 2063+
  2064+void
  2065+comperr(char *str, ...)
  2066+{
  2067+        extern char *ftitle;
  2068+        va_list ap;
  2069+
  2070+        va_start(ap, str);
  2071+        fprintf(stderr, "%s, line %d: compiler error: ", ftitle, thisline);
  2072+        vfprintf(stderr, str, ap);
  2073+        fprintf(stderr, "\n");
  2074+        va_end(ap);
  2075+
  2076+        fwalk(nodepole, e2print, 0);
  2077+        exit(1);
  2078+}
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-07-10 03:50 +0200