[llvm-commits] CVS: llvm/utils/TableGen/Record.cpp Record.h

Chris Lattner lattner at cs.uiuc.edu
Fri Aug 19 10:58:23 PDT 2005



Changes in directory llvm/utils/TableGen:

Record.cpp updated: 1.43 -> 1.44
Record.h updated: 1.49 -> 1.50
---
Log message:

Add a setName method to Record.


---
Diffs of the changes:  (+26 -0)

 Record.cpp |   12 ++++++++++++
 Record.h   |   14 ++++++++++++++
 2 files changed, 26 insertions(+)


Index: llvm/utils/TableGen/Record.cpp
diff -u llvm/utils/TableGen/Record.cpp:1.43 llvm/utils/TableGen/Record.cpp:1.44
--- llvm/utils/TableGen/Record.cpp:1.43	Thu Apr 21 23:13:13 2005
+++ llvm/utils/TableGen/Record.cpp	Fri Aug 19 12:58:11 2005
@@ -589,6 +589,18 @@
   if (PrintSem) OS << ";\n";
 }
 
+void Record::setName(const std::string &Name) {
+  if (Records.getDef(getName()) == this) {
+    Records.removeDef(getName());
+    this->Name = Name;
+    Records.addDef(this);
+  } else {
+    Records.removeClass(getName());
+    this->Name = Name;
+    Records.addClass(this);
+  }
+}
+
 /// 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.


Index: llvm/utils/TableGen/Record.h
diff -u llvm/utils/TableGen/Record.h:1.49 llvm/utils/TableGen/Record.h:1.50
--- llvm/utils/TableGen/Record.h:1.49	Thu Apr 21 23:13:13 2005
+++ llvm/utils/TableGen/Record.h	Fri Aug 19 12:58:11 2005
@@ -898,6 +898,7 @@
   ~Record() {}
 
   const std::string &getName() const { return Name; }
+  void setName(const std::string &Name);  // Also updates RecordKeeper.
   const std::vector<std::string> &getTemplateArgs() const {
     return TemplateArgs;
   }
@@ -1058,6 +1059,19 @@
     Defs.insert(std::make_pair(R->getName(), R));
   }
 
+  /// removeClass - Remove, but do not delete, the specified record.
+  ///
+  void removeClass(const std::string &Name) {
+    assert(Classes.count(Name) && "Class does not exist!");
+    Classes.erase(Name);
+  }
+  /// removeDef - Remove, but do not delete, the specified record.
+  ///
+  void removeDef(const std::string &Name) {
+    assert(Defs.count(Name) && "Def does not exist!");
+    Defs.erase(Name);
+  }
+  
   //===--------------------------------------------------------------------===//
   // High-level helper methods, useful for tablegen backends...
 






More information about the llvm-commits mailing list