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

Chris Lattner lattner at cs.uiuc.edu
Fri Aug 1 01:00:02 PDT 2003


Changes in directory llvm/utils/TableGen:

Record.h updated: 1.20 -> 1.21
Record.cpp updated: 1.14 -> 1.15

---
Log message:

Fix the way field bit references are resolved, also allow resolution of field references overall!


---
Diffs of the changes:

Index: llvm/utils/TableGen/Record.h
diff -u llvm/utils/TableGen/Record.h:1.20 llvm/utils/TableGen/Record.h:1.21
--- llvm/utils/TableGen/Record.h:1.20	Thu Jul 31 23:46:24 2003
+++ llvm/utils/TableGen/Record.h	Fri Aug  1 00:58:58 2003
@@ -480,6 +480,8 @@
 
   virtual Init *resolveBitReference(Record &R, unsigned Bit);
 
+  virtual Init *resolveReferences(Record &R);
+
   virtual void print(std::ostream &OS) const {
     Rec->print(OS); OS << "." << FieldName;
   }


Index: llvm/utils/TableGen/Record.cpp
diff -u llvm/utils/TableGen/Record.cpp:1.14 llvm/utils/TableGen/Record.cpp:1.15
--- llvm/utils/TableGen/Record.cpp:1.14	Thu Jul 31 23:46:24 2003
+++ llvm/utils/TableGen/Record.cpp	Fri Aug  1 00:58:58 2003
@@ -316,7 +316,7 @@
       if (Init *I = RV->getValue()->getFieldInit(R, FieldName))
         return I;
       else
-        return (Init*)this;
+        return 0;
   return 0;
 }
 
@@ -373,14 +373,22 @@
 
 Init *FieldInit::resolveBitReference(Record &R, unsigned Bit) {
   Init *BitsVal = Rec->getFieldInit(R, FieldName);
-  assert(BitsVal && "No initializer found!");
+  if (BitsVal)
+    if (BitsInit *BI = dynamic_cast<BitsInit*>(BitsVal)) {
+      assert(Bit < BI->getNumBits() && "Bit reference out of range!");
+      Init *B = BI->getBit(Bit);
+      
+      if (dynamic_cast<BitInit*>(B))  // If the bit is set...
+        return B;                     // Replace the VarBitInit with it.
+    }
+  return this;
+}
 
-  if (BitsInit *BI = dynamic_cast<BitsInit*>(BitsVal)) {
-    assert(Bit < BI->getNumBits() && "Bit reference out of range!");
-    Init *B = BI->getBit(Bit);
-    
-    if (dynamic_cast<BitInit*>(B))  // If the bit is set...
-      return B;                     // Replace the VarBitInit with it.
+Init *FieldInit::resolveReferences(Record &R) {
+  Init *BitsVal = Rec->getFieldInit(R, FieldName);
+  if (BitsVal) {
+    Init *BVR = BitsVal->resolveReferences(R);
+    return BVR->isComplete() ? BVR : this;
   }
   return this;
 }





More information about the llvm-commits mailing list