Skip to content

Commit

Permalink
Merge pull request #4774 from WalterBright/mergeFL
Browse files Browse the repository at this point in the history
backend: merge FL for all platforms
  • Loading branch information
ibuclaw committed Jun 26, 2015
2 parents 1ea328e + 588d4f6 commit d34aa50
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 118 deletions.
17 changes: 8 additions & 9 deletions src/backend/cc.h
Original file line number Diff line number Diff line change
Expand Up @@ -1397,6 +1397,7 @@ struct PARAM

enum FL
{
// Change this, update debug.c too
FLunde,
FLconst, // numerical constant
FLoper, // operator node
Expand All @@ -1421,13 +1422,13 @@ enum FL
FLdtor, // destructed object
FLregsave, // ref to saved register on stack, int contains offset
FLasm, // (code) an ASM code
#if TX86

FLndp, // saved 8087 register
#endif
#if TARGET_SEGMENTED

// Segmented systems
FLfardata, // ref to far data segment
FLcsdata, // ref to code segment variable
#endif

FLlocalsize, // replaced with # of locals in the stack frame
FLtlsdata, // thread local storage
FLbprel, // ref to variable at fixed offset from frame pointer
Expand All @@ -1436,13 +1437,11 @@ enum FL
FLallocatmp, // temp for built-in alloca()
FLstack, // offset from ESP rather than EBP
FLdsymbol, // it's a Dsymbol
#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
// Change this, update debug.c too

// Global Offset Table
FLgot, // global offset table entry outside this object file
FLgotoff, // global offset table entry inside this object file
//FLoncedata, // link once data
//FLoncecode, // link once code
#endif

FLMAX
};

Expand Down
4 changes: 0 additions & 4 deletions src/backend/cgelem.c
Original file line number Diff line number Diff line change
Expand Up @@ -785,10 +785,8 @@ STATIC elem * eladd(elem *e, goal_t goal)
e2 = e->E2;
if (e2->Eoper == OPconst)
{
#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
if (e1->Eoper == OPrelconst && e1->EV.sp.Vsym->Sfl == FLgot)
goto ret;
#endif
if (e1->Eoper == OPrelconst /* if (&v) + c */
|| e1->Eoper == OPstring
)
Expand All @@ -801,10 +799,8 @@ STATIC elem * eladd(elem *e, goal_t goal)
}
else if (e1->Eoper == OPconst)
{
#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
if (e2->Eoper == OPrelconst && e2->EV.sp.Vsym->Sfl == FLgot)
goto ret;
#endif
if (e2->Eoper == OPrelconst /* if c + (&v) */
|| e2->Eoper == OPstring
)
Expand Down
59 changes: 1 addition & 58 deletions src/backend/cod1.c
Original file line number Diff line number Diff line change
Expand Up @@ -801,34 +801,6 @@ code *getlvalue(code *pcs,elem *e,regm_t keepmsk)
c = CNIL;
switch (fl)
{
#if 0 && TARGET_LINUX
case FLgot:
case FLgotoff:
gotref = 1;
pcs->IEVsym1 = s;
pcs->IEVoffset1 = e->EV.sp.Voffset;
if (e->Eoper == OPvar && fl == FLgot)
{
code *c1;
unsigned saveop = pcs->Iop;
idxregs = allregs & ~keepmsk; // get a scratch register
c = allocreg(&idxregs,&reg,TYptr);
pcs->Irm = modregrm(2,reg,BX); // BX has GOT
pcs->Isib = 0;
//pcs->Iflags |= CFvolatile;
pcs->Iop = 0x8B;
c = gen(c,pcs); // MOV reg,disp[EBX]
pcs->Irm = modregrm(0,0,reg);
pcs->IEVoffset1 = 0;
pcs->Iop = saveop;
}
else
{
pcs->Irm = modregrm(2,0,BX); // disp[EBX] is addr
pcs->Isib = 0;
}
break;
#endif
case FLoper:
#ifdef DEBUG
if (debugw) printf("getlvalue(e = %p, keepmsk = %s)\n", e, regm_str(keepmsk));
Expand Down Expand Up @@ -868,9 +840,7 @@ code *getlvalue(code *pcs,elem *e,regm_t keepmsk)
f = FLconst;
if (e1isadd &&
((e12->Eoper == OPrelconst
#if TARGET_SEGMENTED
&& (f = el_fl(e12)) != FLfardata
#endif
) ||
(e12->Eoper == OPconst && !I16 && !e1->Ecount && (!I64 || el_signx32(e12)))) &&
!(I64 && (config.flags3 & CFG3pic || config.exe == EX_WIN64)) &&
Expand Down Expand Up @@ -917,9 +887,6 @@ code *getlvalue(code *pcs,elem *e,regm_t keepmsk)
{
regm_t scratchm;

#if 0 && TARGET_LINUX
assert(f != FLgot && f != FLgotoff);
#endif
char ssflags = ssindex_array[ssi].ssflags;
if (ssflags & SSFLnobp && stackfl[f])
goto L6;
Expand Down Expand Up @@ -998,21 +965,6 @@ code *getlvalue(code *pcs,elem *e,regm_t keepmsk)
/* Load index register with result of e11 */
c = scodelem(e11,&idxregs,keepmsk,TRUE);
setaddrmode(pcs, idxregs);
#if 0 && TARGET_LINUX
if (e12->EV.sp.Vsym->Sfl == FLgot || e12->EV.sp.Vsym->Sfl == FLgotoff)
{
gotref = 1;
#if 1
reg = findreg(idxregs & (ALLREGS | mBP));
pcs->Irm = modregrm(2,0,4);
pcs->Isib = modregrm(0,reg,BX);
#else
pcs->Isib = modregrm(0,pcs->Irm,BX);
pcs->Irm = modregrm(2,0,4);
#endif
}
else
#endif
if (stackfl[f]) /* if we need [EBP] too */
{ unsigned idx = pcs->Irm & 7;
if (pcs->Irex & REX_B)
Expand All @@ -1026,9 +978,6 @@ code *getlvalue(code *pcs,elem *e,regm_t keepmsk)
{
idxregs = IDXREGS & ~keepmsk; /* only these can be index regs */
assert(idxregs);
#if 0 && TARGET_LINUX
assert(f != FLgot && f != FLgotoff);
#endif
if (stackfl[f]) /* if stack data type */
{ idxregs &= mSI | mDI; /* BX can't index off stack */
if (!idxregs) goto L1; /* index regs aren't avail */
Expand Down Expand Up @@ -1363,12 +1312,10 @@ code *getlvalue(code *pcs,elem *e,regm_t keepmsk)
goto L3;
case FLdata:
case FLudata:
#if TARGET_SEGMENTED
case FLcsdata:
#endif
#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
case FLgot:
case FLgotoff:
#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
case FLtlsdata:
#endif
L3:
Expand Down Expand Up @@ -1416,14 +1363,12 @@ code *getlvalue(code *pcs,elem *e,regm_t keepmsk)
pcs->Iflags |= CFcs | CFoff;
}
#endif
#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
if (I64 && config.flags3 & CFG3pic &&
(fl == FLtlsdata || s->ty() & mTYthread))
{
pcs->Iflags |= CFopsize;
pcs->Irex = 0x48;
}
#endif
pcs->IEVsym1 = s;
pcs->IEVoffset1 = e->EV.sp.Voffset;
if (sz == 1)
Expand Down Expand Up @@ -1453,9 +1398,7 @@ code *getlvalue(code *pcs,elem *e,regm_t keepmsk)
break;
}
#endif
#if TARGET_SEGMENTED
case FLfardata:
#endif
case FLfunc: /* reading from code seg */
if (config.exe & EX_flat)
goto L3;
Expand Down
25 changes: 0 additions & 25 deletions src/backend/cod2.c
Original file line number Diff line number Diff line change
Expand Up @@ -4315,13 +4315,9 @@ code *getoffset(elem *e,unsigned reg)
#endif
case FLdata:
case FLudata:
#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
case FLgot:
case FLgotoff:
#endif
#if TARGET_SEGMENTED
case FLcsdata:
#endif
L4:
cs.IEVsym2 = e->EV.sp.Vsym;
cs.IEVoffset2 = e->EV.sp.Voffset;
Expand Down Expand Up @@ -4360,27 +4356,6 @@ code *getoffset(elem *e,unsigned reg)
c = gen(c,&cs);
break;

#if 0 && TARGET_LINUX
case FLgot:
case FLgotoff:
{
gotref = 1;
symbol *s = e->EV.sp.Vsym;
// When using 8B (MOV), indicating that rm is used
// rm operands are always placed in IEV1 not IEV2
cs.IEVsym1 = s;
cs.IEVoffset1 = e->EV.sp.Voffset;
cs.Irm = modregrm(2,reg,BX); // reg,disp32[EBX]
cs.IFL1 = fl;
cs.Iop = (fl == FLgotoff)
? 0x8D // LEA reg, s[EBX]
: 0x8B; // MOV reg, s[EBX]
cs.Iflags = CFoff; // want offset only
c = gen(NULL,&cs);
break;
}
#endif

case FLreg:
/* Allow this since the tree optimizer puts & in front of */
/* register doubles. */
Expand Down
8 changes: 3 additions & 5 deletions src/backend/cod3.c
Original file line number Diff line number Diff line change
Expand Up @@ -6458,13 +6458,11 @@ static void do32bit(MiniCodeBuf *pbuf, enum FL fl,union evc *uev,int flags, int
ad = * (targ_size_t *) uev + pbuf->getOffset();
objmod->reftocodeseg(cseg,pbuf->offset,ad);
break;
#if TARGET_SEGMENTED

case FLcsdata:
case FLfardata:
#if DEBUG
symbol_print(uev->sp.Vsym);
#endif
#endif
//symbol_print(uev->sp.Vsym);

// NOTE: In ELFOBJ all symbol refs have been tagged FLextern
// strings and statics are treated like offsets from a
// un-named external with is the start of .rodata or .data
Expand Down
13 changes: 4 additions & 9 deletions src/backend/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,27 +253,22 @@ void WRdefnod()
}

void WRFL(enum FL fl)
{ static char fls[FLMAX][7] =
{"unde ","const ","oper ","func ","data ",
{
static const char fls[FLMAX][7] =
{ "unde ","const ","oper ","func ","data ",
"reg ",
"pseudo",
"auto ","fast ","para ","extrn ",
"code ","block ","udata ","cs ","swit ",
"fltrg ","offst ","datsg ",
"ctor ","dtor ","regsav","asm ",
#if TX86
"ndp ",
#endif
#if TARGET_SEGMENTED
"farda ","csdat ",
#endif
"local ","tlsdat",
"bprel ","frameh","blocko","alloca",
"stack ","dsym ",
#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
"got ","gotoff",
#endif
};
};

if ((unsigned)fl >= (unsigned)FLMAX)
dbg_printf("FL%d",fl);
Expand Down
2 changes: 0 additions & 2 deletions src/backend/evalu8.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,10 +546,8 @@ elem *poptelem(elem *e)
if (e2->Eoper == OPconst)
{ targ_int i = e2->EV.Vint;

#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
if (i && e1->EV.sp.Vsym->Sfl == FLgot)
break;
#endif
if (e->Eoper == OPmin)
i = -i;
e1->EV.sp.Voffset += i;
Expand Down
6 changes: 0 additions & 6 deletions src/backend/optabgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -785,24 +785,18 @@ void fltables()
case FLblockoff: segfl[i] = CS; break;
case FLcs: segfl[i] = SS; break;
case FLregsave: segfl[i] = SS; break;
#if TX86
case FLndp: segfl[i] = SS; break;
#endif
case FLswitch: segfl[i] = -1; break;
case FLfltreg: segfl[i] = SS; break;
case FLoffset: segfl[i] = -1; break;
#if TARGET_SEGMENTED
case FLfardata: segfl[i] = -1; break;
case FLcsdata: segfl[i] = CS; break;
#endif
case FLdatseg: segfl[i] = DS; break;
case FLctor: segfl[i] = -1; break;
case FLdtor: segfl[i] = -1; break;
case FLdsymbol: segfl[i] = -1; break;
#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
case FLgot: segfl[i] = -1; break;
case FLgotoff: segfl[i] = -1; break;
#endif
case FLlocalsize: segfl[i] = -1; break;
case FLtlsdata: segfl[i] = -1; break;
case FLframehandler: segfl[i] = -1; break;
Expand Down

0 comments on commit d34aa50

Please sign in to comment.