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