Skip to content

Commit

Permalink
[NFCI] More convertToOpenCLType-related simplifications (#12717)
Browse files Browse the repository at this point in the history
  • Loading branch information
aelovikov-intel committed Feb 16, 2024
1 parent 79d775e commit aa015f3
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 319 deletions.
23 changes: 4 additions & 19 deletions sycl/include/sycl/builtins_preview.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,28 +95,13 @@ template <typename T> auto convert_arg(T &&x) {
__attribute__((ext_vector_type(N)))>;
// TODO: We should have this bit_cast impl inside vec::convert.
return bit_cast<result_type>(static_cast<typename no_cv_ref::vector_t>(x));
} else if constexpr (std::is_same_v<no_cv_ref, half>)
return static_cast<half_impl::BIsRepresentationT>(x);
else if constexpr (is_multi_ptr_v<no_cv_ref>) {
return convert_arg(x.get_decorated());
} else if constexpr (is_scalar_arithmetic_v<no_cv_ref>) {
// E.g. on linux: long long -> int64_t (long), or char -> int8_t (signed
// char) and same for unsigned; Windows has long/long long reversed.
// TODO: Inline this scalar impl.
return static_cast<ConvertToOpenCLType_t<no_cv_ref>>(x);
} else if constexpr (std::is_pointer_v<no_cv_ref>) {
using elem_type = remove_decoration_t<std::remove_pointer_t<no_cv_ref>>;
using converted_elem_type =
decltype(convert_arg(std::declval<elem_type>()));
using result_type =
typename DecoratedType<converted_elem_type,
deduce_AS<no_cv_ref>::value>::type *;
return reinterpret_cast<result_type>(x);
} else if constexpr (is_swizzle_v<no_cv_ref>) {
return convert_arg(simplify_if_swizzle_t<no_cv_ref>{x});
} else {
// TODO: should it be unreachable? What can it be?
return std::forward<T>(x);
static_assert(is_scalar_arithmetic_v<no_cv_ref> ||
is_multi_ptr_v<no_cv_ref> || std::is_pointer_v<no_cv_ref> ||
std::is_same_v<no_cv_ref, half>);
return convertToOpenCLType(std::forward<T>(x));
}
}

Expand Down
Loading

0 comments on commit aa015f3

Please sign in to comment.