ARM: Remove need for CPSR load in some flag calculations
Vicki Pfau vi@endrift.com
Sun, 31 Mar 2019 11:59:18 -0700
3 files changed,
18 insertions(+),
0 deletions(-)
M
include/mgba/internal/arm/arm.h
→
include/mgba/internal/arm/arm.h
@@ -93,6 +93,20 @@ unsigned n : 1;
#endif }; + struct { +#if defined(__BIG_ENDIAN__) + uint8_t flags; + uint8_t status; + uint8_t extension; + uint8_t control; +#else + uint8_t control; + uint8_t extension; + uint8_t status; + uint8_t flags; +#endif + }; + int32_t packed; };
M
src/arm/isa-arm.c
→
src/arm/isa-arm.c
@@ -185,6 +185,7 @@ // Instruction definitions
// Beware pre-processor antics ATTRIBUTE_NOINLINE static void _additionS(struct ARMCore* cpu, int32_t m, int32_t n, int32_t d) { + cpu->cpsr.flags = 0; cpu->cpsr.n = ARM_SIGN(d); cpu->cpsr.z = !d; cpu->cpsr.c = ARM_CARRY_FROM(m, n, d);@@ -192,6 +193,7 @@ cpu->cpsr.v = ARM_V_ADDITION(m, n, d);
} ATTRIBUTE_NOINLINE static void _subtractionS(struct ARMCore* cpu, int32_t m, int32_t n, int32_t d) { + cpu->cpsr.flags = 0; cpu->cpsr.n = ARM_SIGN(d); cpu->cpsr.z = !d; cpu->cpsr.c = ARM_BORROW_FROM(m, n, d);
M
src/arm/isa-thumb.c
→
src/arm/isa-thumb.c
@@ -12,12 +12,14 @@ // Instruction definitions
// Beware pre-processor insanity #define THUMB_ADDITION_S(M, N, D) \ + cpu->cpsr.flags = 0; \ cpu->cpsr.n = ARM_SIGN(D); \ cpu->cpsr.z = !(D); \ cpu->cpsr.c = ARM_CARRY_FROM(M, N, D); \ cpu->cpsr.v = ARM_V_ADDITION(M, N, D); #define THUMB_SUBTRACTION_S(M, N, D) \ + cpu->cpsr.flags = 0; \ cpu->cpsr.n = ARM_SIGN(D); \ cpu->cpsr.z = !(D); \ cpu->cpsr.c = ARM_BORROW_FROM(M, N, D); \