OSDN Git Service

* builtins.c (expand_builtin_sync_operation): Revert last change.
[pf3gnuchains/gcc-fork.git] / gcc / config / ia64 / sync.md
1 ;; GCC machine description for IA-64 synchronization instructions.
2 ;; Copyright (C) 2005
3 ;; Free Software Foundation, Inc.
4 ;;
5 ;; This file is part of GCC.
6 ;;
7 ;; GCC is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 2, or (at your option)
10 ;; any later version.
11 ;;
12 ;; GCC is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 ;; GNU General Public License for more details.
16 ;;
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GCC; see the file COPYING.  If not, write to
19 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
20 ;; Boston, MA 02111-1307, USA.
21
22 (define_mode_macro IMODE [QI HI SI DI])
23 (define_mode_macro I48MODE [SI DI])
24 (define_mode_attr modesuffix [(QI "1") (HI "2") (SI "4") (DI "8")])
25
26
27 (define_insn "memory_barrier"
28   [(set (mem:BLK (match_scratch:DI 0 "X"))
29         (unspec:BLK [(mem:BLK (match_scratch:DI 1 "X"))] UNSPEC_MF))]
30   ""
31   "mf"
32   [(set_attr "itanium_class" "syst_m")])
33
34 (define_expand "sync_add<mode>"
35   [(match_operand:I48MODE 0 "gr_register_operand" "")
36    (match_operand:I48MODE 1 "memory_operand" "")
37    (match_operand:I48MODE 2 "general_operand" "")]
38   ""
39 {
40   if (!fetchadd_operand (operands[2], <MODE>mode))
41     FAIL;
42   emit_insn (gen_memory_barrier ());
43   emit_insn (gen_fetchadd_acq_<mode> (operands[0], operands[1], operands[2]));
44   DONE;
45 })
46
47 (define_expand "sync_old_add<mode>"
48   [(match_operand:I48MODE 0 "gr_register_operand" "")
49    (match_operand:I48MODE 1 "memory_operand" "")
50    (match_operand:I48MODE 2 "general_operand" "")]
51   ""
52 {
53   if (!fetchadd_operand (operands[2], <MODE>mode))
54     FAIL;
55   emit_insn (gen_memory_barrier ());
56   emit_insn (gen_fetchadd_acq_<mode> (operands[0], operands[1], operands[2]));
57   DONE;
58 })
59
60 (define_insn "fetchadd_acq_<mode>"
61   [(set (match_operand:I48MODE 0 "gr_register_operand" "=r")
62         (match_operand:I48MODE 1 "not_postinc_memory_operand" "+S"))
63    (set (match_dup 1)
64         (unspec:I48MODE [(match_dup 1)
65                          (match_operand:I48MODE 2 "fetchadd_operand" "n")]
66                         UNSPEC_FETCHADD_ACQ))]
67   ""
68   "fetchadd<modesuffix>.acq %0 = %1, %2"
69   [(set_attr "itanium_class" "sem")])
70
71 (define_expand "sync_compare_and_swap<mode>"
72   [(match_operand:IMODE 0 "gr_register_operand" "")
73    (match_operand:IMODE 1 "memory_operand" "")
74    (match_operand:IMODE 2 "gr_register_operand" "")
75    (match_operand:IMODE 3 "gr_register_operand" "")]
76   ""
77 {
78   rtx ccv = gen_rtx_REG (DImode, AR_CCV_REGNUM);
79   convert_move (ccv, operands[2], 1);
80   emit_insn (gen_memory_barrier ());
81   emit_insn (gen_cmpxchg_acq_<mode> (operands[0], operands[1],
82                                      ccv, operands[3]));
83   DONE;
84 })
85
86 (define_insn "cmpxchg_acq_<mode>"
87   [(set (match_operand:IMODE 0 "gr_register_operand" "=r")
88         (match_operand:IMODE 1 "not_postinc_memory_operand" "+S"))
89    (set (match_dup 1)
90         (unspec:IMODE [(match_dup 1)
91                        (match_operand:DI 2 "ar_ccv_reg_operand" "")
92                        (match_operand:IMODE 3 "gr_register_operand" "r")]
93                       UNSPEC_CMPXCHG_ACQ))]
94   ""
95   "cmpxchg<modesuffix>.acq %0 = %1, %3, %2"
96   [(set_attr "itanium_class" "sem")])
97
98 (define_insn "sync_lock_test_and_set<mode>"
99   [(set (match_operand:IMODE 0 "gr_register_operand" "=r")
100         (match_operand:IMODE 1 "not_postinc_memory_operand" "+S"))
101    (set (match_dup 1)
102         (match_operand:IMODE 2 "gr_register_operand" "r"))]
103   ""
104   "xchg<modesuffix> %0 = %1, %2"
105   [(set_attr "itanium_class" "sem")])
106
107 (define_expand "sync_lock_release<mode>"
108   [(set (match_operand:IMODE 0 "memory_operand" "")
109         (match_operand:IMODE 1 "gr_reg_or_0_operand" ""))]
110   ""
111 {
112   gcc_assert (MEM_VOLATILE_P (operands[0]));
113 })