Skip to content

Commit

Permalink
integrate D2 pull 246
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Jul 13, 2011
1 parent eace03c commit d6960d5
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 171 deletions.
7 changes: 0 additions & 7 deletions src/backend/blockopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ STATIC elem * assignparams(elem **pe,int *psi,elem **pe2);
STATIC void emptyloops();
int el_anyframeptr(elem *e);

#if TX86
unsigned numblks; // number of basic blocks in current function
block *startblock; /* beginning block of function */
/* (can have no predecessors) */
Expand All @@ -63,8 +62,6 @@ unsigned dfotop; /* # of items in dfo[] */
block *curblock; /* current block being read in */
block *block_last; // last block read in

#endif

static block * block_freelist;

////////////////////////////
Expand Down Expand Up @@ -327,11 +324,7 @@ void block_optimizer_free(block *b)
vec_free(b->Bgen2);
vec_free(b->Bkill2);

#if TX86
memset(&b->_BLU,0,sizeof(b->_BLU));
#else
memset(&b->_BLU.BLCG,0,sizeof(b->_BLU.BLCG));
#endif
}

/****************************
Expand Down
4 changes: 3 additions & 1 deletion src/backend/cc.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,17 +220,19 @@ typedef struct Srcpos
#define srcpos_sfile(p) (**(p).Sfilptr)
#define srcpos_name(p) (srcpos_sfile(p).SFname)
#endif
#endif
#if MARS
const char *Sfilename;
#define srcpos_name(p) ((p).SFname)
#endif
#endif
#if M_UNIX
short Sfilnum; // file number
#endif
#if SOURCE_OFFSETS
unsigned long Sfiloff; // byte offset
#endif

void print(const char *func);
} Srcpos;

#ifndef TOKEN_H
Expand Down
84 changes: 0 additions & 84 deletions src/backend/cgelem.c
Original file line number Diff line number Diff line change
Expand Up @@ -828,13 +828,8 @@ STATIC elem * eladd(elem *e)
else if (e2->Eoper == OPneg)
{ e->E2 = el_selecte1(e2);
e->Eoper = OPmin;
#if TX86
again = 1;
return e;
#else
return elmin(e);
//return optelem(e,TRUE);
#endif
}
/* Replace (-v + e) with (e + -v) */
else if (e1->Eoper == OPneg && OTleaf(e1->E1->Eoper))
Expand Down Expand Up @@ -880,27 +875,17 @@ STATIC elem * eladd(elem *e)
}
#endif
}
#if TX86
again = 1;
return e;
#else
goto L1;
//return optelem(e,TRUE);
#endif
}
/* Replace (e + e) with (e * 2) */
else if (el_match(e1,e2) && !el_sideeffect(e1) && !tyfloating(e->Ety))
{
e->Eoper = OPmul;
el_free(e2);
e->E2 = el_long(e->Ety,2);
#if TX86
again = 1;
return e;
#else
return elmul(e);
//return optelem(e,TRUE);
#endif
}
// Replace ((e11 + c) + e2) with ((e11 + e2) + c)
if (e1->Eoper == OPadd && e1->E2->Eoper == OPconst &&
Expand Down Expand Up @@ -979,12 +964,8 @@ STATIC elem * elmul(elem *e)
e1->Eoper = OPmul;
e->E2 = el_bin(OPmul,tym,e1->E2,e2);
e1->E2 = el_copytree(e2);
#if TX86
again = 1;
return e;
#else
return eladd(e);
#endif
}

// ((e << c1) * c2) => e * ((1 << c1) * c2)
Expand Down Expand Up @@ -1069,43 +1050,18 @@ STATIC elem * elmin(elem *e)

/* Convert subtraction of long pointers to subtraction of integers */
if (tyfv(e2->Ety) && tyfv(e1->Ety))
#if TX86
{ e->E1 = el_una(OPlngsht,tym,e1);
e->E2 = el_una(OPlngsht,tym,e2);
#if TX86
return optelem(e,TRUE);
#else
goto L1;
//return optelem(e,TRUE);
#endif
}
#else
{
e->E1->Ety = TYlong;
e->E2->Ety = TYlong;
e->Ety = TYlong;
#if TX86
return optelem(e,TRUE);
#else
goto L1;
//return optelem(e,TRUE);
#endif
}
#endif


