Skip to content

Commit 20a7d75

Browse files
committed
Add SYCL prefix to PropertySet etc.
Signed-off-by: Arvind Sudarsanam <[email protected]>
1 parent de19806 commit 20a7d75

File tree

5 files changed

+95
-88
lines changed

5 files changed

+95
-88
lines changed

llvm/include/llvm/Support/PropertySetIO.h renamed to llvm/include/llvm/Support/SYCLPropertySetIO.h

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
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
//
@@ -29,8 +29,8 @@
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"
@@ -44,9 +44,9 @@
4444
namespace llvm {
4545
namespace 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 {
5050
public:
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

182183
private:
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 {
209212
public:
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

llvm/lib/Support/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ add_llvm_component_library(LLVMSupport
217217
Parallel.cpp
218218
PluginLoader.cpp
219219
PrettyStackTrace.cpp
220-
PropertySetIO.cpp
220+
SYCLPropertySetIO.cpp
221221
RandomNumberGenerator.cpp
222222
Regex.cpp
223223
RewriteBuffer.cpp

llvm/lib/Support/PropertySetIO.cpp renamed to llvm/lib/Support/SYCLPropertySetIO.cpp

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
//==- PropertySetIO.cpp - models a sequence of property sets and their I/O -==//
1+
//= SYCLPropertySetIO.cpp - 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

9-
#include "llvm/Support/PropertySetIO.h"
9+
#include "llvm/Support/SYCLPropertySetIO.h"
1010

1111
#include "llvm/ADT/APInt.h"
1212
#include "llvm/ADT/StringExtras.h"
@@ -28,10 +28,10 @@ ::llvm::Error makeError(const Twine &Msg) {
2828

2929
} // anonymous namespace
3030

31-
Expected<std::unique_ptr<PropertySetRegistry>>
32-
PropertySetRegistry::read(const MemoryBuffer *Buf) {
33-
auto Res = std::make_unique<PropertySetRegistry>();
34-
PropertySet *CurPropSet = nullptr;
31+
Expected<std::unique_ptr<SYCLPropertySetRegistry>>
32+
SYCLPropertySetRegistry::read(const MemoryBuffer *Buf) {
33+
auto Res = std::make_unique<SYCLPropertySetRegistry>();
34+
SYCLPropertySet *CurPropSet = nullptr;
3535

3636
for (line_iterator LI(*Buf); !LI.is_at_end(); LI++) {
3737
// See if this line starts a new property set
@@ -60,17 +60,17 @@ PropertySetRegistry::read(const MemoryBuffer *Buf) {
6060
// Parse type
6161
if (TypeVal.first.getAsInteger(10, Tint))
6262
return makeError("invalid property type: " + TypeVal.first);
63-
Expected<PropertyValue::Type> Ttag =
64-
PropertyValue::getTypeTag(static_cast<int>(Tint.getSExtValue()));
63+
Expected<SYCLPropertyValue::Type> Ttag =
64+
SYCLPropertyValue::getTypeTag(static_cast<int>(Tint.getSExtValue()));
6565
StringRef Val = TypeVal.second;
6666

6767
if (!Ttag)
6868
return Ttag.takeError();
69-
PropertyValue Prop(Ttag.get());
69+
SYCLPropertyValue Prop(Ttag.get());
7070

7171
// Parse value depending on its type
7272
switch (Ttag.get()) {
73-
case PropertyValue::Type::UINT32: {
73+
case SYCLPropertyValue::Type::UINT32: {
7474
APInt ValV;
7575
if (Val.getAsInteger(10, ValV))
7676
return createStringError(std::error_code{},
@@ -79,7 +79,7 @@ PropertySetRegistry::read(const MemoryBuffer *Buf) {
7979
llvm::errs() << "ARV: read int done\n";
8080
break;
8181
}
82-
case PropertyValue::Type::BYTE_ARRAY: {
82+
case SYCLPropertyValue::Type::BYTE_ARRAY: {
8383
std::vector<char> Output;
8484
if (Error Err = decodeBase64(Val, Output))
8585
return std::move(Err);
@@ -95,18 +95,18 @@ PropertySetRegistry::read(const MemoryBuffer *Buf) {
9595
if (!CurPropSet)
9696
return makeError("invalid property set registry");
9797

98-
return Expected<std::unique_ptr<PropertySetRegistry>>(std::move(Res));
98+
return Expected<std::unique_ptr<SYCLPropertySetRegistry>>(std::move(Res));
9999
}
100100

101101
namespace llvm {
102102
// Output a property to a stream
103-
raw_ostream &operator<<(raw_ostream &Out, const PropertyValue &Prop) {
103+
raw_ostream &operator<<(raw_ostream &Out, const SYCLPropertyValue &Prop) {
104104
Out << static_cast<int>(Prop.getType()) << '|';
105105
switch (Prop.getType()) {
106-
case PropertyValue::Type::UINT32:
106+
case SYCLPropertyValue::Type::UINT32:
107107
Out << Prop.asUint32();
108108
break;
109-
case PropertyValue::Type::BYTE_ARRAY: {
109+
case SYCLPropertyValue::Type::BYTE_ARRAY: {
110110
auto PropArr = Prop.asByteArray();
111111
std::vector<std::byte> V(PropArr, PropArr + Prop.getByteArraySize() /
112112
sizeof(std::byte));
@@ -121,7 +121,7 @@ raw_ostream &operator<<(raw_ostream &Out, const PropertyValue &Prop) {
121121
}
122122
} // namespace llvm
123123

124-
void PropertySetRegistry::write(raw_ostream &Out) const {
124+
void SYCLPropertySetRegistry::write(raw_ostream &Out) const {
125125
for (const auto &PropSet : PropSetMap) {
126126
Out << '[' << PropSet.first << "]\n";
127127

@@ -133,15 +133,16 @@ void PropertySetRegistry::write(raw_ostream &Out) const {
133133
namespace llvm {
134134
namespace util {
135135

136-
template <> PropertyValue::Type PropertyValue::getTypeTag<uint32_t>() {
136+
template <> SYCLPropertyValue::Type SYCLPropertyValue::getTypeTag<uint32_t>() {
137137
return UINT32;
138138
}
139139

140-
template <> PropertyValue::Type PropertyValue::getTypeTag<std::byte *>() {
140+
template <>
141+
SYCLPropertyValue::Type SYCLPropertyValue::getTypeTag<std::byte *>() {
141142
return BYTE_ARRAY;
142143
}
143144

144-
PropertyValue::PropertyValue(const std::byte *Data, SizeTy DataBitSize)
145+
SYCLPropertyValue::SYCLPropertyValue(const std::byte *Data, SizeTy DataBitSize)
145146
: Ty(BYTE_ARRAY) {
146147
constexpr int ByteSizeInBits = 8;
147148
SizeTy DataSize = (DataBitSize + (ByteSizeInBits - 1)) / ByteSizeInBits;
@@ -161,11 +162,13 @@ PropertyValue::PropertyValue(const std::byte *Data, SizeTy DataBitSize)
161162
std::memcpy(ByteArrayVal + SizeFieldSize, Data, DataSize);
162163
}
163164

164-
PropertyValue::PropertyValue(const PropertyValue &P) { *this = P; }
165+
SYCLPropertyValue::SYCLPropertyValue(const SYCLPropertyValue &P) { *this = P; }
165166

166-
PropertyValue::PropertyValue(PropertyValue &&P) { *this = std::move(P); }
167+
SYCLPropertyValue::SYCLPropertyValue(SYCLPropertyValue &&P) {
168+
*this = std::move(P);
169+
}
167170

168-
PropertyValue &PropertyValue::operator=(PropertyValue &&P) {
171+
SYCLPropertyValue &SYCLPropertyValue::operator=(SYCLPropertyValue &&P) {
169172
copy(P);
170173

171174
if (P.getType() == BYTE_ARRAY)
@@ -174,32 +177,32 @@ PropertyValue &PropertyValue::operator=(PropertyValue &&P) {
174177
return *this;
175178
}
176179

177-
PropertyValue &PropertyValue::operator=(const PropertyValue &P) {
180+
SYCLPropertyValue &SYCLPropertyValue::operator=(const SYCLPropertyValue &P) {
178181
if (P.getType() == BYTE_ARRAY)
179-
*this = PropertyValue(P.asByteArray(), P.getByteArraySizeInBits());
182+
*this = SYCLPropertyValue(P.asByteArray(), P.getByteArraySizeInBits());
180183
else
181184
copy(P);
182185
return *this;
183186
}
184187

185-
void PropertyValue::copy(const PropertyValue &P) {
188+
void SYCLPropertyValue::copy(const SYCLPropertyValue &P) {
186189
Ty = P.Ty;
187190
Val = P.Val;
188191
}
189192

190-
constexpr char PropertySetRegistry::SYCL_SPECIALIZATION_CONSTANTS[];
191-
constexpr char PropertySetRegistry::SYCL_DEVICELIB_REQ_MASK[];
192-
constexpr char PropertySetRegistry::SYCL_SPEC_CONSTANTS_DEFAULT_VALUES[];
193-
constexpr char PropertySetRegistry::SYCL_KERNEL_PARAM_OPT_INFO[];
194-
constexpr char PropertySetRegistry::SYCL_PROGRAM_METADATA[];
195-
constexpr char PropertySetRegistry::SYCL_MISC_PROP[];
196-
constexpr char PropertySetRegistry::SYCL_ASSERT_USED[];
197-
constexpr char PropertySetRegistry::SYCL_EXPORTED_SYMBOLS[];
198-
constexpr char PropertySetRegistry::SYCL_IMPORTED_SYMBOLS[];
199-
constexpr char PropertySetRegistry::SYCL_DEVICE_GLOBALS[];
200-
constexpr char PropertySetRegistry::SYCL_DEVICE_REQUIREMENTS[];
201-
constexpr char PropertySetRegistry::SYCL_HOST_PIPES[];
202-
constexpr char PropertySetRegistry::SYCL_VIRTUAL_FUNCTIONS[];
193+
constexpr char SYCLPropertySetRegistry::SYCL_SPECIALIZATION_CONSTANTS[];
194+
constexpr char SYCLPropertySetRegistry::SYCL_DEVICELIB_REQ_MASK[];
195+
constexpr char SYCLPropertySetRegistry::SYCL_SPEC_CONSTANTS_DEFAULT_VALUES[];
196+
constexpr char SYCLPropertySetRegistry::SYCL_KERNEL_PARAM_OPT_INFO[];
197+
constexpr char SYCLPropertySetRegistry::SYCL_PROGRAM_METADATA[];
198+
constexpr char SYCLPropertySetRegistry::SYCL_MISC_PROP[];
199+
constexpr char SYCLPropertySetRegistry::SYCL_ASSERT_USED[];
200+
constexpr char SYCLPropertySetRegistry::SYCL_EXPORTED_SYMBOLS[];
201+
constexpr char SYCLPropertySetRegistry::SYCL_IMPORTED_SYMBOLS[];
202+
constexpr char SYCLPropertySetRegistry::SYCL_DEVICE_GLOBALS[];
203+
constexpr char SYCLPropertySetRegistry::SYCL_DEVICE_REQUIREMENTS[];
204+
constexpr char SYCLPropertySetRegistry::SYCL_HOST_PIPES[];
205+
constexpr char SYCLPropertySetRegistry::SYCL_VIRTUAL_FUNCTIONS[];
203206

204207
} // namespace util
205208
} // namespace llvm

llvm/unittests/Support/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ add_llvm_unittest(SupportTests
6969
PerThreadBumpPtrAllocatorTest.cpp
7070
ProcessTest.cpp
7171
ProgramTest.cpp
72-
PropertySetIOTest.cpp
72+
SYCLPropertySetIOTest.cpp
7373
RegexTest.cpp
7474
ReverseIterationTest.cpp
7575
ReplaceFileTest.cpp

0 commit comments

Comments
 (0)