diff options
Diffstat (limited to 'gcc/config/nvptx/nvptx.c')
| -rw-r--r-- | gcc/config/nvptx/nvptx.c | 29 |
1 files changed, 26 insertions, 3 deletions
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)) |
