From: Hal Finkel Date: Thu, 2 Jan 2014 19:35:33 +0000 (+0000) Subject: [TableGen] Use the same anonymous name as the prefix on all multiclass defs X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=2370e55a535331c849371ed52a3f62b8c5f315a3;p=oota-llvm.git [TableGen] Use the same anonymous name as the prefix on all multiclass defs TableGen had been generating a different name for an anonymous multiclass's NAME for every def in the multiclass. This had an unfortunate side effect: it was impossible to reference one def within the multiclass from another (in the parameter list, for example). By making sure we only generate an anonymous name once per multiclass (which, as it turns out, requires only changing the name parameter to reference type), we can now concatenate NAME within the multiclass with a def name in order to generate a reference to that def. This does not matter so much, in and of itself, but is necessary for a follow-up commit that will fix variable capturing in implicit anonymous multiclass defs (and that is important). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198340 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/TableGen/TGParser.cpp b/lib/TableGen/TGParser.cpp index 38ab71184aa..be5a5242518 100644 --- a/lib/TableGen/TGParser.cpp +++ b/lib/TableGen/TGParser.cpp @@ -2269,7 +2269,7 @@ bool TGParser::ParseMultiClass() { Record *TGParser:: InstantiateMulticlassDef(MultiClass &MC, Record *DefProto, - Init *DefmPrefix, + Init *&DefmPrefix, SMRange DefmPrefixRange) { // We need to preserve DefProto so it can be reused for later // instantiations, so create a new Record to inherit from it. diff --git a/lib/TableGen/TGParser.h b/lib/TableGen/TGParser.h index a5753458108..e5559a33e38 100644 --- a/lib/TableGen/TGParser.h +++ b/lib/TableGen/TGParser.h @@ -137,7 +137,7 @@ private: // Parser methods. bool ParseMultiClass(); Record *InstantiateMulticlassDef(MultiClass &MC, Record *DefProto, - Init *DefmPrefix, + Init *&DefmPrefix, SMRange DefmPrefixRange); bool ResolveMulticlassDefArgs(MultiClass &MC, Record *DefProto, diff --git a/test/TableGen/MultiClassDefName.td b/test/TableGen/MultiClassDefName.td index d3c6de7e842..69b951d378a 100644 --- a/test/TableGen/MultiClassDefName.td +++ b/test/TableGen/MultiClassDefName.td @@ -14,3 +14,18 @@ multiclass Names { } defm Hello : Names<"hello", "world">; + +// Ensure that the same anonymous name is used as the prefix for all defs in an +// anonymous multiclass. + +class Outer { + C Inner = i; +} + +multiclass MC { + def hi : C; + def there : Outer(!strconcat(NAME, "hi"))>; +} + +defm : MC<"foo">; +