[llvm] r326707 - TableGen: Resolve all template args simultaneously in AddSubMultiClass
Nicolai Haehnle via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 5 07:21:16 PST 2018
Author: nha
Date: Mon Mar 5 07:21:15 2018
New Revision: 326707
URL: http://llvm.org/viewvc/llvm-project?rev=326707&view=rev
Log:
TableGen: Resolve all template args simultaneously in AddSubMultiClass
Summary:
Use the new resolver interface more explicitly, and avoid traversing
all the initializers multiple times.
Change-Id: Ia4dcc6d42dd8b65e6079d318c6a202f36f320fee
Reviewers: arsenm, craig.topper, tra, MartinO
Subscribers: wdng, llvm-commits
Differential Revision: https://reviews.llvm.org/D43653
Modified:
llvm/trunk/lib/TableGen/TGParser.cpp
Modified: llvm/trunk/lib/TableGen/TGParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGParser.cpp?rev=326707&r1=326706&r2=326707&view=diff
==============================================================================
--- llvm/trunk/lib/TableGen/TGParser.cpp (original)
+++ llvm/trunk/lib/TableGen/TGParser.cpp Mon Mar 5 07:21:15 2018
@@ -252,6 +252,8 @@ bool TGParser::AddSubMultiClass(MultiCla
// Loop over all of the template arguments, setting them to the specified
// value or leaving them as the default if necessary.
+ MapResolver CurRecResolver(CurRec);
+
for (unsigned i = 0, e = SMCTArgs.size(); i != e; ++i) {
if (i < SubMultiClass.TemplateArgs.size()) {
// If a value is specified for this template arg, set it in the
@@ -260,12 +262,6 @@ bool TGParser::AddSubMultiClass(MultiCla
None, SubMultiClass.TemplateArgs[i]))
return true;
- // Resolve it next.
- CurRec->resolveReferencesTo(CurRec->getValue(SMCTArgs[i]));
-
- // Now remove it.
- CurRec->removeValue(SMCTArgs[i]);
-
// If a value is specified for this template arg, set it in the
// new defs now.
for (const auto &Def :
@@ -273,12 +269,6 @@ bool TGParser::AddSubMultiClass(MultiCla
if (SetValue(Def.get(), SubMultiClass.RefRange.Start, SMCTArgs[i],
None, SubMultiClass.TemplateArgs[i]))
return true;
-
- // Resolve it next.
- Def->resolveReferencesTo(Def->getValue(SMCTArgs[i]));
-
- // Now remove it
- Def->removeValue(SMCTArgs[i]);
}
} else if (!CurRec->getValue(SMCTArgs[i])->getValue()->isComplete()) {
return Error(SubMultiClass.RefRange.Start,
@@ -286,6 +276,24 @@ bool TGParser::AddSubMultiClass(MultiCla
Twine(i) + " (" + SMCTArgs[i]->getAsUnquotedString() +
") of subclass '" + SMC->Rec.getNameInitAsString() + "'!");
}
+
+ CurRecResolver.set(SMCTArgs[i], CurRec->getValue(SMCTArgs[i])->getValue());
+
+ CurRec->removeValue(SMCTArgs[i]);
+ }
+
+ CurRec->resolveReferences(CurRecResolver);
+
+ for (const auto &Def :
+ makeArrayRef(CurMC->DefPrototypes).slice(newDefStart)) {
+ MapResolver R(Def.get());
+
+ for (Init *SMCTArg : SMCTArgs) {
+ R.set(SMCTArg, Def->getValue(SMCTArg)->getValue());
+ Def->removeValue(SMCTArg);
+ }
+
+ Def->resolveReferences(R);
}
return false;
More information about the llvm-commits
mailing list