[PATCH] [Tablegen] Fix alias instruction printer mangling opcodes with optional suffixes.
Matthew Wahab
matthew.wahab at arm.com
Fri Jan 2 01:56:09 PST 2015
Uploaded patch with full context.
http://reviews.llvm.org/D6530
Files:
utils/TableGen/AsmWriterEmitter.cpp
Index: utils/TableGen/AsmWriterEmitter.cpp
===================================================================
--- utils/TableGen/AsmWriterEmitter.cpp
+++ utils/TableGen/AsmWriterEmitter.cpp
@@ -1011,15 +1011,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
+ // '<opcode>('${'<operand>'}')*<separator><operands>'.
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";
@@ -1030,9 +1032,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";
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6530.17758.patch
Type: text/x-patch
Size: 1666 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150102/34d8d144/attachment.bin>
More information about the llvm-commits
mailing list