Experimental automatic builtins for algorithms

This commit is contained in:
John Wellbelove 2021-10-25 14:01:07 +01:00
parent 43b041cbfb
commit b292e58ee4

View File

@ -31,7 +31,48 @@ SOFTWARE.
#ifndef ETL_DETERMINE_BUILTIN_SUPPORT_H_INCLUDED
#define ETL_DETERMINE_BUILTIN_SUPPORT_H_INCLUDED
#if defined(__has_builtin)
#if defined(ETL_USE_MEM_BUILTINS) // Set all of them to be true if not already defined
#if !defined(ETL_USE_BUILTIN_MEMCMP)
#define ETL_USE_BUILTIN_MEMCMP 1
#endif
#if !defined(ETL_USE_BUILTIN_MEMMOVE)
#define ETL_USE_BUILTIN_MEMMOVE 1
#endif
#if !defined(ETL_USE_BUILTIN_MEMSET)
#define ETL_USE_BUILTIN_MEMSET 1
#endif
#endif
#if defined(ETL_USE_TYPE_TRAITS_BUILTINS) // Set all of them to be true if not already defined
#if !defined(ETL_USE_BUILTIN_IS_ASSIGNABLE)
#define ETL_USE_BUILTIN_IS_ASSIGNABLE 1
#endif
#if !defined(ETL_USE_BUILTIN_IS_CONSTRUCTIBLE)
#define ETL_USE_BUILTIN_IS_CONSTRUCTIBLE 1
#endif
#if !defined(ETL_USE_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE)
#define ETL_USE_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE 1
#endif
#if !defined(ETL_USE_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE)
#define ETL_USE_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE 1
#endif
#if !defined(ETL_USE_BUILTIN_IS_TRIVIALLY_COPYABLE)
#define ETL_USE_BUILTIN_IS_TRIVIALLY_COPYABLE 1
#endif
#endif
#if defined(__has_builtin) && (!defined(ETL_USE_MEM_BUILTINS) || !defined(ETL_USE_TYPE_TRAITS_BUILTINS)) // Use __has_builtin to check for existence of builtin functions, if not already defined
#if !defined(ETL_USE_BUILTIN_MEMCMP)
#define ETL_USE_BUILTIN_MEMCMP __has_builtin(__builtin_memcmp)
#endif
@ -48,24 +89,26 @@ SOFTWARE.
#define ETL_USE_BUILTIN_IS_ASSIGNABLE __has_builtin(__is_assignable)
#endif
#if !defined(ETL_USE_BUILTIN_IS_CONSTRUCTIBLE)
#define ETL_USE_BUILTIN_IS_CONSTRUCTIBLE __has_builtin(__is_constructible)
#endif
#if !defined(ETL_USE_BUILTIN_IS_CONSTRUCTIBLE)
#define ETL_USE_BUILTIN_IS_CONSTRUCTIBLE __has_builtin(__is_constructible)
#endif
#if !defined(ETL_USE_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE)
#define ETL_USE_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE (__has_builtin(__has_trivial_constructor) || __has_builtin(__is_trivially_constructible))
#endif
#if !defined(ETL_USE_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE)
#define ETL_USE_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE (__has_builtin(__has_trivial_constructor) || __has_builtin(__is_trivially_constructible))
#endif
#if !defined(ETL_USE_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE)
#define ETL_USE_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE (__has_builtin(__has_trivial_destructor) || __has_builtin(__is_trivially_destructible))
#endif
__has_trivial_destructor
__is_trivially_destructible
#if !defined(ETL_USE_BUILTIN_IS_TRIVIALLY_COPYABLE)
#define ETL_USE_BUILTIN_IS_TRIVIALLY_COPYABLE (__has_builtin(__has_trivial_copy) || __has_builtin(__is_trivially_copyable))
#endif
__has_trivial_copy
__is_trivially_copyable
#if !defined(__has_builtin) && !defined(ETL_USE_MEM_BUILTINS) && !defined(ETL_USE_TYPE_TRAITS_BUILTINS) // Set all of them to be false if not already defined
#else
#if !defined(ETL_USE_BUILTIN_MEMCMP)
#define ETL_USE_BUILTIN_MEMCMP 0
#define ETL_USE_BUILTIN_MEMCMP 0
#endif
#if !defined(ETL_USE_BUILTIN_MEMMOVE)
@ -73,8 +116,29 @@ __is_trivially_copyable
#endif
#if !defined(ETL_USE_BUILTIN_MEMSET)
#define ETL_USE_BUILTIN_MEMSET 0
#define ETL_USE_BUILTIN_MEMSET 0
#endif
#if !defined(ETL_USE_BUILTIN_IS_ASSIGNABLE)
#define ETL_USE_BUILTIN_IS_ASSIGNABLE 0
#endif
#if !defined(ETL_USE_BUILTIN_IS_CONSTRUCTIBLE)
#define ETL_USE_BUILTIN_IS_CONSTRUCTIBLE 0
#endif
#if !defined(ETL_USE_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE)
#define ETL_USE_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE 0
#endif
#if !defined(ETL_USE_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE)
#define ETL_USE_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE 0
#endif
#if !defined(ETL_USE_BUILTIN_IS_TRIVIALLY_COPYABLE)
#define ETL_USE_BUILTIN_IS_TRIVIALLY_COPYABLE 0
#endif
#endif
#endif