Index: utils/TableGen/AsmWriterEmitter.cpp =================================================================== --- utils/TableGen/AsmWriterEmitter.cpp +++ utils/TableGen/AsmWriterEmitter.cpp @@ -1005,15 +1005,17 @@ O.indent(2) << "}\n\n"; // Code that prints the alias, replacing the operands with the ones from the - // MCInst. + // MCInst. Follows the format given by the instruction AsmString field, + // slightly complicated by opcodes with optional suffixes + // '('${''}')*'. O << " unsigned I = 0;\n"; O << " while (AsmString[I] != ' ' && AsmString[I] != '\t' &&\n"; - O << " AsmString[I] != '\\0')\n"; + O << " AsmString[I] != '\\0' && AsmString[I] != '$')\n"; O << " ++I;\n"; O << " OS << '\\t' << StringRef(AsmString, I);\n"; O << " if (AsmString[I] != '\\0') {\n"; - O << " OS << '\\t';\n"; + O << " bool NeedOpcodeSep = true;\n"; O << " do {\n"; O << " if (AsmString[I] == '$') {\n"; O << " ++I;\n"; @@ -1024,9 +1026,13 @@ O << " printCustomAliasOperand(MI, OpIdx, PrintMethodIdx, OS);\n"; O << " } else\n"; O << " printOperand(MI, unsigned(AsmString[I++]) - 1, OS);\n"; - O << " } else {\n"; + O << " } else if (NeedOpcodeSep &&\n"; + O << " (AsmString[I] == ' ' || AsmString[I] == '\t')) {\n"; + O << " NeedOpcodeSep = false;\n"; + O << " OS << '\\t';\n"; + O << " ++I;\n"; + O << " } else\n"; O << " OS << AsmString[I++];\n"; - O << " }\n"; O << " } while (AsmString[I] != '\\0');\n"; O << " }\n\n";