-/// stringForContext - Returns a string containing the name of a particular
-/// InstructionContext, usually for diagnostic purposes.
-///
-/// @param insnContext - The instruction class to transform to a string.
-/// @return - A statically-allocated string constant that contains the
-/// name of the instruction class.
-static inline const char* stringForContext(InstructionContext insnContext) {
- switch (insnContext) {
- default:
- llvm_unreachable("Unhandled instruction class");
-#define ENUM_ENTRY(n, r, d) case n: return #n; break;
-#define ENUM_ENTRY_K_B(n, r, d) ENUM_ENTRY(n, r, d) ENUM_ENTRY(n##_K_B, r, d)\
- ENUM_ENTRY(n##_K, r, d) ENUM_ENTRY(n##_B, r, d)
- INSTRUCTION_CONTEXTS
-#undef ENUM_ENTRY
-#undef ENUM_ENTRY_K_B
- }
-}
-
-/// stringForOperandType - Like stringForContext, but for OperandTypes.
-static inline const char* stringForOperandType(OperandType type) {
- switch (type) {
- default:
- llvm_unreachable("Unhandled type");
-#define ENUM_ENTRY(i, d) case i: return #i;
- TYPES
-#undef ENUM_ENTRY
- }
-}
-
-/// stringForOperandEncoding - like stringForContext, but for
-/// OperandEncodings.
-static inline const char* stringForOperandEncoding(OperandEncoding encoding) {
- switch (encoding) {
- default:
- llvm_unreachable("Unhandled encoding");
-#define ENUM_ENTRY(i, d) case i: return #i;
- ENCODINGS
-#undef ENUM_ENTRY
- }
-}
-
-void DisassemblerTables::emitOneID(raw_ostream &o, unsigned &i, InstrUID id,
- bool addComma) const {
- if (id)
- o.indent(i * 2) << format("0x%hx", id);
- else
- o.indent(i * 2) << 0;
-
- if (addComma)
- o << ", ";
- else
- o << " ";
-
- o << "/* ";
- o << InstructionSpecifiers[id].name;
- o << "*/";
-
- o << "\n";
-}
-
-/// emitEmptyTable - Emits the modRMEmptyTable, which is used as a ID table by
-/// all ModR/M decisions for instructions that are invalid for all possible
-/// ModR/M byte values.
-///
-/// @param o - The output stream on which to emit the table.
-/// @param i - The indentation level for that output stream.
-static void emitEmptyTable(raw_ostream &o, unsigned &i) {
- o.indent(i * 2) << "0x0, /* EmptyTable */\n";
-}
-