Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.76
 
1.77
 
MAIN:ragge:20140524151953
 
code.c
_>247247                                 regno(n) = regpregs[nrarg++];
 248248                         } else {
 249249                                 n = block(OREG, 0, 0, INT, 0, 0);
<>250 -                                n->n_lval = argbase;
  250+                                n->n_lval = argbase/SZCHAR;
251251                                 argbase += SZINT;
 252252                                 regno(n) = FPREG;
 253253                         }
     
 !
409409 static void
 410410 addreg(NODE *p)
 411411 {
<>412 -        if (p->n_op != FUNARG)
  412+        TWORD t;
  413+        NODE *q;
  414+        int sz, r;
  415+
  416+        sz = tsize(p->n_type, p->n_df, p->n_ap)/SZCHAR;
  417+        sz = (sz + 3) >> 2;     /* sz in regs */
  418+        if ((regcvt+sz) > rparg) {
  419+                regcvt = rparg;
413420                 return;
<>414 -        if (regcvt >= rparg)
 415 -                return;
 416 -        if (p->n_type < INT) {
 417 -                p->n_left = ccast(p->n_left, INT, 0, 0, 0);
 418 -                p->n_type = INT;
419421         }
<>420 -        p->n_op = ASSIGN;
 421 -        p->n_right = p->n_left;
  422+        if (sz > 2)
  423+                uerror("cannot put struct in 3 regs (yet)");
  424+
  425+        if (sz == 2)
  426+                r = regcvt == 0 ? EAXEDX : EDXECX;
  427+        else
  428+                r = regcvt == 0 ? EAX : regcvt == 1 ? EDX : ECX;
  429+
  430+        if (p->n_op == FUNARG) {
  431+                /* at most 2 regs */
  432+                if (p->n_type < INT) {
  433+                        p->n_left = ccast(p->n_left, INT, 0, 0, 0);
  434+                        p->n_type = INT;
  435+                }
  436+
  437+                p->n_op = ASSIGN;
  438+                p->n_right = p->n_left;
  439+        } else if (p->n_op == STARG) {
  440+                /* convert to ptr, put in reg */
  441+                q = p->n_left;
  442+                t = sz == 2 ? LONGLONG : INT;
  443+                q = cast(q, INCREF(t), 0);
  444+                q = buildtree(UMUL, q, NIL);
  445+                p->n_op = ASSIGN;
  446+                p->n_type = t;
  447+                p->n_right = q;
  448+        } else
  449+                cerror("addreg");
422450         p->n_left = block(REG, 0, 0, p->n_type, 0, 0);
<>423 -        regno(p->n_left) = regcvt == 0 ? EAX : regcvt == 1 ? EDX : ECX;
 424 -        regcvt++;
  451+        regno(p->n_left) = r;
  452+        regcvt += sz;
425453 }
 426454 
 427455 /*
     
 !
437465         struct attr *ap;
 438466 #endif
 439467         NODE *r, *l;
<>440 -        int narg = 0;
  468+        TWORD t = DECREF(DECREF(p->n_left->n_type));
  469+        int stcall;
441470 
<> 471+        stcall = ISSOU(t);
  472+        /*
  473+         * We may have to prepend:
  474+         * - Hidden arg0 for struct return (in reg or on stack).
  475+         * - ebx in case of PIC code.
  476+         */
  477+
442478         /* Fix function call arguments. On x86, just add funarg */
 443479         for (r = p->n_right; r->n_op == CM; r = r->n_left) {
<>444 -                narg++;
445480                 if (r->n_right->n_op != STARG)
 446481                         r->n_right = block(FUNARG, r->n_right, NIL,
 447482                             r->n_right->n_type, r->n_right->n_df,
 448483                             r->n_right->n_ap);
 449484         }
 450485         if (r->n_op != STARG) {
<>451 -                narg++;
452486                 l = talloc();
 453487                 *l = *r;
 454488                 r->n_op = FUNARG;
 455489                 r->n_left = l;
 456490                 r->n_type = l->n_type;
 457491         }
<> 492+        if (stcall) {
  493+                /* Prepend a placeholder for struct address. */
  494+                /* Use EBP, can never show up under normal circumstances */
  495+                l = talloc();
  496+                *l = *r;
  497+                r->n_op = CM;
  498+                r->n_right = l;
  499+                r->n_type = INT;
  500+                l = block(REG, 0, 0, INCREF(VOID), 0, 0);
  501+                regno(l) = EBP;
  502+                l = block(FUNARG, l, 0, INCREF(VOID), 0, 0);
  503+                r->n_left = l;
  504+        }
458505 
 459506 #ifdef GCC_COMPAT
 460507         if ((ap = attr_find(p->n_left->n_ap, GCC_ATYP_REGPARM)))
 461508                 rparg = ap->iarg(0);
 462509         else
 463510 #endif
 464511                 rparg = 0;
<>465 -        if (rparg > narg)
 466 -                rparg = narg;
467512 
 468513         regcvt = 0;
 469514         if (rparg)
 470515                 listf(p->n_right, addreg);
 471516 
 472517         if (kflag == 0)
 473518                 return p;
<> 519+
<_474520 #if defined(ELFABI)
 475521         /* Create an ASSIGN node for ebx */
 476522         l = block(REG, NIL, NIL, INT, 0, 0);
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 07:35 +0100