@@ -1529,7 +1529,7 @@ std::string PatternToMatch::getPredicateCheck() const {
15291529// SDTypeConstraint implementation
15301530//
15311531
1532- SDTypeConstraint::SDTypeConstraint (Record *R, const CodeGenHwModes &CGH) {
1532+ SDTypeConstraint::SDTypeConstraint (const Record *R, const CodeGenHwModes &CGH) {
15331533 OperandNo = R->getValueAsInt (" OperandNum" );
15341534
15351535 if (R->isSubClassOf (" SDTCisVT" )) {
@@ -1799,7 +1799,7 @@ bool TreePatternNode::setDefaultMode(unsigned Mode) {
17991799// ===----------------------------------------------------------------------===//
18001800// SDNodeInfo implementation
18011801//
1802- SDNodeInfo::SDNodeInfo (Record *R, const CodeGenHwModes &CGH) : Def(R) {
1802+ SDNodeInfo::SDNodeInfo (const Record *R, const CodeGenHwModes &CGH) : Def(R) {
18031803 EnumName = R->getValueAsString (" Opcode" );
18041804 SDClassName = R->getValueAsString (" SDClass" );
18051805 Record *TypeProfile = R->getValueAsDef (" TypeProfile" );
@@ -2296,7 +2296,7 @@ static TypeSetByHwMode getImplicitType(Record *R, unsigned ResNo,
22962296 assert (ResNo == 0 && " FIXME: ComplexPattern with multiple results?" );
22972297 if (NotRegisters)
22982298 return TypeSetByHwMode (); // Unknown.
2299- Record *T = CDP.getComplexPattern (R).getValueType ();
2299+ const Record *T = CDP.getComplexPattern (R).getValueType ();
23002300 const CodeGenHwModes &CGH = CDP.getTargetInfo ().getHwModes ();
23012301 return TypeSetByHwMode (getValueTypeByHwMode (T, CGH));
23022302 }
@@ -2700,7 +2700,7 @@ bool TreePatternNode::ApplyTypeConstraints(TreePattern &TP, bool NotRegisters) {
27002700
27012701 if (!NotRegisters) {
27022702 assert (Types.size () == 1 && " ComplexPatterns only produce one result!" );
2703- Record *T = CDP.getComplexPattern (getOperator ()).getValueType ();
2703+ const Record *T = CDP.getComplexPattern (getOperator ()).getValueType ();
27042704 const CodeGenHwModes &CGH = CDP.getTargetInfo ().getHwModes ();
27052705 const ValueTypeByHwMode VVT = getValueTypeByHwMode (T, CGH);
27062706 // TODO: AArch64 and AMDGPU use ComplexPattern<untyped, ...> and then
@@ -3157,7 +3157,7 @@ void TreePattern::dump() const { print(errs()); }
31573157// CodeGenDAGPatterns implementation
31583158//
31593159
3160- CodeGenDAGPatterns::CodeGenDAGPatterns (RecordKeeper &R,
3160+ CodeGenDAGPatterns::CodeGenDAGPatterns (const RecordKeeper &R,
31613161 PatternRewriterFn PatternRewriter)
31623162 : Records(R), Target(R), Intrinsics(R),
31633163 LegalVTS(Target.getLegalValueTypes()), PatternRewriter(PatternRewriter) {
@@ -3198,14 +3198,10 @@ Record *CodeGenDAGPatterns::getSDNodeNamed(StringRef Name) const {
31983198
31993199// Parse all of the SDNode definitions for the target, populating SDNodes.
32003200void CodeGenDAGPatterns::ParseNodeInfo () {
3201- std::vector<Record *> Nodes = Records.getAllDerivedDefinitions (" SDNode" );
32023201 const CodeGenHwModes &CGH = getTargetInfo ().getHwModes ();
32033202
3204- while (!Nodes.empty ()) {
3205- Record *R = Nodes.back ();
3203+ for (const Record *R : reverse (Records.getAllDerivedDefinitions (" SDNode" )))
32063204 SDNodes.insert (std::pair (R, SDNodeInfo (R, CGH)));
3207- Nodes.pop_back ();
3208- }
32093205
32103206 // Get the builtin intrinsic nodes.
32113207 intrinsic_void_sdnode = getSDNodeNamed (" intrinsic_void" );
@@ -3216,26 +3212,18 @@ void CodeGenDAGPatterns::ParseNodeInfo() {
32163212// / ParseNodeTransforms - Parse all SDNodeXForm instances into the SDNodeXForms
32173213// / map, and emit them to the file as functions.
32183214void 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" );
32243218 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))});
32293220 }
32303221}
32313222
32323223void 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});
32393227}
32403228
32413229// / ParsePatternFragments - Parse all of the PatFrag definitions in the .td
@@ -3244,11 +3232,10 @@ void CodeGenDAGPatterns::ParseComplexPatterns() {
32443232// / inside a pattern fragment to a pattern fragment.
32453233// /
32463234void CodeGenDAGPatterns::ParsePatternFragments (bool OutFrags) {
3247- std::vector<Record *> Fragments =
3248- Records.getAllDerivedDefinitions (" PatFrags" );
3249-
32503235 // 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) {
32523239 if (OutFrags != Frag->isSubClassOf (" OutPatFrag" ))
32533240 continue ;
32543241
@@ -3307,7 +3294,7 @@ void CodeGenDAGPatterns::ParsePatternFragments(bool OutFrags) {
33073294
33083295 // Now that we've parsed all of the tree fragments, do a closure on them so
33093296 // that there are not references to PatFrags left inside of them.
3310- for (Record *Frag : Fragments) {
3297+ for (const Record *Frag : Fragments) {
33113298 if (OutFrags != Frag->isSubClassOf (" OutPatFrag" ))
33123299 continue ;
33133300
@@ -3331,8 +3318,8 @@ void CodeGenDAGPatterns::ParsePatternFragments(bool OutFrags) {
33313318}
33323319
33333320void CodeGenDAGPatterns::ParseDefaultOperands () {
3334- std::vector< Record *> DefaultOps;
3335- DefaultOps = Records.getAllDerivedDefinitions (" OperandWithDefaultOps" );
3321+ ArrayRef< const Record *> DefaultOps =
3322+ Records.getAllDerivedDefinitions (" OperandWithDefaultOps" );
33363323
33373324 // Find some SDNode.
33383325 assert (!SDNodes.empty () && " No SDNodes parsed?" );
@@ -3947,10 +3934,7 @@ void CodeGenDAGPatterns::parseInstructionPattern(CodeGenInstruction &CGI,
39473934// / any fragments involved. This populates the Instructions list with fully
39483935// / resolved instructions.
39493936void 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" )) {
39543938 ListInit *LI = nullptr ;
39553939
39563940 if (isa<ListInit>(Instr->getValueInit (" Pattern" )))
@@ -4346,9 +4330,7 @@ void CodeGenDAGPatterns::ParseOnePattern(
43464330}
43474331
43484332void CodeGenDAGPatterns::ParsePatterns () {
4349- std::vector<Record *> Patterns = Records.getAllDerivedDefinitions (" Pattern" );
4350-
4351- for (Record *CurPattern : Patterns) {
4333+ for (const Record *CurPattern : Records.getAllDerivedDefinitions (" Pattern" )) {
43524334 DagInit *Tree = CurPattern->getValueAsDag (" PatternToMatch" );
43534335
43544336 // If the pattern references the null_frag, there's nothing to do.
@@ -4407,10 +4389,10 @@ void CodeGenDAGPatterns::ExpandHwModeBasedTypes() {
44074389 return ;
44084390 }
44094391
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);
44144396 };
44154397
44164398 for (PatternToMatch &P : Copy) {
@@ -4780,11 +4762,16 @@ void CodeGenDAGPatterns::GenerateVariants() {
47804762 PatternsToMatch[i].getSrcRecord (), PatternsToMatch[i].getPredicates (),
47814763 Variant, PatternsToMatch[i].getDstPatternShared (),
47824764 PatternsToMatch[i].getDstRegs (),
4783- PatternsToMatch[i].getAddedComplexity (), Record:: getNewUID (Records ),
4765+ PatternsToMatch[i].getAddedComplexity (), getNewUID (),
47844766 PatternsToMatch[i].getGISelShouldIgnore (),
47854767 PatternsToMatch[i].getHwModeFeatures ());
47864768 }
47874769
47884770 LLVM_DEBUG (errs () << " \n " );
47894771 }
47904772}
4773+
4774+ unsigned CodeGenDAGPatterns::getNewUID () {
4775+ RecordKeeper &MutableRC = const_cast <RecordKeeper &>(Records);
4776+ return Record::getNewUID (MutableRC);
4777+ }
0 commit comments