1 ;; GCC machine description for Alpha synchronization instructions.
3 ;; Free Software Foundation, Inc.
5 ;; This file is part of GCC.
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)
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.
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, 51 Franklin Street, Fifth Floor,
20 ;; Boston, MA 02110-1301, USA.
22 (define_code_macro FETCHOP [plus minus ior xor and])
23 (define_code_attr fetchop_name
24 [(plus "add") (minus "sub") (ior "ior") (xor "xor") (and "and")])
25 (define_code_attr fetchop_pred
26 [(plus "add_operand") (minus "reg_or_8bit_operand")
27 (ior "or_operand") (xor "or_operand") (and "and_operand")])
28 (define_code_attr fetchop_constr
29 [(plus "rKL") (minus "rI") (ior "rIN") (xor "rIN") (and "riNHM")])
32 (define_expand "memory_barrier"
33 [(set (mem:BLK (match_dup 0))
34 (unspec:BLK [(mem:BLK (match_dup 0))] UNSPEC_MB))]
37 operands[0] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (DImode));
38 MEM_VOLATILE_P (operands[0]) = 1;
41 (define_insn "*mb_internal"
42 [(set (match_operand:BLK 0 "" "")
43 (unspec:BLK [(match_operand:BLK 1 "" "")] UNSPEC_MB))]
46 [(set_attr "type" "mb")])
48 (define_insn "load_locked_<mode>"
49 [(set (match_operand:I48MODE 0 "register_operand" "=r")
50 (unspec_volatile:I48MODE
51 [(match_operand:I48MODE 1 "memory_operand" "m")]
54 "ld<modesuffix>_l %0,%1"
55 [(set_attr "type" "ld_l")])
57 (define_insn "store_conditional_<mode>"
58 [(set (match_operand:DI 0 "register_operand" "=r")
59 (unspec_volatile:DI [(const_int 0)] UNSPECV_SC))
60 (set (match_operand:I48MODE 1 "memory_operand" "=m")
61 (match_operand:I48MODE 2 "reg_or_0_operand" "0"))]
63 "st<modesuffix>_c %0,%1"
64 [(set_attr "type" "st_c")])
66 ;; The Alpha Architecture Handbook says that it is UNPREDICTABLE whether
67 ;; the lock is cleared by a TAKEN branch. If we were to honor that, it
68 ;; would mean that we could not expand a ll/sc sequence until after the
69 ;; final basic-block reordering pass. Fortunately, it appears that no
70 ;; Alpha implementation ever built actually clears the lock on branches,
73 (define_insn_and_split "sync_<fetchop_name><mode>"
74 [(set (match_operand:I48MODE 0 "memory_operand" "+m")
76 [(FETCHOP:I48MODE (match_dup 0)
77 (match_operand:I48MODE 1 "<fetchop_pred>" "<fetchop_constr>"))]
79 (clobber (match_scratch:I48MODE 2 "=&r"))]
85 alpha_split_atomic_op (<CODE>, operands[0], operands[1],
86 NULL, NULL, operands[2]);
89 [(set_attr "type" "multi")])
91 (define_insn_and_split "sync_nand<mode>"
92 [(set (match_operand:I48MODE 0 "memory_operand" "+m")
94 [(and:I48MODE (not:I48MODE (match_dup 0))
95 (match_operand:I48MODE 1 "register_operand" "r"))]
97 (clobber (match_scratch:I48MODE 2 "=&r"))]
103 alpha_split_atomic_op (NOT, operands[0], operands[1],
104 NULL, NULL, operands[2]);
107 [(set_attr "type" "multi")])
109 (define_insn_and_split "sync_old_<fetchop_name><mode>"
110 [(set (match_operand:I48MODE 0 "register_operand" "=&r")
111 (match_operand:I48MODE 1 "memory_operand" "+m"))
114 [(FETCHOP:I48MODE (match_dup 1)
115 (match_operand:I48MODE 2 "<fetchop_pred>" "<fetchop_constr>"))]
117 (clobber (match_scratch:I48MODE 3 "=&r"))]
123 alpha_split_atomic_op (<CODE>, operands[1], operands[2],
124 operands[0], NULL, operands[3]);
127 [(set_attr "type" "multi")])
129 (define_insn_and_split "sync_old_nand<mode>"
130 [(set (match_operand:I48MODE 0 "register_operand" "=&r")
131 (match_operand:I48MODE 1 "memory_operand" "+m"))
134 [(and:I48MODE (not:I48MODE (match_dup 1))
135 (match_operand:I48MODE 2 "register_operand" "r"))]
137 (clobber (match_scratch:I48MODE 3 "=&r"))]
143 alpha_split_atomic_op (NOT, operands[1], operands[2],
144 operands[0], NULL, operands[3]);
147 [(set_attr "type" "multi")])
149 (define_insn_and_split "sync_new_<fetchop_name><mode>"
150 [(set (match_operand:I48MODE 0 "register_operand" "=&r")
152 (match_operand:I48MODE 1 "memory_operand" "+m")
153 (match_operand:I48MODE 2 "<fetchop_pred>" "<fetchop_constr>")))
156 [(FETCHOP:I48MODE (match_dup 1) (match_dup 2))]
158 (clobber (match_scratch:I48MODE 3 "=&r"))]
164 alpha_split_atomic_op (<CODE>, operands[1], operands[2],
165 NULL, operands[0], operands[3]);
168 [(set_attr "type" "multi")])
170 (define_insn_and_split "sync_new_nand<mode>"
171 [(set (match_operand:I48MODE 0 "register_operand" "=&r")
173 (not:I48MODE (match_operand:I48MODE 1 "memory_operand" "+m"))
174 (match_operand:I48MODE 2 "register_operand" "r")))
177 [(and:I48MODE (not:I48MODE (match_dup 1)) (match_dup 2))]
179 (clobber (match_scratch:I48MODE 3 "=&r"))]
185 alpha_split_atomic_op (NOT, operands[1], operands[2],
186 NULL, operands[0], operands[3]);
189 [(set_attr "type" "multi")])
191 (define_expand "sync_compare_and_swap<mode>"
192 [(match_operand:I12MODE 0 "register_operand" "")
193 (match_operand:I12MODE 1 "memory_operand" "")
194 (match_operand:I12MODE 2 "register_operand" "")
195 (match_operand:I12MODE 3 "add_operand" "")]
198 alpha_expand_compare_and_swap_12 (operands[0], operands[1],
199 operands[2], operands[3]);
203 (define_insn_and_split "sync_compare_and_swap<mode>_1"
204 [(set (match_operand:DI 0 "register_operand" "=&r,&r")
206 (mem:I12MODE (match_operand:DI 1 "register_operand" "r,r"))))
207 (set (mem:I12MODE (match_dup 1))
209 [(match_operand:DI 2 "reg_or_8bit_operand" "J,rI")
210 (match_operand:DI 3 "register_operand" "r,r")
211 (match_operand:DI 4 "register_operand" "r,r")]
213 (clobber (match_scratch:DI 5 "=&r,&r"))
214 (clobber (match_scratch:DI 6 "=X,&r"))]
220 alpha_split_compare_and_swap_12 (<MODE>mode, operands[0], operands[1],
221 operands[2], operands[3], operands[4],
222 operands[5], operands[6]);
225 [(set_attr "type" "multi")])
227 (define_expand "sync_compare_and_swap<mode>"
229 [(set (match_operand:I48MODE 0 "register_operand" "")
230 (match_operand:I48MODE 1 "memory_operand" ""))
233 [(match_operand:I48MODE 2 "reg_or_8bit_operand" "")
234 (match_operand:I48MODE 3 "add_operand" "rKL")]
236 (clobber (match_scratch:I48MODE 4 "=&r"))])]
239 if (<MODE>mode == SImode)
240 operands[2] = convert_modes (DImode, SImode, operands[2], 0);
243 (define_insn_and_split "*sync_compare_and_swap<mode>"
244 [(set (match_operand:I48MODE 0 "register_operand" "=&r")
245 (match_operand:I48MODE 1 "memory_operand" "+m"))
248 [(match_operand:DI 2 "reg_or_8bit_operand" "rI")
249 (match_operand:I48MODE 3 "add_operand" "rKL")]
251 (clobber (match_scratch:I48MODE 4 "=&r"))]
257 alpha_split_compare_and_swap (operands[0], operands[1], operands[2],
258 operands[3], operands[4]);
261 [(set_attr "type" "multi")])
263 (define_expand "sync_lock_test_and_set<mode>"
264 [(match_operand:I12MODE 0 "register_operand" "")
265 (match_operand:I12MODE 1 "memory_operand" "")
266 (match_operand:I12MODE 2 "register_operand" "")]
269 alpha_expand_lock_test_and_set_12 (operands[0], operands[1], operands[2]);
273 (define_insn_and_split "sync_lock_test_and_set<mode>_1"
274 [(set (match_operand:DI 0 "register_operand" "=&r")
276 (mem:I12MODE (match_operand:DI 1 "register_operand" "r"))))
277 (set (mem:I12MODE (match_dup 1))
279 [(match_operand:DI 2 "reg_or_8bit_operand" "rI")
280 (match_operand:DI 3 "register_operand" "r")]
282 (clobber (match_scratch:DI 4 "=&r"))]
288 alpha_split_lock_test_and_set_12 (<MODE>mode, operands[0], operands[1],
289 operands[2], operands[3], operands[4]);
292 [(set_attr "type" "multi")])
294 (define_insn_and_split "sync_lock_test_and_set<mode>"
295 [(set (match_operand:I48MODE 0 "register_operand" "=&r")
296 (match_operand:I48MODE 1 "memory_operand" "+m"))
299 [(match_operand:I48MODE 2 "add_operand" "rKL")]
301 (clobber (match_scratch:I48MODE 3 "=&r"))]
307 alpha_split_lock_test_and_set (operands[0], operands[1],
308 operands[2], operands[3]);
311 [(set_attr "type" "multi")])