llvm.org GIT mirror llvm / e338565
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142518 91177308-0d34-0410-b5e6-96231b3b80d8 David Greene 7 years ago
5 changed file(s) with 16 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
14721472 void addValue(const RecordVal &RV) {
14731473 assert(getValue(RV.getName()) == 0 && "Value already added!");
14741474 Values.push_back(RV);
1475 if (Values.size() > 1)
1476 // Keep NAME at the end of the list. It makes record dumps a
1477 // bit prettier and allows TableGen tests to be written more
1478 // naturally. Tests can use CHECK-NEXT to look for Record
1479 // fields they expect to see after a def. They can't do that if
1480 // NAME is the first Record field.
1481 std::swap(Values[Values.size() - 2], Values[Values.size() - 1]);
14751482 }
14761483
14771484 void removeValue(Init *Name) {
16851685
16861686 void Record::init() {
16871687 checkName();
1688
1689 // Every record potentially has a def at the top. This value is
1690 // replaced with the top-level def name at instantiation time.
1691 RecordVal DN("NAME", StringRecTy::get(), 0);
1692 addValue(DN);
16881693 }
16891694
16901695 void Record::checkName() {
17431743 Record *CurRec = Records.getClass(Lex.getCurStrVal());
17441744 if (CurRec) {
17451745 // If the body was previously defined, this is an error.
1746 if (!CurRec->getValues().empty() ||
1746 if (CurRec->getValues().size() > 1 || // Account for NAME.
17471747 !CurRec->getSuperClasses().empty() ||
17481748 !CurRec->getTemplateArgs().empty())
17491749 return TokError("Class '" + CurRec->getNameInitAsString()
5959 // CHECK-NEXT: dag Dag1 = (somedef1 1);
6060 // CHECK-NEXT: dag Dag2 = (somedef1 2);
6161 // CHECK-NEXT: dag Dag3 = (somedef1 2);
62 // CHECK-NEXT: NAME = ?
6263 // CHECK-NEXT: }
6364
6465
6768 // CHECK-NEXT: dag Dag1 = (somedef1 1);
6869 // CHECK-NEXT: dag Dag2 = (somedef2 2);
6970 // CHECK-NEXT: dag Dag3 = (somedef2 2);
71 // CHECK-NEXT: NAME = ?
7072 // CHECK-NEXT: }
0 // RUN: llvm-tblgen %s | grep {Jr} | count 2
11 // RUN: llvm-tblgen %s | grep {Sr} | count 2
2 // RUN: llvm-tblgen %s | grep {NAME} | count 1
2 // RUN: llvm-tblgen %s | grep {"NAME"} | count 1
33 // XFAIL: vg_leak
44
55 // Variables for foreach