//===----------------------------------------------------------------------===// // // 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.reference] // template reference|=(U&& x) && noexcept; // template reference&=(U&& x) && noexcept; // template reference^=(U&& x) && noexcept; // template reference<<=(U&& x) && noexcept; // template reference>>=(U&& x) && noexcept; #include #include #include "../test_utils.h" namespace ex = std::experimental::parallelism_v2; struct AndAssign { template void operator()(T&& lhs, const U& rhs) const noexcept { std::forward(lhs) &= rhs; } }; struct OrAssign { template void operator()(T&& lhs, const U& rhs) const noexcept { std::forward(lhs) |= rhs; } }; struct XorAssign { template void operator()(T&& lhs, const U& rhs) const noexcept { std::forward(lhs) ^= rhs; } }; struct LeftShiftAssign { template void operator()(T&& lhs, const U& rhs) const noexcept { std::forward(lhs) <<= rhs; } }; struct RightShiftAssign { template void operator()(T&& lhs, const U& rhs) const noexcept { std::forward(lhs) >>= rhs; } }; struct LeftShift { template T operator()(const T& lhs, const U& rhs) const noexcept { return lhs << rhs; } }; struct RightShift { template T operator()(const T& lhs, const U& rhs) const noexcept { return lhs >> rhs; } }; template struct SimdReferenceOperatorHelper { template void operator()() const { ex::simd origin_simd(static_cast(3)); static_assert(noexcept(OpAssign{}(origin_simd[0], static_cast(2)))); OpAssign{}(origin_simd[0], static_cast(2)); assert((T)origin_simd[0] == (T)Op{}(static_cast(3), static_cast(std::forward(2)))); } }; template struct MaskReferenceOperatorHelper { template void operator()() const { ex::simd_mask origin_mask(true); static_assert(noexcept(OpAssign{}(origin_mask[0], static_cast(false)))); OpAssign{}(origin_mask[0], static_cast(false)); assert((bool)origin_mask[0] == (bool)Op{}(true, static_cast(std::forward(false)))); } }; template struct CheckReferenceBitwiseOperators { template void operator()() { types::for_each(simd_test_integer_types(), SimdReferenceOperatorHelper, AndAssign>()); types::for_each(simd_test_integer_types(), SimdReferenceOperatorHelper, OrAssign>()); types::for_each(simd_test_integer_types(), SimdReferenceOperatorHelper, XorAssign>()); types::for_each(simd_test_integer_types(), SimdReferenceOperatorHelper()); types::for_each(simd_test_integer_types(), SimdReferenceOperatorHelper()); types::for_each(simd_test_integer_types(), MaskReferenceOperatorHelper, AndAssign>()); types::for_each(simd_test_integer_types(), MaskReferenceOperatorHelper, OrAssign>()); types::for_each(simd_test_integer_types(), MaskReferenceOperatorHelper, XorAssign>()); } }; int main(int, char**) { types::for_each(types::integer_types(), TestAllSimdAbiFunctor()); return 0; }