Skip to content

Commit

Permalink
pairs of longs, pairs of doubles for 64 bit ABI
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Jun 28, 2012
1 parent bcfb7d9 commit 25d2f95
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 8 deletions.
19 changes: 15 additions & 4 deletions src/argtypes.c
Expand Up @@ -94,10 +94,8 @@ TypeTuple *TypeBasic::toArgTypes()
break;

case Tcomplex64:
#if DMDV2
t1 = Type::tfloat64;
t2 = Type::tfloat64;
#endif
break;

case Tcomplex80:
Expand Down Expand Up @@ -378,9 +376,22 @@ TypeTuple *TypeStruct::toArgTypes()
}
}

// Cannot currently handle arg types that fit in 2 registers
if (t2)
goto Lmemory;
{
if (t1->isfloating() && t2->isfloating())
{
if (t1->ty == Tfloat64 && t2->ty == Tfloat64)
;
else
goto Lmemory;
}
else if (t1->isfloating())
goto Lmemory;
else if (t2->isfloating())
goto Lmemory;
else
;
}
#else
if (sym->fields.dim == 1)
{ VarDeclaration *f = sym->fields[0];
Expand Down
8 changes: 8 additions & 0 deletions src/backend/cgelem.c
Expand Up @@ -2669,6 +2669,8 @@ CEXTERN elem * elstruct(elem *e)
}
if (targ1 && !targ2)
goto L1;
if (I64 && ty == TYstruct)
goto L1;
goto Ldefault;

L1:
Expand All @@ -2679,6 +2681,12 @@ CEXTERN elem * elstruct(elem *e)
else if (I64 && !targ1 && !targ2)
// In-memory only
goto Ldefault;
else if (I64 && targ1 && targ2)
{ if (tyfloating(tybasic(targ1->Tty)))
tym = TYcdouble;
else
tym = TYucent;
}
}
switch (e->Eoper)
{ case OPstreq:
Expand Down
40 changes: 38 additions & 2 deletions src/backend/cod1.c
Expand Up @@ -2400,6 +2400,17 @@ int FuncParamRegs::alloc(type *t, tym_t ty, reg_t *preg1, reg_t *preg2)
return 1;
}

if (I64 &&
tybasic(ty) == TYcdouble &&
numfloatregs - xmmcnt >= 2)
{
// Allocate to register pair
*preg1 = floatregs[xmmcnt];
*preg2 = floatregs[xmmcnt + 1];
xmmcnt += 2;
return 1;
}

for (int j = 0; j < 2; j++)
{
if (regcnt < numintegerregs)
Expand Down Expand Up @@ -2630,8 +2641,33 @@ code *cdfunc(elem *e,regm_t *pretregs)
if (preg2 != mreg)
retregs |= mask[preg2];
code *c1 = getregs(retregs);
c1 = genmovreg(c1, preg, lreg);
c1 = genmovreg(c1, preg2, mreg);

tym_t ty1 = tybasic(ep->Ety);
tym_t ty2 = ty1;
if (ty1 == TYstruct)
{ type *targ1 = ep->ET->Ttag->Sstruct->Sarg1type;
type *targ2 = ep->ET->Ttag->Sstruct->Sarg2type;
if (targ1)
ty1 = targ1->Tty;
if (targ2)
ty2 = targ2->Tty;
}

if (preg != lreg)
if (mask[preg] & XMMREGS)
{ unsigned op = xmmload(ty1); // MOVSS/D preg,lreg
c1 = gen2(c1,op,modregxrmx(3,preg-XMM0,lreg-XMM0));
}
else
c1 = genmovreg(c1, preg, lreg);

if (preg2 != mreg)
if (mask[preg2] & XMMREGS)
{ unsigned op = xmmload(ty2); // MOVSS/D preg2,mreg
c1 = gen2(c1,op,modregxrmx(3,preg2-XMM0,mreg-XMM0));
}
else
c1 = genmovreg(c1, preg2, mreg);

c = cat4(c,csave,cp,c1);
retregs = mask[preg] | mask[preg2];
Expand Down
9 changes: 7 additions & 2 deletions src/backend/cod3.c
Expand Up @@ -2978,8 +2978,10 @@ code *prolog()
{ // Argument is passed in a register

type *t = s->Stype;
type *t2 = NULL;
if (tybasic(t->Tty) == TYstruct)
{ type *targ1 = t->Ttag->Sstruct->Sarg1type;
t2 = t->Ttag->Sstruct->Sarg2type;
if (targ1)
t = targ1;
}
Expand Down Expand Up @@ -3053,6 +3055,8 @@ code *prolog()
preg = s->Spreg2;
if (preg == NOREG)
break;
if (t2)
t = t2;
offset += REGSIZE;
}
}
Expand All @@ -3079,9 +3083,9 @@ code *prolog()
type *t2 = NULL;
if (tybasic(t->Tty) == TYstruct)
{ type *targ1 = t->Ttag->Sstruct->Sarg1type;
t2 = t->Ttag->Sstruct->Sarg2type;
if (targ1)
t = targ1;
t2 = t->Ttag->Sstruct->Sarg2type;
}

reg_t preg = s->Spreg;
Expand All @@ -3108,7 +3112,8 @@ code *prolog()
}
preg = s->Spreg2;
r = s->Sregmsw;
t = t2;
if (t2)
t = t2;
}
}
}
Expand Down

0 comments on commit 25d2f95

Please sign in to comment.