Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.9
 
1.10
 
MAIN:gmcgarry:20071222214626
 
code.c
_>4242 void
 4343 defalign(int n)
 4444 {
<>45 -        n /= SZCHAR;
 46 -        if (n == 1)
 47 -                return;
 48 -        printf("\t.align %d\n", n);
  45+        n = ispow2(n / SZCHAR);
  46+        if (n == -1)
  47+                cerror("defalign: n != 2^i");
  48+        printf("\t.p2align %d\n", n);
4949 }
 5050 
 5151 /*
     
 !
179179         int reg = *regp;
 180180         NODE *p, *q;
 181181         int navail;
<>182 -        int sz;
183182 
 184183         /* alignment */
 185184         ++reg;
 186185         reg &= ~1;
 187186 
 188187         navail = nargregs - (reg - A0);
<>189 -        sz = szty(sym->stype);
190188 
<>191 -        if (sz > navail) {
  189+        if (navail < 2) {
192190                 /* would have appeared half in registers/half
 193191                  * on the stack, but alignment ensures it
 194192                  * appears on the stack */
 195193                 if (dotemps)
 196194                         putintemp(sym);
<>197 -        } else {
 198 -                q = block(REG, NIL, NIL,
 199 -                    sym->stype, sym->sdf, sym->ssue);
 200 -                q->n_rval = A0A1 + (reg - A0);
 201 -                if (dotemps) {
 202 -                        p = tempnode(0, sym->stype, sym->sdf, sym->ssue);
 203 -                        sym->soffset = p->n_lval;
 204 -                        sym->sflags |= STNODE;
 205 -                } else {
 206 -                        spname = sym;
 207 -                        p = buildtree(NAME, 0, 0);
 208 -                }
 209 -                p = buildtree(ASSIGN, p, q);
 210 -                ecomp(p);
 211 -                reg += 2;
  195+                *regp = reg;
  196+                return;
212197         }
 213198 
<>214 -        *regp = reg;
  199+        q = block(REG, NIL, NIL, sym->stype, sym->sdf, sym->ssue);
  200+        q->n_rval = A0A1 + (reg - A0);
  201+        if (dotemps) {
  202+                p = tempnode(0, sym->stype, sym->sdf, sym->ssue);
  203+                sym->soffset = p->n_lval;
  204+                sym->sflags |= STNODE;
  205+        } else {
  206+                spname = sym;
  207+                p = buildtree(NAME, 0, 0);
  208+        }
  209+        p = buildtree(ASSIGN, p, q);
  210+        ecomp(p);
  211+        *regp = reg + 2;
215212 }
 216213 
 217214 /* setup a 32-bit param on the stack
     
 !
236233 }
 237234 
 238235 /*
<> 236+ * XXX This is a hack.  We cannot have (l)doubles in more than one
  237+ * register class.  So we bounce them in and out of temps to
  238+ * move them in and out of the right registers.
  239+ */
  240+static void
  241+param_double(struct symtab *sym, int *regp, int dotemps)
  242+{
  243+        int reg = *regp;
  244+        NODE *p, *q, *t;
  245+        int navail;
  246+        int tmpnr;
  247+
  248+        /* alignment */
  249+        ++reg;
  250+        reg &= ~1;
  251+
  252+        navail = nargregs - (reg - A0);
  253+
  254+        if (navail < 2) {
  255+                /* would have appeared half in registers/half
  256+                 * on the stack, but alignment ensures it
  257+                 * appears on the stack */
  258+                if (dotemps)
  259+                        putintemp(sym);
  260+                *regp = reg;
  261+                return;
  262+        }
  263+
  264+        t = tempnode(0, LONGLONG, 0, MKSUE(LONGLONG));
  265+        tmpnr = t->n_lval;
  266+        q = block(REG, NIL, NIL, LONGLONG, 0, MKSUE(LONGLONG));
  267+        q->n_rval = A0A1 + (reg - A0);
  268+        p = buildtree(ASSIGN, t, q);
  269+        ecomp(p);
  270+
  271+        if (dotemps) {
  272+                sym->soffset = tmpnr;
  273+                sym->sflags |= STNODE;
  274+        } else {
  275+                q = tempnode(tmpnr, sym->stype, sym->sdf, sym->ssue);
  276+                spname = sym;
  277+                p = buildtree(NAME, 0, 0);
  278+                p = buildtree(ASSIGN, p, q);
  279+                ecomp(p);
  280+        }
  281+        *regp = reg + 2;
  282+}
  283+
  284+/*
  285+ * XXX This is a hack.  We cannot have floats in more than one
  286+ * register class.  So we bounce them in and out of temps to
  287+ * move them in and out of the right registers.
  288+ */
  289+static void
  290+param_float(struct symtab *sym, int *regp, int dotemps)
  291+{
  292+        NODE *p, *q, *t;
  293+        int tmpnr;
  294+
  295+        t = tempnode(0, INT, 0, MKSUE(INT));
  296+        tmpnr = t->n_lval;
  297+        q = block(REG, NIL, NIL, INT, 0, MKSUE(INT));
  298+        q->n_rval = (*regp)++;
  299+        p = buildtree(ASSIGN, t, q);
  300+        ecomp(p);
  301+
  302+        if (dotemps) {
  303+                sym->soffset = tmpnr;
  304+                sym->sflags |= STNODE;
  305+        } else {
  306+                q = tempnode(tmpnr, sym->stype, sym->sdf, sym->ssue);
  307+                spname = sym;
  308+                p = buildtree(NAME, 0, 0);
  309+                p = buildtree(ASSIGN, p, q);
  310+                ecomp(p);
  311+        }
  312+}
  313+
  314+/*
239315  * code for the beginning of a function; a is an array of
 240316  * indices in symtab for the arguments; n is the number
 241317  */
     
 !
