chore: Changing typedef declarations to using.

This commit is contained in:
Thorben Höhne 2025-05-04 00:52:14 +02:00
parent 040c6b0e46
commit 26e2403fd7
Signed by: thoehne
GPG Key ID: 60D202D915B81DEC
3 changed files with 322 additions and 284 deletions

View File

@ -6,90 +6,85 @@
// Turn os specific types into global types. // // Turn os specific types into global types. //
// ============================================= // // ============================================= //
namespace Phanes::Core::Types namespace Phanes::Core::Types
{ {
// Specific types size // Specific types size
// //
// 8-Bit integer // 8-Bit integer
typedef int8_t int8; using int8 = int8_t;
// 16-Bit integer // 16-Bit integer
typedef int16_t int16; using int16 = int16_t;
// 32-Bit integer // 32-Bit integer
typedef int32_t int32; using int32 = int32_t;
// 64-Bit integer // 64-Bit integer
typedef int64_t int64; using int64 = int64_t;
// 8-Bit unsigned integer // 8-Bit unsigned integer
typedef uint8_t uint8; using uint8 = uint8_t;
// 16-Bit unsigned integer // 16-Bit unsigned integer
typedef uint16_t uint16; using uint16 = uint16_t;
// 32-Bit unsigned integer // 32-Bit unsigned integer
typedef uint32_t uint32; using uint32 = uint32_t;
// 64-Bit unsigned integer // 64-Bit unsigned integer
typedef uint64_t uint64; using uint64 = uint64_t;
// At least N bit types // At least N bit types
// //
// At least 8-Bit integer // At least 8-Bit integer
typedef int_least8_t lint8; using lint8 = int_least8_t;
// At least 16-Bit integer // At least 16-Bit integer
typedef int_least16_t lint16; using lint16 = int_least16_t;
// At least 32-Bit integer // At least 32-Bit integer
typedef int_least32_t lint32; using lint32 = int_least32_t;
// At least 64-Bit integer // At least 64-Bit integer
typedef int_least64_t lint64; using lint64 = int_least64_t;
// At least 8-Bit integer // At least 8-Bit integer
typedef uint_least8_t ulint8; using ulint8 = uint_least8_t;
// At least 16-Bit integer // At least 16-Bit integer
typedef uint_least16_t ulint16; using ulint16 = uint_least16_t;
// At least 32-Bit integer // At least 32-Bit integer
typedef uint_least32_t ulint32; using ulint32 = uint_least32_t;
// At least 64-Bit integer // At least 64-Bit integer
typedef uint_least64_t ulint64; using ulint64 = uint_least64_t;
// Fast N bit types // Fast N bit types
// //
// Fast 8-bit integer // Fast 8-bit integer
typedef int_fast8_t fint8; using fint8 = int_fast8_t;
// At least 16-Bit integer // At least 16-Bit integer
typedef int_fast16_t fint16; using fint16 = int_fast16_t;
// At least 32-Bit integer // At least 32-Bit integer
typedef int_fast32_t fint32; using fint32 = int_fast32_t;
// At least 64-Bit integer // At least 64-Bit integer
typedef int_fast64_t fint64; using fint64 = int_fast64_t;
// At least 8-Bit integer // At least 8-Bit integer
typedef uint_fast8_t ufint8; using ufint8 = uint_fast8_t;
// At least 16-Bit integer // At least 16-Bit integer
typedef uint_fast16_t ufint16; using ufint16 = uint_fast16_t;
// At least 32-Bit integer // At least 32-Bit integer
typedef uint_fast32_t ufint32; using ufint32 = uint_fast32_t;
// At least 64-Bit integer // At least 64-Bit integer
typedef uint_fast64_t ufint64; using ufint64 = uint_fast64_t;
} } // namespace Phanes::Core::Types

View File

