]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cris.c (cris_init_libfuncs): Handle initialization of library functions for basic...
authorHans-Peter Nilsson <hp@axis.com>
Mon, 16 Jul 2012 03:18:23 +0000 (03:18 +0000)
committerHans-Peter Nilsson <hp@gcc.gnu.org>
Mon, 16 Jul 2012 03:18:23 +0000 (03:18 +0000)
* config/cris/cris.c (cris_init_libfuncs): Handle initialization
of library functions for basic atomic compare-and-swap.
* config/cris/cris.h (TARGET_ATOMICS_MAY_CALL_LIBFUNCS): New macro.
* config/cris/cris.opt (munaligned-atomic-may-use-library): New
option.
* config/cris/sync.md ("atomic_fetch_<atomic_op_name><mode>")
("cris_atomic_fetch_<atomic_op_name><mode>_1")
("atomic_compare_and_swap<mode>")
("cris_atomic_compare_and_swap<mode>_1"): Make
conditional on TARGET_ATOMICS_MAY_CALL_LIBFUNCS for
sizes larger than byte.

From-SVN: r189504

gcc/ChangeLog
gcc/config/cris/cris.c
gcc/config/cris/cris.h
gcc/config/cris/cris.opt
gcc/config/cris/sync.md

index 5d08b5ab93dae20c24cde5541afb2a4efdc65bfa..4899570261e07ef891c7cd2e6beb65f097f45707 100644 (file)
@@ -1,5 +1,16 @@
 2012-07-16  Hans-Peter Nilsson  <hp@axis.com>
 
+       * config/cris/cris.c (cris_init_libfuncs): Handle initialization
+       of library functions for basic atomic compare-and-swap.
+       * config/cris/cris.h (TARGET_ATOMICS_MAY_CALL_LIBFUNCS): New macro.
+       * config/cris/cris.opt (munaligned-atomic-may-use-library): New
+       option.
+       * config/cris/sync.md ("atomic_fetch_<atomic_op_name><mode>")
+       ("cris_atomic_fetch_<atomic_op_name><mode>_1")
+       ("atomic_compare_and_swap<mode>")
+       ("cris_atomic_compare_and_swap<mode>_1"): Make
+       conditional on TARGET_ATOMICS_MAY_CALL_LIBFUNCS for
+       sizes larger than byte.
        * config/cris/cris.c (cris_print_operand) <case 'P', 'q'>: New cases.
        * config/cris/sync.md (atomic_op_op_cnstr): New code_attr.
        (atomic_op_op_pred): Ditto.
index 44e328bfb2ac84f5573401be336cd8852f17da3f..71bb276003499e8f3ae3390c8c09959ab48a615c 100644 (file)
@@ -2761,6 +2761,16 @@ cris_init_libfuncs (void)
   set_optab_libfunc (udiv_optab, SImode, "__Udiv");
   set_optab_libfunc (smod_optab, SImode, "__Mod");
   set_optab_libfunc (umod_optab, SImode, "__Umod");
+
+  /* Atomic data being unaligned is unfortunately a reality.
+     Deal with it.  */
+  if (TARGET_ATOMICS_MAY_CALL_LIBFUNCS)
+    {
+      set_optab_libfunc (sync_compare_and_swap_optab, SImode,
+                        "__cris_atcmpxchgr32");
+      set_optab_libfunc (sync_compare_and_swap_optab, HImode,
+                        "__cris_atcmpxchgr16");
+    }
 }
 
 /* The INIT_EXPANDERS worker sets the per-function-data initializer and
index b0bc57f7c0fecc83b0ccc6be18240529e93bf774..d5cf85e4ba52fb6057ef0e22e9ae24aeaf6f7a39 100644 (file)
@@ -316,6 +316,11 @@ extern int cris_cpu_version;
 #define TARGET_TRAP_USING_BREAK8 \
  (cris_trap_using_break8 == 2 ? TARGET_HAS_BREAK : cris_trap_using_break8)
 
+/* Call library functions by default for GNU/Linux.  */
+#define TARGET_ATOMICS_MAY_CALL_LIBFUNCS               \
+ (cris_atomics_calling_libfunc == 2                    \
+  ? TARGET_LINUX : cris_atomics_calling_libfunc)
+
 /* The < v10 atomics turn off interrupts, so they don't need alignment.
    Incidentally, by default alignment is off there causing variables to
    be default unaligned all over, so we'd have to make support
index ebbddaa422eb3f0f346a3905bb94c27e191caa68..d4433a7739945f5196b9b3df6670fd6267f6b80f 100644 (file)
@@ -183,6 +183,10 @@ mtrap-unaligned-atomic
 Target Report Var(cris_trap_unaligned_atomic) Init(2)
 Emit checks causing \"break 8\" instructions to execute when applying atomic builtins on misaligned memory
 
+munaligned-atomic-may-use-library
+Target Report Var(cris_atomics_calling_libfunc) Init(2)
+Handle atomic builtins that may be applied to unaligned data by calling library functions. Overrides -mtrap-unaligned-atomic.
+
 ; TARGET_SVINTO: Currently this just affects alignment.  FIXME:
 ; Redundant with TARGET_ALIGN_BY_32, or put machine stuff here?
 ; This and the others below could just as well be variables and
index b1dac815ddaf1be9989e73307a09d17d2faf1763..1066db0ab7baf4cd52d701b07c88b1207e90a33b 100644 (file)
    (set (match_operand:BWD 0 "register_operand" "=&r")
        (match_dup 1))
    (clobber (match_scratch:SI 3 "=&r"))]
-  ""
+  "<MODE>mode == QImode || !TARGET_ATOMICS_MAY_CALL_LIBFUNCS"
 {
   /* Can't be too sure; better ICE if this happens.  */
   gcc_assert (!reg_overlap_mentioned_p (operands[2], operands[1]));
    (match_operand 5)
    (match_operand 6)
    (match_operand 7)]
-  ""
+  "<MODE>mode == QImode || !TARGET_ATOMICS_MAY_CALL_LIBFUNCS"
 {
   enum memmodel mmodel = (enum memmodel) INTVAL (operands[6]);
 
          (match_dup 3)
          (match_operand:BWD 4 "register_operand" "r")]
         CRIS_UNSPEC_ATOMIC_SWAP_MEM))]
-  ""
+  "<MODE>mode == QImode || !TARGET_ATOMICS_MAY_CALL_LIBFUNCS"
 {
   if (TARGET_V32)
     return