@@ -321,7 +321,7 @@ class Intrinsic {
321
321
ClassKind CK;
322
322
// / The list of DAGs for the body. May be empty, in which case we should
323
323
// / emit a builtin call.
324
- ListInit *Body;
324
+ const ListInit *Body;
325
325
// / The architectural ifdef guard.
326
326
std::string ArchGuard;
327
327
// / The architectural target() guard.
@@ -372,9 +372,9 @@ class Intrinsic {
372
372
373
373
public:
374
374
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)
378
378
: R(R), Name(Name.str()), OutTS(OutTS), InTS(InTS), CK(CK), Body(Body),
379
379
ArchGuard (ArchGuard.str()), TargetGuard(TargetGuard.str()),
380
380
IsUnavailable(IsUnavailable), BigEndianSafe(BigEndianSafe),
@@ -554,19 +554,20 @@ class Intrinsic {
554
554
DagEmitter (Intrinsic &Intr, StringRef CallPrefix) :
555
555
Intr (Intr), CallPrefix(CallPrefix) {
556
556
}
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,
565
566
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);
570
571
};
571
572
};
572
573
@@ -1410,9 +1411,9 @@ void Intrinsic::emitBody(StringRef CallPrefix) {
1410
1411
1411
1412
// We have a list of "things to output". The last should be returned.
1412
1413
for (auto *I : Body->getValues ()) {
1413
- if (StringInit *SI = dyn_cast<StringInit>(I)) {
1414
+ if (const auto *SI = dyn_cast<StringInit>(I)) {
1414
1415
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)) {
1416
1417
DagEmitter DE (*this , CallPrefix);
1417
1418
Lines.push_back (DE.emitDag (DI).second + " ;" );
1418
1419
}
@@ -1438,9 +1439,9 @@ void Intrinsic::emitReturn() {
1438
1439
emitNewLine ();
1439
1440
}
1440
1441
1441
- std::pair<Type, std::string> Intrinsic::DagEmitter::emitDag (DagInit *DI) {
1442
+ std::pair<Type, std::string> Intrinsic::DagEmitter::emitDag (const DagInit *DI) {
1442
1443
// 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 ());
1444
1445
std::string Op = DefI->getAsString ();
1445
1446
1446
1447
if (Op == " cast" || Op == " bitcast" )
@@ -1467,7 +1468,8 @@ std::pair<Type, std::string> Intrinsic::DagEmitter::emitDag(DagInit *DI) {
1467
1468
return std::make_pair (Type::getVoid (), " " );
1468
1469
}
1469
1470
1470
- std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagOp (DagInit *DI) {
1471
+ std::pair<Type, std::string>
1472
+ Intrinsic::DagEmitter::emitDagOp (const DagInit *DI) {
1471
1473
std::string Op = cast<StringInit>(DI->getArg (0 ))->getAsUnquotedString ();
1472
1474
if (DI->getNumArgs () == 2 ) {
1473
1475
// Unary op.
@@ -1486,7 +1488,7 @@ std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagOp(DagInit *DI) {
1486
1488
}
1487
1489
1488
1490
std::pair<Type, std::string>
1489
- Intrinsic::DagEmitter::emitDagCall (DagInit *DI, bool MatchMangledName) {
1491
+ Intrinsic::DagEmitter::emitDagCall (const DagInit *DI, bool MatchMangledName) {
1490
1492
std::vector<Type> Types;
1491
1493
std::vector<std::string> Values;
1492
1494
for (unsigned I = 0 ; I < DI->getNumArgs () - 1 ; ++I) {
@@ -1498,7 +1500,7 @@ Intrinsic::DagEmitter::emitDagCall(DagInit *DI, bool MatchMangledName) {
1498
1500
1499
1501
// Look up the called intrinsic.
1500
1502
std::string N;
1501
- if (StringInit *SI = dyn_cast<StringInit>(DI->getArg (0 )))
1503
+ if (const auto *SI = dyn_cast<StringInit>(DI->getArg (0 )))
1502
1504
N = SI->getAsUnquotedString ();
1503
1505
else
1504
1506
N = emitDagArg (DI->getArg (0 ), " " ).second ;
@@ -1529,8 +1531,8 @@ Intrinsic::DagEmitter::emitDagCall(DagInit *DI, bool MatchMangledName) {
1529
1531
return std::make_pair (Callee.getReturnType (), S);
1530
1532
}
1531
1533
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) {
1534
1536
// (cast MOD* VAL) -> cast VAL to type given by MOD.
1535
1537
std::pair<Type, std::string> R =
1536
1538
emitDagArg (DI->getArg (DI->getNumArgs () - 1 ),
@@ -1552,7 +1554,7 @@ std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagCast(DagInit *DI,
1552
1554
castToType =
1553
1555
Intr.Variables [std::string (DI->getArgNameStr (ArgIdx))].getType ();
1554
1556
} else {
1555
- StringInit *SI = dyn_cast<StringInit>(DI->getArg (ArgIdx));
1557
+ const auto *SI = dyn_cast<StringInit>(DI->getArg (ArgIdx));
1556
1558
assert_with_loc (SI, " Expected string type or $Name for cast type" );
1557
1559
1558
1560
if (SI->getAsUnquotedString () == " R" ) {
@@ -1599,7 +1601,8 @@ std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagCast(DagInit *DI,
1599
1601
return std::make_pair (castToType, S);
1600
1602
}
1601
1603
1602
- std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagShuffle (DagInit *DI){
1604
+ std::pair<Type, std::string>
1605
+ Intrinsic::DagEmitter::emitDagShuffle (const DagInit *DI) {
1603
1606
// See the documentation in arm_neon.td for a description of these operators.
1604
1607
class LowHalf : public SetTheory ::Operator {
1605
1608
public:
@@ -1710,7 +1713,8 @@ std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagShuffle(DagInit *DI){
1710
1713
return std::make_pair (T, S);
1711
1714
}
1712
1715
1713
- std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagDup (DagInit *DI) {
1716
+ std::pair<Type, std::string>
1717
+ Intrinsic::DagEmitter::emitDagDup (const DagInit *DI) {
1714
1718
assert_with_loc (DI->getNumArgs () == 1 , " dup() expects one argument" );
1715
1719
std::pair<Type, std::string> A =
1716
1720
emitDagArg (DI->getArg (0 ), std::string (DI->getArgNameStr (0 )));
@@ -1729,15 +1733,16 @@ std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagDup(DagInit *DI) {
1729
1733
return std::make_pair (T, S);
1730
1734
}
1731
1735
1732
- std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagDupTyped (DagInit *DI) {
1736
+ std::pair<Type, std::string>
1737
+ Intrinsic::DagEmitter::emitDagDupTyped (const DagInit *DI) {
1733
1738
assert_with_loc (DI->getNumArgs () == 2 , " dup_typed() expects two arguments" );
1734
1739
std::pair<Type, std::string> B =
1735
1740
emitDagArg (DI->getArg (1 ), std::string (DI->getArgNameStr (1 )));
1736
1741
assert_with_loc (B.first .isScalar (),
1737
1742
" dup_typed() requires a scalar as the second argument" );
1738
1743
Type T;
1739
1744
// 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 ))) {
1741
1746
T = Type::fromTypedefName (SI->getAsUnquotedString ());
1742
1747
assert_with_loc (!T.isVoid (), " Unknown typedef" );
1743
1748
} else
@@ -1755,7 +1760,8 @@ std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagDupTyped(DagInit *DI)
1755
1760
return std::make_pair (T, S);
1756
1761
}
1757
1762
1758
- std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagSplat (DagInit *DI) {
1763
+ std::pair<Type, std::string>
1764
+ Intrinsic::DagEmitter::emitDagSplat (const DagInit *DI) {
1759
1765
assert_with_loc (DI->getNumArgs () == 2 , " splat() expects two arguments" );
1760
1766
std::pair<Type, std::string> A =
1761
1767
emitDagArg (DI->getArg (0 ), std::string (DI->getArgNameStr (0 )));
@@ -1774,7 +1780,8 @@ std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagSplat(DagInit *DI) {
1774
1780
return std::make_pair (Intr.getBaseType (), S);
1775
1781
}
1776
1782
1777
- std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagSaveTemp (DagInit *DI) {
1783
+ std::pair<Type, std::string>
1784
+ Intrinsic::DagEmitter::emitDagSaveTemp (const DagInit *DI) {
1778
1785
assert_with_loc (DI->getNumArgs () == 2 , " save_temp() expects two arguments" );
1779
1786
std::pair<Type, std::string> A =
1780
1787
emitDagArg (DI->getArg (1 ), std::string (DI->getArgNameStr (1 )));
@@ -1797,7 +1804,7 @@ std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagSaveTemp(DagInit *DI)
1797
1804
}
1798
1805
1799
1806
std::pair<Type, std::string>
1800
- Intrinsic::DagEmitter::emitDagNameReplace (DagInit *DI) {
1807
+ Intrinsic::DagEmitter::emitDagNameReplace (const DagInit *DI) {
1801
1808
std::string S = Intr.Name ;
1802
1809
1803
1810
assert_with_loc (DI->getNumArgs () == 2 , " name_replace requires 2 arguments!" );
@@ -1812,14 +1819,15 @@ Intrinsic::DagEmitter::emitDagNameReplace(DagInit *DI) {
1812
1819
return std::make_pair (Type::getVoid (), S);
1813
1820
}
1814
1821
1815
- std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagLiteral (DagInit *DI){
1822
+ std::pair<Type, std::string>
1823
+ Intrinsic::DagEmitter::emitDagLiteral (const DagInit *DI) {
1816
1824
std::string Ty = cast<StringInit>(DI->getArg (0 ))->getAsUnquotedString ();
1817
1825
std::string Value = cast<StringInit>(DI->getArg (1 ))->getAsUnquotedString ();
1818
1826
return std::make_pair (Type::fromTypedefName (Ty), Value);
1819
1827
}
1820
1828
1821
1829
std::pair<Type, std::string>
1822
- Intrinsic::DagEmitter::emitDagArg (Init *Arg, std::string ArgName) {
1830
+ Intrinsic::DagEmitter::emitDagArg (const Init *Arg, std::string ArgName) {
1823
1831
if (!ArgName.empty ()) {
1824
1832
assert_with_loc (!Arg->isComplete (),
1825
1833
" Arguments must either be DAGs or names, not both!" );
@@ -1830,7 +1838,7 @@ Intrinsic::DagEmitter::emitDagArg(Init *Arg, std::string ArgName) {
1830
1838
}
1831
1839
1832
1840
assert (Arg && " Neither ArgName nor Arg?!" );
1833
- DagInit *DI = dyn_cast<DagInit>(Arg);
1841
+ const auto *DI = dyn_cast<DagInit>(Arg);
1834
1842
assert_with_loc (DI, " Arguments must either be DAGs or names!" );
1835
1843
1836
1844
return emitDag (DI);
@@ -1994,7 +2002,7 @@ void NeonEmitter::createIntrinsic(const Record *R,
1994
2002
// decent location information even when highly nested.
1995
2003
CurrentRecord = R;
1996
2004
1997
- ListInit *Body = OperationRec->getValueAsListInit (" Ops" );
2005
+ const ListInit *Body = OperationRec->getValueAsListInit (" Ops" );
1998
2006
1999
2007
std::vector<TypeSpec> TypeSpecs = TypeSpec::fromTypeSpecs (Types);
2000
2008
0 commit comments