aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2013-11-09 16:32:34 +0000
committerJoseph Myers <jsm28@gcc.gnu.org>2013-11-09 16:32:34 +0000
commit6b28e197217e4508709cc49239ea39b7a1ad0a23 (patch)
treeb2d16d6f89b752a35d24b7bf3a8b3ac694356e18 /gcc
parent86dedeba367e5dc6153f5c92a09ee6888f2ce9a5 (diff)
downloadgcc-6b28e197217e4508709cc49239ea39b7a1ad0a23.zip
gcc-6b28e197217e4508709cc49239ea39b7a1ad0a23.tar.gz
gcc-6b28e197217e4508709cc49239ea39b7a1ad0a23.tar.bz2
c-common.c (atomic_size_supported_p): New function.
* c-common.c (atomic_size_supported_p): New function. (resolve_overloaded_atomic_exchange) (resolve_overloaded_atomic_compare_exchange) (resolve_overloaded_atomic_load, resolve_overloaded_atomic_store): Use it instead of comparing size with a local list of sizes. From-SVN: r204618
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c-family/ChangeLog8
-rw-r--r--gcc/c-family/c-common.c29
2 files changed, 33 insertions, 4 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 4ff4310..6b2a5ab 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,11 @@
+2013-11-09 Joseph Myers <joseph@codesourcery.com>
+
+ * c-common.c (atomic_size_supported_p): New function.
+ (resolve_overloaded_atomic_exchange)
+ (resolve_overloaded_atomic_compare_exchange)
+ (resolve_overloaded_atomic_load, resolve_overloaded_atomic_store):
+ Use it instead of comparing size with a local list of sizes.
+
2013-11-07 Andrew MacLeod <amacleod@redhat.com>
Joseph Myers <joseph@codesourcery.com>
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index e237926..93481b9 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -10403,6 +10403,27 @@ add_atomic_size_parameter (unsigned n, location_t loc, tree function,
}
+/* Return whether atomic operations for naturally aligned N-byte
+ arguments are supported, whether inline or through libatomic. */
+static bool
+atomic_size_supported_p (int n)
+{
+ switch (n)
+ {
+ case 1:
+ case 2:
+ case 4:
+ case 8:
+ return true;
+
+ case 16:
+ return targetm.scalar_mode_supported_p (TImode);
+
+ default:
+ return false;
+ }
+}
+
/* This will process an __atomic_exchange function call, determine whether it
needs to be mapped to the _N variation, or turned into a library call.
LOC is the location of the builtin call.
@@ -10428,7 +10449,7 @@ resolve_overloaded_atomic_exchange (location_t loc, tree function,
}
/* If not a lock-free size, change to the library generic format. */
- if (n != 1 && n != 2 && n != 4 && n != 8 && n != 16)
+ if (!atomic_size_supported_p (n))
{
*new_return = add_atomic_size_parameter (n, loc, function, params);
return true;
@@ -10493,7 +10514,7 @@ resolve_overloaded_atomic_compare_exchange (location_t loc, tree function,
}
/* If not a lock-free size, change to the library generic format. */
- if (n != 1 && n != 2 && n != 4 && n != 8 && n != 16)
+ if (!atomic_size_supported_p (n))
{
/* The library generic format does not have the weak parameter, so
remove it from the param list. Since a parameter has been removed,
@@ -10569,7 +10590,7 @@ resolve_overloaded_atomic_load (location_t loc, tree function,
}
/* If not a lock-free size, change to the library generic format. */
- if (n != 1 && n != 2 && n != 4 && n != 8 && n != 16)
+ if (!atomic_size_supported_p (n))
{
*new_return = add_atomic_size_parameter (n, loc, function, params);
return true;
@@ -10629,7 +10650,7 @@ resolve_overloaded_atomic_store (location_t loc, tree function,
}
/* If not a lock-free size, change to the library generic format. */
- if (n != 1 && n != 2 && n != 4 && n != 8 && n != 16)
+ if (!atomic_size_supported_p (n))
{
*new_return = add_atomic_size_parameter (n, loc, function, params);
return true;