Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.231
 
1.232
 
MAIN:ragge:20080630082137
 
reader.c
_>9090 
 9191 void saveip(struct interpass *ip);
 9292 void deltemp(NODE *p);
<>93 -void cvtemps(struct interpass *epil);
  93+static void cvtemps(struct interpass *ipole, int op, int off);
9494 NODE *store(NODE *);
 9595 static void fixxasm(struct interpass *ip);
 9696 
     
 !
12201220         struct interpass *ip = arg, *ip2;
 12211221         NODE *r = ip->ip_node->n_left;
 12221222         NODE *q;
<> 1223+        TWORD t;
12231224         int cnt;
 12241225 
 12251226         if (p->n_name[0] < '0' || p->n_name[0] > '9')
 12261227                 return; /* not numeric */
 12271228         if ((q = listarg(r, p->n_name[0] - '0', &cnt)) == NIL)
 12281229                 comperr("bad delnums");
 12291230 
<>1230 -        /* move original node to dest */
 1231 -        r = mkbinode(ASSIGN, tcopy(q->n_left), p->n_left, p->n_left->n_type);
  1231+        /* Delete number by adding move-to/from-temp.  Later on */
  1232+        /* the temps may be rewritten to other LTYPEs */
  1233+        t = p->n_left->n_type;
  1234+        r = mklnode(TEMP, 0, epp->ip_tmpnum++, t);
12321235 
<>1233 -        /* must be careful with types */
 1234 -        r->n_left->n_type = p->n_left->n_type; /* XXX LTYPE? */
 1235 -
 1236 -        ip2 = ipnode(r);
  1236+        /* pre node */
  1237+        ip2 = ipnode(mkbinode(ASSIGN, tcopy(r), p->n_left, t));
12371238         DLIST_INSERT_BEFORE(ip, ip2, qelem);
 12381239 
<>1239 -        p->n_left = tcopy(q->n_left);
  1240+        /* post node */
  1241+        ip2 = ipnode(mkbinode(ASSIGN, q->n_left, tcopy(r), t));
  1242+        DLIST_INSERT_AFTER(ip, ip2, qelem);
  1243+
  1244+        p->n_left = tcopy(r);
  1245+        q->n_left = r;
  1246+
12401247         p->n_name = tmpstrdup(q->n_name);
 12411248         if (*p->n_name == '=')
 12421249                 p->n_name++;
     
 !
12521259         struct interpass *ip2;
 12531260         TWORD t = p->n_left->n_type;
 12541261         NODE *q, *r;
<>1255 -        int cw, ooff;
  1262+        int cw, ooff, o;
12561263         char *c;
 12571264 
 12581265 again:
     
 !
12611268 
 12621269         cw = xasmcode(p->n_name);
 12631270         switch (XASMVAL(cw)) {
<> 1271+        case 'g'/* general; any operand */
  1272+                o = p->n_left->n_op;
  1273+                p->n_name = tmpstrdup(p->n_name);
  1274+                c = strchr(p->n_name, XASMVAL(cw)); /* cannot fail */
  1275+                if (optype(o) == LTYPE) {
  1276+                        /* already leaf, just rewrite codeword */
  1277+                        *c = (o == REG || o == TEMP ? 'r' : 'm');
  1278+                } else
  1279+                        *c = 'r'; /* Make reg of it */
  1280+                goto again; /* retry */
  1281+
12641282         case 'p':
 12651283                 /* pointer */
 12661284                 /* just make register of it */
     
 !
12921310                 break;
 12931311 
 12941312         case 'm': /* memory operand */
<>1295 -                if (p->n_left->n_op != REG && p->n_left->n_op != TEMP)
 1296 -                        break;
12971313                 /* store and reload value */
 12981314                 q = p->n_left;
<>1299 -                r = (cw & XASMINOUT ? tcopy(q) : q);
 1300 -                ooff = BITOOR(freetemp(szty(t)));
 1301 -                p->n_left = mklnode(OREG, ooff, FPREG, t);
 1302 -                if ((cw & XASMASG) == 0) {
 1303 -                        ip2 = ipnode(mkbinode(ASSIGN,
 1304 -                            mklnode(OREG, ooff, FPREG, t), q, t));
  1315+                if (optype(q->n_op) == LTYPE) {
  1316+                        if (q->n_op == TEMP) {
  1317+                                ooff = BITOOR(freetemp(szty(t)));
  1318+                                cvtemps(ip, q->n_rval, ooff);
  1319+                        } else if (q->n_op == REG)
  1320+                                comperr("xasm m and reg");
  1321+                } else if (q->n_op == UMUL &&
  1322+                    (q->n_left->n_op != TEMP && q->n_left->n_op != REG)) {
  1323+                        t = q->n_left->n_type;
  1324+                        ooff = epp->ip_tmpnum++;
  1325+                        ip2 = ipnode(mkbinode(ASSIGN,
  1326+                            mklnode(TEMP, 0, ooff, t), q->n_left, t));
  1327+                        q->n_left = mklnode(TEMP, 0, ooff, t);
13051328                         DLIST_INSERT_BEFORE(ip, ip2, qelem);
 13061329                 }
<>1307 -                if (cw & (XASMASG|XASMINOUT)) {
 1308 -                        /* output parameter */
 1309 -                        ip2 = ipnode(mkbinode(ASSIGN, r,
 1310 -                            mklnode(OREG, ooff, FPREG, t), t));
 1311 -                        DLIST_INSERT_AFTER(ip, ip2, qelem);
 1312 -                }
13131330                 break;
 13141331 
 13151332         case 'i': /* immediate constant */
     
 !
13821399         }
 13831400         return cw;
 13841401 }
<_ 1402+
  1403+static int xasnum, xoffnum;
  1404+
  1405+static void
  1406+xconv(NODE *p)
  1407+{
  1408+        if (p->n_op != TEMP || p->n_rval != xasnum)
  1409+                return;
  1410+        p->n_op = OREG;
  1411+        p->n_rval = FPREG;
  1412+        p->n_lval = xoffnum;
  1413+}
  1414+
  1415+/*
  1416+ * Convert nodes of type TEMP to op with lval off.
  1417+ */
  1418+static void
  1419+cvtemps(struct interpass *ipl, int tnum, int off)
  1420+{
  1421+        struct interpass *ip;
  1422+
  1423+        xasnum = tnum;
  1424+        xoffnum = off;
  1425+
  1426+        DLIST_FOREACH(ip, ipl, qelem)
  1427+                if (ip->type == IP_NODE)
  1428+                        walkf(ip->ip_node, xconv);
  1429+        walkf(ipl->ip_node, xconv);
  1430+}
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-01 20:33 +0200