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

Chris Lattner lattner at cs.uiuc.edu
Mon Aug 4 00:03:37 PDT 2003


Changes in directory llvm/utils/TableGen:

Record.h updated: 1.26 -> 1.27
Record.cpp updated: 1.21 -> 1.22

---
Log message:

Add new Record::getValueAsBit method


---
Diffs of the changes:

Index: llvm/utils/TableGen/Record.h
diff -u llvm/utils/TableGen/Record.h:1.26 llvm/utils/TableGen/Record.h:1.27
--- llvm/utils/TableGen/Record.h:1.26	Sun Aug  3 13:29:51 2003
+++ llvm/utils/TableGen/Record.h	Sun Aug  3 16:58:13 2003
@@ -707,6 +707,12 @@
   ///
   Record *getValueAsDef(const std::string &FieldName) const;
 
+  /// getValueAsBit - This method looks up the specified field and returns its
+  /// value as a bit, throwing an exception if the field does not exist or if
+  /// the value is not the right type.
+  ///
+  bool getValueAsBit(const std::string &FieldName) const;
+
   /// getValueAsInt - This method looks up the specified field and returns its
   /// value as an int, throwing an exception if the field does not exist or if
   /// the value is not the right type.


Index: llvm/utils/TableGen/Record.cpp
diff -u llvm/utils/TableGen/Record.cpp:1.21 llvm/utils/TableGen/Record.cpp:1.22
--- llvm/utils/TableGen/Record.cpp:1.21	Sun Aug  3 13:29:51 2003
+++ llvm/utils/TableGen/Record.cpp	Sun Aug  3 16:58:13 2003
@@ -579,6 +579,22 @@
         "' does not have a list initializer!";
 }
 
+/// getValueAsBit - This method looks up the specified field and returns its
+/// value as a bit, throwing an exception if the field does not exist or if
+/// the value is not the right type.
+///
+bool Record::getValueAsBit(const std::string &FieldName) const {
+  const RecordVal *R = getValue(FieldName);
+  if (R == 0 || R->getValue() == 0)
+    throw "Record '" + R->getName() + "' does not have a field named '" +
+      FieldName + "!\n";
+
+  if (BitInit *DI = dynamic_cast<BitInit*>(R->getValue()))
+    return DI->getValue();
+  throw "Record '" + R->getName() + "', field '" + FieldName +
+        "' does not have a list initializer!";
+}
+
 
 void RecordKeeper::dump() const { std::cerr << *this; }
 





More information about the llvm-commits mailing list