<div dir="ltr">Test case added in r257584.</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 12, 2016 at 5:12 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jan 3, 2016 at 7:05 PM, Craig Topper via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ctopper<br>
Date: Sun Jan  3 21:05:14 2016<br>
New Revision: 256725<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=256725&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=256725&view=rev</a><br>
Log:<br>
[TableGen] Fix a bug that caused the wrong name for a record built from a multiclass containing a defm called NAME that references another multiclass that contains a defm that uses NAME concatenated with other strings.<br>
<br>
It would end up doing the concatenations from the second multiclass twice. This occured because SetValue detected a self assignment when trying to set the value of NAME to a VarInit called NAME. NAME is special here and it will get cleaned up later. So add a flag to suppress the self assignment check for this case.<br>
<br>
Strangely the self-assignment error was returning false indicating it wasn't an error, but it wasn't doing the right thing. So this also changes it to report an error.<br>
<br>
This fixes the names of some AVX512 FMA instructions that showed this double expansion.<br></blockquote><div><br></div><div>Any way to test any of this? (either tblgen directly, or the AVX512 stuff that it was producing)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Modified:<br>
    llvm/trunk/lib/TableGen/TGParser.cpp<br>
    llvm/trunk/lib/TableGen/TGParser.h<br>
<br>
Modified: llvm/trunk/lib/TableGen/TGParser.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGParser.cpp?rev=256725&r1=256724&r2=256725&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGParser.cpp?rev=256725&r1=256724&r2=256725&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/TableGen/TGParser.cpp (original)<br>
+++ llvm/trunk/lib/TableGen/TGParser.cpp Sun Jan  3 21:05:14 2016<br>
@@ -77,7 +77,8 @@ bool TGParser::AddValue(Record *CurRec,<br>
 /// SetValue -<br>
 /// Return true on error, false on success.<br>
 bool TGParser::SetValue(Record *CurRec, SMLoc Loc, Init *ValName,<br>
-                        const std::vector<unsigned> &BitList, Init *V) {<br>
+                        const std::vector<unsigned> &BitList, Init *V,<br>
+                        bool AllowSelfAssignment) {<br>
   if (!V) return false;<br>
<br>
   if (!CurRec) CurRec = &CurMultiClass->Rec;<br>
@@ -91,8 +92,8 @@ bool TGParser::SetValue(Record *CurRec,<br>
   // in the resolution machinery.<br>
   if (BitList.empty())<br>
     if (VarInit *VI = dyn_cast<VarInit>(V))<br>
-      if (VI->getNameInit() == ValName)<br>
-        return false;<br>
+      if (VI->getNameInit() == ValName && !AllowSelfAssignment)<br>
+        return true;<br>
<br>
   // If we are assigning to a subset of the bits in the value... then we must be<br>
   // assigning to a field of BitsRecTy, which must have a BitsInit<br>
@@ -2359,7 +2360,8 @@ Record *TGParser::InstantiateMulticlassD<br>
   // though, so that uses in nested multiclass names don't get<br>
   // confused.<br>
   if (SetValue(CurRec.get(), Ref.RefRange.Start, "NAME",<br>
-               std::vector<unsigned>(), DefmPrefix)) {<br>
+               std::vector<unsigned>(), DefmPrefix,<br>
+               /*AllowSelfAssignment*/true)) {<br>
     Error(DefmPrefixRange.Start, "Could not resolve " +<br>
           CurRec->getNameInitAsString() + ":NAME to '" +<br>
           DefmPrefix->getAsUnquotedString() + "'");<br>
<br>
Modified: llvm/trunk/lib/TableGen/TGParser.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGParser.h?rev=256725&r1=256724&r2=256725&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGParser.h?rev=256725&r1=256724&r2=256725&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/TableGen/TGParser.h (original)<br>
+++ llvm/trunk/lib/TableGen/TGParser.h Sun Jan  3 21:05:14 2016<br>
@@ -105,10 +105,13 @@ public:<br>
 private:  // Semantic analysis methods.<br>
   bool AddValue(Record *TheRec, SMLoc Loc, const RecordVal &RV);<br>
   bool SetValue(Record *TheRec, SMLoc Loc, Init *ValName,<br>
-                const std::vector<unsigned> &BitList, Init *V);<br>
+                const std::vector<unsigned> &BitList, Init *V,<br>
+                bool AllowSelfAssignment = false);<br>
   bool SetValue(Record *TheRec, SMLoc Loc, const std::string &ValName,<br>
-                const std::vector<unsigned> &BitList, Init *V) {<br>
-    return SetValue(TheRec, Loc, StringInit::get(ValName), BitList, V);<br>
+                const std::vector<unsigned> &BitList, Init *V,<br>
+                bool AllowSelfAssignment = false) {<br>
+    return SetValue(TheRec, Loc, StringInit::get(ValName), BitList, V,<br>
+                    AllowSelfAssignment);<br>
   }<br>
   bool AddSubClass(Record *Rec, SubClassReference &SubClass);<br>
   bool AddSubMultiClass(MultiClass *CurMC,<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">~Craig</div>
</div>