[llvm] r251418 - [ms-inline-asm] Leave alignment in bytes if the native assembler uses bytes

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 27 10:32:48 PDT 2015


Author: rnk
Date: Tue Oct 27 12:32:48 2015
New Revision: 251418

URL: http://llvm.org/viewvc/llvm-project?rev=251418&view=rev
Log:
[ms-inline-asm] Leave alignment in bytes if the native assembler uses bytes

The existing behavior was correct on Darwin, which is probably the
platform it was written for.

Before this change, we would rewrite "align 8" to ".align 3" and then
fail to make it through the integrated assembler because 3 is not a
power of 2.

Differential Revision: http://reviews.llvm.org/D14120

Modified:
    llvm/trunk/lib/MC/MCParser/AsmParser.cpp

Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=251418&r1=251417&r2=251418&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Tue Oct 27 12:32:48 2015
@@ -4792,10 +4792,16 @@ bool AsmParser::parseMSInlineAsm(
       OS << ".byte";
       break;
     case AOK_Align: {
-      unsigned Val = AR.Val;
-      OS << ".align " << Val;
+      // MS alignment directives are measured in bytes. If the native assembler
+      // measures alignment in bytes, we can pass it straight through.
+      OS << ".align";
+      if (getContext().getAsmInfo()->getAlignmentIsInBytes())
+        break;
 
-      // Skip the original immediate.
+      // Alignment is in log2 form, so print that instead and skip the original
+      // immediate.
+      unsigned Val = AR.Val;
+      OS << ' ' << Val;
       assert(Val < 10 && "Expected alignment less then 2^10.");
       AdditionalSkip = (Val < 4) ? 2 : Val < 7 ? 3 : 4;
       break;




More information about the llvm-commits mailing list