Skip to content

Commit

Permalink
move stackchanged to CGstate
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright authored and dlang-bot committed May 15, 2024
1 parent 45cc33f commit 6501c91
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
9 changes: 2 additions & 7 deletions compiler/src/dmd/backend/cgcod.d
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@ regm_t ALLREGS() { return I64 ? mAX|mBX|mCX|mDX|mSI|mDI| mR8|mR9|mR10|mR11|mR12
regm_t BYTEREGS() { return I64 ? ALLREGS
: BYTEREGS_INIT; }

int stackchanged; /* set to !=0 if any use of the stack
other than accessing parameters. Used
to see if we can address parameters
with ESP rather than EBP.
*/
int refparam; // !=0 if we referenced any parameters
int reflocal; // !=0 if we referenced any locals
bool anyiasm; // !=0 if any inline assembler
Expand Down Expand Up @@ -140,7 +135,7 @@ void codgen(Symbol *sfunc)
needframe = 0;
cgstate.enforcealign = false;
gotref = 0;
stackchanged = 0;
cgstate.stackchanged = 0;
cgstate.stackpush = 0;
refparam = 0;
calledafunc = 0;
Expand Down Expand Up @@ -2873,7 +2868,7 @@ void scodelem(ref CodeBuilder cdb, elem *e,regm_t *pretregs,regm_t keepmsk,bool
cs2 = cat(cdby.finish(),cs2);
if (size)
{
stackchanged = 1;
cgstate.stackchanged = 1;
adjesp += size;
}
}
Expand Down
6 changes: 3 additions & 3 deletions compiler/src/dmd/backend/cod1.d
Original file line number Diff line number Diff line change
Expand Up @@ -4396,7 +4396,7 @@ void pushParams(ref CodeBuilder cdb, elem* e, uint stackalign, tym_t tyf)
{
//printf("params(e = %p, stackalign = %d)\n", e, stackalign);
//printf("params()\n"); elem_print(e);
stackchanged = 1;
cgstate.stackchanged = 1;
assert(e && e.Eoper != OPparam);

tym_t tym = tybasic(e.Ety);
Expand Down Expand Up @@ -5515,7 +5515,7 @@ void loaddata(ref CodeBuilder cdb, elem* e, ref regm_t outretregs)
assert(0);
/+
/* Note that we allocreg(DOUBLEREGS) needlessly */
stackchanged = 1;
cgstate.stackchanged = 1;
int i = DOUBLESIZE - REGSIZE;
do
{
Expand All @@ -5542,7 +5542,7 @@ void loaddata(ref CodeBuilder cdb, elem* e, ref regm_t outretregs)
if ((outretregs & (mSTACK | mPSW)) == mSTACK)
{
// Note that we allocreg(DOUBLEREGS) needlessly
stackchanged = 1;
cgstate.stackchanged = 1;
int i = sz - REGSIZE;
do
{
Expand Down
12 changes: 6 additions & 6 deletions compiler/src/dmd/backend/cod2.d
Original file line number Diff line number Diff line change
Expand Up @@ -3344,7 +3344,7 @@ void cdind(ref CodeBuilder cdb,elem *e,regm_t *pretregs)
cs.Iop = 0xFF;
cs.Irm |= modregrm(0,6,0);
cs.IEV1.Voffset += 8 - REGSIZE;
stackchanged = 1;
cgstate.stackchanged = 1;
i = 8 - REGSIZE;
do
{
Expand Down Expand Up @@ -3838,7 +3838,7 @@ void cdstrcpy(ref CodeBuilder cdb,elem *e,regm_t *pretregs)
POP DS
*/

stackchanged = 1;
cgstate.stackchanged = 1;
regm_t retregs = mDI;
tym_t ty2 = tybasic(e.E2.Ety);
if (!tyreg(ty2))
Expand Down Expand Up @@ -4838,7 +4838,7 @@ void getoffset(ref CodeBuilder cdb,elem *e,reg_t reg)
if (reg & 8)
code_orrex(cdb.last(), REX_B);
cdb.genadjesp(REGSIZE);
stackchanged = 1;
cgstate.stackchanged = 1;
}
break;
}
Expand Down Expand Up @@ -4886,7 +4886,7 @@ void getoffset(ref CodeBuilder cdb,elem *e,reg_t reg)
cs.IEV2.Voffset = e.Voffset;
L3:
if (reg == STACK)
{ stackchanged = 1;
{ cgstate.stackchanged = 1;
cs.Iop = 0x68; /* PUSH immed16 */
cdb.genadjesp(REGSIZE);
}
Expand Down Expand Up @@ -4938,7 +4938,7 @@ void getoffset(ref CodeBuilder cdb,elem *e,reg_t reg)
if (reg & 8)
code_orrex(cdb.last(), REX_B);
cdb.genadjesp(REGSIZE);
stackchanged = 1;
cgstate.stackchanged = 1;
}
else
{
Expand Down Expand Up @@ -5208,7 +5208,7 @@ if (config.exe & EX_windos)
regm_t idxregs = idxregm(&cs); // mask of index regs used
cs.Iop = 0x8B; /* MOV DOUBLEREGS,EA */
fltregs(cdb,&cs,tyml);
stackchanged = 1;
cgstate.stackchanged = 1;
int stackpushsave = cgstate.stackpush;
regm_t retregs;
if (sz == 8)
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dmd/backend/cod3.d
Original file line number Diff line number Diff line change
Expand Up @@ -2405,7 +2405,7 @@ void cod3_ptrchk(ref CodeBuilder cdb,code *pcs,regm_t keepmsk)
{
int push,pop;

stackchanged = 1;
cgstate.stackchanged = 1;
if (i == ES)
{ push = 0x06;
pop = 0x07;
Expand Down
6 changes: 6 additions & 0 deletions compiler/src/dmd/backend/code.d
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ struct CGstate
targ_size_t pushoff; // offset of saved registers
bool pushoffuse; // using pushoff

int stackchanged; /* set to !=0 if any use of the stack
other than accessing parameters. Used
to see if we can address parameters
with ESP rather than EBP.
*/

LocalSection funcarg; // where function arguments are placed
LocalSection Para; // section of function parameters
LocalSection Auto; // section of automatics and registers
Expand Down

0 comments on commit 6501c91

Please sign in to comment.