Skip to content

Commit

Permalink
[MSVC] Unroll SIMD to adapt for MSVC.
Browse files Browse the repository at this point in the history
Signed-off-by: Wang Jikai <[email protected]>
  • Loading branch information
am009 authored and hydai committed Sep 12, 2023
1 parent 29663ac commit 473817c
Show file tree
Hide file tree
Showing 6 changed files with 1,194 additions and 2 deletions.
20 changes: 20 additions & 0 deletions include/common/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,25 @@ using RemoveCVRefT = std::remove_cv_t<std::remove_reference_t<T>>;
using Byte = uint8_t;

/// SIMD types definition.
#if defined(_MSC_VER) && !defined(__clang__) // MSVC

/// Because MSVC does not support [[gnu::vector_size(16)]] or
/// __attribute__((vector_size(16)), we use this type to fill the gap.
template <typename Ty, size_t TotalSize = 16,
std::enable_if_t<(TotalSize % sizeof(Ty) == 0), int> = 0>
using SIMDArray = std::array<Ty, (TotalSize / sizeof(Ty))>;

using int64x2_t = SIMDArray<int64_t>;
using uint64x2_t = SIMDArray<uint64_t>;
using int32x4_t = SIMDArray<int32_t>;
using uint32x4_t = SIMDArray<uint32_t>;
using int16x8_t = SIMDArray<int16_t>;
using uint16x8_t = SIMDArray<uint16_t>;
using int8x16_t = SIMDArray<int8_t>;
using uint8x16_t = SIMDArray<uint8_t>;
using doublex2_t = SIMDArray<double>;
using floatx4_t = SIMDArray<float>;
#else
using int64x2_t [[gnu::vector_size(16)]] = int64_t;
using uint64x2_t [[gnu::vector_size(16)]] = uint64_t;
using int32x4_t [[gnu::vector_size(16)]] = int32_t;
Expand All @@ -49,6 +68,7 @@ using int8x16_t [[gnu::vector_size(16)]] = int8_t;
using uint8x16_t [[gnu::vector_size(16)]] = uint8_t;
using doublex2_t [[gnu::vector_size(16)]] = double;
using floatx4_t [[gnu::vector_size(16)]] = float;
#endif

/// UnknownRef definition.
struct UnknownRef {
Expand Down
Loading

0 comments on commit 473817c

Please sign in to comment.