Support older GCC and clang that lack some intrinsics

This commit is contained in:
Isaac Aronson 2023-09-06 17:17:09 -05:00 committed by Sam Lantinga
parent e8cba442c5
commit c80c540be3
3 changed files with 37 additions and 0 deletions

View file

@ -4,6 +4,8 @@
#ifdef SDL_AVX2_INTRINSICS
#define SDL_blit_A_avx2_c
#include "SDL_blit.h"
#include "SDL_blit_A_sse4_1.h"

View file

@ -4,7 +4,10 @@
#ifdef SDL_SSE4_1_INTRINSICS
#define SDL_blit_A_sse4_1_c
#include "SDL_blit.h"
#include "SDL_blit_A_sse4_1.h"
/**
* Using the SSE4.1 instruction set, blit four pixels with alpha blending

View file

@ -12,4 +12,36 @@ void SDL_TARGETING("sse4.1") BlitNtoNPixelAlpha_SSE4_1(SDL_BlitInfo *info);
#endif
/* for compatibility with older compilers: */
#if defined(SDL_blit_A_sse4_1_c) || defined(SDL_blit_A_avx2_c)
/* _mm_loadu_si64 : missing in clang < 3.9, missing in gcc < 9
* _mm_storeu_si64: missing in clang < 8.0, missing in gcc < 9
* __m128i_u type (to be used to define the missing two above):
* missing in gcc < 7, missing in clang < 9
*/
#if defined(__clang__)
#if (__clang_major__ < 9)
#define MISSING__m128i_u
#endif
#if (__clang_major__ < 8)
#define MISSING__mm_storeu_si64
#endif
#elif defined(__GNUC__)
#if (__GNUC__ < 7)
#define MISSING__m128i_u
#endif
#if (__GNUC__ < 9)
#define MISSING__mm_storeu_si64
#endif
#endif
#ifdef MISSING__m128i_u
typedef long long __m128i_u __attribute__((__vector_size__(16), __may_alias__, __aligned__(1)));
#endif
#ifdef MISSING__mm_storeu_si64
#define _mm_loadu_si64(_x) _mm_loadl_epi64((__m128i_u*)(_x))
#define _mm_storeu_si64(_x,_y) _mm_storel_epi64((__m128i_u*)(_x),(_y))
#endif
#endif /**/
#endif //SDL_SDL_BLIT_A_SSE4_1_H