@@ -958,7 +958,7 @@ class ACLEIntrinsic {
958958 " ;\n " ;
959959 }
960960
961- ACLEIntrinsic (EmitterBase &ME, Record *R, const Type *Param);
961+ ACLEIntrinsic (EmitterBase &ME, const Record *R, const Type *Param);
962962};
963963
964964// -----------------------------------------------------------------------------
@@ -988,7 +988,7 @@ class EmitterBase {
988988 const ScalarType *getScalarType (StringRef Name) {
989989 return ScalarTypes[std::string (Name)].get ();
990990 }
991- const ScalarType *getScalarType (Record *R) {
991+ const ScalarType *getScalarType (const Record *R) {
992992 return getScalarType (R->getName ());
993993 }
994994 const VectorType *getVectorType (const ScalarType *ST, unsigned Lanes) {
@@ -1028,7 +1028,7 @@ class EmitterBase {
10281028 // the Params list in the Tablegen record for the intrinsic), which is used
10291029 // to expand Tablegen classes like 'Vector' which mean something different in
10301030 // each member of a parametric family.
1031- const Type *getType (Record *R, const Type *Param);
1031+ const Type *getType (const Record *R, const Type *Param);
10321032 const Type *getType (DagInit *D, const Type *Param);
10331033 const Type *getType (Init *I, const Type *Param);
10341034
@@ -1046,7 +1046,7 @@ class EmitterBase {
10461046
10471047 // Constructor and top-level functions.
10481048
1049- EmitterBase (RecordKeeper &Records);
1049+ EmitterBase (const RecordKeeper &Records);
10501050 virtual ~EmitterBase () = default ;
10511051
10521052 virtual void EmitHeader (raw_ostream &OS) = 0;
@@ -1065,7 +1065,7 @@ const Type *EmitterBase::getType(Init *I, const Type *Param) {
10651065 PrintFatalError (" Could not convert this value into a type" );
10661066}
10671067
1068- const Type *EmitterBase::getType (Record *R, const Type *Param) {
1068+ const Type *EmitterBase::getType (const Record *R, const Type *Param) {
10691069 // Pass to a subfield of any wrapper records. We don't expect more than one
10701070 // of these: immediate operands are used as plain numbers rather than as
10711071 // llvm::Value, so it's meaningless to promote their type anyway.
@@ -1088,7 +1088,7 @@ const Type *EmitterBase::getType(DagInit *D, const Type *Param) {
10881088 // The meat of the getType system: types in the Tablegen are represented by a
10891089 // dag whose operators select sub-cases of this function.
10901090
1091- Record *Op = cast<DefInit>(D->getOperator ())->getDef ();
1091+ const Record *Op = cast<DefInit>(D->getOperator ())->getDef ();
10921092 if (!Op->isSubClassOf (" ComplexTypeOp" ))
10931093 PrintFatalError (
10941094 " Expected ComplexTypeOp as dag operator in type expression" );
@@ -1154,7 +1154,7 @@ const Type *EmitterBase::getType(DagInit *D, const Type *Param) {
11541154
11551155Result::Ptr EmitterBase::getCodeForDag (DagInit *D, const Result::Scope &Scope,
11561156 const Type *Param) {
1157- Record *Op = cast<DefInit>(D->getOperator ())->getDef ();
1157+ const Record *Op = cast<DefInit>(D->getOperator ())->getDef ();
11581158
11591159 if (Op->getName () == " seq" ) {
11601160 Result::Scope SubScope = Scope;
@@ -1211,7 +1211,7 @@ Result::Ptr EmitterBase::getCodeForDag(DagInit *D, const Result::Scope &Scope,
12111211 } else if (Op->getName () == " unsignedflag" ) {
12121212 if (D->getNumArgs () != 1 )
12131213 PrintFatalError (" unsignedflag should have exactly one argument" );
1214- Record *TypeRec = cast<DefInit>(D->getArg (0 ))->getDef ();
1214+ const Record *TypeRec = cast<DefInit>(D->getArg (0 ))->getDef ();
12151215 if (!TypeRec->isSubClassOf (" Type" ))
12161216 PrintFatalError (" unsignedflag's argument should be a type" );
12171217 if (const auto *ST = dyn_cast<ScalarType>(getType (TypeRec, Param))) {
@@ -1223,7 +1223,7 @@ Result::Ptr EmitterBase::getCodeForDag(DagInit *D, const Result::Scope &Scope,
12231223 } else if (Op->getName () == " bitsize" ) {
12241224 if (D->getNumArgs () != 1 )
12251225 PrintFatalError (" bitsize should have exactly one argument" );
1226- Record *TypeRec = cast<DefInit>(D->getArg (0 ))->getDef ();
1226+ const Record *TypeRec = cast<DefInit>(D->getArg (0 ))->getDef ();
12271227 if (!TypeRec->isSubClassOf (" Type" ))
12281228 PrintFatalError (" bitsize's argument should be a type" );
12291229 if (const auto *ST = dyn_cast<ScalarType>(getType (TypeRec, Param))) {
@@ -1239,7 +1239,7 @@ Result::Ptr EmitterBase::getCodeForDag(DagInit *D, const Result::Scope &Scope,
12391239 if (Op->isSubClassOf (" IRBuilderBase" )) {
12401240 std::set<unsigned > AddressArgs;
12411241 std::map<unsigned , std::string> IntegerArgs;
1242- for (Record *sp : Op->getValueAsListOfDefs (" special_params" )) {
1242+ for (const Record *sp : Op->getValueAsListOfDefs (" special_params" )) {
12431243 unsigned Index = sp->getValueAsInt (" index" );
12441244 if (sp->isSubClassOf (" IRBuilderAddrParam" )) {
12451245 AddressArgs.insert (Index);
@@ -1251,7 +1251,7 @@ Result::Ptr EmitterBase::getCodeForDag(DagInit *D, const Result::Scope &Scope,
12511251 Args, AddressArgs, IntegerArgs);
12521252 } else if (Op->isSubClassOf (" IRIntBase" )) {
12531253 std::vector<const Type *> ParamTypes;
1254- for (Record *RParam : Op->getValueAsListOfDefs (" params" ))
1254+ for (const Record *RParam : Op->getValueAsListOfDefs (" params" ))
12551255 ParamTypes.push_back (getType (RParam, Param));
12561256 std::string IntName = std::string (Op->getValueAsString (" intname" ));
12571257 if (Op->getValueAsBit (" appendKind" ))
@@ -1294,7 +1294,7 @@ Result::Ptr EmitterBase::getCodeForDagArg(DagInit *D, unsigned ArgNum,
12941294 return getCodeForDag (DI, Scope, Param);
12951295
12961296 if (auto *DI = dyn_cast<DefInit>(Arg)) {
1297- Record *Rec = DI->getDef ();
1297+ const Record *Rec = DI->getDef ();
12981298 if (Rec->isSubClassOf (" Type" )) {
12991299 const Type *T = getType (Rec, Param);
13001300 return std::make_shared<TypeResult>(T);
@@ -1328,7 +1328,8 @@ Result::Ptr EmitterBase::getCodeForArg(unsigned ArgNum, const Type *ArgType,
13281328 return V;
13291329}
13301330
1331- ACLEIntrinsic::ACLEIntrinsic (EmitterBase &ME, Record *R, const Type *Param)
1331+ ACLEIntrinsic::ACLEIntrinsic (EmitterBase &ME, const Record *R,
1332+ const Type *Param)
13321333 : ReturnType(ME.getType(R->getValueAsDef (" ret" ), Param)) {
13331334 // Derive the intrinsic's full name, by taking the name of the
13341335 // Tablegen record (or override) and appending the suffix from its
@@ -1346,7 +1347,7 @@ ACLEIntrinsic::ACLEIntrinsic(EmitterBase &ME, Record *R, const Type *Param)
13461347 // full name as specified by its 'pnt' member ('polymorphic name type'),
13471348 // which indicates how many type suffixes to remove, and any other piece of
13481349 // the name that should be removed.
1349- Record *PolymorphicNameType = R->getValueAsDef (" pnt" );
1350+ const Record *PolymorphicNameType = R->getValueAsDef (" pnt" );
13501351 SmallVector<StringRef, 8 > NameParts;
13511352 StringRef (FullName).split (NameParts, ' _' );
13521353 for (unsigned i = 0 , e = PolymorphicNameType->getValueAsInt (
@@ -1393,11 +1394,11 @@ ACLEIntrinsic::ACLEIntrinsic(EmitterBase &ME, Record *R, const Type *Param)
13931394 // what values it can take, for Sema checking.
13941395 bool Immediate = false ;
13951396 if (auto TypeDI = dyn_cast<DefInit>(TypeInit)) {
1396- Record *TypeRec = TypeDI->getDef ();
1397+ const Record *TypeRec = TypeDI->getDef ();
13971398 if (TypeRec->isSubClassOf (" Immediate" )) {
13981399 Immediate = true ;
13991400
1400- Record *Bounds = TypeRec->getValueAsDef (" bounds" );
1401+ const Record *Bounds = TypeRec->getValueAsDef (" bounds" );
14011402 ImmediateArg &IA = ImmediateArgs[i];
14021403 if (Bounds->isSubClassOf (" IB_ConstRange" )) {
14031404 IA.boundsType = ImmediateArg::BoundsType::ExplicitRange;
@@ -1440,7 +1441,7 @@ ACLEIntrinsic::ACLEIntrinsic(EmitterBase &ME, Record *R, const Type *Param)
14401441 // Finally, go through the codegen dag and translate it into a Result object
14411442 // (with an arbitrary DAG of depended-on Results hanging off it).
14421443 DagInit *CodeDag = R->getValueAsDag (" codegen" );
1443- Record *MainOp = cast<DefInit>(CodeDag->getOperator ())->getDef ();
1444+ const Record *MainOp = cast<DefInit>(CodeDag->getOperator ())->getDef ();
14441445 if (MainOp->isSubClassOf (" CustomCodegen" )) {
14451446 // Or, if it's the special case of CustomCodegen, just accumulate
14461447 // a list of parameters we're going to assign to variables before
@@ -1464,21 +1465,21 @@ ACLEIntrinsic::ACLEIntrinsic(EmitterBase &ME, Record *R, const Type *Param)
14641465 }
14651466}
14661467
1467- EmitterBase::EmitterBase (RecordKeeper &Records) {
1468+ EmitterBase::EmitterBase (const RecordKeeper &Records) {
14681469 // Construct the whole EmitterBase.
14691470
14701471 // First, look up all the instances of PrimitiveType. This gives us the list
14711472 // of vector typedefs we have to put in arm_mve.h, and also allows us to
14721473 // collect all the useful ScalarType instances into a big list so that we can
14731474 // use it for operations such as 'find the unsigned version of this signed
14741475 // integer type'.
1475- for (Record *R : Records.getAllDerivedDefinitions (" PrimitiveType" ))
1476+ for (const Record *R : Records.getAllDerivedDefinitions (" PrimitiveType" ))
14761477 ScalarTypes[std::string (R->getName ())] = std::make_unique<ScalarType>(R);
14771478
14781479 // Now go through the instances of Intrinsic, and for each one, iterate
14791480 // through its list of type parameters making an ACLEIntrinsic for each one.
1480- for (Record *R : Records.getAllDerivedDefinitions (" Intrinsic" )) {
1481- for (Record *RParam : R->getValueAsListOfDefs (" params" )) {
1481+ for (const Record *R : Records.getAllDerivedDefinitions (" Intrinsic" )) {
1482+ for (const Record *RParam : R->getValueAsListOfDefs (" params" )) {
14821483 const Type *Param = getType (RParam, getVoidType ());
14831484 auto Intrinsic = std::make_unique<ACLEIntrinsic>(*this , R, Param);
14841485 ACLEIntrinsics[Intrinsic->fullName ()] = std::move (Intrinsic);
@@ -1752,7 +1753,7 @@ void EmitterBase::GroupSemaChecks(
17521753
17531754class MveEmitter : public EmitterBase {
17541755public:
1755- MveEmitter (RecordKeeper &Records) : EmitterBase(Records){};
1756+ MveEmitter (const RecordKeeper &Records) : EmitterBase(Records){}
17561757 void EmitHeader (raw_ostream &OS) override ;
17571758 void EmitBuiltinDef (raw_ostream &OS) override ;
17581759 void EmitBuiltinSema (raw_ostream &OS) override ;
@@ -2010,14 +2011,14 @@ class CdeEmitter : public EmitterBase {
20102011 std::map<StringRef, FunctionMacro> FunctionMacros;
20112012
20122013public:
2013- CdeEmitter (RecordKeeper &Records);
2014+ CdeEmitter (const RecordKeeper &Records);
20142015 void EmitHeader (raw_ostream &OS) override ;
20152016 void EmitBuiltinDef (raw_ostream &OS) override ;
20162017 void EmitBuiltinSema (raw_ostream &OS) override ;
20172018};
20182019
2019- CdeEmitter::CdeEmitter (RecordKeeper &Records) : EmitterBase(Records) {
2020- for (Record *R : Records.getAllDerivedDefinitions (" FunctionMacro" ))
2020+ CdeEmitter::CdeEmitter (const RecordKeeper &Records) : EmitterBase(Records) {
2021+ for (const Record *R : Records.getAllDerivedDefinitions (" FunctionMacro" ))
20212022 FunctionMacros.emplace (R->getName (), FunctionMacro (*R));
20222023}
20232024
@@ -2179,45 +2180,45 @@ namespace clang {
21792180
21802181// MVE
21812182
2182- void EmitMveHeader (RecordKeeper &Records, raw_ostream &OS) {
2183+ void EmitMveHeader (const RecordKeeper &Records, raw_ostream &OS) {
21832184 MveEmitter (Records).EmitHeader (OS);
21842185}
21852186
2186- void EmitMveBuiltinDef (RecordKeeper &Records, raw_ostream &OS) {
2187+ void EmitMveBuiltinDef (const RecordKeeper &Records, raw_ostream &OS) {
21872188 MveEmitter (Records).EmitBuiltinDef (OS);
21882189}
21892190
2190- void EmitMveBuiltinSema (RecordKeeper &Records, raw_ostream &OS) {
2191+ void EmitMveBuiltinSema (const RecordKeeper &Records, raw_ostream &OS) {
21912192 MveEmitter (Records).EmitBuiltinSema (OS);
21922193}
21932194
2194- void EmitMveBuiltinCG (RecordKeeper &Records, raw_ostream &OS) {
2195+ void EmitMveBuiltinCG (const RecordKeeper &Records, raw_ostream &OS) {
21952196 MveEmitter (Records).EmitBuiltinCG (OS);
21962197}
21972198
2198- void EmitMveBuiltinAliases (RecordKeeper &Records, raw_ostream &OS) {
2199+ void EmitMveBuiltinAliases (const RecordKeeper &Records, raw_ostream &OS) {
21992200 MveEmitter (Records).EmitBuiltinAliases (OS);
22002201}
22012202
22022203// CDE
22032204
2204- void EmitCdeHeader (RecordKeeper &Records, raw_ostream &OS) {
2205+ void EmitCdeHeader (const RecordKeeper &Records, raw_ostream &OS) {
22052206 CdeEmitter (Records).EmitHeader (OS);
22062207}
22072208
2208- void EmitCdeBuiltinDef (RecordKeeper &Records, raw_ostream &OS) {
2209+ void EmitCdeBuiltinDef (const RecordKeeper &Records, raw_ostream &OS) {
22092210 CdeEmitter (Records).EmitBuiltinDef (OS);
22102211}
22112212
2212- void EmitCdeBuiltinSema (RecordKeeper &Records, raw_ostream &OS) {
2213+ void EmitCdeBuiltinSema (const RecordKeeper &Records, raw_ostream &OS) {
22132214 CdeEmitter (Records).EmitBuiltinSema (OS);
22142215}
22152216
2216- void EmitCdeBuiltinCG (RecordKeeper &Records, raw_ostream &OS) {
2217+ void EmitCdeBuiltinCG (const RecordKeeper &Records, raw_ostream &OS) {
22172218 CdeEmitter (Records).EmitBuiltinCG (OS);
22182219}
22192220
2220- void EmitCdeBuiltinAliases (RecordKeeper &Records, raw_ostream &OS) {
2221+ void EmitCdeBuiltinAliases (const RecordKeeper &Records, raw_ostream &OS) {
22212222 CdeEmitter (Records).EmitBuiltinAliases (OS);
22222223}
22232224
0 commit comments