[llvm] r256725 - [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.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 12 23:57:22 PST 2016


Test case added in r257584.

On Tue, Jan 12, 2016 at 5:12 PM, David Blaikie <dblaikie at gmail.com> wrote:

>
>
> On Sun, Jan 3, 2016 at 7:05 PM, Craig Topper via llvm-commits <
> llvm-commits at lists.llvm.org> wrote:
>
>> Author: ctopper
>> Date: Sun Jan  3 21:05:14 2016
>> New Revision: 256725
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=256725&view=rev
>> Log:
>> [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.
>>
>> 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.
>>
>> 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.
>>
>> This fixes the names of some AVX512 FMA instructions that showed this
>> double expansion.
>>
>
> Any way to test any of this? (either tblgen directly, or the AVX512 stuff
> that it was producing)
>
>
>>
>> Modified:
>>     llvm/trunk/lib/TableGen/TGParser.cpp
>>     llvm/trunk/lib/TableGen/TGParser.h
>>
>> Modified: llvm/trunk/lib/TableGen/TGParser.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGParser.cpp?rev=256725&r1=256724&r2=256725&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/TableGen/TGParser.cpp (original)
>> +++ llvm/trunk/lib/TableGen/TGParser.cpp Sun Jan  3 21:05:14 2016
>> @@ -77,7 +77,8 @@ bool TGParser::AddValue(Record *CurRec,
>>  /// SetValue -
>>  /// Return true on error, false on success.
>>  bool TGParser::SetValue(Record *CurRec, SMLoc Loc, Init *ValName,
>> -                        const std::vector<unsigned> &BitList, Init *V) {
>> +                        const std::vector<unsigned> &BitList, Init *V,
>> +                        bool AllowSelfAssignment) {
>>    if (!V) return false;
>>
>>    if (!CurRec) CurRec = &CurMultiClass->Rec;
>> @@ -91,8 +92,8 @@ bool TGParser::SetValue(Record *CurRec,
>>    // in the resolution machinery.
>>    if (BitList.empty())
>>      if (VarInit *VI = dyn_cast<VarInit>(V))
>> -      if (VI->getNameInit() == ValName)
>> -        return false;
>> +      if (VI->getNameInit() == ValName && !AllowSelfAssignment)
>> +        return true;
>>
>>    // If we are assigning to a subset of the bits in the value... then we
>> must be
>>    // assigning to a field of BitsRecTy, which must have a BitsInit
>> @@ -2359,7 +2360,8 @@ Record *TGParser::InstantiateMulticlassD
>>    // though, so that uses in nested multiclass names don't get
>>    // confused.
>>    if (SetValue(CurRec.get(), Ref.RefRange.Start, "NAME",
>> -               std::vector<unsigned>(), DefmPrefix)) {
>> +               std::vector<unsigned>(), DefmPrefix,
>> +               /*AllowSelfAssignment*/true)) {
>>      Error(DefmPrefixRange.Start, "Could not resolve " +
>>            CurRec->getNameInitAsString() + ":NAME to '" +
>>            DefmPrefix->getAsUnquotedString() + "'");
>>
>> Modified: llvm/trunk/lib/TableGen/TGParser.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGParser.h?rev=256725&r1=256724&r2=256725&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/TableGen/TGParser.h (original)
>> +++ llvm/trunk/lib/TableGen/TGParser.h Sun Jan  3 21:05:14 2016
>> @@ -105,10 +105,13 @@ public:
>>  private:  // Semantic analysis methods.
>>    bool AddValue(Record *TheRec, SMLoc Loc, const RecordVal &RV);
>>    bool SetValue(Record *TheRec, SMLoc Loc, Init *ValName,
>> -                const std::vector<unsigned> &BitList, Init *V);
>> +                const std::vector<unsigned> &BitList, Init *V,
>> +                bool AllowSelfAssignment = false);
>>    bool SetValue(Record *TheRec, SMLoc Loc, const std::string &ValName,
>> -                const std::vector<unsigned> &BitList, Init *V) {
>> -    return SetValue(TheRec, Loc, StringInit::get(ValName), BitList, V);
>> +                const std::vector<unsigned> &BitList, Init *V,
>> +                bool AllowSelfAssignment = false) {
>> +    return SetValue(TheRec, Loc, StringInit::get(ValName), BitList, V,
>> +                    AllowSelfAssignment);
>>    }
>>    bool AddSubClass(Record *Rec, SubClassReference &SubClass);
>>    bool AddSubMultiClass(MultiClass *CurMC,
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>
>


-- 
~Craig
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160112/c336f164/attachment-0001.html>


More information about the llvm-commits mailing list