@@ -321,7 +321,7 @@ class Intrinsic {
321321 ClassKind CK;
322322 // / The list of DAGs for the body. May be empty, in which case we should
323323 // / emit a builtin call.
324- ListInit *Body;
324+ const ListInit *Body;
325325 // / The architectural ifdef guard.
326326 std::string ArchGuard;
327327 // / The architectural target() guard.
@@ -372,9 +372,9 @@ class Intrinsic {
372372
373373public:
374374 Intrinsic (const Record *R, StringRef Name, StringRef Proto, TypeSpec OutTS,
375- TypeSpec InTS, ClassKind CK, ListInit *Body, NeonEmitter &Emitter ,
376- StringRef ArchGuard , StringRef TargetGuard, bool IsUnavailable ,
377- bool BigEndianSafe)
375+ TypeSpec InTS, ClassKind CK, const ListInit *Body,
376+ NeonEmitter &Emitter , StringRef ArchGuard, StringRef TargetGuard ,
377+ bool IsUnavailable, bool BigEndianSafe)
378378 : R(R), Name(Name.str()), OutTS(OutTS), InTS(InTS), CK(CK), Body(Body),
379379 ArchGuard (ArchGuard.str()), TargetGuard(TargetGuard.str()),
380380 IsUnavailable(IsUnavailable), BigEndianSafe(BigEndianSafe),
@@ -554,19 +554,20 @@ class Intrinsic {
554554 DagEmitter (Intrinsic &Intr, StringRef CallPrefix) :
555555 Intr (Intr), CallPrefix(CallPrefix) {
556556 }
557- std::pair<Type, std::string> emitDagArg (Init *Arg, std::string ArgName);
558- std::pair<Type, std::string> emitDagSaveTemp (DagInit *DI);
559- std::pair<Type, std::string> emitDagSplat (DagInit *DI);
560- std::pair<Type, std::string> emitDagDup (DagInit *DI);
561- std::pair<Type, std::string> emitDagDupTyped (DagInit *DI);
562- std::pair<Type, std::string> emitDagShuffle (DagInit *DI);
563- std::pair<Type, std::string> emitDagCast (DagInit *DI, bool IsBitCast);
564- std::pair<Type, std::string> emitDagCall (DagInit *DI,
557+ std::pair<Type, std::string> emitDagArg (const Init *Arg,
558+ std::string ArgName);
559+ std::pair<Type, std::string> emitDagSaveTemp (const DagInit *DI);
560+ std::pair<Type, std::string> emitDagSplat (const DagInit *DI);
561+ std::pair<Type, std::string> emitDagDup (const DagInit *DI);
562+ std::pair<Type, std::string> emitDagDupTyped (const DagInit *DI);
563+ std::pair<Type, std::string> emitDagShuffle (const DagInit *DI);
564+ std::pair<Type, std::string> emitDagCast (const DagInit *DI, bool IsBitCast);
565+ std::pair<Type, std::string> emitDagCall (const DagInit *DI,
565566 bool MatchMangledName);
566- std::pair<Type, std::string> emitDagNameReplace (DagInit *DI);
567- std::pair<Type, std::string> emitDagLiteral (DagInit *DI);
568- std::pair<Type, std::string> emitDagOp (DagInit *DI);
569- std::pair<Type, std::string> emitDag (DagInit *DI);
567+ std::pair<Type, std::string> emitDagNameReplace (const DagInit *DI);
568+ std::pair<Type, std::string> emitDagLiteral (const DagInit *DI);
569+ std::pair<Type, std::string> emitDagOp (const DagInit *DI);
570+ std::pair<Type, std::string> emitDag (const DagInit *DI);
570571 };
571572};
572573
@@ -1410,9 +1411,9 @@ void Intrinsic::emitBody(StringRef CallPrefix) {
14101411
14111412 // We have a list of "things to output". The last should be returned.
14121413 for (auto *I : Body->getValues ()) {
1413- if (StringInit *SI = dyn_cast<StringInit>(I)) {
1414+ if (const auto *SI = dyn_cast<StringInit>(I)) {
14141415 Lines.push_back (replaceParamsIn (SI->getAsString ()));
1415- } else if (DagInit *DI = dyn_cast<DagInit>(I)) {
1416+ } else if (const auto *DI = dyn_cast<DagInit>(I)) {
14161417 DagEmitter DE (*this , CallPrefix);
14171418 Lines.push_back (DE.emitDag (DI).second + " ;" );
14181419 }
@@ -1438,9 +1439,9 @@ void Intrinsic::emitReturn() {
14381439 emitNewLine ();
14391440}
14401441
1441- std::pair<Type, std::string> Intrinsic::DagEmitter::emitDag (DagInit *DI) {
1442+ std::pair<Type, std::string> Intrinsic::DagEmitter::emitDag (const DagInit *DI) {
14421443 // At this point we should only be seeing a def.
1443- DefInit *DefI = cast<DefInit>(DI->getOperator ());
1444+ const DefInit *DefI = cast<DefInit>(DI->getOperator ());
14441445 std::string Op = DefI->getAsString ();
14451446
14461447 if (Op == " cast" || Op == " bitcast" )
@@ -1467,7 +1468,8 @@ std::pair<Type, std::string> Intrinsic::DagEmitter::emitDag(DagInit *DI) {
14671468 return std::make_pair (Type::getVoid (), " " );
14681469}
14691470
1470- std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagOp (DagInit *DI) {
1471+ std::pair<Type, std::string>
1472+ Intrinsic::DagEmitter::emitDagOp (const DagInit *DI) {
14711473 std::string Op = cast<StringInit>(DI->getArg (0 ))->getAsUnquotedString ();
14721474 if (DI->getNumArgs () == 2 ) {
14731475 // Unary op.
@@ -1486,7 +1488,7 @@ std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagOp(DagInit *DI) {
14861488}
14871489
14881490std::pair<Type, std::string>
1489- Intrinsic::DagEmitter::emitDagCall (DagInit *DI, bool MatchMangledName) {
1491+ Intrinsic::DagEmitter::emitDagCall (const DagInit *DI, bool MatchMangledName) {
14901492 std::vector<Type> Types;
14911493 std::vector<std::string> Values;
14921494 for (unsigned I = 0 ; I < DI->getNumArgs () - 1 ; ++I) {
@@ -1498,7 +1500,7 @@ Intrinsic::DagEmitter::emitDagCall(DagInit *DI, bool MatchMangledName) {
14981500
14991501 // Look up the called intrinsic.
15001502 std::string N;
1501- if (StringInit *SI = dyn_cast<StringInit>(DI->getArg (0 )))
1503+ if (const auto *SI = dyn_cast<StringInit>(DI->getArg (0 )))
15021504 N = SI->getAsUnquotedString ();
15031505 else
15041506 N = emitDagArg (DI->getArg (0 ), " " ).second ;
@@ -1529,8 +1531,8 @@ Intrinsic::DagEmitter::emitDagCall(DagInit *DI, bool MatchMangledName) {
15291531 return std::make_pair (Callee.getReturnType (), S);
15301532}
15311533
1532- std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagCast (DagInit *DI,
1533- bool IsBitCast){
1534+ std::pair<Type, std::string>
1535+ Intrinsic::DagEmitter::emitDagCast ( const DagInit *DI, bool IsBitCast) {
15341536 // (cast MOD* VAL) -> cast VAL to type given by MOD.
15351537 std::pair<Type, std::string> R =
15361538 emitDagArg (DI->getArg (DI->getNumArgs () - 1 ),
@@ -1552,7 +1554,7 @@ std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagCast(DagInit *DI,
15521554 castToType =
15531555 Intr.Variables [std::string (DI->getArgNameStr (ArgIdx))].getType ();
15541556 } else {
1555- StringInit *SI = dyn_cast<StringInit>(DI->getArg (ArgIdx));
1557+ const auto *SI = dyn_cast<StringInit>(DI->getArg (ArgIdx));
15561558 assert_with_loc (SI, " Expected string type or $Name for cast type" );
15571559
15581560 if (SI->getAsUnquotedString () == " R" ) {
@@ -1599,7 +1601,8 @@ std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagCast(DagInit *DI,
15991601 return std::make_pair (castToType, S);
16001602}
16011603
1602- std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagShuffle (DagInit *DI){
1604+ std::pair<Type, std::string>
1605+ Intrinsic::DagEmitter::emitDagShuffle (const DagInit *DI) {
16031606 // See the documentation in arm_neon.td for a description of these operators.
16041607 class LowHalf : public SetTheory ::Operator {
16051608 public:
@@ -1710,7 +1713,8 @@ std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagShuffle(DagInit *DI){
17101713 return std::make_pair (T, S);
17111714}
17121715
1713- std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagDup (DagInit *DI) {
1716+ std::pair<Type, std::string>
1717+ Intrinsic::DagEmitter::emitDagDup (const DagInit *DI) {
17141718 assert_with_loc (DI->getNumArgs () == 1 , " dup() expects one argument" );
17151719 std::pair<Type, std::string> A =
17161720 emitDagArg (DI->getArg (0 ), std::string (DI->getArgNameStr (0 )));
@@ -1729,15 +1733,16 @@ std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagDup(DagInit *DI) {
17291733 return std::make_pair (T, S);
17301734}
17311735
1732- std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagDupTyped (DagInit *DI) {
1736+ std::pair<Type, std::string>
1737+ Intrinsic::DagEmitter::emitDagDupTyped (const DagInit *DI) {
17331738 assert_with_loc (DI->getNumArgs () == 2 , " dup_typed() expects two arguments" );
17341739 std::pair<Type, std::string> B =
17351740 emitDagArg (DI->getArg (1 ), std::string (DI->getArgNameStr (1 )));
17361741 assert_with_loc (B.first .isScalar (),
17371742 " dup_typed() requires a scalar as the second argument" );
17381743 Type T;
17391744 // If the type argument is a constant string, construct the type directly.
1740- if (StringInit *SI = dyn_cast<StringInit>(DI->getArg (0 ))) {
1745+ if (const auto *SI = dyn_cast<StringInit>(DI->getArg (0 ))) {
17411746 T = Type::fromTypedefName (SI->getAsUnquotedString ());
17421747 assert_with_loc (!T.isVoid (), " Unknown typedef" );
17431748 } else
@@ -1755,7 +1760,8 @@ std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagDupTyped(DagInit *DI)
17551760 return std::make_pair (T, S);
17561761}
17571762
1758- std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagSplat (DagInit *DI) {
1763+ std::pair<Type, std::string>
1764+ Intrinsic::DagEmitter::emitDagSplat (const DagInit *DI) {
17591765 assert_with_loc (DI->getNumArgs () == 2 , " splat() expects two arguments" );
17601766 std::pair<Type, std::string> A =
17611767 emitDagArg (DI->getArg (0 ), std::string (DI->getArgNameStr (0 )));
@@ -1774,7 +1780,8 @@ std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagSplat(DagInit *DI) {
17741780 return std::make_pair (Intr.getBaseType (), S);
17751781}
17761782
1777- std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagSaveTemp (DagInit *DI) {
1783+ std::pair<Type, std::string>
1784+ Intrinsic::DagEmitter::emitDagSaveTemp (const DagInit *DI) {
17781785 assert_with_loc (DI->getNumArgs () == 2 , " save_temp() expects two arguments" );
17791786 std::pair<Type, std::string> A =
17801787 emitDagArg (DI->getArg (1 ), std::string (DI->getArgNameStr (1 )));
@@ -1797,7 +1804,7 @@ std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagSaveTemp(DagInit *DI)
17971804}
17981805
17991806std::pair<Type, std::string>
1800- Intrinsic::DagEmitter::emitDagNameReplace (DagInit *DI) {
1807+ Intrinsic::DagEmitter::emitDagNameReplace (const DagInit *DI) {
18011808 std::string S = Intr.Name ;
18021809
18031810 assert_with_loc (DI->getNumArgs () == 2 , " name_replace requires 2 arguments!" );
@@ -1812,14 +1819,15 @@ Intrinsic::DagEmitter::emitDagNameReplace(DagInit *DI) {
18121819 return std::make_pair (Type::getVoid (), S);
18131820}
18141821
1815- std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagLiteral (DagInit *DI){
1822+ std::pair<Type, std::string>
1823+ Intrinsic::DagEmitter::emitDagLiteral (const DagInit *DI) {
18161824 std::string Ty = cast<StringInit>(DI->getArg (0 ))->getAsUnquotedString ();
18171825 std::string Value = cast<StringInit>(DI->getArg (1 ))->getAsUnquotedString ();
18181826 return std::make_pair (Type::fromTypedefName (Ty), Value);
18191827}
18201828
18211829std::pair<Type, std::string>
1822- Intrinsic::DagEmitter::emitDagArg (Init *Arg, std::string ArgName) {
1830+ Intrinsic::DagEmitter::emitDagArg (const Init *Arg, std::string ArgName) {
18231831 if (!ArgName.empty ()) {
18241832 assert_with_loc (!Arg->isComplete (),
18251833 " Arguments must either be DAGs or names, not both!" );
@@ -1830,7 +1838,7 @@ Intrinsic::DagEmitter::emitDagArg(Init *Arg, std::string ArgName) {
18301838 }
18311839
18321840 assert (Arg && " Neither ArgName nor Arg?!" );
1833- DagInit *DI = dyn_cast<DagInit>(Arg);
1841+ const auto *DI = dyn_cast<DagInit>(Arg);
18341842 assert_with_loc (DI, " Arguments must either be DAGs or names!" );
18351843
18361844 return emitDag (DI);
@@ -1994,7 +2002,7 @@ void NeonEmitter::createIntrinsic(const Record *R,
19942002 // decent location information even when highly nested.
19952003 CurrentRecord = R;
19962004
1997- ListInit *Body = OperationRec->getValueAsListInit (" Ops" );
2005+ const ListInit *Body = OperationRec->getValueAsListInit (" Ops" );
19982006
19992007 std::vector<TypeSpec> TypeSpecs = TypeSpec::fromTypeSpecs (Types);
20002008
0 commit comments