[llvm] r213924 - [ARM] In thumb mode, emit directive ".code 16" before file level inline

Akira Hatanaka ahatanaka at apple.com
Thu Jul 24 22:12:49 PDT 2014


Author: ahatanak
Date: Fri Jul 25 00:12:49 2014
New Revision: 213924

URL: http://llvm.org/viewvc/llvm-project?rev=213924&view=rev
Log:
[ARM] In thumb mode, emit directive ".code 16" before file level inline
assembly instructions.

This is necessary to ensure ARM assembler switches to Thumb mode before it
starts assembling the file level inline assembly instructions at the beginning
of a .s file.

<rdar://problem/17757232>


Added:
    llvm/trunk/test/CodeGen/ARM/inlineasm-global.ll
Modified:
    llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp

Modified: llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp?rev=213924&r1=213923&r2=213924&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp Fri Jul 25 00:12:49 2014
@@ -478,6 +478,9 @@ void ARMAsmPrinter::EmitStartOfAsmFile(M
   // Emit ARM Build Attributes
   if (Subtarget->isTargetELF())
     emitAttributes();
+
+  if (!M.getModuleInlineAsm().empty() && Subtarget->isThumb())
+    OutStreamer.EmitAssemblerFlag(MCAF_Code16);
 }
 
 static void

Added: llvm/trunk/test/CodeGen/ARM/inlineasm-global.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/inlineasm-global.ll?rev=213924&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/inlineasm-global.ll (added)
+++ llvm/trunk/test/CodeGen/ARM/inlineasm-global.ll Fri Jul 25 00:12:49 2014
@@ -0,0 +1,13 @@
+; RUN: llc -march thumb -no-integrated-as %s -o - | FileCheck %s --check-prefix=THUMB
+; RUN: llc -march arm -no-integrated-as %s -o - | FileCheck %s --check-prefix=ARM
+
+; In thumb mode, emit ".code 16" before global inline-asm instructions.
+
+; THUMB: .code 16
+; THUMB: stmib
+; THUMB: .code 16
+
+; ARM-NOT: .code 16
+; ARM:     stmib
+
+module asm "stmib sp, {r0-r14};"





More information about the llvm-commits mailing list