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