//===----------------------------------------------------------------------===// // // 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 PlusAssign { template void operator()(T&& lhs, const U& rhs) const noexcept { std::forward(lhs) += rhs; } }; struct MinusAssign { template void operator()(T&& lhs, const U& rhs) const noexcept { std::forward(lhs) -= rhs; } }; struct MultipliesAssign { template void operator()(T&& lhs, const U& rhs) const noexcept { std::forward(lhs) *= rhs; } }; struct DividesAssign { template void operator()(T&& lhs, const U& rhs) const noexcept { std::forward(lhs) /= rhs; } }; struct ModulusAssign { template void operator()(T&& lhs, const U& rhs) const noexcept { std::forward(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 CheckReferenceArithOperators { template void operator()() { types::for_each(simd_test_types(), SimdReferenceOperatorHelper, PlusAssign>()); types::for_each(simd_test_types(), SimdReferenceOperatorHelper, MinusAssign>()); types::for_each(simd_test_types(), SimdReferenceOperatorHelper, MultipliesAssign>()); types::for_each(simd_test_types(), SimdReferenceOperatorHelper, DividesAssign>()); } }; template struct CheckReferenceModOperators { template void operator()() { types::for_each( simd_test_integer_types(), SimdReferenceOperatorHelper, ModulusAssign>()); } }; int main(int, char**) { test_all_simd_abi(); types::for_each(types::integer_types(), TestAllSimdAbiFunctor()); return 0; }