diff options
author | David Chisnall <csdavec@swan.ac.uk> | 2012-03-29 18:01:11 +0000 |
---|---|---|
committer | David Chisnall <csdavec@swan.ac.uk> | 2012-03-29 18:01:11 +0000 |
commit | 3a7d69bf666140e45ea7d75b6887d4b67eecd68e (patch) | |
tree | 82e81c2cbd76ba8feacb3c1e472dd7e4f277a9a1 /test/CodeGen/atomic-ops.c | |
parent | 2ebb98a78471f2039af4321bae657e7daacc2a62 (diff) |
Call out to GCC-compatible runtime functions for atomic ops that we can't use
LLVM intrinsics for.
I have an implementation of these functions, which wants to go in a libgcc_s
equivalent in compiler-rt. It's currently here:
http://people.freebsd.org/~theraven/atomic.c
It will be committed to compiler-rt as soon as I work out where would be a
sensible place to put it...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153666 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/atomic-ops.c')
-rw-r--r-- | test/CodeGen/atomic-ops.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/CodeGen/atomic-ops.c b/test/CodeGen/atomic-ops.c index 3885d76b6d..a3608de6e0 100644 --- a/test/CodeGen/atomic-ops.c +++ b/test/CodeGen/atomic-ops.c @@ -81,3 +81,39 @@ int lock_free() { // CHECK: ret i32 1 return __atomic_is_lock_free(sizeof(_Atomic(int))); } + +// Tests for atomic operations on big values. These should call the functions +// defined here: +// http://gcc.gnu.org/wiki/Atomic/GCCMM/LIbrary#The_Library_interface + +struct foo { + int big[128]; +}; + +_Atomic(struct foo) bigAtomic; + +void structAtomicStore() { + // CHECK: @structAtomicStore + struct foo f = {0}; + __atomic_store(&bigAtomic, f, 5); + // CHECK: call void @__atomic_store(i32 512, i8* bitcast (%struct.foo* @bigAtomic to i8*), i8* %3, i32 5) +} +void structAtomicLoad() { + // CHECK: @structAtomicLoad + struct foo f = __atomic_load(&bigAtomic, 5); + // CHECK: call void @__atomic_load(i32 512, i8* bitcast (%struct.foo* @bigAtomic to i8*), i8* %0, i32 5) +} +struct foo structAtomicExchange() { + // CHECK: @structAtomicExchange + struct foo f = {0}; + return __atomic_exchange(&bigAtomic, f, 5); + // CHECK: call void @__atomic_exchange(i32 512, i8* bitcast (%struct.foo* @bigAtomic to i8*), i8* %3, i8* %4, i32 5) +} +int structAtomicCmpExchange() { + // CHECK: @structAtomicCmpExchange + struct foo f = {0}; + struct foo g = {0}; + g.big[12] = 12; + return __atomic_compare_exchange_strong(&bigAtomic, &f, g, 5, 5); + // CHECK: call zeroext i1 @__atomic_compare_exchange(i32 512, i8* bitcast (%struct.foo* @bigAtomic to i8*), i8* %4, i8* %5, i32 5, i32 5) +} |