[llvm-commits] [llvm] r142518 - in /llvm/trunk: include/llvm/TableGen/Record.h lib/TableGen/Record.cpp lib/TableGen/TGParser.cpp test/TableGen/Dag.td test/TableGen/foreach.td
David Greene
greened at obbligato.org
Wed Oct 19 06:04:13 PDT 2011
Author: greened
Date: Wed Oct 19 08:04:13 2011
New Revision: 142518
URL: http://llvm.org/viewvc/llvm-project?rev=142518&view=rev
Log:
Add NAME Member
Add a Value named "NAME" to each Record. This will be set to the def or defm
name when instantiating multiclasses. This will replace the #NAME# processing
hack once paste functionality is in place.
Modified:
llvm/trunk/include/llvm/TableGen/Record.h
llvm/trunk/lib/TableGen/Record.cpp
llvm/trunk/lib/TableGen/TGParser.cpp
llvm/trunk/test/TableGen/Dag.td
llvm/trunk/test/TableGen/foreach.td
Modified: llvm/trunk/include/llvm/TableGen/Record.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/TableGen/Record.h?rev=142518&r1=142517&r2=142518&view=diff
==============================================================================
--- llvm/trunk/include/llvm/TableGen/Record.h (original)
+++ llvm/trunk/include/llvm/TableGen/Record.h Wed Oct 19 08:04:13 2011
@@ -1473,6 +1473,13 @@
void addValue(const RecordVal &RV) {
assert(getValue(RV.getName()) == 0 && "Value already added!");
Values.push_back(RV);
+ if (Values.size() > 1)
+ // Keep NAME at the end of the list. It makes record dumps a
+ // bit prettier and allows TableGen tests to be written more
+ // naturally. Tests can use CHECK-NEXT to look for Record
+ // fields they expect to see after a def. They can't do that if
+ // NAME is the first Record field.
+ std::swap(Values[Values.size() - 2], Values[Values.size() - 1]);
}
void removeValue(Init *Name) {
Modified: llvm/trunk/lib/TableGen/Record.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/Record.cpp?rev=142518&r1=142517&r2=142518&view=diff
==============================================================================
--- llvm/trunk/lib/TableGen/Record.cpp (original)
+++ llvm/trunk/lib/TableGen/Record.cpp Wed Oct 19 08:04:13 2011
@@ -1686,6 +1686,11 @@
void Record::init() {
checkName();
+
+ // Every record potentially has a def at the top. This value is
+ // replaced with the top-level def name at instantiation time.
+ RecordVal DN("NAME", StringRecTy::get(), 0);
+ addValue(DN);
}
void Record::checkName() {
Modified: llvm/trunk/lib/TableGen/TGParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGParser.cpp?rev=142518&r1=142517&r2=142518&view=diff
==============================================================================
--- llvm/trunk/lib/TableGen/TGParser.cpp (original)
+++ llvm/trunk/lib/TableGen/TGParser.cpp Wed Oct 19 08:04:13 2011
@@ -1744,7 +1744,7 @@
Record *CurRec = Records.getClass(Lex.getCurStrVal());
if (CurRec) {
// If the body was previously defined, this is an error.
- if (!CurRec->getValues().empty() ||
+ if (CurRec->getValues().size() > 1 || // Account for NAME.
!CurRec->getSuperClasses().empty() ||
!CurRec->getTemplateArgs().empty())
return TokError("Class '" + CurRec->getNameInitAsString()
Modified: llvm/trunk/test/TableGen/Dag.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/Dag.td?rev=142518&r1=142517&r2=142518&view=diff
==============================================================================
--- llvm/trunk/test/TableGen/Dag.td (original)
+++ llvm/trunk/test/TableGen/Dag.td Wed Oct 19 08:04:13 2011
@@ -60,6 +60,7 @@
// CHECK-NEXT: dag Dag1 = (somedef1 1);
// CHECK-NEXT: dag Dag2 = (somedef1 2);
// CHECK-NEXT: dag Dag3 = (somedef1 2);
+// CHECK-NEXT: NAME = ?
// CHECK-NEXT: }
@@ -68,4 +69,5 @@
// CHECK-NEXT: dag Dag1 = (somedef1 1);
// CHECK-NEXT: dag Dag2 = (somedef2 2);
// CHECK-NEXT: dag Dag3 = (somedef2 2);
+// CHECK-NEXT: NAME = ?
// CHECK-NEXT: }
Modified: llvm/trunk/test/TableGen/foreach.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/foreach.td?rev=142518&r1=142517&r2=142518&view=diff
==============================================================================
--- llvm/trunk/test/TableGen/foreach.td (original)
+++ llvm/trunk/test/TableGen/foreach.td Wed Oct 19 08:04:13 2011
@@ -1,6 +1,6 @@
// RUN: llvm-tblgen %s | grep {Jr} | count 2
// RUN: llvm-tblgen %s | grep {Sr} | count 2
-// RUN: llvm-tblgen %s | grep {NAME} | count 1
+// RUN: llvm-tblgen %s | grep {"NAME"} | count 1
// XFAIL: vg_leak
// Variables for foreach
More information about the llvm-commits
mailing list