Skip to content

Commit

Permalink
Merge pull request #5385 from WalterBright/optabgen
Browse files Browse the repository at this point in the history
remove #ifs from optabgen, gother, gloop
  • Loading branch information
yebblies committed Jan 31, 2016
2 parents 22ee44c + 8052ec1 commit 2936b14
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 89 deletions.
33 changes: 1 addition & 32 deletions src/backend/gloop.c
Expand Up @@ -567,10 +567,8 @@ STATIC int looprotate(loop *l)
if (b == head) // if loop already rotated
goto Lret;

#if SCPP
if (head->BC == BCtry)
goto Lret;
#endif
if (head->BC == BC_try)
goto Lret;
#ifdef DEBUG
Expand Down Expand Up @@ -988,19 +986,15 @@ STATIC void markinvar(elem *n,vec_t rd)
case OPvoid:
case OPstrlen:
case OPddtor:
#if TX86
case OPinp:
#endif
markinvar(n->E1,rd);
break;
case OPcond:
case OPparam:
case OPstrcmp:
case OPmemcmp:
case OPbt: // OPbt is like OPind, assume not LI
#if TX86
case OPoutp:
#endif
markinvar(n->E1,rd);
markinvar(n->E2,rd);
break;
Expand Down Expand Up @@ -1055,16 +1049,12 @@ STATIC void markinvar(elem *n,vec_t rd)
case OPbsr:
case OPbswap:
case OPpopcnt:
#if TX86
case OPsqrt:
case OPsin:
case OPcos:
#endif
#if TARGET_SEGMENTED
case OPvp_fp: /* BUG for MacHandles */
case OPnp_f16p: case OPf16p_np: case OPoffset: case OPnp_fp:
case OPcvp_fp:
#endif
markinvar(n->E1,rd);
if (isLI(n->E1)) /* if child is LI */
makeLI(n);
Expand Down Expand Up @@ -1116,11 +1106,9 @@ STATIC void markinvar(elem *n,vec_t rd)
case OPpair:
case OPrpair:
case OPremquo:
#if TX86
case OPscale:
case OPyl2x:
case OPyl2xp1:
#endif
markinvar(n->E1,rd);
markinvar(n->E2,rd);
if (isLI(n->E2) && isLI(n->E1))
Expand Down Expand Up @@ -1930,12 +1918,10 @@ STATIC famlist * newfamlist(tym_t ty)
c.Vshort = 1;
break;

#if TARGET_SEGMENTED
case TYsptr:
case TYcptr:
case TYfptr:
case TYvptr:
#endif
case TYnptr:
case TYnullptr:
ty = TYint;
Expand All @@ -1946,10 +1932,9 @@ STATIC famlist * newfamlist(tym_t ty)
case TYuint:
c.Vint = 1;
break;
#if TARGET_SEGMENTED

case TYhptr:
ty = TYlong;
#endif
case TYlong:
case TYulong:
case TYdchar:
Expand All @@ -1962,10 +1947,8 @@ STATIC famlist * newfamlist(tym_t ty)
if (typtr(ty))
{
ty = TYint;
#if TARGET_SEGMENTED
if (tybasic(ty) == TYhptr)
ty = TYlong;
#endif
if (I64)
ty = TYllong;
}
Expand Down Expand Up @@ -2350,7 +2333,6 @@ STATIC void ivfamelems(Iv *biv,elem **pn)
n1 = n->E1;
}

#if TARGET_SEGMENTED
// Get rid of case where we painted a far pointer to a long
if (op == OPadd || op == OPmin)
{ int sz;
Expand All @@ -2360,7 +2342,6 @@ STATIC void ivfamelems(Iv *biv,elem **pn)
(sz != tysize(n1->Ety) || sz != tysize(n2->Ety)))
return;
}
#endif

/* Look for function of basic IV (-biv or biv op const) */
if (n1->Eoper == OPvar && n1->EV.sp.Vsym == biv->IVbasic)
Expand Down Expand Up @@ -2406,11 +2387,9 @@ STATIC void ivfamelems(Iv *biv,elem **pn)
/* Check for subtracting two pointers */
if (typtr(c2ty) && typtr(n2->Ety))
{
#if TARGET_SEGMENTED
if (tybasic(c2ty) == TYhptr)
c2ty = TYlong;
else
#endif
c2ty = I64 ? TYllong : TYint;
}
L1:
Expand Down Expand Up @@ -2679,11 +2658,9 @@ STATIC bool funcprev(Iv *biv,famlist *fl)
else /* can't subtract fptr */
goto L1;
}
#if TARGET_SEGMENTED
if (tybasic(fls->c2->Ety) == TYhptr)
tymin = TYlong;
else
#endif
tymin = I64 ? TYllong : TYint; /* type of (ptr - ptr) */
}

