1// RUN: llvm-mc -triple aarch64-elf -filetype=obj %s -o - | llvm-objdump -d - | FileCheck %s
2
3start:
4  .space 8
5end:
6  // CHECK-LABEL: <end>:
7
8  adds w0, w1, #(end - start)
9  adds x0, x1, #(end - start)
10  add w0, w1, #(end - start)
11  add x0, x1, #(end - start)
12  cmp w0, #(end - start)
13  cmp x0, #(end - start)
14  sub w0, w1, #(end - start)
15  sub x0, x1, #(end - start)
16  // FIXME: adr x1, #(end - start) // This could be supported, but currently doesn't work
17  // CHECK: adds w0, w1, #8
18  // CHECK: adds x0, x1, #8
19  // CHECK: add w0, w1, #8
20  // CHECK: add x0, x1, #8
21  // CHECK: cmp w0, #8
22  // CHECK: cmp x0, #8
23  // CHECK: sub w0, w1, #8
24  // CHECK: sub x0, x1, #8
25  // FIXME: adr x1, #8
26
27  add w0, w1, #(end - start), lsl #12
28  cmp w0, #(end - start), lsl #12
29  // CHECK: add w0, w1, #8, lsl #12
30  // CHECK: cmp w0, #8, lsl #12
31
32  add w0, w1, #((end - start) >> 2)
33  cmp w0, #((end - start) >> 2)
34  // CHECK: add w0, w1, #2
35  // CHECK: cmp w0, #2
36
37  add w0, w1, #(end - start + 12)
38  cmp w0, #(end - start + 12)
39  // CHECK: add w0, w1, #20
40  // CHECK: cmp w0, #20
41
42  add w0, w1, #(forward - end)
43  cmp w0, #(forward - end)
44  // CHECK: add w0, w1, #320
45  // CHECK: cmp w0, #320
46
47// Add some filler so we don't have to modify #(forward - end) if we add more
48// instructions above
49.Lfiller:
50  .space 320 - (.Lfiller - end)
51
52forward:
53  .space 8
54
55.Lstart:
56  .space 8
57.Lend:
58  add w0, w1, #(.Lend - .Lstart)
59  cmp w0, #(.Lend - .Lstart)
60  // CHECK: add w0, w1, #8
61  // CHECK: cmp w0, #8
62
63.Lprivate1:
64  .space 8
65notprivate:
66  .space 8
67.Lprivate2:
68  add w0, w1, #(.Lprivate2 - .Lprivate1)
69  cmp w0, #(.Lprivate2 - .Lprivate1)
70  // CHECK: add w0, w1, #16
71  // CHECK: cmp w0, #16
72
73  .type foo, @function
74foo:
75  // CHECK-LABEL: <foo>:
76
77  add w0, w1, #(foo - .Lprivate2)
78  cmp w0, #(foo - .Lprivate2)
79  // CHECK: add w0, w1, #8
80  // CHECK: cmp w0, #8
81
82  ret
83
84  .type goo, @function
85goo:
86  // CHECK-LABEL: <goo>:
87
88  add w0, w1, #(goo - foo)
89  cmp w0, #(goo - foo)
90  // CHECK: add w0, w1, #12
91  // CHECK: cmp w0, #12
92
93  add w0, w1, #(. - goo)
94  cmp w0, #(. - goo)
95  // CHECK: add w0, w1, #8
96  // CHECK: cmp w0, #12
97
98  ret
99