From 642c8bef1931cfc05f6d23a9b25d7d182cc48c01 Mon Sep 17 00:00:00 2001 From: Akira Hatanaka Date: Fri, 25 Jul 2014 05:12:49 +0000 Subject: [PATCH] [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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213924 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/ARM/ARMAsmPrinter.cpp | 3 +++ test/CodeGen/ARM/inlineasm-global.ll | 13 +++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 test/CodeGen/ARM/inlineasm-global.ll diff --git a/lib/Target/ARM/ARMAsmPrinter.cpp b/lib/Target/ARM/ARMAsmPrinter.cpp index 28d2610c390..9ad808c00e7 100644 --- a/lib/Target/ARM/ARMAsmPrinter.cpp +++ b/lib/Target/ARM/ARMAsmPrinter.cpp @@ -478,6 +478,9 @@ void ARMAsmPrinter::EmitStartOfAsmFile(Module &M) { // Emit ARM Build Attributes if (Subtarget->isTargetELF()) emitAttributes(); + + if (!M.getModuleInlineAsm().empty() && Subtarget->isThumb()) + OutStreamer.EmitAssemblerFlag(MCAF_Code16); } static void diff --git a/test/CodeGen/ARM/inlineasm-global.ll b/test/CodeGen/ARM/inlineasm-global.ll new file mode 100644 index 00000000000..d1a15e393a1 --- /dev/null +++ b/test/CodeGen/ARM/inlineasm-global.ll @@ -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};" -- 2.34.1