llvm.org GIT mirror llvm / c8b398c
[ARM] Add ".code 32" to functions in the ARM instruction set 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 Pablo Barrio 4 years ago
3 changed file(s) with 29 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
7373 if (AFI->isThumbFunction()) {
7474 OutStreamer->EmitAssemblerFlag(MCAF_Code16);
7575 OutStreamer->EmitThumbFunc(CurrentFnSym);
76 }
77
76 } else {
77 OutStreamer->EmitAssemblerFlag(MCAF_Code32);
78 }
7879 OutStreamer->EmitLabel(CurrentFnSym);
7980 }
8081
0 ; One file may have multiple functions targeted at different (ARM, Thumb)
1 ; instruction sets. Passing this information to the linker and the assembler
2 ; is done through the ".code 16" and ".code 32" directives.
3 ;
4 ; RUN: llc -mtriple=arm-arm-none-eabi %s -o - | FileCheck %s
5
6 define void @ft() #0 {
7 ; CHECK: .code 16
8 ; CHECK: .thumb_func
9 ; CHECK-LABEL: ft:
10 entry:
11 ret void
12 }
13
14 define void @fz() #1 {
15 ; CHECK: .code 32
16 ; CHECK-LABEL: fz:
17 entry:
18 ret void
19 }
20
21 attributes #0 = { "target-features"="+thumb-mode" }
22 attributes #1 = { "target-features"="-thumb-mode" }
77 ; CHECK-NEXT: .syntax unified
88 ; CHECK-NEXT: .globl _f
99 ; CHECK-NEXT: .p2align 2
10 ; CHECK-NEXT: _f: @ @f
10 ; CHECK-NEXT: .code 32 @ @f
11 ; CHECK-NEXT: _f:
1112
1213 ; CHECK: .section __DWARF,__debug_str,regular,debug
1314
2021 !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)
2122 !1 = !DIFile(filename: "/foo/test.c", directory: "/foo")
2223 !2 = !{}
23 !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)
24 !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)
2425 !5 = !DISubroutineType(types: !6)
2526 !6 = !{null}
2627 !7 = !{i32 2, !"Dwarf Version", i32 4}