aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2016-05-13 12:57:50 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2016-05-13 12:57:50 +0000
commitac3d02e247208eff86d084d9f7517adc74f9751c (patch)
tree535c973833914e9b842a1784d581fbca1094544e /gcc
parent7549163c15796e33369661ea90cc6a6900d13fc2 (diff)
downloadgcc-ac3d02e247208eff86d084d9f7517adc74f9751c.zip
gcc-ac3d02e247208eff86d084d9f7517adc74f9751c.tar.gz
gcc-ac3d02e247208eff86d084d9f7517adc74f9751c.tar.bz2
nvptx.c (write_fn_proto): Handle BUILT_IN_ATOMIC_COMPARE_EXCHANGE_n oddity.
gcc/ * config/nvptx/nvptx.c (write_fn_proto): Handle BUILT_IN_ATOMIC_COMPARE_EXCHANGE_n oddity. gcc/testsuite/ * gcc.dg/atomic-noinline-aux.c: Include stddef.h. Fix __atomic_is_lock_free declaration. From-SVN: r236209
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/config/nvptx/nvptx.c29
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/atomic-noinline-aux.c3
4 files changed, 38 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 14c37d7..005b701 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2016-05-13 Nathan Sidwell <nathan@acm.org>
+
+ * config/nvptx/nvptx.c (write_fn_proto): Handle
+ BUILT_IN_ATOMIC_COMPARE_EXCHANGE_n oddity.
+
2016-05-13 Martin Liska <mliska@suse.cz>
* tree-ssa-loop-ivopts.c (create_new_ivs): Use HOST_WIDE_INT_PRINT_DEC
diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c
index a6c90b6..1631dae 100644
--- a/gcc/config/nvptx/nvptx.c
+++ b/gcc/config/nvptx/nvptx.c
@@ -751,6 +751,26 @@ write_fn_proto (std::stringstream &s, bool is_defn,
tree fntype = TREE_TYPE (decl);
tree result_type = TREE_TYPE (fntype);
+ /* atomic_compare_exchange_$n builtins have an exceptional calling
+ convention. */
+ int not_atomic_weak_arg = -1;
+ if (DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL)
+ switch (DECL_FUNCTION_CODE (decl))
+ {
+ case BUILT_IN_ATOMIC_COMPARE_EXCHANGE_1:
+ case BUILT_IN_ATOMIC_COMPARE_EXCHANGE_2:
+ case BUILT_IN_ATOMIC_COMPARE_EXCHANGE_4:
+ case BUILT_IN_ATOMIC_COMPARE_EXCHANGE_8:
+ case BUILT_IN_ATOMIC_COMPARE_EXCHANGE_16:
+ /* These atomics skip the 'weak' parm in an actual library
+ call. We must skip it in the prototype too. */
+ not_atomic_weak_arg = 3;
+ break;
+
+ default:
+ break;
+ }
+
/* Declare the result. */
bool return_in_mem = write_return_type (s, true, result_type);
@@ -775,11 +795,14 @@ write_fn_proto (std::stringstream &s, bool is_defn,
prototyped = false;
}
- for (; args; args = TREE_CHAIN (args))
+ for (; args; args = TREE_CHAIN (args), not_atomic_weak_arg--)
{
tree type = prototyped ? TREE_VALUE (args) : TREE_TYPE (args);
-
- argno = write_arg_type (s, -1, argno, type, prototyped);
+
+ if (not_atomic_weak_arg)
+ argno = write_arg_type (s, -1, argno, type, prototyped);
+ else
+ gcc_assert (type == boolean_type_node);
}
if (stdarg_p (fntype))
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 57b7580..3e971cd 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2016-05-13 Nathan Sidwell <nathan@acm.org>
+
+ * gcc.dg/atomic-noinline-aux.c: Include stddef.h. Fix
+ __atomic_is_lock_free declaration.
+
2016-05-13 Richard Biener <rguenther@suse.de>
PR tree-optimization/42587
diff --git a/gcc/testsuite/gcc.dg/atomic-noinline-aux.c b/gcc/testsuite/gcc.dg/atomic-noinline-aux.c
index 9798979..f0e3387b 100644
--- a/gcc/testsuite/gcc.dg/atomic-noinline-aux.c
+++ b/gcc/testsuite/gcc.dg/atomic-noinline-aux.c
@@ -7,6 +7,7 @@
the exact entry points the test file will require. All these routines
simply set the first parameter to 1, and the caller will test for that. */
+#include <stddef.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
@@ -64,7 +65,7 @@ __atomic_fetch_nand_1 (unsigned char *p, unsigned char v, int i)
return ret;
}
-bool __atomic_is_lock_free (int i, void *p)
+bool __atomic_is_lock_free (size_t i, void *p)
{
*(short *)p = 1;
return true;