diff options
| author | Nicolai Haehnle <nhaehnle@gmail.com> | 2018-03-05 15:21:19 +0000 |
|---|---|---|
| committer | Nicolai Haehnle <nhaehnle@gmail.com> | 2018-03-05 15:21:19 +0000 |
| commit | 7d697857cd5d348b971107b8fc7a1fcf1d6d7add (patch) | |
| tree | 793c26fa5cf33c65b12d9c0b558addc916615248 | |
| parent | 1faf8689d7f065e29b0440178385c60451cde13e (diff) | |
| download | bcm5719-llvm-7d697857cd5d348b971107b8fc7a1fcf1d6d7add.tar.gz bcm5719-llvm-7d697857cd5d348b971107b8fc7a1fcf1d6d7add.zip | |
TableGen: Resolve all template args simultaneously in ResolveMulticlassDefARgs
Summary:
Use the new resolver interface more explicitly, and avoid traversing
all the initializers multiple times.
Change-Id: I679e86988b309d19f25e6cca8b0b14ea150198a6
Reviewers: arsenm, craig.topper, tra, MartinO
Subscribers: wdng, llvm-commits
Differential Revision: https://reviews.llvm.org/D43654
llvm-svn: 326708
| -rw-r--r-- | llvm/lib/TableGen/TGParser.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/llvm/lib/TableGen/TGParser.cpp b/llvm/lib/TableGen/TGParser.cpp index 73a7e5cd6a7..6b29061b751 100644 --- a/llvm/lib/TableGen/TGParser.cpp +++ b/llvm/lib/TableGen/TGParser.cpp @@ -2576,29 +2576,30 @@ bool TGParser::ResolveMulticlassDefArgs(MultiClass &MC, Record *CurRec, ArrayRef<Init *> TArgs, ArrayRef<Init *> TemplateVals, bool DeleteArgs) { - // Loop over all of the template arguments, setting them to the specified - // value or leaving them as the default if necessary. + // Set all template arguments to the specified value or leave them as the + // default if necessary, then resolve them all simultaneously. + MapResolver R(CurRec); + for (unsigned i = 0, e = TArgs.size(); i != e; ++i) { // Check if a value is specified for this temp-arg. if (i < TemplateVals.size()) { - // Set it now. if (SetValue(CurRec, DefmPrefixLoc, TArgs[i], None, TemplateVals[i])) return true; - - // Resolve it next. - CurRec->resolveReferencesTo(CurRec->getValue(TArgs[i])); - - if (DeleteArgs) - // Now remove it. - CurRec->removeValue(TArgs[i]); - } else if (!CurRec->getValue(TArgs[i])->getValue()->isComplete()) { return Error(SubClassLoc, "value not specified for template argument #" + Twine(i) + " (" + TArgs[i]->getAsUnquotedString() + ") of multiclassclass '" + MC.Rec.getNameInitAsString() + "'"); } + + R.set(TArgs[i], CurRec->getValue(TArgs[i])->getValue()); + + if (DeleteArgs) + CurRec->removeValue(TArgs[i]); } + + CurRec->resolveReferences(R); + return false; } |

