Wei Mi | b086289 | 2017-09-22 16:30:00 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -std=c++11 -emit-llvm -o - -triple=x86_64-linux-gnu | FileCheck %s |
| 2 | // RUN: %clang_cc1 %s -std=c++11 -emit-llvm -o - -triple=x86_64-linux-gnu -target-cpu core2 | FileCheck %s --check-prefix=CORE2 |
Hans Wennborg | b427889 | 2018-08-24 22:46:33 +0000 | [diff] [blame] | 3 | // Check the atomic code generation for cpu targets w/wo cx16 support. |
Wei Mi | b086289 | 2017-09-22 16:30:00 +0000 | [diff] [blame] | 4 | |
| 5 | struct alignas(8) AM8 { |
| 6 | int f1, f2; |
| 7 | }; |
| 8 | AM8 m8; |
| 9 | AM8 load8() { |
| 10 | AM8 am; |
| 11 | // CHECK-LABEL: @_Z5load8v |
| 12 | // CHECK: load atomic i64, {{.*}} monotonic |
| 13 | // CORE2-LABEL: @_Z5load8v |
| 14 | // CORE2: load atomic i64, {{.*}} monotonic |
| 15 | __atomic_load(&m8, &am, 0); |
| 16 | return am; |
| 17 | } |
| 18 | |
| 19 | AM8 s8; |
| 20 | void store8() { |
| 21 | // CHECK-LABEL: @_Z6store8v |
| 22 | // CHECK: store atomic i64 {{.*}} monotonic |
| 23 | // CORE2-LABEL: @_Z6store8v |
| 24 | // CORE2: store atomic i64 {{.*}} monotonic |
| 25 | __atomic_store(&m8, &s8, 0); |
| 26 | } |
| 27 | |
| 28 | bool cmpxchg8() { |
| 29 | AM8 am; |
| 30 | // CHECK-LABEL: @_Z8cmpxchg8v |
| 31 | // CHECK: cmpxchg i64* {{.*}} monotonic |
| 32 | // CORE2-LABEL: @_Z8cmpxchg8v |
| 33 | // CORE2: cmpxchg i64* {{.*}} monotonic |
| 34 | return __atomic_compare_exchange(&m8, &s8, &am, 0, 0, 0); |
| 35 | } |
| 36 | |
| 37 | struct alignas(16) AM16 { |
| 38 | long f1, f2; |
| 39 | }; |
| 40 | |
| 41 | AM16 m16; |
| 42 | AM16 load16() { |
| 43 | AM16 am; |
| 44 | // CHECK-LABEL: @_Z6load16v |
| 45 | // CHECK: call void @__atomic_load |
| 46 | // CORE2-LABEL: @_Z6load16v |
| 47 | // CORE2: load atomic i128, {{.*}} monotonic |
| 48 | __atomic_load(&m16, &am, 0); |
| 49 | return am; |
| 50 | } |
| 51 | |
| 52 | AM16 s16; |
| 53 | void store16() { |
| 54 | // CHECK-LABEL: @_Z7store16v |
| 55 | // CHECK: call void @__atomic_store |
| 56 | // CORE2-LABEL: @_Z7store16v |
| 57 | // CORE2: store atomic i128 {{.*}} monotonic |
| 58 | __atomic_store(&m16, &s16, 0); |
| 59 | } |
| 60 | |
| 61 | bool cmpxchg16() { |
| 62 | AM16 am; |
| 63 | // CHECK-LABEL: @_Z9cmpxchg16v |
| 64 | // CHECK: call zeroext i1 @__atomic_compare_exchange |
| 65 | // CORE2-LABEL: @_Z9cmpxchg16v |
| 66 | // CORE2: cmpxchg i128* {{.*}} monotonic |
| 67 | return __atomic_compare_exchange(&m16, &s16, &am, 0, 0, 0); |
| 68 | } |
Hans Wennborg | b427889 | 2018-08-24 22:46:33 +0000 | [diff] [blame] | 69 | |