Coding style

This commit is contained in:
Colin Leroy-Mira
2025-07-20 16:06:34 +02:00
parent a0b705fd41
commit 1f6cca2140
3 changed files with 16 additions and 20 deletions

View File

@@ -244,6 +244,12 @@ static inline int CE_IsCallTo (const CodeEntry* E, const char* Name)
return (E->OPC == OP65_JSR && strcmp (E->Arg, Name) == 0);
}
static inline int CE_IsJumpTo (const CodeEntry* E, const char* Name)
/* Check if this is a jump to the given function */
{
return (E->OPC == OP65_JMP && strcmp (E->Arg, Name) == 0);
}
int CE_UseLoadFlags (CodeEntry* E);
/* Return true if the instruction uses any flags that are set by a load of
** a register (N and Z).

View File

@@ -573,11 +573,9 @@ unsigned OptTosLoadPop (CodeSeg* S)
const CodeEntry* E = CS_GetEntry (S, I);
/* Check for the sequence */
if (E->OPC == OP65_JSR &&
strncmp (E->Arg, "ldax0sp", 5) == 0 &&
if (CE_IsCallTo (E, "ldax0sp") &&
(N = CS_GetNextEntry (S, I)) != 0 &&
(N->OPC == OP65_JSR || N->OPC == OP65_JMP) &&
strcmp (N->Arg, "incsp2") == 0 &&
(CE_IsCallTo (N, "incsp2") || CE_IsJumpTo (N, "incsp2")) &&
!CE_HasLabel (N)) {
CodeEntry* X;
@@ -588,9 +586,6 @@ unsigned OptTosLoadPop (CodeSeg* S)
/* Delete the old code */
CS_DelEntries (S, I, 2);
/* Regenerate register info */
CS_GenRegInfo (S);
/* Remember we had changes */
++Changes;
@@ -1219,11 +1214,9 @@ unsigned OptTosPushPop(CodeSeg *S)
const CodeEntry* E = CS_GetEntry (S, I);
/* Check for decspn, incspn, subysp or addysp */
if (E->OPC == OP65_JSR &&
strcmp(E->Arg, "pushax") == 0 &&
if (CE_IsCallTo (E, "pushax") &&
(N = CS_GetNextEntry (S, I)) != 0 &&
(N->OPC == OP65_JSR || N->OPC == OP65_JMP) &&
strcmp(N->Arg, "popax") == 0 &&
(CE_IsCallTo (N, "popax") || CE_IsJumpTo (N, "popax")) &&
!CE_HasLabel (N)) {
/* Insert an rts if jmp popax */
@@ -1235,9 +1228,6 @@ unsigned OptTosPushPop(CodeSeg *S)
/* Delete the old code */
CS_DelEntries (S, I+1, 2);
/* Regenerate register info */
CS_GenRegInfo (S);
/* Remember we had changes */
++Changes;