Home | History | Annotate | Download | only in ARM
      1 ; RUN: llc -mtriple=thumbv7m-none-macho %s -o - -relocation-model=pic -disable-fp-elim | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-NON-FAST
      2 ; RUN: llc -mtriple=thumbv7m-none-macho -O0 %s -o - -relocation-model=pic -disable-fp-elim | FileCheck %s
      3 ; RUN: llc -mtriple=thumbv7m-none-macho -filetype=obj %s -o /dev/null
      4 
      5 @var = external global i32
      6 
      7 define i32 @test_litpool() minsize {
      8 ; CHECK-LABEL: test_litpool:
      9   %val = load i32, i32* @var
     10   ret i32 %val
     11 
     12   ; Lit-pool entries need to produce a "$non_lazy_ptr" version of the symbol.
     13 ; CHECK: LCPI0_0:
     14 ; CHECK-NEXT: .long L_var$non_lazy_ptr-(LPC0_0+4)
     15 }
     16 
     17 define i32 @test_movw_movt() {
     18 ; CHECK-LABEL: test_movw_movt:
     19   %val = load i32, i32* @var
     20   ret i32 %val
     21 
     22   ; movw/movt should also address their symbols MachO-style
     23 ; CHECK: movw [[RTMP:r[0-9]+]], :lower16:(L_var$non_lazy_ptr-(LPC1_0+4))
     24 ; CHECK: movt [[RTMP]], :upper16:(L_var$non_lazy_ptr-(LPC1_0+4))
     25 ; CHECK: LPC1_0:
     26 ; CHECK: add [[RTMP]], pc
     27 }
     28 
     29 declare void @llvm.trap()
     30 
     31 define void @test_trap() {
     32 ; CHECK-LABEL: test_trap:
     33 
     34   ; Bare-metal MachO gets compiled on top of normal MachO toolchain which
     35   ; understands trap natively.
     36   call void @llvm.trap()
     37 ; CHECK: trap
     38 
     39   ret void
     40 }
     41 
     42 define i32 @test_frame_ptr() {
     43 ; CHECK-LABEL: test_frame_ptr:
     44   call void @test_trap()
     45 
     46   ; Frame pointer is r7.
     47 ; CHECK: mov r7, sp
     48   ret i32 42
     49 }
     50 
     51 %big_arr = type [8 x i32]
     52 define void @test_two_areas(%big_arr* %addr) {
     53 ; CHECK-LABEL: test_two_areas:
     54   %val = load %big_arr, %big_arr* %addr
     55   call void @test_trap()
     56   store %big_arr %val, %big_arr* %addr
     57 
     58   ; This goes with the choice of r7 as FP (largely). FP and LR have to be stored
     59   ; consecutively on the stack for the frame record to be valid, which means we
     60   ; need the 2 register-save areas employed by iOS.
     61 ; CHECK-NON-FAST: push {r4, r5, r6, r7, lr}
     62 ; CHECK-NON-FAST: push.w {r8, r9, r10, r11}
     63 ; ...
     64 ; CHECK-NON-FAST: pop.w {r8, r9, r10, r11}
     65 ; CHECK-NON-FAST: pop {r4, r5, r6, r7, pc}
     66   ret void
     67 }
     68 
     69 define void @test_tail_call() {
     70 ; CHECK-LABEL: test_tail_call:
     71   tail call void @test_trap()
     72 
     73   ; Tail calls should be available and use Thumb2 branch.
     74 ; CHECK: b.w _test_trap
     75   ret void
     76 }
     77 
     78 define float @test_softfloat_calls(float %in) {
     79 ; CHECK-LABEL: test_softfloat_calls:
     80   %sum = fadd float %in, %in
     81 
     82   ; Soft-float calls should be GNU-style rather than RTABI and should not be the
     83   ; *vfp variants used for ARMv6 iOS.
     84 ; CHECK: bl ___addsf3{{$}}
     85   ret float %sum
     86 }
     87 
     88   ; Even bare-metal PIC needs GOT-like behaviour, in principle. Depends a bit on
     89   ; the use-case of course, but LLVM doesn't know what that is.
     90 ; CHECK: non_lazy_symbol_pointers
     91 ; CHECK: L_var$non_lazy_ptr:
     92 ; CHECK-NEXT:   .indirect_symbol _var
     93 
     94   ; All MachO objects should have this to give the linker leeway in removing
     95   ; dead code.
     96 ; CHECK: .subsections_via_symbols
     97