First steps to getting PredicateOperand's to work. This handles instruction
[oota-llvm.git] / utils / TableGen / FileParser.y
index 0f0c4689e86d2303992d54f32d10e6e2bbde3434..8e564564bdef4e6a8240bd07b491bb774319afbb 100644 (file)
@@ -90,7 +90,8 @@ static void setValue(const std::string &ValName,
                      std::vector<unsigned> *BitList, Init *V) {
   if (!V) return;
 
-  RecordVal *RV = CurRec->getValue(ValName);
+  Record *TheRec = getActiveRec();
+  RecordVal *RV = TheRec->getValue(ValName);
   if (RV == 0) {
     err() << "Value '" << ValName << "' unknown!\n";
     exit(1);
@@ -623,9 +624,9 @@ ObjectBody : ClassList {
              // Delete the template arg values for the class
              delete (*$1)[i].second;
            }
-           delete $1;   // Delete the class list...
+           delete $1;   // Delete the class list.
   
-           // Process any variables on the set stack...
+           // Process any variables on the let stack.
            for (unsigned i = 0, e = LetStack.size(); i != e; ++i)
              for (unsigned j = 0, e = LetStack[i].size(); j != e; ++j)
                setValue(LetStack[i][j].Name,
@@ -742,6 +743,14 @@ DefMInst : DEFM ID { CurDefmPrefix = $2; } ':' SubClassRef ';' {
       }
     }
     
+    // If the mdef is inside a 'let' expression, add to each def.
+    for (unsigned i = 0, e = LetStack.size(); i != e; ++i)
+      for (unsigned j = 0, e = LetStack[i].size(); j != e; ++j)
+        setValue(LetStack[i][j].Name,
+                 LetStack[i][j].HasBits ? &LetStack[i][j].Bits : 0,
+                 LetStack[i][j].Value);
+    
+    
     // Ensure redefinition doesn't happen.
     if (Records.getDef(CurRec->getName())) {
       err() << "def '" << CurRec->getName() << "' already defined, "
@@ -758,6 +767,7 @@ DefMInst : DEFM ID { CurDefmPrefix = $2; } ':' SubClassRef ';' {
   
   delete &TemplateVals;
   delete $2;
+  CurDefmPrefix = 0;
 };
 
 Object : ClassInst {} | DefInst {};