1 @ This test has a partner (ldr-pseudo-darwin.s) that contains matching 2 @ tests for the ldr-pseudo on darwin targets. We need separate files 3 @ because the syntax for switching sections and temporary labels differs 4 @ between darwin and linux. Any tests added here should have a matching 5 @ test added there. 6 7 @RUN: llvm-mc -triple armv7-unknown-linux-gnueabi %s | FileCheck %s 8 @RUN: llvm-mc -triple thumbv5-unknown-linux-gnueabi %s | FileCheck %s 9 @RUN: llvm-mc -triple thumbv7-unknown-linux-gnueabi %s | FileCheck %s 10 11 @ 12 @ Check that large constants are converted to ldr from constant pool 13 @ 14 @ simple test 15 .section b,"ax",%progbits 16 @ CHECK-LABEL: f3: 17 f3: 18 ldr r0, =0x10001 19 @ CHECK: ldr r0, .Ltmp[[TMP0:[0-9]+]] 20 21 @ loading multiple constants 22 .section c,"ax",%progbits 23 @ CHECK-LABEL: f4: 24 f4: 25 ldr r0, =0x10002 26 @ CHECK: ldr r0, .Ltmp[[TMP1:[0-9]+]] 27 adds r0, r0, #1 28 adds r0, r0, #1 29 adds r0, r0, #1 30 adds r0, r0, #1 31 ldr r0, =0x10003 32 @ CHECK: ldr r0, .Ltmp[[TMP2:[0-9]+]] 33 adds r0, r0, #1 34 adds r0, r0, #1 35 36 @ TODO: the same constants should have the same constant pool location 37 .section d,"ax",%progbits 38 @ CHECK-LABEL: f5: 39 f5: 40 ldr r0, =0x10004 41 @ CHECK: ldr r0, .Ltmp[[TMP3:[0-9]+]] 42 adds r0, r0, #1 43 adds r0, r0, #1 44 adds r0, r0, #1 45 adds r0, r0, #1 46 adds r0, r0, #1 47 adds r0, r0, #1 48 adds r0, r0, #1 49 ldr r0, =0x10004 50 @ CHECK: ldr r0, .Ltmp[[TMP4:[0-9]+]] 51 adds r0, r0, #1 52 adds r0, r0, #1 53 adds r0, r0, #1 54 adds r0, r0, #1 55 adds r0, r0, #1 56 adds r0, r0, #1 57 58 @ a section defined in multiple pieces should be merged and use a single constant pool 59 .section e,"ax",%progbits 60 @ CHECK-LABEL: f6: 61 f6: 62 ldr r0, =0x10006 63 @ CHECK: ldr r0, .Ltmp[[TMP5:[0-9]+]] 64 adds r0, r0, #1 65 adds r0, r0, #1 66 adds r0, r0, #1 67 68 .section f, "ax", %progbits 69 @ CHECK-LABEL: f7: 70 f7: 71 adds r0, r0, #1 72 adds r0, r0, #1 73 adds r0, r0, #1 74 75 .section e, "ax", %progbits 76 @ CHECK-LABEL: f8: 77 f8: 78 adds r0, r0, #1 79 ldr r0, =0x10007 80 @ CHECK: ldr r0, .Ltmp[[TMP6:[0-9]+]] 81 adds r0, r0, #1 82 adds r0, r0, #1 83 84 @ 85 @ Check that symbols can be loaded using ldr pseudo 86 @ 87 88 @ load an undefined symbol 89 .section g,"ax",%progbits 90 @ CHECK-LABEL: f9: 91 f9: 92 ldr r0, =foo 93 @ CHECK: ldr r0, .Ltmp[[TMP7:[0-9]+]] 94 95 @ load a symbol from another section 96 .section h,"ax",%progbits 97 @ CHECK-LABEL: f10: 98 f10: 99 ldr r0, =f5 100 @ CHECK: ldr r0, .Ltmp[[TMP8:[0-9]+]] 101 102 @ load a symbol from the same section 103 .section i,"ax",%progbits 104 @ CHECK-LABEL: f11: 105 f11: 106 ldr r0, =f12 107 @ CHECK: ldr r0, .Ltmp[[TMP9:[0-9]+]] 108 109 @ CHECK-LABEL: f12: 110 f12: 111 adds r0, r0, #1 112 adds r0, r0, #1 113 114 .section j,"ax",%progbits 115 @ mix of symbols and constants 116 @ CHECK-LABEL: f13: 117 f13: 118 adds r0, r0, #1 119 adds r0, r0, #1 120 ldr r0, =0x101 121 @ CHECK: ldr r0, .Ltmp[[TMP10:[0-9]+]] 122 adds r0, r0, #1 123 adds r0, r0, #1 124 ldr r0, =bar 125 @ CHECK: ldr r0, .Ltmp[[TMP11:[0-9]+]] 126 adds r0, r0, #1 127 adds r0, r0, #1 128 @ 129 @ Check for correct usage in other contexts 130 @ 131 132 @ usage in macro 133 .macro useit_in_a_macro 134 ldr r0, =0x10008 135 ldr r0, =baz 136 .endm 137 .section k,"ax",%progbits 138 @ CHECK-LABEL: f14: 139 f14: 140 useit_in_a_macro 141 @ CHECK: ldr r0, .Ltmp[[TMP12:[0-9]+]] 142 @ CHECK: ldr r0, .Ltmp[[TMP13:[0-9]+]] 143 144 @ usage with expressions 145 .section l, "ax", %progbits 146 @ CHECK-LABEL: f15: 147 f15: 148 ldr r0, =0x10001+8 149 @ CHECK: ldr r0, .Ltmp[[TMP14:[0-9]+]] 150 adds r0, r0, #1 151 ldr r0, =bar+4 152 @ CHECK: ldr r0, .Ltmp[[TMP15:[0-9]+]] 153 adds r0, r0, #1 154 155 @ 156 @ Constant Pools 157 @ 158 @ CHECK: .section b,"ax",%progbits 159 @ CHECK: .align 2 160 @ CHECK: .Ltmp[[TMP0]] 161 @ CHECK: .long 65537 162 163 @ CHECK: .section c,"ax",%progbits 164 @ CHECK: .align 2 165 @ CHECK: .Ltmp[[TMP1]] 166 @ CHECK: .long 65538 167 @ CHECK: .Ltmp[[TMP2]] 168 @ CHECK: .long 65539 169 170 @ CHECK: .section d,"ax",%progbits 171 @ CHECK: .align 2 172 @ CHECK: .Ltmp[[TMP3]] 173 @ CHECK: .long 65540 174 @ CHECK: .Ltmp[[TMP4]] 175 @ CHECK: .long 65540 176 177 @ CHECK: .section e,"ax",%progbits 178 @ CHECK: .align 2 179 @ CHECK: .Ltmp[[TMP5]] 180 @ CHECK: .long 65542 181 @ CHECK: .Ltmp[[TMP6]] 182 @ CHECK: .long 65543 183 184 @ Should not switch to section because it has no constant pool 185 @ CHECK-NOT: .section f,"ax",%progbits 186 187 @ CHECK: .section g,"ax",%progbits 188 @ CHECK: .align 2 189 @ CHECK: .Ltmp[[TMP7]] 190 @ CHECK: .long foo 191 192 @ CHECK: .section h,"ax",%progbits 193 @ CHECK: .align 2 194 @ CHECK: .Ltmp[[TMP8]] 195 @ CHECK: .long f5 196 197 @ CHECK: .section i,"ax",%progbits 198 @ CHECK: .align 2 199 @ CHECK: .Ltmp[[TMP9]] 200 @ CHECK: .long f12 201 202 @ CHECK: .section j,"ax",%progbits 203 @ CHECK: .align 2 204 @ CHECK: .Ltmp[[TMP10]] 205 @ CHECK: .long 257 206 @ CHECK: .Ltmp[[TMP11]] 207 @ CHECK: .long bar 208 209 @ CHECK: .section k,"ax",%progbits 210 @ CHECK: .align 2 211 @ CHECK: .Ltmp[[TMP12]] 212 @ CHECK: .long 65544 213 @ CHECK: .Ltmp[[TMP13]] 214 @ CHECK: .long baz 215 216 @ CHECK: .section l,"ax",%progbits 217 @ CHECK: .align 2 218 @ CHECK: .Ltmp[[TMP14]] 219 @ CHECK: .long 65545 220 @ CHECK: .Ltmp[[TMP15]] 221 @ CHECK: .long bar+4 222