@@ -958,7 +958,7 @@ class ACLEIntrinsic {
958
958
" ;\n " ;
959
959
}
960
960
961
- ACLEIntrinsic (EmitterBase &ME, Record *R, const Type *Param);
961
+ ACLEIntrinsic (EmitterBase &ME, const Record *R, const Type *Param);
962
962
};
963
963
964
964
// -----------------------------------------------------------------------------
@@ -988,7 +988,7 @@ class EmitterBase {
988
988
const ScalarType *getScalarType (StringRef Name) {
989
989
return ScalarTypes[std::string (Name)].get ();
990
990
}
991
- const ScalarType *getScalarType (Record *R) {
991
+ const ScalarType *getScalarType (const Record *R) {
992
992
return getScalarType (R->getName ());
993
993
}
994
994
const VectorType *getVectorType (const ScalarType *ST, unsigned Lanes) {
@@ -1028,7 +1028,7 @@ class EmitterBase {
1028
1028
// the Params list in the Tablegen record for the intrinsic), which is used
1029
1029
// to expand Tablegen classes like 'Vector' which mean something different in
1030
1030
// 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);
1032
1032
const Type *getType (DagInit *D, const Type *Param);
1033
1033
const Type *getType (Init *I, const Type *Param);
1034
1034
@@ -1046,7 +1046,7 @@ class EmitterBase {
1046
1046
1047
1047
// Constructor and top-level functions.
1048
1048
1049
- EmitterBase (RecordKeeper &Records);
1049
+ EmitterBase (const RecordKeeper &Records);
1050
1050
virtual ~EmitterBase () = default ;
1051
1051
1052
1052
virtual void EmitHeader (raw_ostream &OS) = 0;
@@ -1065,7 +1065,7 @@ const Type *EmitterBase::getType(Init *I, const Type *Param) {
1065
1065
PrintFatalError (" Could not convert this value into a type" );
1066
1066
}
1067
1067
1068
- const Type *EmitterBase::getType (Record *R, const Type *Param) {
1068
+ const Type *EmitterBase::getType (const Record *R, const Type *Param) {
1069
1069
// Pass to a subfield of any wrapper records. We don't expect more than one
1070
1070
// of these: immediate operands are used as plain numbers rather than as
1071
1071
// llvm::Value, so it's meaningless to promote their type anyway.
@@ -1088,7 +1088,7 @@ const Type *EmitterBase::getType(DagInit *D, const Type *Param) {
1088
1088
// The meat of the getType system: types in the Tablegen are represented by a
1089
1089
// dag whose operators select sub-cases of this function.
1090
1090
1091
- Record *Op = cast<DefInit>(D->getOperator ())->getDef ();
1091
+ const Record *Op = cast<DefInit>(D->getOperator ())->getDef ();
1092
1092
if (!Op->isSubClassOf (" ComplexTypeOp" ))
1093
1093
PrintFatalError (
1094
1094
" Expected ComplexTypeOp as dag operator in type expression" );
@@ -1154,7 +1154,7 @@ const Type *EmitterBase::getType(DagInit *D, const Type *Param) {
1154
1154
1155
1155
Result::Ptr EmitterBase::getCodeForDag (DagInit *D, const Result::Scope &Scope,
1156
1156
const Type *Param) {
1157
- Record *Op = cast<DefInit>(D->getOperator ())->getDef ();
1157
+ const Record *Op = cast<DefInit>(D->getOperator ())->getDef ();
1158
1158
1159
1159
if (Op->getName () == " seq" ) {
1160
1160
Result::Scope SubScope = Scope;
@@ -1211,7 +1211,7 @@ Result::Ptr EmitterBase::getCodeForDag(DagInit *D, const Result::Scope &Scope,
1211
1211
} else if (Op->getName () == " unsignedflag" ) {
1212
1212
if (D->getNumArgs () != 1 )
1213
1213
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 ();
1215
1215
if (!TypeRec->isSubClassOf (" Type" ))
1216
1216
PrintFatalError (" unsignedflag's argument should be a type" );
1217
1217
if (const auto *ST = dyn_cast<ScalarType>(getType (TypeRec, Param))) {
@@ -1223,7 +1223,7 @@ Result::Ptr EmitterBase::getCodeForDag(DagInit *D, const Result::Scope &Scope,
1223
1223
} else if (Op->getName () == " bitsize" ) {
1224
1224
if (D->getNumArgs () != 1 )
1225
1225
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 ();
1227
1227
if (!TypeRec->isSubClassOf (" Type" ))
1228
1228
PrintFatalError (" bitsize's argument should be a type" );
1229
1229
if (const auto *ST = dyn_cast<ScalarType>(getType (TypeRec, Param))) {
@@ -1239,7 +1239,7 @@ Result::Ptr EmitterBase::getCodeForDag(DagInit *D, const Result::Scope &Scope,
1239
1239
if (Op->isSubClassOf (" IRBuilderBase" )) {
1240
1240
std::set<unsigned > AddressArgs;
1241
1241
std::map<unsigned , std::string> IntegerArgs;
1242
- for (Record *sp : Op->getValueAsListOfDefs (" special_params" )) {
1242
+ for (const Record *sp : Op->getValueAsListOfDefs (" special_params" )) {
1243
1243
unsigned Index = sp->getValueAsInt (" index" );
1244
1244
if (sp->isSubClassOf (" IRBuilderAddrParam" )) {
1245
1245
AddressArgs.insert (Index);
@@ -1251,7 +1251,7 @@ Result::Ptr EmitterBase::getCodeForDag(DagInit *D, const Result::Scope &Scope,
1251
1251
Args, AddressArgs, IntegerArgs);
1252
1252
} else if (Op->isSubClassOf (" IRIntBase" )) {
1253
1253
std::vector<const Type *> ParamTypes;
1254
- for (Record *RParam : Op->getValueAsListOfDefs (" params" ))
1254
+ for (const Record *RParam : Op->getValueAsListOfDefs (" params" ))
1255
1255
ParamTypes.push_back (getType (RParam, Param));
1256
1256
std::string IntName = std::string (Op->getValueAsString (" intname" ));
1257
1257
if (Op->getValueAsBit (" appendKind" ))
@@ -1294,7 +1294,7 @@ Result::Ptr EmitterBase::getCodeForDagArg(DagInit *D, unsigned ArgNum,
1294
1294
return getCodeForDag (DI, Scope, Param);
1295
1295
1296
1296
if (auto *DI = dyn_cast<DefInit>(Arg)) {
1297
- Record *Rec = DI->getDef ();
1297
+ const Record *Rec = DI->getDef ();
1298
1298
if (Rec->isSubClassOf (" Type" )) {
1299
1299
const Type *T = getType (Rec, Param);
1300
1300
return std::make_shared<TypeResult>(T);
@@ -1328,7 +1328,8 @@ Result::Ptr EmitterBase::getCodeForArg(unsigned ArgNum, const Type *ArgType,
1328
1328
return V;
1329
1329
}
1330
1330
1331
- ACLEIntrinsic::ACLEIntrinsic (EmitterBase &ME, Record *R, const Type *Param)
1331
+ ACLEIntrinsic::ACLEIntrinsic (EmitterBase &ME, const Record *R,
1332
+ const Type *Param)
1332
1333
: ReturnType(ME.getType(R->getValueAsDef (" ret" ), Param)) {
1333
1334
// Derive the intrinsic's full name, by taking the name of the
1334
1335
// Tablegen record (or override) and appending the suffix from its
@@ -1346,7 +1347,7 @@ ACLEIntrinsic::ACLEIntrinsic(EmitterBase &ME, Record *R, const Type *Param)
1346
1347
// full name as specified by its 'pnt' member ('polymorphic name type'),
1347
1348
// which indicates how many type suffixes to remove, and any other piece of
1348
1349
// the name that should be removed.
1349
- Record *PolymorphicNameType = R->getValueAsDef (" pnt" );
1350
+ const Record *PolymorphicNameType = R->getValueAsDef (" pnt" );
1350
1351
SmallVector<StringRef, 8 > NameParts;
1351
1352
StringRef (FullName).split (NameParts, ' _' );
1352
1353
for (unsigned i = 0 , e = PolymorphicNameType->getValueAsInt (
@@ -1393,11 +1394,11 @@ ACLEIntrinsic::ACLEIntrinsic(EmitterBase &ME, Record *R, const Type *Param)
1393
1394
// what values it can take, for Sema checking.
1394
1395
bool Immediate = false ;
1395
1396
if (auto TypeDI = dyn_cast<DefInit>(TypeInit)) {
1396
- Record *TypeRec = TypeDI->getDef ();
1397
+ const Record *TypeRec = TypeDI->getDef ();
1397
1398
if (TypeRec->isSubClassOf (" Immediate" )) {
1398
1399
Immediate = true ;
1399
1400
1400
- Record *Bounds = TypeRec->getValueAsDef (" bounds" );
1401
+ const Record *Bounds = TypeRec->getValueAsDef (" bounds" );
1401
1402
ImmediateArg &IA = ImmediateArgs[i];
1402
1403
if (Bounds->isSubClassOf (" IB_ConstRange" )) {
1403
1404
IA.boundsType = ImmediateArg::BoundsType::ExplicitRange;
@@ -1440,7 +1441,7 @@ ACLEIntrinsic::ACLEIntrinsic(EmitterBase &ME, Record *R, const Type *Param)
1440
1441
// Finally, go through the codegen dag and translate it into a Result object
1441
1442
// (with an arbitrary DAG of depended-on Results hanging off it).
1442
1443
DagInit *CodeDag = R->getValueAsDag (" codegen" );
1443
- Record *MainOp = cast<DefInit>(CodeDag->getOperator ())->getDef ();
1444
+ const Record *MainOp = cast<DefInit>(CodeDag->getOperator ())->getDef ();
1444
1445
if (MainOp->isSubClassOf (" CustomCodegen" )) {
1445
1446
// Or, if it's the special case of CustomCodegen, just accumulate
1446
1447
// 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)
1464
1465
}
1465
1466
}
1466
1467
1467
- EmitterBase::EmitterBase (RecordKeeper &Records) {
1468
+ EmitterBase::EmitterBase (const RecordKeeper &Records) {
1468
1469
// Construct the whole EmitterBase.
1469
1470
1470
1471
// First, look up all the instances of PrimitiveType. This gives us the list
1471
1472
// of vector typedefs we have to put in arm_mve.h, and also allows us to
1472
1473
// collect all the useful ScalarType instances into a big list so that we can
1473
1474
// use it for operations such as 'find the unsigned version of this signed
1474
1475
// integer type'.
1475
- for (Record *R : Records.getAllDerivedDefinitions (" PrimitiveType" ))
1476
+ for (const Record *R : Records.getAllDerivedDefinitions (" PrimitiveType" ))
1476
1477
ScalarTypes[std::string (R->getName ())] = std::make_unique<ScalarType>(R);
1477
1478
1478
1479
// Now go through the instances of Intrinsic, and for each one, iterate
1479
1480
// 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" )) {
1482
1483
const Type *Param = getType (RParam, getVoidType ());
1483
1484
auto Intrinsic = std::make_unique<ACLEIntrinsic>(*this , R, Param);
1484
1485
ACLEIntrinsics[Intrinsic->fullName ()] = std::move (Intrinsic);
@@ -1752,7 +1753,7 @@ void EmitterBase::GroupSemaChecks(
1752
1753
1753
1754
class MveEmitter : public EmitterBase {
1754
1755
public:
1755
- MveEmitter (RecordKeeper &Records) : EmitterBase(Records){};
1756
+ MveEmitter (const RecordKeeper &Records) : EmitterBase(Records) {}
1756
1757
void EmitHeader (raw_ostream &OS) override ;
1757
1758
void EmitBuiltinDef (raw_ostream &OS) override ;
1758
1759
void EmitBuiltinSema (raw_ostream &OS) override ;
@@ -2010,14 +2011,14 @@ class CdeEmitter : public EmitterBase {
2010
2011
std::map<StringRef, FunctionMacro> FunctionMacros;
2011
2012
2012
2013
public:
2013
- CdeEmitter (RecordKeeper &Records);
2014
+ CdeEmitter (const RecordKeeper &Records);
2014
2015
void EmitHeader (raw_ostream &OS) override ;
2015
2016
void EmitBuiltinDef (raw_ostream &OS) override ;
2016
2017
void EmitBuiltinSema (raw_ostream &OS) override ;
2017
2018
};
2018
2019
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" ))
2021
2022
FunctionMacros.emplace (R->getName (), FunctionMacro (*R));
2022
2023
}
2023
2024
@@ -2179,45 +2180,45 @@ namespace clang {
2179
2180
2180
2181
// MVE
2181
2182
2182
- void EmitMveHeader (RecordKeeper &Records, raw_ostream &OS) {
2183
+ void EmitMveHeader (const RecordKeeper &Records, raw_ostream &OS) {
2183
2184
MveEmitter (Records).EmitHeader (OS);
2184
2185
}
2185
2186
2186
- void EmitMveBuiltinDef (RecordKeeper &Records, raw_ostream &OS) {
2187
+ void EmitMveBuiltinDef (const RecordKeeper &Records, raw_ostream &OS) {
2187
2188
MveEmitter (Records).EmitBuiltinDef (OS);
2188
2189
}
2189
2190
2190
- void EmitMveBuiltinSema (RecordKeeper &Records, raw_ostream &OS) {
2191
+ void EmitMveBuiltinSema (const RecordKeeper &Records, raw_ostream &OS) {
2191
2192
MveEmitter (Records).EmitBuiltinSema (OS);
2192
2193
}
2193
2194
2194
- void EmitMveBuiltinCG (RecordKeeper &Records, raw_ostream &OS) {
2195
+ void EmitMveBuiltinCG (const RecordKeeper &Records, raw_ostream &OS) {
2195
2196
MveEmitter (Records).EmitBuiltinCG (OS);
2196
2197
}
2197
2198
2198
- void EmitMveBuiltinAliases (RecordKeeper &Records, raw_ostream &OS) {
2199
+ void EmitMveBuiltinAliases (const RecordKeeper &Records, raw_ostream &OS) {
2199
2200
MveEmitter (Records).EmitBuiltinAliases (OS);
2200
2201
}
2201
2202
2202
2203
// CDE
2203
2204
2204
- void EmitCdeHeader (RecordKeeper &Records, raw_ostream &OS) {
2205
+ void EmitCdeHeader (const RecordKeeper &Records, raw_ostream &OS) {
2205
2206
CdeEmitter (Records).EmitHeader (OS);
2206
2207
}
2207
2208
2208
- void EmitCdeBuiltinDef (RecordKeeper &Records, raw_ostream &OS) {
2209
+ void EmitCdeBuiltinDef (const RecordKeeper &Records, raw_ostream &OS) {
2209
2210
CdeEmitter (Records).EmitBuiltinDef (OS);
2210
2211
}
2211
2212
2212
- void EmitCdeBuiltinSema (RecordKeeper &Records, raw_ostream &OS) {
2213
+ void EmitCdeBuiltinSema (const RecordKeeper &Records, raw_ostream &OS) {
2213
2214
CdeEmitter (Records).EmitBuiltinSema (OS);
2214
2215
}
2215
2216
2216
- void EmitCdeBuiltinCG (RecordKeeper &Records, raw_ostream &OS) {
2217
+ void EmitCdeBuiltinCG (const RecordKeeper &Records, raw_ostream &OS) {
2217
2218
CdeEmitter (Records).EmitBuiltinCG (OS);
2218
2219
}
2219
2220
2220
- void EmitCdeBuiltinAliases (RecordKeeper &Records, raw_ostream &OS) {
2221
+ void EmitCdeBuiltinAliases (const RecordKeeper &Records, raw_ostream &OS) {
2221
2222
CdeEmitter (Records).EmitBuiltinAliases (OS);
2222
2223
}
2223
2224
0 commit comments