mirror of
https://github.com/cc65/cc65.git
synced 2024-08-27 11:29:12 +00:00
When changing the reference to a jump label, do also replace the string
argument for the instruction with the name of the new jump label. This allows CodeEntriesAreEqual to work in all cases, and therefore optimizations based on this function will also work more effectively (or at all). git-svn-id: svn://svn.cc65.org/cc65/trunk@3100 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
e4473c0a96
commit
aa39d98cbc
@ -306,7 +306,7 @@ void CE_ReplaceOPC (CodeEntry* E, opc_t OPC)
|
||||
int CodeEntriesAreEqual (const CodeEntry* E1, const CodeEntry* E2)
|
||||
/* Check if both code entries are equal */
|
||||
{
|
||||
return E1->OPC == E2->OPC && E1->AM == E2->AM && strcmp (E1->Arg, E2->Arg) == 0;
|
||||
return (E1->OPC == E2->OPC && E1->AM == E2->AM && strcmp (E1->Arg, E2->Arg) == 0);
|
||||
}
|
||||
|
||||
|
||||
@ -336,6 +336,18 @@ void CE_MoveLabel (CodeLabel* L, CodeEntry* E)
|
||||
|
||||
|
||||
|
||||
void CE_SetArg (CodeEntry* E, const char* Arg)
|
||||
/* Replace the argument by the new one. */
|
||||
{
|
||||
/* Free the old argument */
|
||||
FreeArg (E->Arg);
|
||||
|
||||
/* Assign the new one */
|
||||
E->Arg = GetArgCopy (Arg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CE_SetNumArg (CodeEntry* E, long Num)
|
||||
/* Set a new numeric argument for the given code entry that must already
|
||||
* have a numeric argument.
|
||||
@ -357,11 +369,8 @@ void CE_SetNumArg (CodeEntry* E, long Num)
|
||||
Internal ("Invalid instruction size in CE_SetNumArg");
|
||||
}
|
||||
|
||||
/* Free the old argument */
|
||||
FreeArg (E->Arg);
|
||||
|
||||
/* Assign the new one */
|
||||
E->Arg = GetArgCopy (Buf);
|
||||
/* Replace the argument by the new one */
|
||||
CE_SetArg (E, Buf);
|
||||
|
||||
/* Use the new numerical value */
|
||||
E->Num = Num;
|
||||
|
@ -178,6 +178,9 @@ INLINE void CE_ResetMark (CodeEntry* E)
|
||||
# define CE_ResetMark(E) ((E)->Flags &= ~CEF_USERMARK)
|
||||
#endif
|
||||
|
||||
void CE_SetArg (CodeEntry* E, const char* Arg);
|
||||
/* Replace the argument by the new one. */
|
||||
|
||||
void CE_SetNumArg (CodeEntry* E, long Num);
|
||||
/* Set a new numeric argument for the given code entry that must already
|
||||
* have a numeric argument.
|
||||
|
@ -89,6 +89,9 @@ void CL_AddRef (CodeLabel* L, struct CodeEntry* E)
|
||||
/* The insn at E jumps to this label */
|
||||
E->JumpTo = L;
|
||||
|
||||
/* Replace the code entry argument with the name of the new label */
|
||||
CE_SetArg (E, L->Name);
|
||||
|
||||
/* Remember that in the label */
|
||||
CollAppend (&L->JumpFrom, E);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user