X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=utils%2FTableGen%2FCodeEmitterGen.cpp;h=557a8f4df9abfffb2d583f0ba7c232332b4b44e6;hb=7b2e579546d1ebf49c2e187efab2c76be9e32050;hp=24235381b951a3d455941474ae5cb950b41245bd;hpb=f1b05bf755c3a083944f03fbf6a83892bc051065;p=oota-llvm.git diff --git a/utils/TableGen/CodeEmitterGen.cpp b/utils/TableGen/CodeEmitterGen.cpp index 24235381b95..557a8f4df9a 100644 --- a/utils/TableGen/CodeEmitterGen.cpp +++ b/utils/TableGen/CodeEmitterGen.cpp @@ -2,8 +2,8 @@ // // The LLVM Compiler Infrastructure // -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // @@ -24,7 +24,16 @@ 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() == "DBG_LABEL" || + R->getName() == "EH_LABEL" || + R->getName() == "GC_LABEL" || + R->getName() == "DECLARE" || + R->getName() == "EXTRACT_SUBREG" || + R->getName() == "INSERT_SUBREG" || + R->getName() == "IMPLICIT_DEF" || + R->getName() == "SUBREG_TO_REG") continue; BitsInit *BI = R->getValueAsBitsInit("Inst"); @@ -49,7 +58,10 @@ void CodeEmitterGen::reverseBits(std::vector &Insts) { } -int CodeEmitterGen::getVariableBit(const std::string &VarName, BitsInit *BI, int bit){ +// If the VarBitInit at position 'bit' matches the specified variable then +// return the variable bit position. Otherwise return -1. +int CodeEmitterGen::getVariableBit(const std::string &VarName, + BitsInit *BI, int bit) { if (VarBitInit *VBI = dynamic_cast(BI->getBit(bit))) { TypedInit *TI = VBI->getVariable(); @@ -90,17 +102,24 @@ 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() == "DBG_LABEL" || + R->getName() == "EH_LABEL" || + R->getName() == "GC_LABEL" || + R->getName() == "DECLARE" || + R->getName() == "EXTRACT_SUBREG" || + R->getName() == "INSERT_SUBREG" || + R->getName() == "IMPLICIT_DEF" || + R->getName() == "SUBREG_TO_REG") { 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); @@ -120,11 +139,21 @@ 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 == "DBG_LABEL"|| + InstName == "EH_LABEL"|| + InstName == "GC_LABEL"|| + InstName == "DECLARE"|| + InstName == "EXTRACT_SUBREG" || + InstName == "INSERT_SUBREG" || + InstName == "IMPLICIT_DEF" || + InstName == "SUBREG_TO_REG") 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; @@ -153,10 +182,14 @@ 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; } @@ -179,7 +212,7 @@ void CodeEmitterGen::run(std::ostream &o) { } } - std::vector &InstList = CaseMap[Case]; + std::vector &InstList = CaseMap[Case]; InstList.push_back(InstName); } @@ -208,7 +241,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"