@@ -1255,28 +1255,28 @@ bool TreePredicateFn::isAtomicOrderingWeakerThanRelease() const {
1255
1255
false );
1256
1256
}
1257
1257
Record *TreePredicateFn::getMemoryVT () const {
1258
- Record *R = getOrigPatFragRecord ()->getRecord ();
1258
+ const Record *R = getOrigPatFragRecord ()->getRecord ();
1259
1259
if (R->isValueUnset (" MemoryVT" ))
1260
1260
return nullptr ;
1261
1261
return R->getValueAsDef (" MemoryVT" );
1262
1262
}
1263
1263
1264
1264
ListInit *TreePredicateFn::getAddressSpaces () const {
1265
- Record *R = getOrigPatFragRecord ()->getRecord ();
1265
+ const Record *R = getOrigPatFragRecord ()->getRecord ();
1266
1266
if (R->isValueUnset (" AddressSpaces" ))
1267
1267
return nullptr ;
1268
1268
return R->getValueAsListInit (" AddressSpaces" );
1269
1269
}
1270
1270
1271
1271
int64_t TreePredicateFn::getMinAlignment () const {
1272
- Record *R = getOrigPatFragRecord ()->getRecord ();
1272
+ const Record *R = getOrigPatFragRecord ()->getRecord ();
1273
1273
if (R->isValueUnset (" MinAlignment" ))
1274
1274
return 0 ;
1275
1275
return R->getValueAsInt (" MinAlignment" );
1276
1276
}
1277
1277
1278
1278
Record *TreePredicateFn::getScalarMemoryVT () const {
1279
- Record *R = getOrigPatFragRecord ()->getRecord ();
1279
+ const Record *R = getOrigPatFragRecord ()->getRecord ();
1280
1280
if (R->isValueUnset (" ScalarMemoryVT" ))
1281
1281
return nullptr ;
1282
1282
return R->getValueAsDef (" ScalarMemoryVT" );
@@ -1390,7 +1390,7 @@ std::string TreePredicateFn::getCodeToRunOnSDNode() const {
1390
1390
if (Tree->isLeaf ())
1391
1391
TreeClassName = " SDNode" ;
1392
1392
else {
1393
- Record *Op = Tree->getOperator ();
1393
+ const Record *Op = Tree->getOperator ();
1394
1394
const SDNodeInfo &Info = PatFragRec->getDAGPatterns ().getSDNodeInfo (Op);
1395
1395
TreeClassName = Info.getSDClassName ();
1396
1396
}
@@ -1848,7 +1848,8 @@ MVT::SimpleValueType SDNodeInfo::getKnownType(unsigned ResNo) const {
1848
1848
// TreePatternNode implementation
1849
1849
//
1850
1850
1851
- static unsigned GetNumNodeResults (Record *Operator, CodeGenDAGPatterns &CDP) {
1851
+ static unsigned GetNumNodeResults (const Record *Operator,
1852
+ CodeGenDAGPatterns &CDP) {
1852
1853
if (Operator->getName () == " set" || Operator->getName () == " implicit" )
1853
1854
return 0 ; // All return nothing.
1854
1855
@@ -2077,7 +2078,7 @@ void TreePatternNode::InlinePatternFragments(
2077
2078
return ;
2078
2079
}
2079
2080
2080
- Record *Op = getOperator ();
2081
+ const Record *Op = getOperator ();
2081
2082
2082
2083
if (!Op->isSubClassOf (" PatFrags" )) {
2083
2084
if (getNumChildren () == 0 ) {
@@ -2340,7 +2341,7 @@ TreePatternNode::getIntrinsicInfo(const CodeGenDAGPatterns &CDP) const {
2340
2341
// / return the ComplexPattern information, otherwise return null.
2341
2342
const ComplexPattern *
2342
2343
TreePatternNode::getComplexPatternInfo (const CodeGenDAGPatterns &CGP) const {
2343
- Record *Rec;
2344
+ const Record *Rec;
2344
2345
if (isLeaf ()) {
2345
2346
DefInit *DI = dyn_cast<DefInit>(getLeafValue ());
2346
2347
if (!DI)
@@ -2793,23 +2794,23 @@ bool TreePatternNode::canPatternMatch(std::string &Reason,
2793
2794
// TreePattern implementation
2794
2795
//
2795
2796
2796
- TreePattern::TreePattern (Record *TheRec, ListInit *RawPat, bool isInput,
2797
+ TreePattern::TreePattern (const Record *TheRec, ListInit *RawPat, bool isInput,
2797
2798
CodeGenDAGPatterns &cdp)
2798
2799
: TheRecord(TheRec), CDP(cdp), isInputPattern(isInput), HasError(false ),
2799
2800
Infer(*this ) {
2800
2801
for (Init *I : RawPat->getValues ())
2801
2802
Trees.push_back (ParseTreePattern (I, " " ));
2802
2803
}
2803
2804
2804
- TreePattern::TreePattern (Record *TheRec, DagInit *Pat, bool isInput,
2805
+ TreePattern::TreePattern (const Record *TheRec, DagInit *Pat, bool isInput,
2805
2806
CodeGenDAGPatterns &cdp)
2806
2807
: TheRecord(TheRec), CDP(cdp), isInputPattern(isInput), HasError(false ),
2807
2808
Infer(*this ) {
2808
2809
Trees.push_back (ParseTreePattern (Pat, " " ));
2809
2810
}
2810
2811
2811
- TreePattern::TreePattern (Record *TheRec, TreePatternNodePtr Pat, bool isInput ,
2812
- CodeGenDAGPatterns &cdp)
2812
+ TreePattern::TreePattern (const Record *TheRec, TreePatternNodePtr Pat,
2813
+ bool isInput, CodeGenDAGPatterns &cdp)
2813
2814
: TheRecord(TheRec), CDP(cdp), isInputPattern(isInput), HasError(false ),
2814
2815
Infer(*this ) {
2815
2816
Trees.push_back (Pat);
@@ -3389,7 +3390,7 @@ static bool HandleUse(TreePattern &I, TreePatternNodePtr Pat,
3389
3390
return false ;
3390
3391
}
3391
3392
3392
- Record *Rec;
3393
+ const Record *Rec;
3393
3394
if (Pat->isLeaf ()) {
3394
3395
DefInit *DI = dyn_cast<DefInit>(Pat->getLeafValue ());
3395
3396
if (!DI)
@@ -3408,7 +3409,7 @@ static bool HandleUse(TreePattern &I, TreePatternNodePtr Pat,
3408
3409
Slot = Pat;
3409
3410
return true ;
3410
3411
}
3411
- Record *SlotRec;
3412
+ const Record *SlotRec;
3412
3413
if (Slot->isLeaf ()) {
3413
3414
SlotRec = cast<DefInit>(Slot->getLeafValue ())->getDef ();
3414
3415
} else {
@@ -3633,7 +3634,8 @@ class InstAnalyzer {
3633
3634
};
3634
3635
3635
3636
static bool InferFromPattern (CodeGenInstruction &InstInfo,
3636
- const InstAnalyzer &PatInfo, Record *PatDef) {
3637
+ const InstAnalyzer &PatInfo,
3638
+ const Record *PatDef) {
3637
3639
bool Error = false ;
3638
3640
3639
3641
// Remember where InstInfo got its flags.
@@ -3729,7 +3731,7 @@ static bool hasNullFragReference(ListInit *LI) {
3729
3731
3730
3732
// / Get all the instructions in a tree.
3731
3733
static void getInstructionsInTree (TreePatternNode &Tree,
3732
- SmallVectorImpl<Record *> &Instrs) {
3734
+ SmallVectorImpl<const Record *> &Instrs) {
3733
3735
if (Tree.isLeaf ())
3734
3736
return ;
3735
3737
if (Tree.getOperator ()->isSubClassOf (" Instruction" ))
@@ -3935,8 +3937,7 @@ void CodeGenDAGPatterns::parseInstructionPattern(CodeGenInstruction &CGI,
3935
3937
3936
3938
// Create and insert the instruction.
3937
3939
// FIXME: InstImpResults should not be part of DAGInstruction.
3938
- Record *R = I.getRecord ();
3939
- DAGInsts.try_emplace (R, std::move (Results), std::move (Operands),
3940
+ DAGInsts.try_emplace (I.getRecord (), std::move (Results), std::move (Operands),
3940
3941
std::move (InstImpResults), SrcPattern, ResultPattern);
3941
3942
3942
3943
LLVM_DEBUG (I.dump ());
@@ -3989,9 +3990,7 @@ void CodeGenDAGPatterns::ParseInstructions() {
3989
3990
}
3990
3991
3991
3992
// If we can, convert the instructions to be patterns that are matched!
3992
- for (auto &Entry : Instructions) {
3993
- Record *Instr = Entry.first ;
3994
- DAGInstruction &TheInst = Entry.second ;
3993
+ for (const auto &[Instr, TheInst] : Instructions) {
3995
3994
TreePatternNodePtr SrcPattern = TheInst.getSrcPattern ();
3996
3995
TreePatternNodePtr ResultPattern = TheInst.getResultPattern ();
3997
3996
@@ -4078,7 +4077,7 @@ void CodeGenDAGPatterns::InferInstructionFlags() {
4078
4077
for (const PatternToMatch &PTM : ptms ()) {
4079
4078
// We can only infer from single-instruction patterns, otherwise we won't
4080
4079
// know which instruction should get the flags.
4081
- SmallVector<Record *, 8 > PatInstrs;
4080
+ SmallVector<const Record *, 8 > PatInstrs;
4082
4081
getInstructionsInTree (PTM.getDstPattern (), PatInstrs);
4083
4082
if (PatInstrs.size () != 1 )
4084
4083
continue ;
@@ -4135,7 +4134,7 @@ void CodeGenDAGPatterns::InferInstructionFlags() {
4135
4134
void CodeGenDAGPatterns::VerifyInstructionFlags () {
4136
4135
unsigned Errors = 0 ;
4137
4136
for (const PatternToMatch &PTM : ptms ()) {
4138
- SmallVector<Record *, 8 > Instrs;
4137
+ SmallVector<const Record *, 8 > Instrs;
4139
4138
getInstructionsInTree (PTM.getDstPattern (), Instrs);
4140
4139
if (Instrs.empty ())
4141
4140
continue ;
@@ -4245,7 +4244,7 @@ static TreePatternNodePtr PromoteXForms(TreePatternNodePtr N) {
4245
4244
}
4246
4245
4247
4246
void CodeGenDAGPatterns::ParseOnePattern (
4248
- Record *TheDef, TreePattern &Pattern, TreePattern &Result,
4247
+ const Record *TheDef, TreePattern &Pattern, TreePattern &Result,
4249
4248
const std::vector<Record *> &InstImpResults, bool ShouldIgnore) {
4250
4249
4251
4250
// Inline pattern fragments and expand multiple alternatives.
@@ -4591,7 +4590,7 @@ GatherChildrenOfAssociativeOpcode(TreePatternNodePtr N,
4591
4590
std::vector<TreePatternNodePtr> &Children) {
4592
4591
assert (N->getNumChildren () == 2 &&
4593
4592
" Associative but doesn't have 2 children!" );
4594
- Record *Operator = N->getOperator ();
4593
+ const Record *Operator = N->getOperator ();
4595
4594
4596
4595
// Only permit raw nodes.
4597
4596
if (!N->getName ().empty () || !N->getPredicateCalls ().empty () ||
0 commit comments