GBA Memory: partially unroll loops for LDM/STM and add UNLIKELYs

This commit is contained in:
Jeffrey Pfau 2014-11-18 04:29:16 -08:00
parent d49df216b8
commit 0308f136c7
1 changed files with 46 additions and 4 deletions

View File

@ -669,14 +669,35 @@ void GBAStore8(struct ARMCore* cpu, uint32_t address, int8_t value, int* cycleCo
}
#define LDM_LOOP(LDM) \
for (i = 0; i < 16; ++i) { \
if (mask & (1 << i)) { \
for (i = 0; i < 16; i += 4) { \
if (UNLIKELY(mask & (1 << i))) { \
LDM; \
waitstatesRegion = memory->waitstatesSeq32; \
cpu->gprs[i] = value; \
++wait; \
address += 4; \
} \
if (UNLIKELY(mask & (2 << i))) { \
LDM; \
waitstatesRegion = memory->waitstatesSeq32; \
cpu->gprs[i + 1] = value; \
++wait; \
address += 4; \
} \
if (UNLIKELY(mask & (4 << i))) { \
LDM; \
waitstatesRegion = memory->waitstatesSeq32; \
cpu->gprs[i + 2] = value; \
++wait; \
address += 4; \
} \
if (UNLIKELY(mask & (8 << i))) { \
LDM; \
waitstatesRegion = memory->waitstatesSeq32; \
cpu->gprs[i + 3] = value; \
++wait; \
address += 4; \
} \
}
uint32_t GBALoadMultiple(struct ARMCore* cpu, uint32_t address, int mask, enum LSMDirection direction, int* cycleCounter) {
@ -757,14 +778,35 @@ uint32_t GBALoadMultiple(struct ARMCore* cpu, uint32_t address, int mask, enum L
}
#define STM_LOOP(STM) \
for (i = 0; i < 16; ++i) { \
if (mask & (1 << i)) { \
for (i = 0; i < 16; i += 4) { \
if (UNLIKELY(mask & (1 << i))) { \
value = cpu->gprs[i]; \
STM; \
waitstatesRegion = memory->waitstatesSeq32; \
++wait; \
address += 4; \
} \
if (UNLIKELY(mask & (2 << i))) { \
value = cpu->gprs[i + 1]; \
STM; \
waitstatesRegion = memory->waitstatesSeq32; \
++wait; \
address += 4; \
} \
if (UNLIKELY(mask & (4 << i))) { \
value = cpu->gprs[i + 2]; \
STM; \
waitstatesRegion = memory->waitstatesSeq32; \
++wait; \
address += 4; \
} \
if (UNLIKELY(mask & (8 << i))) { \
value = cpu->gprs[i + 3]; \
STM; \
waitstatesRegion = memory->waitstatesSeq32; \
++wait; \
address += 4; \
} \
}
uint32_t GBAStoreMultiple(struct ARMCore* cpu, uint32_t address, int mask, enum LSMDirection direction, int* cycleCounter) {