1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -march=ppc64 | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -march=ppc64 -mcpu=pwr7 | FileCheck %s 3*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -march=ppc64 -mcpu=pwr8 | FileCheck %s -check-prefix=CHECK-P8U 4*9880d681SAndroid Build Coastguard Worker 5*9880d681SAndroid Build Coastguard Workerdefine i64 @exchange_and_add(i64* %mem, i64 %val) nounwind { 6*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: exchange_and_add: 7*9880d681SAndroid Build Coastguard Worker; CHECK: ldarx 8*9880d681SAndroid Build Coastguard Worker %tmp = atomicrmw add i64* %mem, i64 %val monotonic 9*9880d681SAndroid Build Coastguard Worker; CHECK: stdcx. 10*9880d681SAndroid Build Coastguard Worker ret i64 %tmp 11*9880d681SAndroid Build Coastguard Worker} 12*9880d681SAndroid Build Coastguard Worker 13*9880d681SAndroid Build Coastguard Workerdefine i8 @exchange_and_add8(i8* %mem, i8 %val) nounwind { 14*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: exchange_and_add8: 15*9880d681SAndroid Build Coastguard Worker; CHECK-P8U: lbarx 16*9880d681SAndroid Build Coastguard Worker %tmp = atomicrmw add i8* %mem, i8 %val monotonic 17*9880d681SAndroid Build Coastguard Worker; CHECK-P8U: stbcx. 18*9880d681SAndroid Build Coastguard Worker ret i8 %tmp 19*9880d681SAndroid Build Coastguard Worker} 20*9880d681SAndroid Build Coastguard Worker 21*9880d681SAndroid Build Coastguard Workerdefine i16 @exchange_and_add16(i16* %mem, i16 %val) nounwind { 22*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: exchange_and_add16: 23*9880d681SAndroid Build Coastguard Worker; CHECK-P8U: lharx 24*9880d681SAndroid Build Coastguard Worker %tmp = atomicrmw add i16* %mem, i16 %val monotonic 25*9880d681SAndroid Build Coastguard Worker; CHECK-P8U: sthcx. 26*9880d681SAndroid Build Coastguard Worker ret i16 %tmp 27*9880d681SAndroid Build Coastguard Worker} 28*9880d681SAndroid Build Coastguard Worker 29*9880d681SAndroid Build Coastguard Workerdefine i64 @exchange_and_cmp(i64* %mem) nounwind { 30*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: exchange_and_cmp: 31*9880d681SAndroid Build Coastguard Worker; CHECK: ldarx 32*9880d681SAndroid Build Coastguard Worker %tmppair = cmpxchg i64* %mem, i64 0, i64 1 monotonic monotonic 33*9880d681SAndroid Build Coastguard Worker %tmp = extractvalue { i64, i1 } %tmppair, 0 34*9880d681SAndroid Build Coastguard Worker; CHECK: stdcx. 35*9880d681SAndroid Build Coastguard Worker; CHECK: stdcx. 36*9880d681SAndroid Build Coastguard Worker ret i64 %tmp 37*9880d681SAndroid Build Coastguard Worker} 38*9880d681SAndroid Build Coastguard Worker 39*9880d681SAndroid Build Coastguard Workerdefine i8 @exchange_and_cmp8(i8* %mem) nounwind { 40*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: exchange_and_cmp8: 41*9880d681SAndroid Build Coastguard Worker; CHECK-P8U: lbarx 42*9880d681SAndroid Build Coastguard Worker %tmppair = cmpxchg i8* %mem, i8 0, i8 1 monotonic monotonic 43*9880d681SAndroid Build Coastguard Worker %tmp = extractvalue { i8, i1 } %tmppair, 0 44*9880d681SAndroid Build Coastguard Worker; CHECK-P8U: stbcx. 45*9880d681SAndroid Build Coastguard Worker; CHECK-P8U: stbcx. 46*9880d681SAndroid Build Coastguard Worker ret i8 %tmp 47*9880d681SAndroid Build Coastguard Worker} 48*9880d681SAndroid Build Coastguard Worker 49*9880d681SAndroid Build Coastguard Workerdefine i16 @exchange_and_cmp16(i16* %mem) nounwind { 50*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: exchange_and_cmp16: 51*9880d681SAndroid Build Coastguard Worker; CHECK-P8U: lharx 52*9880d681SAndroid Build Coastguard Worker %tmppair = cmpxchg i16* %mem, i16 0, i16 1 monotonic monotonic 53*9880d681SAndroid Build Coastguard Worker %tmp = extractvalue { i16, i1 } %tmppair, 0 54*9880d681SAndroid Build Coastguard Worker; CHECK-P8U: sthcx. 55*9880d681SAndroid Build Coastguard Worker; CHECK-P8U: sthcx. 56*9880d681SAndroid Build Coastguard Worker ret i16 %tmp 57*9880d681SAndroid Build Coastguard Worker} 58*9880d681SAndroid Build Coastguard Worker 59*9880d681SAndroid Build Coastguard Workerdefine i64 @exchange(i64* %mem, i64 %val) nounwind { 60*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: exchange: 61*9880d681SAndroid Build Coastguard Worker; CHECK: ldarx 62*9880d681SAndroid Build Coastguard Worker %tmp = atomicrmw xchg i64* %mem, i64 1 monotonic 63*9880d681SAndroid Build Coastguard Worker; CHECK: stdcx. 64*9880d681SAndroid Build Coastguard Worker ret i64 %tmp 65*9880d681SAndroid Build Coastguard Worker} 66*9880d681SAndroid Build Coastguard Worker 67*9880d681SAndroid Build Coastguard Workerdefine i8 @exchange8(i8* %mem, i8 %val) nounwind { 68*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: exchange8: 69*9880d681SAndroid Build Coastguard Worker; CHECK-P8U: lbarx 70*9880d681SAndroid Build Coastguard Worker %tmp = atomicrmw xchg i8* %mem, i8 1 monotonic 71*9880d681SAndroid Build Coastguard Worker; CHECK-P8U: stbcx. 72*9880d681SAndroid Build Coastguard Worker ret i8 %tmp 73*9880d681SAndroid Build Coastguard Worker} 74*9880d681SAndroid Build Coastguard Worker 75*9880d681SAndroid Build Coastguard Workerdefine i16 @exchange16(i16* %mem, i16 %val) nounwind { 76*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: exchange16: 77*9880d681SAndroid Build Coastguard Worker; CHECK-P8U: lharx 78*9880d681SAndroid Build Coastguard Worker %tmp = atomicrmw xchg i16* %mem, i16 1 monotonic 79*9880d681SAndroid Build Coastguard Worker; CHECK-P8U: sthcx. 80*9880d681SAndroid Build Coastguard Worker ret i16 %tmp 81*9880d681SAndroid Build Coastguard Worker} 82*9880d681SAndroid Build Coastguard Worker 83*9880d681SAndroid Build Coastguard Workerdefine void @atomic_store(i64* %mem, i64 %val) nounwind { 84*9880d681SAndroid Build Coastguard Workerentry: 85*9880d681SAndroid Build Coastguard Worker; CHECK: @atomic_store 86*9880d681SAndroid Build Coastguard Worker store atomic i64 %val, i64* %mem release, align 64 87*9880d681SAndroid Build Coastguard Worker; CHECK: lwsync 88*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: stdcx 89*9880d681SAndroid Build Coastguard Worker; CHECK: std 90*9880d681SAndroid Build Coastguard Worker ret void 91*9880d681SAndroid Build Coastguard Worker} 92*9880d681SAndroid Build Coastguard Worker 93*9880d681SAndroid Build Coastguard Workerdefine i64 @atomic_load(i64* %mem) nounwind { 94*9880d681SAndroid Build Coastguard Workerentry: 95*9880d681SAndroid Build Coastguard Worker; CHECK: @atomic_load 96*9880d681SAndroid Build Coastguard Worker %tmp = load atomic i64, i64* %mem acquire, align 64 97*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: ldarx 98*9880d681SAndroid Build Coastguard Worker; CHECK: ld 99*9880d681SAndroid Build Coastguard Worker; CHECK: lwsync 100*9880d681SAndroid Build Coastguard Worker ret i64 %tmp 101*9880d681SAndroid Build Coastguard Worker} 102*9880d681SAndroid Build Coastguard Worker 103