Use one struct for R4300 registers on all architectures #134
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The New Dynarec/ARM redefines global variables in its own memory block in order to bring a lot of them together in memory for easy indexing. This PR does the same for all other R4300 cores on all architectures by moving a lot of often-used global variables from many files into one struct in
r4300.c:The compiler is then allowed to reference every member of that structure with offsets from a single address, which is faster on ARM and MIPS (and may or may not be faster on x86 due to processor microarchitecture changes) when emitting position-independent code.
In addition, I have aligned the new structure to 4 KiB in order to induce only 1 TLB miss for accessing it.
The new structure is hidden and recreated in the New Dynarec/ARM as usual, but the number of recreated variables is greatly reduced.
I expect the performance to increase in these cores:
MFC0,MTC0,[D]MFC1,[D]MTC1, floating-point width conversion instructions and memory access instructions, which accessed more than one global variable (and now access the members of the structure).struct precomp_instr, so after compilation, there are no reloads of global variable addresses.A possibly undesirable aspect of this change is that the Coprocessor 0-related variables are no longer in
cp0.c, the FPU is no longer incp1.c, and the global variables used as parameters to the memory accessor functions are no longer inmemory.c.Commit 3c9a3fc will definitely not build on ARM, and bbe2a26 should build, but I don't know if it works properly because I don't have an ARM device to test with.