@@ -87,7 +87,7 @@ struct BuiltinTableEntries {
87
87
//
88
88
class BuiltinNameEmitter {
89
89
public:
90
- BuiltinNameEmitter (RecordKeeper &Records, raw_ostream &OS)
90
+ BuiltinNameEmitter (const RecordKeeper &Records, raw_ostream &OS)
91
91
: Records(Records), OS(OS) {}
92
92
93
93
// Entrypoint to generate the functions and structures for checking
@@ -100,7 +100,7 @@ class BuiltinNameEmitter {
100
100
101
101
// Contains OpenCL builtin functions and related information, stored as
102
102
// Record instances. They are coming from the associated TableGen file.
103
- RecordKeeper &Records;
103
+ const RecordKeeper &Records;
104
104
105
105
// The output file.
106
106
raw_ostream &OS;
@@ -113,7 +113,7 @@ class BuiltinNameEmitter {
113
113
// \param Output (out) String containing the enums to emit in the output file.
114
114
// \param List (out) List containing the extracted Types, except the Types in
115
115
// TypesSeen.
116
- void ExtractEnumTypes (std::vector< Record *> & Types,
116
+ void ExtractEnumTypes (ArrayRef< const Record *> Types,
117
117
StringMap<bool > &TypesSeen, std::string &Output,
118
118
std::vector<const Record *> &List);
119
119
@@ -237,7 +237,7 @@ class BuiltinNameEmitter {
237
237
// / Base class for emitting a file (e.g. header or test) from OpenCLBuiltins.td
238
238
class OpenCLBuiltinFileEmitterBase {
239
239
public:
240
- OpenCLBuiltinFileEmitterBase (RecordKeeper &Records, raw_ostream &OS)
240
+ OpenCLBuiltinFileEmitterBase (const RecordKeeper &Records, raw_ostream &OS)
241
241
: Records(Records), OS(OS) {}
242
242
virtual ~OpenCLBuiltinFileEmitterBase () = default ;
243
243
@@ -305,7 +305,7 @@ class OpenCLBuiltinFileEmitterBase {
305
305
306
306
// Contains OpenCL builtin functions and related information, stored as
307
307
// Record instances. They are coming from the associated TableGen file.
308
- RecordKeeper &Records;
308
+ const RecordKeeper &Records;
309
309
310
310
// The output file.
311
311
raw_ostream &OS;
@@ -316,7 +316,7 @@ class OpenCLBuiltinFileEmitterBase {
316
316
// builtin function described in the .td input.
317
317
class OpenCLBuiltinTestEmitter : public OpenCLBuiltinFileEmitterBase {
318
318
public:
319
- OpenCLBuiltinTestEmitter (RecordKeeper &Records, raw_ostream &OS)
319
+ OpenCLBuiltinTestEmitter (const RecordKeeper &Records, raw_ostream &OS)
320
320
: OpenCLBuiltinFileEmitterBase(Records, OS) {}
321
321
322
322
// Entrypoint to generate the functions for testing all OpenCL builtin
@@ -329,7 +329,7 @@ class OpenCLBuiltinTestEmitter : public OpenCLBuiltinFileEmitterBase {
329
329
// prototype for each builtin function described in the .td input.
330
330
class OpenCLBuiltinHeaderEmitter : public OpenCLBuiltinFileEmitterBase {
331
331
public:
332
- OpenCLBuiltinHeaderEmitter (RecordKeeper &Records, raw_ostream &OS)
332
+ OpenCLBuiltinHeaderEmitter (const RecordKeeper &Records, raw_ostream &OS)
333
333
: OpenCLBuiltinFileEmitterBase(Records, OS) {}
334
334
335
335
// Entrypoint to generate the header.
@@ -362,7 +362,7 @@ void BuiltinNameEmitter::Emit() {
362
362
EmitQualTypeFinder ();
363
363
}
364
364
365
- void BuiltinNameEmitter::ExtractEnumTypes (std::vector< Record *> & Types,
365
+ void BuiltinNameEmitter::ExtractEnumTypes (ArrayRef< const Record *> Types,
366
366
StringMap<bool > &TypesSeen,
367
367
std::string &Output,
368
368
std::vector<const Record *> &List) {
@@ -392,11 +392,11 @@ void BuiltinNameEmitter::EmitDeclarations() {
392
392
// Extract generic types and non-generic types separately, to keep
393
393
// gentypes at the end of the enum which simplifies the special handling
394
394
// for gentypes in SemaLookup.
395
- std::vector< Record *> GenTypes =
395
+ ArrayRef< const Record *> GenTypes =
396
396
Records.getAllDerivedDefinitions (" GenericType" );
397
397
ExtractEnumTypes (GenTypes, TypesSeen, GenTypeEnums, GenTypeList);
398
398
399
- std::vector< Record *> Types = Records.getAllDerivedDefinitions (" Type" );
399
+ ArrayRef< const Record *> Types = Records.getAllDerivedDefinitions (" Type" );
400
400
ExtractEnumTypes (Types, TypesSeen, TypeEnums, TypeList);
401
401
402
402
OS << TypeEnums;
@@ -499,15 +499,16 @@ static void VerifySignature(const std::vector<Record *> &Signature,
499
499
500
500
void BuiltinNameEmitter::GetOverloads () {
501
501
// Populate the TypeMap.
502
- std::vector< Record *> Types = Records.getAllDerivedDefinitions (" Type" );
502
+ ArrayRef< const Record *> Types = Records.getAllDerivedDefinitions (" Type" );
503
503
unsigned I = 0 ;
504
504
for (const auto &T : Types) {
505
505
TypeMap.insert (std::make_pair (T, I++));
506
506
}
507
507
508
508
// Populate the SignaturesList and the FctOverloadMap.
509
509
unsigned CumulativeSignIndex = 0 ;
510
- std::vector<Record *> Builtins = Records.getAllDerivedDefinitions (" Builtin" );
510
+ ArrayRef<const Record *> Builtins =
511
+ Records.getAllDerivedDefinitions (" Builtin" );
511
512
for (const auto *B : Builtins) {
512
513
StringRef BName = B->getValueAsString (" Name" );
513
514
FctOverloadMap.try_emplace (BName);
@@ -535,7 +536,7 @@ void BuiltinNameEmitter::GetOverloads() {
535
536
void BuiltinNameEmitter::EmitExtensionTable () {
536
537
OS << " static const char *FunctionExtensionTable[] = {\n " ;
537
538
unsigned Index = 0 ;
538
- std::vector< Record *> FuncExtensions =
539
+ ArrayRef< const Record *> FuncExtensions =
539
540
Records.getAllDerivedDefinitions (" FunctionExtension" );
540
541
541
542
for (const auto &FE : FuncExtensions) {
@@ -804,11 +805,11 @@ static void OCL2Qual(Sema &S, const OpenCLTypeStruct &Ty,
804
805
OS << " \n switch (Ty.ID) {\n " ;
805
806
806
807
// Switch cases for image types (Image2d, Image3d, ...)
807
- std::vector< Record *> ImageTypes =
808
+ ArrayRef< const Record *> ImageTypes =
808
809
Records.getAllDerivedDefinitions (" ImageType" );
809
810
810
811
// Map an image type name to its 3 access-qualified types (RO, WO, RW).
811
- StringMap<SmallVector<Record *, 3 >> ImageTypesMap;
812
+ StringMap<SmallVector<const Record *, 3 >> ImageTypesMap;
812
813
for (auto *IT : ImageTypes)
813
814
ImageTypesMap[IT->getValueAsString (" Name" )].push_back (IT);
814
815
@@ -890,7 +891,7 @@ static void OCL2Qual(Sema &S, const OpenCLTypeStruct &Ty,
890
891
// Switch cases for non generic, non image types (int, int4, float, ...).
891
892
// Only insert the plain scalar type; vector information and type qualifiers
892
893
// are added in step 2.
893
- std::vector< Record *> Types = Records.getAllDerivedDefinitions (" Type" );
894
+ ArrayRef< const Record *> Types = Records.getAllDerivedDefinitions (" Type" );
894
895
StringMap<bool > TypesSeen;
895
896
896
897
for (const auto *T : Types) {
@@ -1211,7 +1212,8 @@ void OpenCLBuiltinTestEmitter::emit() {
1211
1212
unsigned TestID = 0 ;
1212
1213
1213
1214
// Iterate over all builtins.
1214
- std::vector<Record *> Builtins = Records.getAllDerivedDefinitions (" Builtin" );
1215
+ ArrayRef<const Record *> Builtins =
1216
+ Records.getAllDerivedDefinitions (" Builtin" );
1215
1217
for (const auto *B : Builtins) {
1216
1218
StringRef Name = B->getValueAsString (" Name" );
1217
1219
@@ -1274,7 +1276,8 @@ void OpenCLBuiltinHeaderEmitter::emit() {
1274
1276
)" ;
1275
1277
1276
1278
// Iterate over all builtins; sort to follow order of definition in .td file.
1277
- std::vector<Record *> Builtins = Records.getAllDerivedDefinitions (" Builtin" );
1279
+ std::vector<const Record *> Builtins =
1280
+ Records.getAllDerivedDefinitions (" Builtin" );
1278
1281
llvm::sort (Builtins, LessRecord ());
1279
1282
1280
1283
for (const auto *B : Builtins) {
@@ -1319,18 +1322,19 @@ void OpenCLBuiltinHeaderEmitter::emit() {
1319
1322
" #pragma OPENCL EXTENSION all : disable\n " ;
1320
1323
}
1321
1324
1322
- void clang::EmitClangOpenCLBuiltins (RecordKeeper &Records, raw_ostream &OS) {
1325
+ void clang::EmitClangOpenCLBuiltins (const RecordKeeper &Records,
1326
+ raw_ostream &OS) {
1323
1327
BuiltinNameEmitter NameChecker (Records, OS);
1324
1328
NameChecker.Emit ();
1325
1329
}
1326
1330
1327
- void clang::EmitClangOpenCLBuiltinHeader (RecordKeeper &Records,
1331
+ void clang::EmitClangOpenCLBuiltinHeader (const RecordKeeper &Records,
1328
1332
raw_ostream &OS) {
1329
1333
OpenCLBuiltinHeaderEmitter HeaderFileGenerator (Records, OS);
1330
1334
HeaderFileGenerator.emit ();
1331
1335
}
1332
1336
1333
- void clang::EmitClangOpenCLBuiltinTests (RecordKeeper &Records,
1337
+ void clang::EmitClangOpenCLBuiltinTests (const RecordKeeper &Records,
1334
1338
raw_ostream &OS) {
1335
1339
OpenCLBuiltinTestEmitter TestFileGenerator (Records, OS);
1336
1340
TestFileGenerator.emit ();
0 commit comments