@@ -1529,7 +1529,7 @@ std::string PatternToMatch::getPredicateCheck() const {
1529
1529
// SDTypeConstraint implementation
1530
1530
//
1531
1531
1532
- SDTypeConstraint::SDTypeConstraint (Record *R, const CodeGenHwModes &CGH) {
1532
+ SDTypeConstraint::SDTypeConstraint (const Record *R, const CodeGenHwModes &CGH) {
1533
1533
OperandNo = R->getValueAsInt (" OperandNum" );
1534
1534
1535
1535
if (R->isSubClassOf (" SDTCisVT" )) {
@@ -1799,7 +1799,7 @@ bool TreePatternNode::setDefaultMode(unsigned Mode) {
1799
1799
// ===----------------------------------------------------------------------===//
1800
1800
// SDNodeInfo implementation
1801
1801
//
1802
- SDNodeInfo::SDNodeInfo (Record *R, const CodeGenHwModes &CGH) : Def(R) {
1802
+ SDNodeInfo::SDNodeInfo (const Record *R, const CodeGenHwModes &CGH) : Def(R) {
1803
1803
EnumName = R->getValueAsString (" Opcode" );
1804
1804
SDClassName = R->getValueAsString (" SDClass" );
1805
1805
Record *TypeProfile = R->getValueAsDef (" TypeProfile" );
@@ -2296,7 +2296,7 @@ static TypeSetByHwMode getImplicitType(Record *R, unsigned ResNo,
2296
2296
assert (ResNo == 0 && " FIXME: ComplexPattern with multiple results?" );
2297
2297
if (NotRegisters)
2298
2298
return TypeSetByHwMode (); // Unknown.
2299
- Record *T = CDP.getComplexPattern (R).getValueType ();
2299
+ const Record *T = CDP.getComplexPattern (R).getValueType ();
2300
2300
const CodeGenHwModes &CGH = CDP.getTargetInfo ().getHwModes ();
2301
2301
return TypeSetByHwMode (getValueTypeByHwMode (T, CGH));
2302
2302
}
@@ -2700,7 +2700,7 @@ bool TreePatternNode::ApplyTypeConstraints(TreePattern &TP, bool NotRegisters) {
2700
2700
2701
2701
if (!NotRegisters) {
2702
2702
assert (Types.size () == 1 && " ComplexPatterns only produce one result!" );
2703
- Record *T = CDP.getComplexPattern (getOperator ()).getValueType ();
2703
+ const Record *T = CDP.getComplexPattern (getOperator ()).getValueType ();
2704
2704
const CodeGenHwModes &CGH = CDP.getTargetInfo ().getHwModes ();
2705
2705
const ValueTypeByHwMode VVT = getValueTypeByHwMode (T, CGH);
2706
2706
// TODO: AArch64 and AMDGPU use ComplexPattern<untyped, ...> and then
@@ -3157,7 +3157,7 @@ void TreePattern::dump() const { print(errs()); }
3157
3157
// CodeGenDAGPatterns implementation
3158
3158
//
3159
3159
3160
- CodeGenDAGPatterns::CodeGenDAGPatterns (RecordKeeper &R,
3160
+ CodeGenDAGPatterns::CodeGenDAGPatterns (const RecordKeeper &R,
3161
3161
PatternRewriterFn PatternRewriter)
3162
3162
: Records(R), Target(R), Intrinsics(R),
3163
3163
LegalVTS(Target.getLegalValueTypes()), PatternRewriter(PatternRewriter) {
@@ -3198,14 +3198,10 @@ Record *CodeGenDAGPatterns::getSDNodeNamed(StringRef Name) const {
3198
3198
3199
3199
// Parse all of the SDNode definitions for the target, populating SDNodes.
3200
3200
void CodeGenDAGPatterns::ParseNodeInfo () {
3201
- std::vector<Record *> Nodes = Records.getAllDerivedDefinitions (" SDNode" );
3202
3201
const CodeGenHwModes &CGH = getTargetInfo ().getHwModes ();
3203
3202
3204
- while (!Nodes.empty ()) {
3205
- Record *R = Nodes.back ();
3203
+ for (const Record *R : reverse (Records.getAllDerivedDefinitions (" SDNode" )))
3206
3204
SDNodes.insert (std::pair (R, SDNodeInfo (R, CGH)));
3207
- Nodes.pop_back ();
3208
- }
3209
3205
3210
3206
// Get the builtin intrinsic nodes.
3211
3207
intrinsic_void_sdnode = getSDNodeNamed (" intrinsic_void" );
@@ -3216,26 +3212,18 @@ void CodeGenDAGPatterns::ParseNodeInfo() {
3216
3212
// / ParseNodeTransforms - Parse all SDNodeXForm instances into the SDNodeXForms
3217
3213
// / map, and emit them to the file as functions.
3218
3214
void CodeGenDAGPatterns::ParseNodeTransforms () {
3219
- std::vector<Record *> Xforms =
3220
- Records.getAllDerivedDefinitions (" SDNodeXForm" );
3221
- while (!Xforms.empty ()) {
3222
- Record *XFormNode = Xforms.back ();
3223
- Record *SDNode = XFormNode->getValueAsDef (" Opcode" );
3215
+ for (const Record *XFormNode :
3216
+ reverse (Records.getAllDerivedDefinitions (" SDNodeXForm" ))) {
3217
+ const Record *SDNode = XFormNode->getValueAsDef (" Opcode" );
3224
3218
StringRef Code = XFormNode->getValueAsString (" XFormFunction" );
3225
- SDNodeXForms.insert (
3226
- std::pair (XFormNode, NodeXForm (SDNode, std::string (Code))));
3227
-
3228
- Xforms.pop_back ();
3219
+ SDNodeXForms.insert ({XFormNode, NodeXForm (SDNode, std::string (Code))});
3229
3220
}
3230
3221
}
3231
3222
3232
3223
void CodeGenDAGPatterns::ParseComplexPatterns () {
3233
- std::vector<Record *> AMs =
3234
- Records.getAllDerivedDefinitions (" ComplexPattern" );
3235
- while (!AMs.empty ()) {
3236
- ComplexPatterns.insert (std::pair (AMs.back (), AMs.back ()));
3237
- AMs.pop_back ();
3238
- }
3224
+ for (const Record *R :
3225
+ reverse (Records.getAllDerivedDefinitions (" ComplexPattern" )))
3226
+ ComplexPatterns.insert ({R, R});
3239
3227
}
3240
3228
3241
3229
// / ParsePatternFragments - Parse all of the PatFrag definitions in the .td
@@ -3244,11 +3232,10 @@ void CodeGenDAGPatterns::ParseComplexPatterns() {
3244
3232
// / inside a pattern fragment to a pattern fragment.
3245
3233
// /
3246
3234
void CodeGenDAGPatterns::ParsePatternFragments (bool OutFrags) {
3247
- std::vector<Record *> Fragments =
3248
- Records.getAllDerivedDefinitions (" PatFrags" );
3249
-
3250
3235
// First step, parse all of the fragments.
3251
- for (Record *Frag : Fragments) {
3236
+ ArrayRef<const Record *> Fragments =
3237
+ Records.getAllDerivedDefinitions (" PatFrags" );
3238
+ for (const Record *Frag : Fragments) {
3252
3239
if (OutFrags != Frag->isSubClassOf (" OutPatFrag" ))
3253
3240
continue ;
3254
3241
@@ -3307,7 +3294,7 @@ void CodeGenDAGPatterns::ParsePatternFragments(bool OutFrags) {
3307
3294
3308
3295
// Now that we've parsed all of the tree fragments, do a closure on them so
3309
3296
// that there are not references to PatFrags left inside of them.
3310
- for (Record *Frag : Fragments) {
3297
+ for (const Record *Frag : Fragments) {
3311
3298
if (OutFrags != Frag->isSubClassOf (" OutPatFrag" ))
3312
3299
continue ;
3313
3300
@@ -3331,8 +3318,8 @@ void CodeGenDAGPatterns::ParsePatternFragments(bool OutFrags) {
3331
3318
}
3332
3319
3333
3320
void CodeGenDAGPatterns::ParseDefaultOperands () {
3334
- std::vector< Record *> DefaultOps;
3335
- DefaultOps = Records.getAllDerivedDefinitions (" OperandWithDefaultOps" );
3321
+ ArrayRef< const Record *> DefaultOps =
3322
+ Records.getAllDerivedDefinitions (" OperandWithDefaultOps" );
3336
3323
3337
3324
// Find some SDNode.
3338
3325
assert (!SDNodes.empty () && " No SDNodes parsed?" );
@@ -3947,10 +3934,7 @@ void CodeGenDAGPatterns::parseInstructionPattern(CodeGenInstruction &CGI,
3947
3934
// / any fragments involved. This populates the Instructions list with fully
3948
3935
// / resolved instructions.
3949
3936
void CodeGenDAGPatterns::ParseInstructions () {
3950
- std::vector<Record *> Instrs =
3951
- Records.getAllDerivedDefinitions (" Instruction" );
3952
-
3953
- for (Record *Instr : Instrs) {
3937
+ for (const Record *Instr : Records.getAllDerivedDefinitions (" Instruction" )) {
3954
3938
ListInit *LI = nullptr ;
3955
3939
3956
3940
if (isa<ListInit>(Instr->getValueInit (" Pattern" )))
@@ -4346,9 +4330,7 @@ void CodeGenDAGPatterns::ParseOnePattern(
4346
4330
}
4347
4331
4348
4332
void CodeGenDAGPatterns::ParsePatterns () {
4349
- std::vector<Record *> Patterns = Records.getAllDerivedDefinitions (" Pattern" );
4350
-
4351
- for (Record *CurPattern : Patterns) {
4333
+ for (const Record *CurPattern : Records.getAllDerivedDefinitions (" Pattern" )) {
4352
4334
DagInit *Tree = CurPattern->getValueAsDag (" PatternToMatch" );
4353
4335
4354
4336
// If the pattern references the null_frag, there's nothing to do.
@@ -4407,10 +4389,10 @@ void CodeGenDAGPatterns::ExpandHwModeBasedTypes() {
4407
4389
return ;
4408
4390
}
4409
4391
4410
- PatternsToMatch.emplace_back (
4411
- P. getSrcRecord (), P. getPredicates ( ), std::move (NewSrc ),
4412
- std::move (NewDst), P.getDstRegs (), P.getAddedComplexity (),
4413
- Record:: getNewUID (Records ), P.getGISelShouldIgnore (), Check);
4392
+ PatternsToMatch.emplace_back (P. getSrcRecord (), P. getPredicates (),
4393
+ std::move (NewSrc ), std::move (NewDst ),
4394
+ P.getDstRegs (), P.getAddedComplexity (),
4395
+ getNewUID (), P.getGISelShouldIgnore (), Check);
4414
4396
};
4415
4397
4416
4398
for (PatternToMatch &P : Copy) {
@@ -4780,11 +4762,16 @@ void CodeGenDAGPatterns::GenerateVariants() {
4780
4762
PatternsToMatch[i].getSrcRecord (), PatternsToMatch[i].getPredicates (),
4781
4763
Variant, PatternsToMatch[i].getDstPatternShared (),
4782
4764
PatternsToMatch[i].getDstRegs (),
4783
- PatternsToMatch[i].getAddedComplexity (), Record:: getNewUID (Records ),
4765
+ PatternsToMatch[i].getAddedComplexity (), getNewUID (),
4784
4766
PatternsToMatch[i].getGISelShouldIgnore (),
4785
4767
PatternsToMatch[i].getHwModeFeatures ());
4786
4768
}
4787
4769
4788
4770
LLVM_DEBUG (errs () << " \n " );
4789
4771
}
4790
4772
}
4773
+
4774
+ unsigned CodeGenDAGPatterns::getNewUID () {
4775
+ RecordKeeper &MutableRC = const_cast <RecordKeeper &>(Records);
4776
+ return Record::getNewUID (MutableRC);
4777
+ }
0 commit comments