Changed g_addaddr_local() codegen to reduce code size.

This commit is contained in:
acqn
2021-02-22 12:33:26 +08:00
committed by Oliver Schmidt
parent 8eeaaa3f36
commit b02838439c

View File

@@ -2112,29 +2112,38 @@ void g_addaddr_local (unsigned flags attribute ((unused)), int offs)
/* Add the offset */ /* Add the offset */
offs -= StackPtr; offs -= StackPtr;
if (offs != 0) { if (IS_Get (&CodeSizeFactor) <= 100) {
/* We cannot address more then 256 bytes of locals anyway */ if (offs != 0) {
L = GetLocalLabel(); /* We cannot address more then 256 bytes of locals anyway */
CheckLocalOffs (offs); g_inc (CF_INT | CF_CONST, offs);
AddCodeLine ("clc"); }
AddCodeLine ("adc #$%02X", offs & 0xFF); /* Add the current stackpointer value */
/* Do also skip the CLC insn below */ AddCodeLine ("jsr leaaxsp");
AddCodeLine ("bcc %s", LocalLabelName (L)); } else {
AddCodeLine ("inx"); if (offs != 0) {
} /* We cannot address more then 256 bytes of locals anyway */
L = GetLocalLabel();
CheckLocalOffs (offs);
AddCodeLine ("clc");
AddCodeLine ("adc #$%02X", offs & 0xFF);
/* Do also skip the CLC insn below */
AddCodeLine ("bcc %s", LocalLabelName (L));
AddCodeLine ("inx");
}
/* Add the current stackpointer value */ /* Add the current stackpointer value */
AddCodeLine ("clc"); AddCodeLine ("clc");
if (L != 0) { if (L != 0) {
/* Label was used above */ /* Label was used above */
g_defcodelabel (L); g_defcodelabel (L);
}
AddCodeLine ("adc sp");
AddCodeLine ("tay");
AddCodeLine ("txa");
AddCodeLine ("adc sp+1");
AddCodeLine ("tax");
AddCodeLine ("tya");
} }
AddCodeLine ("adc sp");
AddCodeLine ("tay");
AddCodeLine ("txa");
AddCodeLine ("adc sp+1");
AddCodeLine ("tax");
AddCodeLine ("tya");
} }