@@ -185,7 +185,7 @@ class BuiltinNameEmitter {
185
185
// <<float>, 5>,
186
186
// ...
187
187
// <<double, double>, 35>.
188
- std::vector<std::pair<std::vector<Record *>, unsigned >> SignaturesList;
188
+ std::vector<std::pair<std::vector<const Record *>, unsigned >> SignaturesList;
189
189
190
190
// Map the name of a builtin function to its prototypes (instances of the
191
191
// TableGen "Builtin" class).
@@ -261,8 +261,8 @@ class OpenCLBuiltinFileEmitterBase {
261
261
// Return the type(s) and vector size(s) for the given type. For
262
262
// non-GenericTypes, the resulting vectors will contain 1 element. For
263
263
// GenericTypes, the resulting vectors typically contain multiple elements.
264
- void getTypeLists (Record *Type, TypeFlags &Flags,
265
- std::vector<Record *> &TypeList,
264
+ void getTypeLists (const Record *Type, TypeFlags &Flags,
265
+ std::vector<const Record *> &TypeList,
266
266
std::vector<int64_t > &VectorList) const ;
267
267
268
268
// Expand the TableGen Records representing a builtin function signature into
@@ -278,7 +278,7 @@ class OpenCLBuiltinFileEmitterBase {
278
278
// [char, float3, float3]
279
279
// ...
280
280
void
281
- expandTypesInSignature (const std::vector< Record *> & Signature,
281
+ expandTypesInSignature (ArrayRef< const Record *> Signature,
282
282
SmallVectorImpl<SmallVector<std::string, 2 >> &Types);
283
283
284
284
// Emit extension enabling pragmas.
@@ -458,7 +458,7 @@ struct OpenCLBuiltinStruct {
458
458
// the same number of actual scalar or vector types.
459
459
//
460
460
// Exit with a fatal error if an unsupported construct is encountered.
461
- static void VerifySignature (const std::vector< Record *> & Signature,
461
+ static void VerifySignature (ArrayRef< const Record *> Signature,
462
462
const Record *BuiltinRec) {
463
463
unsigned GenTypeVecSizes = 1 ;
464
464
unsigned GenTypeTypes = 1 ;
@@ -480,8 +480,9 @@ static void VerifySignature(const std::vector<Record *> &Signature,
480
480
}
481
481
482
482
// Check number of data types.
483
- unsigned NTypes =
484
- T->getValueAsDef (" TypeList" )->getValueAsListOfDefs (" List" ).size ();
483
+ unsigned NTypes = T->getValueAsDef (" TypeList" )
484
+ ->getValueAsListOfConstDefs (" List" )
485
+ .size ();
485
486
if (NTypes != GenTypeTypes && NTypes != 1 ) {
486
487
if (GenTypeTypes > 1 ) {
487
488
// We already saw a gentype with a different number of types.
@@ -511,12 +512,13 @@ void BuiltinNameEmitter::GetOverloads() {
511
512
StringRef BName = B->getValueAsString (" Name" );
512
513
FctOverloadMap.try_emplace (BName);
513
514
514
- auto Signature = B->getValueAsListOfDefs (" Signature" );
515
+ auto Signature = B->getValueAsListOfConstDefs (" Signature" );
515
516
// Reuse signatures to avoid unnecessary duplicates.
516
- auto it = find_if (SignaturesList,
517
- [&](const std::pair<std::vector<Record *>, unsigned > &a) {
518
- return a.first == Signature;
519
- });
517
+ auto it =
518
+ find_if (SignaturesList,
519
+ [&](const std::pair<std::vector<const Record *>, unsigned > &a) {
520
+ return a.first == Signature;
521
+ });
520
522
unsigned SignIndex;
521
523
if (it == SignaturesList.end ()) {
522
524
VerifySignature (Signature, B);
@@ -634,8 +636,8 @@ void BuiltinNameEmitter::EmitBuiltinTable() {
634
636
Overload.first ->getValueAsDef (" MaxVersion" )->getValueAsInt (" ID" );
635
637
636
638
OS << " { " << Overload.second << " , "
637
- << Overload.first ->getValueAsListOfDefs (" Signature" ).size () << " , "
638
- << (Overload.first ->getValueAsBit (" IsPure" )) << " , "
639
+ << Overload.first ->getValueAsListOfConstDefs (" Signature" ).size ()
640
+ << " , " << (Overload.first ->getValueAsBit (" IsPure" )) << " , "
639
641
<< (Overload.first ->getValueAsBit (" IsConst" )) << " , "
640
642
<< (Overload.first ->getValueAsBit (" IsConv" )) << " , "
641
643
<< FunctionExtensionIndex[ExtName] << " , "
@@ -849,8 +851,8 @@ static void OCL2Qual(Sema &S, const OpenCLTypeStruct &Ty,
849
851
// Build the Cartesian product of (vector sizes) x (types). Only insert
850
852
// the plain scalar types for now; other type information such as vector
851
853
// size and type qualifiers will be added after the switch statement.
852
- std::vector<Record *> BaseTypes =
853
- GenType->getValueAsDef (" TypeList" )->getValueAsListOfDefs (" List" );
854
+ std::vector<const Record *> BaseTypes =
855
+ GenType->getValueAsDef (" TypeList" )->getValueAsListOfConstDefs (" List" );
854
856
855
857
// Collect all QualTypes for a single vector size into TypeList.
856
858
OS << " SmallVector<QualType, " << BaseTypes.size () << " > TypeList;\n " ;
@@ -1022,11 +1024,12 @@ std::string OpenCLBuiltinFileEmitterBase::getTypeString(const Record *Type,
1022
1024
}
1023
1025
1024
1026
void OpenCLBuiltinFileEmitterBase::getTypeLists (
1025
- Record *Type, TypeFlags &Flags, std::vector<Record *> &TypeList,
1027
+ const Record *Type, TypeFlags &Flags, std::vector<const Record *> &TypeList,
1026
1028
std::vector<int64_t > &VectorList) const {
1027
1029
bool isGenType = Type->isSubClassOf (" GenericType" );
1028
1030
if (isGenType) {
1029
- TypeList = Type->getValueAsDef (" TypeList" )->getValueAsListOfDefs (" List" );
1031
+ TypeList =
1032
+ Type->getValueAsDef (" TypeList" )->getValueAsListOfConstDefs (" List" );
1030
1033
VectorList =
1031
1034
Type->getValueAsDef (" VectorList" )->getValueAsListOfInts (" List" );
1032
1035
return ;
@@ -1035,7 +1038,7 @@ void OpenCLBuiltinFileEmitterBase::getTypeLists(
1035
1038
if (Type->isSubClassOf (" PointerType" ) || Type->isSubClassOf (" ConstType" ) ||
1036
1039
Type->isSubClassOf (" VolatileType" )) {
1037
1040
StringRef SubTypeName = Type->getValueAsString (" Name" );
1038
- Record *PossibleGenType = Records.getDef (SubTypeName);
1041
+ const Record *PossibleGenType = Records.getDef (SubTypeName);
1039
1042
if (PossibleGenType && PossibleGenType->isSubClassOf (" GenericType" )) {
1040
1043
// When PointerType, ConstType, or VolatileType is applied to a
1041
1044
// GenericType, the flags need to be taken from the subtype, not from the
@@ -1055,15 +1058,15 @@ void OpenCLBuiltinFileEmitterBase::getTypeLists(
1055
1058
}
1056
1059
1057
1060
void OpenCLBuiltinFileEmitterBase::expandTypesInSignature (
1058
- const std::vector< Record *> & Signature,
1061
+ ArrayRef< const Record *> Signature,
1059
1062
SmallVectorImpl<SmallVector<std::string, 2 >> &Types) {
1060
1063
// Find out if there are any GenTypes in this signature, and if so, calculate
1061
1064
// into how many signatures they will expand.
1062
1065
unsigned NumSignatures = 1 ;
1063
1066
SmallVector<SmallVector<std::string, 4 >, 4 > ExpandedGenTypes;
1064
1067
for (const auto &Arg : Signature) {
1065
1068
SmallVector<std::string, 4 > ExpandedArg;
1066
- std::vector<Record *> TypeList;
1069
+ std::vector<const Record *> TypeList;
1067
1070
std::vector<int64_t > VectorList;
1068
1071
TypeFlags Flags;
1069
1072
@@ -1212,7 +1215,7 @@ void OpenCLBuiltinTestEmitter::emit() {
1212
1215
StringRef Name = B->getValueAsString (" Name" );
1213
1216
1214
1217
SmallVector<SmallVector<std::string, 2 >, 4 > FTypes;
1215
- expandTypesInSignature (B->getValueAsListOfDefs (" Signature" ), FTypes);
1218
+ expandTypesInSignature (B->getValueAsListOfConstDefs (" Signature" ), FTypes);
1216
1219
1217
1220
OS << " // Test " << Name << " \n " ;
1218
1221
@@ -1281,7 +1284,7 @@ void OpenCLBuiltinHeaderEmitter::emit() {
1281
1284
std::string OptionalVersionEndif = emitVersionGuard (B);
1282
1285
1283
1286
SmallVector<SmallVector<std::string, 2 >, 4 > FTypes;
1284
- expandTypesInSignature (B->getValueAsListOfDefs (" Signature" ), FTypes);
1287
+ expandTypesInSignature (B->getValueAsListOfConstDefs (" Signature" ), FTypes);
1285
1288
1286
1289
for (const auto &Signature : FTypes) {
1287
1290
StringRef OptionalTypeExtEndif = emitTypeExtensionGuards (Signature);
0 commit comments