[llvm] r210526 - Anonymous definitions in foreach blocks triggered a 'def already exists'
Artyom Skrobov
Artyom.Skrobov at arm.com
Tue Jun 10 05:41:15 PDT 2014
Author: askrobov
Date: Tue Jun 10 07:41:14 2014
New Revision: 210526
URL: http://llvm.org/viewvc/llvm-project?rev=210526&view=rev
Log:
Anonymous definitions in foreach blocks triggered a 'def already exists'
Modified:
llvm/trunk/lib/TableGen/TGParser.cpp
llvm/trunk/test/TableGen/ForeachLoop.td
Modified: llvm/trunk/lib/TableGen/TGParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGParser.cpp?rev=210526&r1=210525&r2=210526&view=diff
==============================================================================
--- llvm/trunk/lib/TableGen/TGParser.cpp (original)
+++ llvm/trunk/lib/TableGen/TGParser.cpp Tue Jun 10 07:41:14 2014
@@ -360,8 +360,13 @@ bool TGParser::ProcessForeachDefs(Record
}
if (Records.getDef(IterRec->getNameInitAsString())) {
- Error(Loc, "def already exists: " + IterRec->getNameInitAsString());
- return true;
+ // If this record is anonymous, it's no problem, just generate a new name
+ if (IterRec->isAnonymous())
+ IterRec->setName(GetNewAnonymousName());
+ else {
+ Error(Loc, "def already exists: " + IterRec->getNameInitAsString());
+ return true;
+ }
}
Records.addDef(IterRec);
Modified: llvm/trunk/test/TableGen/ForeachLoop.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/ForeachLoop.td?rev=210526&r1=210525&r2=210526&view=diff
==============================================================================
--- llvm/trunk/test/TableGen/ForeachLoop.td (original)
+++ llvm/trunk/test/TableGen/ForeachLoop.td Tue Jun 10 07:41:14 2014
@@ -51,8 +51,10 @@ foreach i = [0, 1, 2, 3, 4, 5, 6, 7] in
// CHECK: string Name = "R7";
// CHECK: int Index = 7;
-foreach i = {0-3,9-7} in
+foreach i = {0-3,9-7} in {
def S#i : Register<"Q"#i, i>;
+ def : Register<"T"#i, i>;
+}
// CHECK: def S0
// CHECK: def S1
@@ -61,3 +63,25 @@ foreach i = {0-3,9-7} in
// CHECK: def S7
// CHECK: def S8
// CHECK: def S9
+
+// CHECK: def
+// CHECK: string Name = "T0";
+
+// CHECK: def
+// CHECK: string Name = "T1";
+
+// CHECK: def
+// CHECK: string Name = "T2";
+
+// CHECK: def
+// CHECK: string Name = "T3";
+
+// CHECK: def
+// CHECK: string Name = "T9";
+
+// CHECK: def
+// CHECK: string Name = "T8";
+
+// CHECK: def
+// CHECK: string Name = "T7";
+
More information about the llvm-commits
mailing list