/* Replace (0 - e2) with (-e2) */
if (cnst(e1) && !boolres(e1))
{ el_free(e1);
e->E1 = e2;
e->E2 = NULL;
e->Eoper = OPneg;
#if TX86
return optelem(e,TRUE);
#else
return elneg(e);
//return optelem(e,TRUE);
#endif
}

/* Replace (e - e) with (0) */
Expand All @@ -1130,12 +1086,7 @@ STATIC elem * elmin(elem *e)
tmp = e1->E2;
e1->E2 = e2->E1;
e2->E1 = tmp;
#if TX86
return optelem(e,TRUE);
#else
return eladd(e);
//return optelem(e,TRUE);
#endif
}
}

Expand Down Expand Up @@ -1476,12 +1427,7 @@ STATIC elem * elnot(elem *e)
e1->Ety = e->Ety;
e1->E1 = e1->E2; // b
e1->E2 = NULL;
#if TX86
e = optelem(e,TRUE);
#else
e = elcomma(e);
//e = optelem(e,TRUE);
#endif
break;
}
return e;
Expand Down Expand Up @@ -1758,9 +1704,7 @@ STATIC elem * elcomma(elem *e)
)
{
/* ((a = b),(a || c)) => ((a = b) || c) */
#if TX86
e1->Ety = e2->E1->Ety;
#endif
e->E1 = e2->E1;
e2->E1 = e1;
e = el_selecte2(e);
Expand Down Expand Up @@ -2122,12 +2066,7 @@ STATIC elem * elandand(elem *e)
else /* e1 && (x,0) => e1 , (x,0) */
{ if (e2 == e->E2)
{ e->Eoper = OPcomma;
#if TX86
goto L3;
#else
return elcomma(e);
//goto L3;
#endif
}
}
}
Expand Down Expand Up @@ -2269,14 +2208,8 @@ STATIC elem * elind(elem *e)
e->Ety = tym;
e->E2 = el_una(OPind,tym,e->E2);
e->E2->ET = t;
#if TX86
again = 1;
return e;
#else
e = elcomma(e);
//e = optelem(e,TRUE);
#endif
break;
}
return e;
}
Expand Down Expand Up @@ -3082,26 +3015,16 @@ STATIC elem * elcmp(elem *e)
e1->Ety = TYptrdiff;
e2->Eoper = OPconst;
e2->Ety = TYptrdiff;
#if TX86
return optelem(e,TRUE);
#else
goto L1;
//return optelem(e,TRUE);
#endif
}

// Convert comparison of long pointers to comparison of integers
if ((op == OPlt || op == OPle || op == OPgt || op == OPge) &&
tyfv(e2->Ety) && tyfv(e1->Ety))
{
#if TX86
e->E1 = el_una(OPlngsht,e->Ety,e1);
e->E2 = el_una(OPlngsht,e->Ety,e2);
return optelem(e,TRUE);
#else
e->E1->Ety = e->Ety;
e->E2->Ety = e->Ety;
#endif
}

