reference.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // -*- C++ -*-
  2. //===----------------------------------------------------------------------===//
  3. //
  4. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  5. // See https://llvm.org/LICENSE.txt for license information.
  6. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #ifndef _LIBCPP_EXPERIMENTAL___SIMD_REFERENCE_H
  10. #define _LIBCPP_EXPERIMENTAL___SIMD_REFERENCE_H
  11. #include <experimental/__simd/utility.h>
  12. #if _LIBCPP_STD_VER >= 17 && defined(_LIBCPP_ENABLE_EXPERIMENTAL)
  13. _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL
  14. inline namespace parallelism_v2 {
  15. template <class _Tp, class _Storage, class _Vp>
  16. class __simd_reference {
  17. template <class, class>
  18. friend class simd;
  19. template <class, class>
  20. friend class simd_mask;
  21. _Storage& __s_;
  22. size_t __idx_;
  23. _LIBCPP_HIDE_FROM_ABI _Vp __get() const { return __s_.__get(__idx_); }
  24. _LIBCPP_HIDE_FROM_ABI void __set(_Vp __v) {
  25. if constexpr (is_same_v<_Vp, bool>)
  26. __s_.__set(__idx_, experimental::__set_all_bits<_Tp>(__v));
  27. else
  28. __s_.__set(__idx_, __v);
  29. }
  30. public:
  31. using value_type = _Vp;
  32. __simd_reference() = delete;
  33. __simd_reference(const __simd_reference&) = delete;
  34. };
  35. } // namespace parallelism_v2
  36. _LIBCPP_END_NAMESPACE_EXPERIMENTAL
  37. #endif // _LIBCPP_STD_VER >= 17 && defined(_LIBCPP_ENABLE_EXPERIMENTAL)
  38. #endif // _LIBCPP_EXPERIMENTAL___SIMD_REFERENCE_H