277353                         putintemp(sp[i]);
 278354                 else if (sp[i]->stype == STRTY || sp[i]->stype == UNIONTY)
 279355                         param_struct(sp[i], &reg);
<>280 -                else if (sp[i]->stype == DOUBLE || sp[i]->stype == LDOUBLE ||
 281 -                     DEUNSIGN(sp[i]->stype) == LONGLONG)
  356+                else if (DEUNSIGN(sp[i]->stype) == LONGLONG)
282357                         param_64bit(sp[i], &reg, xtemps && !saveallargs);
<> 358+                else if (sp[i]->stype == DOUBLE || sp[i]->stype == LDOUBLE)
  359+                        param_double(sp[i], &reg, xtemps && !saveallargs);
  360+                else if (sp[i]->stype == FLOAT)
  361+                        param_float(sp[i], &reg, xtemps && !saveallargs);
283362                 else
 284363                         param_32bit(sp[i], &reg, xtemps && !saveallargs);
 285364         }
     
 !
340419 
 341420         if (t < 0) {
 342421                 if (i != 0)
<>343 -                        puts("\"");
  422+                        puts("\\000\"");
344423         } else {
 345424                 if (i == 0)
<>346 -                        printf("\t.asciiz \"");
  425+                        printf("\t.ascii \"");
347426                 if (t == 0)
 348427                         return;
 349428                 else if (t == '\\' || t == '"') {
 350429                         lastoctal = 0;
 351430                         putchar('\\');
 352431                         putchar(t);
<> 432+                } else if (t == 011) {
  433+                        printf("\\t");
353434                 } else if (t == 012) {
 354435                         printf("\\n");
 355436                 } else if (t < 040 || t >= 0177) {
 356437                         lastoctal++;
 357438                         printf("\\%o",t);
 358439                 } else if (lastoctal && '0' <= t && t <= '9') {
 359440                         lastoctal = 0;
<>360 -                        printf("\"\n\t.asciiz \"%c", t);
  441+                        printf("\"\n\t.ascii \"%c", t);
361442                 } else {        
 362443                         lastoctal = 0;
 363444                         putchar(t);
     
 !
397478 movearg_struct(NODE *p, NODE *parent, int *regp)
 398479 {
 399480         int reg = *regp;
<>400 -        NODE *q, *t, *r;
  481+        NODE *l, *q, *t, *r;
  482+        int tmpnr;
401483         int navail;
 402484         int off;
 403485         int num;
 404486         int sz;
<> 487+        int ty;
405488         int i;
 406489 
 407490         navail = nargregs - (reg - A0);
 408491         sz = tsize(p->n_type, p->n_df, p->n_sue) / SZINT;
 409492         num = sz > navail ? navail : sz;
 410493 
<>411 -        if (p != parent)
  494+        l = p->n_left;
  495+        nfree(p);
  496+        ty = l->n_type;
  497+        t = tempnode(0, l->n_type, l->n_df, l->n_sue);
  498+        tmpnr = t->n_lval;
  499+        l = buildtree(ASSIGN, t, l);
  500+
  501+        if (p != parent) {
412502                 q = parent->n_left;
<>413 -        else
  503+        } else
414504                 q = NULL;
 415505 
 416506         /* copy structure into registers */
 417507         for (i = 0; i < num; i++) {
<>418 -                t = tcopy(p->n_left);
  508+                t = tempnode(tmpnr, ty, 0, MKSUE(PTR+ty));
419509                 t = block(SCONV, t, NIL, PTR+INT, 0, MKSUE(PTR+INT));
 420510                 t = block(PLUS, t, bcon(4*i), PTR+INT, 0, MKSUE(PTR+INT));
 421511                 t = buildtree(UMUL, t, NIL);
     
 !
426516                 r = buildtree(ASSIGN, r, t);
 427517                 if (q == NULL)
 428518                         q = r;
<>429 -                else
  519+                else
430520                         q = block(CM, q, r, INT, 0, MKSUE(INT));
 431521         }
 432522         off = ARGINIT/SZINT + nargregs;
 433523         for (i = num; i < sz; i++) {
<>434 -                t = tcopy(p->n_left);
  524+                t = tempnode(tmpnr, ty, 0, MKSUE(PTR+ty));
435525                 t = block(SCONV, t, NIL, PTR+INT, 0, MKSUE(PTR+INT));
 436526                 t = block(PLUS, t, bcon(4*i), PTR+INT, 0, MKSUE(PTR+INT));
 437527                 t = buildtree(UMUL, t, NIL);
     
 !
447537                 else
 448538                         q = block(CM, q, r, INT, 0, MKSUE(INT));
 449539         }
<>450 -        tfree(p);
451540 
 452541         if (parent->n_op == CM) {
<>453 -                parent->n_left = q->n_left;
 454 -                t = q;
 455 -                q = q->n_right;
 456 -                nfree(t);
  542+                parent->n_left = q;
  543+                q = l;
  544+        } else {
  545+                q = block(CM, q, l, INT, 0, MKSUE(INT));
457546         }
 458547 
 459548         *regp = reg;
     
 !
467556 {
 468557         int reg = *regp;
 469558         NODE *q;
<> 559+        int lastarg;
470560 
 471561         /* alignment */
 472562         ++reg;
 473563         reg &= ~1;
 474564 
<> 565+        lastarg = A0 + nargregs - 1;
  566+        if (reg > lastarg) {
  567+                *regp = reg;
  568+                return block(FUNARG, p, NIL, p->n_type, p->n_df, p->n_sue);
  569+        }
  570+
475571         q = block(REG, NIL, NIL, p->n_type, p->n_df, p->n_sue);
<>476 -        q->n_rval = A0A1 + (reg++ - A0);
  572+        q->n_rval = A0A1 + (reg - A0);
477573         q = buildtree(ASSIGN, q, p);
 478574 
<>479 -        *regp = reg;
  575+        *regp = reg + 2;
480576         return q;
 481577 }
 482578 
     
 !
519615                 *rp = block(FUNARG, r, NIL, r->n_type, r->n_df, r->n_sue);
 520616         else if (r->n_op == STARG) {
 521617                 *rp = movearg_struct(r, p, regp);
<>522 -        } else if (DEUNSIGN(r->n_type) == LONGLONG || r->n_type == DOUBLE ||
 523 -            r->n_type == LDOUBLE)
  618+        } else if (DEUNSIGN(r->n_type) == LONGLONG) {
524619                 *rp = movearg_64bit(r, regp);
<>525 -        else
  620+        } else if (r->n_type == DOUBLE || r->n_type == LDOUBLE) {
  621+                /* XXX bounce in and out of temporary to change to longlong */
  622+                NODE *t1 = tempnode(0, LONGLONG, 0, MKSUE(LONGLONG));
  623+                int tmpnr = t1->n_lval;
  624+                NODE *t2 = tempnode(tmpnr, r->n_type, r->n_df, r->n_sue);
  625+                t1movearg_64bit(t1, regp);
  626+                r = block(ASSIGN, t2, r, r->n_type, r->n_df, r->n_sue);
  627+                if (p->n_op == CM) {
  628+                        p->n_left = buildtree(CM, p->n_left, t1);
  629+                        p->n_right = r;
  630+                } else {
  631+                        p = buildtree(CM, t1, r);
  632+                }
  633+        } else if (r->n_type == FLOAT) {
  634+                /* XXX bounce in and out of temporary to change to int */
  635+                NODE *t1 = tempnode(0, INT, 0, MKSUE(INT));
  636+                int tmpnr = t1->n_lval;
  637+                NODE *t2 = tempnode(tmpnr, r->n_type, r->n_df, r->n_sue);
  638+                t1movearg_32bit(t1, regp);
  639+                r = block(ASSIGN, t2, r, r->n_type, r->n_df, r->n_sue);
  640+                if (p->n_op == CM) {
  641+                        p->n_left = buildtree(CM, p->n_left, t1);
  642+                        p->n_right = r;
  643+                } else {
  644+                        p = buildtree(CM, t1, r);
  645+                }
  646+        } else {
526647                 *rp = movearg_32bit(r, regp);
<> 648+        }
<_527649 
 528650         return p;
 529651 }
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-08-27 18:59 +0200