Skip to content

Commit

Permalink
revert most of pull 165
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Jun 28, 2011
1 parent e5b13f5 commit 31cee7a
Show file tree
Hide file tree
Showing 36 changed files with 199 additions and 79 deletions.
2 changes: 2 additions & 0 deletions src/backend/cgcod.c
Original file line number Diff line number Diff line change
Expand Up @@ -1735,6 +1735,8 @@ STATIC void resetEcomsub(elem *e)

int isregvar(elem *e,regm_t *pregm,unsigned *preg)
{ symbol *s;
unsigned u;
regm_t m;
regm_t regm;
unsigned reg;

Expand Down
27 changes: 20 additions & 7 deletions src/backend/cgelem.c
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,8 @@ STATIC void eltonear(elem **pe)
*/

STATIC elem * elstrcpy(elem *e)
{
{ tym_t ty;

elem_debug(e);
switch (e->E2->Eoper)
{
Expand Down Expand Up @@ -1904,7 +1905,8 @@ STATIC elem * elcomma(elem *e)
;
if ((OTopeq(e2->Eoper)) &&
el_match(e1->E1,e2->E1))
{
{ elem *ex;

e->E1 = el_long(TYint,0);
e1->Eoper = opeqtoop(e1op);
e2->E2 = el_bin(opeqtoop(e2->Eoper),e2->Ety,e1,e2->E2);
Expand Down Expand Up @@ -1936,6 +1938,8 @@ STATIC elem * elremquo(elem *e)

STATIC elem * elmod(elem *e)
{
elem *e1;
elem *e2;
tym_t tym;

tym = e->E1->Ety;
Expand Down Expand Up @@ -2542,7 +2546,8 @@ STATIC elem * eladdr(elem *e)
case OPstreq:
// & (v1 = e) => ((v1 = e), &v1)
if (e1->E1->Eoper == OPvar)
{
{ elem *ex;

e->Eoper = OPcomma;
e->E2 = el_una(OPaddr,tym,el_copytree(e1->E1));
goto L1;
Expand Down Expand Up @@ -2781,7 +2786,10 @@ CEXTERN elem * elstruct(elem *e)
*/

STATIC elem * eleq(elem *e)
{ elem *e1;
{ targ_ullong m;
unsigned t,w,b;
unsigned sz;
elem *l,*l2,*r,*r2,*e1,*eres;
int wantres;
tym_t tyl;

Expand Down Expand Up @@ -2876,6 +2884,7 @@ STATIC elem * eleq(elem *e)
&& op2 != OPdiv && op2 != OPmod
)
{ tym_t ty;
int op3;

// Replace (e1 = e1 op e) with (e1 op= e)
if (el_match(e1,e2->E1))
Expand Down Expand Up @@ -2917,7 +2926,8 @@ STATIC elem * eleq(elem *e)
}

if (op2 == OPneg && el_match(e1,e2->E1) && !el_sideeffect(e1))
{
{ int offset;

tyl = tybasic(e1->Ety);
Ldef:
// Replace (i = -i) with (negass i)
Expand Down Expand Up @@ -3098,8 +3108,11 @@ STATIC elem * elnegass(elem *e)
*/

STATIC elem * elopass(elem *e)
{
elem *e1;
{ targ_llong m;
unsigned w,b,op;
tym_t t;
tym_t tyl;
elem *l,*r,*e1,*l2,*l3,*op2,*eres;
int wantres;

wantres = expgoal;
Expand Down
1 change: 1 addition & 0 deletions src/backend/cod1.c
Original file line number Diff line number Diff line change
Expand Up @@ -3155,6 +3155,7 @@ code *params(elem *e,unsigned stackalign)
elem *e1;
elem *e2;
symbol *s;
int fl;

//printf("params(e = %p, stackalign = %d)\n", e, stackalign);
cp = NULL;
Expand Down
20 changes: 13 additions & 7 deletions src/backend/cod2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1524,6 +1524,7 @@ code *cdcom(elem *e,regm_t *pretregs)
tym = tybasic(e->Ety);
sz = tysize[tym];
unsigned rex = (I64 && sz == 8) ? REX_W : 0;
unsigned grex = rex << 16;
possregs = (sz == 1) ? BYTEREGS : allregs;
retregs = *pretregs & possregs;
if (retregs == 0)
Expand Down Expand Up @@ -1560,10 +1561,11 @@ code *cdcom(elem *e,regm_t *pretregs)
*/

code *cdbswap(elem *e,regm_t *pretregs)
{ unsigned reg;
{ unsigned reg,op;
regm_t retregs;
code *c,*c1,*cg;
tym_t tym;
int sz;

if (*pretregs == 0)
return codelem(e->E1,pretregs,FALSE);
Expand Down Expand Up @@ -1591,6 +1593,7 @@ code *cdcond(elem *e,regm_t *pretregs)
code *cc,*c,*c1,*cnop1,*c2,*cnop2;
con_t regconold,regconsave;
unsigned stackpushold,stackpushsave;
int ehindexold,ehindexsave;
unsigned jop;
unsigned op1;
unsigned sz1;
Expand Down Expand Up @@ -2057,7 +2060,7 @@ code *cdshift(elem *e,regm_t *pretregs)
!(*pretregs & mPSW) &&
config.flags4 & CFG4speed
)
{
{ Symbol *s1 = e1->EV.sp.Vsym;
unsigned reg;
regm_t regm;
code cs;
Expand Down Expand Up @@ -2410,7 +2413,7 @@ code *cdind(elem *e,regm_t *pretregs)
{ code *c,*ce,cs;
tym_t tym;
regm_t idxregs,retregs;
unsigned reg,byte;
unsigned reg,nreg,byte;
elem *e1;
unsigned sz;

Expand Down Expand Up @@ -2765,7 +2768,7 @@ code *cdstrlen( elem *e, regm_t *pretregs)
*/

code *cdstrcmp( elem *e, regm_t *pretregs)
{ code *c1,*c2,*c3,*c4;
{ code *c1,*c1a,*c2,*c3,*c4;
char need_DS;
int segreg;

Expand Down Expand Up @@ -3093,7 +3096,7 @@ code *cdstrcpy(elem *e,regm_t *pretregs)
*/

code *cdmemcpy(elem *e,regm_t *pretregs)
{ code *c1,*c2,*c3;
{ code *c1,*c2,*c3,*c4;
regm_t retregs1;
regm_t retregs2;
regm_t retregs3;
Expand Down Expand Up @@ -3235,13 +3238,14 @@ code *cdmemcpy(elem *e,regm_t *pretregs)

#if 1
code *cdmemset(elem *e,regm_t *pretregs)
{ code *c1,*c2,*c3 = NULL;
{ code *c1,*c2,*c3 = NULL,*c4;
regm_t retregs1;
regm_t retregs2;
regm_t retregs3;
unsigned reg,vreg;
tym_t ty1;
elem *e2,*e1;
int segreg;
unsigned remainder;
targ_uns numbytes,numwords;
int op;
Expand Down Expand Up @@ -4139,6 +4143,7 @@ code *cdabs( elem *e, regm_t *pretregs)
cg = getregs(retregs); /* retregs will be destroyed */
if (sz <= REGSIZE)
{ unsigned reg;
code *c2;

/* cwd
xor AX,DX
Expand Down Expand Up @@ -4191,13 +4196,14 @@ code *cdabs( elem *e, regm_t *pretregs)
*/

code *cdpost(elem *e,regm_t *pretregs)
{ code cs,*c1,*c2,*c3,*c4,*c5;
{ code cs,*c1,*c2,*c3,*c4,*c5,*c6;
unsigned reg,op,byte;
tym_t tyml;
regm_t retregs,possregs,idxregs;
targ_int n;
elem *e2;
int sz;
int stackpushsave;

//printf("cdpost(pretregs = %s)\n", regm_str(*pretregs));
retregs = *pretregs;
Expand Down
16 changes: 10 additions & 6 deletions src/backend/cod3.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ void cod3_align()
void doswitch(block *b)
{ code *cc,*c,*ce;
regm_t retregs;
unsigned ncases,n,reg,reg2;
unsigned ncases,n,reg,reg2,rm;
targ_llong vmax,vmin,val;
targ_llong *p;
list_t bl;
Expand Down Expand Up @@ -908,7 +908,7 @@ int jmpopcode(elem *e)
void cod3_ptrchk(code **pc,code *pcs,regm_t keepmsk)
{ code *c;
code *cs2;
unsigned char rm;
unsigned char rm,sib;
unsigned reg;
unsigned flagsave;
unsigned opsave;
Expand Down Expand Up @@ -1931,6 +1931,7 @@ code *prolog()
*/
targ_size_t voff = Aoff + BPoff + sv->Soffset; // EBP offset of start of sv
const int vregnum = 6;
const unsigned vsize = vregnum * 8 + 8 * 16;
code *cv = CNIL;

static unsigned char regs[vregnum] = { DI,SI,DX,CX,R8,R9 };
Expand Down Expand Up @@ -3121,6 +3122,7 @@ void pinholeopt(code *c,block *b)
unsigned char ins;
int usespace;
int useopsize;
int space;
block *bn;

#ifdef DEBUG
Expand Down Expand Up @@ -4056,7 +4058,7 @@ STATIC void cod3_flush()

unsigned codout(code *c)
{ unsigned op;
unsigned char rm;
unsigned char rm,mod;
unsigned char ins;
code *cn;
unsigned flags;
Expand Down Expand Up @@ -4457,9 +4459,10 @@ unsigned codout(code *c)


STATIC void do64bit(enum FL fl,union evc *uev,int flags)
{
{ char *p;
symbol *s;
targ_size_t ad;
long tmp;

assert(I64);
switch (fl)
Expand Down Expand Up @@ -4542,9 +4545,10 @@ STATIC void do64bit(enum FL fl,union evc *uev,int flags)


STATIC void do32bit(enum FL fl,union evc *uev,int flags, targ_size_t val)
{
{ char *p;
symbol *s;
targ_size_t ad;
long tmp;

//printf("do32bit(flags = x%x)\n", flags);
switch (fl)
Expand Down Expand Up @@ -4651,7 +4655,7 @@ STATIC void do32bit(enum FL fl,union evc *uev,int flags, targ_size_t val)


STATIC void do16bit(enum FL fl,union evc *uev,int flags)
{
{ char *p;
symbol *s;
targ_size_t ad;

Expand Down
2 changes: 2 additions & 0 deletions src/backend/evalu8.c
Original file line number Diff line number Diff line change
Expand Up @@ -2113,6 +2113,8 @@ elem * evalu8(elem *e)
return e;
}
#if TX86
int flags;

if (!ignore_exceptions &&
(config.flags4 & CFG4fastfloat) == 0 &&
#if __OpenBSD__
Expand Down
25 changes: 13 additions & 12 deletions src/cast.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ Expression *Expression::implicitCastTo(Scope *sc, Type *t)

MATCH match = implicitConvTo(t);
if (match)
{
#if DMDV1
TY tyfrom = type->toBasetype()->ty;
{ TY tyfrom = type->toBasetype()->ty;
TY tyto = t->toBasetype()->ty;
#if DMDV1
if (global.params.warnings &&
Type::impcnvWarn[tyfrom][tyto] &&
op != TOKint64)
Expand Down Expand Up @@ -443,7 +442,8 @@ MATCH StructLiteralExp::implicitConvTo(Type *t)
#endif

MATCH StringExp::implicitConvTo(Type *t)
{
{ MATCH m;

#if 0
printf("StringExp::implicitConvTo(this=%s, committed=%d, type=%s, t=%s)\n",
toChars(), committed, type->toChars(), t->toChars());
Expand Down Expand Up @@ -508,7 +508,6 @@ MATCH StringExp::implicitConvTo(Type *t)
}
return Expression::implicitConvTo(t);
#if 0
MATCH m;
m = (MATCH)type->implicitConvTo(t);
if (m)
{
Expand Down Expand Up @@ -685,6 +684,8 @@ MATCH DelegateExp::implicitConvTo(Type *t)
if (result == MATCHnomatch)
{
// Look for pointers to functions where the functions are overloaded.
FuncDeclaration *f;

t = t->toBasetype();
if (type->ty == Tdelegate && type->nextOf()->ty == Tfunction &&
t->ty == Tdelegate && t->nextOf()->ty == Tfunction)
Expand Down Expand Up @@ -2039,14 +2040,14 @@ IntRange AddExp::getIntRange()
{
IntRange ir1 = e1->getIntRange();
IntRange ir2 = e2->getIntRange();
return IntRange(ir1.imin + ir2.imin, ir1.imax + ir2.imax).cast(type) DUMP;
return IntRange(ir1.imin + ir2.imin, ir1.imax + ir2.imax).cast(type) DUMP;
}

IntRange MinExp::getIntRange()
{
IntRange ir1 = e1->getIntRange();
IntRange ir2 = e2->getIntRange();
return IntRange(ir1.imin - ir2.imax, ir1.imax - ir2.imin).cast(type) DUMP;
return IntRange(ir1.imin - ir2.imax, ir1.imax - ir2.imin).cast(type) DUMP;
}

IntRange DivExp::getIntRange()
Expand Down Expand Up @@ -2087,18 +2088,18 @@ IntRange ModExp::getIntRange()
{
IntRange irNum = e1->getIntRange();
IntRange irDen = e2->getIntRange().absNeg();

/*
due to the rules of D (C)'s % operator, we need to consider the cases
separately in different range of signs.
case 1. [500, 1700] % [7, 23] (numerator is always positive)
= [0, 22]
case 2. [-500, 1700] % [7, 23] (numerator can be negative)
= [-22, 22]
case 3. [-1700, -500] % [7, 23] (numerator is always negative)
= [-22, 0]
the number 22 is the maximum absolute value in the denomator's range. We
don't care about divide by zero.
*/
Expand All @@ -2110,7 +2111,7 @@ IntRange ModExp::getIntRange()
++ irDen.imin;
irDen.imax = -irDen.imin;

if (!irNum.imin.negative)
if (!irNum.imin.negative)
irNum.imin.value = 0;
else if (irNum.imin < irDen.imin)
irNum.imin = irDen.imin;
Expand All @@ -2135,7 +2136,7 @@ static IntRange unsignedBitwiseAnd(const IntRange& a, const IntRange& b)
// the DiffMasks stores the mask of bits which are variable in the range.
uinteger_t aDiffMask = getMask(a.imin.value ^ a.imax.value);
uinteger_t bDiffMask = getMask(b.imin.value ^ b.imax.value);
// Since '&' computes the digitwise-minimum, the we could set all varying
// Since '&' computes the digitwise-minimum, the we could set all varying
// digits to 0 to get a lower bound, and set all varying digits to 1 to get
// an upper bound.
IntRange result;
Expand Down
1 change: 1 addition & 0 deletions src/class.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ Dsymbol *ClassDeclaration::syntaxCopy(Dsymbol *s)

void ClassDeclaration::semantic(Scope *sc)
{ int i;
unsigned offset;

//printf("ClassDeclaration::semantic(%s), type = %p, sizeok = %d, this = %p\n", toChars(), type, sizeok, this);
//printf("\tparent = %p, '%s'\n", sc->parent, sc->parent ? sc->parent->toChars() : "");
Expand Down
Loading

0 comments on commit 31cee7a

Please sign in to comment.