Skip to content

Commit

Permalink
Merge pull request #5100 from WalterBright/movParams
Browse files Browse the repository at this point in the history
move parameters to stack instead of pushing
  • Loading branch information
andralex committed Sep 21, 2015
2 parents d26cf5f + 4d1f35b commit 039e230
Show file tree
Hide file tree
Showing 10 changed files with 302 additions and 50 deletions.
2 changes: 2 additions & 0 deletions src/backend/cc.h
Original file line number Diff line number Diff line change
Expand Up @@ -1420,6 +1420,8 @@ enum FL
FLgot, // global offset table entry outside this object file
FLgotoff, // global offset table entry inside this object file

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 039e230

Please sign in to comment.