move Auto to CGstate.Auto

This commit is contained in:
Walter Bright 2024-05-08 09:25:55 -07:00 committed by The Dlang Bot
parent 978cdca8b9
commit 1f963ecf3b
6 changed files with 32 additions and 32 deletions

View file

@ -69,7 +69,6 @@ targ_size_t pushoff; // offset of saved registers
bool pushoffuse; // using pushoff bool pushoffuse; // using pushoff
int BPoff; // offset from BP int BPoff; // offset from BP
int EBPtoESP; // add to EBP offset to get ESP offset int EBPtoESP; // add to EBP offset to get ESP offset
LocalSection Auto; // section of automatics and registers
LocalSection Fast; // section of fastpar LocalSection Fast; // section of fastpar
LocalSection EEStack; // offset of SCstack variables from ESP LocalSection EEStack; // offset of SCstack variables from ESP
LocalSection Alloca; // data for alloca() temporary LocalSection Alloca; // data for alloca() temporary
@ -653,7 +652,7 @@ void prolog(ref CodeBuilder cdb)
{ {
bool enter; bool enter;
//printf("cod3.prolog() %s, needframe = %d, Auto.alignment = %d\n", funcsym_p.Sident.ptr, needframe, Auto.alignment); //printf("cod3.prolog() %s, needframe = %d, Auto.alignment = %d\n", funcsym_p.Sident.ptr, needframe, cgstate.Auto.alignment);
debug debugw && printf("funcstart()\n"); debug debugw && printf("funcstart()\n");
regcon.immed.mval = 0; /* no values in registers yet */ regcon.immed.mval = 0; /* no values in registers yet */
version (FRAMEPTR) version (FRAMEPTR)
@ -803,11 +802,11 @@ else
Fast.size = alignsection(Fast.size - Fast.offset, Fast.alignment, bias); Fast.size = alignsection(Fast.size - Fast.offset, Fast.alignment, bias);
if (Auto.alignment < REGSIZE) if (cgstate.Auto.alignment < REGSIZE)
Auto.alignment = REGSIZE; // necessary because localsize must be REGSIZE aligned cgstate.Auto.alignment = REGSIZE; // necessary because localsize must be REGSIZE aligned
Auto.size = alignsection(Fast.size - Auto.offset, Auto.alignment, bias); cgstate.Auto.size = alignsection(Fast.size - cgstate.Auto.offset, cgstate.Auto.alignment, bias);
regsave.off = alignsection(Auto.size - regsave.top, regsave.alignment, bias); regsave.off = alignsection(cgstate.Auto.size - regsave.top, regsave.alignment, bias);
//printf("regsave.off = x%x, size = x%x, alignment = %x\n", //printf("regsave.off = x%x, size = x%x, alignment = %x\n",
//cast(int)regsave.off, cast(int)(regsave.top), cast(int)regsave.alignment); //cast(int)regsave.off, cast(int)(regsave.top), cast(int)regsave.alignment);
@ -852,7 +851,7 @@ else
} }
} }
//printf("Fast.size = x%x, Auto.size = x%x\n", cast(int)Fast.size, cast(int)Auto.size); //printf("Fast.size = x%x, Auto.size = x%x\n", cast(int)Fast.size, cast(int)cgstate.Auto.size);
cgstate.funcarg.alignment = STACKALIGN; cgstate.funcarg.alignment = STACKALIGN;
/* If the function doesn't need the extra alignment, don't do it. /* If the function doesn't need the extra alignment, don't do it.
@ -899,7 +898,7 @@ else
cgstate.funcarg.offset = -localsize; 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", //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)cgstate.Para.size,(int)localsize); //(int)Foff,(int)cgstate.Auto.size,(int)NDPoff,(int)CSoff,(int)cgstate.Para.size,(int)localsize);
uint xlocalsize = cast(uint)localsize; // amount to subtract from ESP to make room for locals uint xlocalsize = cast(uint)localsize; // amount to subtract from ESP to make room for locals
@ -1056,8 +1055,8 @@ Lcont:
/* Alignment checks /* Alignment checks
*/ */
//assert(Auto.alignment <= STACKALIGN); //assert(cgstate.Auto.alignment <= STACKALIGN);
//assert(((Auto.size + cgstate.Para.size + BPoff) & (Auto.alignment - 1)) == 0); //assert(((cgstate.Auto.size + cgstate.Para.size + BPoff) & (cgstate.Auto.alignment - 1)) == 0);
} }
/************************************ /************************************
@ -1116,7 +1115,7 @@ void stackoffsets(ref symtab_t symtab, bool estimate)
cgstate.Para.initialize(); // parameter offset cgstate.Para.initialize(); // parameter offset
Fast.initialize(); // SCfastpar offset Fast.initialize(); // SCfastpar offset
Auto.initialize(); // automatic & register offset cgstate.Auto.initialize(); // automatic & register offset
EEStack.initialize(); // for SCstack's EEStack.initialize(); // for SCstack's
// Set if doing optimization of auto layout // Set if doing optimization of auto layout
@ -1213,13 +1212,13 @@ void stackoffsets(ref symtab_t symtab, bool estimate)
break; break;
} }
Auto.offset = _align(sz,Auto.offset); cgstate.Auto.offset = _align(sz,cgstate.Auto.offset);
s.Soffset = Auto.offset; s.Soffset = cgstate.Auto.offset;
Auto.offset += sz; cgstate.Auto.offset += sz;
//printf("auto '%s' sz = %d, auto offset = x%lx\n", s.Sident,sz, cast(long) s.Soffset); //printf("auto '%s' sz = %d, auto offset = x%lx\n", s.Sident,sz, cast(long) s.Soffset);
if (alignsize > Auto.alignment) if (alignsize > cgstate.Auto.alignment)
Auto.alignment = alignsize; cgstate.Auto.alignment = alignsize;
break; break;
case SC.stack: case SC.stack:
@ -1306,15 +1305,15 @@ void stackoffsets(ref symtab_t symtab, bool estimate)
} }
} }
} }
Auto.offset = _align(sz,Auto.offset); cgstate.Auto.offset = _align(sz,cgstate.Auto.offset);
s.Soffset = Auto.offset; s.Soffset = cgstate.Auto.offset;
//printf("auto '%s' sz = %d, auto offset = x%lx\n", s.Sident, sz, cast(long) s.Soffset); //printf("auto '%s' sz = %d, auto offset = x%lx\n", s.Sident, sz, cast(long) s.Soffset);
Auto.offset += sz; cgstate.Auto.offset += sz;
if (s.Srange && !(s.Sflags & SFLspill)) if (s.Srange && !(s.Sflags & SFLspill))
vec_setbit(si,tbl); vec_setbit(si,tbl);
if (alignsize > Auto.alignment) if (alignsize > cgstate.Auto.alignment)
Auto.alignment = alignsize; cgstate.Auto.alignment = alignsize;
L2: { } L2: { }
} }

View file

@ -2525,7 +2525,7 @@ regm_t cod3_useBP()
goto Lcant; goto Lcant;
stackoffsets(globsym, true); // estimate stack offsets stackoffsets(globsym, true); // estimate stack offsets
localsize = Auto.offset + Fast.offset; // an estimate only localsize = cgstate.Auto.offset + Fast.offset; // an estimate only
// if (localsize) // if (localsize)
{ {
if (!(config.flags4 & CFG4speed) || if (!(config.flags4 & CFG4speed) ||
@ -3842,7 +3842,7 @@ void prolog_genvarargs(ref CodeBuilder cdb, Symbol* sv)
/* Save registers into the voff area on the stack /* Save registers into the voff area on the stack
*/ */
targ_size_t voff = Auto.size + BPoff + sv.Soffset; // EBP offset of start of sv targ_size_t voff = cgstate.Auto.size + BPoff + sv.Soffset; // EBP offset of start of sv
const int vregnum = 6; const int vregnum = 6;
const uint vsize = vregnum * 8 + 8 * 16; const uint vsize = vregnum * 8 + 8 * 16;
@ -5125,9 +5125,9 @@ void cod3_adjSymOffsets()
if (s.Sfl == FLfast) if (s.Sfl == FLfast)
s.Soffset += Fast.size + BPoff; s.Soffset += Fast.size + BPoff;
else else
//printf("s = '%s', Soffset = x%x, Auto.size = x%x, BPoff = x%x EBPtoESP = x%x\n", s.Sident, cast(int)s.Soffset, cast(int)Auto.size, cast(int)BPoff, cast(int)EBPtoESP); //printf("s = '%s', Soffset = x%x, Auto.size = x%x, BPoff = x%x EBPtoESP = x%x\n", s.Sident, cast(int)s.Soffset, cast(int)cgstate.Auto.size, cast(int)BPoff, cast(int)EBPtoESP);
// if (!(funcsym_p.Sfunc.Fflags3 & Fnested)) // if (!(funcsym_p.Sfunc.Fflags3 & Fnested))
s.Soffset += Auto.size + BPoff; s.Soffset += cgstate.Auto.size + BPoff;
break; break;
case SC.bprel: case SC.bprel:
@ -5327,7 +5327,7 @@ void assignaddrc(code *c)
case FLreg: case FLreg:
case FLauto: case FLauto:
soff = Auto.size; soff = cgstate.Auto.size;
L1: L1:
if (Symbol_Sisdead(*s, anyiasm)) if (Symbol_Sisdead(*s, anyiasm))
{ {
@ -5505,7 +5505,7 @@ void assignaddrc(code *c)
break; break;
case FLauto: case FLauto:
c.IEV2.Vpointer += s.Soffset + Auto.size + BPoff; c.IEV2.Vpointer += s.Soffset + cgstate.Auto.size + BPoff;
L3: L3:
if (!hasframe || (enforcealign && c.IFL2 != FLpara)) if (!hasframe || (enforcealign && c.IFL2 != FLpara))
/* Convert to ESP relative address instead of EBP */ /* Convert to ESP relative address instead of EBP */
@ -5579,7 +5579,7 @@ targ_size_t cod3_bpoffset(Symbol *s)
break; break;
case FLauto: case FLauto:
offset += Auto.size + BPoff; offset += cgstate.Auto.size + BPoff;
break; break;
default: default:

View file

@ -160,6 +160,7 @@ struct CGstate
LocalSection funcarg; // where function arguments are placed LocalSection funcarg; // where function arguments are placed
LocalSection Para; // section of function parameters LocalSection Para; // section of function parameters
LocalSection Auto; // section of automatics and registers
targ_size_t funcargtos; // current high water level of arguments being moved onto targ_size_t funcargtos; // current high water level of arguments being moved onto
// the funcarg section. It is filled from top to bottom, // the funcarg section. It is filled from top to bottom,

View file

@ -709,7 +709,7 @@ void cv8_outsym(Symbol *s)
if (s.Sfl == FLreg) if (s.Sfl == FLreg)
goto case_register; goto case_register;
case_auto: case_auto:
base = cast(uint)Auto.size; base = cast(uint)cgstate.Auto.size;
L1: L1:
if (s.Sscope) // local variables moved into the closure cannot be emitted directly if (s.Sscope) // local variables moved into the closure cannot be emitted directly
break; break;

View file

@ -1644,7 +1644,7 @@ private void cv4_outsym(Symbol *s)
if (s.Sfl == FLreg) if (s.Sfl == FLreg)
goto case_register; goto case_register;
case_auto: case_auto:
base = Auto.size; base = cgstate.Auto.size;
L1: L1:
if (s.Sscope) // local variables moved into the closure cannot be emitted directly if (s.Sscope) // local variables moved into the closure cannot be emitted directly
goto Lret; goto Lret;

View file

@ -1987,7 +1987,7 @@ static if (1)
// sa.Sident.ptr, sa.Sscope.Sident.ptr, closptr_off, memb_off); // sa.Sident.ptr, sa.Sscope.Sident.ptr, closptr_off, memb_off);
debug_info.buf.writeByte(DW_OP_fbreg); debug_info.buf.writeByte(DW_OP_fbreg);
debug_info.buf.writesLEB128(cast(uint)(Auto.size + BPoff - cgstate.Para.size + closptr_off)); // closure pointer offset from frame base debug_info.buf.writesLEB128(cast(uint)(cgstate.Auto.size + BPoff - cgstate.Para.size + closptr_off)); // closure pointer offset from frame base
debug_info.buf.writeByte(DW_OP_deref); debug_info.buf.writeByte(DW_OP_deref);
debug_info.buf.writeByte(DW_OP_plus_uconst); debug_info.buf.writeByte(DW_OP_plus_uconst);
debug_info.buf.writeuLEB128(cast(uint)memb_off); // closure variable offset debug_info.buf.writeuLEB128(cast(uint)memb_off); // closure variable offset
@ -2003,7 +2003,7 @@ static if (1)
else if (sa.Sclass == SC.bprel) else if (sa.Sclass == SC.bprel)
debug_info.buf.writesLEB128(cast(int)(-cgstate.Para.size + sa.Soffset)); debug_info.buf.writesLEB128(cast(int)(-cgstate.Para.size + sa.Soffset));
else else
debug_info.buf.writesLEB128(cast(int)(Auto.size + BPoff - cgstate.Para.size + sa.Soffset)); debug_info.buf.writesLEB128(cast(int)(cgstate.Auto.size + BPoff - cgstate.Para.size + sa.Soffset));
} }
debug_info.buf.buf[soffset] = cast(ubyte)(debug_info.buf.length() - soffset - 1); debug_info.buf.buf[soffset] = cast(ubyte)(debug_info.buf.length() - soffset - 1);
break; break;