1 ;; GCC machine description for Alpha synchronization instructions.
2 ;; Copyright (C) 2005, 2007 Free Software Foundation, Inc.
4 ;; This file is part of GCC.
6 ;; GCC is free software; you can redistribute it and/or modify
7 ;; it under the terms of the GNU General Public License as published by
8 ;; the Free Software Foundation; either version 3, or (at your option)
11 ;; GCC is distributed in the hope that it will be useful,
12 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;; GNU General Public License for more details.
16 ;; You should have received a copy of the GNU General Public License
17 ;; along with GCC; see the file COPYING3. If not see
18 ;; <http://www.gnu.org/licenses/>.
20 (define_code_iterator FETCHOP [plus minus ior xor and])
21 (define_code_attr fetchop_name
22 [(plus "add") (minus "sub") (ior "ior") (xor "xor") (and "and")])
23 (define_code_attr fetchop_pred
24 [(plus "add_operand") (minus "reg_or_8bit_operand")
25 (ior "or_operand") (xor "or_operand") (and "and_operand")])
26 (define_code_attr fetchop_constr
27 [(plus "rKL") (minus "rI") (ior "rIN") (xor "rIN") (and "riNHM")])
30 (define_expand "memory_barrier"
31 [(set (mem:BLK (match_dup 0))
32 (unspec:BLK [(mem:BLK (match_dup 0))] UNSPEC_MB))]
35 operands[0] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (DImode));
36 MEM_VOLATILE_P (operands[0]) = 1;
39 (define_insn "*mb_internal"
40 [(set (match_operand:BLK 0 "" "")
41 (unspec:BLK [(match_operand:BLK 1 "" "")] UNSPEC_MB))]
44 [(set_attr "type" "mb")])
46 (define_insn "load_locked_<mode>"
47 [(set (match_operand:I48MODE 0 "register_operand" "=r")
48 (unspec_volatile:I48MODE
49 [(match_operand:I48MODE 1 "memory_operand" "m")]
52 "ld<modesuffix>_l %0,%1"
53 [(set_attr "type" "ld_l")])
55 (define_insn "store_conditional_<mode>"
56 [(set (match_operand:DI 0 "register_operand" "=r")
57 (unspec_volatile:DI [(const_int 0)] UNSPECV_SC))
58 (set (match_operand:I48MODE 1 "memory_operand" "=m")
59 (match_operand:I48MODE 2 "reg_or_0_operand" "0"))]
61 "st<modesuffix>_c %0,%1"
62 [(set_attr "type" "st_c")])
64 ;; The Alpha Architecture Handbook says that it is UNPREDICTABLE whether
65 ;; the lock is cleared by a TAKEN branch. If we were to honor that, it
66 ;; would mean that we could not expand a ll/sc sequence until after the
67 ;; final basic-block reordering pass. Fortunately, it appears that no
68 ;; Alpha implementation ever built actually clears the lock on branches,
71 (define_insn_and_split "sync_<fetchop_name><mode>"
72 [(set (match_operand:I48MODE 0 "memory_operand" "+m")
74 [(FETCHOP:I48MODE (match_dup 0)
75 (match_operand:I48MODE 1 "<fetchop_pred>" "<fetchop_constr>"))]
77 (clobber (match_scratch:I48MODE 2 "=&r"))]
83 alpha_split_atomic_op (<CODE>, operands[0], operands[1],
84 NULL, NULL, operands[2]);
87 [(set_attr "type" "multi")])
89 (define_insn_and_split "sync_nand<mode>"
90 [(set (match_operand:I48MODE 0 "memory_operand" "+m")
92 [(and:I48MODE (not:I48MODE (match_dup 0))
93 (match_operand:I48MODE 1 "register_operand" "r"))]
95 (clobber (match_scratch:I48MODE 2 "=&r"))]
101 alpha_split_atomic_op (NOT, operands[0], operands[1],
102 NULL, NULL, operands[2]);
105 [(set_attr "type" "multi")])
107 (define_insn_and_split "sync_old_<fetchop_name><mode>"
108 [(set (match_operand:I48MODE 0 "register_operand" "=&r")
109 (match_operand:I48MODE 1 "memory_operand" "+m"))
112 [(FETCHOP:I48MODE (match_dup 1)
113 (match_operand:I48MODE 2 "<fetchop_pred>" "<fetchop_constr>"))]
115 (clobber (match_scratch:I48MODE 3 "=&r"))]
121 alpha_split_atomic_op (<CODE>, operands[1], operands[2],
122 operands[0], NULL, operands[3]);
125 [(set_attr "type" "multi")])
127 (define_insn_and_split "sync_old_nand<mode>"
128 [(set (match_operand:I48MODE 0 "register_operand" "=&r")
129 (match_operand:I48MODE 1 "memory_operand" "+m"))
132 [(and:I48MODE (not:I48MODE (match_dup 1))
133 (match_operand:I48MODE 2 "register_operand" "r"))]
135 (clobber (match_scratch:I48MODE 3 "=&r"))]
141 alpha_split_atomic_op (NOT, operands[1], operands[2],
142 operands[0], NULL, operands[3]);
145 [(set_attr "type" "multi")])
147 (define_insn_and_split "sync_new_<fetchop_name><mode>"
148 [(set (match_operand:I48MODE 0 "register_operand" "=&r")
150 (match_operand:I48MODE 1 "memory_operand" "+m")
151 (match_operand:I48MODE 2 "<fetchop_pred>" "<fetchop_constr>")))
154 [(FETCHOP:I48MODE (match_dup 1) (match_dup 2))]
156 (clobber (match_scratch:I48MODE 3 "=&r"))]
162 alpha_split_atomic_op (<CODE>, operands[1], operands[2],
163 NULL, operands[0], operands[3]);
166 [(set_attr "type" "multi")])
168 (define_insn_and_split "sync_new_nand<mode>"
169 [(set (match_operand:I48MODE 0 "register_operand" "=&r")
171 (not:I48MODE (match_operand:I48MODE 1 "memory_operand" "+m"))
172 (match_operand:I48MODE 2 "register_operand" "r")))
175 [(and:I48MODE (not:I48MODE (match_dup 1)) (match_dup 2))]
177 (clobber (match_scratch:I48MODE 3 "=&r"))]
183 alpha_split_atomic_op (NOT, operands[1], operands[2],
184 NULL, operands[0], operands[3]);
187 [(set_attr "type" "multi")])
189 (define_expand "sync_compare_and_swap<mode>"
190 [(match_operand:I12MODE 0 "register_operand" "")
191 (match_operand:I12MODE 1 "memory_operand" "")
192 (match_operand:I12MODE 2 "register_operand" "")
193 (match_operand:I12MODE 3 "add_operand" "")]
196 alpha_expand_compare_and_swap_12 (operands[0], operands[1],
197 operands[2], operands[3]);
201 (define_insn_and_split "sync_compare_and_swap<mode>_1"
202 [(set (match_operand:DI 0 "register_operand" "=&r,&r")
204 (mem:I12MODE (match_operand:DI 1 "register_operand" "r,r"))))
205 (set (mem:I12MODE (match_dup 1))
207 [(match_operand:DI 2 "reg_or_8bit_operand" "J,rI")
208 (match_operand:DI 3 "register_operand" "r,r")
209 (match_operand:DI 4 "register_operand" "r,r")]
211 (clobber (match_scratch:DI 5 "=&r,&r"))
212 (clobber (match_scratch:DI 6 "=X,&r"))]
218 alpha_split_compare_and_swap_12 (<MODE>mode, operands[0], operands[1],
219 operands[2], operands[3], operands[4],
220 operands[5], operands[6]);
223 [(set_attr "type" "multi")])
225 (define_expand "sync_compare_and_swap<mode>"
227 [(set (match_operand:I48MODE 0 "register_operand" "")
228 (match_operand:I48MODE 1 "memory_operand" ""))
231 [(match_operand:I48MODE 2 "reg_or_8bit_operand" "")
232 (match_operand:I48MODE 3 "add_operand" "rKL")]
234 (clobber (match_scratch:I48MODE 4 "=&r"))])]
237 if (<MODE>mode == SImode)
238 operands[2] = convert_modes (DImode, SImode, operands[2], 0);
241 (define_insn_and_split "*sync_compare_and_swap<mode>"
242 [(set (match_operand:I48MODE 0 "register_operand" "=&r")
243 (match_operand:I48MODE 1 "memory_operand" "+m"))
246 [(match_operand:DI 2 "reg_or_8bit_operand" "rI")
247 (match_operand:I48MODE 3 "add_operand" "rKL")]
249 (clobber (match_scratch:I48MODE 4 "=&r"))]
255 alpha_split_compare_and_swap (operands[0], operands[1], operands[2],
256 operands[3], operands[4]);
259 [(set_attr "type" "multi")])
261 (define_expand "sync_lock_test_and_set<mode>"
262 [(match_operand:I12MODE 0 "register_operand" "")
263 (match_operand:I12MODE 1 "memory_operand" "")
264 (match_operand:I12MODE 2 "register_operand" "")]
267 alpha_expand_lock_test_and_set_12 (operands[0], operands[1], operands[2]);
271 (define_insn_and_split "sync_lock_test_and_set<mode>_1"
272 [(set (match_operand:DI 0 "register_operand" "=&r")
274 (mem:I12MODE (match_operand:DI 1 "register_operand" "r"))))
275 (set (mem:I12MODE (match_dup 1))
277 [(match_operand:DI 2 "reg_or_8bit_operand" "rI")
278 (match_operand:DI 3 "register_operand" "r")]
280 (clobber (match_scratch:DI 4 "=&r"))]
286 alpha_split_lock_test_and_set_12 (<MODE>mode, operands[0], operands[1],
287 operands[2], operands[3], operands[4]);
290 [(set_attr "type" "multi")])
292 (define_insn_and_split "sync_lock_test_and_set<mode>"
293 [(set (match_operand:I48MODE 0 "register_operand" "=&r")
294 (match_operand:I48MODE 1 "memory_operand" "+m"))
297 [(match_operand:I48MODE 2 "add_operand" "rKL")]
299 (clobber (match_scratch:I48MODE 3 "=&r"))]
305 alpha_split_lock_test_and_set (operands[0], operands[1],
306 operands[2], operands[3]);
309 [(set_attr "type" "multi")])