]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
sparc: Convert to atomic_load/store.
authorRichard Henderson <rth@redhat.com>
Wed, 30 Nov 2011 15:48:13 +0000 (07:48 -0800)
committerRichard Henderson <rth@gcc.gnu.org>
Wed, 30 Nov 2011 15:48:13 +0000 (07:48 -0800)
        * config/sparc/predicates.md (register_or_v9_zero_operand): New.
        * config/sparc/sparc.md (UNSPEC_ATOMIC): New.
        * config/sparc/sync.md (atomic_load<I>): New.
        (atomic_loaddi_1, atomic_store<I>, atomic_storedi_1): New.

From-SVN: r181849

gcc/ChangeLog
gcc/config/sparc/predicates.md
gcc/config/sparc/sparc.md
gcc/config/sparc/sync.md

index eee535f904798225ac4addd9efe8867fee478638..e48130eb0eee5b7ea4834f13c071c993beb4621f 100644 (file)
@@ -1,3 +1,10 @@
+2011-11-30  Richard Henderson  <rth@redhat.com>
+
+       * config/sparc/predicates.md (register_or_v9_zero_operand): New.
+       * config/sparc/sparc.md (UNSPEC_ATOMIC): New.
+       * config/sparc/sync.md (atomic_load<I>): New.
+       (atomic_loaddi_1, atomic_store<I>, atomic_storedi_1): New.
+
 2011-11-30  Richard Henderson  <rth@redhat.com>
 
        * config/sparc/predicates.md (zero_or_v7_operand): New.
index 047b21786fcf8305abd69f9854063b9d5857562b..a9207beaadb1704655863d95b3061a7ce8014c0c 100644 (file)
   (ior (match_operand 0 "register_operand")
        (match_operand 0 "const_zero_operand")))
 
+(define_predicate "register_or_v9_zero_operand"
+  (ior (match_operand 0 "register_operand")
+       (and (match_test "TARGET_V9")
+           (match_operand 0 "const_zero_operand"))))
+
 ;; Return true if OP is either the zero constant, the all-ones
 ;; constant, or a register.
 (define_predicate "register_or_zero_or_all_ones_operand"
index c059dc5e730c52e80941c4d30dcd46b17ed56053..37ac1701b69559ab1887322276edb7545d08f686 100644 (file)
@@ -41,6 +41,7 @@
    (UNSPEC_MOVE_GOTDATA                19)
 
    (UNSPEC_MEMBAR              20)
+   (UNSPEC_ATOMIC              21)
 
    (UNSPEC_TLSGD               30)
    (UNSPEC_TLSLDM              31)
index e22f5167fecbe2ff1a898e244ae63b2a68e2438b..e2f45968666cafb864daa3d688bca63b64c0dd68 100644 (file)
   "membar\t%1"
   [(set_attr "type" "multi")])
 
+(define_expand "atomic_load<mode>"
+  [(match_operand:I 0 "register_operand" "")
+   (match_operand:I 1 "memory_operand" "")
+   (match_operand:SI 2 "const_int_operand" "")]
+  ""
+{
+  enum memmodel model = (enum memmodel) INTVAL (operands[2]);
+
+  sparc_emit_membar_for_model (model, 1, 1);
+
+  if (TARGET_ARCH64 || <MODE>mode != DImode)
+    emit_move_insn (operands[0], operands[1]);
+  else
+    emit_insn (gen_atomic_loaddi_1 (operands[0], operands[1]));
+
+  sparc_emit_membar_for_model (model, 1, 2);
+  DONE;
+})
+
+(define_insn "atomic_loaddi_1"
+  [(set (match_operand:DI 0 "register_operand" "=U,?*f")
+       (unspec:DI [(match_operand:DI 1 "memory_operand" "m,m")]
+                  UNSPEC_ATOMIC))]
+  "!TARGET_ARCH64"
+  "ldd\t%1, %0"
+  [(set_attr "type" "load,fpload")])
+
+(define_expand "atomic_store<mode>"
+  [(match_operand:I 0 "register_operand" "")
+   (match_operand:I 1 "memory_operand" "")
+   (match_operand:SI 2 "const_int_operand" "")]
+  ""
+{
+  enum memmodel model = (enum memmodel) INTVAL (operands[2]);
+
+  sparc_emit_membar_for_model (model, 2, 1);
+
+  if (TARGET_ARCH64 || <MODE>mode != DImode)
+    emit_move_insn (operands[0], operands[1]);
+  else
+    emit_insn (gen_atomic_storedi_1 (operands[0], operands[1]));
+
+  sparc_emit_membar_for_model (model, 2, 2);
+  DONE;
+})
+
+(define_insn "atomic_storedi_1"
+  [(set (match_operand:DI 0 "memory_operand" "=m,m,m")
+       (unspec:DI
+         [(match_operand:DI 1 "register_or_v9_zero_operand" "J,U,?*f")]
+         UNSPEC_ATOMIC))]
+  "!TARGET_ARCH64"
+  "@
+   stx\t%r1, %0
+   std\t%1, %0
+   std\t%1, %0"
+  [(set_attr "type" "store,store,fpstore")
+   (set_attr "cpu_feature" "v9,*,*")])
+
 ;;;;;;;;
 
 (define_expand "sync_compare_and_swap<mode>"