Add support for BSWAP intrinsic (#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)
commitf72025c8b6d8a4fc3b4e22e2a3b6e1afeaef15ff
tree963da39e25dfd9ac91fcca84e8b78adba86b5820
parent28417584d8e98ae7eac22e92b952778f8ea94047
Add support for BSWAP intrinsic (#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.
15 files changed:
src/System.Private.CoreLib/shared/System/Buffers/Binary/Reader.cs
src/jit/codegen.h
src/jit/codegenxarch.cpp
src/jit/compiler.h
src/jit/compiler.hpp
src/jit/emitxarch.cpp
src/jit/gentree.cpp
src/jit/gtlist.h
src/jit/importer.cpp
src/jit/instrsxarch.h
src/jit/namedintrinsiclist.h
src/jit/optcse.cpp
tests/src/JIT/Intrinsics/BinaryPrimitivesReverseEndianness.cs [new file with mode: 0644]
tests/src/JIT/Intrinsics/BinaryPrimitivesReverseEndianness_r.csproj [new file with mode: 0644]
tests/src/JIT/Intrinsics/BinaryPrimitivesReverseEndianness_ro.csproj [new file with mode: 0644]