X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;ds=sidebyside;f=utils%2FTableGen%2FCodeEmitterGen.cpp;h=40065bf009cec59f9dd525ca8914f0348da63ff8;hb=eb178c146a0f56cca8421eda9fb6ed2a8c73a2b4;hp=6cf18c2ded9e37b091ce2338616d047dd95ba645;hpb=2082ebe8b3a5db302748828ab4f79a36d239c1d9;p=oota-llvm.git diff --git a/utils/TableGen/CodeEmitterGen.cpp b/utils/TableGen/CodeEmitterGen.cpp index 6cf18c2ded9..40065bf009c 100644 --- a/utils/TableGen/CodeEmitterGen.cpp +++ b/utils/TableGen/CodeEmitterGen.cpp @@ -7,7 +7,9 @@ // //===----------------------------------------------------------------------===// // -// FIXME: Document. +// CodeEmitterGen uses the descriptions of instructions and their fields to +// construct an automated code emitter: a function that, given a MachineInstr, +// returns the (currently, 32-bit unsigned) value of the instruction. // //===----------------------------------------------------------------------===// @@ -21,8 +23,9 @@ void CodeEmitterGen::run(std::ostream &o) { EmitSourceFileHeader("Machine Code Emitter", o); - std::string Namespace = "V9::"; - std::string ClassName = "SparcV9CodeEmitter::"; + std::string Namespace = Insts[0]->getValueAsString("Namespace") + "::"; + std::string ClassName = Insts[0]->getValueAsString("ClassPrefix") + + "CodeEmitter::"; //const std::string &Namespace = Inst->getValue("Namespace")->getName(); o << "unsigned " << ClassName @@ -152,7 +155,7 @@ void CodeEmitterGen::run(std::ostream &o) { << " &= (1<<" << beginBitInVar+1 << ") - 1;\n"; // Shift the value to the correct place (according to place in inst) - assert(endBitInInst >= 0 && "Negative shift amount in inst position!"); + assert(endBitInInst >= 0 && "Negative shift amount!"); if (endBitInInst != 0) o << " op" << OpOrder[Vals[i].getName()] << " <<= " << endBitInInst << ";\n"; @@ -175,14 +178,12 @@ void CodeEmitterGen::run(std::ostream &o) { // Scan through the field looking for bit initializers of the current // variable... for (int i = FieldInitializer->getNumBits()-1; i >= 0; --i) { - if (BitInit *BI = dynamic_cast(FieldInitializer->getBit(i))) - { + Init *I = FieldInitializer->getBit(i); + if (BitInit *BI = dynamic_cast(I)) { DEBUG(o << " // bit init: f: " << f << ", i: " << i << "\n"); - } else if (UnsetInit *UI = - dynamic_cast(FieldInitializer->getBit(i))) { + } else if (UnsetInit *UI = dynamic_cast(I)) { DEBUG(o << " // unset init: f: " << f << ", i: " << i << "\n"); - } else if (VarBitInit *VBI = - dynamic_cast(FieldInitializer->getBit(i))) { + } else if (VarBitInit *VBI = dynamic_cast(I)) { TypedInit *TI = VBI->getVariable(); if (VarInit *VI = dynamic_cast(TI)) { // If the bits of the field are laid out consecutively in the