//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++03, c++11, c++14 // // // [simd.class] // template simd(const U* mem, Flags); #include "../test_utils.h" namespace ex = std::experimental::parallelism_v2; template struct ElementAlignedLoadCtorHelper { template void operator()() const { U buffer[array_size]; for (size_t i = 0; i < array_size; ++i) buffer[i] = static_cast(i); ex::simd origin_simd(buffer, ex::element_aligned_tag()); assert_simd_values_equal(origin_simd, buffer); } }; template struct VectorAlignedLoadCtorHelper { template void operator()() const { alignas(ex::memory_alignment_v, U>) U buffer[array_size]; for (size_t i = 0; i < array_size; ++i) buffer[i] = static_cast(i); ex::simd origin_simd(buffer, ex::vector_aligned_tag()); assert_simd_values_equal(origin_simd, buffer); } }; template struct OveralignedLoadCtorHelper { template void operator()() const { alignas(bit_ceil(sizeof(U) + 1)) U buffer[array_size]; for (size_t i = 0; i < array_size; ++i) buffer[i] = static_cast(i); ex::simd origin_simd(buffer, ex::overaligned_tag()); assert_simd_values_equal(origin_simd, buffer); } }; template struct CheckSimdLoadCtor { template void operator()() { constexpr std::size_t array_size = ex::simd_size_v; types::for_each(simd_test_types(), ElementAlignedLoadCtorHelper()); types::for_each(simd_test_types(), VectorAlignedLoadCtorHelper()); types::for_each(simd_test_types(), OveralignedLoadCtorHelper()); } }; template struct CheckLoadCtorTraits { template void operator()() { // This function shall not participate in overload resolution unless // is_simd_flag_type_v is true, and // U is a vectorizable type. static_assert(std::is_constructible_v, const int*, ex::element_aligned_tag>); // is_simd_flag_type_v is false static_assert(!std::is_constructible_v, const int*, T>); static_assert(!std::is_constructible_v, const int*, SimdAbi>); // U is not a vectorizable type. static_assert(!std::is_constructible_v, const SimdAbi*, ex::element_aligned_tag>); static_assert( !std::is_constructible_v, const ex::element_aligned_tag*, ex::element_aligned_tag>); } }; int main(int, char**) { test_all_simd_abi(); test_all_simd_abi(); return 0; }