@@ -19,16 +19,16 @@ template <typename Set>
1919inline constexpr indirectly_callable_key::value_t <Set> indirectly_callable_in;
2020
2121struct calls_indirectly_key {
22- template <typename First = void , typename ... SetIds>
22+ template <typename ... SetIds>
2323 using value_t =
2424 sycl::ext::oneapi::experimental::property_value<calls_indirectly_key,
25- First, SetIds...>;
25+ SetIds...>;
2626};
2727
2828inline constexpr calls_indirectly_key::value_t <void > assume_indirect_calls;
2929
30- template <typename First, typename ... Rest >
31- inline constexpr calls_indirectly_key::value_t <First, Rest ...>
30+ template <typename ... SetIds >
31+ inline constexpr calls_indirectly_key::value_t <SetIds ...>
3232 assume_indirect_calls_to;
3333
3434template <> struct is_property_key <indirectly_callable_key> : std::true_type {};
@@ -60,16 +60,57 @@ struct PropertyMetaInfo<indirectly_callable_key::value_t<Set>> {
6060#endif
6161};
6262
63- template <typename First, typename ... Rest>
64- struct PropertyMetaInfo <calls_indirectly_key::value_t <First, Rest...>> {
65- static_assert (
66- sizeof ...(Rest) == 0 ,
67- " assume_indirect_calls_to property only supports a single set for now" );
63+ #ifdef __SYCL_DEVICE_ONLY__
64+ // Helper to concatenate several lists of characters into a single string.
65+ // Lists are separated from each other with comma within the resulting string.
66+ template <typename List, typename ... Rest> struct ConcatenateCharsToStr ;
67+
68+ // Specialization for a single list
69+ template <char ... Chars> struct ConcatenateCharsToStr <CharList<Chars...>> {
70+ static constexpr char value[] = {Chars..., ' \0 ' };
71+ };
72+
73+ // Specialization for two lists
74+ template <char ... Chars, char ... CharsToAppend>
75+ struct ConcatenateCharsToStr <CharList<Chars...>, CharList<CharsToAppend...>>
76+ : ConcatenateCharsToStr<CharList<Chars..., ' ,' , CharsToAppend...>> {};
77+
78+ // Specialization for the case when there are more than two lists
79+ template <char ... Chars, char ... CharsToAppend, typename ... Rest>
80+ struct ConcatenateCharsToStr <CharList<Chars...>, CharList<CharsToAppend...>,
81+ Rest...>
82+ : ConcatenateCharsToStr<CharList<Chars..., ' ,' , CharsToAppend...>,
83+ Rest...> {};
84+
85+ // Helper to convert type T to a list of characters representing the type (its
86+ // mangled name).
87+ template <typename T, size_t ... Indices> struct StableNameToCharsHelper {
88+ using chars = CharList<__builtin_sycl_unique_stable_name(T)[Indices]...>;
89+ };
90+
91+ // Wrapper helper for the struct above
92+ template <typename T, typename Sequence> struct StableNameToChars ;
93+
94+ // Specialization of that wrapper helper which accepts sequence of integers
95+ template <typename T, size_t ... Indices>
96+ struct StableNameToChars <T, std::integer_sequence<size_t , Indices...>>
97+ : StableNameToCharsHelper<T, Indices...> {};
98+
99+ // Creates a comma-separated string with unique stable names for each type in
100+ // Ts.
101+ template <typename ... Ts>
102+ struct UniqueStableNameListStr
103+ : ConcatenateCharsToStr<typename StableNameToChars<
104+ Ts, std::make_index_sequence<__builtin_strlen(
105+ __builtin_sycl_unique_stable_name (Ts))>>::chars...> {};
106+ #endif // __SYCL_DEVICE_ONLY__
107+
108+ template <typename ... SetIds>
109+ struct PropertyMetaInfo <calls_indirectly_key::value_t <SetIds...>> {
68110 static constexpr const char *name = " calls-indirectly" ;
69111 static constexpr const char *value =
70112#ifdef __SYCL_DEVICE_ONLY__
71- // FIXME: we should handle Rest... here as well
72- __builtin_sycl_unique_stable_name (First);
113+ UniqueStableNameListStr<SetIds...>::value;
73114#else
74115 " " ;
75116#endif
0 commit comments