This is an archive of the discontinued LLVM Phabricator instance.

[Tablegen] Fix alias instruction printer mangling opcodes with optional suffixes.
Needs ReviewPublic

Authored by mwahab on Dec 4 2014, 8:21 AM.
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary

Log:

[Tablegen] Fix alias instruction printer mangling opcodes with optional suffixes.

The generic printer will now properly print AsmString formats such as
"opcode${a}${b} operands".

This introduces a slight change in behaviour: a tab is printed for the first
whitespace after the opcode and suffixes part. Previously, a tab would always be
printed after the opcode.

Summary:

An instruction alias defined with InstAlias and an optional operand immediately
after the opcode, "<opcode>${a} <operands>", would get the optional operand
emitted as unprintable characters in the instrution disassembly. This wouldn't
happen if the optional operand appeared as the last item in the AsmString which
is how the current backends avoided the problem.

There don't appear to be any tests for this part of Tablegen but it passes the
pre-commit tests. Manually tested the change by enabling the generic alias
printer in the ARM backend and checking the output.

Diff Detail

Event Timeline

mwahab updated this revision to Diff 16930.Dec 4 2014, 8:21 AM
mwahab retitled this revision from to [Tablegen] Fix alias instruction printer mangling opcodes with optional suffixes. .
mwahab updated this object.
mwahab edited the test plan for this revision. (Show Details)
mwahab added a subscriber: Unknown Object (MLST).

Can you please upload this patch with full context? For instructions, see:

http://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface
utils/TableGen/AsmWriterEmitter.cpp
1029

So the general idea here is that we always eat the first ' ' or '\t' and replace it with a '\t'. All other whitespace (including that in between operands) passes through as provided. Is that right?

mwahab updated this revision to Diff 17758.Jan 2 2015, 1:55 AM

Uploaded patch with full context.

mwahab added a comment.Jan 2 2015, 2:06 AM

From: hfinkel@anl.gov [mailto:hfinkel@anl.gov]
Sent: 23 December 2014 23:27

Comment at: utils/TableGen/AsmWriterEmitter.cpp:1029
@@ -1026,2 +1028,3 @@

O << "          printOperand(MI, unsigned(AsmString[I++]) - 1, OS);\n";
  • O << " } else {\n";

+ O << " } else if (NeedOpcodeSep &&\n";
+ O << " (AsmString[I] == ' ' || AsmString[I] == '\t'))

{\n";

So the general idea here is that we always eat the first ' ' or '\t' and
replace it with a '\t'. All other whitespace (including that in between
operands) passes through as provided. Is that right?

That's right. The current printer puts a tab between the opcode and the first operand. This needs to be suppressed until after those operands which are not separated from the opcode. Whitespace after the first separator will appear as is.

http://reviews.llvm.org/D6530

EMAIL PREFERENCES

http://reviews.llvm.org/settings/panel/emailpreferences/
  • IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

ARM Limited, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, Registered in England & Wales, Company No: 2557590
ARM Holdings plc, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, Registered in England & Wales, Company No: 2548782