@@ -185,7 +185,7 @@ class BuiltinNameEmitter {
185185 // <<float>, 5>,
186186 // ...
187187 // <<double, double>, 35>.
188- std::vector<std::pair<std::vector<Record *>, unsigned >> SignaturesList;
188+ std::vector<std::pair<std::vector<const Record *>, unsigned >> SignaturesList;
189189
190190 // Map the name of a builtin function to its prototypes (instances of the
191191 // TableGen "Builtin" class).
@@ -261,8 +261,8 @@ class OpenCLBuiltinFileEmitterBase {
261261 // Return the type(s) and vector size(s) for the given type. For
262262 // non-GenericTypes, the resulting vectors will contain 1 element. For
263263 // 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,
266266 std::vector<int64_t > &VectorList) const ;
267267
268268 // Expand the TableGen Records representing a builtin function signature into
@@ -278,7 +278,7 @@ class OpenCLBuiltinFileEmitterBase {
278278 // [char, float3, float3]
279279 // ...
280280 void
281- expandTypesInSignature (const std::vector< Record *> & Signature,
281+ expandTypesInSignature (ArrayRef< const Record *> Signature,
282282 SmallVectorImpl<SmallVector<std::string, 2 >> &Types);
283283
284284 // Emit extension enabling pragmas.
@@ -458,7 +458,7 @@ struct OpenCLBuiltinStruct {
458458// the same number of actual scalar or vector types.
459459//
460460// 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,
462462 const Record *BuiltinRec) {
463463 unsigned GenTypeVecSizes = 1 ;
464464 unsigned GenTypeTypes = 1 ;
@@ -480,8 +480,9 @@ static void VerifySignature(const std::vector<Record *> &Signature,
480480 }
481481
482482 // 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 ();
485486 if (NTypes != GenTypeTypes && NTypes != 1 ) {
486487 if (GenTypeTypes > 1 ) {
487488 // We already saw a gentype with a different number of types.
@@ -511,12 +512,13 @@ void BuiltinNameEmitter::GetOverloads() {
511512 StringRef BName = B->getValueAsString (" Name" );
512513 FctOverloadMap.try_emplace (BName);
513514
514- auto Signature = B->getValueAsListOfDefs (" Signature" );
515+ auto Signature = B->getValueAsListOfConstDefs (" Signature" );
515516 // 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+ });
520522 unsigned SignIndex;
521523 if (it == SignaturesList.end ()) {
522524 VerifySignature (Signature, B);
@@ -634,8 +636,8 @@ void BuiltinNameEmitter::EmitBuiltinTable() {
634636 Overload.first ->getValueAsDef (" MaxVersion" )->getValueAsInt (" ID" );
635637
636638 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" )) << " , "
639641 << (Overload.first ->getValueAsBit (" IsConst" )) << " , "
640642 << (Overload.first ->getValueAsBit (" IsConv" )) << " , "
641643 << FunctionExtensionIndex[ExtName] << " , "
@@ -849,8 +851,8 @@ static void OCL2Qual(Sema &S, const OpenCLTypeStruct &Ty,
849851 // Build the Cartesian product of (vector sizes) x (types). Only insert
850852 // the plain scalar types for now; other type information such as vector
851853 // 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" );
854856
855857 // Collect all QualTypes for a single vector size into TypeList.
856858 OS << " SmallVector<QualType, " << BaseTypes.size () << " > TypeList;\n " ;
@@ -1022,11 +1024,12 @@ std::string OpenCLBuiltinFileEmitterBase::getTypeString(const Record *Type,
10221024}
10231025
10241026void OpenCLBuiltinFileEmitterBase::getTypeLists (
1025- Record *Type, TypeFlags &Flags, std::vector<Record *> &TypeList,
1027+ const Record *Type, TypeFlags &Flags, std::vector<const Record *> &TypeList,
10261028 std::vector<int64_t > &VectorList) const {
10271029 bool isGenType = Type->isSubClassOf (" GenericType" );
10281030 if (isGenType) {
1029- TypeList = Type->getValueAsDef (" TypeList" )->getValueAsListOfDefs (" List" );
1031+ TypeList =
1032+ Type->getValueAsDef (" TypeList" )->getValueAsListOfConstDefs (" List" );
10301033 VectorList =
10311034 Type->getValueAsDef (" VectorList" )->getValueAsListOfInts (" List" );
10321035 return ;
@@ -1035,7 +1038,7 @@ void OpenCLBuiltinFileEmitterBase::getTypeLists(
10351038 if (Type->isSubClassOf (" PointerType" ) || Type->isSubClassOf (" ConstType" ) ||
10361039 Type->isSubClassOf (" VolatileType" )) {
10371040 StringRef SubTypeName = Type->getValueAsString (" Name" );
1038- Record *PossibleGenType = Records.getDef (SubTypeName);
1041+ const Record *PossibleGenType = Records.getDef (SubTypeName);
10391042 if (PossibleGenType && PossibleGenType->isSubClassOf (" GenericType" )) {
10401043 // When PointerType, ConstType, or VolatileType is applied to a
10411044 // GenericType, the flags need to be taken from the subtype, not from the
@@ -1055,15 +1058,15 @@ void OpenCLBuiltinFileEmitterBase::getTypeLists(
10551058}
10561059
10571060void OpenCLBuiltinFileEmitterBase::expandTypesInSignature (
1058- const std::vector< Record *> & Signature,
1061+ ArrayRef< const Record *> Signature,
10591062 SmallVectorImpl<SmallVector<std::string, 2 >> &Types) {
10601063 // Find out if there are any GenTypes in this signature, and if so, calculate
10611064 // into how many signatures they will expand.
10621065 unsigned NumSignatures = 1 ;
10631066 SmallVector<SmallVector<std::string, 4 >, 4 > ExpandedGenTypes;
10641067 for (const auto &Arg : Signature) {
10651068 SmallVector<std::string, 4 > ExpandedArg;
1066- std::vector<Record *> TypeList;
1069+ std::vector<const Record *> TypeList;
10671070 std::vector<int64_t > VectorList;
10681071 TypeFlags Flags;
10691072
@@ -1212,7 +1215,7 @@ void OpenCLBuiltinTestEmitter::emit() {
12121215 StringRef Name = B->getValueAsString (" Name" );
12131216
12141217 SmallVector<SmallVector<std::string, 2 >, 4 > FTypes;
1215- expandTypesInSignature (B->getValueAsListOfDefs (" Signature" ), FTypes);
1218+ expandTypesInSignature (B->getValueAsListOfConstDefs (" Signature" ), FTypes);
12161219
12171220 OS << " // Test " << Name << " \n " ;
12181221
@@ -1281,7 +1284,7 @@ void OpenCLBuiltinHeaderEmitter::emit() {
12811284 std::string OptionalVersionEndif = emitVersionGuard (B);
12821285
12831286 SmallVector<SmallVector<std::string, 2 >, 4 > FTypes;
1284- expandTypesInSignature (B->getValueAsListOfDefs (" Signature" ), FTypes);
1287+ expandTypesInSignature (B->getValueAsListOfConstDefs (" Signature" ), FTypes);
12851288
12861289 for (const auto &Signature : FTypes) {
12871290 StringRef OptionalTypeExtEndif = emitTypeExtensionGuards (Signature);
0 commit comments