1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -O0 -fast-isel-abort=1 -relocation-model=dynamic-no-pic -mtriple=armv7-apple-ios -verify-machineinstrs | FileCheck %s --check-prefix=ARM --check-prefix=ARM-MACHO 2*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -O0 -fast-isel-abort=1 -relocation-model=dynamic-no-pic -mtriple=armv7-linux-gnueabi -verify-machineinstrs | FileCheck %s --check-prefix=ARM --check-prefix=ARM-ELF 3*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -O0 -fast-isel-abort=1 -relocation-model=dynamic-no-pic -mtriple=thumbv7-apple-ios -verify-machineinstrs | FileCheck %s --check-prefix=THUMB 4*9880d681SAndroid Build Coastguard Worker 5*9880d681SAndroid Build Coastguard Worker; Very basic fast-isel functionality. 6*9880d681SAndroid Build Coastguard Workerdefine i32 @test0(i32 %a, i32 %b) nounwind { 7*9880d681SAndroid Build Coastguard Workerentry: 8*9880d681SAndroid Build Coastguard Worker %a.addr = alloca i32, align 4 9*9880d681SAndroid Build Coastguard Worker %b.addr = alloca i32, align 4 10*9880d681SAndroid Build Coastguard Worker store i32 %a, i32* %a.addr 11*9880d681SAndroid Build Coastguard Worker store i32 %b, i32* %b.addr 12*9880d681SAndroid Build Coastguard Worker %tmp = load i32, i32* %a.addr 13*9880d681SAndroid Build Coastguard Worker %tmp1 = load i32, i32* %b.addr 14*9880d681SAndroid Build Coastguard Worker %add = add nsw i32 %tmp, %tmp1 15*9880d681SAndroid Build Coastguard Worker ret i32 %add 16*9880d681SAndroid Build Coastguard Worker} 17*9880d681SAndroid Build Coastguard Worker 18*9880d681SAndroid Build Coastguard Worker; Check truncate to bool 19*9880d681SAndroid Build Coastguard Workerdefine void @test1(i32 %tmp) nounwind { 20*9880d681SAndroid Build Coastguard Workerentry: 21*9880d681SAndroid Build Coastguard Worker%tobool = trunc i32 %tmp to i1 22*9880d681SAndroid Build Coastguard Workerbr i1 %tobool, label %if.then, label %if.end 23*9880d681SAndroid Build Coastguard Worker 24*9880d681SAndroid Build Coastguard Workerif.then: ; preds = %entry 25*9880d681SAndroid Build Coastguard Workercall void @test1(i32 0) 26*9880d681SAndroid Build Coastguard Workerbr label %if.end 27*9880d681SAndroid Build Coastguard Worker 28*9880d681SAndroid Build Coastguard Workerif.end: ; preds = %if.then, %entry 29*9880d681SAndroid Build Coastguard Workerret void 30*9880d681SAndroid Build Coastguard Worker; ARM-LABEL: test1: 31*9880d681SAndroid Build Coastguard Worker; ARM: tst r0, #1 32*9880d681SAndroid Build Coastguard Worker; THUMB-LABEL: test1: 33*9880d681SAndroid Build Coastguard Worker; THUMB: tst.w r0, #1 34*9880d681SAndroid Build Coastguard Worker} 35*9880d681SAndroid Build Coastguard Worker 36*9880d681SAndroid Build Coastguard Worker; Check some simple operations with immediates 37*9880d681SAndroid Build Coastguard Workerdefine void @test2(i32 %tmp, i32* %ptr) nounwind { 38*9880d681SAndroid Build Coastguard Worker; THUMB-LABEL: test2: 39*9880d681SAndroid Build Coastguard Worker; ARM-LABEL: test2: 40*9880d681SAndroid Build Coastguard Worker 41*9880d681SAndroid Build Coastguard Workerb1: 42*9880d681SAndroid Build Coastguard Worker %a = add i32 %tmp, 4096 43*9880d681SAndroid Build Coastguard Worker store i32 %a, i32* %ptr 44*9880d681SAndroid Build Coastguard Worker br label %b2 45*9880d681SAndroid Build Coastguard Worker 46*9880d681SAndroid Build Coastguard Worker; THUMB: add.w {{.*}} #4096 47*9880d681SAndroid Build Coastguard Worker; ARM: add {{.*}} #4096 48*9880d681SAndroid Build Coastguard Worker 49*9880d681SAndroid Build Coastguard Workerb2: 50*9880d681SAndroid Build Coastguard Worker %b = add i32 %tmp, 4095 51*9880d681SAndroid Build Coastguard Worker store i32 %b, i32* %ptr 52*9880d681SAndroid Build Coastguard Worker br label %b3 53*9880d681SAndroid Build Coastguard Worker; THUMB: addw {{.*}} #4095 54*9880d681SAndroid Build Coastguard Worker; ARM: movw {{.*}} #4095 55*9880d681SAndroid Build Coastguard Worker; ARM: add 56*9880d681SAndroid Build Coastguard Worker 57*9880d681SAndroid Build Coastguard Workerb3: 58*9880d681SAndroid Build Coastguard Worker %c = or i32 %tmp, 4 59*9880d681SAndroid Build Coastguard Worker store i32 %c, i32* %ptr 60*9880d681SAndroid Build Coastguard Worker ret void 61*9880d681SAndroid Build Coastguard Worker 62*9880d681SAndroid Build Coastguard Worker; THUMB: orr {{.*}} #4 63*9880d681SAndroid Build Coastguard Worker; ARM: orr {{.*}} #4 64*9880d681SAndroid Build Coastguard Worker} 65*9880d681SAndroid Build Coastguard Worker 66*9880d681SAndroid Build Coastguard Workerdefine void @test3(i32 %tmp, i32* %ptr1, i16* %ptr2, i8* %ptr3) nounwind { 67*9880d681SAndroid Build Coastguard Worker; THUMB-LABEL: test3: 68*9880d681SAndroid Build Coastguard Worker; ARM-LABEL: test3: 69*9880d681SAndroid Build Coastguard Worker 70*9880d681SAndroid Build Coastguard Workerbb1: 71*9880d681SAndroid Build Coastguard Worker %a1 = trunc i32 %tmp to i16 72*9880d681SAndroid Build Coastguard Worker %a2 = trunc i16 %a1 to i8 73*9880d681SAndroid Build Coastguard Worker %a3 = trunc i8 %a2 to i1 74*9880d681SAndroid Build Coastguard Worker %a4 = zext i1 %a3 to i8 75*9880d681SAndroid Build Coastguard Worker store i8 %a4, i8* %ptr3 76*9880d681SAndroid Build Coastguard Worker %a5 = zext i8 %a4 to i16 77*9880d681SAndroid Build Coastguard Worker store i16 %a5, i16* %ptr2 78*9880d681SAndroid Build Coastguard Worker %a6 = zext i16 %a5 to i32 79*9880d681SAndroid Build Coastguard Worker store i32 %a6, i32* %ptr1 80*9880d681SAndroid Build Coastguard Worker br label %bb2 81*9880d681SAndroid Build Coastguard Worker 82*9880d681SAndroid Build Coastguard Worker; THUMB: and 83*9880d681SAndroid Build Coastguard Worker; THUMB: strb 84*9880d681SAndroid Build Coastguard Worker; THUMB: and{{.*}}, #255 85*9880d681SAndroid Build Coastguard Worker; THUMB: strh 86*9880d681SAndroid Build Coastguard Worker; THUMB: uxth 87*9880d681SAndroid Build Coastguard Worker; ARM: and 88*9880d681SAndroid Build Coastguard Worker; ARM: strb 89*9880d681SAndroid Build Coastguard Worker; ARM: and{{.*}}, #255 90*9880d681SAndroid Build Coastguard Worker; ARM: strh 91*9880d681SAndroid Build Coastguard Worker; ARM: uxth 92*9880d681SAndroid Build Coastguard Worker 93*9880d681SAndroid Build Coastguard Workerbb2: 94*9880d681SAndroid Build Coastguard Worker %b1 = trunc i32 %tmp to i16 95*9880d681SAndroid Build Coastguard Worker %b2 = trunc i16 %b1 to i8 96*9880d681SAndroid Build Coastguard Worker store i8 %b2, i8* %ptr3 97*9880d681SAndroid Build Coastguard Worker %b3 = sext i8 %b2 to i16 98*9880d681SAndroid Build Coastguard Worker store i16 %b3, i16* %ptr2 99*9880d681SAndroid Build Coastguard Worker %b4 = sext i16 %b3 to i32 100*9880d681SAndroid Build Coastguard Worker store i32 %b4, i32* %ptr1 101*9880d681SAndroid Build Coastguard Worker br label %bb3 102*9880d681SAndroid Build Coastguard Worker 103*9880d681SAndroid Build Coastguard Worker; THUMB: strb 104*9880d681SAndroid Build Coastguard Worker; THUMB: sxtb 105*9880d681SAndroid Build Coastguard Worker; THUMB: strh 106*9880d681SAndroid Build Coastguard Worker; THUMB: sxth 107*9880d681SAndroid Build Coastguard Worker; ARM: strb 108*9880d681SAndroid Build Coastguard Worker; ARM: sxtb 109*9880d681SAndroid Build Coastguard Worker; ARM: strh 110*9880d681SAndroid Build Coastguard Worker; ARM: sxth 111*9880d681SAndroid Build Coastguard Worker 112*9880d681SAndroid Build Coastguard Workerbb3: 113*9880d681SAndroid Build Coastguard Worker %c1 = load i8, i8* %ptr3 114*9880d681SAndroid Build Coastguard Worker %c2 = load i16, i16* %ptr2 115*9880d681SAndroid Build Coastguard Worker %c3 = load i32, i32* %ptr1 116*9880d681SAndroid Build Coastguard Worker %c4 = zext i8 %c1 to i32 117*9880d681SAndroid Build Coastguard Worker %c5 = sext i16 %c2 to i32 118*9880d681SAndroid Build Coastguard Worker %c6 = add i32 %c4, %c5 119*9880d681SAndroid Build Coastguard Worker %c7 = sub i32 %c3, %c6 120*9880d681SAndroid Build Coastguard Worker store i32 %c7, i32* %ptr1 121*9880d681SAndroid Build Coastguard Worker ret void 122*9880d681SAndroid Build Coastguard Worker 123*9880d681SAndroid Build Coastguard Worker; THUMB: ldrb 124*9880d681SAndroid Build Coastguard Worker; THUMB: ldrh 125*9880d681SAndroid Build Coastguard Worker; THUMB: and{{.*}}, #255 126*9880d681SAndroid Build Coastguard Worker; THUMB: sxth 127*9880d681SAndroid Build Coastguard Worker; THUMB: add 128*9880d681SAndroid Build Coastguard Worker; THUMB: sub 129*9880d681SAndroid Build Coastguard Worker; ARM: ldrb 130*9880d681SAndroid Build Coastguard Worker; ARM: ldrh 131*9880d681SAndroid Build Coastguard Worker; ARM: and{{.*}}, #255 132*9880d681SAndroid Build Coastguard Worker; ARM: sxth 133*9880d681SAndroid Build Coastguard Worker; ARM: add 134*9880d681SAndroid Build Coastguard Worker; ARM: sub 135*9880d681SAndroid Build Coastguard Worker} 136*9880d681SAndroid Build Coastguard Worker 137*9880d681SAndroid Build Coastguard Worker; Check loads/stores with globals 138*9880d681SAndroid Build Coastguard Worker@test4g = external global i32 139*9880d681SAndroid Build Coastguard Worker 140*9880d681SAndroid Build Coastguard Workerdefine void @test4() { 141*9880d681SAndroid Build Coastguard Worker %a = load i32, i32* @test4g 142*9880d681SAndroid Build Coastguard Worker %b = add i32 %a, 1 143*9880d681SAndroid Build Coastguard Worker store i32 %b, i32* @test4g 144*9880d681SAndroid Build Coastguard Worker ret void 145*9880d681SAndroid Build Coastguard Worker 146*9880d681SAndroid Build Coastguard Worker 147*9880d681SAndroid Build Coastguard Worker; Note that relocations are either movw/movt or constant pool 148*9880d681SAndroid Build Coastguard Worker; loads. Different platforms will select different approaches. 149*9880d681SAndroid Build Coastguard Worker 150*9880d681SAndroid Build Coastguard Worker; THUMB: {{(movw r0, :lower16:L_test4g\$non_lazy_ptr)|(ldr.n r0, .LCPI)}} 151*9880d681SAndroid Build Coastguard Worker; THUMB: {{(movt r0, :upper16:L_test4g\$non_lazy_ptr)?}} 152*9880d681SAndroid Build Coastguard Worker; THUMB: ldr r0, [r0] 153*9880d681SAndroid Build Coastguard Worker; THUMB: ldr r1, [r0] 154*9880d681SAndroid Build Coastguard Worker; THUMB: adds r1, #1 155*9880d681SAndroid Build Coastguard Worker; THUMB: str r1, [r0] 156*9880d681SAndroid Build Coastguard Worker 157*9880d681SAndroid Build Coastguard Worker; ARM-MACHO: {{(movw r0, :lower16:L_test4g\$non_lazy_ptr)|(ldr r0, .LCPI)}} 158*9880d681SAndroid Build Coastguard Worker; ARM-MACHO: {{(movt r0, :upper16:L_test4g\$non_lazy_ptr)?}} 159*9880d681SAndroid Build Coastguard Worker; ARM-MACHO: ldr r0, [r0] 160*9880d681SAndroid Build Coastguard Worker 161*9880d681SAndroid Build Coastguard Worker; ARM-ELF: movw r0, :lower16:test4g 162*9880d681SAndroid Build Coastguard Worker; ARM-ELF: movt r0, :upper16:test4g 163*9880d681SAndroid Build Coastguard Worker 164*9880d681SAndroid Build Coastguard Worker; ARM: ldr r1, [r0] 165*9880d681SAndroid Build Coastguard Worker; ARM: add r1, r1, #1 166*9880d681SAndroid Build Coastguard Worker; ARM: str r1, [r0] 167*9880d681SAndroid Build Coastguard Worker} 168*9880d681SAndroid Build Coastguard Worker 169*9880d681SAndroid Build Coastguard Worker; ARM: @urem_fold 170*9880d681SAndroid Build Coastguard Worker; THUMB: @urem_fold 171*9880d681SAndroid Build Coastguard Worker; ARM: and r0, r0, #31 172*9880d681SAndroid Build Coastguard Worker; THUMB: and r0, r0, #31 173*9880d681SAndroid Build Coastguard Workerdefine i32 @urem_fold(i32 %a) nounwind { 174*9880d681SAndroid Build Coastguard Worker %rem = urem i32 %a, 32 175*9880d681SAndroid Build Coastguard Worker ret i32 %rem 176*9880d681SAndroid Build Coastguard Worker} 177*9880d681SAndroid Build Coastguard Worker 178*9880d681SAndroid Build Coastguard Workerdefine i32 @trap_intrinsic() noreturn nounwind { 179*9880d681SAndroid Build Coastguard Workerentry: 180*9880d681SAndroid Build Coastguard Worker; ARM: @trap_intrinsic 181*9880d681SAndroid Build Coastguard Worker; THUMB: @trap_intrinsic 182*9880d681SAndroid Build Coastguard Worker; ARM: trap 183*9880d681SAndroid Build Coastguard Worker; THUMB: trap 184*9880d681SAndroid Build Coastguard Worker tail call void @llvm.trap( ) 185*9880d681SAndroid Build Coastguard Worker unreachable 186*9880d681SAndroid Build Coastguard Worker} 187*9880d681SAndroid Build Coastguard Worker 188*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.trap() nounwind 189