diff options
author | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-11-07 23:11:55 +0000 |
---|---|---|
committer | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-11-07 23:11:55 +0000 |
commit | 29139cdc71a9f22d6eee8c3d7a5bcc1539c63b0b (patch) | |
tree | 52678eae26470ab300ea093fc393e910585625cb /gcc/java | |
parent | 1d422816e1f19d6c464b649e49bfc2099aff690a (diff) | |
download | gcc-29139cdc71a9f22d6eee8c3d7a5bcc1539c63b0b.tar.gz |
Allow libcalls to be installed for legacy __sync optabs.
This allows a target which implements the __sync interfaces
in libgcc to continue to use them transparently with the
new __atomic builtins.
It is assumed that these libgcc routines DO NOT use spinlocks.
This is true of all extant libgcc instances.
* optabs.h (OTI_sync_compare_and_swap, OTI_sync_lock_test_and_set,
OTI_sync_old_add, OTI_sync_old_sub, OTI_sync_old_ior,
OTI_sync_old_and, OTI_sync_old_xor, OTI_sync_old_nand,
OTI_sync_new_add, OTI_sync_new_sub, OTI_sync_new_ior,
OTI_sync_new_and, OTI_sync_new_xor, OTI_sync_new_nand): Move and
rename from the direct_optab_index enum.
(sync_compare_and_swap_optab, sync_lock_test_and_set_optab,
sync_old_add_optab, sync_old_sub_optab, sync_old_ior_optab,
sync_old_and_optab, sync_old_xor_optab, sync_old_nand_optab,
sync_new_add_optab, sync_new_sub_optab, sync_new_ior_optab,
sync_new_and_optab, sync_new_xor_optab, sync_new_nand_optab): Read
from the optab_table, not the direct_optab_table.
(init_sync_libfuncs): Declare.
(can_compare_and_swap_p): Update parameters.
* optabs.c (init_sync_libfuncs_1, init_sync_libfuncs): New.
(can_compare_and_swap_p): Add allow_libcall parameter; if true,
test for the legacy compare-and-swap libcall.
(expand_atomic_exchange): Use the legacy test-and-set libcall.
(expand_atomic_compare_and_swap): Use the legacy CAS libcall.
(struct atomic_op_functions): Update for optab type changes.
(maybe_emit_op): Likewise.
(expand_atomic_fetch_op): Use the legacy fetch-op libcalls.
* builtins.c (fold_builtin_atomic_always_lock_free): Update call
to can_compare_and_swap_p.
* omp-low.c (expand_omp_atomic_fetch_op): Likewise.
(expand_omp_atomic_pipeline): Likewise.
* genopinit.c (optabs): Make sync_old_*_optab, sync_new_*_optab,
sync_compare_and_swap_optab, sync_lock_test_and_set_optab regular
optabs.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@181134 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/java')
-rw-r--r-- | gcc/java/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/java/builtins.c | 24 |
2 files changed, 16 insertions, 15 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 715d1f5885c..27a44f11f7d 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,10 @@ +2011-11-07 Richard Henderson <rth@redhat.com> + + * builtins.c (compareAndSwapInt_builtin): Use can_compare_and_swap_p. + (compareAndSwapLong_builtin): Likewise. + (compareAndSwapObject_builtin): Likewise. + (VMSupportsCS8_builtin): Likewise. + 2011-11-02 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> * Make-lang.in (jvspec.o): Pass SHLIB instead of SHLIB_LINK. diff --git a/gcc/java/builtins.c b/gcc/java/builtins.c index 5ab345dc472..66addcbcc08 100644 --- a/gcc/java/builtins.c +++ b/gcc/java/builtins.c @@ -319,9 +319,7 @@ compareAndSwapInt_builtin (tree method_return_type ATTRIBUTE_UNUSED, tree orig_call) { enum machine_mode mode = TYPE_MODE (int_type_node); - if (direct_optab_handler (sync_compare_and_swap_optab, mode) - != CODE_FOR_nothing - || flag_use_atomic_builtins) + if (can_compare_and_swap_p (mode, flag_use_atomic_builtins)) { tree addr, stmt; enum built_in_function fncode = BUILT_IN_SYNC_BOOL_COMPARE_AND_SWAP_4; @@ -342,13 +340,12 @@ compareAndSwapLong_builtin (tree method_return_type ATTRIBUTE_UNUSED, tree orig_call) { enum machine_mode mode = TYPE_MODE (long_type_node); - if (direct_optab_handler (sync_compare_and_swap_optab, mode) - != CODE_FOR_nothing - || (GET_MODE_SIZE (mode) <= GET_MODE_SIZE (word_mode) - && flag_use_atomic_builtins)) - /* We don't trust flag_use_atomic_builtins for multi-word - compareAndSwap. Some machines such as ARM have atomic libfuncs - but not the multi-word versions. */ + /* We don't trust flag_use_atomic_builtins for multi-word compareAndSwap. + Some machines such as ARM have atomic libfuncs but not the multi-word + versions. */ + if (can_compare_and_swap_p (mode, + (flag_use_atomic_builtins + && GET_MODE_SIZE (mode) <= UNITS_PER_WORD))) { tree addr, stmt; enum built_in_function fncode = BUILT_IN_SYNC_BOOL_COMPARE_AND_SWAP_8; @@ -368,9 +365,7 @@ compareAndSwapObject_builtin (tree method_return_type ATTRIBUTE_UNUSED, tree orig_call) { enum machine_mode mode = TYPE_MODE (ptr_type_node); - if (direct_optab_handler (sync_compare_and_swap_optab, mode) - != CODE_FOR_nothing - || flag_use_atomic_builtins) + if (can_compare_and_swap_p (mode, flag_use_atomic_builtins)) { tree addr, stmt; enum built_in_function builtin; @@ -448,8 +443,7 @@ VMSupportsCS8_builtin (tree method_return_type, { enum machine_mode mode = TYPE_MODE (long_type_node); gcc_assert (method_return_type == boolean_type_node); - if (direct_optab_handler (sync_compare_and_swap_optab, mode) - != CODE_FOR_nothing) + if (can_compare_and_swap_p (mode, false)) return boolean_true_node; else return boolean_false_node; |