Commit 6b28e197 by Joseph Myers Committed by Joseph Myers

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
parent 86dedeba
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> 2013-11-07 Andrew MacLeod <amacleod@redhat.com>
Joseph Myers <joseph@codesourcery.com> Joseph Myers <joseph@codesourcery.com>
......
...@@ -10403,6 +10403,27 @@ add_atomic_size_parameter (unsigned n, location_t loc, tree function, ...@@ -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 /* 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. needs to be mapped to the _N variation, or turned into a library call.
LOC is the location of the builtin call. LOC is the location of the builtin call.
...@@ -10428,7 +10449,7 @@ resolve_overloaded_atomic_exchange (location_t loc, tree function, ...@@ -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 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); *new_return = add_atomic_size_parameter (n, loc, function, params);
return true; return true;
...@@ -10493,7 +10514,7 @@ resolve_overloaded_atomic_compare_exchange (location_t loc, tree function, ...@@ -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 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 /* The library generic format does not have the weak parameter, so
remove it from the param list. Since a parameter has been removed, 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, ...@@ -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 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); *new_return = add_atomic_size_parameter (n, loc, function, params);
return true; return true;
...@@ -10629,7 +10650,7 @@ resolve_overloaded_atomic_store (location_t loc, tree function, ...@@ -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 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); *new_return = add_atomic_size_parameter (n, loc, function, params);
return true; return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment