Add support for BSWAP intrinsic (dotnet/coreclr#18398)
authorLevi Broderick <GrabYourPitchforks@users.noreply.github.com>
Tue, 6 Nov 2018 00:06:32 +0000 (16:06 -0800)
committerGitHub <noreply@github.com>
Tue, 6 Nov 2018 00:06:32 +0000 (16:06 -0800)
commitaaec6a70a961652d4b5eb942d5053ac72737f678
treec6e65604df9357b2627dd8565d726e185335a058
parent7a5da6d46e61a5a8c1c64b36608394da341fcd7b
Add support for BSWAP intrinsic (dotnet/coreclr#18398)

With this change, the JIT will recognize a call to BinaryPrimitives.ReverseEndianness and will emit a bswap instruction.
This logic is currently only hooked up for x86 and x64; ARM still uses fallback logic.
If the JIT can't emit a bswap instruction (for example, trying to emit a 64-bit bswap in a 32-bit process), it will fall back to a software implementation, so the APIs will work across all architectures.

Commit migrated from https://github.com/dotnet/coreclr/commit/f72025c8b6d8a4fc3b4e22e2a3b6e1afeaef15ff
15 files changed:
src/coreclr/src/jit/codegen.h
src/coreclr/src/jit/codegenxarch.cpp
src/coreclr/src/jit/compiler.h
src/coreclr/src/jit/compiler.hpp
src/coreclr/src/jit/emitxarch.cpp
src/coreclr/src/jit/gentree.cpp
src/coreclr/src/jit/gtlist.h
src/coreclr/src/jit/importer.cpp
src/coreclr/src/jit/instrsxarch.h
src/coreclr/src/jit/namedintrinsiclist.h
src/coreclr/src/jit/optcse.cpp
src/coreclr/tests/src/JIT/Intrinsics/BinaryPrimitivesReverseEndianness.cs [new file with mode: 0644]
src/coreclr/tests/src/JIT/Intrinsics/BinaryPrimitivesReverseEndianness_r.csproj [new file with mode: 0644]
src/coreclr/tests/src/JIT/Intrinsics/BinaryPrimitivesReverseEndianness_ro.csproj [new file with mode: 0644]
src/libraries/System.Private.CoreLib/src/System/Buffers/Binary/Reader.cs