Home | History | Annotate | Download | only in ARM
      1 @ This test has a partner (ldr-pseudo.s) that contains matching
      2 @ tests for the ldr-pseudo on linux 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-apple-darwin %s | FileCheck %s
      8 @RUN: llvm-mc -triple thumbv5-apple-darwin %s | FileCheck %s
      9 @RUN: llvm-mc -triple thumbv7-apple-darwin %s | FileCheck %s
     10 
     11 @
     12 @ Check that large constants are converted to ldr from constant pool
     13 @
     14 @ simple test
     15 .section __TEXT,b,regular,pure_instructions
     16 @ CHECK-LABEL: f3:
     17 f3:
     18   ldr r0, =0x10001
     19 @ CHECK: ldr r0, Ltmp0
     20 
     21 @ loading multiple constants
     22 .section __TEXT,c,regular,pure_instructions
     23 @ CHECK-LABEL: f4:
     24 f4:
     25   ldr r0, =0x10002
     26 @ CHECK: ldr r0, Ltmp1
     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, Ltmp2
     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 __TEXT,d,regular,pure_instructions
     38 @ CHECK-LABEL: f5:
     39 f5:
     40   ldr r0, =0x10004
     41 @ CHECK: ldr r0, Ltmp3
     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, Ltmp4
     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 __TEXT,e,regular,pure_instructions
     60 @ CHECK-LABEL: f6:
     61 f6:
     62   ldr r0, =0x10006
     63 @ CHECK: ldr r0, Ltmp5
     64   adds r0, r0, #1
     65   adds r0, r0, #1
     66   adds r0, r0, #1
     67 
     68 .section __TEXT,f,regular,pure_instructions
     69 @ CHECK-LABEL: f7:
     70 f7:
     71   adds r0, r0, #1
     72   adds r0, r0, #1
     73   adds r0, r0, #1
     74 
     75 .section __TEXT,e,regular,pure_instructions
     76 @ CHECK-LABEL: f8:
     77 f8:
     78   adds r0, r0, #1
     79   ldr r0, =0x10007
     80 @ CHECK: ldr r0, Ltmp6
     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 __TEXT,g,regular,pure_instructions
     90 @ CHECK-LABEL: f9:
     91 f9:
     92   ldr r0, =foo
     93 @ CHECK: ldr r0, Ltmp7
     94 
     95 @ load a symbol from another section
     96 .section __TEXT,h,regular,pure_instructions
     97 @ CHECK-LABEL: f10:
     98 f10:
     99   ldr r0, =f5
    100 @ CHECK: ldr r0, Ltmp8
    101 
    102 @ load a symbol from the same section
    103 .section __TEXT,i,regular,pure_instructions
    104 @ CHECK-LABEL: f11:
    105 f11:
    106   ldr r0, =f12
    107 @ CHECK: ldr r0, Ltmp9
    108 
    109 @ CHECK-LABEL: f12:
    110 f12:
    111   adds r0, r0, #1
    112   adds r0, r0, #1
    113 
    114 .section __TEXT,j,regular,pure_instructions
    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, Ltmp10
    122   adds r0, r0, #1
    123   adds r0, r0, #1
    124   ldr r0, =bar
    125 @ CHECK: ldr r0, Ltmp11
    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 __TEXT,k,regular,pure_instructions
    138 @ CHECK-LABEL: f14:
    139 f14:
    140   useit_in_a_macro
    141 @ CHECK: ldr r0, Ltmp12
    142 @ CHECK: ldr r0, Ltmp13
    143 
    144 @ usage with expressions
    145 .section __TEXT,l,regular,pure_instructions
    146 @ CHECK-LABEL: f15:
    147 f15:
    148   ldr r0, =0x10001+8
    149 @ CHECK: ldr r0, Ltmp14
    150   adds r0, r0, #1
    151   ldr r0, =bar+4
    152 @ CHECK: ldr r0, Ltmp15
    153   adds r0, r0, #1
    154 
    155 @
    156 @ Constant Pools
    157 @
    158 @ CHECK: .section __TEXT,b,regular,pure_instructions
    159 @ CHECK: .align 2
    160 @ CHECK: .data_region
    161 @ CHECK-LABEL: Ltmp0:
    162 @ CHECK: .long 65537
    163 @ CHECK: .end_data_region
    164 
    165 @ CHECK: .section __TEXT,c,regular,pure_instructions
    166 @ CHECK: .align 2
    167 @ CHECK: .data_region
    168 @ CHECK-LABEL: Ltmp1:
    169 @ CHECK: .long 65538
    170 @ CHECK-LABEL: Ltmp2:
    171 @ CHECK: .long 65539
    172 @ CHECK: .end_data_region
    173 
    174 @ CHECK: .section __TEXT,d,regular,pure_instructions
    175 @ CHECK: .align 2
    176 @ CHECK: .data_region
    177 @ CHECK-LABEL: Ltmp3:
    178 @ CHECK: .long 65540
    179 @ CHECK-LABEL: Ltmp4:
    180 @ CHECK: .long 65540
    181 @ CHECK: .end_data_region
    182 
    183 @ CHECK: .section __TEXT,e,regular,pure_instructions
    184 @ CHECK: .align 2
    185 @ CHECK: .data_region
    186 @ CHECK-LABEL: Ltmp5:
    187 @ CHECK: .long 65542
    188 @ CHECK-LABEL: Ltmp6:
    189 @ CHECK: .long 65543
    190 @ CHECK: .end_data_region
    191 
    192 @ Should not switch to section because it has no constant pool
    193 @ CHECK-NOT: .section __TEXT,f,regular,pure_instructions
    194 
    195 @ CHECK: .section __TEXT,g,regular,pure_instructions
    196 @ CHECK: .align 2
    197 @ CHECK: .data_region
    198 @ CHECK-LABEL: Ltmp7:
    199 @ CHECK: .long foo
    200 @ CHECK: .end_data_region
    201 
    202 @ CHECK: .section __TEXT,h,regular,pure_instructions
    203 @ CHECK: .align 2
    204 @ CHECK: .data_region
    205 @ CHECK-LABEL: Ltmp8:
    206 @ CHECK: .long f5
    207 @ CHECK: .end_data_region
    208 
    209 @ CHECK: .section __TEXT,i,regular,pure_instructions
    210 @ CHECK: .align 2
    211 @ CHECK: .data_region
    212 @ CHECK-LABEL: Ltmp9:
    213 @ CHECK: .long f12
    214 @ CHECK: .end_data_region
    215 
    216 @ CHECK: .section __TEXT,j,regular,pure_instructions
    217 @ CHECK: .align 2
    218 @ CHECK: .data_region
    219 @ CHECK-LABEL: Ltmp10:
    220 @ CHECK: .long 257
    221 @ CHECK-LABEL: Ltmp11:
    222 @ CHECK: .long bar
    223 @ CHECK: .end_data_region
    224 
    225 @ CHECK: .section __TEXT,k,regular,pure_instructions
    226 @ CHECK: .align 2
    227 @ CHECK: .data_region
    228 @ CHECK-LABEL: Ltmp12:
    229 @ CHECK: .long 65544
    230 @ CHECK-LABEL: Ltmp13:
    231 @ CHECK: .long baz
    232 @ CHECK: .end_data_region
    233 
    234 @ CHECK: .section __TEXT,l,regular,pure_instructions
    235 @ CHECK: .align 2
    236 @ CHECK: .data_region
    237 @ CHECK-LABEL: Ltmp14:
    238 @ CHECK: .long 65545
    239 @ CHECK-LABEL: Ltmp15:
    240 @ CHECK: .long bar+4
    241 @ CHECK: .end_data_region
    242