ImmutablePredicateOperand is no more.
[oota-llvm.git] / utils / TableGen / CodeEmitterGen.cpp
index 3dcaea43007b279fd7b817b2a5ff3616ab1034f2..300a1009a735bed0270527f80fa764c04edbfdb4 100644 (file)
@@ -24,7 +24,9 @@ void CodeEmitterGen::reverseBits(std::vector<Record*> &Insts) {
   for (std::vector<Record*>::iterator I = Insts.begin(), E = Insts.end();
        I != E; ++I) {
     Record *R = *I;
-    if (R->getName() == "PHI" || R->getName() == "INLINEASM") continue;
+    if (R->getName() == "PHI" ||
+        R->getName() == "INLINEASM" ||
+        R->getName() == "LABEL") continue;
     
     BitsInit *BI = R->getValueAsBitsInit("Inst");
 
@@ -93,17 +95,17 @@ void CodeEmitterGen::run(std::ostream &o) {
     
     if (IN != NumberedInstructions.begin()) o << ",\n";
     
-    if (R->getName() == "PHI" || R->getName() == "INLINEASM") {
+    if (R->getName() == "PHI" ||
+        R->getName() == "INLINEASM" ||
+        R->getName() == "LABEL") {
       o << "    0U";
       continue;
     }
     
     BitsInit *BI = R->getValueAsBitsInit("Inst");
 
-    unsigned Value = 0;
-    const std::vector<RecordVal> &Vals = R->getValues();
-
     // Start by filling in fixed values...
+    unsigned Value = 0;
     for (unsigned i = 0, e = BI->getNumBits(); i != e; ++i) {
       if (BitInit *B = dynamic_cast<BitInit*>(BI->getBit(e-i-1))) {
         Value |= B->getValue() << (e-i-1);
@@ -123,11 +125,14 @@ void CodeEmitterGen::run(std::ostream &o) {
     const std::string &InstName = R->getName();
     std::string Case("");
     
-    if (InstName == "PHI" || InstName == "INLINEASM") continue;
+    if (InstName == "PHI" ||
+        InstName == "INLINEASM" ||
+        InstName == "LABEL") continue;
     
     BitsInit *BI = R->getValueAsBitsInit("Inst");
     const std::vector<RecordVal> &Vals = R->getValues();
-
+    CodeGenInstruction &CGI = Target.getInstruction(InstName);
+    
     // Loop over all of the fields in the instruction, determining which are the
     // operands to the instruction.
     unsigned op = 0;
@@ -156,16 +161,15 @@ void CodeEmitterGen::run(std::ostream &o) {
             }
 
             if (!gotOp) {
+              /// If this operand is not supposed to be emitted by the generated
+              /// emitter, skip it.
+              while (CGI.isFlatOperandNotEmitted(op))
+                ++op;
+              
               Case += "      // op: " + VarName + "\n"
                    +  "      op = getMachineOpValue(MI, MI.getOperand("
-                   +  utostr(op++)
-                   +  "));\n";
+                   +  utostr(op++) + "));\n";
               gotOp = true;
-              
-              // If this is a two-address instruction and we just got the dest
-              // op, skip the src op.
-              if (op == 1 && Target.getInstruction(InstName).isTwoAddress)
-                ++op;
             }
             
             unsigned opMask = (1 << N) - 1;
@@ -187,7 +191,7 @@ void CodeEmitterGen::run(std::ostream &o) {
       }
     }
 
-    std::vector<std::string> &InstList =  CaseMap[Case];
+    std::vector<std::string> &InstList = CaseMap[Case];
     InstList.push_back(InstName);
   }
 
@@ -216,7 +220,7 @@ void CodeEmitterGen::run(std::ostream &o) {
 
   // Default case: unhandled opcode
   o << "  default:\n"
-    << "    std::cerr << \"Not supported instr: \" << MI << \"\\n\";\n"
+    << "    cerr << \"Not supported instr: \" << MI << \"\\n\";\n"
     << "    abort();\n"
     << "  }\n"
     << "  return Value;\n"