[llvm-commits] [llvm] r142496 - in /llvm/trunk: include/llvm/TableGen/Record.h lib/TableGen/Record.cpp
David Greene
greened at obbligato.org
Wed Oct 19 06:02:30 PDT 2011
Author: greened
Date: Wed Oct 19 08:02:29 2011
New Revision: 142496
URL: http://llvm.org/viewvc/llvm-project?rev=142496&view=rev
Log:
Add Value Accessors
Add accessors to get Record values by Init name. This lets us look up
Record values whose names are not yet fully resolved. More work
toward paste.
Modified:
llvm/trunk/include/llvm/TableGen/Record.h
llvm/trunk/lib/TableGen/Record.cpp
Modified: llvm/trunk/include/llvm/TableGen/Record.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/TableGen/Record.h?rev=142496&r1=142495&r2=142496&view=diff
==============================================================================
--- llvm/trunk/include/llvm/TableGen/Record.h (original)
+++ llvm/trunk/include/llvm/TableGen/Record.h Wed Oct 19 08:02:29 2011
@@ -1442,6 +1442,9 @@
return 0;
}
+ const RecordVal *getValue(Init *Name) const;
+ RecordVal *getValue(Init *Name);
+
void addTemplateArg(StringRef Name) {
assert(!isTemplateArg(Name) && "Template arg already defined!");
TemplateArgs.push_back(Name);
@@ -1452,15 +1455,19 @@
Values.push_back(RV);
}
- void removeValue(StringRef Name) {
+ void removeValue(Init *Name) {
for (unsigned i = 0, e = Values.size(); i != e; ++i)
- if (Values[i].getName() == Name) {
+ if (Values[i].getNameInit() == Name) {
Values.erase(Values.begin()+i);
return;
}
assert(0 && "Cannot remove an entry that does not exist!");
}
+ void removeValue(StringRef Name) {
+ removeValue(StringInit::get(Name.str()));
+ }
+
bool isSubClassOf(const Record *R) const {
for (unsigned i = 0, e = SuperClasses.size(); i != e; ++i)
if (SuperClasses[i] == R)
Modified: llvm/trunk/lib/TableGen/Record.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/Record.cpp?rev=142496&r1=142495&r2=142496&view=diff
==============================================================================
--- llvm/trunk/lib/TableGen/Record.cpp (original)
+++ llvm/trunk/lib/TableGen/Record.cpp Wed Oct 19 08:02:29 2011
@@ -1726,6 +1726,18 @@
setName(StringInit::get(Name));
}
+const RecordVal *Record::getValue(Init *Name) const {
+ for (unsigned i = 0, e = Values.size(); i != e; ++i)
+ if (Values[i].getNameInit() == Name) return &Values[i];
+ return 0;
+}
+
+RecordVal *Record::getValue(Init *Name) {
+ for (unsigned i = 0, e = Values.size(); i != e; ++i)
+ if (Values[i].getNameInit() == Name) return &Values[i];
+ return 0;
+}
+
/// resolveReferencesTo - If anything in this record refers to RV, replace the
/// reference to RV with the RHS of RV. If RV is null, we resolve all possible
/// references.
More information about the llvm-commits
mailing list