Skip to content

Commit

Permalink
merge D2 pull 455
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Nov 26, 2011
1 parent 4d1146b commit 29cd0c6
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 313 deletions.
6 changes: 1 addition & 5 deletions src/backend/el.c
Expand Up @@ -2949,11 +2949,7 @@ void elem_print(elem *e)
{
if (e->ET)
{ type_debug(e->ET);
if (tybasic(e->ET->Tty) == TYstruct
#if !TX86
&& (e->PEFflags & PEFstrsize)
#endif
)
if (tybasic(e->ET->Tty) == TYstruct)
dbg_printf("%d ", (int)type_size(e->ET));
WRTYxx(e->ET->Tty);
}
Expand Down
21 changes: 0 additions & 21 deletions src/backend/el.h
Expand Up @@ -57,15 +57,6 @@ struct elem
#define PEFaddrmem 0x40 // address of member
#define PEFdependent 0x80 // value-dependent
#define PEFmember 0x100 // was a class member access
#if !TX86
#define PEFdblldbl 2 // long double return from dbl func
#define PEFfltldbl 4 // long double return from flt func
#define PEFstrsize 8 // The structure size for this
// node of type TYstruct is
// not the same as type_size
// of the struct. This happens
// in C++ operator = generation
#endif
Symbol *Emember_; // if PEFmember, this is the member
#define Emember _EU._EP.Emember_
}_EP;
Expand All @@ -87,12 +78,6 @@ struct elem
#define NFLassign 8 // unambiguous assignment elem
#define NFLaecp 0x10 // AE or CP or VBE expression
#define NFLdelcse 0x40 // this is not the generating CSE
#if !TX86
#define NFLfcall 0x20 // flag that there has been a function call on RHS
// of an assignment of this LHS value hence do not
// propagate this assignment into a paramter list
// (see glocal.c)
#endif
#define NFLtouns 0x80 // relational operator was changed from signed to unsigned
#if MARS
unsigned char Ejty_; // original Jupiter/Mars type
Expand Down Expand Up @@ -147,11 +132,7 @@ elem *el_params(void **args, int length);
elem *el_combines(void **args, int length);
int el_nparams(elem *e);
elem_p el_pair(tym_t, elem_p, elem_p);
#if TX86 || DEBUG
void el_copy(elem_p ,elem_p);
#else
#define el_copy(to,from) {*(to) = *(from);}
#endif
elem_p el_alloctmp(tym_t);
elem_p el_selecte1(elem_p);
elem_p el_selecte2(elem_p);
Expand All @@ -160,9 +141,7 @@ void el_replace_sym(elem *e,symbol *s1,symbol *s2);
elem_p el_scancommas(elem_p);
int el_countCommas(elem_p);
int el_sideeffect(elem_p);
#if TX86
int el_depends(elem *ea,elem *eb);
#endif
#if LONGLONG
targ_llong el_tolongt(elem_p);
targ_llong el_tolong(elem_p);
Expand Down
18 changes: 1 addition & 17 deletions src/backend/gdag.c
Expand Up @@ -376,7 +376,6 @@ STATIC elem * delcse(elem **pe)
assert(e->Ecount != 0);
if (EOP(e))
{
#if 1 || !TX86
if (e->E1->Ecount == 0xFF-1)
{ elem *ereplace;
ereplace = el_calloc();
Expand All @@ -385,7 +384,6 @@ STATIC elem * delcse(elem **pe)
ereplace->Ecount = 0;
}
else
#endif
{
e->E1->Ecount++;
#ifdef DEBUG
Expand All @@ -394,7 +392,6 @@ STATIC elem * delcse(elem **pe)
}
if (EBIN(e))
{
#if 1 || !TX86
if (e->E2->Ecount == 0xFF-1)
{ elem *ereplace;
ereplace = el_calloc();
Expand All @@ -403,7 +400,6 @@ STATIC elem * delcse(elem **pe)
ereplace->Ecount = 0;
}
else
#endif
{ e->E2->Ecount++;
#ifdef DEBUG
assert(e->E2->Ecount != 0);
Expand Down Expand Up @@ -505,24 +501,12 @@ L1: e = *pe;
}

// Remove *e1 where it's a double
if (e->Ecount &&
#if 1
tyfloating(e->Ety)
#else
// Why not TYfloat? Same issue in cgcs.c
(tybasic(e->Ety) == TYdouble ||
tybasic(e->Ety) == TYdouble_alias ||
tybasic(e->Ety) == TYldouble)
#endif
)
if (e->Ecount && tyfloating(e->Ety))
e = delcse(pe);

}
#if TX86
// This CSE is too easy to regenerate
else if (op == OPu16_32 && !I32 && e->Ecount)
e = delcse(pe);
#endif
}
else if (OTbinary(op))
{
Expand Down
29 changes: 2 additions & 27 deletions src/backend/gflow.c
Expand Up @@ -137,11 +137,8 @@ void flowrd()
STATIC void rdgenkill()
{ register unsigned i,deftopsave;

#if TX86
util_free(defnod); /* free existing junk */
#else /* might be from previous memory pool */
MEM_BEF_FREE(defnod); /* free existing junk */
#endif

defnod = NULL;

/* Compute number of definition elems. */
Expand All @@ -158,11 +155,7 @@ STATIC void rdgenkill()
/* The elems are in dfo order. */
/* defnod[]s consist of a elem pointer and a pointer */
/* to the enclosing block. */
#if TX86
defnod = (dn *) util_calloc(sizeof(dn),deftop);
#else
defnod = (dn *)MEM_BEF_CALLOC(sizeof(dn) * deftop);
#endif
deftopsave = deftop;
deftop = 0;
for (i = 0; i < dfotop; i++)
Expand Down Expand Up @@ -478,11 +471,8 @@ STATIC void aecpgenkill()
{ register unsigned i;
unsigned exptopsave;

#if TX86
util_free(expnod); /* dump any existing one */
#else /* might be from previous memory pool */
MEM_BEF_FREE(expnod); /* dump any existing one */
#endif

expnod = NULL;

/* Compute number of expressions */
Expand All @@ -501,17 +491,10 @@ STATIC void aecpgenkill()
/* (The elems are in order. Also, these expressions must not */
/* have any side effects, and possibly should not be machine */
/* dependent primitive addressing modes.) */
#if TX86
expnod = (elem **) util_calloc(sizeof(elem *),exptop);
util_free(expblk);
expblk = (flowxx == VBE)
? (block **) util_calloc(sizeof(block *),exptop) : NULL;
#else
expnod = (elem **) MEM_BEF_CALLOC(sizeof(elem *) * exptop);
MEM_BEF_FREE(expblk);
expblk = (flowxx == VBE)
? (block **) MEM_BEF_CALLOC(sizeof(block *) * exptop) : NULL;
#endif

exptopsave = exptop;
exptop = 1;
Expand Down Expand Up @@ -999,15 +982,13 @@ STATIC void accumaecpx(elem *n)
vec_clear(GEN); // GEN nothing
return;

#if TX86
case OPeq:
case OPstreq:
accumaecpx(n->E2);
case OPnegass:
accumaecpx(n->E1);
t = Elvalue(n);
break;
#endif

case OPvp_fp:
case OPcvp_fp: // if vptr access
Expand All @@ -1018,16 +999,10 @@ STATIC void accumaecpx(elem *n)
default:
if (OTunary(op))
{
#if TX86
case OPind: // most common unary operator
accumaecpx(n->E1);
#ifdef DEBUG
assert(!OTassign(op));
#endif
#else
accumaecpx(n->E1);
if (OTassign(op)) // if assignment operator
t = Elvalue(n);
#endif
}
else if (OTbinary(op))
Expand Down
47 changes: 1 addition & 46 deletions src/backend/glocal.c
Expand Up @@ -64,10 +64,6 @@ STATIC void local_ambigdef(void);
STATIC void local_symref(symbol *s);
STATIC void local_symdef(symbol *s);

#if !TX86
static bool fcall_seen = FALSE;
#endif

///////////////////////////////
// This optimization attempts to replace sequences like:
// x = func();
Expand Down Expand Up @@ -167,12 +163,7 @@ STATIC void local_exp(elem *e,int goal)
{ s = e1->EV.sp.Vsym;
if (s->Sflags & SFLunambig)
{ local_symdef(s);
#if TX86
if (!goal)
#else
if (!(goal || fcall_seen))
// do not localize if there is a function call on the rhs
#endif
local_ins(e);
}
else
Expand All @@ -186,9 +177,6 @@ STATIC void local_exp(elem *e,int goal)
local_exp(e1->E2,1);
local_ambigdef();
}
#if !TX86
e1->Nflags |= (e->E2->Nflags & NFLfcall);
#endif
break;

case OPpostinc:
Expand Down Expand Up @@ -295,7 +283,6 @@ STATIC void local_exp(elem *e,int goal)
local_exp(e->E2,1);
goto Lrd;

#if TX86
case OPstrcmp:
case OPmemcmp:
case OPbt:
Expand Down Expand Up @@ -324,22 +311,6 @@ STATIC void local_exp(elem *e,int goal)
local_exp(e->E1,1);
local_exp(e->E2,1);
goto Lrd;
#else
case OPcall:
case OPcallns:
{
local_exp(e->E2,1);
}
case OPstrctor:
case OPucall:
case OPucallns:
fcall_seen = FALSE;
local_exp(e->E1,1);

e->Nflags |= NFLfcall;
fcall_seen = TRUE;

#endif
case OPasm:
Lrd:
local_remove(LFfloat | LFambigref | LFambigdef);
Expand Down Expand Up @@ -378,11 +349,7 @@ STATIC void local_exp(elem *e,int goal)

em = loctab[u].e;
if (em->E1->EV.sp.Vsym == s &&
(em->Eoper == OPeq || em->Eoper == OPstreq)
#if !TX86
&& !(em->Nflags & NFLfcall)
#endif
)
(em->Eoper == OPeq || em->Eoper == OPstreq))
{
if (tysize(em->Ety) == tysize(e->Ety) &&
em->E1->EV.sp.Voffset == e->EV.sp.Voffset &&
Expand Down Expand Up @@ -468,18 +435,6 @@ STATIC void local_exp(elem *e,int goal)
}
break;
} // end of switch (e->Eoper)

#if !TX86
if (EUNA(e))
{
e->Nflags |= (e->E1->Nflags & NFLfcall);
}

if (EBIN(e))
{
e->Nflags |= ((e->E1->Nflags | e->E2->Nflags) & NFLfcall);
}
#endif
}

///////////////////////////////////
Expand Down

0 comments on commit 29cd0c6

Please sign in to comment.