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