[llvm] r198340 - [TableGen] Use the same anonymous name as the prefix on all multiclass defs

Hal Finkel hfinkel at anl.gov
Thu Jan 2 11:35:34 PST 2014


Author: hfinkel
Date: Thu Jan  2 13:35:33 2014
New Revision: 198340

URL: http://llvm.org/viewvc/llvm-project?rev=198340&view=rev
Log:
[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).

Modified:
    llvm/trunk/lib/TableGen/TGParser.cpp
    llvm/trunk/lib/TableGen/TGParser.h
    llvm/trunk/test/TableGen/MultiClassDefName.td

Modified: llvm/trunk/lib/TableGen/TGParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGParser.cpp?rev=198340&r1=198339&r2=198340&view=diff
==============================================================================
--- llvm/trunk/lib/TableGen/TGParser.cpp (original)
+++ llvm/trunk/lib/TableGen/TGParser.cpp Thu Jan  2 13:35:33 2014
@@ -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.

Modified: llvm/trunk/lib/TableGen/TGParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGParser.h?rev=198340&r1=198339&r2=198340&view=diff
==============================================================================
--- llvm/trunk/lib/TableGen/TGParser.h (original)
+++ llvm/trunk/lib/TableGen/TGParser.h Thu Jan  2 13:35:33 2014
@@ -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,

Modified: llvm/trunk/test/TableGen/MultiClassDefName.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/MultiClassDefName.td?rev=198340&r1=198339&r2=198340&view=diff
==============================================================================
--- llvm/trunk/test/TableGen/MultiClassDefName.td (original)
+++ llvm/trunk/test/TableGen/MultiClassDefName.td Thu Jan  2 13:35:33 2014
@@ -14,3 +14,18 @@ multiclass Names<string n, string m> {
 }
 
 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 i> {
+  C Inner = i;
+}
+
+multiclass MC<string name> {
+  def hi : C<name>;
+  def there : Outer<!cast<C>(!strconcat(NAME, "hi"))>;
+}
+
+defm : MC<"foo">;
+





More information about the llvm-commits mailing list