// Convert ((e & 1) == 1) => (e & 1)
Expand Down Expand Up @@ -3336,12 +3259,7 @@ STATIC elem * elbool(elem *e)
i = boolres(e1) != 0;
e->Eoper = OPcomma;
e->E2 = el_int(e->Ety,i);
#if TX86
e = optelem(e,TRUE);
#else
e = elcomma(e);
//e = optelem(e,TRUE);
#endif
}
}
return e;
Expand Down Expand Up @@ -3427,9 +3345,7 @@ STATIC elem * ellngsht(elem *e)
/* 68000 - preclude using An */
e1->EV.sp.Vsym->Sflags |= GTbyte;
}
#if TX86
else
#endif
e1->Ety = ty;
e = el_selecte1(e);
break;
Expand Down
6 changes: 1 addition & 5 deletions src/backend/cgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,11 +463,7 @@ code *genlinnum(code *c,Srcpos srcpos)
{ code cs;

#if 0
#if MARS
printf("genlinnum(Sfilename = %p, Slinnum = %u)\n", srcpos.Sfilename, srcpos.Slinnum);
#else
printf("genlinnum(Sfilptr = %p, Slinnum = %u)\n", srcpos.Sfilptr, srcpos.Slinnum);
#endif
srcpos.print("genlinnum");
#endif
cs.Iop = ESCAPE | ESClinnum;
cs.Iflags = 0;
Expand Down
15 changes: 4 additions & 11 deletions src/backend/cgobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -801,19 +801,12 @@ void objlinnum(Srcpos srcpos,targ_size_t offset)
unsigned linnum = srcpos.Slinnum;

#if 0
#if MARS
printf("objlinnum(cseg=%d, filename=%s linnum=%u, offset=x%lx)\n",
cseg,srcpos.Sfilename ? srcpos.Sfilename : "null",linnum,offset);
#else
printf("objlinnum(cseg=%d, filptr=%p linnum=%u, offset=x%lx)\n",
cseg,srcpos.Sfilptr ? *srcpos.Sfilptr : 0,linnum,offset);
if (srcpos.Sfilptr)
{
Sfile *sf = *srcpos.Sfilptr;
printf("filename = %s\n", sf ? sf->SFname : "null");
}
#if MARS || SCPP
printf("objlinnum(cseg=%d, offset=0x%lx) ", cseg, offset);
#endif
srcpos.print("");
#endif

char linos2 = config.exe == EX_OS2 && cseg >= 0;

#if MARS
Expand Down
14 changes: 1 addition & 13 deletions src/backend/el.c
Original file line number Diff line number Diff line change
Expand Up @@ -2947,19 +2947,7 @@ void elem_print(elem *e)
elem_debug(e);
if (configv.addlinenumbers)
{
#if TX86
#if MARS
dbg_printf("fil=%p lin=%u ",e->Esrcpos.Sfilename,e->Esrcpos.Slinnum);
#elif SCPP
dbg_printf("fil=%p lin=%u ",e->Esrcpos.Sfilptr,e->Esrcpos.Slinnum);
#endif
#else
dbg_printf("fil=%d lin=%u ",((struct ELEMsrcpos *)e)->Esrcpos.Sfilnum,
((struct ELEMsrcpos *)e)->Esrcpos.Slinnum);
#endif
#if SOURCE_OFFSETS
dbg_printf("off %d ",((struct ELEMsrcpos *)e)->Esrcpos.Sfiloff);
#endif
e->Esrcpos.print("elem_print");
}
if (!PARSER)
{ dbg_printf("cnt=%d ",e->Ecount);
Expand Down
27 changes: 7 additions & 20 deletions src/backend/elfobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -1244,38 +1244,25 @@ void obj_term()

void objlinnum(Srcpos srcpos, targ_size_t offset)
{
unsigned linnum = srcpos.Slinnum;
if (linnum == 0)
if (srcpos.Slinnum == 0)
return;

#if 0
#if MARS
printf("objlinnum(cseg=%d, filename=%s linnum=%u, offset=x%lx)\n",
cseg,srcpos.Sfilename ? srcpos.Sfilename : "null",linnum,offset);
#endif
#if SCPP
printf("objlinnum(cseg=%d, filptr=%p linnum=%u, offset=x%lx)\n",
cseg,srcpos.Sfilptr ? *srcpos.Sfilptr : 0,linnum,offset);
if (srcpos.Sfilptr)
{
Sfile *sf = *srcpos.Sfilptr;
printf("filename = %s\n", sf ? sf->SFname : "null");
}
#if MARS || SCPP
printf("objlinnum(cseg=%d, offset=0x%lx) ", cseg, offset);
#endif
srcpos.print("");
#endif

#if MARS
if (!srcpos.Sfilename)
return;
#endif
#if SCPP
Sfile *sf;
if (srcpos.Sfilptr)
{ sfile_debug(&srcpos_sfile(srcpos));
sf = *srcpos.Sfilptr;
}
else
if (!srcpos.Sfilptr)
return;
sfile_debug(&srcpos_sfile(srcpos));
Sfile *sf = *srcpos.Sfilptr;
#endif

size_t i;
Expand Down
Loading

0 comments on commit d6960d5

Please sign in to comment.