]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
builtins.c (compareAndSwapInt_builtin): Use flag_use_atomic_builtins.
authorAndrew Haley <aph@redhat.com>
Wed, 12 Aug 2009 16:10:12 +0000 (16:10 +0000)
committerAndrew Haley <aph@gcc.gnu.org>
Wed, 12 Aug 2009 16:10:12 +0000 (16:10 +0000)
2009-08-12  Andrew Haley  <aph@redhat.com>

* builtins.c (compareAndSwapInt_builtin): Use
flag_use_atomic_builtins.
(compareAndSwapLong_builtin): Likewise.
(compareAndSwapObject_builtin): Likewise.
* jvspec.c: Add flag_use_atomic_builtins.
* gcj.texi: Likewise.
* java-tree.h: Likewise.
* lang.opt: Likewise.

From-SVN: r150699

gcc/java/ChangeLog
gcc/java/builtins.c
gcc/java/gcj.texi
gcc/java/java-tree.h
gcc/java/jvspec.c
gcc/java/lang.opt

index b8a5d7dd613ae45ff12ac78226533b69f73acc77..d9fb9f5986647ce2a58f07795fe36e05da012925 100644 (file)
@@ -1,3 +1,14 @@
+2009-08-12  Andrew Haley  <aph@redhat.com>
+
+       * builtins.c (compareAndSwapInt_builtin): Use
+       flag_use_atomic_builtins.
+       (compareAndSwapLong_builtin): Likewise.
+       (compareAndSwapObject_builtin): Likewise.
+       * jvspec.c: Add flag_use_atomic_builtins.
+       * gcj.texi: Likewise.
+       * java-tree.h: Likewise.
+       * lang.opt: Likewise.
+
 2009-08-11  Dodji Seketeli  <dodji@redhat.com>
 
        PR debug/40990
index 0f7b197f78c8ba5bdbfd1257058ea57a31f1f902..6e4815beeab2755e9e7a4b2b5bb95741c0e9bebe 100644 (file)
@@ -318,7 +318,8 @@ compareAndSwapInt_builtin (tree method_return_type ATTRIBUTE_UNUSED,
                           tree orig_call)
 {
   enum machine_mode mode = TYPE_MODE (int_type_node);
-  if (sync_compare_and_swap[mode] != CODE_FOR_nothing)
+  if (sync_compare_and_swap[mode] != CODE_FOR_nothing
+      || flag_use_atomic_builtins)
     {
       tree addr, stmt;
       UNMARSHAL5 (orig_call);
@@ -337,7 +338,12 @@ compareAndSwapLong_builtin (tree method_return_type ATTRIBUTE_UNUSED,
                            tree orig_call)
 {
   enum machine_mode mode = TYPE_MODE (long_type_node);
-  if (sync_compare_and_swap[mode] != CODE_FOR_nothing)
+  if (sync_compare_and_swap[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.  */
     {
       tree addr, stmt;
       UNMARSHAL5 (orig_call);
@@ -355,7 +361,8 @@ compareAndSwapObject_builtin (tree method_return_type ATTRIBUTE_UNUSED,
                              tree orig_call)
 {
   enum machine_mode mode = TYPE_MODE (ptr_type_node);
-  if (sync_compare_and_swap[mode] != CODE_FOR_nothing)
+  if (sync_compare_and_swap[mode] != CODE_FOR_nothing
+      || flag_use_atomic_builtins)
   {
     tree addr, stmt;
     int builtin;
index 00ac9f7dee03e1ed47199f2b8db7ec0acead91e0..46b0899e80083975eab21f7e3b276ef484a86f9f 100644 (file)
@@ -607,6 +607,13 @@ On some systems it's necessary to insert inline checks whenever
 accessing an object via a reference.  On other systems you won't need
 this because null pointer accesses are caught automatically by the
 processor.
+
+@item -fuse-atomic-builtins
+On some systems, gcc can generate code for built-in atomic operations.
+Use this option to force gcj to use these builtins when compiling Java
+code.  Where this capability is present it should be automatically
+detected, so you won't usually need to use this option.
+
 @end table
 
 @c man end
index e68b136db711e208acfd0c5794b722c3a1ab4ae5..3bdd75a2ed813b69a3cfd31bb0fa792679a1b582 100644 (file)
@@ -145,6 +145,9 @@ extern int flag_newer;
 /* When nonzero, call a library routine to do integer divisions. */
 extern int flag_use_divide_subroutine;
 
+/* When nonzero, use atomic builtins. */
+extern int flag_use_atomic_builtins;
+
 /* When nonzero, generate code for the Boehm GC.  */
 extern int flag_use_boehm_gc;
 
index 24f2e166a6408d0bc21d2d8a9cf9f5fc650a130f..9e57dab651cc3dfb0eeb19d87e0032e06e592956 100644 (file)
@@ -73,6 +73,7 @@ static const char jvgenmain_spec[] =
                   %<fclasspath* %<fCLASSPATH* %<fbootclasspath*\
                   %<fextdirs*\
                   %<fuse-divide-subroutine %<fno-use-divide-subroutine\
+                  %<fuse-atomic-builtins %<fno-use-atomic-builtins\
                   %<fcheck-references %<fno-check-references\
                   %<ffilelist-file %<fsaw-java-file %<fsource* %<ftarget*\
                   %{f*} -fdollars-in-identifiers\
index 8af1bd59e4601395a38bd7ccd0b7774119b2901b..9e9a8cb5210862805727d541b0cdcd4bc333b27a 100644 (file)
@@ -192,6 +192,10 @@ fuse-divide-subroutine
 Java Var(flag_use_divide_subroutine) Init(1)
 Call a library routine to do integer divisions
 
+fuse-atomic-builtins
+Java Var(flag_use_atomic_builtins) Init(0)
+Generate code for built-in atomic operations
+
 fbootstrap-classes
 Java Var(flag_bootstrap_classes)
 Generated should be loaded by bootstrap loader