From b292e58ee458c56be189196305a099b7e60ee623 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 25 Oct 2021 14:01:07 +0100 Subject: [PATCH] Experimental automatic builtins for algorithms --- .../etl/profiles/determine_builtin_support.h | 92 ++++++++++++++++--- 1 file changed, 78 insertions(+), 14 deletions(-) diff --git a/include/etl/profiles/determine_builtin_support.h b/include/etl/profiles/determine_builtin_support.h index ad16a70d..39f22d29 100644 --- a/include/etl/profiles/determine_builtin_support.h +++ b/include/etl/profiles/determine_builtin_support.h @@ -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