Debian Codegraph @

Source/Core/Common/Intrinsics.h

raw symbols SCIP
1 // Copyright 2015 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #pragma once
5
6 #if defined(_M_X86_64)
7
8 /**
9 * It is assumed that all compilers used to build Dolphin support intrinsics up to and including
10 * SSE 4.2 on x86/x64.
11 */
12
13 #if defined(__GNUC__) || defined(__clang__)
14
15 /**
16 * Due to limitations in GCC, SSE intrinsics are only available when compiling with the
17 * corresponding instruction set enabled. However, using the target attribute, we can compile
18 * single functions with a different target instruction set, while still creating a generic build.
19 *
20 * Since this instruction set is enabled per-function, any callers should verify that the
21 * instruction set is supported at runtime before calling it, and provide a fallback implementation
22 * when not supported.
23 *
24 * When building with -march=native, or enabling the instruction sets in the compile flags, permit
25 * usage of the intrinsics without any function attributes. If the command-line architecture does
26 * not support this instruction set, enable it via function targeting.
27 */
28
29 #include <x86intrin.h>
30 #ifndef __SSE4_2__
31 #define FUNCTION_TARGET_SSE42 [[gnu::target("sse4.2")]]
32 #endif
33 #ifndef __SSE4_1__
34 #define FUNCTION_TARGET_SSR41 [[gnu::target("sse4.1")]]
35 #endif
36 #ifndef __SSSE3__
37 #define FUNCTION_TARGET_SSSE3 [[gnu::target("ssse3")]]
38 #endif
39 #ifndef __SSE3__
40 #define FUNCTION_TARGET_SSE3 [[gnu::target("sse3")]]
41 #endif
42
43 #elif defined(_MSC_VER) || defined(__INTEL_COMPILER)
44
45 /**
46 * MSVC and ICC support intrinsics for any instruction set without any function attributes.
47 */
48 #include <intrin.h>
49
50 #endif // defined(_MSC_VER) || defined(__INTEL_COMPILER)
51
52 #endif // _M_X86_64
53
54 /**
55 * Define the FUNCTION_TARGET macros to nothing if they are not needed, or not on an X86 platform.
56 * This way when a function is defined with FUNCTION_TARGET you don't need to define a second
57 * version without the macro around a #ifdef guard. Be careful when using intrinsics, as all use
58 * should still be placed around a #ifdef _M_X86_64 if the file is compiled on all architectures.
59 */
60 #ifndef FUNCTION_TARGET_SSE42
61 #define FUNCTION_TARGET_SSE42
62 #endif
63 #ifndef FUNCTION_TARGET_SSR41
64 #define FUNCTION_TARGET_SSR41
65 #endif
66 #ifndef FUNCTION_TARGET_SSSE3
67 #define FUNCTION_TARGET_SSSE3
68 #endif
69 #ifndef FUNCTION_TARGET_SSE3
70 #define FUNCTION_TARGET_SSE3
71 #endif