[ms-inline-asm] Leave alignment in bytes if the native assembler uses bytes
[oota-llvm.git] / lib / MC / MCParser / AsmParser.cpp
index 0c5100c07f5ad16fd4dd5a77b2f0c7f2c134cd1f..ad2e1fd5809a2e9af3a3c90576ea2100cfb05ea5 100644 (file)
@@ -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;