[libcxx-commits] [PATCH] D144362: [libcxx] Updated <experimental/simd> based on Parallelism-TS N4808

Yin Zhang via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Mar 13 01:20:22 PDT 2023


Joy12138 added inline comments.


================
Comment at: libcxx/include/experimental/simd:96-99
+  template<class _Tp, class = void> struct __is_abi_tag_impl : false_type {};
+  template<class _Tp> struct __is_abi_tag_impl<_Tp, enable_if_t<_Tp::__is_abi_tag>> : bool_constant<_Tp::__is_abi_tag> {};
+  template<class _Tp> struct is_abi_tag : __is_abi_tag_impl<_Tp> {};
+  template<class _Tp> inline constexpr bool is_abi_tag_v = is_abi_tag<_Tp>::value;
----------------
philnik wrote:
> I think it would be easier to move this to it's own header, and then specialize `is_abi_tag` per ABI tag, i.e.
> ```lang=c++
> // traits.h
> template <class _Tp>
> inline constexpr bool is_abi_tag_v = false;
> 
> template <class _Tp>
> struct is_abi_tag : bool_constant<is_abi_tag_v<_Tp>> {};
> 
> // scalar.h
> template <>
> inline constexpr bool is_abi_tag_v<__scalar> = true;
> 
> // vec_ext.h
> template <int _Np>
> inline constexpr bool is_abi_tag_v<__vec_ext<_Np>> = true;
> ```
> Note that this also implements `is_abi_tag` in terms of `is_abi_tag_v` and not the other way around. Most people just use the latter, so we should avoid instantiating a class every time. This part also applies to `is_simd` and `is_simd_mask`.
This looks great, but there are often references to other interfaces in the implementation of traits. If traits are to be implemented in different ABI tag headers, we may need to add some declarations to the outer layer of these headers. For example, class `simd`/`simd_mask` will be referenced in the `is_simd`/`is_simd_mask` implementation. Should I use a new header (`declaration. h`) to add these declarations?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144362/new/

https://reviews.llvm.org/D144362



More information about the libcxx-commits mailing list