summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/TableGen/Record.h11
-rw-r--r--llvm/lib/TableGen/Record.cpp12
2 files changed, 21 insertions, 2 deletions
diff --git a/llvm/include/llvm/TableGen/Record.h b/llvm/include/llvm/TableGen/Record.h
index 22e761f44ae..4502aa72a73 100644
--- a/llvm/include/llvm/TableGen/Record.h
+++ b/llvm/include/llvm/TableGen/Record.h
@@ -1442,6 +1442,9 @@ public:
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 @@ public:
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)
diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp
index b7c51cae953..06a41c9eb26 100644
--- a/llvm/lib/TableGen/Record.cpp
+++ b/llvm/lib/TableGen/Record.cpp
@@ -1726,6 +1726,18 @@ void Record::setName(const std::string &Name) {
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.
OpenPOWER on IntegriCloud