citra-emu
Go to file
Lioncash b8d43d4dfb common/swap: Improve codegen of the default swap fallbacks
Uses arithmetic that can be identified more trivially by compilers for
optimizations. e.g. Rather than shifting the halves of the value and
then swapping and combining them, we can swap them in place.

e.g. for the original swap32 code on x86-64, clang 8.0 would generate:

    mov     ecx, edi
    rol     cx, 8
    shl     ecx, 16
    shr     edi, 16
    rol     di, 8
    movzx   eax, di
    or      eax, ecx
    ret

while GCC 8.3 would generate the ideal:

    mov     eax, edi
    bswap   eax
    ret

now both generate the same optimal output.

MSVC used to generate the following with the old code:

    mov     eax, ecx
    rol     cx, 8
    shr     eax, 16
    rol     ax, 8
    movzx   ecx, cx
    movzx   eax, ax
    shl     ecx, 16
    or      eax, ecx
    ret     0

Now MSVC also generates a similar, but equally optimal result as clang/GCC:

    bswap   ecx
    mov     eax, ecx
    ret     0

====

In the swap64 case, for the original code, clang 8.0 would generate:

    mov     eax, edi
    bswap   eax
    shl     rax, 32
    shr     rdi, 32
    bswap   edi
    or      rax, rdi
    ret

(almost there, but still missing the mark)

while, again, GCC 8.3 would generate the more ideal:

    mov     rax, rdi
    bswap   rax
    ret

now clang also generates the optimal sequence for this fallback as well.

This is a case where MSVC unfortunately falls short, despite the new
code, this one still generates a doozy of an output.

    mov     r8, rcx
    mov     r9, rcx
    mov     rax, 71776119061217280
    mov     rdx, r8
    and     r9, rax
    and     edx, 65280
    mov     rax, rcx
    shr     rax, 16
    or      r9, rax
    mov     rax, rcx
    shr     r9, 16
    mov     rcx, 280375465082880
    and     rax, rcx
    mov     rcx, 1095216660480
    or      r9, rax
    mov     rax, r8
    and     rax, rcx
    shr     r9, 16
    or      r9, rax
    mov     rcx, r8
    mov     rax, r8
    shr     r9, 8
    shl     rax, 16
    and     ecx, 16711680
    or      rdx, rax
    mov     eax, -16777216
    and     rax, r8
    shl     rdx, 16
    or      rdx, rcx
    shl     rdx, 16
    or      rax, rdx
    shl     rax, 8
    or      rax, r9
    ret     0

which is pretty unfortunate.
2019-04-15 17:56:16 +02:00
.appveyor appveyor: Generate PDBs for mingw build 2018-03-27 11:57:34 +01:00
.github ISSUE_TEMPLATE: also ask for a log file 2019-03-05 13:03:06 +01:00
.travis Merge pull request #4125 from ccawley2011/travis-ninja 2019-03-23 23:15:00 -04:00
CMakeModules android: set up cmake 2018-11-20 14:24:19 -05:00
dist Scripting: reimplement protocol over plan UDP using boost::asio 2019-02-02 15:25:23 -05:00
externals archive_ncch: add open source mii archive 2019-03-09 08:19:32 -05:00
hooks hook: remove clang-format check 2017-02-17 13:52:23 +02:00
src common/swap: Improve codegen of the default swap fallbacks 2019-04-15 17:56:16 +02:00
.gitattributes Meta: Add gitattributes file 2018-09-22 14:59:15 -06:00
.gitignore Flatpak support (#4383) 2018-11-07 21:33:36 -05:00
.gitmodules Remove libzmq submodule 2019-02-02 15:25:23 -05:00
.travis.yml Merge pull request #4129 from ccawley2011/clang-format-docker 2018-12-02 07:57:42 +08:00
CMakeLists.txt fix clang-format target when using a path with spaces on windows 2019-04-02 21:02:43 -04:00
CONTRIBUTING.md CONTRIBUTING.md: migrate to the wiki 2018-11-08 00:15:55 -05:00
Doxyfile Remove every trailing whitespace from the project (but externals). 2015-05-29 21:59:29 +01:00
README.md update CONTRIBUTING link 2018-12-24 19:43:35 -05:00
appveyor.yml audio_core: dsp_hle: add Media Foundation decoder... 2019-02-09 11:56:51 +01:00
bitrise.yml android: set up cmake 2018-11-20 14:24:19 -05:00
keys.tar.enc Flatpak support (#4383) 2018-11-07 21:33:36 -05:00
license.txt citra_qt/multiplayer: Add user ping support 2018-12-15 11:03:35 +08:00

README.md

BEFORE FILING AN ISSUE, READ THE RELEVANT SECTION IN THE CONTRIBUTING FILE!!!

Citra

Travis CI Build Status AppVeyor CI Build Status Bitrise CI Build Status

Citra is an experimental open-source Nintendo 3DS emulator/debugger written in C++. It is written with portability in mind, with builds actively maintained for Windows, Linux and macOS.

Citra emulates a subset of 3DS hardware and therefore is useful for running/debugging homebrew applications, and it is also able to run many commercial games! Some of these do not run at a playable state, but we are working every day to advance the project forward. (Playable here means compatibility of at least "Okay" on our game compatibility list.)

Citra is licensed under the GPLv2 (or any later version). Refer to the license.txt file included. Please read the FAQ before getting started with the project.

Check out our website!

For development discussion, please join us at #citra-dev on freenode.

Development

Most of the development happens on GitHub. It's also where our central repository is hosted.

If you want to contribute please take a look at the Contributor's Guide and Developer Information. You should as well contact any of the developers in the forum in order to know about the current state of the emulator because the TODO list isn't maintained anymore.

If you want to contribute to the user interface translation, please checkout citra project on transifex. We centralize the translation work there, and periodically upstream translation.

Building

Support

We happily accept monetary donations or donated games and hardware. Please see our donations page for more information on how you can contribute to Citra. Any donations received will go towards things like:

  • 3DS consoles for developers to explore the hardware
  • 3DS games for testing
  • Any equipment required for homebrew
  • Infrastructure setup
  • Eventually 3D displays to get proper 3D output working

We also more than gladly accept used 3DS consoles, preferably ones with firmware 4.5 or lower! If you would like to give yours away, don't hesitate to join our IRC channel #citra on Freenode and talk to neobrain or bunnei. Mind you, IRC is slow-paced, so it might be a while until people reply. If you're in a hurry you can just leave contact details in the channel or via private message and we'll get back to you.