[libcxx] implement <simd> ABI for Clang/GCC vector extension, constructors, copy_from and copy_to.
Summary:
This patch adds a new macro _LIBCPP_HAS_NO_VECTOR_EXTENSION for detecting
whether a vector extension (\_\_attribute\_\_((vector_size(num_bytes)))) is
available.
On the top of that, this patch implements the following API:
* all constructors
* operator[]
* copy_from
* copy_to
It also defines simd_abi::native to use vector extension, if available.
In GCC and Clang, certain values with vector extension are passed by registers,
instead of memory.
Based on D41148.
Reviewers: mclow.lists, EricWF
Subscribers: cfe-commits, MaskRay, lichray, sanjoy
Differential Revision: https://reviews.llvm.org/D41376
llvm-svn: 338309
diff --git a/libcxx/test/std/experimental/simd/simd.cons/broadcast.pass.cpp b/libcxx/test/std/experimental/simd/simd.cons/broadcast.pass.cpp
index 60230cc..49b2b55 100644
--- a/libcxx/test/std/experimental/simd/simd.cons/broadcast.pass.cpp
+++ b/libcxx/test/std/experimental/simd/simd.cons/broadcast.pass.cpp
@@ -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 @@
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>>();
+}