Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.171
 
1.172
 
MAIN:ragge:20060204174346
 
reader.c
_>6363 /*
 6464  * processing order for nodes:
 6565  * - myreader()
<>66 - * - mkhardops()
6766  * - gencall()
 6867  * - delay()
 6968  * - canon()
     
 !
129128                 cerror("not logop branch");
 130129         if ((dope[p->n_op] & ASGOPFLG) && p->n_op != RETURN)
 131130                 cerror("asgop %d slipped through", p->n_op);
<>132 -        if (p->n_op ==CALL)
 133 -                cerror("non-UCALL node");
134131 }
 135132 #endif
 136133 
     
 !
257254         return NULL;
 258255 }
 259256 
<> 257+static struct interpass ipole;
  258+struct interpass_prolog *epp;
  259+
  260+#if 0
  261+static NODE *
  262+fixargs(NODE *p, struct interpass *ip)
  263+{
  264+        struct interpass *ip2;
  265+        int num;
  266+
  267+        if (canaddr(p))
  268+                return p;
  269+        num = epp->ip_tmpnum++;
  270+        ip2 = ipnode(mkbinode(ASSIGN,
  271+            mklnode(TEMP, num, 0, p->n_type), p, p->n_type));
  272+        DLIST_INSERT_BEFORE(ip, ip2, qelem);
  273+        return mklnode(TEMP, num, 0, p->n_type);
  274+}
  275+
260276 /*
<> 277+ * Gencall() is the first function in pass2.  It cuts out the
  278+ * call arguments and replaces them with temp variables.
  279+ */
  280+static void
  281+xgencall(NODE *p, struct interpass *ip)
  282+{
  283+        int o = p->n_op;
  284+        int ty = optype(o);
  285+
  286+        if (ty == LTYPE)
  287+                return;
  288+
  289+        if (ty != UTYPE)
  290+                xgencall(p->n_right, ip);
  291+        xgencall(p->n_left, ip);
  292+
  293+        if (o != CALL)
  294+                return;
  295+
  296+        if (p->n_right->n_op == CM) {
  297+                p = p->n_right;
  298+                while (p->n_left->n_op == CM) {
  299+                        p->n_right = fixargs(p->n_right, ip);
  300+                        p = p->n_left;
  301+                }
  302+                p->n_right = fixargs(p->n_right, ip);
  303+                p->n_left = fixargs(p->n_left, ip);
  304+        } else
  305+                p->n_right = fixargs(p->n_right, ip);
  306+}
  307+#endif
  308+
  309+/*
261310  * Receives interpass structs from pass1.
 262311  */
 263312 void
 264313 pass2_compile(struct interpass *ip)
 265314 {
<> 315+        if (ip->type == IP_PROLOG) {
  316+                tmpsave = NULL;
  317+                DLIST_INIT(&ipole, qelem);
  318+        }
  319+        DLIST_INSERT_BEFORE(&ipole, ip, qelem);
  320+        if (ip->type != IP_EPILOG)
  321+                return;
266322 
<> 323+#ifdef PCC_DEBUG
  324+        if (e2debug) {
  325+                printf("Entering pass2\n");
  326+                printip(&ipole);
  327+        }
  328+#endif
  329+        epp = (struct interpass_prolog *)DLIST_PREV(&ipole, qelem);
  330+        p2maxautooff = p2autooff = epp->ipp_autos;
  331+        DLIST_FOREACH(ip, &ipole, qelem) {
  332+                if (ip->type != IP_NODE)
  333+                        continue;
  334+                myreader(ip->ip_node); /* local massage of input */
  335+                if (xtemps == 0)
  336+                        walkf(ip->ip_node, deltemp);
  337+                DLIST_INIT(&delayq, qelem);
  338+                delay(ip->ip_node);
  339+                while (DLIST_NEXT(&delayq, qelem) != &delayq) {
  340+                        struct interpass *ip2;
  341+                        ip2 = DLIST_NEXT(&delayq, qelem);
  342+                        DLIST_REMOVE(ip2, qelem);
  343+                        DLIST_INSERT_AFTER(ip, ip2, qelem);
  344+                        ip = ip2;
  345+                }
  346+
  347+        }
  348+        DLIST_FOREACH(ip, &ipole, qelem) {
  349+                if (ip->type != IP_NODE)
  350+                        continue;
  351+                canon(ip->ip_node);
  352+                walkf(ip->ip_node, cktree);
  353+                if ((ip->ip_node = deluseless(ip->ip_node)) == NULL)
  354+                        DLIST_REMOVE(ip, qelem);
  355+        }
  356+
  357+        optimize(&ipole);
  358+        ngenregs(&ipole);
  359+
  360+        DLIST_FOREACH(ip, &ipole, qelem)
  361+                emit(ip);
  362+}
  363+
  364+#if 0
  365+/*
  366+ * Receives interpass structs from pass1.
  367+ */
  368+void
  369+pass2_compile(struct interpass *ip)
  370+{
  371+
267372         if (ip->type == IP_NODE) {
 268373                 myreader(ip->ip_node); /* local massage of input */
 269374                 mkhardops(ip->ip_node);
     
 !
307412         compile4(ip);
 308413 }
 309414 
<>310 -static struct interpass ipole;
311415 /*
 312416  * Save a complete function before doing anything with it in both the
 313417  * optimized and unoptimized case.
     
 !
340444         DLIST_FOREACH(ip, &ipole, qelem)
 341445                 emit(ip);
 342446 }
<> 447+#endif
343448 
 344449 void
 345450 emit(struct interpass *ip)
     
 !
568673                 break;
 569674 #endif
 570675 
<> 676+        case STCALL:
  677+        case CALL:
  678+                /* CALL arguments are handled special */
  679+                for (p1 = p->n_right; p1->n_op == CM; p1 = p1->n_left)
  680+                        geninsn(p1->n_right, FOREFF);
  681+                geninsn(p1, FOREFF);
  682+                /* FALLTHROUGH */
571683         case COMPL:
 572684         case UMINUS:
 573685         case PCONV:
 574686         case SCONV:
 575687         case INIT:
 576688         case GOTO:
 577689         case FUNARG:
<> 690+        case STARG:
578691         case UCALL:
 579692         case USTCALL:
 580693                 rv = finduni(p, cookie);
     
 !
688801 gencode(NODE *p, int cookie)
 689802 {
 690803         struct optab *q = &table[TBLIDX(p->n_su)];
<> 804+        NODE *p1;
691805 
 692806         if (p->n_su == -1) /* For OREGs and similar */
 693807                 return gencode(p->n_left, cookie);
     
 !
770884 
 771885         CDEBUG(("emitting node %p\n", p));
 772886 
<> 887+        if (p->n_op == CALL || p->n_op == FORTCALL || p->n_op == STCALL) {
  888+                /* Print out arguments first */
  889+                lastcall(p); /* last chance before printing out insn */
  890+                for (p1 = p->n_right; p1->n_op == CM; p1 = p1->n_left)
  891+                        gencode(p1->n_right, FOREFF);
  892+                gencode(p1, FOREFF);
  893+        }
  894+
773895         expand(p, cookie, q->cstring);
 774896         if (callop(p->n_op) && cookie != FOREFF &&
 775897             DECRA(p->n_reg, 0) != RETREG(p->n_type)) {
     
 !
11061228 #endif
 11071229         }
 11081230 
<>1109 -/*
 1110 - * Convert unimplemented ops to function calls.
 1111 - */
 1112 -void
 1113 -mkhardops(NODE *p)
 1114 -{
 1115 -        NODE *r, *l, *q;
 1116 -        struct hardops *hop;
 1117 -        int ty = optype(p->n_op);
 1118 -
 1119 -        if (ty == UTYPE)
 1120 -                return mkhardops(p->n_left);
 1121 -        if (ty != BITYPE)
 1122 -                return;
 1123 -        for (hop = hardops; hop->op != 0; hop++)
 1124 -                if (hop->op == p->n_op && hop->type == p->n_type)
 1125 -                        break;
 1126 -
 1127 -        /* Traverse down only if find hardop failed */
 1128 -        /* otherwise traversal down will be done in pass2_compile() */
 1129 -        if (hop->op == 0) {
 1130 -                mkhardops(p->n_left);
 1131 -                mkhardops(p->n_right);
 1132 -                return;
 1133 -        }
 1134 -
 1135 -        l = p->n_left;
 1136 -        if (p->n_op == STASG) {
 1137 -                if (l->n_op == UMUL) {
 1138 -                        /* make it a pointer reference */
 1139 -                        r = l;
 1140 -                        l = l->n_left;
 1141 -                        nfree(r);
 1142 -                } else if (l->n_op == NAME) {
 1143 -                        l->n_op = ICON; /* Constant reference */
 1144 -                        l->n_type = INCREF(l->n_type);
 1145 -                } else
 1146 -                        comperr("STASG mot UMUL");
 1147 -        }
 1148 -        r = p->n_right;
 1149 -
 1150 -        /*
 1151 -         * node p must be converted to a call to fun.
 1152 -         * arguments first.
 1153 -         */
 1154 -        q = mkbinode(CM, l, r, 0);
 1155 -
 1156 -        if (p->n_op == STASG) {
 1157 -                /* Must push the size */
 1158 -                
 1159 -                l = mklnode(ICON, p->n_stsize, 0, INT);
 1160 -                r = mkbinode(CM, q, l, 0);
 1161 -                q = r;
 1162 -        }
 1163 -        p->n_op = CALL;
 1164 -        p->n_right = q;
 1165 -
 1166 -        /* Make function name node */
 1167 -        p->n_left = mklnode(ICON, 0, 0, 0);
 1168 -        p->n_left->n_name = hop->fun;
 1169 -        /* Done! */
 1170 -}
 1171 -
<_11721231 NODE *
 11731232 mklnode(int op, CONSZ lval, int rval, TWORD type)
 11741233 {
FishEye: Open Source License registered to PCC.
Atlassian FishEye, CVS analysis. (Version:1.6.3 Build:build-336 2008-11-04) - Administration - Page generated 2014-12-27 16:04 +0100