1; RUN: llc < %s -mtriple=powerpc-apple-darwin -march=ppc32 -verify-machineinstrs | FileCheck %s --check-prefix=CHECK --check-prefix=PPC32 2; FIXME: -verify-machineinstrs currently fail on ppc64 (mismatched register/instruction). 3; This is already checked for in Atomics-64.ll 4; RUN: llc < %s -mtriple=powerpc-apple-darwin -march=ppc64 | FileCheck %s --check-prefix=CHECK --check-prefix=PPC64 5 6; In this file, we check that atomic load/store can make use of the indexed 7; versions of the instructions. 8 9; Indexed version of loads 10define i8 @load_x_i8_seq_cst([100000 x i8]* %mem) { 11; CHECK-LABEL: load_x_i8_seq_cst 12; CHECK: sync 13; CHECK: lbzx 14; CHECK: lwsync 15 %ptr = getelementptr inbounds [100000 x i8], [100000 x i8]* %mem, i64 0, i64 90000 16 %val = load atomic i8, i8* %ptr seq_cst, align 1 17 ret i8 %val 18} 19define i16 @load_x_i16_acquire([100000 x i16]* %mem) { 20; CHECK-LABEL: load_x_i16_acquire 21; CHECK: lhzx 22; CHECK: lwsync 23 %ptr = getelementptr inbounds [100000 x i16], [100000 x i16]* %mem, i64 0, i64 90000 24 %val = load atomic i16, i16* %ptr acquire, align 2 25 ret i16 %val 26} 27define i32 @load_x_i32_monotonic([100000 x i32]* %mem) { 28; CHECK-LABEL: load_x_i32_monotonic 29; CHECK: lwzx 30; CHECK-NOT: sync 31 %ptr = getelementptr inbounds [100000 x i32], [100000 x i32]* %mem, i64 0, i64 90000 32 %val = load atomic i32, i32* %ptr monotonic, align 4 33 ret i32 %val 34} 35define i64 @load_x_i64_unordered([100000 x i64]* %mem) { 36; CHECK-LABEL: load_x_i64_unordered 37; PPC32: __sync_ 38; PPC64-NOT: __sync_ 39; PPC64: ldx 40; CHECK-NOT: sync 41 %ptr = getelementptr inbounds [100000 x i64], [100000 x i64]* %mem, i64 0, i64 90000 42 %val = load atomic i64, i64* %ptr unordered, align 8 43 ret i64 %val 44} 45 46; Indexed version of stores 47define void @store_x_i8_seq_cst([100000 x i8]* %mem) { 48; CHECK-LABEL: store_x_i8_seq_cst 49; CHECK: sync 50; CHECK: stbx 51 %ptr = getelementptr inbounds [100000 x i8], [100000 x i8]* %mem, i64 0, i64 90000 52 store atomic i8 42, i8* %ptr seq_cst, align 1 53 ret void 54} 55define void @store_x_i16_release([100000 x i16]* %mem) { 56; CHECK-LABEL: store_x_i16_release 57; CHECK: lwsync 58; CHECK: sthx 59 %ptr = getelementptr inbounds [100000 x i16], [100000 x i16]* %mem, i64 0, i64 90000 60 store atomic i16 42, i16* %ptr release, align 2 61 ret void 62} 63define void @store_x_i32_monotonic([100000 x i32]* %mem) { 64; CHECK-LABEL: store_x_i32_monotonic 65; CHECK-NOT: sync 66; CHECK: stwx 67 %ptr = getelementptr inbounds [100000 x i32], [100000 x i32]* %mem, i64 0, i64 90000 68 store atomic i32 42, i32* %ptr monotonic, align 4 69 ret void 70} 71define void @store_x_i64_unordered([100000 x i64]* %mem) { 72; CHECK-LABEL: store_x_i64_unordered 73; CHECK-NOT: sync 74; PPC32: __sync_ 75; PPC64-NOT: __sync_ 76; PPC64: stdx 77 %ptr = getelementptr inbounds [100000 x i64], [100000 x i64]* %mem, i64 0, i64 90000 78 store atomic i64 42, i64* %ptr unordered, align 8 79 ret void 80} 81