1*9880d681SAndroid Build Coastguard Worker; RUN: llc -mcpu=pwr7 -mattr=+altivec -mattr=-vsx < %s | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker 3*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-m:e-i64:64-n32:64" 4*9880d681SAndroid Build Coastguard Workertarget triple = "powerpc64le-unknown-linux-gnu" 5*9880d681SAndroid Build Coastguard Worker 6*9880d681SAndroid Build Coastguard Worker@g = common global ppc_fp128 0xM00000000000000000000000000000000, align 16 7*9880d681SAndroid Build Coastguard Worker 8*9880d681SAndroid Build Coastguard Workerdefine void @callee(ppc_fp128 %x) { 9*9880d681SAndroid Build Coastguard Workerentry: 10*9880d681SAndroid Build Coastguard Worker %x.addr = alloca ppc_fp128, align 16 11*9880d681SAndroid Build Coastguard Worker store ppc_fp128 %x, ppc_fp128* %x.addr, align 16 12*9880d681SAndroid Build Coastguard Worker %0 = load ppc_fp128, ppc_fp128* %x.addr, align 16 13*9880d681SAndroid Build Coastguard Worker store ppc_fp128 %0, ppc_fp128* @g, align 16 14*9880d681SAndroid Build Coastguard Worker ret void 15*9880d681SAndroid Build Coastguard Worker} 16*9880d681SAndroid Build Coastguard Worker; CHECK: @callee 17*9880d681SAndroid Build Coastguard Worker; CHECK: ld [[REG:[0-9]+]], .LC 18*9880d681SAndroid Build Coastguard Worker; CHECK: stfd 2, 8([[REG]]) 19*9880d681SAndroid Build Coastguard Worker; CHECK: stfd 1, 0([[REG]]) 20*9880d681SAndroid Build Coastguard Worker; CHECK: blr 21*9880d681SAndroid Build Coastguard Worker 22*9880d681SAndroid Build Coastguard Workerdefine void @caller() { 23*9880d681SAndroid Build Coastguard Workerentry: 24*9880d681SAndroid Build Coastguard Worker %0 = load ppc_fp128, ppc_fp128* @g, align 16 25*9880d681SAndroid Build Coastguard Worker call void @test(ppc_fp128 %0) 26*9880d681SAndroid Build Coastguard Worker ret void 27*9880d681SAndroid Build Coastguard Worker} 28*9880d681SAndroid Build Coastguard Worker; CHECK: @caller 29*9880d681SAndroid Build Coastguard Worker; CHECK: ld [[REG:[0-9]+]], .LC 30*9880d681SAndroid Build Coastguard Worker; CHECK: lfd 2, 8([[REG]]) 31*9880d681SAndroid Build Coastguard Worker; CHECK: lfd 1, 0([[REG]]) 32*9880d681SAndroid Build Coastguard Worker; CHECK: bl test 33*9880d681SAndroid Build Coastguard Worker 34*9880d681SAndroid Build Coastguard Workerdeclare void @test(ppc_fp128) 35*9880d681SAndroid Build Coastguard Worker 36*9880d681SAndroid Build Coastguard Workerdefine void @caller_const() { 37*9880d681SAndroid Build Coastguard Workerentry: 38*9880d681SAndroid Build Coastguard Worker call void @test(ppc_fp128 0xM3FF00000000000000000000000000000) 39*9880d681SAndroid Build Coastguard Worker ret void 40*9880d681SAndroid Build Coastguard Worker} 41*9880d681SAndroid Build Coastguard Worker; CHECK: .LCPI[[LC:[0-9]+]]_0: 42*9880d681SAndroid Build Coastguard Worker; CHECK: .long 1065353216 43*9880d681SAndroid Build Coastguard Worker; CHECK: .LCPI[[LC]]_1: 44*9880d681SAndroid Build Coastguard Worker; CHECK: .long 0 45*9880d681SAndroid Build Coastguard Worker; CHECK: @caller_const 46*9880d681SAndroid Build Coastguard Worker; CHECK: addi [[REG0:[0-9]+]], {{[0-9]+}}, .LCPI[[LC]]_0 47*9880d681SAndroid Build Coastguard Worker; CHECK: addi [[REG1:[0-9]+]], {{[0-9]+}}, .LCPI[[LC]]_1 48*9880d681SAndroid Build Coastguard Worker; CHECK: lfs 1, 0([[REG0]]) 49*9880d681SAndroid Build Coastguard Worker; CHECK: lfs 2, 0([[REG1]]) 50*9880d681SAndroid Build Coastguard Worker; CHECK: bl test 51*9880d681SAndroid Build Coastguard Worker 52*9880d681SAndroid Build Coastguard Workerdefine ppc_fp128 @result() { 53*9880d681SAndroid Build Coastguard Workerentry: 54*9880d681SAndroid Build Coastguard Worker %0 = load ppc_fp128, ppc_fp128* @g, align 16 55*9880d681SAndroid Build Coastguard Worker ret ppc_fp128 %0 56*9880d681SAndroid Build Coastguard Worker} 57*9880d681SAndroid Build Coastguard Worker; CHECK: @result 58*9880d681SAndroid Build Coastguard Worker; CHECK: ld [[REG:[0-9]+]], .LC 59*9880d681SAndroid Build Coastguard Worker; CHECK: lfd 1, 0([[REG]]) 60*9880d681SAndroid Build Coastguard Worker; CHECK: lfd 2, 8([[REG]]) 61*9880d681SAndroid Build Coastguard Worker; CHECK: blr 62*9880d681SAndroid Build Coastguard Worker 63*9880d681SAndroid Build Coastguard Workerdefine void @use_result() { 64*9880d681SAndroid Build Coastguard Workerentry: 65*9880d681SAndroid Build Coastguard Worker %call = tail call ppc_fp128 @test_result() #3 66*9880d681SAndroid Build Coastguard Worker store ppc_fp128 %call, ppc_fp128* @g, align 16 67*9880d681SAndroid Build Coastguard Worker ret void 68*9880d681SAndroid Build Coastguard Worker} 69*9880d681SAndroid Build Coastguard Worker; CHECK: @use_result 70*9880d681SAndroid Build Coastguard Worker; CHECK: bl test_result 71*9880d681SAndroid Build Coastguard Worker; CHECK: ld [[REG:[0-9]+]], .LC 72*9880d681SAndroid Build Coastguard Worker; CHECK: stfd 2, 8([[REG]]) 73*9880d681SAndroid Build Coastguard Worker; CHECK: stfd 1, 0([[REG]]) 74*9880d681SAndroid Build Coastguard Worker; CHECK: blr 75*9880d681SAndroid Build Coastguard Worker 76*9880d681SAndroid Build Coastguard Workerdeclare ppc_fp128 @test_result() 77*9880d681SAndroid Build Coastguard Worker 78*9880d681SAndroid Build Coastguard Workerdefine void @caller_result() { 79*9880d681SAndroid Build Coastguard Workerentry: 80*9880d681SAndroid Build Coastguard Worker %call = tail call ppc_fp128 @test_result() 81*9880d681SAndroid Build Coastguard Worker tail call void @test(ppc_fp128 %call) 82*9880d681SAndroid Build Coastguard Worker ret void 83*9880d681SAndroid Build Coastguard Worker} 84*9880d681SAndroid Build Coastguard Worker; CHECK: @caller_result 85*9880d681SAndroid Build Coastguard Worker; CHECK: bl test_result 86*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: nop 87*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: bl test 88*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: nop 89*9880d681SAndroid Build Coastguard Worker 90*9880d681SAndroid Build Coastguard Workerdefine i128 @convert_from(ppc_fp128 %x) { 91*9880d681SAndroid Build Coastguard Workerentry: 92*9880d681SAndroid Build Coastguard Worker %0 = bitcast ppc_fp128 %x to i128 93*9880d681SAndroid Build Coastguard Worker ret i128 %0 94*9880d681SAndroid Build Coastguard Worker} 95*9880d681SAndroid Build Coastguard Worker; CHECK: @convert_from 96*9880d681SAndroid Build Coastguard Worker; CHECK: stfd 1, [[OFF1:.*]](1) 97*9880d681SAndroid Build Coastguard Worker; CHECK: stfd 2, [[OFF2:.*]](1) 98*9880d681SAndroid Build Coastguard Worker; CHECK: ld 3, [[OFF1]](1) 99*9880d681SAndroid Build Coastguard Worker; CHECK: ld 4, [[OFF2]](1) 100*9880d681SAndroid Build Coastguard Worker; CHECK: blr 101*9880d681SAndroid Build Coastguard Worker 102*9880d681SAndroid Build Coastguard Workerdefine ppc_fp128 @convert_to(i128 %x) { 103*9880d681SAndroid Build Coastguard Workerentry: 104*9880d681SAndroid Build Coastguard Worker %0 = bitcast i128 %x to ppc_fp128 105*9880d681SAndroid Build Coastguard Worker ret ppc_fp128 %0 106*9880d681SAndroid Build Coastguard Worker} 107*9880d681SAndroid Build Coastguard Worker; CHECK: convert_to: 108*9880d681SAndroid Build Coastguard Worker; CHECK: std 3, [[OFF1:.*]](1) 109*9880d681SAndroid Build Coastguard Worker; CHECK: std 4, [[OFF2:.*]](1) 110*9880d681SAndroid Build Coastguard Worker; CHECK: ori 2, 2, 0 111*9880d681SAndroid Build Coastguard Worker; CHECK: lfd 1, [[OFF1]](1) 112*9880d681SAndroid Build Coastguard Worker; CHECK: lfd 2, [[OFF2]](1) 113*9880d681SAndroid Build Coastguard Worker; CHECK: blr 114*9880d681SAndroid Build Coastguard Worker 115*9880d681SAndroid Build Coastguard Workerdefine ppc_fp128 @convert_to2(i128 %x) { 116*9880d681SAndroid Build Coastguard Workerentry: 117*9880d681SAndroid Build Coastguard Worker %shl = shl i128 %x, 1 118*9880d681SAndroid Build Coastguard Worker %0 = bitcast i128 %shl to ppc_fp128 119*9880d681SAndroid Build Coastguard Worker ret ppc_fp128 %0 120*9880d681SAndroid Build Coastguard Worker} 121*9880d681SAndroid Build Coastguard Worker 122*9880d681SAndroid Build Coastguard Worker; CHECK: convert_to2: 123*9880d681SAndroid Build Coastguard Worker; CHECK: std 3, [[OFF1:.*]](1) 124*9880d681SAndroid Build Coastguard Worker; CHECK: std 5, [[OFF2:.*]](1) 125*9880d681SAndroid Build Coastguard Worker; CHECK: ori 2, 2, 0 126*9880d681SAndroid Build Coastguard Worker; CHECK: lfd 1, [[OFF1]](1) 127*9880d681SAndroid Build Coastguard Worker; CHECK: lfd 2, [[OFF2]](1) 128*9880d681SAndroid Build Coastguard Worker; CHECK: blr 129*9880d681SAndroid Build Coastguard Worker 130*9880d681SAndroid Build Coastguard Workerdefine double @convert_vector(<4 x i32> %x) { 131*9880d681SAndroid Build Coastguard Workerentry: 132*9880d681SAndroid Build Coastguard Worker %cast = bitcast <4 x i32> %x to ppc_fp128 133*9880d681SAndroid Build Coastguard Worker %conv = fptrunc ppc_fp128 %cast to double 134*9880d681SAndroid Build Coastguard Worker ret double %conv 135*9880d681SAndroid Build Coastguard Worker} 136*9880d681SAndroid Build Coastguard Worker; CHECK: @convert_vector 137*9880d681SAndroid Build Coastguard Worker; CHECK: addi [[REG:[0-9]+]], 1, [[OFF:.*]] 138*9880d681SAndroid Build Coastguard Worker; CHECK: stvx 2, 0, [[REG]] 139*9880d681SAndroid Build Coastguard Worker; CHECK: lfd 1, [[OFF]](1) 140*9880d681SAndroid Build Coastguard Worker; CHECK: blr 141*9880d681SAndroid Build Coastguard Worker 142*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.va_start(i8*) 143*9880d681SAndroid Build Coastguard Worker 144*9880d681SAndroid Build Coastguard Workerdefine double @vararg(i32 %a, ...) { 145*9880d681SAndroid Build Coastguard Workerentry: 146*9880d681SAndroid Build Coastguard Worker %va = alloca i8*, align 8 147*9880d681SAndroid Build Coastguard Worker %va1 = bitcast i8** %va to i8* 148*9880d681SAndroid Build Coastguard Worker call void @llvm.va_start(i8* %va1) 149*9880d681SAndroid Build Coastguard Worker %arg = va_arg i8** %va, ppc_fp128 150*9880d681SAndroid Build Coastguard Worker %conv = fptrunc ppc_fp128 %arg to double 151*9880d681SAndroid Build Coastguard Worker ret double %conv 152*9880d681SAndroid Build Coastguard Worker} 153*9880d681SAndroid Build Coastguard Worker; CHECK: @vararg 154*9880d681SAndroid Build Coastguard Worker; CHECK: lfd 1, 0({{[0-9]+}}) 155*9880d681SAndroid Build Coastguard Worker; CHECK: blr 156*9880d681SAndroid Build Coastguard Worker 157