]> granicus.if.org Git - llvm/commitdiff
[ARM] Add ".code 32" to functions in the ARM instruction set
authorPablo Barrio <pablo.barrio@arm.com>
Tue, 13 Sep 2016 12:18:15 +0000 (12:18 +0000)
committerPablo Barrio <pablo.barrio@arm.com>
Tue, 13 Sep 2016 12:18:15 +0000 (12:18 +0000)
Before, only Thumb functions were marked as ".code 16". These
".code x" directives are effective until the next directive of its
kind is encountered. Therefore, in code with interleaved ARM and
Thumb functions, it was possible to declare a function as ARM and
end up with a Thumb function after assembly. A test has been added.

An existing test has also been fixed to take this change into
account.

Reviewers: aschwaighofer, t.p.northover, jmolloy, rengolin

Subscribers: aemerson, rengolin, llvm-commits

Differential Revision: https://reviews.llvm.org/D24337

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281324 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/ARMAsmPrinter.cpp
test/CodeGen/ARM/interwork.ll [new file with mode: 0644]
test/DebugInfo/ARM/header.ll

index 2a20c4789facaf238dd56b85c5e6b1bcf4f56bd9..8d44a26b1dba0d6d6248b3d7ad9aee4e32000dd6 100644 (file)
@@ -74,8 +74,9 @@ void ARMAsmPrinter::EmitFunctionEntryLabel() {
   if (AFI->isThumbFunction()) {
     OutStreamer->EmitAssemblerFlag(MCAF_Code16);
     OutStreamer->EmitThumbFunc(CurrentFnSym);
+  } else {
+    OutStreamer->EmitAssemblerFlag(MCAF_Code32);
   }
-
   OutStreamer->EmitLabel(CurrentFnSym);
 }
 
diff --git a/test/CodeGen/ARM/interwork.ll b/test/CodeGen/ARM/interwork.ll
new file mode 100644 (file)
index 0000000..9a75cde
--- /dev/null
@@ -0,0 +1,23 @@
+; One file may have multiple functions targeted at different (ARM, Thumb)
+; instruction sets. Passing this information to the linker and the assembler
+; is done through the ".code 16" and ".code 32" directives.
+;
+; RUN: llc -mtriple=arm-arm-none-eabi %s -o - | FileCheck %s
+
+define void @ft() #0 {
+; CHECK: .code 16
+; CHECK: .thumb_func
+; CHECK-LABEL: ft:
+entry:
+  ret void
+}
+
+define void @fz() #1 {
+; CHECK: .code 32
+; CHECK-LABEL: fz:
+entry:
+  ret void
+}
+
+attributes #0 = { "target-features"="+thumb-mode" }
+attributes #1 = { "target-features"="-thumb-mode" }
index 96a5cff73bced676b99db1a64f1623a19dd478f7..5bc3b55a4bdef5fdafb99b8b686af2405b429491 100644 (file)
@@ -8,7 +8,8 @@
 ; CHECK-NEXT: .syntax unified
 ; CHECK-NEXT: .globl  _f
 ; CHECK-NEXT: .p2align  2
-; CHECK-NEXT: _f:                    @ @f
+; CHECK-NEXT: .code 32                    @ @f
+; CHECK-NEXT: _f:
 
 ; CHECK:  .section        __DWARF,__debug_str,regular,debug
 
@@ -21,7 +22,7 @@ define void @f() !dbg !4 {
 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "foo", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
 !1 = !DIFile(filename: "/foo/test.c", directory: "/foo")
 !2 = !{}
-!4 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !2)
+!4 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 2, type: !5, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !2)
 !5 = !DISubroutineType(types: !6)
 !6 = !{null}
 !7 = !{i32 2, !"Dwarf Version", i32 4}