[MC] Attach labels to existing fragments instead of using a separate fragment
[oota-llvm.git] / test / MC / X86 / AlignedBundling / labeloffset.s
1 # RUN: llvm-mc -triple=i686-linux -filetype=obj %s -o - | \
2 # RUN: llvm-objdump -disassemble -no-show-raw-insn -r - | FileCheck %s
3 # RUN: llvm-mc -triple=i686-nacl -filetype=obj %s -o - | \
4 # RUN: llvm-objdump -disassemble -no-show-raw-insn -r - | FileCheck %s
5
6         .bundle_align_mode 5
7         .text
8         .globl  main
9         .align  32, 0x90
10         .type   main,@function
11 main:                                   # @main
12 # CHECK-LABEL: main:
13 # Call + pop sequence for determining the PIC base.
14         .bundle_lock align_to_end
15         calll   .L0$pb
16         .bundle_unlock
17 .L0$pb:
18         popl    %eax
19 # CHECK: 20: popl
20 # 26 bytes of instructions between the pop and the use of the pic base symbol.
21         movl    $3, 2(%ebx, %ebx)
22         movl    $3, 2(%ebx, %ebx)
23         movl    $3, 2(%ebx, %ebx)
24         hlt
25         hlt
26 # CHECK: nop
27 .Ltmp0:
28         addl    (.Ltmp0-.L0$pb), %eax
29 # The addl has bundle padding to push it from 0x3b to 0x40.
30 # The difference between the labels should be 0x20 (0x40-0x20) not 0x1b
31 # (0x3b-0x20)
32 # CHECK: 40: addl 32, %eax
33         popl    %ecx
34         jmp     *%ecx
35
36
37 # Also make sure it works with a non-relaxable instruction (cmp vs add)
38 # and for 2 adjacent labels that both point to the correct instruction
39         .section .text.bar, "ax"
40         .globl  bar
41         .align  32, 0x90
42         .type   bar,@function
43 bar:
44 # CHECK-LABEL: bar:
45         .bundle_lock align_to_end
46         calll   .L1$pb
47         .bundle_unlock
48 .L1$pb:
49         popl %eax
50 # CHECK: 20: popl
51 # 26 bytes of instructions between the pop and the use of the pic base symbol.
52         movl    $3, 2(%ebx, %ebx)
53         movl    $3, 2(%ebx, %ebx)
54         movl    $3, 2(%ebx, %ebx)
55         hlt
56         hlt
57 # CHECK: nop
58 .Ltmp1:
59 .Ltmp2:
60         cmpl    %eax, .Ltmp1
61 # CHECK: 40: cmpl %eax, 64
62         cmpl     %eax, (.Ltmp2-.L1$pb)
63 # CHECK: 46: cmpl %eax, 32
64         popl    %ecx
65         jmp *%ecx
66
67
68 # Switch sections in the middle of a function
69         .section .text.foo, "ax"
70         .globl  foo
71         .align  32, 0x90
72         .type   foo,@function
73 # CHECK-LABEL: foo:
74 foo:
75         inc %eax
76 tmp3:
77         .rodata
78         .type   obj,@object
79         .comm   obj,4,4
80         .section .text.foo
81         inc %eax
82 # CHECK: tmp3:
83 # CHECK-NEXT: 1: incl