Home | History | Annotate | Download | only in ARM
      1 ; RUN: llc < %s -O0 -fast-isel-abort -relocation-model=dynamic-no-pic -mtriple=armv7-apple-ios | FileCheck %s --check-prefix=ARM
      2 ; RUN: llc < %s -O0 -fast-isel-abort -relocation-model=dynamic-no-pic -mtriple=armv7-linux-gnueabi | FileCheck %s --check-prefix=ARM
      3 ; RUN: llc < %s -O0 -fast-isel-abort -relocation-model=dynamic-no-pic -mtriple=thumbv7-apple-ios | FileCheck %s --check-prefix=THUMB
      4 ; RUN: llc < %s -O0 -fast-isel-abort -relocation-model=dynamic-no-pic -mtriple=armv7-apple-ios -arm-long-calls | FileCheck %s --check-prefix=ARM-LONG
      5 ; RUN: llc < %s -O0 -fast-isel-abort -relocation-model=dynamic-no-pic -mtriple=armv7-linux-gnueabi -arm-long-calls | FileCheck %s --check-prefix=ARM-LONG
      6 ; RUN: llc < %s -O0 -fast-isel-abort -relocation-model=dynamic-no-pic -mtriple=thumbv7-apple-ios -arm-long-calls | FileCheck %s --check-prefix=THUMB-LONG
      7 ; RUN: llc < %s -O0 -fast-isel-abort -relocation-model=dynamic-no-pic -mtriple=armv7-apple-ios -mattr=-vfp2 | FileCheck %s --check-prefix=ARM-NOVFP
      8 ; RUN: llc < %s -O0 -fast-isel-abort -relocation-model=dynamic-no-pic -mtriple=armv7-linux-gnueabi -mattr=-vfp2 | FileCheck %s --check-prefix=ARM-NOVFP
      9 ; RUN: llc < %s -O0 -fast-isel-abort -relocation-model=dynamic-no-pic -mtriple=thumbv7-apple-ios -mattr=-vfp2 | FileCheck %s --check-prefix=THUMB-NOVFP
     10 
     11 ; Note that some of these tests assume that relocations are either
     12 ; movw/movt or constant pool loads. Different platforms will select
     13 ; different approaches.
     14 
     15 define i32 @t0(i1 zeroext %a) nounwind {
     16   %1 = zext i1 %a to i32
     17   ret i32 %1
     18 }
     19 
     20 define i32 @t1(i8 signext %a) nounwind {
     21   %1 = sext i8 %a to i32
     22   ret i32 %1
     23 }
     24 
     25 define i32 @t2(i8 zeroext %a) nounwind {
     26   %1 = zext i8 %a to i32
     27   ret i32 %1
     28 }
     29 
     30 define i32 @t3(i16 signext %a) nounwind {
     31   %1 = sext i16 %a to i32
     32   ret i32 %1
     33 }
     34 
     35 define i32 @t4(i16 zeroext %a) nounwind {
     36   %1 = zext i16 %a to i32
     37   ret i32 %1
     38 }
     39 
     40 define void @foo(i8 %a, i16 %b) nounwind {
     41 ; ARM: foo
     42 ; THUMB: foo
     43 ;; Materialize i1 1
     44 ; ARM: movw r2, #1
     45 ;; zero-ext
     46 ; ARM: and r2, r2, #1
     47 ; THUMB: and r2, r2, #1
     48   %1 = call i32 @t0(i1 zeroext 1)
     49 ; ARM: sxtb	r2, r1
     50 ; ARM: mov r0, r2
     51 ; THUMB: sxtb	r2, r1
     52 ; THUMB: mov r0, r2
     53   %2 = call i32 @t1(i8 signext %a)
     54 ; ARM: and	r2, r1, #255
     55 ; ARM: mov r0, r2
     56 ; THUMB: and	r2, r1, #255
     57 ; THUMB: mov r0, r2
     58   %3 = call i32 @t2(i8 zeroext %a)
     59 ; ARM: sxth	r2, r1
     60 ; ARM: mov r0, r2
     61 ; THUMB: sxth	r2, r1
     62 ; THUMB: mov r0, r2
     63   %4 = call i32 @t3(i16 signext %b)
     64 ; ARM: uxth	r2, r1
     65 ; ARM: mov r0, r2
     66 ; THUMB: uxth	r2, r1
     67 ; THUMB: mov r0, r2
     68   %5 = call i32 @t4(i16 zeroext %b)
     69 
     70 ;; A few test to check materialization
     71 ;; Note: i1 1 was materialized with t1 call
     72 ; ARM: movw r1, #255
     73 %6 = call i32 @t2(i8 zeroext 255)
     74 ; ARM: movw r1, #65535
     75 ; THUMB: movw r1, #65535
     76 %7 = call i32 @t4(i16 zeroext 65535)
     77   ret void
     78 }
     79 
     80 define void @foo2() nounwind {
     81   %1 = call signext i16 @t5()
     82   %2 = call zeroext i16 @t6()
     83   %3 = call signext i8 @t7()
     84   %4 = call zeroext i8 @t8()
     85   %5 = call zeroext i1 @t9()
     86   ret void
     87 }
     88 
     89 declare signext i16 @t5();
     90 declare zeroext i16 @t6();
     91 declare signext i8 @t7();
     92 declare zeroext i8 @t8();
     93 declare zeroext i1 @t9();
     94 
     95 define i32 @t10() {
     96 entry:
     97 ; ARM: @t10
     98 ; ARM: movw [[R0:l?r[0-9]*]], #0
     99 ; ARM: movw [[R1:l?r[0-9]*]], #248
    100 ; ARM: movw [[R2:l?r[0-9]*]], #187
    101 ; ARM: movw [[R3:l?r[0-9]*]], #28
    102 ; ARM: movw [[R4:l?r[0-9]*]], #40
    103 ; ARM: movw [[R5:l?r[0-9]*]], #186
    104 ; ARM: and [[R0]], [[R0]], #255
    105 ; ARM: and [[R1]], [[R1]], #255
    106 ; ARM: and [[R2]], [[R2]], #255
    107 ; ARM: and [[R3]], [[R3]], #255
    108 ; ARM: and [[R4]], [[R4]], #255
    109 ; ARM: str [[R4]], [sp]
    110 ; ARM: and [[R4]], [[R5]], #255
    111 ; ARM: str [[R4]], [sp, #4]
    112 ; ARM: bl {{_?}}bar
    113 ; ARM-LONG: @t10
    114 ; ARM-LONG: {{(movw)|(ldr)}} [[R:l?r[0-9]*]], {{(:lower16:L_bar\$non_lazy_ptr)|(.LCPI)}}
    115 ; ARM-LONG: {{(movt [[R]], :upper16:L_bar\$non_lazy_ptr)?}}
    116 ; ARM-LONG: ldr [[R]], {{\[}}[[R]]{{\]}}
    117 ; ARM-LONG: blx [[R]]
    118 ; THUMB: @t10
    119 ; THUMB: movs [[R0:l?r[0-9]*]], #0
    120 ; THUMB: movt [[R0]], #0
    121 ; THUMB: movs [[R1:l?r[0-9]*]], #248
    122 ; THUMB: movt [[R1]], #0
    123 ; THUMB: movs [[R2:l?r[0-9]*]], #187
    124 ; THUMB: movt [[R2]], #0
    125 ; THUMB: movs [[R3:l?r[0-9]*]], #28
    126 ; THUMB: movt [[R3]], #0
    127 ; THUMB: movw [[R4:l?r[0-9]*]], #40
    128 ; THUMB: movt [[R4]], #0
    129 ; THUMB: movw [[R5:l?r[0-9]*]], #186
    130 ; THUMB: movt [[R5]], #0
    131 ; THUMB: and [[R0]], [[R0]], #255
    132 ; THUMB: and [[R1]], [[R1]], #255
    133 ; THUMB: and [[R2]], [[R2]], #255
    134 ; THUMB: and [[R3]], [[R3]], #255
    135 ; THUMB: and [[R4]], [[R4]], #255
    136 ; THUMB: str.w [[R4]], [sp]
    137 ; THUMB: and [[R4]], [[R5]], #255
    138 ; THUMB: str.w [[R4]], [sp, #4]
    139 ; THUMB: bl {{_?}}bar
    140 ; THUMB-LONG: @t10
    141 ; THUMB-LONG: {{(movw)|(ldr.n)}} [[R:l?r[0-9]*]], {{(:lower16:L_bar\$non_lazy_ptr)|(.LCPI)}}
    142 ; THUMB-LONG: {{(movt [[R]], :upper16:L_bar\$non_lazy_ptr)?}}
    143 ; THUMB-LONG: ldr{{(.w)?}} [[R]], {{\[}}[[R]]{{\]}}
    144 ; THUMB-LONG: blx [[R]]
    145   %call = call i32 @bar(i8 zeroext 0, i8 zeroext -8, i8 zeroext -69, i8 zeroext 28, i8 zeroext 40, i8 zeroext -70)
    146   ret i32 0
    147 }
    148 
    149 declare i32 @bar(i8 zeroext, i8 zeroext, i8 zeroext, i8 zeroext, i8 zeroext, i8 zeroext)
    150 
    151 define i32 @bar0(i32 %i) nounwind {
    152   ret i32 0
    153 }
    154 
    155 define void @foo3() uwtable {
    156 ; ARM: movw    r0, #0
    157 ; ARM: {{(movw r1, :lower16:_?bar0)|(ldr r1, .LCPI)}}
    158 ; ARM: {{(movt r1, :upper16:_?bar0)|(ldr r1, \[r1\])}}
    159 ; ARM: blx     r1
    160 ; THUMB: movs    r0, #0
    161 ; THUMB: {{(movw r1, :lower16:_?bar0)|(ldr.n r1, .LCPI)}}
    162 ; THUMB: {{(movt r1, :upper16:_?bar0)|(ldr r1, \[r1\])}}
    163 ; THUMB: blx     r1
    164   %fptr = alloca i32 (i32)*, align 8
    165   store i32 (i32)* @bar0, i32 (i32)** %fptr, align 8
    166   %1 = load i32 (i32)** %fptr, align 8
    167   %call = call i32 %1(i32 0)
    168   ret void
    169 }
    170 
    171 define i32 @LibCall(i32 %a, i32 %b) {
    172 entry:
    173 ; ARM: LibCall
    174 ; ARM: bl {{___udivsi3|__aeabi_uidiv}}
    175 ; ARM-LONG: LibCall
    176 ; ARM-LONG: {{(movw r2, :lower16:L___udivsi3\$non_lazy_ptr)|(ldr r2, .LCPI)}}
    177 ; ARM-LONG: {{(movt r2, :upper16:L___udivsi3\$non_lazy_ptr)?}}
    178 ; ARM-LONG: ldr r2, [r2]
    179 ; ARM-LONG: blx r2
    180 ; THUMB: LibCall
    181 ; THUMB: bl {{___udivsi3|__aeabi_uidiv}}
    182 ; THUMB-LONG: LibCall
    183 ; THUMB-LONG: {{(movw r2, :lower16:L___udivsi3\$non_lazy_ptr)|(ldr.n r2, .LCPI)}}
    184 ; THUMB-LONG: {{(movt r2, :upper16:L___udivsi3\$non_lazy_ptr)?}}
    185 ; THUMB-LONG: ldr r2, [r2]
    186 ; THUMB-LONG: blx r2
    187         %tmp1 = udiv i32 %a, %b         ; <i32> [#uses=1]
    188         ret i32 %tmp1
    189 }
    190 
    191 ; Test fastcc
    192 
    193 define fastcc void @fast_callee(float %i) ssp {
    194 entry:
    195 ; ARM: fast_callee
    196 ; ARM: vmov r0, s0
    197 ; THUMB: fast_callee
    198 ; THUMB: vmov r0, s0
    199 ; ARM-NOVFP: fast_callee
    200 ; ARM-NOVFP-NOT: s0
    201 ; THUMB-NOVFP: fast_callee
    202 ; THUMB-NOVFP-NOT: s0
    203   call void @print(float %i)
    204   ret void
    205 }
    206 
    207 define void @fast_caller() ssp {
    208 entry:
    209 ; ARM: fast_caller
    210 ; ARM: vldr s0,
    211 ; THUMB: fast_caller
    212 ; THUMB: vldr s0,
    213 ; ARM-NOVFP: fast_caller
    214 ; ARM-NOVFP: movw r0, #13107
    215 ; ARM-NOVFP: movt r0, #16611
    216 ; THUMB-NOVFP: fast_caller
    217 ; THUMB-NOVFP: movw r0, #13107
    218 ; THUMB-NOVFP: movt r0, #16611
    219   call fastcc void @fast_callee(float 0x401C666660000000)
    220   ret void
    221 }
    222 
    223 define void @no_fast_callee(float %i) ssp {
    224 entry:
    225 ; ARM: no_fast_callee
    226 ; ARM: vmov s0, r0
    227 ; THUMB: no_fast_callee
    228 ; THUMB: vmov s0, r0
    229 ; ARM-NOVFP: no_fast_callee
    230 ; ARM-NOVFP-NOT: s0
    231 ; THUMB-NOVFP: no_fast_callee
    232 ; THUMB-NOVFP-NOT: s0
    233   call void @print(float %i)
    234   ret void
    235 }
    236 
    237 define void @no_fast_caller() ssp {
    238 entry:
    239 ; ARM: no_fast_caller
    240 ; ARM: vmov r0, s0
    241 ; THUMB: no_fast_caller
    242 ; THUMB: vmov r0, s0
    243 ; ARM-NOVFP: no_fast_caller
    244 ; ARM-NOVFP: movw r0, #13107
    245 ; ARM-NOVFP: movt r0, #16611
    246 ; THUMB-NOVFP: no_fast_caller
    247 ; THUMB-NOVFP: movw r0, #13107
    248 ; THUMB-NOVFP: movt r0, #16611
    249   call void @no_fast_callee(float 0x401C666660000000)
    250   ret void
    251 }
    252 
    253 declare void @print(float)
    254