mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
enhance llvm-mc -show-inst to print the enum of an instruction, like so:
testb %al, %al ## <MCInst #2412 TEST8rr ## <MCOperand Reg:2> ## <MCOperand Reg:2>> jne LBB1_7 ## <MCInst #938 JNE_1 ## <MCOperand Expr:(LBB1_7)>> llvm-svn: 95935
This commit is contained in:
parent
144a1b7a24
commit
fcce3c5ee4
@ -25,10 +25,15 @@ using namespace llvm;
|
|||||||
|
|
||||||
// Include the auto-generated portion of the assembly writer.
|
// Include the auto-generated portion of the assembly writer.
|
||||||
#define MachineInstr MCInst
|
#define MachineInstr MCInst
|
||||||
|
#define GET_INSTRUCTION_NAME
|
||||||
#include "X86GenAsmWriter.inc"
|
#include "X86GenAsmWriter.inc"
|
||||||
#undef MachineInstr
|
#undef MachineInstr
|
||||||
|
|
||||||
void X86ATTInstPrinter::printInst(const MCInst *MI) { printInstruction(MI); }
|
void X86ATTInstPrinter::printInst(const MCInst *MI) { printInstruction(MI); }
|
||||||
|
StringRef X86ATTInstPrinter::getOpcodeName(unsigned Opcode) const {
|
||||||
|
return getInstructionName(Opcode);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void X86ATTInstPrinter::printSSECC(const MCInst *MI, unsigned Op) {
|
void X86ATTInstPrinter::printSSECC(const MCInst *MI, unsigned Op) {
|
||||||
switch (MI->getOperand(Op).getImm()) {
|
switch (MI->getOperand(Op).getImm()) {
|
||||||
|
@ -26,11 +26,12 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
virtual void printInst(const MCInst *MI);
|
virtual void printInst(const MCInst *MI);
|
||||||
|
virtual StringRef getOpcodeName(unsigned Opcode) const;
|
||||||
|
|
||||||
// Autogenerated by tblgen.
|
// Autogenerated by tblgen.
|
||||||
void printInstruction(const MCInst *MI);
|
void printInstruction(const MCInst *MI);
|
||||||
static const char *getRegisterName(unsigned RegNo);
|
static const char *getRegisterName(unsigned RegNo);
|
||||||
|
static const char *getInstructionName(unsigned Opcode);
|
||||||
|
|
||||||
void printOperand(const MCInst *MI, unsigned OpNo);
|
void printOperand(const MCInst *MI, unsigned OpNo);
|
||||||
void printMemReference(const MCInst *MI, unsigned Op);
|
void printMemReference(const MCInst *MI, unsigned Op);
|
||||||
|
@ -24,10 +24,14 @@ using namespace llvm;
|
|||||||
|
|
||||||
// Include the auto-generated portion of the assembly writer.
|
// Include the auto-generated portion of the assembly writer.
|
||||||
#define MachineInstr MCInst
|
#define MachineInstr MCInst
|
||||||
|
#define GET_INSTRUCTION_NAME
|
||||||
#include "X86GenAsmWriter1.inc"
|
#include "X86GenAsmWriter1.inc"
|
||||||
#undef MachineInstr
|
#undef MachineInstr
|
||||||
|
|
||||||
void X86IntelInstPrinter::printInst(const MCInst *MI) { printInstruction(MI); }
|
void X86IntelInstPrinter::printInst(const MCInst *MI) { printInstruction(MI); }
|
||||||
|
StringRef X86IntelInstPrinter::getOpcodeName(unsigned Opcode) const {
|
||||||
|
return getInstructionName(Opcode);
|
||||||
|
}
|
||||||
|
|
||||||
void X86IntelInstPrinter::printSSECC(const MCInst *MI, unsigned Op) {
|
void X86IntelInstPrinter::printSSECC(const MCInst *MI, unsigned Op) {
|
||||||
switch (MI->getOperand(Op).getImm()) {
|
switch (MI->getOperand(Op).getImm()) {
|
||||||
|
@ -26,10 +26,12 @@ public:
|
|||||||
: MCInstPrinter(O, MAI) {}
|
: MCInstPrinter(O, MAI) {}
|
||||||
|
|
||||||
virtual void printInst(const MCInst *MI);
|
virtual void printInst(const MCInst *MI);
|
||||||
|
virtual StringRef getOpcodeName(unsigned Opcode) const;
|
||||||
|
|
||||||
// Autogenerated by tblgen.
|
// Autogenerated by tblgen.
|
||||||
void printInstruction(const MCInst *MI);
|
void printInstruction(const MCInst *MI);
|
||||||
static const char *getRegisterName(unsigned RegNo);
|
static const char *getRegisterName(unsigned RegNo);
|
||||||
|
static const char *getInstructionName(unsigned Opcode);
|
||||||
|
|
||||||
|
|
||||||
void printOperand(const MCInst *MI, unsigned OpNo,
|
void printOperand(const MCInst *MI, unsigned OpNo,
|
||||||
|
@ -494,11 +494,55 @@ void AsmWriterEmitter::EmitGetRegisterName(raw_ostream &O) {
|
|||||||
<< "}\n";
|
<< "}\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AsmWriterEmitter::EmitGetInstructionName(raw_ostream &O) {
|
||||||
|
CodeGenTarget Target;
|
||||||
|
Record *AsmWriter = Target.getAsmWriter();
|
||||||
|
std::string ClassName = AsmWriter->getValueAsString("AsmWriterClassName");
|
||||||
|
|
||||||
|
std::vector<const CodeGenInstruction*> NumberedInstructions;
|
||||||
|
Target.getInstructionsByEnumValue(NumberedInstructions);
|
||||||
|
|
||||||
|
StringToOffsetTable StringTable;
|
||||||
|
O <<
|
||||||
|
"\n\n#ifdef GET_INSTRUCTION_NAME\n"
|
||||||
|
"#undef GET_INSTRUCTION_NAME\n\n"
|
||||||
|
"/// getInstructionName: This method is automatically generated by tblgen\n"
|
||||||
|
"/// from the instruction set description. This returns the enum name of the\n"
|
||||||
|
"/// specified instruction.\n"
|
||||||
|
"const char *" << Target.getName() << ClassName
|
||||||
|
<< "::getInstructionName(unsigned Opcode) {\n"
|
||||||
|
<< " assert(Opcode < " << NumberedInstructions.size()
|
||||||
|
<< " && \"Invalid instruction number!\");\n"
|
||||||
|
<< "\n"
|
||||||
|
<< " static const unsigned InstAsmOffset[] = {";
|
||||||
|
for (unsigned i = 0, e = NumberedInstructions.size(); i != e; ++i) {
|
||||||
|
const CodeGenInstruction &Inst = *NumberedInstructions[i];
|
||||||
|
|
||||||
|
std::string AsmName = Inst.TheDef->getName();
|
||||||
|
if ((i % 14) == 0)
|
||||||
|
O << "\n ";
|
||||||
|
|
||||||
|
O << StringTable.GetOrAddStringOffset(AsmName) << ", ";
|
||||||
|
}
|
||||||
|
O << "0\n"
|
||||||
|
<< " };\n"
|
||||||
|
<< "\n";
|
||||||
|
|
||||||
|
O << " const char *Strs =\n";
|
||||||
|
StringTable.EmitString(O);
|
||||||
|
O << ";\n";
|
||||||
|
|
||||||
|
O << " return Strs+InstAsmOffset[Opcode];\n"
|
||||||
|
<< "}\n\n#endif\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void AsmWriterEmitter::run(raw_ostream &O) {
|
void AsmWriterEmitter::run(raw_ostream &O) {
|
||||||
EmitSourceFileHeader("Assembly Writer Source Fragment", O);
|
EmitSourceFileHeader("Assembly Writer Source Fragment", O);
|
||||||
|
|
||||||
EmitPrintInstruction(O);
|
EmitPrintInstruction(O);
|
||||||
EmitGetRegisterName(O);
|
EmitGetRegisterName(O);
|
||||||
|
EmitGetInstructionName(O);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ namespace llvm {
|
|||||||
private:
|
private:
|
||||||
void EmitPrintInstruction(raw_ostream &o);
|
void EmitPrintInstruction(raw_ostream &o);
|
||||||
void EmitGetRegisterName(raw_ostream &o);
|
void EmitGetRegisterName(raw_ostream &o);
|
||||||
|
void EmitGetInstructionName(raw_ostream &o);
|
||||||
|
|
||||||
AsmWriterInst *getAsmWriterInstByID(unsigned ID) const {
|
AsmWriterInst *getAsmWriterInstByID(unsigned ID) const {
|
||||||
assert(ID < NumberedInstructions.size());
|
assert(ID < NumberedInstructions.size());
|
||||||
|
Loading…
Reference in New Issue
Block a user