@ -6,7 +6,6 @@
// Turn os specific types into global types. // // Turn os specific types into global types. //
// ============================================= // // ============================================= //
// TODO: include int128 // TODO: include int128
namespace Phanes::Core::Types namespace Phanes::Core::Types
@ -16,97 +15,91 @@ namespace Phanes::Core::Types
// MSVC specific types // MSVC specific types
typedef _FLOAT128 float128; using float128 = _FLOAT128;
#elif defined(P_LINUX_BUILD) #elif defined(P_LINUX_BUILD)
// Linux specific types // Linux specific types
typedef __float128 float128; using float128 = __float128;
#endif #endif
// Specific types size // Specific types size
// //
// 8-Bit integer // 8-Bit integer
typedef int8_t int8; using int8 = int8_t;
// 16-Bit integer // 16-Bit integer
typedef int16_t int16; using int16 = int16_t;
// 32-Bit integer // 32-Bit integer
typedef int32_t int32; using int32 = int32_t;
// 64-Bit integer // 64-Bit integer
typedef int64_t int64; using int64 = int64_t;
// 8-Bit unsigned integer // 8-Bit unsigned integer
typedef uint8_t uint8; using uint8 = uint8_t;
// 16-Bit unsigned integer // 16-Bit unsigned integer
typedef uint16_t uint16; using uint16 = uint16_t;
// 32-Bit unsigned integer // 32-Bit unsigned integer
typedef uint32_t uint32; using uint32 = uint32_t;
// 64-Bit unsigned integer // 64-Bit unsigned integer
typedef uint64_t uint64; using uint64 = uint64_t;
// At least N bit types // At least N bit types
// //
// At least 8-Bit integer // At least 8-Bit integer
typedef int_least8_t lint8; using lint8 = int_least8_t;
// At least 16-Bit integer // At least 16-Bit integer
typedef int_least16_t lint16; using lint16 = int_least16_t;
// At least 32-Bit integer // At least 32-Bit integer
typedef int_least32_t lint32; using lint32 = int_least32_t;
// At least 64-Bit integer // At least 64-Bit integer
typedef int_least64_t lint64; using lint64 = int_least64_t;
// At least 8-Bit integer // At least 8-Bit integer
typedef uint_least8_t ulint8; using ulint8 = uint_least8_t;
// At least 16-Bit integer // At least 16-Bit integer
typedef uint_least16_t ulint16; using ulint16 = uint_least16_t;
// At least 32-Bit integer // At least 32-Bit integer
typedef uint_least32_t ulint32; using ulint32 = uint_least32_t;
// At least 64-Bit integer // At least 64-Bit integer
typedef uint_least64_t ulint64; using ulint64 = uint_least64_t;
// Fast N bit types // Fast N bit types
// //
// Fast 8-bit integer // Fast 8-bit integer
typedef int_fast8_t fint8; using fint8 = int_fast8_t;
// At least 16-Bit integer // At least 16-Bit integer
typedef int_fast16_t fint16; using fint16 = int_fast16_t;
// At least 32-Bit integer // At least 32-Bit integer
typedef int_fast32_t fint32; using fint32 = int_fast32_t;
// At least 64-Bit integer // At least 64-Bit integer
typedef int_fast64_t fint64; using fint64 = int_fast64_t;
// At least 8-Bit integer // At least 8-Bit integer
typedef uint_fast8_t ufint8; using ufint8 = uint_fast8_t;
// At least 16-Bit integer // At least 16-Bit integer
typedef uint_fast16_t ufint16; using ufint16 = uint_fast16_t;
// At least 32-Bit integer // At least 32-Bit integer
typedef uint_fast32_t ufint32; using ufint32 = uint_fast32_t;
// At least 64-Bit integer // At least 64-Bit integer
typedef uint_fast64_t ufint64; using ufint64 = uint_fast64_t;
} } // namespace Phanes::Core::Types

View File

