hbintrinsics.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /**
  2. * @file hbintrinsics.h
  3. * @brief Cross-platform intrinsics inclusion header
  4. *
  5. * $LicenseInfo:firstyear=2024&license=viewergpl$
  6. *
  7. * Copyright (c) 2024, Henri Beauchamp.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_HBINTRINSICS_H
  33. #define LL_HBINTRINSICS_H
  34. // This header file is automatically included (via linden_common.h) by all
  35. // *.cpp modules, and may be included as need be from header files using
  36. // inlined intrinsics functions.
  37. // This header also defines LL_SS* to 1 when the compiler is set to generate
  38. // the corresponding intrinsic types: these defines shall be tested instead
  39. // of the __SS*__ ones in the corresponding optimized parts of the viewer code,
  40. // since the MSVC compiler and ARM64 achictectures lack the gcc/clang x86_64
  41. // defines while perhaps able to use these optimizations.
  42. // Note that SSE2 support is a prerequisite for the viewer, so you do not need
  43. // to test for anything before using SSE or SSE2 intrinsics in your code.
  44. // The __AVX*__ defines can be used "as is" (for now, and until sse2neon.h
  45. // implements support for AVX intrinsics).
  46. #if SSE2NEON
  47. # define SSE2NEON_ALLOC_DEFINED
  48. # include "sse2neon.h"
  49. // sse2non offers most SSE* equivalent intrinsics, but for now lacks AVX ones.
  50. # define LL_SSE3 1
  51. # define LL_SSSE3 1
  52. # define LL_SSE41 1
  53. # define LL_SSE42 1
  54. #elif !defined(__clang__) && (defined(__MSVC_VER__) || defined(_MSC_VER))
  55. # include <immintrin.h>
  56. // Note: MSVC does not define any of __SS*__
  57. // We define __SSE__ and __SSE2__ here (since all viewer builds are now 64 bits
  58. // ones and therefore always got both), but we do not really care as far as
  59. // actual optimizations are concerned: the only place where they are tested is
  60. // in llfloaterabout.cpp to display what maths intrinsics have been generated
  61. // by the compiler itself (and the MSVC build options do include SSE2 maths
  62. // generation).
  63. # ifndef __SSE__
  64. # define __SSE__ 1
  65. # endif
  66. # ifndef __SSE2__
  67. # define __SSE2__ 1
  68. # endif
  69. // When AVX is here, so should be SS(S)E 3 and SSE 4...
  70. # if defined(__AVX__)
  71. # define __SSE3__ 1
  72. # define __SSSE3__ 1
  73. # define __SSE4_1__ 1
  74. # define __SSE4_2__ 1
  75. # define __SSE4A__ 1
  76. # endif
  77. #else
  78. # include <immintrin.h>
  79. #endif
  80. #if defined(__SSE3__)
  81. # define LL_SSE3 1
  82. #endif
  83. #if defined(__SSSE3__)
  84. # define LL_SSSE3 1
  85. #endif
  86. #if defined(__SSE4_1__)
  87. # define LL_SSE41 1
  88. #endif
  89. #if defined(__SSE4_2__)
  90. # define LL_SSE42 1
  91. #endif
  92. #if defined(__SSE4A__)
  93. # define LL_SSE4A 1
  94. #endif
  95. #endif // LL_HBINTRINSICS_H