[RFC, PowerPC] Always use "assembler dialect" 1

Ulrich Weigand Ulrich.Weigand at de.ibm.com
Mon Jul 8 11:06:48 PDT 2013


Hello,

a setting in MCAsmInfo defines the "assembler dialect" to use.  This is
used by common code to chose between alternatives in a multi-alternative
GNU inline asm statement like the following:

  __asm__ ("{sfe|subfe} %0,%1,%2" : "=r" (out) : "r" (in1), "r" (in2));

The meaning of these dialects is platform specific, and GCC defines those
for PowerPC to use dialect 0 for old-style (POWER) mnemonics and 1 for
new-style (PowerPC) mnemonics, like in the example above.   To be
compatible with inline asm used with GCC, LLVM ought to do the same.
Specifically, this means we should always use assembler dialect 1 since
old-style mnemonics really aren't supported on any current platform (as of
GCC 4.8, GCC also no longer supports old-style mnemonics).

However, the current LLVM back-end uses:
  AssemblerDialect = 1;           // New-Style mnemonics.
in PPCMCAsmInfoDarwin, and
  AssemblerDialect = 0;           // Old-Style mnemonics.
in PPCLinuxMCAsmInfo.

The Linux setting really isn't correct, we should be using new-style
mnemonics everywhere.

Unfortunately, the setting of this variable is overloaded in back-end to
decide whether or not we are on a Darwin target by back-end code.  This is
done in PPCInstPrinter (the "SyntaxVariant" is initialized from the
MCAsmInfo AssemblerDialect setting), and also in PPCMCExpr.  So setting
AssemblerDialect to 1 for both Darwin and Linux no longer allows use to
make this distinction.

Both PPCInstPrinter and PPCMCExpr have a MCAsmInfo available to
discriminate between Darwin and Linux, and we do in fact have two different
MCAsmInfo structures allocated on the target.  Unfortunately, we cannot
easily check which of them we got (MCAsmInfo doesn't support isa<>).   So
I've changed those two places to use a different member of MCAsmInfo as
"stand-in" to distinguish between Darwin and non-Darwin:
hasMachoZeroFillDirective.  Since this is currently on Darwin and only on
Darwin, it works for the purpose, but it seems a bit ugly.

Any other suggestions are certainly welcome.   Should we maybe extend the
generic MCAsmInfo by a "isDarwin" field?

Bye,
Ulrich

(See attached file: diff-llvm-asmdialect)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: diff-llvm-asmdialect
Type: application/octet-stream
Size: 4773 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130708/8c2c2fa4/attachment.obj>


More information about the llvm-commits mailing list