mirror of
https://github.com/dlang/dmd.git
synced 2025-04-30 15:10:15 +03:00
backend: use el_scancommas to skip over OPcomma chains
This commit is contained in:
parent
748fab1e02
commit
c6286ab558
7 changed files with 18 additions and 36 deletions
|
@ -851,8 +851,7 @@ private void bropt()
|
||||||
{
|
{
|
||||||
elem **pn = &(b.Belem);
|
elem **pn = &(b.Belem);
|
||||||
if (OPTIMIZER && *pn)
|
if (OPTIMIZER && *pn)
|
||||||
while ((*pn).Eoper == OPcomma)
|
pn = el_scancommas(pn);
|
||||||
pn = &((*pn).EV.E2);
|
|
||||||
|
|
||||||
elem *n = *pn;
|
elem *n = *pn;
|
||||||
|
|
||||||
|
@ -927,8 +926,7 @@ private void bropt()
|
||||||
}
|
}
|
||||||
else if (b.BC == BCswitch)
|
else if (b.BC == BCswitch)
|
||||||
{ /* see we can evaluate this switch now */
|
{ /* see we can evaluate this switch now */
|
||||||
while (n.Eoper == OPcomma)
|
n = *el_scancommas(&n);
|
||||||
n = n.EV.E2;
|
|
||||||
if (n.Eoper != OPconst)
|
if (n.Eoper != OPconst)
|
||||||
continue;
|
continue;
|
||||||
assert(tyintegral(n.Ety));
|
assert(tyintegral(n.Ety));
|
||||||
|
@ -1803,20 +1801,13 @@ private void brtailrecursion()
|
||||||
if (el_anyframeptr(*pe)) // if any OPframeptr's
|
if (el_anyframeptr(*pe)) // if any OPframeptr's
|
||||||
return;
|
return;
|
||||||
|
|
||||||
static elem** skipCommas(elem** pe)
|
pe = el_scancommas(pe);
|
||||||
{
|
|
||||||
while ((*pe).Eoper == OPcomma)
|
|
||||||
pe = &(*pe).EV.E2;
|
|
||||||
return pe;
|
|
||||||
}
|
|
||||||
|
|
||||||
pe = skipCommas(pe);
|
|
||||||
|
|
||||||
elem *e = *pe;
|
elem *e = *pe;
|
||||||
|
|
||||||
static bool isCandidate(elem* e)
|
static bool isCandidate(elem* e)
|
||||||
{
|
{
|
||||||
e = *skipCommas(&e);
|
e = *el_scancommas(&e);
|
||||||
if (e.Eoper == OPcond)
|
if (e.Eoper == OPcond)
|
||||||
return isCandidate(e.EV.E2.EV.E1) || isCandidate(e.EV.E2.EV.E2);
|
return isCandidate(e.EV.E2.EV.E1) || isCandidate(e.EV.E2.EV.E2);
|
||||||
|
|
||||||
|
@ -1990,9 +1981,7 @@ private void emptyloops()
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Find einit
|
// Find einit
|
||||||
elem *einit;
|
elem *einit = *el_scancommas(&(bpred.Belem));
|
||||||
for (einit = bpred.Belem; einit.Eoper == OPcomma; einit = einit.EV.E2)
|
|
||||||
{ }
|
|
||||||
if (einit.Eoper != OPeq ||
|
if (einit.Eoper != OPeq ||
|
||||||
einit.EV.E2.Eoper != OPconst ||
|
einit.EV.E2.Eoper != OPconst ||
|
||||||
einit.EV.E1.Eoper != OPvar)
|
einit.EV.E1.Eoper != OPvar)
|
||||||
|
|
|
@ -273,8 +273,7 @@ void note87(elem *e, uint offset, int i, int linnum)
|
||||||
}
|
}
|
||||||
assert(i < global87.stackused);
|
assert(i < global87.stackused);
|
||||||
|
|
||||||
while (e.Eoper == OPcomma)
|
e = *el_scancommas(&e);
|
||||||
e = e.EV.E2;
|
|
||||||
global87.stack[i].e = e;
|
global87.stack[i].e = e;
|
||||||
global87.stack[i].offset = offset;
|
global87.stack[i].offset = offset;
|
||||||
}
|
}
|
||||||
|
@ -310,8 +309,7 @@ private void makesure87(ref CodeBuilder cdb,elem *e,uint offset,int i,uint flag,
|
||||||
{
|
{
|
||||||
debug if (NDPP) printf("makesure87(e=%p, offset=%d, i=%d, flag=%d, line=%d)\n",e,offset,i,flag,linnum);
|
debug if (NDPP) printf("makesure87(e=%p, offset=%d, i=%d, flag=%d, line=%d)\n",e,offset,i,flag,linnum);
|
||||||
|
|
||||||
while (e.Eoper == OPcomma)
|
e = *el_scancommas(&e);
|
||||||
e = e.EV.E2;
|
|
||||||
assert(e && i < 4);
|
assert(e && i < 4);
|
||||||
L1:
|
L1:
|
||||||
if (global87.stack[i].e != e || global87.stack[i].offset != offset)
|
if (global87.stack[i].e != e || global87.stack[i].offset != offset)
|
||||||
|
@ -2021,8 +2019,7 @@ void eq87(ref CodeBuilder cdb,elem *e,regm_t *pretregs)
|
||||||
if (*pretregs & (mST0 | ALLREGS | mBP | XMMREGS)) // if want result on stack too
|
if (*pretregs & (mST0 | ALLREGS | mBP | XMMREGS)) // if want result on stack too
|
||||||
{ // Make sure it's still there
|
{ // Make sure it's still there
|
||||||
elem *e2 = e.EV.E2;
|
elem *e2 = e.EV.E2;
|
||||||
while (e2.Eoper == OPcomma)
|
e2 = *el_scancommas(&e2);
|
||||||
e2 = e2.EV.E2;
|
|
||||||
note87(e2,0,0);
|
note87(e2,0,0);
|
||||||
getlvalue87(cdb, cs, e.EV.E1, 0);
|
getlvalue87(cdb, cs, e.EV.E1, 0);
|
||||||
makesure87(cdb,e2,0,0,1);
|
makesure87(cdb,e2,0,0,1);
|
||||||
|
|
|
@ -3677,8 +3677,7 @@ elem * elstruct(elem *e, goal_t goal)
|
||||||
pe2 = &e.EV.E1;
|
pe2 = &e.EV.E1;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
while ((*pe2).Eoper == OPcomma)
|
pe2 = el_scancommas(pe2);
|
||||||
pe2 = &(*pe2).EV.E2;
|
|
||||||
elem *e2 = *pe2;
|
elem *e2 = *pe2;
|
||||||
|
|
||||||
if (e2.Eoper == OPvar)
|
if (e2.Eoper == OPvar)
|
||||||
|
|
|
@ -84,8 +84,7 @@ int isscaledindex(elem *e)
|
||||||
targ_uns ss;
|
targ_uns ss;
|
||||||
|
|
||||||
assert(!I16);
|
assert(!I16);
|
||||||
while (e.Eoper == OPcomma)
|
e = *el_scancommas(&e);
|
||||||
e = e.EV.E2;
|
|
||||||
if (!(e.Eoper == OPshl && !e.Ecount &&
|
if (!(e.Eoper == OPshl && !e.Ecount &&
|
||||||
e.EV.E2.Eoper == OPconst &&
|
e.EV.E2.Eoper == OPconst &&
|
||||||
(ss = e.EV.E2.EV.Vuns) <= 3
|
(ss = e.EV.E2.EV.Vuns) <= 3
|
||||||
|
|
|
@ -1180,14 +1180,16 @@ bool el_returns(const(elem)* e)
|
||||||
|
|
||||||
/********************************
|
/********************************
|
||||||
* Scan down commas and return the controlling elem.
|
* Scan down commas and return the controlling elem.
|
||||||
|
* Extra layer of indirection so we can update
|
||||||
|
* (*ret)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@trusted
|
@trusted
|
||||||
elem *el_scancommas(elem *e)
|
elem **el_scancommas(elem **pe)
|
||||||
{
|
{
|
||||||
while (e.Eoper == OPcomma)
|
while ((*pe).Eoper == OPcomma)
|
||||||
e = e.EV.E2;
|
pe = &(*pe).EV.E2;
|
||||||
return e;
|
return pe;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************
|
/***************************
|
||||||
|
|
|
@ -1910,8 +1910,7 @@ public void verybusyexp()
|
||||||
pn = &(b.Belem);
|
pn = &(b.Belem);
|
||||||
if (*pn)
|
if (*pn)
|
||||||
{
|
{
|
||||||
while ((*pn).Eoper == OPcomma)
|
pn = el_scancommas(pn);
|
||||||
pn = &((*pn).EV.E2);
|
|
||||||
/* If last statement has side effects, */
|
/* If last statement has side effects, */
|
||||||
/* don't do these VBEs. Potentially we */
|
/* don't do these VBEs. Potentially we */
|
||||||
/* could by assigning the result to */
|
/* could by assigning the result to */
|
||||||
|
|
|
@ -420,10 +420,7 @@ elem *addressElem(elem *e, Type t, bool alwaysCopy = false)
|
||||||
{
|
{
|
||||||
//printf("addressElem()\n");
|
//printf("addressElem()\n");
|
||||||
|
|
||||||
elem **pe;
|
elem **pe = el_scancommas(&e);
|
||||||
for (pe = &e; (*pe).Eoper == OPcomma; pe = &(*pe).EV.E2)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// For conditional operator, both branches need conversion.
|
// For conditional operator, both branches need conversion.
|
||||||
if ((*pe).Eoper == OPcond)
|
if ((*pe).Eoper == OPcond)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue