@@ -59,7 +59,7 @@ namespace {
59
59
// While globals are generally bad, this one allows us to perform assertions
60
60
// liberally and somehow still trace them back to the def they indirectly
61
61
// came from.
62
- static Record *CurrentRecord = nullptr ;
62
+ static const Record *CurrentRecord = nullptr ;
63
63
static void assert_with_loc (bool Assertion, const std::string &Str) {
64
64
if (!Assertion) {
65
65
if (CurrentRecord)
@@ -308,7 +308,7 @@ class Variable {
308
308
// / a particular typespec and prototype.
309
309
class Intrinsic {
310
310
// / The Record this intrinsic was created from.
311
- Record *R;
311
+ const Record *R;
312
312
// / The unmangled name.
313
313
std::string Name;
314
314
// / The input and output typespecs. InTS == OutTS except when
@@ -371,7 +371,7 @@ class Intrinsic {
371
371
}
372
372
373
373
public:
374
- Intrinsic (Record *R, StringRef Name, StringRef Proto, TypeSpec OutTS,
374
+ Intrinsic (const Record *R, StringRef Name, StringRef Proto, TypeSpec OutTS,
375
375
TypeSpec InTS, ClassKind CK, ListInit *Body, NeonEmitter &Emitter,
376
376
StringRef ArchGuard, StringRef TargetGuard, bool IsUnavailable,
377
377
bool BigEndianSafe)
@@ -442,7 +442,7 @@ class Intrinsic {
442
442
}
443
443
444
444
// / Get the Record that this intrinsic is based off.
445
- Record *getRecord () const { return R; }
445
+ const Record *getRecord () const { return R; }
446
446
// / Get the set of Intrinsics that this intrinsic calls.
447
447
// / this is the set of immediate dependencies, NOT the
448
448
// / transitive closure.
@@ -576,12 +576,12 @@ class Intrinsic {
576
576
// ===----------------------------------------------------------------------===//
577
577
578
578
class NeonEmitter {
579
- RecordKeeper &Records;
580
- DenseMap<Record *, ClassKind> ClassMap;
579
+ const RecordKeeper &Records;
580
+ DenseMap<const Record *, ClassKind> ClassMap;
581
581
std::map<std::string, std::deque<Intrinsic>> IntrinsicMap;
582
582
unsigned UniqueNumber;
583
583
584
- void createIntrinsic (Record *R, SmallVectorImpl<Intrinsic *> &Out);
584
+ void createIntrinsic (const Record *R, SmallVectorImpl<Intrinsic *> &Out);
585
585
void genBuiltinsDef (raw_ostream &OS, SmallVectorImpl<Intrinsic *> &Defs);
586
586
void genStreamingSVECompatibleList (raw_ostream &OS,
587
587
SmallVectorImpl<Intrinsic *> &Defs);
@@ -601,15 +601,15 @@ class NeonEmitter {
601
601
// / Called by Intrinsic - returns a globally-unique number.
602
602
unsigned getUniqueNumber () { return UniqueNumber++; }
603
603
604
- NeonEmitter (RecordKeeper &R) : Records(R), UniqueNumber(0 ) {
605
- Record *SI = R.getClass (" SInst" );
606
- Record *II = R.getClass (" IInst" );
607
- Record *WI = R.getClass (" WInst" );
608
- Record *SOpI = R.getClass (" SOpInst" );
609
- Record *IOpI = R.getClass (" IOpInst" );
610
- Record *WOpI = R.getClass (" WOpInst" );
611
- Record *LOpI = R.getClass (" LOpInst" );
612
- Record *NoTestOpI = R.getClass (" NoTestOpInst" );
604
+ NeonEmitter (const RecordKeeper &R) : Records(R), UniqueNumber(0 ) {
605
+ const Record *SI = R.getClass (" SInst" );
606
+ const Record *II = R.getClass (" IInst" );
607
+ const Record *WI = R.getClass (" WInst" );
608
+ const Record *SOpI = R.getClass (" SOpInst" );
609
+ const Record *IOpI = R.getClass (" IOpInst" );
610
+ const Record *WOpI = R.getClass (" WOpInst" );
611
+ const Record *LOpI = R.getClass (" LOpInst" );
612
+ const Record *NoTestOpI = R.getClass (" NoTestOpInst" );
613
613
614
614
ClassMap[SI] = ClassS;
615
615
ClassMap[II] = ClassI;
@@ -1979,12 +1979,12 @@ Intrinsic &NeonEmitter::getIntrinsic(StringRef Name, ArrayRef<Type> Types,
1979
1979
return *GoodVec.front ();
1980
1980
}
1981
1981
1982
- void NeonEmitter::createIntrinsic (Record *R,
1982
+ void NeonEmitter::createIntrinsic (const Record *R,
1983
1983
SmallVectorImpl<Intrinsic *> &Out) {
1984
1984
std::string Name = std::string (R->getValueAsString (" Name" ));
1985
1985
std::string Proto = std::string (R->getValueAsString (" Prototype" ));
1986
1986
std::string Types = std::string (R->getValueAsString (" Types" ));
1987
- Record *OperationRec = R->getValueAsDef (" Operation" );
1987
+ const Record *OperationRec = R->getValueAsDef (" Operation" );
1988
1988
bool BigEndianSafe = R->getValueAsBit (" BigEndianSafe" );
1989
1989
std::string ArchGuard = std::string (R->getValueAsString (" ArchGuard" ));
1990
1990
std::string TargetGuard = std::string (R->getValueAsString (" TargetGuard" ));
@@ -2240,10 +2240,8 @@ void NeonEmitter::genIntrinsicRangeCheckCode(
2240
2240
// / 2. the SemaChecking code for the type overload checking.
2241
2241
// / 3. the SemaChecking code for validation of intrinsic immediate arguments.
2242
2242
void NeonEmitter::runHeader (raw_ostream &OS) {
2243
- std::vector<Record *> RV = Records.getAllDerivedDefinitions (" Inst" );
2244
-
2245
2243
SmallVector<Intrinsic *, 128 > Defs;
2246
- for (auto *R : RV )
2244
+ for (const Record *R : Records. getAllDerivedDefinitions ( " Inst " ) )
2247
2245
createIntrinsic (R, Defs);
2248
2246
2249
2247
// Generate shared BuiltinsXXX.def
@@ -2402,8 +2400,7 @@ void NeonEmitter::run(raw_ostream &OS) {
2402
2400
" __nodebug__))\n\n " ;
2403
2401
2404
2402
SmallVector<Intrinsic *, 128 > Defs;
2405
- std::vector<Record *> RV = Records.getAllDerivedDefinitions (" Inst" );
2406
- for (auto *R : RV)
2403
+ for (const Record *R : Records.getAllDerivedDefinitions (" Inst" ))
2407
2404
createIntrinsic (R, Defs);
2408
2405
2409
2406
for (auto *I : Defs)
@@ -2510,8 +2507,7 @@ void NeonEmitter::runFP16(raw_ostream &OS) {
2510
2507
" __nodebug__))\n\n " ;
2511
2508
2512
2509
SmallVector<Intrinsic *, 128 > Defs;
2513
- std::vector<Record *> RV = Records.getAllDerivedDefinitions (" Inst" );
2514
- for (auto *R : RV)
2510
+ for (const Record *R : Records.getAllDerivedDefinitions (" Inst" ))
2515
2511
createIntrinsic (R, Defs);
2516
2512
2517
2513
for (auto *I : Defs)
@@ -2619,8 +2615,7 @@ void NeonEmitter::runBF16(raw_ostream &OS) {
2619
2615
" __nodebug__))\n\n " ;
2620
2616
2621
2617
SmallVector<Intrinsic *, 128 > Defs;
2622
- std::vector<Record *> RV = Records.getAllDerivedDefinitions (" Inst" );
2623
- for (auto *R : RV)
2618
+ for (const Record *R : Records.getAllDerivedDefinitions (" Inst" ))
2624
2619
createIntrinsic (R, Defs);
2625
2620
2626
2621
for (auto *I : Defs)
@@ -2674,26 +2669,26 @@ void NeonEmitter::runBF16(raw_ostream &OS) {
2674
2669
OS << " #endif\n " ;
2675
2670
}
2676
2671
2677
- void clang::EmitNeon (RecordKeeper &Records, raw_ostream &OS) {
2672
+ void clang::EmitNeon (const RecordKeeper &Records, raw_ostream &OS) {
2678
2673
NeonEmitter (Records).run (OS);
2679
2674
}
2680
2675
2681
- void clang::EmitFP16 (RecordKeeper &Records, raw_ostream &OS) {
2676
+ void clang::EmitFP16 (const RecordKeeper &Records, raw_ostream &OS) {
2682
2677
NeonEmitter (Records).runFP16 (OS);
2683
2678
}
2684
2679
2685
- void clang::EmitBF16 (RecordKeeper &Records, raw_ostream &OS) {
2680
+ void clang::EmitBF16 (const RecordKeeper &Records, raw_ostream &OS) {
2686
2681
NeonEmitter (Records).runBF16 (OS);
2687
2682
}
2688
2683
2689
- void clang::EmitNeonSema (RecordKeeper &Records, raw_ostream &OS) {
2684
+ void clang::EmitNeonSema (const RecordKeeper &Records, raw_ostream &OS) {
2690
2685
NeonEmitter (Records).runHeader (OS);
2691
2686
}
2692
2687
2693
- void clang::EmitVectorTypes (RecordKeeper &Records, raw_ostream &OS) {
2688
+ void clang::EmitVectorTypes (const RecordKeeper &Records, raw_ostream &OS) {
2694
2689
NeonEmitter (Records).runVectorTypes (OS);
2695
2690
}
2696
2691
2697
- void clang::EmitNeonTest (RecordKeeper &Records, raw_ostream &OS) {
2692
+ void clang::EmitNeonTest (const RecordKeeper &Records, raw_ostream &OS) {
2698
2693
llvm_unreachable (" Neon test generation no longer implemented!" );
2699
2694
}
0 commit comments