@ -4,8 +4,8 @@
// //
// ARM is not supported. // ARM is not supported.
#include "Core/Math/SIMD/Platform.h"
#include "Core/Math/MathTypes.h" #include "Core/Math/MathTypes.h"
#include "Core/Math/SIMD/Platform.h"
#if P_INTRINSICS == P_INTRINSICS_AVX2 #if P_INTRINSICS == P_INTRINSICS_AVX2
# include <immintrin.h> # include <immintrin.h>
@ -27,132 +27,128 @@ namespace Phanes::Core::Math::SIMD
/// <typeparam name="T">Type of vector</typeparam> /// <typeparam name="T">Type of vector</typeparam>
/// <typeparam name="L">Length of vector</typeparam> /// <typeparam name="L">Length of vector</typeparam>
/// <typeparam name="IsAligned">Whether the vector is aligned for simd usage.</typeparam> /// <typeparam name="IsAligned">Whether the vector is aligned for simd usage.</typeparam>
template<typename T, size_t L, bool IsAligned> template <typename T, size_t L, bool IsAligned>
struct use_simd struct use_simd
{ {
static const bool value = false; static const bool value = false;
}; };
// SSE / NEON // SSE / NEON
template<> template <>
struct use_simd<float, 4, true> struct use_simd<float, 4, true>
{ {
static const bool value = true && (P_SSE__ || P_NEON__); static const bool value = (P_SSE__ || P_NEON__);
}; };
template<> template <>
struct use_simd<float, 3, true> struct use_simd<float, 3, true>
{ {
static const bool value = true && (P_SSE__ || P_NEON__); static const bool value = (P_SSE__ || P_NEON__);
}; };
template<> template <>
struct use_simd<int, 4, true> struct use_simd<int, 4, true>
{ {
static const bool value = true && (P_SSE__ || P_NEON__); static const bool value = (P_SSE__ || P_NEON__);
}; };
template<> template <>
struct use_simd<int, 3, true> struct use_simd<int, 3, true>
{ {
static const bool value = true && (P_SSE__ || P_NEON__); static const bool value = (P_SSE__ || P_NEON__);
}; };
template<> template <>
struct use_simd<unsigned int, 4, true> struct use_simd<unsigned int, 4, true>
{ {
static const bool value = true && (P_SSE__ || P_NEON__); static const bool value = (P_SSE__ || P_NEON__);
}; };
template<> template <>
struct use_simd<unsigned int, 3, true> struct use_simd<unsigned int, 3, true>
{ {
static const bool value = true && (P_SSE__ || P_NEON__); static const bool value = (P_SSE__ || P_NEON__);
}; };
// SSE // SSE
template<> template <>
struct use_simd<double, 2, true> struct use_simd<double, 2, true>
{ {
static const bool value = true && P_SSE__; static const bool value = P_SSE__;
}; };
template<> template <>
struct use_simd<Phanes::Core::Types::int64, 2, true> struct use_simd<Phanes::Core::Types::int64, 2, true>
{ {
static const bool value = true && P_SSE__; static const bool value = P_SSE__;
}; };
template<> template <>
struct use_simd<Phanes::Core::Types::uint64, 2, true> struct use_simd<Phanes::Core::Types::uint64, 2, true>
{ {
static const bool value = true && P_SSE__; static const bool value = P_SSE__;
}; };
// AVX // AVX
template<> template <>
struct use_simd<double, 4, true> struct use_simd<double, 4, true>
{ {
static const bool value = true && P_AVX__; static const bool value = P_AVX__;
}; };
template<> template <>
struct use_simd<double, 3, true> struct use_simd<double, 3, true>
{ {
static const bool value = true && P_AVX__; static const bool value = P_AVX__;
}; };
template<> template <>
struct use_simd<float, 8, true> struct use_simd<float, 8, true>
{ {
static const bool value = true && P_AVX__; static const bool value = P_AVX__;
}; };
// AVX2 // AVX2
template<> template <>
struct use_simd<Phanes::Core::Types::int64, 4, true> struct use_simd<Phanes::Core::Types::int64, 4, true>
{ {
static const bool value = true && P_AVX2__; static const bool value = P_AVX2__;
}; };
template<> template <>
struct use_simd<Phanes::Core::Types::int64, 3, true> struct use_simd<Phanes::Core::Types::int64, 3, true>
{ {
static const bool value = true && P_AVX2__; static const bool value = P_AVX2__;
}; };
template<> template <>
struct use_simd<Phanes::Core::Types::uint64, 4, true> struct use_simd<Phanes::Core::Types::uint64, 4, true>
{ {
static const bool value = true && P_AVX2__; static const bool value = P_AVX2__;
}; };
template<> template <>
struct use_simd<Phanes::Core::Types::uint64, 3, true> struct use_simd<Phanes::Core::Types::uint64, 3, true>
{ {
static const bool value = true && P_AVX2__; static const bool value = P_AVX2__;
}; };
template<> template <>
struct use_simd<int, 8, true> struct use_simd<int, 8, true>
{ {
static const bool value = true && P_AVX2__; static const bool value = P_AVX2__;
}; };
template<> template <>
struct use_simd<unsigned int, 8, true> struct use_simd<unsigned int, 8, true>
{ {
static const bool value = true && P_AVX2__; static const bool value = P_AVX2__;
}; };
} } // namespace Phanes::Core::Math::SIMD
// Register aliases // Register aliases
namespace Phanes::Core::Types namespace Phanes::Core::Types
@ -160,69 +156,123 @@ namespace Phanes::Core::Types
#if P_INTRINSICS >= 1 #if P_INTRINSICS >= 1
typedef __m128 Vec4f32Reg; using Vec4f32Reg = __m128;
typedef __m128d Vec2f64Reg; using Vec2f64Reg = __m128d;
typedef __m128i Vec4i32Reg; using Vec4i32Reg = __m128i;
typedef __m128i Vec2i64Reg; using Vec2i64Reg = __m128i;
typedef __m128i Vec4u32Reg; using Vec4u32Reg = __m128i;
typedef __m128i Vec2u64Reg; using Vec2u64Reg = __m128i;
#elif P_INTRINSICS != P_INTRINSICS_NEON #elif P_INTRINSICS != P_INTRINSICS_NEON
typedef struct alignas(16) Vec4f32Reg { float data[4]; } Vec4f32Reg; using Vec4f32Reg = struct alignas(16) Vec4f32Reg
typedef struct alignas(16) Vec2f64Reg { double data[2]; } Vec2f64Reg; {
typedef struct alignas(16) Vec4i32Reg { int data[4]; } Vec4i32Reg; float data[4];
typedef struct alignas(16) Vec2i64Reg { Phanes::Core::Types::int64 data[2]; } Vec2i64Reg; };
typedef struct alignas(16) Vec4u32Reg { unsigned int data[4]; } Vec4u32Reg; using Vec2f64Reg = struct alignas(16) Vec2f64Reg
typedef struct alignas(16) Vec2u64Reg { Phanes::Core::Types::uint64 data[4]; } Vec2u64Reg; {
double data[2];
};
using Vec4i32Reg = struct alignas(16) Vec4i32Reg
{
int data[4];
};
using Vec2i64Reg = struct alignas(16) Vec2i64Reg
{
Phanes::Core::Types::int64 data[2];
};
using Vec4u32Reg = struct alignas(16) Vec4u32Reg
{
unsigned int data[4];
};
using Vec2u64Reg = struct alignas(16) Vec2u64Reg
{
Phanes::Core::Types::uint64 data[4];
};
#endif #endif
#if P_INTRINSICS >= 2 #if P_INTRINSICS >= 2
typedef __m256 Vec4x2f32Reg; using Vec4x2f32Reg = __m256;
typedef __m256 Vec8f32Reg; using Vec8f32Reg = __m256;
typedef __m256d Vec2x2f64Reg; using Vec2x2f64Reg = __m256d;
typedef __m256d Vec4f64Reg; using Vec4f64Reg = __m256d;
#elif P_INTRINSICS != P_INTRINSICS_NEON #elif P_INTRINSICS != P_INTRINSICS_NEON
typedef struct alignas(32) Vec4x2f32Reg { float data[8]; } Vec4x2f32Reg; using Vec4x2f32Reg = struct alignas(32) Vec4x2f32Reg
typedef struct alignas(32) Vec8f32Reg { float data[8]; } Vec8f32Reg; {
typedef struct alignas(32) Vec2x2f64Reg { double data[4]; } Vec2x2f64Reg; float data[8];
typedef struct alignas(32) Vec4f64Reg { double data[4]; } Vec4f64Reg; };
using Vec8f32Reg = struct alignas(32) Vec8f32Reg
{
float data[8];
};
using Vec2x2f64Reg = struct alignas(32) Vec2x2f64Reg
{
double data[4];
};
using Vec4f64Reg = struct alignas(32) Vec4f64Reg
{
double data[4];
};
#endif #endif
#if P_INTRINSICS == 3 #if P_INTRINSICS == 3
typedef __m256i Vec4x2i32Reg; using Vec4x2i32Reg = __m256i;
typedef __m256i Vec8i32Reg; using Vec8i32Reg;
typedef __m256i Vec2x2i64Reg; = __m256i using Vec2x2i64Reg;
typedef __m256i Vec4i64Reg; = __m256i using Vec4i64Reg;
= __m256i
typedef __m256i Vec4x2u32Reg; using Vec4x2u32Reg;
typedef __m256i Vec8u32Reg; = __m256i using Vec8u32Reg;
typedef __m256i Vec2x2u64Reg; = __m256i using Vec2x2u64Reg;
typedef __m256i Vec4u64Reg; = __m256i using Vec4u64Reg;
= __m256i
#elif P_INTRINSICS != P_INTRINSICS_NEON #elif P_INTRINSICS != P_INTRINSICS_NEON
typedef struct alignas(32) Vec4x2i32Reg { int data[8]; } Vec4x2i32Reg; using Vec4x2i32Reg = struct alignas(32) Vec4x2i32Reg
typedef struct alignas(32) Vec8i32Reg { int data[8]; } Vec8i32Reg; {
typedef struct alignas(32) Vec2x2i64Reg { Phanes::Core::Types::int64 data[4]; } Vec2x2i64Reg; int data[8];
typedef struct alignas(32) Vec4i64Reg { Phanes::Core::Types::int64 data[4]; } Vec4i64Reg; };
using Vec8i32Reg = struct alignas(32) Vec8i32Reg
{
int data[8];
};
using Vec2x2i64Reg = struct alignas(32) Vec2x2i64Reg
{
Phanes::Core::Types::int64 data[4];
};
using Vec4i64Reg = struct alignas(32) Vec4i64Reg
{
Phanes::Core::Types::int64 data[4];
};
typedef struct alignas(32) Vec4x2u32Reg { unsigned int data[8]; } Vec4x2u32Reg; using Vec4x2u32Reg = struct alignas(32) Vec4x2u32Reg
typedef struct alignas(32) Vec8u32Reg { unsigned int data[8]; } Vec8u32Reg; {
typedef struct alignas(32) Vec2x2u64Reg { Phanes::Core::Types::uint64 data[4]; } Vec2x2u64Reg; unsigned int data[8];
typedef struct alignas(32) Vec4u64Reg { Phanes::Core::Types::uint64 data[4]; } Vec4u64Reg; };
using Vec8u32Reg = struct alignas(32) Vec8u32Reg
{
unsigned int data[8];
};
using Vec2x2u64Reg = struct alignas(32) Vec2x2u64Reg
{
Phanes::Core::Types::uint64 data[4];
};
using Vec4u64Reg = struct alignas(32) Vec4u64Reg
{
Phanes::Core::Types::uint64 data[4];
};
#endif #endif
// NEON ... // NEON ...
} } // namespace Phanes::Core::Types