1- // ==-- PropertySetIO .h -- models a sequence of property sets and their I/O -= =//
1+ // =- SYCLPropertySetIO .h -- models a sequence of property sets and their I/O =//
22//
33// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44// See https://llvm.org/LICENSE.txt for license information.
55// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66//
77// ===----------------------------------------------------------------------===//
88// Models a sequence of property sets and their input and output operations.
9- // PropertyValue set format:
10- // '['<PropertyValue set name>']'
9+ // SYCLPropertyValue set format:
10+ // '['<SYCLPropertyValue set name>']'
1111// <property name>=<property type>'|'<property value>
1212// <property name>=<property type>'|'<property value>
1313// ...
14- // '['<PropertyValue set name>']'
14+ // '['<SYCLPropertyValue set name>']'
1515// <property name>=<property type>'|'<property value>
1616// where
17- // <PropertyValue set name>, <property name> are strings
17+ // <SYCLPropertyValue set name>, <property name> are strings
1818// <property type> - string representation of the property type
1919// <property value> - string representation of the property value.
2020//
2929//
3030// ===----------------------------------------------------------------------===//
3131
32- #ifndef LLVM_SUPPORT_PROPERTYSETIO_H
33- #define LLVM_SUPPORT_PROPERTYSETIO_H
32+ #ifndef LLVM_SUPPORT_SYCLPROPERTYSETIO_H
33+ #define LLVM_SUPPORT_SYCLPROPERTYSETIO_H
3434
3535#include " llvm/ADT/MapVector.h"
3636#include " llvm/ADT/SmallString.h"
4444namespace llvm {
4545namespace util {
4646
47- // Represents a property value. PropertyValue name is stored in the encompassing
48- // container.
49- class PropertyValue {
47+ // Represents a SYCL property value. SYCLPropertyValue name is stored in the
48+ // encompassing container.
49+ class SYCLPropertyValue {
5050public:
5151 // Type of the size of the value. Value size gets serialized along with the
5252 // value data in some cases for later reading at runtime, so size_t is not
@@ -66,26 +66,27 @@ class PropertyValue {
6666 return static_cast <Type>(T);
6767 }
6868
69- ~PropertyValue () {}
69+ ~SYCLPropertyValue () {}
7070
71- PropertyValue () = default ;
72- PropertyValue (Type T) : Ty(T) {}
71+ SYCLPropertyValue () = default ;
72+ SYCLPropertyValue (Type T) : Ty(T) {}
7373
74- PropertyValue (uint32_t Val) : Ty(UINT32), Val({Val}) {}
75- PropertyValue (const std::byte *Data, SizeTy DataBitSize);
74+ SYCLPropertyValue (uint32_t Val) : Ty(UINT32), Val({Val}) {}
75+ SYCLPropertyValue (const std::byte *Data, SizeTy DataBitSize);
7676 template <typename C, typename T = typename C::value_type>
77- PropertyValue (const C &Data)
78- : PropertyValue(reinterpret_cast <const std::byte *>(Data.data()),
79- Data.size() * sizeof (T) * CHAR_BIT) {}
80- PropertyValue (const llvm::StringRef &Str)
81- : PropertyValue(reinterpret_cast <const std::byte *>(Str.data()),
82- Str.size() * sizeof (char ) * /* bits in one byte */ 8 ) {}
83- PropertyValue (const PropertyValue &P);
84- PropertyValue (PropertyValue &&P);
77+ SYCLPropertyValue (const C &Data)
78+ : SYCLPropertyValue(reinterpret_cast <const std::byte *>(Data.data()),
79+ Data.size() * sizeof (T) * CHAR_BIT) {}
80+ SYCLPropertyValue (const llvm::StringRef &Str)
81+ : SYCLPropertyValue(reinterpret_cast <const std::byte *>(Str.data()),
82+ Str.size() * sizeof (char ) *
83+ /* bits in one byte */ 8 ) {}
84+ SYCLPropertyValue (const SYCLPropertyValue &P);
85+ SYCLPropertyValue (SYCLPropertyValue &&P);
8586
86- PropertyValue &operator =(PropertyValue &&P);
87+ SYCLPropertyValue &operator =(SYCLPropertyValue &&P);
8788
88- PropertyValue &operator =(const PropertyValue &P);
89+ SYCLPropertyValue &operator =(const SYCLPropertyValue &P);
8990
9091 // Get property value as unsigned 32-bit integer
9192 uint32_t asUint32 () const {
@@ -139,14 +140,14 @@ class PropertyValue {
139140
140141 bool isValid () const { return getType () != NONE; }
141142
142- // Set property value; the 'T' type must be convertible to a property type tag
143+ // Set property value when data type is UINT32_T
143144 void set (uint32_t V) {
144145 if (Ty != UINT32)
145146 llvm_unreachable (" invalid type tag for this operation" );
146147 Val = V;
147148 }
148149
149- // Set property value; the 'T' type must be convertible to a property type tag
150+ // Set property value when data type is BYTE_ARRAY
150151 void set (std::byte *V, int DataSize) {
151152 if (Ty != BYTE_ARRAY)
152153 llvm_unreachable (" invalid type tag for this operation" );
@@ -175,19 +176,19 @@ class PropertyValue {
175176 case BYTE_ARRAY:
176177 return getRawByteArraySize ();
177178 default :
178- llvm_unreachable_internal (" unsupported property type" );
179+ llvm_unreachable_internal (" unsupported SYCL property type" );
179180 }
180181 }
181182
182183private:
183- void copy (const PropertyValue &P);
184+ void copy (const SYCLPropertyValue &P);
184185
185186 Type Ty = NONE;
186187 std::variant<uint32_t , std::byte *> Val;
187188};
188189
189- // / Structure for specialization of DenseMap in PropertySetRegistry .
190- struct PropertySetKeyInfo {
190+ // / Structure for specialization of DenseMap in SYCLPropertySetRegistry .
191+ struct SYCLPropertySetKeyInfo {
191192 static unsigned getHashValue (const SmallString<16 > &K) { return xxHash64 (K); }
192193
193194 static SmallString<16 > getEmptyKey () { return SmallString<16 >(" " ); }
@@ -197,17 +198,19 @@ struct PropertySetKeyInfo {
197198 static bool isEqual (StringRef L, StringRef R) { return L == R; }
198199};
199200
200- using PropertyMapTy = DenseMap<SmallString<16 >, unsigned , PropertySetKeyInfo>;
201+ using SYCLPropertyMapTy =
202+ DenseMap<SmallString<16 >, unsigned , SYCLPropertySetKeyInfo>;
201203// / A property set. Preserves insertion order when iterating elements.
202- using PropertySet = MapVector<SmallString<16 >, PropertyValue, PropertyMapTy>;
204+ using SYCLPropertySet =
205+ MapVector<SmallString<16 >, SYCLPropertyValue, SYCLPropertyMapTy>;
203206
204207// / A registry of property sets. Maps a property set name to its
205208// / content.
206209// /
207210// / The order of keys is preserved and corresponds to the order of insertion.
208- class PropertySetRegistry {
211+ class SYCLPropertySetRegistry {
209212public:
210- using MapTy = MapVector<SmallString<16 >, PropertySet, PropertyMapTy >;
213+ using MapTy = MapVector<SmallString<16 >, SYCLPropertySet, SYCLPropertyMapTy >;
211214
212215 // Specific property category names used by tools.
213216 static constexpr char SYCL_SPECIALIZATION_CONSTANTS[] =
@@ -234,19 +237,19 @@ class PropertySetRegistry {
234237 auto &PropSet = PropSetMap[Category];
235238
236239 for (const auto &[PropName, PropVal] : Props)
237- PropSet.insert_or_assign (PropName, PropertyValue (PropVal));
240+ PropSet.insert_or_assign (PropName, SYCLPropertyValue (PropVal));
238241 }
239242
240243 // / Adds the given \p PropVal with the given \p PropName into the given \p
241244 // / Category .
242245 template <typename T>
243246 void add (StringRef Category, StringRef PropName, const T &PropVal) {
244247 auto &PropSet = PropSetMap[Category];
245- PropSet.insert ({PropName, PropertyValue (PropVal)});
248+ PropSet.insert ({PropName, SYCLPropertyValue (PropVal)});
246249 }
247250
248251 // / Parses from the given \p Buf a property set registry.
249- static Expected<std::unique_ptr<PropertySetRegistry >>
252+ static Expected<std::unique_ptr<SYCLPropertySetRegistry >>
250253 read (const MemoryBuffer *Buf);
251254
252255 // / Dumps the property set registry to the given \p Out stream.
@@ -256,7 +259,7 @@ class PropertySetRegistry {
256259 MapTy::const_iterator end () const { return PropSetMap.end (); }
257260
258261 // / Retrieves a property set with given \p Name .
259- PropertySet &operator [](StringRef Name) { return PropSetMap[Name]; }
262+ SYCLPropertySet &operator [](StringRef Name) { return PropSetMap[Name]; }
260263 // / Constant access to the underlying map.
261264 const MapTy &getPropSets () const { return PropSetMap; }
262265
@@ -268,4 +271,4 @@ class PropertySetRegistry {
268271
269272} // namespace llvm
270273
271- #endif // #define LLVM_SUPPORT_PROPERTYSETIO_H
274+ #endif // #define LLVM_SUPPORT_SYCLPROPERTYSETIO_H
0 commit comments