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
Engine/Source/Runtime/Core

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

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

@ -1,158 +1,154 @@
#pragma once
// This file includes the necessary header for vectorization intrinsics. If no specifics are defined SSE4.2 is used.
//
//
// ARM is not supported.
#include "Core/Math/SIMD/Platform.h"
#include "Core/Math/MathTypes.h"
#include "Core/Math/SIMD/Platform.h"
#if P_INTRINSICS == P_INTRINSICS_AVX2
# include <immintrin.h>
# include <immintrin.h>
#elif P_INTRINSICS == P_INTRINSICS_AVX
# include <immintrin.h>
# include <immintrin.h>
#elif P_INTRINSICS == P_INTRINSICS_SSE
# include <nmmintrin.h>
# include <nmmintrin.h>
#elif P_INTRINSICS == P_INTRINSICS_NEON
# include "neon.h" // <- Not supported
# include "neon.h" // <- Not supported
#endif
// use_simd for metaprogramming
namespace Phanes::Core::Math::SIMD
{
/// <summary>
/// This decides, whether simd operations should be used, based on the vector type, it's size, the vector alignment and whether the right extension can be loaded during compiletime.
/// </summary>
/// <typeparam name="T">Type of vector</typeparam>
/// <typeparam name="L">Length of vector</typeparam>
/// <typeparam name="IsAligned">Whether the vector is aligned for simd usage.</typeparam>
template<typename T, size_t L, bool IsAligned>
struct use_simd
{
static const bool value = false;
};
/// <summary>
/// This decides, whether simd operations should be used, based on the vector type, it's size, the vector alignment and whether the right extension can be loaded during compiletime.
/// </summary>
/// <typeparam name="T">Type of vector</typeparam>
/// <typeparam name="L">Length of vector</typeparam>
/// <typeparam name="IsAligned">Whether the vector is aligned for simd usage.</typeparam>
template <typename T, size_t L, bool IsAligned>
struct use_simd
{
static const bool value = false;
};
// SSE / NEON
// SSE / NEON
template<>
struct use_simd<float, 4, true>
{
static const bool value = true && (P_SSE__ || P_NEON__);
};
template <>
struct use_simd<float, 4, true>
{
static const bool value = (P_SSE__ || P_NEON__);
};
template<>
struct use_simd<float, 3, true>
{
static const bool value = true && (P_SSE__ || P_NEON__);
};
template <>
struct use_simd<float, 3, true>
{
static const bool value = (P_SSE__ || P_NEON__);
};
template<>
struct use_simd<int, 4, true>
{
static const bool value = true && (P_SSE__ || P_NEON__);
};
template <>
struct use_simd<int, 4, true>
{
static const bool value = (P_SSE__ || P_NEON__);
};
template<>
struct use_simd<int, 3, true>
{
static const bool value = true && (P_SSE__ || P_NEON__);
};
template <>
struct use_simd<int, 3, true>
{
static const bool value = (P_SSE__ || P_NEON__);
};
template<>
struct use_simd<unsigned int, 4, true>
{
static const bool value = true && (P_SSE__ || P_NEON__);
};
template <>
struct use_simd<unsigned int, 4, true>
{
static const bool value = (P_SSE__ || P_NEON__);
};
template<>
struct use_simd<unsigned int, 3, true>
{
static const bool value = true && (P_SSE__ || P_NEON__);
};
template <>
struct use_simd<unsigned int, 3, true>
{
static const bool value = (P_SSE__ || P_NEON__);
};
// SSE
// SSE
template<>
struct use_simd<double, 2, true>
{
static const bool value = true && P_SSE__;
};
template <>
struct use_simd<double, 2, true>
{
static const bool value = P_SSE__;
};
template<>
struct use_simd<Phanes::Core::Types::int64, 2, true>
{
static const bool value = true && P_SSE__;
};
template <>
struct use_simd<Phanes::Core::Types::int64, 2, true>
{
static const bool value = P_SSE__;
};
template<>
struct use_simd<Phanes::Core::Types::uint64, 2, true>
{
static const bool value = true && P_SSE__;
};
template <>
struct use_simd<Phanes::Core::Types::uint64, 2, true>
{
static const bool value = P_SSE__;
};
// AVX
template <>
struct use_simd<double, 4, true>
{
static const bool value = P_AVX__;
};
// AVX
template <>
struct use_simd<double, 3, true>
{
static const bool value = P_AVX__;
};
template<>
struct use_simd<double, 4, true>
{
static const bool value = true && P_AVX__;
};
template <>
struct use_simd<float, 8, true>
{
static const bool value = P_AVX__;
};
template<>
struct use_simd<double, 3, true>
{
static const bool value = true && P_AVX__;
};
// AVX2
template<>
struct use_simd<float, 8, true>
{
static const bool value = true && P_AVX__;
};
template <>
struct use_simd<Phanes::Core::Types::int64, 4, true>
{
static const bool value = P_AVX2__;
};
template <>
struct use_simd<Phanes::Core::Types::int64, 3, true>
{
static const bool value = P_AVX2__;
};
// AVX2
template <>
struct use_simd<Phanes::Core::Types::uint64, 4, true>
{
static const bool value = P_AVX2__;
};
template<>
struct use_simd<Phanes::Core::Types::int64, 4, true>
{
static const bool value = true && P_AVX2__;
};
template <>
struct use_simd<Phanes::Core::Types::uint64, 3, true>
{
static const bool value = P_AVX2__;
};
template<>
struct use_simd<Phanes::Core::Types::int64, 3, true>
{
static const bool value = true && P_AVX2__;
};
template <>
struct use_simd<int, 8, true>
{
static const bool value = P_AVX2__;
};
template<>
struct use_simd<Phanes::Core::Types::uint64, 4, true>
{
static const bool value = true && P_AVX2__;
};
template<>
struct use_simd<Phanes::Core::Types::uint64, 3, true>
{
static const bool value = true && P_AVX2__;
};
template<>
struct use_simd<int, 8, true>
{
static const bool value = true && P_AVX2__;
};
template<>
struct use_simd<unsigned int, 8, true>
{
static const bool value = true && P_AVX2__;
};
}
template <>
struct use_simd<unsigned int, 8, true>
{
static const bool value = P_AVX2__;
};
} // namespace Phanes::Core::Math::SIMD
// Register aliases
namespace Phanes::Core::Types
@ -160,69 +156,123 @@ namespace Phanes::Core::Types
#if P_INTRINSICS >= 1
typedef __m128 Vec4f32Reg;
typedef __m128d Vec2f64Reg;
using Vec4f32Reg = __m128;
using Vec2f64Reg = __m128d;
typedef __m128i Vec4i32Reg;
typedef __m128i Vec2i64Reg;
using Vec4i32Reg = __m128i;
using Vec2i64Reg = __m128i;
typedef __m128i Vec4u32Reg;
typedef __m128i Vec2u64Reg;
using Vec4u32Reg = __m128i;
using Vec2u64Reg = __m128i;
#elif P_INTRINSICS != P_INTRINSICS_NEON
typedef struct alignas(16) Vec4f32Reg { float data[4]; } Vec4f32Reg;
typedef struct alignas(16) Vec2f64Reg { double data[2]; } Vec2f64Reg;
typedef struct alignas(16) Vec4i32Reg { int data[4]; } Vec4i32Reg;
typedef struct alignas(16) Vec2i64Reg { Phanes::Core::Types::int64 data[2]; } Vec2i64Reg;
typedef struct alignas(16) Vec4u32Reg { unsigned int data[4]; } Vec4u32Reg;
typedef struct alignas(16) Vec2u64Reg { Phanes::Core::Types::uint64 data[4]; } Vec2u64Reg;
using Vec4f32Reg = struct alignas(16) Vec4f32Reg
{
float data[4];
};
using Vec2f64Reg = struct alignas(16) Vec2f64Reg
{
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
#if P_INTRINSICS >= 2
typedef __m256 Vec4x2f32Reg;
typedef __m256 Vec8f32Reg;
typedef __m256d Vec2x2f64Reg;
typedef __m256d Vec4f64Reg;
using Vec4x2f32Reg = __m256;
using Vec8f32Reg = __m256;
using Vec2x2f64Reg = __m256d;
using Vec4f64Reg = __m256d;
#elif P_INTRINSICS != P_INTRINSICS_NEON
typedef struct alignas(32) Vec4x2f32Reg { float data[8]; } Vec4x2f32Reg;
typedef struct alignas(32) Vec8f32Reg { float data[8]; } Vec8f32Reg;
typedef struct alignas(32) Vec2x2f64Reg { double data[4]; } Vec2x2f64Reg;
typedef struct alignas(32) Vec4f64Reg { double data[4]; } Vec4f64Reg;
using Vec4x2f32Reg = struct alignas(32) Vec4x2f32Reg
{
float data[8];
};
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
#if P_INTRINSICS == 3
typedef __m256i Vec4x2i32Reg;
typedef __m256i Vec8i32Reg;
typedef __m256i Vec2x2i64Reg;
typedef __m256i Vec4i64Reg;
using Vec4x2i32Reg = __m256i;
using Vec8i32Reg;
= __m256i using Vec2x2i64Reg;
= __m256i using Vec4i64Reg;
= __m256i
typedef __m256i Vec4x2u32Reg;
typedef __m256i Vec8u32Reg;
typedef __m256i Vec2x2u64Reg;
typedef __m256i Vec4u64Reg;
using Vec4x2u32Reg;
= __m256i using Vec8u32Reg;
= __m256i using Vec2x2u64Reg;
= __m256i using Vec4u64Reg;
= __m256i
#elif P_INTRINSICS != P_INTRINSICS_NEON
typedef struct alignas(32) Vec4x2i32Reg { int data[8]; } Vec4x2i32Reg;
typedef struct alignas(32) Vec8i32Reg { int data[8]; } Vec8i32Reg;
typedef struct alignas(32) Vec2x2i64Reg { Phanes::Core::Types::int64 data[4]; } Vec2x2i64Reg;
typedef struct alignas(32) Vec4i64Reg { Phanes::Core::Types::int64 data[4]; } Vec4i64Reg;
using Vec4x2i32Reg = struct alignas(32) Vec4x2i32Reg
{
int data[8];
};
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;
typedef struct alignas(32) Vec8u32Reg { unsigned int data[8]; } Vec8u32Reg;
typedef struct alignas(32) Vec2x2u64Reg { Phanes::Core::Types::uint64 data[4]; } Vec2x2u64Reg;
typedef struct alignas(32) Vec4u64Reg { Phanes::Core::Types::uint64 data[4]; } Vec4u64Reg;
using Vec4x2u32Reg = struct alignas(32) Vec4x2u32Reg
{
unsigned int data[8];
};
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
// NEON ...
}
// NEON ...
} // namespace Phanes::Core::Types