[libcxx-commits] [libcxx] [libc++] Start implementing std::datapar::simd (PR #139919)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Fri May 30 08:49:56 PDT 2025
================
@@ -0,0 +1,141 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___SIMD_BASIC_SIMD_MASK_H
+#define _LIBCPP___SIMD_BASIC_SIMD_MASK_H
+
+#include <__assert>
+#include <__config>
+#include <__cstddef/size_t.h>
+#include <__simd/abi.h>
+#include <__utility/integer_sequence.h>
+
+#if _LIBCPP_STD_VER >= 26
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+namespace datapar {
+
+_LIBCPP_DIAGNOSTIC_PUSH
+_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wpsabi")
+
+struct __from_data_tag {};
+inline constexpr __from_data_tag __from_data;
+
+template <size_t _Bytes, class _Abi = __native_abi<__integer_from<_Bytes>>>
+class basic_simd_mask {
+public:
+ using value_type = bool;
+ using abi_type = _Abi;
+
+ static constexpr integral_constant<__simd_size_type, __simd_size_v<__integer_from<_Bytes>, abi_type>> size{};
+
+private:
+ using __data_t = abi_type::_MaskT;
+ __data_t __data_;
+
+ _LIBCPP_ALWAYS_INLINE static constexpr __data_t __broadcast(value_type __value) {
+ return [&]<size_t... _Indices>(index_sequence<_Indices...>) _LIBCPP_ALWAYS_INLINE {
+ return __data_t{((void)_Indices, __value)...};
+ }(make_index_sequence<size()>{});
+ }
+
+public:
+ // [simd.mask.ctor]
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit basic_simd_mask(value_type __value) noexcept
+ : __data_(__broadcast(__value)) {}
+
+ // TODO: converting constructor
+
+ // TODO: generating constructor
+
+ // libc++ extension
----------------
ldionne wrote:
Let's make sure we have tests for those.
https://github.com/llvm/llvm-project/pull/139919
More information about the libcxx-commits
mailing list