Eli Friedman | c83b975 | 2011-09-07 01:41:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s |
Eric Christopher | 3883e66 | 2011-07-26 22:17:02 +0000 | [diff] [blame] | 2 | |
| 3 | int* foo(int** a, int* b, int* c) { |
| 4 | return __sync_val_compare_and_swap (a, b, c); |
| 5 | } |
Eli Friedman | c83b975 | 2011-09-07 01:41:24 +0000 | [diff] [blame] | 6 | // CHECK: define i32* @foo |
| 7 | // CHECK: cmpxchg |
Eric Christopher | 3883e66 | 2011-07-26 22:17:02 +0000 | [diff] [blame] | 8 | |
| 9 | int foo2(int** a, int* b, int* c) { |
| 10 | return __sync_bool_compare_and_swap (a, b, c); |
| 11 | } |
Eli Friedman | c83b975 | 2011-09-07 01:41:24 +0000 | [diff] [blame] | 12 | // CHECK: define i32 @foo2 |
| 13 | // CHECK: cmpxchg |
Eric Christopher | 3883e66 | 2011-07-26 22:17:02 +0000 | [diff] [blame] | 14 | |
| 15 | int* foo3(int** a, int b) { |
| 16 | return __sync_fetch_and_add (a, b); |
| 17 | } |
Eli Friedman | c83b975 | 2011-09-07 01:41:24 +0000 | [diff] [blame] | 18 | // CHECK: define i32* @foo3 |
| 19 | // CHECK: atomicrmw add |
| 20 | |
Eric Christopher | 3883e66 | 2011-07-26 22:17:02 +0000 | [diff] [blame] | 21 | |
| 22 | int* foo4(int** a, int b) { |
| 23 | return __sync_fetch_and_sub (a, b); |
| 24 | } |
Eli Friedman | c83b975 | 2011-09-07 01:41:24 +0000 | [diff] [blame] | 25 | // CHECK: define i32* @foo4 |
| 26 | // CHECK: atomicrmw sub |
| 27 | |
Eric Christopher | 3883e66 | 2011-07-26 22:17:02 +0000 | [diff] [blame] | 28 | |
| 29 | int* foo5(int** a, int* b) { |
| 30 | return __sync_lock_test_and_set (a, b); |
| 31 | } |
Eli Friedman | c83b975 | 2011-09-07 01:41:24 +0000 | [diff] [blame] | 32 | // CHECK: define i32* @foo5 |
| 33 | // CHECK: atomicrmw xchg |
| 34 | |
Eric Christopher | 3883e66 | 2011-07-26 22:17:02 +0000 | [diff] [blame] | 35 | |
| 36 | int* foo6(int** a, int*** b) { |
| 37 | return __sync_lock_test_and_set (a, b); |
| 38 | } |
Eli Friedman | c83b975 | 2011-09-07 01:41:24 +0000 | [diff] [blame] | 39 | // CHECK: define i32* @foo6 |
| 40 | // CHECK: atomicrmw xchg |