x86_amd.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. Copyright Charly Chevalier 2015
  3. Copyright Joel Falcou 2015
  4. Distributed under the Boost Software License, Version 1.0.
  5. (See accompanying file LICENSE_1_0.txt or copy at
  6. http://www.boost.org/LICENSE_1_0.txt)
  7. */
  8. #ifndef BOOST_PREDEF_HARDWARE_SIMD_X86_AMD_H
  9. #define BOOST_PREDEF_HARDWARE_SIMD_X86_AMD_H
  10. #include <boost/predef/version_number.h>
  11. #include <boost/predef/hardware/simd/x86_amd/versions.h>
  12. /* tag::reference[]
  13. = `BOOST_HW_SIMD_X86_AMD`
  14. The SIMD extension for x86 (AMD) (*if detected*).
  15. Version number depends on the most recent detected extension.
  16. [options="header"]
  17. |===
  18. | {predef_symbol} | {predef_version}
  19. | `+__SSE4A__+` | {predef_detection}
  20. | `+__FMA4__+` | {predef_detection}
  21. | `+__XOP__+` | {predef_detection}
  22. | `BOOST_HW_SIMD_X86` | {predef_detection}
  23. |===
  24. [options="header"]
  25. |===
  26. | {predef_symbol} | {predef_version}
  27. | `+__SSE4A__+` | BOOST_HW_SIMD_X86_SSE4A_VERSION
  28. | `+__FMA4__+` | BOOST_HW_SIMD_X86_FMA4_VERSION
  29. | `+__XOP__+` | BOOST_HW_SIMD_X86_XOP_VERSION
  30. | `BOOST_HW_SIMD_X86` | BOOST_HW_SIMD_X86
  31. |===
  32. NOTE: This predef includes every other x86 SIMD extensions and also has other
  33. more specific extensions (FMA4, XOP, SSE4a). You should use this predef
  34. instead of `BOOST_HW_SIMD_X86` to test if those specific extensions have
  35. been detected.
  36. */ // end::reference[]
  37. #define BOOST_HW_SIMD_X86_AMD BOOST_VERSION_NUMBER_NOT_AVAILABLE
  38. // AMD CPUs also use x86 architecture. We first try to detect if any AMD
  39. // specific extension are detected, if yes, then try to detect more recent x86
  40. // common extensions.
  41. #undef BOOST_HW_SIMD_X86_AMD
  42. #if !defined(BOOST_HW_SIMD_X86_AMD) && defined(__XOP__)
  43. # define BOOST_HW_SIMD_X86_AMD BOOST_HW_SIMD_X86_AMD_XOP_VERSION
  44. #endif
  45. #if !defined(BOOST_HW_SIMD_X86_AMD) && defined(__FMA4__)
  46. # define BOOST_HW_SIMD_X86_AMD BOOST_HW_SIMD_X86_AMD_FMA4_VERSION
  47. #endif
  48. #if !defined(BOOST_HW_SIMD_X86_AMD) && defined(__SSE4A__)
  49. # define BOOST_HW_SIMD_X86_AMD BOOST_HW_SIMD_X86_AMD_SSE4A_VERSION
  50. #endif
  51. #if !defined(BOOST_HW_SIMD_X86_AMD)
  52. # define BOOST_HW_SIMD_X86_AMD BOOST_VERSION_NUMBER_NOT_AVAILABLE
  53. #else
  54. // At this point, we know that we have an AMD CPU, we do need to check for
  55. // other x86 extensions to determine the final version number.
  56. # include <boost/predef/hardware/simd/x86.h>
  57. # if BOOST_HW_SIMD_X86 > BOOST_HW_SIMD_X86_AMD
  58. # undef BOOST_HW_SIMD_X86_AMD
  59. # define BOOST_HW_SIMD_X86_AMD BOOST_HW_SIMD_X86
  60. # endif
  61. # define BOOST_HW_SIMD_X86_AMD_AVAILABLE
  62. #endif
  63. #define BOOST_HW_SIMD_X86_AMD_NAME "x86 (AMD) SIMD"
  64. #endif
  65. #include <boost/predef/detail/test.h>
  66. BOOST_PREDEF_DECLARE_TEST(BOOST_HW_SIMD_X86_AMD, BOOST_HW_SIMD_X86_AMD_NAME)