optimize aligned address arithmetic

This commit is contained in:
drmortalwombat 2022-01-06 16:26:19 +01:00
parent 85f99fe411
commit 085fba137f
3 changed files with 34 additions and 5 deletions

View File

@ -26,6 +26,18 @@ const char keyb_codes[128] = {
byte keyb_matrix[8], keyb_key;
static byte keyb_pmatrix[8];
bool key_pressed(char code)
{
return !(keyb_matrix[code >> 3] & (1 << (code & 7)));
}
bool key_shift(void)
{
return
!(keyb_matrix[6] & 0x10) ||
!(keyb_matrix[1] & 0x80);
}
void keyb_poll(void)
{
cia1.ddra = 0xff;
@ -65,9 +77,8 @@ void keyb_poll(void)
}
}
keyb_key |= ~(((keyb_matrix[6] << 3) & keyb_matrix[1]) >> 1) & 0x40;
// if (keyb_key && (!(keyb_matrix[1] & 0x80) || (!(keyb_matrix[6] & 0x10))))
// keyb_key |= 0x40;
if (keyb_key && (!(keyb_matrix[1] & 0x80) || (!(keyb_matrix[6] & 0x10))))
keyb_key |= 0x40;
}
else
{

View File

@ -23,6 +23,11 @@
#define KEY_F6 (139)
#define KEY_F8 (140)
#define KEY_CODE_CSR_RIGHT (2)
#define KEY_CODE_CSR_DOWN (7)
#define KEY_CODE_LSHIFT (15)
#define KEY_CODE_RSHIFT (48)
// map of keyboard codes to PETSCII, first 64 without shift
// second 64 with shift
@ -38,6 +43,10 @@ extern byte keyb_key;
void keyb_poll(void);
inline bool key_pressed(char code);
inline bool key_shift(void);
#pragma compile("keyboard.c")
#endif

View File

@ -10205,8 +10205,6 @@ bool NativeCodeBasicBlock::OptimizeSimpleLoopInvariant(NativeCodeProcedure* proc
bool NativeCodeBasicBlock::OptimizeSimpleLoopInvariant(NativeCodeProcedure* proc, NativeCodeBasicBlock* prevBlock, NativeCodeBasicBlock* exitBlock)
{
return false;
bool changed = false;
int ai = 0;
@ -13485,7 +13483,18 @@ bool NativeCodeBasicBlock::PeepHoleOptimizer(int pass)
#endif
#endif
#if 1
if (pass > 1 && mIns[i].mMode == ASMIM_IMMEDIATE_ADDRESS && mIns[i].mLinkerObject && (mIns[i].mFlags & NCIF_LOWER) && !(mIns[i].mAddress & 0xff) && !(mIns[i].mLinkerObject->mAlignment & 0xff))
{
mIns[i].mMode = ASMIM_IMMEDIATE;
mIns[i].mAddress = 0;
mIns[i].mLinkerObject = nullptr;
mIns[i].mFlags &= ~NCIF_LOWER;
progress = true;
}
#endif
#endif
}
if (progress)