Home | History | Annotate | Download | only in ARM
      1 ; RUN: llc -mtriple=thumbv7-apple-none-macho < %s | FileCheck %s
      2 ; RUN: llc -mtriple=thumbv6m-apple-none-macho -disable-fp-elim < %s | FileCheck %s --check-prefix=CHECK-T1
      3 ; RUN: llc -mtriple=thumbv7-apple-darwin-ios -disable-fp-elim < %s | FileCheck %s --check-prefix=CHECK-IOS
      4 ; RUN: llc -mtriple=thumbv7--linux-gnueabi -disable-fp-elim < %s | FileCheck %s --check-prefix=CHECK-LINUX
      5 
      6 
      7 declare void @bar(i8*)
      8 
      9 %bigVec = type [2 x double]
     10 
     11 @var = global %bigVec zeroinitializer
     12 
     13 define void @check_simple() minsize {
     14 ; CHECK-LABEL: check_simple:
     15 ; CHECK: push.w {r7, r8, r9, r10, r11, lr}
     16 ; CHECK-NOT: sub sp, sp,
     17 ; ...
     18 ; CHECK-NOT: add sp, sp,
     19 ; CHECK: pop.w {r0, r1, r2, r3, r11, pc}
     20 
     21 ; CHECK-T1-LABEL: check_simple:
     22 ; CHECK-T1: push {r3, r4, r5, r6, r7, lr}
     23 ; CHECK-T1: add r7, sp, #16
     24 ; CHECK-T1-NOT: sub sp, sp,
     25 ; ...
     26 ; CHECK-T1-NOT: add sp, sp,
     27 ; CHECK-T1: pop {r0, r1, r2, r3, r7, pc}
     28 
     29   ; iOS always has a frame pointer and messing with the push affects
     30   ; how it's set in the prologue. Make sure we get that right.
     31 ; CHECK-IOS-LABEL: check_simple:
     32 ; CHECK-IOS: push {r3, r4, r5, r6, r7, lr}
     33 ; CHECK-NOT: sub sp,
     34 ; CHECK-IOS: add r7, sp, #16
     35 ; CHECK-NOT: sub sp,
     36 ; ...
     37 ; CHECK-NOT: add sp,
     38 ; CHEC: pop {r3, r4, r5, r6, r7, pc}
     39 
     40   %var = alloca i8, i32 16
     41   call void @bar(i8* %var)
     42   ret void
     43 }
     44 
     45 define void @check_simple_too_big() minsize {
     46 ; CHECK-LABEL: check_simple_too_big:
     47 ; CHECK: push.w {r11, lr}
     48 ; CHECK: sub sp,
     49 ; ...
     50 ; CHECK: add sp,
     51 ; CHECK: pop.w {r11, pc}
     52   %var = alloca i8, i32 64
     53   call void @bar(i8* %var)
     54   ret void
     55 }
     56 
     57 define void @check_vfp_fold() minsize {
     58 ; CHECK-LABEL: check_vfp_fold:
     59 ; CHECK: push {r[[GLOBREG:[0-9]+]], lr}
     60 ; CHECK: vpush {d6, d7, d8, d9}
     61 ; CHECK-NOT: sub sp,
     62 ; ...
     63 ; CHECK: vldmia r[[GLOBREG]], {d8, d9}
     64 ; ...
     65 ; CHECK-NOT: add sp,
     66 ; CHECK: vpop {d6, d7, d8, d9}
     67 ; CHECKL pop {r[[GLOBREG]], pc}
     68 
     69   ; iOS uses aligned NEON stores here, which is convenient since we
     70   ; want to make sure that works too.
     71 ; CHECK-IOS-LABEL: check_vfp_fold:
     72 ; CHECK-IOS: push {r0, r1, r2, r3, r4, r7, lr}
     73 ; CHECK-IOS: sub.w r4, sp, #16
     74 ; CHECK-IOS: bic r4, r4, #15
     75 ; CHECK-IOS: mov sp, r4
     76 ; CHECK-IOS: vst1.64 {d8, d9}, [r4:128]
     77 ; ...
     78 ; CHECK-IOS: add r4, sp, #16
     79 ; CHECK-IOS: vld1.64 {d8, d9}, [r4:128]
     80 ; CHECK-IOS: mov sp, r4
     81 ; CHECK-IOS: pop {r4, r7, pc}
     82 
     83   %var = alloca i8, i32 16
     84 
     85   %tmp = load %bigVec* @var
     86   call void @bar(i8* %var)
     87   store %bigVec %tmp, %bigVec* @var
     88 
     89   ret void
     90 }
     91 
     92 ; This function should use just enough space that the "add sp, sp, ..." could be
     93 ; folded in except that doing so would clobber the value being returned.
     94 define i64 @check_no_return_clobber() minsize {
     95 ; CHECK-LABEL: check_no_return_clobber:
     96 ; CHECK: push.w {r5, r6, r7, r8, r9, r10, r11, lr}
     97 ; CHECK-NOT: sub sp,
     98 ; ...
     99 ; CHECK: add sp, #24
    100 ; CHECK: pop.w {r11, pc}
    101 
    102   ; Just to keep iOS FileCheck within previous function:
    103 ; CHECK-IOS-LABEL: check_no_return_clobber:
    104 
    105   %var = alloca i8, i32 20
    106   call void @bar(i8* %var)
    107   ret i64 0
    108 }
    109 
    110 define arm_aapcs_vfpcc double @check_vfp_no_return_clobber() minsize {
    111 ; CHECK-LABEL: check_vfp_no_return_clobber:
    112 ; CHECK: push {r[[GLOBREG:[0-9]+]], lr}
    113 ; CHECK: vpush {d0, d1, d2, d3, d4, d5, d6, d7, d8, d9}
    114 ; CHECK-NOT: sub sp,
    115 ; ...
    116 ; CHECK: add sp, #64
    117 ; CHECK: vpop {d8, d9}
    118 ; CHECK: pop {r[[GLOBREG]], pc}
    119 
    120   %var = alloca i8, i32 64
    121 
    122   %tmp = load %bigVec* @var
    123   call void @bar(i8* %var)
    124   store %bigVec %tmp, %bigVec* @var
    125 
    126   ret double 1.0
    127 }
    128 
    129 @dbl = global double 0.0
    130 
    131 ; PR18136: there was a bug determining where the first eligible pop in a
    132 ; basic-block was when the entire block was epilogue code.
    133 define void @test_fold_point(i1 %tst) minsize {
    134 ; CHECK-LABEL: test_fold_point:
    135 
    136   ; Important to check for beginning of basic block, because if it gets
    137   ; if-converted the test is probably no longer checking what it should.
    138 ; CHECK: {{LBB[0-9]+_2}}:
    139 ; CHECK-NEXT: vpop {d7, d8}
    140 ; CHECK-NEXT: pop {r4, pc}
    141 
    142   ; With a guaranteed frame-pointer, we want to make sure that its offset in the
    143   ; push block is correct, even if a few registers have been tacked onto a later
    144   ; vpush (PR18160).
    145 ; CHECK-IOS-LABEL: test_fold_point:
    146 ; CHECK-IOS: push {r4, r7, lr}
    147 ; CHECK-IOS-NEXT: add r7, sp, #4
    148 ; CHECK-IOS-NEXT: vpush {d7, d8}
    149 
    150   ; We want some memory so there's a stack adjustment to fold...
    151   %var = alloca i8, i32 8
    152 
    153   ; We want a long-lived floating register so that a callee-saved dN is used and
    154   ; there's both a vpop and a pop.
    155   %live_val = load double* @dbl
    156   br i1 %tst, label %true, label %end
    157 true:
    158   call void @bar(i8* %var)
    159   store double %live_val, double* @dbl
    160   br label %end
    161 end:
    162   ; We want the epilogue to be the only thing in a basic block so that we hit
    163   ; the correct edge-case (first inst in block is correct one to adjust).
    164   ret void
    165 }
    166 
    167 define void @test_varsize(...) minsize {
    168 ; CHECK-T1-LABEL: test_varsize:
    169 ; CHECK-T1: sub	sp, #16
    170 ; CHECK-T1: push	{r2, r3, r4, r5, r7, lr}
    171 ; ...
    172 ; CHECK-T1: pop	{r2, r3, r4, r5, r7}
    173 ; CHECK-T1: pop	{r3}
    174 ; CHECK-T1: add	sp, #16
    175 ; CHECK-T1: bx	r3
    176 
    177 ; CHECK-LABEL: test_varsize:
    178 ; CHECK: sub	sp, #16
    179 ; CHECK: push.w {r9, r10, r11, lr}
    180 ; ...
    181 ; CHECK: pop.w	{r2, r3, r11, lr}
    182 ; CHECK: add	sp, #16
    183 ; CHECK: bx	lr
    184 
    185   %var = alloca i8, i32 8
    186   call void @bar(i8* %var)
    187   ret void
    188 }
    189 
    190 %"MyClass" = type { i8*, i32, i32, float, float, float, [2 x i8], i32, i32* }
    191 
    192 declare float @foo()
    193 
    194 declare void @bar3()
    195 
    196 declare %"MyClass"* @bar2(%"MyClass"* returned, i16*, i32, float, float, i32, i32, i1 zeroext, i1 zeroext, i32)
    197 
    198 define fastcc float @check_vfp_no_return_clobber2(i16* %r, i16* %chars, i32 %length, i1 zeroext %flag) minsize {
    199 entry:
    200 ; CHECK-LINUX-LABEL: check_vfp_no_return_clobber2
    201 ; CHECK-LINUX: vpush	{d0, d1, d2, d3, d4, d5, d6, d7, d8}
    202 ; CHECK-NOT: sub sp,
    203 ; ...
    204 ; CHECK-LINUX: add sp
    205 ; CHECK-LINUX: vpop {d8}
    206   %run = alloca %"MyClass", align 4
    207   %call = call %"MyClass"* @bar2(%"MyClass"* %run, i16* %chars, i32 %length, float 0.000000e+00, float 0.000000e+00, i32 1, i32 1, i1 zeroext false, i1 zeroext true, i32 3)
    208   %call1 = call float @foo()
    209   %cmp = icmp eq %"MyClass"* %run, null
    210   br i1 %cmp, label %exit, label %if.then
    211 
    212 if.then:                                          ; preds = %entry
    213   call void @bar3()
    214   br label %exit
    215 
    216 exit:                                             ; preds = %if.then, %entry
    217   ret float %call1
    218 }
    219