Expand Down Expand Up @@ -2950,15 +2927,13 @@ STATIC void elimbasivs(loop *l)
}
}

#if TARGET_SEGMENTED
/* Fix if leaves of compare are TYfptrs and the compare */
/* operator is < <= > >=. */
if (ref->Eoper >= OPle && ref->Eoper <= OPge && tyfv(ref->E1->Ety))
{ assert(tyfv(ref->E2->Ety));
ref->E1 = el_una(OPoffset,TYuint,ref->E1);
ref->E2 = el_una(OPoffset,TYuint,fofe);
}
#endif
#ifdef DEBUG
if (debugc)
{ WReqn(ref);
Expand Down Expand Up @@ -2989,14 +2964,12 @@ STATIC void elimbasivs(loop *l)
ne = el_bin(OPmin,ty,
el_var(fl->FLtemp),
C2);
#if TARGET_SEGMENTED
if (tybasic(ne->E1->Ety) == TYfptr &&
tybasic(ne->E2->Ety) == TYfptr)
{ ne->Ety = I64 ? TYllong : TYint;
if (tylong(ty) && intsize == 2)
ne = el_una(OPs16_32,ty,ne);
}
#endif

ne = el_bin(OPeq,X->ty(),
el_var(X),
Expand Down Expand Up @@ -3214,10 +3187,8 @@ STATIC famlist * flcmp(famlist *f1,famlist *f2)
goto Lf2;
break;

#if TARGET_SEGMENTED
case TYsptr:
case TYcptr:
#endif
case TYnptr: // BUG: 64 bit pointers?
case TYnullptr:
case TYint:
Expand All @@ -3229,11 +3200,9 @@ STATIC famlist * flcmp(famlist *f1,famlist *f2)
case TYlong:
case TYulong:
case TYdchar:
#if TARGET_SEGMENTED
case TYfptr:
case TYvptr:
case TYhptr:
#endif
case_long:
if (t2->Vlong == 1 ||
t1->Vlong != 1 && f2->c2->EV.Vlong == 0)
Expand Down
12 changes: 1 addition & 11 deletions src/backend/gother.c
Expand Up @@ -102,9 +102,7 @@ void constprop()
{
rd_compute();
intranges(); // compute integer ranges
#if 0
eqeqranges(); // see if we can eliminate some relationals
#endif
//eqeqranges(); // see if we can eliminate some relationals
elemdatafree(&eqeqlist);
elemdatafree(&rellist);
elemdatafree(&inclist);
Expand Down Expand Up @@ -132,9 +130,7 @@ STATIC void rd_compute()

switch (b->BC)
{
#if MARS
case BCjcatch:
#endif
case BC_finally:
case BC_lpad:
case BCasm:
Expand Down Expand Up @@ -424,9 +420,7 @@ STATIC void chkrd(elem *n,list_t rdlist)
#endif

sv->Sflags |= SFLnord; // no redundant messages
#ifdef DEBUG
//elem_print(n);
#endif
}

/**********************************
Expand Down Expand Up @@ -1213,9 +1207,7 @@ void elimass(elem *n)
/* Don't screw up assnod[]. */
n->Eoper = OPcomma;
n->Ety |= n->E2->Ety & (mTYconst | mTYvolatile | mTYimmutable | mTYshared
#if TARGET_SEGMENTED
| mTYfar
#endif
);
n->E1->Eoper = OPconst;
break;
Expand Down Expand Up @@ -1366,9 +1358,7 @@ STATIC void accumda(elem *n,vec_t DEAD, vec_t POSS)
case OPind:
case OPucall:
case OPucallns:
#if TARGET_SEGMENTED
case OPvp_fp:
#endif
accumda(n->E1,DEAD,POSS);
vec_subass(POSS,ambigref); // remove possibly refed
// assignments from list
Expand Down

0 comments on commit 2936b14

Please sign in to comment.