diff options
author | Jim Grosbach <grosbach@apple.com> | 2010-11-03 23:38:14 +0000 |
---|---|---|
committer | Jim Grosbach <grosbach@apple.com> | 2010-11-03 23:38:14 +0000 |
commit | e4e6bf49f300dc3d122dea7caac21d7236b5d3e4 (patch) | |
tree | 3c9759258e0e6bdf4ae91e0f3dd6eb47233f298f /llvm/utils/TableGen/CodeEmitterGen.cpp | |
parent | 147e1cbb4914b767192439ca8431b6bd603fad69 (diff) | |
download | bcm5719-llvm-e4e6bf49f300dc3d122dea7caac21d7236b5d3e4.tar.gz bcm5719-llvm-e4e6bf49f300dc3d122dea7caac21d7236b5d3e4.zip |
Support generating an MC'ized CodeEmitter directly. Maintain a reference to the
Fixups list for the instruction so the operand encoders can add to it as
needed.
llvm-svn: 118206
Diffstat (limited to 'llvm/utils/TableGen/CodeEmitterGen.cpp')
-rw-r--r-- | llvm/utils/TableGen/CodeEmitterGen.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/llvm/utils/TableGen/CodeEmitterGen.cpp b/llvm/utils/TableGen/CodeEmitterGen.cpp index fbe9947b096..e86c18fb663 100644 --- a/llvm/utils/TableGen/CodeEmitterGen.cpp +++ b/llvm/utils/TableGen/CodeEmitterGen.cpp @@ -21,8 +21,11 @@ #include "llvm/Support/Debug.h" using namespace llvm; +// FIXME: Somewhat hackish to use a command line option for this. There should +// be a CodeEmitter class in the Target.td that controls this sort of thing +// instead. static cl::opt<bool> -MCEmitter("mc-code-emitter", +MCEmitter("mc-emitter", cl::desc("Generate CodeEmitter for use with the MC library."), cl::init(false)); @@ -84,8 +87,12 @@ void CodeEmitterGen::run(raw_ostream &o) { Target.getInstructionsByEnumValue(); // Emit function declaration - o << "unsigned " << Target.getName() << "CodeEmitter::" - << "getBinaryCodeForInstr(const MachineInstr &MI) const {\n"; + o << "unsigned " << Target.getName(); + if (MCEmitter) + o << "MCCodeEmitter::getBinaryCodeForInstr(const MCInst &MI,\n" + << " SmallVectorImpl<MCFixup> &Fixups) const {\n"; + else + o << "CodeEmitter::getBinaryCodeForInstr(const MachineInstr &MI) const {\n"; // Emit instruction base values o << " static const unsigned InstBits[] = {\n"; @@ -188,12 +195,18 @@ void CodeEmitterGen::run(raw_ostream &o) { if (SO.second == 0) { Case += " // op: " + VarName + "\n" + " op = " + EncoderMethodName + "(MI, " - + utostr(OpIdx) + ");\n"; + + utostr(OpIdx); + if (MCEmitter) + Case += ", Fixups"; + Case += ");\n"; } } else { Case += " // op: " + VarName + "\n" + " op = getMachineOpValue(MI, MI.getOperand(" - + utostr(OpIdx) + "));\n"; + + utostr(OpIdx) + ")"; + if (MCEmitter) + Case += ", Fixups"; + Case += ");\n"; } gotOp = true; } |