summaryrefslogtreecommitdiff
path: root/gcc/builtins.c
diff options
context:
space:
mode:
authoramacleod <amacleod@138bc75d-0d04-0410-961f-82ee72b054a4>2011-11-17 20:51:51 +0000
committeramacleod <amacleod@138bc75d-0d04-0410-961f-82ee72b054a4>2011-11-17 20:51:51 +0000
commit2c201ad17197e631e5411c084760da9060817727 (patch)
tree0452b724a356b47d7c1793b5851f2045d411f1f9 /gcc/builtins.c
parenta1c636b09c8c5ed2156b569cf1153d0c8863f399 (diff)
downloadgcc-2c201ad17197e631e5411c084760da9060817727.tar.gz
2011-11-17 Andrew MacLeod <amacleod@redhat.com>
* builtins.c (expand_builtin): Remove 4th parameter representing weak/strong mode when __atomic_compare_exchange becomes a library call. * gcc.dg/atomic-generic-aux.c (__atomic_compare_exchange): Fail if memory model parameters don't match expected values. * gcc.dg/atomic-generic.c: Pass specific memory model parameters to __atomic_compare_exchange. * gcc.dg/atomic-noinline.c: Pass specific memory model parameters to __atomic_compare_exchange_n. * gcc.dg/atomic-noinline-aux.c (__atomic_compare_exchange_2): Remove weak/strong parameter and fail if memory models aren't correct. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@181453 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r--gcc/builtins.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c
index fe0260ff33e..0fc5a420c82 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -6497,12 +6497,28 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode,
case BUILT_IN_ATOMIC_COMPARE_EXCHANGE_4:
case BUILT_IN_ATOMIC_COMPARE_EXCHANGE_8:
case BUILT_IN_ATOMIC_COMPARE_EXCHANGE_16:
- mode =
- get_builtin_sync_mode (fcode - BUILT_IN_ATOMIC_COMPARE_EXCHANGE_1);
- target = expand_builtin_atomic_compare_exchange (mode, exp, target);
- if (target)
- return target;
- break;
+ {
+ unsigned int nargs, z;
+ VEC(tree,gc) *vec;
+
+ mode =
+ get_builtin_sync_mode (fcode - BUILT_IN_ATOMIC_COMPARE_EXCHANGE_1);
+ target = expand_builtin_atomic_compare_exchange (mode, exp, target);
+ if (target)
+ return target;
+
+ /* If this is turned into an external library call, the weak parameter
+ must be dropped to match the expected parameter list. */
+ nargs = call_expr_nargs (exp);
+ vec = VEC_alloc (tree, gc, nargs - 1);
+ for (z = 0; z < 3; z++)
+ VEC_quick_push (tree, vec, CALL_EXPR_ARG (exp, z));
+ /* Skip the boolean weak parameter. */
+ for (z = 4; z < 6; z++)
+ VEC_quick_push (tree, vec, CALL_EXPR_ARG (exp, z));
+ exp = build_call_vec (TREE_TYPE (exp), CALL_EXPR_FN (exp), vec);
+ break;
+ }
case BUILT_IN_ATOMIC_LOAD_1:
case BUILT_IN_ATOMIC_LOAD_2: