Skip to content

Commit

Permalink
harmonize with some D2 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed May 17, 2013
1 parent 542c871 commit fadd2a3
Show file tree
Hide file tree
Showing 27 changed files with 238 additions and 309 deletions.
310 changes: 134 additions & 176 deletions src/backend/cgcod.c

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions src/backend/cgcs.c
Expand Up @@ -500,8 +500,7 @@ STATIC void addhcstab(elem *e,int hash)
*/

STATIC void touchlvalue(elem *e)
{ register int i;

{
if (e->Eoper == OPind) /* if indirect store */
{
/* NOTE: Some types of array assignments do not need
Expand All @@ -513,12 +512,16 @@ STATIC void touchlvalue(elem *e)
return;
}

for (i = hcstop; --i >= 0;)
{ if (hcstab[i].Helem &&
for (int i = hcstop; --i >= 0;)
{ if (hcstab[i].Helem &&
hcstab[i].Helem->EV.sp.Vsym == e->EV.sp.Vsym)
hcstab[i].Helem = NULL;
}
}

#ifdef DEBUG
if (!(e->Eoper == OPvar || e->Eoper == OPrelconst))
elem_print(e);
#endif
assert(e->Eoper == OPvar || e->Eoper == OPrelconst);
switch (e->EV.sp.Vsym->Sclass)
{
Expand Down
31 changes: 24 additions & 7 deletions src/backend/cgelem.c
Expand Up @@ -2245,10 +2245,18 @@ STATIC elem * eloror(elem *e, goal_t goal)
{
if (boolres(e1)) /* (x,1) || e2 => (x,1),1 */
{
L2:
e->Eoper = OPcomma;
el_free(e->E2);
e->E2 = el_int(t,1);
if (tybasic(e->E2->Ety) == TYvoid)
{ assert(!goal);
el_free(e);
return NULL;
}
else
{
L2:
e->Eoper = OPcomma;
el_free(e->E2);
e->E2 = el_int(t,1);
}
}
else /* (x,0) || e2 => (x,0),(bool e2) */
{ e->Eoper = OPcomma;
Expand Down Expand Up @@ -2401,12 +2409,21 @@ STATIC elem * elandand(elem *e, goal_t goal)
e->Eoper = OPcomma;
if (boolres(e1)) /* (x,1) && e2 => (x,1),bool e2 */
{
e->E2 = el_una(OPbool,e->Ety,e->E2);
if (tybasic(e->E2->Ety) != TYvoid)
e->E2 = el_una(OPbool,e->Ety,e->E2);
}
else /* (x,0) && e2 => (x,0),0 */
{
el_free(e->E2);
e->E2 = el_int(e->Ety,0);
if (tybasic(e->E2->Ety) == TYvoid)
{ assert(!goal);
el_free(e);
return NULL;
}
else
{
el_free(e->E2);
e->E2 = el_int(e->Ety,0);
}
}
}
else
Expand Down
2 changes: 2 additions & 0 deletions src/backend/cgen.c
Expand Up @@ -580,11 +580,13 @@ size_t addtofixlist(symbol *s,targ_size_t soffset,int seg,targ_size_t val,int fl
if (I64 && !(flags & CFoffset64))
numbytes = 4;

#if TARGET_WINDOS
/* This can happen when generating CV8 data
*/
if (flags & CFseg)
numbytes += 2;
#endif
#endif
#ifdef DEBUG
assert(numbytes <= sizeof(zeros));
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/backend/cgsched.c
Expand Up @@ -2711,7 +2711,7 @@ code *schedule(code *c,regm_t scratch)
while (c)
{
if ((c->Iop == NOP ||
((c->Iop & 0xFF) == ESCAPE && c->Iop != (ESCAPE | ESCadjfpu)) ||
((c->Iop & ESCAPEmask) == ESCAPE && c->Iop != (ESCAPE | ESCadjfpu)) ||
c->Iflags & CFclassinit) &&
!(c->Iflags & (CFtarg | CFtarg2)))
{ code *cn;
Expand Down
1 change: 1 addition & 0 deletions src/backend/cod2.c
Expand Up @@ -3261,6 +3261,7 @@ code *cdmemcmp(elem *e,regm_t *pretregs)
#if 1
c3 = cat(c3,getregs(mAX));
c3 = gen2(c3,0x33,modregrm(3,AX,AX)); // XOR AX,AX
code_orflag(c3, CFpsw); // keep flags
#else
if (*pretregs != mPSW) // if not flags only
c3 = regwithvalue(c3,mAX,0,NULL,0); // put 0 in AX
Expand Down
44 changes: 4 additions & 40 deletions src/backend/cod3.c
Expand Up @@ -776,25 +776,13 @@ void outblkexitcode(block *bl, code*& c, int& anyspill, const char* sflsave, sym
// Mark all registers as destroyed. This will prevent
// register assignments to variables used in catch blocks.
c = cat(c,getregs((I32 | I64) ? allregs : (ALLREGS | mES)));
#if 0 && TARGET_LINUX
if (config.flags3 & CFG3pic && !(allregs & mBX))
{
c = cat(c, cod3_load_got());
}
#endif
goto case_goto;
#endif
#if SCPP
case BCcatch:
// Mark all registers as destroyed. This will prevent
// register assignments to variables used in catch blocks.
c = cat(c,getregs(allregs | mES));
#if 0 && TARGET_LINUX
if (config.flags3 & CFG3pic && !(allregs & mBX))
{
c = cat(c, cod3_load_got());
}
#endif
goto case_goto;

case BCtry:
Expand Down Expand Up @@ -2527,7 +2515,10 @@ code *movregconst(code *c,unsigned reg,targ_size_t value,regm_t flags)
if (flags & 64)
c = genc2(c,0xC7,(REX_W << 16) | modregrmx(3,0,reg),value); // MOV reg,value64
else
c = genc2(c,0xC7,modregrmx(3,0,reg),value); // MOV reg,value
{ c = genc2(c,0xC7,modregrmx(3,0,reg),value); // MOV reg,value
if (I64)
value &= 0xFFFFFFFF;
}
}
}
done:
Expand Down Expand Up @@ -3657,33 +3648,6 @@ targ_size_t cod3_spoff()
return spoff + localsize;
}

/**********************************
* Load value of _GLOBAL_OFFSET_TABLE_ into EBX
*/

code *cod3_load_got()
{
#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
code *c;
code *cgot;

c = genc2(NULL,CALL,0,0); // CALL L1
gen1(c, 0x58 + BX); // L1: POP EBX

// ADD EBX,_GLOBAL_OFFSET_TABLE_+3
symbol *gotsym = Obj::getGOTsym();
cgot = gencs(CNIL,0x81,0xC3,FLextern,gotsym);
cgot->Iflags = CFoff;
cgot->IEVoffset2 = 3;

makeitextern(gotsym);
return cat(c,cgot);
#else
assert(0);
return NULL;
#endif
}

code* gen_spill_reg(Symbol* s, bool toreg)
{
code *c;
Expand Down
2 changes: 2 additions & 0 deletions src/backend/code_stub.h
Expand Up @@ -4,6 +4,7 @@
#define ESCAPE 2
// 8 is to leave room for opcodes to be in the range 0 .. 255
// probably better off moving them to the high byte rather than second byte
#define ESCAPEmask 0xff
#define ESClinnum (0 << 8)
#define ESCadjesp (1 << 8)
#define ESCadjfpu (2 << 8)
Expand Down Expand Up @@ -84,5 +85,6 @@ struct code

bool isJumpOP() { return false; }

void print() {}
};

1 change: 1 addition & 0 deletions src/backend/code_x86.h
Expand Up @@ -231,6 +231,7 @@ extern regm_t BYTEREGS;
#define NOP 0x2E /* actually CS: (we don't use 0x90 because the */
/* silly Windows stuff wants to output 0x90's) */

#define ESCAPEmask 0xFF // code.Iop & ESCAPEmask ==> actual Iop
#define ESCAPE 0x3E // marker that special information is here
// (Iop2 is the type of special information)
// (Same as DS:, but we will never generate
Expand Down
8 changes: 7 additions & 1 deletion src/backend/el.c
Expand Up @@ -1105,7 +1105,13 @@ symbol *el_alloc_localgot()
char name[15];
static int tmpnum;
sprintf(name, "_LOCALGOT%d", tmpnum++);
localgot = symbol_name(name, SCauto, type_fake(TYnptr));
type *t = type_fake(TYnptr);
/* Make it volatile because we need it for calling functions, but that isn't
* noticed by the data flow analysis. Hence, it may get deleted if we don't
* make it volatile.
*/
type_setcv(&t, mTYvolatile);
localgot = symbol_name(name, SCauto, t);
symbol_add(localgot);
localgot->Sfl = FLauto;
localgot->Sflags = SFLfree | SFLunambig | GTregcand;
Expand Down
9 changes: 9 additions & 0 deletions src/backend/gother.c
Expand Up @@ -399,6 +399,15 @@ STATIC void chkrd(elem *n,list_t rdlist)
if (sv->Stype->Ttag->Sstruct->Sflags & (STRbitfields | STR0size))
return;
}
#if 0
// If variable is zero length static array, don't print message.
// BUG: Suppress error even if variable is initialized with void.
if (sv->Stype->Tty == TYarray && sv->Stype->Tdim == 0)
{
printf("sv->Sident = %s\n", sv->Sident);
return;
}
#endif
#if SCPP
{ Outbuffer buf;
char *p2;
Expand Down
4 changes: 2 additions & 2 deletions src/backend/ptrntab.c
Expand Up @@ -653,8 +653,8 @@ PTRNTAB2 aptb2MOVSXD[] = /* MOVSXD */ {
{ ASM_END }
};
PTRNTAB2 aptb2MOVZX[] = /* MOVZX */ {
{ 0x0fb6, _r|_16_bit, _r16, _rm8 },
{ 0x0fb6, _r|_32_bit, _r32, _rm8 },
{ 0x0fb6, _r|_16_bit, _r16, _rm8 },
{ 0x0fb6, _r|_32_bit, _r32, _rm8 },
{ 0x0fb6, _r|_64_bit, _r64, _rm8 }, // TODO: REX_W override is implicit
{ 0x0fb7, _r|_16_bit, _r16, _rm16 },
{ 0x0fb7, _r|_32_bit, _r32, _rm16 },
Expand Down
1 change: 1 addition & 0 deletions src/backend/rtlsym.h
Expand Up @@ -46,6 +46,7 @@ SYMBOL_MARS(MONITOR_HANDLER, FLfunc,FREGSAVED,"_d_monitor_handler", 0, 0) \
SYMBOL_MARS(MONITOR_PROLOG, FLfunc,FREGSAVED,"_d_monitor_prolog",0,t) \
SYMBOL_MARS(MONITOR_EPILOG, FLfunc,FREGSAVED,"_d_monitor_epilog",0,t) \
SYMBOL_MARS(DCOVER, FLfunc,FREGSAVED,"_d_cover_register", 0, t) \
SYMBOL_MARS(DCOVER2, FLfunc,FREGSAVED,"_d_cover_register2", 0, t) \
SYMBOL_MARS(DASSERT, FLfunc,FREGSAVED,"_d_assert", SFLexit, t) \
SYMBOL_MARS(DASSERTM, FLfunc,FREGSAVED,"_d_assertm", SFLexit, t) \
SYMBOL_MARS(DASSERT_MSG, FLfunc,FREGSAVED,"_d_assert_msg", SFLexit, t) \
Expand Down
22 changes: 0 additions & 22 deletions src/iasm.c
Expand Up @@ -203,8 +203,6 @@ typedef struct
char regstr[6];
unsigned char val;
opflag_t ty;

bool isSIL_DIL_BPL_SPL();
} REG;

static REG regFp = { "ST", 0, _st };
Expand Down Expand Up @@ -443,16 +441,6 @@ static REG regtab64[] =
"YMM15", 15, _ymm,
};

bool REG::isSIL_DIL_BPL_SPL()
{
// Be careful as these have the same val's as AH CH DH BH
return ty == _r8 &&
((val == _SIL && strcmp(regstr, "SIL") == 0) ||
(val == _DIL && strcmp(regstr, "DIL") == 0) ||
(val == _BPL && strcmp(regstr, "BPL") == 0) ||
(val == _SPL && strcmp(regstr, "SPL") == 0));
}

typedef enum {
ASM_JUMPTYPE_UNSPECIFIED,
ASM_JUMPTYPE_SHORT,
Expand Down Expand Up @@ -1944,11 +1932,6 @@ printf("usOpcode = %x\n", usOpcode);
pc->Irex |= REX_B;
assert(I64);
}
else if (popnd1->base->isSIL_DIL_BPL_SPL())
{
pc->Irex |= REX;
assert(I64);
}
if (asmstate.ucItype == ITfloat)
pc->Irm += reg;
else
Expand All @@ -1968,11 +1951,6 @@ printf("usOpcode = %x\n", usOpcode);
pc->Irex |= REX_B;
assert(I64);
}
else if (popnd1->base->isSIL_DIL_BPL_SPL())
{
pc->Irex |= REX;
assert(I64);
}
if (asmstate.ucItype == ITfloat)
pc->Irm += reg;
else
Expand Down
2 changes: 1 addition & 1 deletion src/lexer.c
Expand Up @@ -3064,7 +3064,7 @@ void Lexer::initKeywords()
{
unsigned nkeywords = sizeof(keywords) / sizeof(keywords[0]);

stringtable.init(6151);
stringtable._init(6151);

if (global.params.Dversion == 1)
nkeywords -= 2;
Expand Down
2 changes: 1 addition & 1 deletion src/libelf.c
Expand Up @@ -77,7 +77,7 @@ Library *Library::factory()
LibElf::LibElf()
{
libfile = NULL;
tab.init();
tab._init();
}

/***********************************
Expand Down
2 changes: 1 addition & 1 deletion src/libmach.c
Expand Up @@ -87,7 +87,7 @@ Library *Library::factory()
LibMach::LibMach()
{
libfile = NULL;
tab.init();
tab._init();
}

/***********************************
Expand Down
2 changes: 1 addition & 1 deletion src/libmscoff.c
Expand Up @@ -103,7 +103,7 @@ Library *LibMSCoff_factory()
LibMSCoff::LibMSCoff()
{
libfile = NULL;
tab.init();
tab._init();
}

/***********************************
Expand Down
2 changes: 1 addition & 1 deletion src/libomf.c
Expand Up @@ -87,7 +87,7 @@ Library *Library::factory()
LibOMF::LibOMF()
{
libfile = NULL;
tab.init();
tab._init();
}

/***********************************
Expand Down
8 changes: 0 additions & 8 deletions src/mars.h
Expand Up @@ -342,14 +342,6 @@ typedef d_uns32 d_dchar;
typedef long double real_t;
#endif

// Modify OutBuffer::writewchar to write the correct size of wchar
#if _WIN32
#define writewchar writeword
#else
// This needs a configuration test...
#define writewchar write4
#endif

#ifdef IN_GCC
#include "d-gcc-complex_t.h"
#endif
Expand Down
6 changes: 2 additions & 4 deletions src/msc.c
@@ -1,6 +1,6 @@

// Compiler implementation of the D programming language
// Copyright (c) 1999-2013 by Digital Mars
// Copyright (c) 1999-2012 by Digital Mars
// All Rights Reserved
// written by Walter Bright
// http://www.digitalmars.com
Expand Down Expand Up @@ -73,9 +73,7 @@ void backend_init()
bool exe;
#if TARGET_WINDOS
exe = false;
if (params->dll)
;
else if (params->run)
if (params->run)
exe = true; // EXE file only optimizations
else if (params->link && !global.params.deffile)
exe = true; // EXE file only optimizations
Expand Down
2 changes: 1 addition & 1 deletion src/mtype.c
Expand Up @@ -137,7 +137,7 @@ char Type::needThisPrefix()

void Type::init()
{
stringtable.init(1543);
stringtable._init(1543);
Lexer::initKeywords();

mangleChar[Tarray] = 'A';
Expand Down

0 comments on commit fadd2a3

Please sign in to comment.