]> granicus.if.org Git - clang/commitdiff
Emit native implementations of atomic operations on FreeBSD/armv6.
authorEd Schouten <ed@80386.nl>
Sat, 15 Jun 2013 09:40:14 +0000 (09:40 +0000)
committerEd Schouten <ed@80386.nl>
Sat, 15 Jun 2013 09:40:14 +0000 (09:40 +0000)
Just like on Linux, FreeBSD/armv6 assumes the system supports
ldrex/strex unconditionally. It is also used by the kernel. We can
therefore enable support for it, like we do on Linux.

While there, change one of the unit tests to explicitly test against
armv5 instead of armv7, as it actually tests whether libcalls are
emitted.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184040 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/Targets.cpp
test/CodeGen/c11atomics.c
test/CodeGen/linux-arm-atomic.c

index baf83c1a14c6868ad740d92d4a0b2a409590d2ff..f3d7e0ce671c48bd7c851545ca6d935b1bbce2d6 100644 (file)
@@ -3534,8 +3534,8 @@ class ARMTargetInfo : public TargetInfo {
     // the kernel which on armv6 and newer uses ldrex and strex. The net result
     // is that if we assume the kernel is at least as recent as the hardware,
     // it is safe to use atomic instructions on armv6 and newer.
-    if (T.getOS() != llvm::Triple::Linux)
-     return false;
+    if (T.getOS() != llvm::Triple::Linux && T.getOS() != llvm::Triple::FreeBSD)
+      return false;
     StringRef ArchName = T.getArchName();
     if (T.getArch() == llvm::Triple::arm) {
       if (!ArchName.startswith("armv"))
index 8d298af019195ba273779d543415af0ff675aa30..6c845e9e01d410c00904b037a0851a8fcea9f283 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - -triple=armv7-unknown-freebsd -std=c11 | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=armv5-unknown-freebsd -std=c11 | FileCheck %s
 
 // Test that we are generating atomicrmw instructions, rather than
 // compare-exchange loops for common atomic ops.  This makes a big difference
index c7ce1d228bb5d3bd18c677831829859005b4e4df..b8535f8248270783ef0f389a052bc9bca9a83929 100644 (file)
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=armv7-unknown-linux | FileCheck %s
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=armv6-unknown-linux | FileCheck %s
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=thumbv7-unknown-linux | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=armv6-unknown-freebsd | FileCheck %s
 
 typedef int _Atomic_word;
 _Atomic_word exchange_and_add(volatile _Atomic_word *__mem, int __val) {