mirror of
https://github.com/dlang/dmd.git
synced 2025-04-28 14:10:11 +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);
|
||||
if (OPTIMIZER && *pn)
|
||||
while ((*pn).Eoper == OPcomma)
|
||||
pn = &((*pn).EV.E2);
|
||||
pn = el_scancommas(pn);
|
||||
|
||||
elem *n = *pn;
|
||||
|
||||
|
@ -927,8 +926,7 @@ private void bropt()
|
|||
}
|
||||
else if (b.BC == BCswitch)
|
||||
{ /* see we can evaluate this switch now */
|
||||
while (n.Eoper == OPcomma)
|
||||
n = n.EV.E2;
|
||||
n = *el_scancommas(&n);
|
||||
if (n.Eoper != OPconst)
|
||||
continue;
|
||||
assert(tyintegral(n.Ety));
|
||||
|
@ -1803,20 +1801,13 @@ private void brtailrecursion()
|
|||
if (el_anyframeptr(*pe)) // if any OPframeptr's
|
||||
return;
|
||||
|
||||
static elem** skipCommas(elem** pe)
|
||||
{
|
||||
while ((*pe).Eoper == OPcomma)
|
||||
pe = &(*pe).EV.E2;
|
||||
return pe;
|
||||
}
|
||||
|
||||
pe = skipCommas(pe);
|
||||
pe = el_scancommas(pe);
|
||||
|
||||
elem *e = *pe;
|
||||
|
||||
static bool isCandidate(elem* e)
|
||||
{
|
||||
e = *skipCommas(&e);
|
||||
e = *el_scancommas(&e);
|
||||
if (e.Eoper == OPcond)
|
||||
return isCandidate(e.EV.E2.EV.E1) || isCandidate(e.EV.E2.EV.E2);
|
||||
|
||||
|
@ -1990,9 +1981,7 @@ private void emptyloops()
|
|||
continue;
|
||||
|
||||
// Find einit
|
||||
elem *einit;
|
||||
for (einit = bpred.Belem; einit.Eoper == OPcomma; einit = einit.EV.E2)
|
||||
{ }
|
||||
elem *einit = *el_scancommas(&(bpred.Belem));
|
||||
if (einit.Eoper != OPeq ||
|
||||
einit.EV.E2.Eoper != OPconst ||
|
||||
einit.EV.E1.Eoper != OPvar)
|
||||
|
|
|
@ -273,8 +273,7 @@ void note87(elem *e, uint offset, int i, int linnum)
|
|||
}
|
||||
assert(i < global87.stackused);
|
||||
|
||||
while (e.Eoper == OPcomma)
|
||||
e = e.EV.E2;
|
||||
e = *el_scancommas(&e);
|
||||
global87.stack[i].e = e;
|
||||
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);
|
||||
|
||||
while (e.Eoper == OPcomma)
|
||||
e = e.EV.E2;
|
||||
e = *el_scancommas(&e);
|
||||
assert(e && i < 4);
|
||||
L1:
|
||||
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
|
||||
{ // Make sure it's still there
|
||||
elem *e2 = e.EV.E2;
|
||||
while (e2.Eoper == OPcomma)
|
||||
e2 = e2.EV.E2;
|
||||
e2 = *el_scancommas(&e2);
|
||||
note87(e2,0,0);
|
||||
getlvalue87(cdb, cs, e.EV.E1, 0);
|
||||
makesure87(cdb,e2,0,0,1);
|
||||
|
|
|
@ -3677,8 +3677,7 @@ elem * elstruct(elem *e, goal_t goal)
|
|||
pe2 = &e.EV.E1;
|
||||
else
|
||||
break;
|
||||
while ((*pe2).Eoper == OPcomma)
|
||||
pe2 = &(*pe2).EV.E2;
|
||||
pe2 = el_scancommas(pe2);
|
||||
elem *e2 = *pe2;
|
||||
|
||||
if (e2.Eoper == OPvar)
|
||||
|
|
|
@ -84,8 +84,7 @@ int isscaledindex(elem *e)
|
|||
targ_uns ss;
|
||||
|
||||
assert(!I16);
|
||||
while (e.Eoper == OPcomma)
|
||||
e = e.EV.E2;
|
||||
e = *el_scancommas(&e);
|
||||
if (!(e.Eoper == OPshl && !e.Ecount &&
|
||||
e.EV.E2.Eoper == OPconst &&
|
||||
(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.
|
||||
* Extra layer of indirection so we can update
|
||||
* (*ret)
|
||||
*/
|
||||
|
||||
@trusted
|
||||
elem *el_scancommas(elem *e)
|
||||
elem **el_scancommas(elem **pe)
|
||||
{
|
||||
while (e.Eoper == OPcomma)
|
||||
e = e.EV.E2;
|
||||
return e;
|
||||
while ((*pe).Eoper == OPcomma)
|
||||
pe = &(*pe).EV.E2;
|
||||
return pe;
|
||||
}
|
||||
|
||||
/***************************
|
||||
|
|
|
@ -1910,8 +1910,7 @@ public void verybusyexp()
|
|||
pn = &(b.Belem);
|
||||
if (*pn)
|
||||
{
|
||||
while ((*pn).Eoper == OPcomma)
|
||||
pn = &((*pn).EV.E2);
|
||||
pn = el_scancommas(pn);
|
||||
/* If last statement has side effects, */
|
||||
/* don't do these VBEs. Potentially we */
|
||||
/* could by assigning the result to */
|
||||
|
|
|
@ -420,10 +420,7 @@ elem *addressElem(elem *e, Type t, bool alwaysCopy = false)
|
|||
{
|
||||
//printf("addressElem()\n");
|
||||
|
||||
elem **pe;
|
||||
for (pe = &e; (*pe).Eoper == OPcomma; pe = &(*pe).EV.E2)
|
||||
{
|
||||
}
|
||||
elem **pe = el_scancommas(&e);
|
||||
|
||||
// For conditional operator, both branches need conversion.
|
||||
if ((*pe).Eoper == OPcond)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue