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

Chris Lattner lattner at cs.uiuc.edu
Thu Aug 7 01:01:01 PDT 2003


Changes in directory llvm/utils/TableGen:

Record.cpp updated: 1.26 -> 1.27
Record.h updated: 1.32 -> 1.33

---
Log message:

Add new method getVAlueAsDag


---
Diffs of the changes:

Index: llvm/utils/TableGen/Record.cpp
diff -u llvm/utils/TableGen/Record.cpp:1.26 llvm/utils/TableGen/Record.cpp:1.27
--- llvm/utils/TableGen/Record.cpp:1.26	Wed Aug  6 17:29:04 2003
+++ llvm/utils/TableGen/Record.cpp	Thu Aug  7 01:00:43 2003
@@ -613,10 +613,26 @@
     throw "Record '" + getName() + "' does not have a field named '" +
       FieldName + "!\n";
 
-  if (BitInit *DI = dynamic_cast<BitInit*>(R->getValue()))
-    return DI->getValue();
+  if (BitInit *BI = dynamic_cast<BitInit*>(R->getValue()))
+    return BI->getValue();
   throw "Record '" + getName() + "', field '" + FieldName +
-        "' does not have a list initializer!";
+        "' does not have a bit initializer!";
+}
+
+/// getValueAsDag - This method looks up the specified field and returns its
+/// value as an Dag, throwing an exception if the field does not exist or if
+/// the value is not the right type.
+///
+DagInit *Record::getValueAsDag(const std::string &FieldName) const {
+  const RecordVal *R = getValue(FieldName);
+  if (R == 0 || R->getValue() == 0)
+    throw "Record '" + getName() + "' does not have a field named '" +
+      FieldName + "!\n";
+
+  if (DagInit *DI = dynamic_cast<DagInit*>(R->getValue()))
+    return DI;
+  throw "Record '" + getName() + "', field '" + FieldName +
+        "' does not have a dag initializer!";
 }
 
 


Index: llvm/utils/TableGen/Record.h
diff -u llvm/utils/TableGen/Record.h:1.32 llvm/utils/TableGen/Record.h:1.33
--- llvm/utils/TableGen/Record.h:1.32	Wed Aug  6 18:01:18 2003
+++ llvm/utils/TableGen/Record.h	Thu Aug  7 01:00:43 2003
@@ -759,6 +759,12 @@
   /// the value is not the right type.
   ///
   int getValueAsInt(const std::string &FieldName) const;
+
+  /// getValueAsDag - This method looks up the specified field and returns its
+  /// value as an Dag, throwing an exception if the field does not exist or if
+  /// the value is not the right type.
+  ///
+  DagInit *getValueAsDag(const std::string &FieldName) const;
 };
 
 std::ostream &operator<<(std::ostream &OS, const Record &R);





More information about the llvm-commits mailing list