Remove getInstructionName from MCInstPrinter implementations in favor of using the...
authorCraig Topper <craig.topper@gmail.com>
Mon, 2 Apr 2012 07:01:04 +0000 (07:01 +0000)
committerCraig Topper <craig.topper@gmail.com>
Mon, 2 Apr 2012 07:01:04 +0000 (07:01 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153863 91177308-0d34-0410-b5e6-96231b3b80d8

15 files changed:
lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp
lib/Target/ARM/InstPrinter/ARMInstPrinter.h
lib/Target/MBlaze/InstPrinter/MBlazeInstPrinter.h
lib/Target/Mips/InstPrinter/MipsInstPrinter.cpp
lib/Target/Mips/InstPrinter/MipsInstPrinter.h
lib/Target/PTX/InstPrinter/PTXInstPrinter.cpp
lib/Target/PTX/InstPrinter/PTXInstPrinter.h
lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp
lib/Target/PowerPC/InstPrinter/PPCInstPrinter.h
lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp
lib/Target/X86/InstPrinter/X86ATTInstPrinter.h
lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp
lib/Target/X86/InstPrinter/X86IntelInstPrinter.h
utils/TableGen/AsmWriterEmitter.cpp
utils/TableGen/AsmWriterEmitter.h

index 22ddc7ed18f6e4a78380b3cce7c5594b38bc2ee8..b654a75a2ebf1f0c8ef53f72f8f1ede8c766190e 100644 (file)
 #include "llvm/MC/MCInst.h"
 #include "llvm/MC/MCAsmInfo.h"
 #include "llvm/MC/MCExpr.h"
+#include "llvm/MC/MCInstrInfo.h"
 #include "llvm/MC/MCRegisterInfo.h"
 #include "llvm/Support/raw_ostream.h"
 using namespace llvm;
 
-#define GET_INSTRUCTION_NAME
 #include "ARMGenAsmWriter.inc"
 
 /// translateShiftImm - Convert shift immediate from 0-31 to 1-32 for printing.
@@ -45,7 +45,7 @@ ARMInstPrinter::ARMInstPrinter(const MCAsmInfo &MAI,
 }
 
 StringRef ARMInstPrinter::getOpcodeName(unsigned Opcode) const {
-  return getInstructionName(Opcode);
+  return MII.getName(Opcode);
 }
 
 void ARMInstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const {
index b2bc202fb7b1baa7a5a1941ea604244c9093bdab..d103ca4232c98d6eed50135573f80b6ca181c671 100644 (file)
@@ -30,8 +30,6 @@ public:
   virtual StringRef getOpcodeName(unsigned Opcode) const;
   virtual void printRegName(raw_ostream &OS, unsigned RegNo) const;
 
-  static const char *getInstructionName(unsigned Opcode);
-
   // Autogenerated by tblgen.
   void printInstruction(const MCInst *MI, raw_ostream &O);
   static const char *getRegisterName(unsigned RegNo);
index e34e4b3a8fe1aacd0f4148ed1edd3c1a267d2a0d..51ba7c359a1bd65218ef5d07d9efcbd0197c3d1e 100644 (file)
@@ -30,7 +30,6 @@ namespace llvm {
     // Autogenerated by tblgen.
     void printInstruction(const MCInst *MI, raw_ostream &O);
     static const char *getRegisterName(unsigned RegNo);
-    static const char *getInstructionName(unsigned Opcode);
 
     void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O,
                       const char *Modifier = 0);
index 2917a89a2261976f975678550052f23f8e3df3bf..679082274262635b9503fc22406fa149e09d0128 100644 (file)
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/MC/MCExpr.h"
 #include "llvm/MC/MCInst.h"
+#include "llvm/MC/MCInstrInfo.h"
 #include "llvm/MC/MCSymbol.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/raw_ostream.h"
 using namespace llvm;
 
-#define GET_INSTRUCTION_NAME
 #include "MipsGenAsmWriter.inc"
 
 const char* Mips::MipsFCCToString(Mips::CondCode CC) {
@@ -63,7 +63,7 @@ const char* Mips::MipsFCCToString(Mips::CondCode CC) {
 }
 
 StringRef MipsInstPrinter::getOpcodeName(unsigned Opcode) const {
-  return getInstructionName(Opcode);
+  return MII.getName(Opcode);
 }
 
 void MipsInstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const {
index 39d15dcd5266639e393ccdacc60f3ad685667766..8e614740eb358ed96c27ab8f2149225c1b9cfde5 100644 (file)
@@ -83,7 +83,6 @@ public:
 
   // Autogenerated by tblgen.
   void printInstruction(const MCInst *MI, raw_ostream &O);
-  static const char *getInstructionName(unsigned Opcode);
   static const char *getRegisterName(unsigned RegNo);
 
   virtual StringRef getOpcodeName(unsigned Opcode) const;
index 1f6fc684545f96bce7b6186353e30ff0aed0b96d..3aa3b26bf887d63fc472e6a60bffbacf18d8107f 100644 (file)
 #include "llvm/MC/MCExpr.h"
 #include "llvm/MC/MCInst.h"
 #include "llvm/MC/MCSymbol.h"
+#include "llvm/MC/MCInstrInfo.h"
 #include "llvm/ADT/APFloat.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/raw_ostream.h"
 using namespace llvm;
 
-#define GET_INSTRUCTION_NAME
 #include "PTXGenAsmWriter.inc"
 
 PTXInstPrinter::PTXInstPrinter(const MCAsmInfo &MAI,
@@ -37,7 +37,7 @@ PTXInstPrinter::PTXInstPrinter(const MCAsmInfo &MAI,
 }
 
 StringRef PTXInstPrinter::getOpcodeName(unsigned Opcode) const {
-  return getInstructionName(Opcode);
+  return MII.getName(Opcode);
 }
 
 void PTXInstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const {
index e89a8fe65113fe92383415768457c28239e989e5..b01293a99535e00d5967ce9e38fa423599d063be 100644 (file)
@@ -30,8 +30,6 @@ public:
   virtual StringRef getOpcodeName(unsigned Opcode) const;
   virtual void printRegName(raw_ostream &OS, unsigned RegNo) const;
 
-  static const char *getInstructionName(unsigned Opcode);
-
   // Autogenerated by tblgen.
   void printInstruction(const MCInst *MI, raw_ostream &O);
   static const char *getRegisterName(unsigned RegNo);
index 000d6d412ec7b5f95a63a1b7760b3615b3706226..6e85ab926cdb93537d2caa9641775f51c63d9499 100644 (file)
 #include "MCTargetDesc/PPCPredicates.h"
 #include "llvm/MC/MCExpr.h"
 #include "llvm/MC/MCInst.h"
+#include "llvm/MC/MCInstrInfo.h"
 #include "llvm/Support/raw_ostream.h"
 using namespace llvm;
 
-#define GET_INSTRUCTION_NAME
 #include "PPCGenAsmWriter.inc"
 
 StringRef PPCInstPrinter::getOpcodeName(unsigned Opcode) const {
-  return getInstructionName(Opcode);
+  return MII.getName(Opcode);
 }
 
 void PPCInstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const {
index 461aaf00b31a3519ca8bbcee8c7f3390bebda5c9..d4d3929777b70d6c5a5e645023ee290051c87ee0 100644 (file)
@@ -36,8 +36,6 @@ public:
   virtual void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot);
   virtual StringRef getOpcodeName(unsigned Opcode) const;
   
-  static const char *getInstructionName(unsigned Opcode);
-  
   // Autogenerated by tblgen.
   void printInstruction(const MCInst *MI, raw_ostream &O);
   static const char *getRegisterName(unsigned RegNo);
index ec35d3c911e3752555b94c5a091f8c57750294a5..8bf9058dd5dd2b47acd769fd6bb7d9935abe8b74 100644 (file)
@@ -19,6 +19,7 @@
 #include "llvm/MC/MCInst.h"
 #include "llvm/MC/MCAsmInfo.h"
 #include "llvm/MC/MCExpr.h"
+#include "llvm/MC/MCInstrInfo.h"
 #include "llvm/MC/MCRegisterInfo.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Format.h"
@@ -27,7 +28,6 @@
 using namespace llvm;
 
 // Include the auto-generated portion of the assembly writer.
-#define GET_INSTRUCTION_NAME
 #define PRINT_ALIAS_INSTR
 #include "X86GenAsmWriter.inc"
 
@@ -51,7 +51,7 @@ void X86ATTInstPrinter::printInst(const MCInst *MI, raw_ostream &OS,
 }
 
 StringRef X86ATTInstPrinter::getOpcodeName(unsigned Opcode) const {
-  return getInstructionName(Opcode);
+  return MII.getName(Opcode);
 }
 
 void X86ATTInstPrinter::printSSECC(const MCInst *MI, unsigned Op,
index af72c890096963637d50cec5490f1a57a5e3931a..568b7940a767b0f1334c73a8662a8b32ef90cc8b 100644 (file)
@@ -37,7 +37,6 @@ public:
   // Autogenerated by tblgen.
   void printInstruction(const MCInst *MI, raw_ostream &OS);
   static const char *getRegisterName(unsigned RegNo);
-  static const char *getInstructionName(unsigned Opcode);
 
   void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &OS);
   void printMemReference(const MCInst *MI, unsigned Op, raw_ostream &OS);
index 46a96d20989fc7e6e077ef6d18f140e11d8bf7ec..e37a477b1550e86c80da43efac4a747f45be6a0a 100644 (file)
 #include "X86InstComments.h"
 #include "MCTargetDesc/X86MCTargetDesc.h"
 #include "llvm/MC/MCInst.h"
-#include "llvm/MC/MCAsmInfo.h"
 #include "llvm/MC/MCExpr.h"
+#include "llvm/MC/MCInstrInfo.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FormattedStream.h"
 #include <cctype>
 using namespace llvm;
 
-// Include the auto-generated portion of the assembly writer.
-#define GET_INSTRUCTION_NAME
 #include "X86GenAsmWriter1.inc"
 
 void X86IntelInstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const {
@@ -44,7 +42,7 @@ void X86IntelInstPrinter::printInst(const MCInst *MI, raw_ostream &OS,
     EmitAnyX86InstComments(MI, *CommentStream, getRegisterName);
 }
 StringRef X86IntelInstPrinter::getOpcodeName(unsigned Opcode) const {
-  return getInstructionName(Opcode);
+  return MII.getName(Opcode);
 }
 
 void X86IntelInstPrinter::printSSECC(const MCInst *MI, unsigned Op,
index 2c26b1915f5f55e0cab5062f91b6bf3c711a29f3..c70b141b728d85e6b7f9e127b83d0f400429bbe8 100644 (file)
@@ -34,7 +34,6 @@ public:
   // Autogenerated by tblgen.
   void printInstruction(const MCInst *MI, raw_ostream &O);
   static const char *getRegisterName(unsigned RegNo);
-  static const char *getInstructionName(unsigned Opcode);
 
   void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
   void printMemReference(const MCInst *MI, unsigned Op, raw_ostream &O);
index de2dc51250487740578559d884edbad9b7ecb66e..bc6345467e3afc893c0d7750a01b2e89340f8b5f 100644 (file)
@@ -565,54 +565,6 @@ void AsmWriterEmitter::EmitGetRegisterName(raw_ostream &O) {
     << "}\n";
 }
 
-void AsmWriterEmitter::EmitGetInstructionName(raw_ostream &O) {
-  CodeGenTarget Target(Records);
-  Record *AsmWriter = Target.getAsmWriter();
-  std::string ClassName = AsmWriter->getValueAsString("AsmWriterClassName");
-
-  const std::vector<const CodeGenInstruction*> &NumberedInstructions =
-    Target.getInstructionsByEnumValue();
-
-  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";
-
-  SequenceToOffsetTable<std::string> StringTable;
-  for (unsigned i = 0, e = NumberedInstructions.size(); i != e; ++i) {
-    const CodeGenInstruction &Inst = *NumberedInstructions[i];
-    StringTable.add(Inst.TheDef->getName());
-  }
-
-  StringTable.layout();
-  O << "  static const char Strs[] = {\n";
-  StringTable.emit(O, printChar);
-  O << "  };\n\n";
-
-  O << "  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.get(AsmName) << ", ";
-  }
-  O << "  };\n"
-    << "\n";
-
-  O << "  return Strs+InstAsmOffset[Opcode];\n"
-  << "}\n\n#endif\n";
-}
-
 namespace {
 // IAPrinter - Holds information about an InstAlias. Two InstAliases match if
 // they both have the same conditionals. In which case, we cannot print out the
@@ -965,7 +917,6 @@ void AsmWriterEmitter::run(raw_ostream &O) {
 
   EmitPrintInstruction(O);
   EmitGetRegisterName(O);
-  EmitGetInstructionName(O);
   EmitPrintAliasInstruction(O);
 }
 
index 08f7ae39c20041152e4ebff91c060d6fc1f5da4e..9719b202faab57f37e330813227b9d6f4627a7d4 100644 (file)
@@ -37,7 +37,6 @@ namespace llvm {
 private:
     void EmitPrintInstruction(raw_ostream &o);
     void EmitGetRegisterName(raw_ostream &o);
-    void EmitGetInstructionName(raw_ostream &o);
     void EmitPrintAliasInstruction(raw_ostream &O);
     
     AsmWriterInst *getAsmWriterInstByID(unsigned ID) const {