Skip to content

Commit 3a90d73

Browse files
author
Julian LALU
committed
Merge branch 'main' of https://github.com/HUD-Software/core
2 parents f905185 + 3d6ebda commit 3a90d73

25 files changed

Lines changed: 920 additions & 718 deletions

interface/core/assert.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ namespace hud
1313
*/
1414
static constexpr void check([[maybe_unused]] const bool condition) noexcept
1515
{
16-
if (!hud::is_constant_evaluated())
16+
if consteval
17+
{
18+
}
19+
else
1720
{
1821
if constexpr (hud::compilation::is_assertion_enabled())
1922
{
@@ -24,7 +27,11 @@ namespace hud
2427
}
2528
}
2629
}
27-
2830
} // namespace hud
2931

32+
#if HUD_ASSERTION_ENABLED
33+
#define HUD_CHECK(condition) hud::check(condition);
34+
#else
35+
#define HUD_CHECK(condition)
36+
#endif
3037
#endif // HD_INC_CORE_ASSERT_H

interface/core/compilation.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
#define HD_INC_CORE_COMPILATION_H
33
#include "defines.h"
44

5+
#ifndef HUD_ASSERTION_ENABLED
6+
#if defined(HD_DEBUG) || defined(HD_DEBUGOPTIMIZED)
7+
#define HUD_ASSERTION_ENABLED 1
8+
#else
9+
#define HUD_ASSERTION_ENABLED 0
10+
#endif
11+
#endif
12+
513
namespace hud
614
{
715

@@ -174,11 +182,7 @@ namespace hud
174182
/** Retrieves if the assertion are enabled. */
175183
static constexpr bool is_assertion_enabled() noexcept
176184
{
177-
#if defined(HD_DEBUG) || defined(HD_DEBUGOPTIMIZED)
178-
return true;
179-
#else
180-
return false;
181-
#endif
185+
return HUD_ASSERTION_ENABLED == 1;
182186
}
183187

184188
/** Retrieves the endianness of scalar types. */

interface/core/compiler_defines.h

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ __arm__. If defined, you can further check:
4444
__powerpc64__
4545
__aarch64__
4646
47+
---- To check SIMD
48+
MSVC :
49+
AVX-512 __AVX512F__
50+
AVX2 __AVX2__
51+
AVX __AVX__
52+
SSE2 _M_IX86_FP == 2
53+
SSE _M_IX86_FP == 1
54+
Clang :
55+
AVX-512 __AVX512F__
56+
AVX2 __AVX2__
57+
AVX __AVX__
58+
SSE2 __SSE__
59+
SSE __SSE2__
4760
*/
4861

4962
/** Detect target OS */
@@ -180,4 +193,54 @@ static_assert(sizeof(void *) == 8, "HD_TARGET_64_BITS is defined but size of poi
180193
#error Target should be 32 bits or 64 bits
181194
#endif
182195

196+
/** Detect SIMD
197+
- MSVC :
198+
// MSVC only defines macros for x86 32-bit code
199+
// All x86-64 processors support SSE2, so support can be assumed.
200+
// https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros
201+
AVX-512 __AVX512F__
202+
AVX2 __AVX2__
203+
AVX __AVX__
204+
SSE2 _M_IX86_FP == 2
205+
SSE _M_IX86_FP == 1
206+
- Clang, GCC:
207+
AVX-512 __AVX512F__
208+
AVX2 __AVX2__
209+
AVX __AVX__
210+
SSE2 __SSE2__
211+
SSE __SSE__
212+
*/
213+
214+
#if defined(__AVX512F__)
215+
#define HD_AVX512 1
216+
#else
217+
#define HD_AVX512 0
218+
#endif
219+
#if defined(__AVX2__)
220+
#define HD_AVX2 1
221+
#else
222+
#define HD_AVX2 0
223+
#endif
224+
#if defined(__AVX__)
225+
#define HD_AVX 1
226+
#else
227+
#define HD_AVX 0
228+
#endif
229+
#if defined(__SSE2__)
230+
#define HD_SSE2 1
231+
#else
232+
#define HD_SSE2 0
233+
#endif
234+
#if defined(__SSE__)
235+
#define HD_SSE 1
236+
#else
237+
#define HD_SSE 0
238+
#endif
239+
240+
#if defined(__SSSE3__)
241+
#define HD_SSSE3 1
242+
#else
243+
#define HD_SSSE3 0
244+
#endif
245+
183246
#endif // HD_INC_CORE_COMPILER_DEFINES_H

0 commit comments

Comments
 (0)