SDL_intrin.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. #ifndef SDL_intrin_h_
  19. #define SDL_intrin_h_
  20. #include <SDL3/SDL_stdinc.h>
  21. /* Need to do this here because intrin.h has C++ code in it */
  22. /* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */
  23. #if defined(_MSC_VER) && (_MSC_VER >= 1500) && (defined(_M_IX86) || defined(_M_X64))
  24. #ifdef __clang__
  25. /* As of Clang 11, '_m_prefetchw' is conflicting with the winnt.h's version,
  26. so we define the needed '_m_prefetch' here as a pseudo-header, until the issue is fixed. */
  27. #ifndef __PRFCHWINTRIN_H
  28. #define __PRFCHWINTRIN_H
  29. static __inline__ void __attribute__((__always_inline__, __nodebug__))
  30. _m_prefetch(void *__P)
  31. {
  32. __builtin_prefetch (__P, 0, 3 /* _MM_HINT_T0 */);
  33. }
  34. #endif /* __PRFCHWINTRIN_H */
  35. #endif /* __clang__ */
  36. #include <intrin.h>
  37. #ifndef _WIN64
  38. #ifndef __MMX__
  39. #define __MMX__
  40. #endif
  41. #ifndef __3dNOW__
  42. #define __3dNOW__
  43. #endif
  44. #endif
  45. #ifndef __SSE__
  46. #define __SSE__
  47. #endif
  48. #ifndef __SSE2__
  49. #define __SSE2__
  50. #endif
  51. #ifndef __SSE3__
  52. #define __SSE3__
  53. #endif
  54. #elif defined(__MINGW64_VERSION_MAJOR)
  55. #include <intrin.h>
  56. #if !defined(SDL_DISABLE_ARM_NEON_H) && defined(__ARM_NEON)
  57. # include <arm_neon.h>
  58. #endif
  59. #else
  60. /* altivec.h redefining bool causes a number of problems, see bugs 3993 and 4392, so you need to explicitly define SDL_ENABLE_ALTIVEC_H to have it included. */
  61. #if defined(HAVE_ALTIVEC_H) && defined(__ALTIVEC__) && !defined(__APPLE_ALTIVEC__) && defined(SDL_ENABLE_ALTIVEC_H)
  62. #include <altivec.h>
  63. #endif
  64. #if !defined(SDL_DISABLE_ARM_NEON_H)
  65. # if defined(__ARM_NEON)
  66. # include <arm_neon.h>
  67. # elif defined(__WINDOWS__) || defined(__WINRT__) || defined(__GDK__)
  68. /* Visual Studio doesn't define __ARM_ARCH, but _M_ARM (if set, always 7), and _M_ARM64 (if set, always 1). */
  69. # if defined(_M_ARM)
  70. # include <armintr.h>
  71. # include <arm_neon.h>
  72. # define __ARM_NEON 1 /* Set __ARM_NEON so that it can be used elsewhere, at compile time */
  73. # endif
  74. # if defined (_M_ARM64)
  75. # include <arm64intr.h>
  76. # include <arm64_neon.h>
  77. # define __ARM_NEON 1 /* Set __ARM_NEON so that it can be used elsewhere, at compile time */
  78. # define __ARM_ARCH 8
  79. # endif
  80. # endif
  81. #endif
  82. #endif /* compiler version */
  83. #if defined(__3dNOW__) && !defined(SDL_DISABLE_MM3DNOW_H)
  84. #include <mm3dnow.h>
  85. #endif
  86. #if defined(__loongarch_sx) && !defined(SDL_DISABLE_LSX_H)
  87. #include <lsxintrin.h>
  88. #define __LSX__
  89. #endif
  90. #if defined(__loongarch_asx) && !defined(SDL_DISABLE_LASX_H)
  91. #include <lasxintrin.h>
  92. #define __LASX__
  93. #endif
  94. #if defined(HAVE_IMMINTRIN_H) && !defined(SDL_DISABLE_IMMINTRIN_H)
  95. #include <immintrin.h>
  96. #else
  97. #if defined(__MMX__) && !defined(SDL_DISABLE_MMINTRIN_H)
  98. #include <mmintrin.h>
  99. #endif
  100. #if defined(__SSE__) && !defined(SDL_DISABLE_XMMINTRIN_H)
  101. #include <xmmintrin.h>
  102. #endif
  103. #if defined(__SSE2__) && !defined(SDL_DISABLE_EMMINTRIN_H)
  104. #include <emmintrin.h>
  105. #endif
  106. #if defined(__SSE3__) && !defined(SDL_DISABLE_PMMINTRIN_H)
  107. #include <pmmintrin.h>
  108. #endif
  109. #endif /* HAVE_IMMINTRIN_H */
  110. #endif /* SDL_intrin_h_ */
  111. /* vi: set ts=4 sw=4 expandtab: */