Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / MachO / loh-adrp-ldr.s
blob956632ae99910f8861ec8f596d63a6be86392548
1 # REQUIRES: aarch64
3 # RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %s -o %t.o
4 # RUN: %lld -arch arm64 %t.o -o %t
5 # RUN: llvm-objdump --no-print-imm-hex -d --macho %t | FileCheck %s
7 .text
8 .align 2
9 _before_far:
10 .space 1048576
12 .align 2
13 _before_near:
14 .quad 0
16 .globl _main
17 # CHECK-LABEL: _main:
18 _main:
19 ## Out of range, before
20 L1: adrp x0, _before_far@PAGE
21 L2: ldr x0, [x0, _before_far@PAGEOFF]
22 # CHECK-NEXT: adrp x0
23 # CHECK-NEXT: ldr x0
25 ## In range, before
26 L3: adrp x1, _before_near@PAGE
27 L4: ldr x1, [x1, _before_near@PAGEOFF]
28 # CHECK-NEXT: nop
29 # CHECK-NEXT: ldr x1, #-20
31 ## Registers don't match (invalid input)
32 L5: adrp x2, _before_near@PAGE
33 L6: ldr x3, [x3, _before_near@PAGEOFF]
34 # CHECK-NEXT: adrp x2
35 # CHECK-NEXT: ldr x3
37 ## Not an adrp instruction
38 L9: udf 0
39 L10: ldr x5, [x5, _after_near@PAGEOFF]
40 # CHECK-NEXT: udf
41 # CHECK-NEXT: ldr x5
43 ## Not an ldr with an immediate offset
44 L11: adrp x6, _after_near@PAGE
45 L12: ldr x6, 0
46 # CHECK-NEXT: adrp x6
47 # CHECK-NEXT: ldr x6, #0
49 ## Byte load, unsupported
50 L15: adrp x8, _after_near@PAGE
51 L16: ldr b8, [x8, _after_near@PAGEOFF]
52 # CHECK-NEXT: adrp x8
53 # CHECK-NEXT: ldr b8
55 ## Halfword load, unsupported
56 L17: adrp x9, _after_near@PAGE
57 L18: ldr h9, [x9, _after_near@PAGEOFF]
58 # CHECK-NEXT: adrp x9
59 # CHECK-NEXT: ldr h9
61 ## Word load
62 L19: adrp x10, _after_near@PAGE
63 L20: ldr w10, [x10, _after_near@PAGEOFF]
64 # CHECK-NEXT: nop
65 # CHECK-NEXT: ldr w10, _after_near
67 ## With addend
68 L21: adrp x11, _after_near@PAGE + 8
69 L22: ldr x11, [x11, _after_near@PAGEOFF + 8]
70 # CHECK-NEXT: nop
71 # CHECK-NEXT: ldr x11
73 ## Signed 32-bit read from 16-bit value, unsupported
74 L23: adrp x12, _after_near@PAGE
75 L24: ldrsb w12, [x12, _after_near@PAGEOFF]
76 # CHECK-NEXT: adrp x12
77 # CHECK-NEXT: ldrsb w12
79 ## 64-bit load from signed 32-bit value
80 L25: adrp x13, _after_near@PAGE
81 L26: ldrsw x13, [x13, _after_near@PAGEOFF]
82 # CHECK-NEXT: nop
83 # CHECK-NEXT: ldrsw x13, _after_near
85 ## Single precision FP read
86 L27: adrp x14, _after_near@PAGE
87 L28: ldr s0, [x14, _after_near@PAGEOFF]
88 # CHECK-NEXT: nop
89 # CHECK-NEXT: ldr s0, _after_near
91 ## Double precision FP read
92 L29: adrp x15, _after_near@PAGE
93 L30: ldr d0, [x15, _after_near@PAGEOFF]
94 # CHECK-NEXT: nop
95 # CHECK-NEXT: ldr d0, _after_near
97 ## Quad precision FP read
98 L31: adrp x16, _after_near@PAGE
99 L32: ldr q0, [x16, _after_near@PAGEOFF]
100 # CHECK-NEXT: nop
101 # CHECK-NEXT: ldr q0, _after_near
103 ## Out of range, after
104 L33: adrp x17, _after_far@PAGE
105 L34: ldr x17, [x17, _after_far@PAGEOFF]
106 # CHECK-NEXT: adrp x17
107 # CHECK-NEXT: ldr x17
109 .data
110 .align 4
111 _after_near:
112 .quad 0
113 .quad 0
114 .space 1048576
116 _after_far:
117 .quad 0
119 .loh AdrpLdr L1, L2
120 .loh AdrpLdr L3, L4
121 .loh AdrpLdr L5, L6
122 .loh AdrpLdr L9, L10
123 .loh AdrpLdr L11, L12
124 .loh AdrpLdr L15, L16
125 .loh AdrpLdr L17, L18
126 .loh AdrpLdr L19, L20
127 .loh AdrpLdr L21, L22
128 .loh AdrpLdr L23, L24
129 .loh AdrpLdr L25, L26
130 .loh AdrpLdr L27, L28
131 .loh AdrpLdr L29, L30
132 .loh AdrpLdr L31, L32
133 .loh AdrpLdr L33, L34