all repos — mgba @ bf8c1d1b4b52d45cd84590dc7bd7d40b0dffc7bd

mGBA Game Boy Advance Emulator

ARM: Remove need for CPSR load in some flag calculations
Vicki Pfau vi@endrift.com
Sun, 31 Mar 2019 11:59:18 -0700
commit

bf8c1d1b4b52d45cd84590dc7bd7d40b0dffc7bd

parent

e18f275aaa0e702233d267e83559a4fdaa37cec6

3 files changed, 18 insertions(+), 0 deletions(-)

jump to
M include/mgba/internal/arm/arm.hinclude/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.csrc/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.csrc/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); \