Skip to content

Commit

Permalink
Merge pull request #5100 from WalterBright/movParams
Browse files Browse the repository at this point in the history
  • Loading branch information
andralex authored and WalterBright committed Sep 21, 2015
1 parent 54898ad commit ac5b0e3
Show file tree
Hide file tree
Showing 11 changed files with 316 additions and 71 deletions.
19 changes: 10 additions & 9 deletions src/backend/cc.h
Original file line number Diff line number Diff line change
Expand Up @@ -1375,6 +1375,7 @@ struct PARAM

enum FL
{
// Change this, update debug.c too
FLunde,
FLconst, // numerical constant
FLoper, // operator node
Expand All @@ -1399,13 +1400,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 @@ -1414,13 +1415,13 @@ 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

FLfuncarg, // argument to upcoming function call

FLMAX
};

Expand Down
19 changes: 13 additions & 6 deletions src/backend/cgcod.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ void codgen()
cod3_initregs();
allregs = ALLREGS;
pass = PASSinit;
Alloca.init();
anyiasm = 0;

tryagain:
#ifdef DEBUG
Expand All @@ -162,12 +164,13 @@ void codgen()
stackchanged = 0;
stackpush = 0;
refparam = 0;
anyiasm = 0;
calledafunc = 0;
cgstate.stackclean = 1;
retsym = NULL;

Alloca.init();
cgstate.stackclean = 1;
cgstate.funcarg.init();
cgstate.funcargtos = ~0;

regsave.reset();
#if TX86
memset(_8087elems,0,sizeof(_8087elems));
Expand Down Expand Up @@ -783,7 +786,7 @@ code *prolog()
*/
int xmmtopush = numbitsset(topush & XMMREGS); // XMM regs take 16 bytes
int gptopush = numbitsset(topush) - xmmtopush; // general purpose registers to save
if (NDPoff || xmmtopush)
if (NDPoff || xmmtopush || cgstate.funcarg.size)
{
pushoff = alignsection(pushoff - (gptopush * REGSIZE + xmmtopush * 16),
xmmtopush ? STACKALIGN : REGSIZE, bias);
Expand All @@ -793,7 +796,10 @@ code *prolog()

//printf("Fast.size = x%x, Auto.size = x%x\n", (int)Fast.size, (int)Auto.size);

localsize = -pushoff;
cgstate.funcarg.alignment = STACKALIGN;
cgstate.funcarg.offset = alignsection(pushoff - cgstate.funcarg.size, cgstate.funcarg.alignment, bias);

localsize = -cgstate.funcarg.offset;

//printf("Alloca.offset = x%llx, cstop = x%llx, CSoff = x%llx, NDPoff = x%llx, localsize = x%llx\n",
//(long long)Alloca.offset, (long long)cstop, (long long)CSoff, (long long)NDPoff, (long long)localsize);
Expand All @@ -809,7 +815,7 @@ code *prolog()
npush = 0;

//printf("npush = %d Para.size = x%x needframe = %d localsize = x%x\n",
// npush, Para.size, needframe, localsize);
//npush, Para.size, needframe, localsize);

int sz = Para.size + (needframe ? 0 : -REGSIZE) + localsize + npush * REGSIZE;
if (STACKALIGN == 16)
Expand All @@ -820,6 +826,7 @@ code *prolog()
else if (sz & 4)
localsize += 4;
}
cgstate.funcarg.offset = -localsize;

//printf("Foff x%02x Auto.size x%02x NDPoff x%02x CSoff x%02x Para.size x%02x localsize x%02x\n",
//(int)Foff,(int)Auto.size,(int)NDPoff,(int)CSoff,(int)Para.size,(int)localsize);
Expand Down
Loading

0 comments on commit ac5b0e3

Please sign in to comment.