summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGen/atomic-ops.c
diff options
context:
space:
mode:
authorDavid Chisnall <csdavec@swan.ac.uk>2012-03-29 18:01:11 +0000
committerDavid Chisnall <csdavec@swan.ac.uk>2012-03-29 18:01:11 +0000
commitdb365f38ea81a3bfaef0cde2802d7279caea4c55 (patch)
tree78407cf46e9f55ff635a15d7a0508c65d6b0d6dc /clang/test/CodeGen/atomic-ops.c
parent891ec2870dbcc6be98b165f224e4dd564056aa67 (diff)
downloadbcm5719-llvm-db365f38ea81a3bfaef0cde2802d7279caea4c55.tar.gz
bcm5719-llvm-db365f38ea81a3bfaef0cde2802d7279caea4c55.zip
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... llvm-svn: 153666
Diffstat (limited to 'clang/test/CodeGen/atomic-ops.c')
-rw-r--r--clang/test/CodeGen/atomic-ops.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/clang/test/CodeGen/atomic-ops.c b/clang/test/CodeGen/atomic-ops.c
index 3885d76b6de..a3608de6e08 100644
--- a/clang/test/CodeGen/atomic-ops.c
+++ b/clang/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)
+}
OpenPOWER on IntegriCloud