X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=utils%2FTableGen%2FCodeEmitterGen.cpp;h=300a1009a735bed0270527f80fa764c04edbfdb4;hb=c419bd3396cc035942b219efae30dd2890ae430f;hp=3dcaea43007b279fd7b817b2a5ff3616ab1034f2;hpb=8aa01f4b435b8e6871f63887cd2ee00b7530ee9c;p=oota-llvm.git diff --git a/utils/TableGen/CodeEmitterGen.cpp b/utils/TableGen/CodeEmitterGen.cpp index 3dcaea43007..300a1009a73 100644 --- a/utils/TableGen/CodeEmitterGen.cpp +++ b/utils/TableGen/CodeEmitterGen.cpp @@ -24,7 +24,9 @@ void CodeEmitterGen::reverseBits(std::vector &Insts) { for (std::vector::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 &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(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 &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 &InstList = CaseMap[Case]; + std::vector &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"