Re-apply "[libcxx] implement <simd> ABI for Clang/GCC vector extension, constructors, copy_from and copy_to."
...with proper guarding #ifdefs for unsupported C++11. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@338318 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// UNSUPPORTED: c++98, c++03
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14
|
||||
|
||||
// See GCC PR63723.
|
||||
// UNSUPPORTED: gcc-4.9
|
||||
@@ -20,18 +20,19 @@
|
||||
#include <cstdint>
|
||||
#include <experimental/simd>
|
||||
|
||||
using namespace std::experimental::parallelism_v2;
|
||||
namespace ex = std::experimental::parallelism_v2;
|
||||
|
||||
template <class T, class... Args>
|
||||
auto not_supported_native_simd_ctor(Args&&... args)
|
||||
-> decltype(native_simd<T>(std::forward<Args>(args)...), void()) = delete;
|
||||
-> decltype(ex::native_simd<T>(std::forward<Args>(args)...),
|
||||
void()) = delete;
|
||||
|
||||
template <class T>
|
||||
void not_supported_native_simd_ctor(...) {}
|
||||
|
||||
template <class T, class... Args>
|
||||
auto supported_native_simd_ctor(Args&&... args)
|
||||
-> decltype(native_simd<T>(std::forward<Args>(args)...), void()) {}
|
||||
-> decltype(ex::native_simd<T>(std::forward<Args>(args)...), void()) {}
|
||||
|
||||
template <class T>
|
||||
void supported_native_simd_ctor(...) = delete;
|
||||
@@ -55,4 +56,31 @@ void compile_narrowing_conversion() {
|
||||
not_supported_native_simd_ctor<int>(3.);
|
||||
}
|
||||
|
||||
int main() {}
|
||||
void compile_convertible() {
|
||||
struct ConvertibleToInt {
|
||||
operator int64_t() const;
|
||||
};
|
||||
supported_native_simd_ctor<int64_t>(ConvertibleToInt());
|
||||
|
||||
struct NotConvertibleToInt {};
|
||||
not_supported_native_simd_ctor<int64_t>(NotConvertibleToInt());
|
||||
}
|
||||
|
||||
void compile_unsigned() {
|
||||
not_supported_native_simd_ctor<int>(3u);
|
||||
supported_native_simd_ctor<uint16_t>(3u);
|
||||
}
|
||||
|
||||
template <typename SimdType>
|
||||
void test_broadcast() {
|
||||
SimdType a(3);
|
||||
for (size_t i = 0; i < a.size(); i++) {
|
||||
assert(a[i] == 3);
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
test_broadcast<ex::native_simd<int>>();
|
||||
test_broadcast<ex::fixed_size_simd<int, 4>>();
|
||||
test_broadcast<ex::fixed_size_simd<int, 15>>();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user