Post-review tweaks.

This commit is contained in:
laubzega
2018-10-15 23:08:44 -07:00
committed by Oliver Schmidt
parent 7d9485f6bc
commit 5fa79be997
3 changed files with 15 additions and 15 deletions

View File

@@ -644,11 +644,11 @@ static unsigned OptGotoSPAdj (CodeSeg* S)
adjustment = FindSPAdjustment (L[1]->Arg); adjustment = FindSPAdjustment (L[1]->Arg);
if (adjustment == 0) { if (adjustment == 0) {
/* No SP adjustment needed, remove the whole sequence */ /* No SP adjustment needed, remove the whole sequence */
CS_DelEntries (S, I, 9); CS_DelEntries (S, I, 9);
} }
else if (adjustment >= 65536 - 8) { else if (adjustment >= 65536 - 8) {
/* If adjustment is in range [-8, 0) we use decsp* calls */ /* If adjustment is in range [-8, 0) we use decsp* calls */
char Buf[20]; char Buf[20];
adjustment = 65536 - adjustment; adjustment = 65536 - adjustment;
xsprintf (Buf, sizeof (Buf), "decsp%u", adjustment); xsprintf (Buf, sizeof (Buf), "decsp%u", adjustment);
@@ -659,7 +659,7 @@ static unsigned OptGotoSPAdj (CodeSeg* S)
CS_DelEntries (S, I, 9); CS_DelEntries (S, I, 9);
} }
else if (adjustment >= 65536 - 255) { else if (adjustment >= 65536 - 255) {
/* For range [-255, -8) we have ldy #, jsr subysp */ /* For range [-255, -8) we have ldy #, jsr subysp */
adjustment = 65536 - adjustment; adjustment = 65536 - adjustment;
Arg = MakeHexArg (adjustment); Arg = MakeHexArg (adjustment);
X = NewCodeEntry (OP65_LDY, AM65_IMM, Arg, 0, L[1]->LI); X = NewCodeEntry (OP65_LDY, AM65_IMM, Arg, 0, L[1]->LI);
@@ -671,8 +671,9 @@ static unsigned OptGotoSPAdj (CodeSeg* S)
CS_DelEntries (S, I, 9); CS_DelEntries (S, I, 9);
} }
else if (adjustment > 255) { else if (adjustment > 255) {
/* For ranges [-32768, 255) and (255, 32767) the only modification /* For ranges [-32768, 255) and (255, 32767) the only modification
** is to replace the absolute with immediate addressing */ ** is to replace the absolute with immediate addressing
*/
Arg = MakeHexArg (adjustment & 0xff); Arg = MakeHexArg (adjustment & 0xff);
X = NewCodeEntry (OP65_LDA, AM65_IMM, Arg, 0, L[1]->LI); X = NewCodeEntry (OP65_LDA, AM65_IMM, Arg, 0, L[1]->LI);
CS_InsertEntry (S, X, I + 1); CS_InsertEntry (S, X, I + 1);
@@ -685,7 +686,7 @@ static unsigned OptGotoSPAdj (CodeSeg* S)
CS_DelEntry (S, I + 6); CS_DelEntry (S, I + 6);
} }
else if (adjustment > 8) { else if (adjustment > 8) {
/* For range (8, 255] we have ldy #, jsr addysp */ /* For range (8, 255] we have ldy #, jsr addysp */
Arg = MakeHexArg (adjustment & 0xff); Arg = MakeHexArg (adjustment & 0xff);
X = NewCodeEntry (OP65_LDY, AM65_IMM, Arg, 0, L[1]->LI); X = NewCodeEntry (OP65_LDY, AM65_IMM, Arg, 0, L[1]->LI);
CS_InsertEntry (S, X, I + 9); CS_InsertEntry (S, X, I + 9);
@@ -696,7 +697,7 @@ static unsigned OptGotoSPAdj (CodeSeg* S)
CS_DelEntries (S, I, 9); CS_DelEntries (S, I, 9);
} }
else { else {
/* If adjustment is in range (0, 8] we use incsp* calls */ /* If adjustment is in range (0, 8] we use incsp* calls */
char Buf[20]; char Buf[20];
xsprintf (Buf, sizeof (Buf), "incsp%u", adjustment); xsprintf (Buf, sizeof (Buf), "incsp%u", adjustment);
X = NewCodeEntry (OP65_JSR, AM65_ABS, Buf, 0, L[1]->LI); X = NewCodeEntry (OP65_JSR, AM65_ABS, Buf, 0, L[1]->LI);

View File

@@ -141,9 +141,7 @@ struct SymEntry {
} L; } L;
/* Value of SP adjustment needed after forward 'goto' */ /* Value of SP adjustment needed after forward 'goto' */
struct { unsigned short SPAdjustment;
unsigned short SPAdjustment;
} G;
/* Register bank offset and offset of the saved copy on stack for /* Register bank offset and offset of the saved copy on stack for
** register variables. ** register variables.

View File

@@ -408,7 +408,7 @@ void LeaveStructLevel (void)
SymEntry* FindSymInTable (const SymTable* T, const char* Name, unsigned Hash) static SymEntry* FindSymInTable (const SymTable* T, const char* Name, unsigned Hash)
/* Search for an entry in one table */ /* Search for an entry in one table */
{ {
/* Get the start of the hash chain */ /* Get the start of the hash chain */
@@ -681,15 +681,15 @@ DefOrRef* AddDefOrRef (SymEntry* E, unsigned Flags)
} }
unsigned short FindSPAdjustment (const char* Name) unsigned short FindSPAdjustment (const char* Name)
{
/* Search for an entry in the table of SP adjustments */ /* Search for an entry in the table of SP adjustments */
{
SymEntry* Entry = FindSymInTable (SPAdjustTab, Name, HashStr (Name)); SymEntry* Entry = FindSymInTable (SPAdjustTab, Name, HashStr (Name));
if (!Entry) { if (!Entry) {
Internal ("No SP adjustment label entry found"); Internal ("No SP adjustment label entry found");
} }
return Entry->V.G.SPAdjustment; return Entry->V.SPAdjustment;
} }
SymEntry* AddLabelSym (const char* Name, unsigned Flags) SymEntry* AddLabelSym (const char* Name, unsigned Flags)
@@ -749,9 +749,10 @@ SymEntry* AddLabelSym (const char* Name, unsigned Flags)
g_defdata (CF_CONST | CF_INT, StackPtr - DOR->StackPtr, 0); g_defdata (CF_CONST | CF_INT, StackPtr - DOR->StackPtr, 0);
/* Optimizer will need the information about the value of SP adjustment /* Optimizer will need the information about the value of SP adjustment
** later, so let's preserve it. */ ** later, so let's preserve it.
*/
E = NewSymEntry (LocalLabelName (DOR->LateSP_Label), SC_SPADJUSTMENT); E = NewSymEntry (LocalLabelName (DOR->LateSP_Label), SC_SPADJUSTMENT);
E->V.G.SPAdjustment = StackPtr - DOR->StackPtr; E->V.SPAdjustment = StackPtr - DOR->StackPtr;
AddSymEntry (SPAdjustTab, E); AddSymEntry (SPAdjustTab, E);
/* Are we jumping into a block with initalization of an object that /* Are we jumping into a block with initalization of an object that