annotate gcc/config/i386/sync.md @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 ;; GCC machine description for i386 synchronization instructions.
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
2 ;; Copyright (C) 2005-2020 Free Software Foundation, Inc.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 ;;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 ;; This file is part of GCC.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 ;;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 ;; GCC is free software; you can redistribute it and/or modify
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 ;; it under the terms of the GNU General Public License as published by
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 ;; the Free Software Foundation; either version 3, or (at your option)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 ;; any later version.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 ;;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 ;; GCC is distributed in the hope that it will be useful,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 ;; GNU General Public License for more details.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 ;;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 ;; You should have received a copy of the GNU General Public License
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 ;; along with GCC; see the file COPYING3. If not see
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 ;; <http://www.gnu.org/licenses/>.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19
111
kono
parents: 63
diff changeset
20 (define_c_enum "unspec" [
kono
parents: 63
diff changeset
21 UNSPEC_LFENCE
kono
parents: 63
diff changeset
22 UNSPEC_SFENCE
kono
parents: 63
diff changeset
23 UNSPEC_MFENCE
kono
parents: 63
diff changeset
24
kono
parents: 63
diff changeset
25 UNSPEC_FILD_ATOMIC
kono
parents: 63
diff changeset
26 UNSPEC_FIST_ATOMIC
kono
parents: 63
diff changeset
27
kono
parents: 63
diff changeset
28 UNSPEC_LDX_ATOMIC
kono
parents: 63
diff changeset
29 UNSPEC_STX_ATOMIC
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30
111
kono
parents: 63
diff changeset
31 ;; __atomic support
kono
parents: 63
diff changeset
32 UNSPEC_LDA
kono
parents: 63
diff changeset
33 UNSPEC_STA
kono
parents: 63
diff changeset
34 ])
kono
parents: 63
diff changeset
35
kono
parents: 63
diff changeset
36 (define_c_enum "unspecv" [
kono
parents: 63
diff changeset
37 UNSPECV_CMPXCHG
kono
parents: 63
diff changeset
38 UNSPECV_XCHG
kono
parents: 63
diff changeset
39 UNSPECV_LOCK
kono
parents: 63
diff changeset
40 ])
kono
parents: 63
diff changeset
41
kono
parents: 63
diff changeset
42 (define_expand "sse2_lfence"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 [(set (match_dup 0)
111
kono
parents: 63
diff changeset
44 (unspec:BLK [(match_dup 0)] UNSPEC_LFENCE))]
kono
parents: 63
diff changeset
45 "TARGET_SSE2"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 operands[0] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 MEM_VOLATILE_P (operands[0]) = 1;
111
kono
parents: 63
diff changeset
49 })
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
50
111
kono
parents: 63
diff changeset
51 (define_insn "*sse2_lfence"
kono
parents: 63
diff changeset
52 [(set (match_operand:BLK 0)
kono
parents: 63
diff changeset
53 (unspec:BLK [(match_dup 0)] UNSPEC_LFENCE))]
kono
parents: 63
diff changeset
54 "TARGET_SSE2"
kono
parents: 63
diff changeset
55 "lfence"
kono
parents: 63
diff changeset
56 [(set_attr "type" "sse")
kono
parents: 63
diff changeset
57 (set_attr "length_address" "0")
kono
parents: 63
diff changeset
58 (set_attr "atom_sse_attr" "lfence")
kono
parents: 63
diff changeset
59 (set_attr "memory" "unknown")])
kono
parents: 63
diff changeset
60
kono
parents: 63
diff changeset
61 (define_expand "sse_sfence"
kono
parents: 63
diff changeset
62 [(set (match_dup 0)
kono
parents: 63
diff changeset
63 (unspec:BLK [(match_dup 0)] UNSPEC_SFENCE))]
kono
parents: 63
diff changeset
64 "TARGET_SSE || TARGET_3DNOW_A"
kono
parents: 63
diff changeset
65 {
kono
parents: 63
diff changeset
66 operands[0] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
kono
parents: 63
diff changeset
67 MEM_VOLATILE_P (operands[0]) = 1;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 })
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
69
111
kono
parents: 63
diff changeset
70 (define_insn "*sse_sfence"
kono
parents: 63
diff changeset
71 [(set (match_operand:BLK 0)
kono
parents: 63
diff changeset
72 (unspec:BLK [(match_dup 0)] UNSPEC_SFENCE))]
kono
parents: 63
diff changeset
73 "TARGET_SSE || TARGET_3DNOW_A"
kono
parents: 63
diff changeset
74 "sfence"
kono
parents: 63
diff changeset
75 [(set_attr "type" "sse")
kono
parents: 63
diff changeset
76 (set_attr "length_address" "0")
kono
parents: 63
diff changeset
77 (set_attr "atom_sse_attr" "fence")
kono
parents: 63
diff changeset
78 (set_attr "memory" "unknown")])
kono
parents: 63
diff changeset
79
kono
parents: 63
diff changeset
80 (define_expand "sse2_mfence"
kono
parents: 63
diff changeset
81 [(set (match_dup 0)
kono
parents: 63
diff changeset
82 (unspec:BLK [(match_dup 0)] UNSPEC_MFENCE))]
kono
parents: 63
diff changeset
83 "TARGET_SSE2"
kono
parents: 63
diff changeset
84 {
kono
parents: 63
diff changeset
85 operands[0] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
kono
parents: 63
diff changeset
86 MEM_VOLATILE_P (operands[0]) = 1;
kono
parents: 63
diff changeset
87 })
kono
parents: 63
diff changeset
88
kono
parents: 63
diff changeset
89 (define_insn "mfence_sse2"
kono
parents: 63
diff changeset
90 [(set (match_operand:BLK 0)
kono
parents: 63
diff changeset
91 (unspec:BLK [(match_dup 0)] UNSPEC_MFENCE))]
kono
parents: 63
diff changeset
92 "TARGET_64BIT || TARGET_SSE2"
kono
parents: 63
diff changeset
93 "mfence"
kono
parents: 63
diff changeset
94 [(set_attr "type" "sse")
kono
parents: 63
diff changeset
95 (set_attr "length_address" "0")
kono
parents: 63
diff changeset
96 (set_attr "atom_sse_attr" "fence")
kono
parents: 63
diff changeset
97 (set_attr "memory" "unknown")])
kono
parents: 63
diff changeset
98
kono
parents: 63
diff changeset
99 (define_insn "mfence_nosse"
kono
parents: 63
diff changeset
100 [(set (match_operand:BLK 0)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 (unspec:BLK [(match_dup 0)] UNSPEC_MFENCE))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 (clobber (reg:CC FLAGS_REG))]
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 "!(TARGET_64BIT || TARGET_SSE2)"
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
104 "lock{%;} or{l}\t{$0, (%%esp)|DWORD PTR [esp], 0}"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 [(set_attr "memory" "unknown")])
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
106
111
kono
parents: 63
diff changeset
107 (define_expand "mem_thread_fence"
kono
parents: 63
diff changeset
108 [(match_operand:SI 0 "const_int_operand")] ;; model
kono
parents: 63
diff changeset
109 ""
kono
parents: 63
diff changeset
110 {
kono
parents: 63
diff changeset
111 enum memmodel model = memmodel_from_int (INTVAL (operands[0]));
kono
parents: 63
diff changeset
112
kono
parents: 63
diff changeset
113 /* Unless this is a SEQ_CST fence, the i386 memory model is strong
kono
parents: 63
diff changeset
114 enough not to require barriers of any kind. */
kono
parents: 63
diff changeset
115 if (is_mm_seq_cst (model))
kono
parents: 63
diff changeset
116 {
kono
parents: 63
diff changeset
117 rtx (*mfence_insn)(rtx);
kono
parents: 63
diff changeset
118 rtx mem;
kono
parents: 63
diff changeset
119
kono
parents: 63
diff changeset
120 if (TARGET_64BIT || TARGET_SSE2)
kono
parents: 63
diff changeset
121 mfence_insn = gen_mfence_sse2;
kono
parents: 63
diff changeset
122 else
kono
parents: 63
diff changeset
123 mfence_insn = gen_mfence_nosse;
kono
parents: 63
diff changeset
124
kono
parents: 63
diff changeset
125 mem = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
kono
parents: 63
diff changeset
126 MEM_VOLATILE_P (mem) = 1;
kono
parents: 63
diff changeset
127
kono
parents: 63
diff changeset
128 emit_insn (mfence_insn (mem));
kono
parents: 63
diff changeset
129 }
kono
parents: 63
diff changeset
130 DONE;
kono
parents: 63
diff changeset
131 })
kono
parents: 63
diff changeset
132
kono
parents: 63
diff changeset
133 ;; ??? From volume 3 section 8.1.1 Guaranteed Atomic Operations,
kono
parents: 63
diff changeset
134 ;; Only beginning at Pentium family processors do we get any guarantee of
kono
parents: 63
diff changeset
135 ;; atomicity in aligned 64-bit quantities. Beginning at P6, we get a
kono
parents: 63
diff changeset
136 ;; guarantee for 64-bit accesses that do not cross a cacheline boundary.
kono
parents: 63
diff changeset
137 ;;
kono
parents: 63
diff changeset
138 ;; Note that the TARGET_CMPXCHG8B test below is a stand-in for "Pentium".
kono
parents: 63
diff changeset
139 ;;
kono
parents: 63
diff changeset
140 ;; Importantly, *no* processor makes atomicity guarantees for larger
kono
parents: 63
diff changeset
141 ;; accesses. In particular, there's no way to perform an atomic TImode
kono
parents: 63
diff changeset
142 ;; move, despite the apparent applicability of MOVDQA et al.
kono
parents: 63
diff changeset
143
kono
parents: 63
diff changeset
144 (define_mode_iterator ATOMIC
kono
parents: 63
diff changeset
145 [QI HI SI
kono
parents: 63
diff changeset
146 (DI "TARGET_64BIT || (TARGET_CMPXCHG8B && (TARGET_80387 || TARGET_SSE))")
kono
parents: 63
diff changeset
147 ])
kono
parents: 63
diff changeset
148
kono
parents: 63
diff changeset
149 (define_expand "atomic_load<mode>"
kono
parents: 63
diff changeset
150 [(set (match_operand:ATOMIC 0 "nonimmediate_operand")
kono
parents: 63
diff changeset
151 (unspec:ATOMIC [(match_operand:ATOMIC 1 "memory_operand")
kono
parents: 63
diff changeset
152 (match_operand:SI 2 "const_int_operand")]
kono
parents: 63
diff changeset
153 UNSPEC_LDA))]
kono
parents: 63
diff changeset
154 ""
kono
parents: 63
diff changeset
155 {
kono
parents: 63
diff changeset
156 /* For DImode on 32-bit, we can use the FPU to perform the load. */
kono
parents: 63
diff changeset
157 if (<MODE>mode == DImode && !TARGET_64BIT)
kono
parents: 63
diff changeset
158 emit_insn (gen_atomic_loaddi_fpu
kono
parents: 63
diff changeset
159 (operands[0], operands[1],
kono
parents: 63
diff changeset
160 assign_386_stack_local (DImode, SLOT_TEMP)));
kono
parents: 63
diff changeset
161 else
kono
parents: 63
diff changeset
162 {
kono
parents: 63
diff changeset
163 rtx dst = operands[0];
kono
parents: 63
diff changeset
164
kono
parents: 63
diff changeset
165 if (MEM_P (dst))
kono
parents: 63
diff changeset
166 dst = gen_reg_rtx (<MODE>mode);
kono
parents: 63
diff changeset
167
kono
parents: 63
diff changeset
168 emit_move_insn (dst, operands[1]);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
169
111
kono
parents: 63
diff changeset
170 /* Fix up the destination if needed. */
kono
parents: 63
diff changeset
171 if (dst != operands[0])
kono
parents: 63
diff changeset
172 emit_move_insn (operands[0], dst);
kono
parents: 63
diff changeset
173 }
kono
parents: 63
diff changeset
174 DONE;
kono
parents: 63
diff changeset
175 })
kono
parents: 63
diff changeset
176
kono
parents: 63
diff changeset
177 (define_insn_and_split "atomic_loaddi_fpu"
kono
parents: 63
diff changeset
178 [(set (match_operand:DI 0 "nonimmediate_operand" "=x,m,?r")
kono
parents: 63
diff changeset
179 (unspec:DI [(match_operand:DI 1 "memory_operand" "m,m,m")]
kono
parents: 63
diff changeset
180 UNSPEC_LDA))
kono
parents: 63
diff changeset
181 (clobber (match_operand:DI 2 "memory_operand" "=X,X,m"))
kono
parents: 63
diff changeset
182 (clobber (match_scratch:DF 3 "=X,xf,xf"))]
kono
parents: 63
diff changeset
183 "!TARGET_64BIT && (TARGET_80387 || TARGET_SSE)"
kono
parents: 63
diff changeset
184 "#"
kono
parents: 63
diff changeset
185 "&& reload_completed"
kono
parents: 63
diff changeset
186 [(const_int 0)]
kono
parents: 63
diff changeset
187 {
kono
parents: 63
diff changeset
188 rtx dst = operands[0], src = operands[1];
kono
parents: 63
diff changeset
189 rtx mem = operands[2], tmp = operands[3];
kono
parents: 63
diff changeset
190
kono
parents: 63
diff changeset
191 if (SSE_REG_P (dst))
kono
parents: 63
diff changeset
192 emit_move_insn (dst, src);
kono
parents: 63
diff changeset
193 else
kono
parents: 63
diff changeset
194 {
kono
parents: 63
diff changeset
195 if (MEM_P (dst))
kono
parents: 63
diff changeset
196 mem = dst;
kono
parents: 63
diff changeset
197
kono
parents: 63
diff changeset
198 if (STACK_REG_P (tmp))
kono
parents: 63
diff changeset
199 {
kono
parents: 63
diff changeset
200 emit_insn (gen_loaddi_via_fpu (tmp, src));
kono
parents: 63
diff changeset
201 emit_insn (gen_storedi_via_fpu (mem, tmp));
kono
parents: 63
diff changeset
202 }
kono
parents: 63
diff changeset
203 else
kono
parents: 63
diff changeset
204 {
kono
parents: 63
diff changeset
205 emit_insn (gen_loaddi_via_sse (tmp, src));
kono
parents: 63
diff changeset
206 emit_insn (gen_storedi_via_sse (mem, tmp));
kono
parents: 63
diff changeset
207 }
kono
parents: 63
diff changeset
208
kono
parents: 63
diff changeset
209 if (mem != dst)
kono
parents: 63
diff changeset
210 emit_move_insn (dst, mem);
kono
parents: 63
diff changeset
211 }
kono
parents: 63
diff changeset
212 DONE;
kono
parents: 63
diff changeset
213 })
kono
parents: 63
diff changeset
214
kono
parents: 63
diff changeset
215 (define_peephole2
kono
parents: 63
diff changeset
216 [(set (match_operand:DF 0 "fp_register_operand")
kono
parents: 63
diff changeset
217 (unspec:DF [(match_operand:DI 1 "memory_operand")]
kono
parents: 63
diff changeset
218 UNSPEC_FILD_ATOMIC))
kono
parents: 63
diff changeset
219 (set (match_operand:DI 2 "memory_operand")
kono
parents: 63
diff changeset
220 (unspec:DI [(match_dup 0)]
kono
parents: 63
diff changeset
221 UNSPEC_FIST_ATOMIC))
kono
parents: 63
diff changeset
222 (set (match_operand:DF 3 "any_fp_register_operand")
kono
parents: 63
diff changeset
223 (match_operand:DF 4 "memory_operand"))]
kono
parents: 63
diff changeset
224 "!TARGET_64BIT
kono
parents: 63
diff changeset
225 && peep2_reg_dead_p (2, operands[0])
kono
parents: 63
diff changeset
226 && rtx_equal_p (XEXP (operands[4], 0), XEXP (operands[2], 0))"
kono
parents: 63
diff changeset
227 [(set (match_dup 3) (match_dup 5))]
kono
parents: 63
diff changeset
228 "operands[5] = gen_lowpart (DFmode, operands[1]);")
kono
parents: 63
diff changeset
229
kono
parents: 63
diff changeset
230 (define_peephole2
kono
parents: 63
diff changeset
231 [(set (match_operand:DF 0 "fp_register_operand")
kono
parents: 63
diff changeset
232 (unspec:DF [(match_operand:DI 1 "memory_operand")]
kono
parents: 63
diff changeset
233 UNSPEC_FILD_ATOMIC))
kono
parents: 63
diff changeset
234 (set (match_operand:DI 2 "memory_operand")
kono
parents: 63
diff changeset
235 (unspec:DI [(match_dup 0)]
kono
parents: 63
diff changeset
236 UNSPEC_FIST_ATOMIC))
kono
parents: 63
diff changeset
237 (set (mem:BLK (scratch:SI))
kono
parents: 63
diff changeset
238 (unspec:BLK [(mem:BLK (scratch:SI))] UNSPEC_MEMORY_BLOCKAGE))
kono
parents: 63
diff changeset
239 (set (match_operand:DF 3 "any_fp_register_operand")
kono
parents: 63
diff changeset
240 (match_operand:DF 4 "memory_operand"))]
kono
parents: 63
diff changeset
241 "!TARGET_64BIT
kono
parents: 63
diff changeset
242 && peep2_reg_dead_p (2, operands[0])
kono
parents: 63
diff changeset
243 && rtx_equal_p (XEXP (operands[4], 0), XEXP (operands[2], 0))"
kono
parents: 63
diff changeset
244 [(const_int 0)]
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
245 {
111
kono
parents: 63
diff changeset
246 emit_move_insn (operands[3], gen_lowpart (DFmode, operands[1]));
kono
parents: 63
diff changeset
247 emit_insn (gen_memory_blockage ());
kono
parents: 63
diff changeset
248 DONE;
kono
parents: 63
diff changeset
249 })
kono
parents: 63
diff changeset
250
kono
parents: 63
diff changeset
251 (define_peephole2
kono
parents: 63
diff changeset
252 [(set (match_operand:DF 0 "sse_reg_operand")
kono
parents: 63
diff changeset
253 (unspec:DF [(match_operand:DI 1 "memory_operand")]
kono
parents: 63
diff changeset
254 UNSPEC_LDX_ATOMIC))
kono
parents: 63
diff changeset
255 (set (match_operand:DI 2 "memory_operand")
kono
parents: 63
diff changeset
256 (unspec:DI [(match_dup 0)]
kono
parents: 63
diff changeset
257 UNSPEC_STX_ATOMIC))
kono
parents: 63
diff changeset
258 (set (match_operand:DF 3 "any_fp_register_operand")
kono
parents: 63
diff changeset
259 (match_operand:DF 4 "memory_operand"))]
kono
parents: 63
diff changeset
260 "!TARGET_64BIT
kono
parents: 63
diff changeset
261 && peep2_reg_dead_p (2, operands[0])
kono
parents: 63
diff changeset
262 && rtx_equal_p (XEXP (operands[4], 0), XEXP (operands[2], 0))"
kono
parents: 63
diff changeset
263 [(set (match_dup 3) (match_dup 5))]
kono
parents: 63
diff changeset
264 "operands[5] = gen_lowpart (DFmode, operands[1]);")
kono
parents: 63
diff changeset
265
kono
parents: 63
diff changeset
266 (define_peephole2
kono
parents: 63
diff changeset
267 [(set (match_operand:DF 0 "sse_reg_operand")
kono
parents: 63
diff changeset
268 (unspec:DF [(match_operand:DI 1 "memory_operand")]
kono
parents: 63
diff changeset
269 UNSPEC_LDX_ATOMIC))
kono
parents: 63
diff changeset
270 (set (match_operand:DI 2 "memory_operand")
kono
parents: 63
diff changeset
271 (unspec:DI [(match_dup 0)]
kono
parents: 63
diff changeset
272 UNSPEC_STX_ATOMIC))
kono
parents: 63
diff changeset
273 (set (mem:BLK (scratch:SI))
kono
parents: 63
diff changeset
274 (unspec:BLK [(mem:BLK (scratch:SI))] UNSPEC_MEMORY_BLOCKAGE))
kono
parents: 63
diff changeset
275 (set (match_operand:DF 3 "any_fp_register_operand")
kono
parents: 63
diff changeset
276 (match_operand:DF 4 "memory_operand"))]
kono
parents: 63
diff changeset
277 "!TARGET_64BIT
kono
parents: 63
diff changeset
278 && peep2_reg_dead_p (2, operands[0])
kono
parents: 63
diff changeset
279 && rtx_equal_p (XEXP (operands[4], 0), XEXP (operands[2], 0))"
kono
parents: 63
diff changeset
280 [(const_int 0)]
kono
parents: 63
diff changeset
281 {
kono
parents: 63
diff changeset
282 emit_move_insn (operands[3], gen_lowpart (DFmode, operands[1]));
kono
parents: 63
diff changeset
283 emit_insn (gen_memory_blockage ());
kono
parents: 63
diff changeset
284 DONE;
kono
parents: 63
diff changeset
285 })
kono
parents: 63
diff changeset
286
kono
parents: 63
diff changeset
287 (define_expand "atomic_store<mode>"
kono
parents: 63
diff changeset
288 [(set (match_operand:ATOMIC 0 "memory_operand")
kono
parents: 63
diff changeset
289 (unspec:ATOMIC [(match_operand:ATOMIC 1 "nonimmediate_operand")
kono
parents: 63
diff changeset
290 (match_operand:SI 2 "const_int_operand")]
kono
parents: 63
diff changeset
291 UNSPEC_STA))]
kono
parents: 63
diff changeset
292 ""
kono
parents: 63
diff changeset
293 {
kono
parents: 63
diff changeset
294 enum memmodel model = memmodel_from_int (INTVAL (operands[2]));
kono
parents: 63
diff changeset
295
kono
parents: 63
diff changeset
296 if (<MODE>mode == DImode && !TARGET_64BIT)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
297 {
111
kono
parents: 63
diff changeset
298 /* For DImode on 32-bit, we can use the FPU to perform the store. */
kono
parents: 63
diff changeset
299 /* Note that while we could perform a cmpxchg8b loop, that turns
kono
parents: 63
diff changeset
300 out to be significantly larger than this plus a barrier. */
kono
parents: 63
diff changeset
301 emit_insn (gen_atomic_storedi_fpu
kono
parents: 63
diff changeset
302 (operands[0], operands[1],
kono
parents: 63
diff changeset
303 assign_386_stack_local (DImode, SLOT_TEMP)));
kono
parents: 63
diff changeset
304 }
kono
parents: 63
diff changeset
305 else
kono
parents: 63
diff changeset
306 {
kono
parents: 63
diff changeset
307 operands[1] = force_reg (<MODE>mode, operands[1]);
kono
parents: 63
diff changeset
308
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
309 /* For seq-cst stores, use XCHG when we lack MFENCE
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
310 or when target prefers XCHG. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
311 if (is_mm_seq_cst (model)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
312 && (!(TARGET_64BIT || TARGET_SSE2)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
313 || TARGET_USE_XCHG_FOR_ATOMIC_STORE))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
314 {
111
kono
parents: 63
diff changeset
315 emit_insn (gen_atomic_exchange<mode> (gen_reg_rtx (<MODE>mode),
kono
parents: 63
diff changeset
316 operands[0], operands[1],
kono
parents: 63
diff changeset
317 operands[2]));
kono
parents: 63
diff changeset
318 DONE;
kono
parents: 63
diff changeset
319 }
kono
parents: 63
diff changeset
320
kono
parents: 63
diff changeset
321 /* Otherwise use a store. */
kono
parents: 63
diff changeset
322 emit_insn (gen_atomic_store<mode>_1 (operands[0], operands[1],
kono
parents: 63
diff changeset
323 operands[2]));
kono
parents: 63
diff changeset
324 }
kono
parents: 63
diff changeset
325 /* ... followed by an MFENCE, if required. */
kono
parents: 63
diff changeset
326 if (is_mm_seq_cst (model))
kono
parents: 63
diff changeset
327 emit_insn (gen_mem_thread_fence (operands[2]));
kono
parents: 63
diff changeset
328 DONE;
kono
parents: 63
diff changeset
329 })
kono
parents: 63
diff changeset
330
kono
parents: 63
diff changeset
331 (define_insn "atomic_store<mode>_1"
kono
parents: 63
diff changeset
332 [(set (match_operand:SWI 0 "memory_operand" "=m")
kono
parents: 63
diff changeset
333 (unspec:SWI [(match_operand:SWI 1 "<nonmemory_operand>" "<r><i>")
kono
parents: 63
diff changeset
334 (match_operand:SI 2 "const_int_operand")]
kono
parents: 63
diff changeset
335 UNSPEC_STA))]
kono
parents: 63
diff changeset
336 ""
kono
parents: 63
diff changeset
337 "%K2mov{<imodesuffix>}\t{%1, %0|%0, %1}")
kono
parents: 63
diff changeset
338
kono
parents: 63
diff changeset
339 (define_insn_and_split "atomic_storedi_fpu"
kono
parents: 63
diff changeset
340 [(set (match_operand:DI 0 "memory_operand" "=m,m,m")
kono
parents: 63
diff changeset
341 (unspec:DI [(match_operand:DI 1 "nonimmediate_operand" "x,m,?r")]
kono
parents: 63
diff changeset
342 UNSPEC_STA))
kono
parents: 63
diff changeset
343 (clobber (match_operand:DI 2 "memory_operand" "=X,X,m"))
kono
parents: 63
diff changeset
344 (clobber (match_scratch:DF 3 "=X,xf,xf"))]
kono
parents: 63
diff changeset
345 "!TARGET_64BIT && (TARGET_80387 || TARGET_SSE)"
kono
parents: 63
diff changeset
346 "#"
kono
parents: 63
diff changeset
347 "&& reload_completed"
kono
parents: 63
diff changeset
348 [(const_int 0)]
kono
parents: 63
diff changeset
349 {
kono
parents: 63
diff changeset
350 rtx dst = operands[0], src = operands[1];
kono
parents: 63
diff changeset
351 rtx mem = operands[2], tmp = operands[3];
kono
parents: 63
diff changeset
352
kono
parents: 63
diff changeset
353 if (SSE_REG_P (src))
kono
parents: 63
diff changeset
354 emit_move_insn (dst, src);
kono
parents: 63
diff changeset
355 else
kono
parents: 63
diff changeset
356 {
kono
parents: 63
diff changeset
357 if (REG_P (src))
kono
parents: 63
diff changeset
358 {
kono
parents: 63
diff changeset
359 emit_move_insn (mem, src);
kono
parents: 63
diff changeset
360 src = mem;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
361 }
111
kono
parents: 63
diff changeset
362
kono
parents: 63
diff changeset
363 if (STACK_REG_P (tmp))
kono
parents: 63
diff changeset
364 {
kono
parents: 63
diff changeset
365 emit_insn (gen_loaddi_via_fpu (tmp, src));
kono
parents: 63
diff changeset
366 emit_insn (gen_storedi_via_fpu (dst, tmp));
kono
parents: 63
diff changeset
367 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
368 else
111
kono
parents: 63
diff changeset
369 {
kono
parents: 63
diff changeset
370 emit_insn (gen_loaddi_via_sse (tmp, src));
kono
parents: 63
diff changeset
371 emit_insn (gen_storedi_via_sse (dst, tmp));
kono
parents: 63
diff changeset
372 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
373 }
111
kono
parents: 63
diff changeset
374 DONE;
kono
parents: 63
diff changeset
375 })
kono
parents: 63
diff changeset
376
kono
parents: 63
diff changeset
377 (define_peephole2
kono
parents: 63
diff changeset
378 [(set (match_operand:DF 0 "memory_operand")
kono
parents: 63
diff changeset
379 (match_operand:DF 1 "any_fp_register_operand"))
kono
parents: 63
diff changeset
380 (set (match_operand:DF 2 "fp_register_operand")
kono
parents: 63
diff changeset
381 (unspec:DF [(match_operand:DI 3 "memory_operand")]
kono
parents: 63
diff changeset
382 UNSPEC_FILD_ATOMIC))
kono
parents: 63
diff changeset
383 (set (match_operand:DI 4 "memory_operand")
kono
parents: 63
diff changeset
384 (unspec:DI [(match_dup 2)]
kono
parents: 63
diff changeset
385 UNSPEC_FIST_ATOMIC))]
kono
parents: 63
diff changeset
386 "!TARGET_64BIT
kono
parents: 63
diff changeset
387 && peep2_reg_dead_p (3, operands[2])
kono
parents: 63
diff changeset
388 && rtx_equal_p (XEXP (operands[0], 0), XEXP (operands[3], 0))"
kono
parents: 63
diff changeset
389 [(set (match_dup 5) (match_dup 1))]
kono
parents: 63
diff changeset
390 "operands[5] = gen_lowpart (DFmode, operands[4]);")
kono
parents: 63
diff changeset
391
kono
parents: 63
diff changeset
392 (define_peephole2
kono
parents: 63
diff changeset
393 [(set (match_operand:DF 0 "memory_operand")
kono
parents: 63
diff changeset
394 (match_operand:DF 1 "any_fp_register_operand"))
kono
parents: 63
diff changeset
395 (set (mem:BLK (scratch:SI))
kono
parents: 63
diff changeset
396 (unspec:BLK [(mem:BLK (scratch:SI))] UNSPEC_MEMORY_BLOCKAGE))
kono
parents: 63
diff changeset
397 (set (match_operand:DF 2 "fp_register_operand")
kono
parents: 63
diff changeset
398 (unspec:DF [(match_operand:DI 3 "memory_operand")]
kono
parents: 63
diff changeset
399 UNSPEC_FILD_ATOMIC))
kono
parents: 63
diff changeset
400 (set (match_operand:DI 4 "memory_operand")
kono
parents: 63
diff changeset
401 (unspec:DI [(match_dup 2)]
kono
parents: 63
diff changeset
402 UNSPEC_FIST_ATOMIC))]
kono
parents: 63
diff changeset
403 "!TARGET_64BIT
kono
parents: 63
diff changeset
404 && peep2_reg_dead_p (4, operands[2])
kono
parents: 63
diff changeset
405 && rtx_equal_p (XEXP (operands[0], 0), XEXP (operands[3], 0))"
kono
parents: 63
diff changeset
406 [(const_int 0)]
kono
parents: 63
diff changeset
407 {
kono
parents: 63
diff changeset
408 emit_insn (gen_memory_blockage ());
kono
parents: 63
diff changeset
409 emit_move_insn (gen_lowpart (DFmode, operands[4]), operands[1]);
kono
parents: 63
diff changeset
410 DONE;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
411 })
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
412
111
kono
parents: 63
diff changeset
413 (define_peephole2
kono
parents: 63
diff changeset
414 [(set (match_operand:DF 0 "memory_operand")
kono
parents: 63
diff changeset
415 (match_operand:DF 1 "any_fp_register_operand"))
kono
parents: 63
diff changeset
416 (set (match_operand:DF 2 "sse_reg_operand")
kono
parents: 63
diff changeset
417 (unspec:DF [(match_operand:DI 3 "memory_operand")]
kono
parents: 63
diff changeset
418 UNSPEC_LDX_ATOMIC))
kono
parents: 63
diff changeset
419 (set (match_operand:DI 4 "memory_operand")
kono
parents: 63
diff changeset
420 (unspec:DI [(match_dup 2)]
kono
parents: 63
diff changeset
421 UNSPEC_STX_ATOMIC))]
kono
parents: 63
diff changeset
422 "!TARGET_64BIT
kono
parents: 63
diff changeset
423 && peep2_reg_dead_p (3, operands[2])
kono
parents: 63
diff changeset
424 && rtx_equal_p (XEXP (operands[0], 0), XEXP (operands[3], 0))"
kono
parents: 63
diff changeset
425 [(set (match_dup 5) (match_dup 1))]
kono
parents: 63
diff changeset
426 "operands[5] = gen_lowpart (DFmode, operands[4]);")
kono
parents: 63
diff changeset
427
kono
parents: 63
diff changeset
428 (define_peephole2
kono
parents: 63
diff changeset
429 [(set (match_operand:DF 0 "memory_operand")
kono
parents: 63
diff changeset
430 (match_operand:DF 1 "any_fp_register_operand"))
kono
parents: 63
diff changeset
431 (set (mem:BLK (scratch:SI))
kono
parents: 63
diff changeset
432 (unspec:BLK [(mem:BLK (scratch:SI))] UNSPEC_MEMORY_BLOCKAGE))
kono
parents: 63
diff changeset
433 (set (match_operand:DF 2 "sse_reg_operand")
kono
parents: 63
diff changeset
434 (unspec:DF [(match_operand:DI 3 "memory_operand")]
kono
parents: 63
diff changeset
435 UNSPEC_LDX_ATOMIC))
kono
parents: 63
diff changeset
436 (set (match_operand:DI 4 "memory_operand")
kono
parents: 63
diff changeset
437 (unspec:DI [(match_dup 2)]
kono
parents: 63
diff changeset
438 UNSPEC_STX_ATOMIC))]
kono
parents: 63
diff changeset
439 "!TARGET_64BIT
kono
parents: 63
diff changeset
440 && peep2_reg_dead_p (4, operands[2])
kono
parents: 63
diff changeset
441 && rtx_equal_p (XEXP (operands[0], 0), XEXP (operands[3], 0))"
kono
parents: 63
diff changeset
442 [(const_int 0)]
kono
parents: 63
diff changeset
443 {
kono
parents: 63
diff changeset
444 emit_insn (gen_memory_blockage ());
kono
parents: 63
diff changeset
445 emit_move_insn (gen_lowpart (DFmode, operands[4]), operands[1]);
kono
parents: 63
diff changeset
446 DONE;
kono
parents: 63
diff changeset
447 })
kono
parents: 63
diff changeset
448
kono
parents: 63
diff changeset
449 ;; ??? You'd think that we'd be able to perform this via FLOAT + FIX_TRUNC
kono
parents: 63
diff changeset
450 ;; operations. But the fix_trunc patterns want way more setup than we want
kono
parents: 63
diff changeset
451 ;; to provide. Note that the scratch is DFmode instead of XFmode in order
kono
parents: 63
diff changeset
452 ;; to make it easy to allocate a scratch in either SSE or FP_REGs above.
kono
parents: 63
diff changeset
453
kono
parents: 63
diff changeset
454 (define_insn "loaddi_via_fpu"
kono
parents: 63
diff changeset
455 [(set (match_operand:DF 0 "register_operand" "=f")
kono
parents: 63
diff changeset
456 (unspec:DF [(match_operand:DI 1 "memory_operand" "m")]
kono
parents: 63
diff changeset
457 UNSPEC_FILD_ATOMIC))]
kono
parents: 63
diff changeset
458 "TARGET_80387"
kono
parents: 63
diff changeset
459 "fild%Z1\t%1"
kono
parents: 63
diff changeset
460 [(set_attr "type" "fmov")
kono
parents: 63
diff changeset
461 (set_attr "mode" "DF")
kono
parents: 63
diff changeset
462 (set_attr "fp_int_src" "true")])
kono
parents: 63
diff changeset
463
kono
parents: 63
diff changeset
464 (define_insn "storedi_via_fpu"
kono
parents: 63
diff changeset
465 [(set (match_operand:DI 0 "memory_operand" "=m")
kono
parents: 63
diff changeset
466 (unspec:DI [(match_operand:DF 1 "register_operand" "f")]
kono
parents: 63
diff changeset
467 UNSPEC_FIST_ATOMIC))]
kono
parents: 63
diff changeset
468 "TARGET_80387"
kono
parents: 63
diff changeset
469 {
kono
parents: 63
diff changeset
470 gcc_assert (find_regno_note (insn, REG_DEAD, FIRST_STACK_REG) != NULL_RTX);
kono
parents: 63
diff changeset
471
kono
parents: 63
diff changeset
472 return "fistp%Z0\t%0";
kono
parents: 63
diff changeset
473 }
kono
parents: 63
diff changeset
474 [(set_attr "type" "fmov")
kono
parents: 63
diff changeset
475 (set_attr "mode" "DI")])
kono
parents: 63
diff changeset
476
kono
parents: 63
diff changeset
477 (define_insn "loaddi_via_sse"
kono
parents: 63
diff changeset
478 [(set (match_operand:DF 0 "register_operand" "=x")
kono
parents: 63
diff changeset
479 (unspec:DF [(match_operand:DI 1 "memory_operand" "m")]
kono
parents: 63
diff changeset
480 UNSPEC_LDX_ATOMIC))]
kono
parents: 63
diff changeset
481 "TARGET_SSE"
kono
parents: 63
diff changeset
482 {
kono
parents: 63
diff changeset
483 if (TARGET_SSE2)
kono
parents: 63
diff changeset
484 return "%vmovq\t{%1, %0|%0, %1}";
kono
parents: 63
diff changeset
485 return "movlps\t{%1, %0|%0, %1}";
kono
parents: 63
diff changeset
486 }
kono
parents: 63
diff changeset
487 [(set_attr "type" "ssemov")
kono
parents: 63
diff changeset
488 (set_attr "mode" "DI")])
kono
parents: 63
diff changeset
489
kono
parents: 63
diff changeset
490 (define_insn "storedi_via_sse"
kono
parents: 63
diff changeset
491 [(set (match_operand:DI 0 "memory_operand" "=m")
kono
parents: 63
diff changeset
492 (unspec:DI [(match_operand:DF 1 "register_operand" "x")]
kono
parents: 63
diff changeset
493 UNSPEC_STX_ATOMIC))]
kono
parents: 63
diff changeset
494 "TARGET_SSE"
kono
parents: 63
diff changeset
495 {
kono
parents: 63
diff changeset
496 if (TARGET_SSE2)
kono
parents: 63
diff changeset
497 return "%vmovq\t{%1, %0|%0, %1}";
kono
parents: 63
diff changeset
498 return "movlps\t{%1, %0|%0, %1}";
kono
parents: 63
diff changeset
499 }
kono
parents: 63
diff changeset
500 [(set_attr "type" "ssemov")
kono
parents: 63
diff changeset
501 (set_attr "mode" "DI")])
kono
parents: 63
diff changeset
502
kono
parents: 63
diff changeset
503 (define_expand "atomic_compare_and_swap<mode>"
kono
parents: 63
diff changeset
504 [(match_operand:QI 0 "register_operand") ;; bool success output
kono
parents: 63
diff changeset
505 (match_operand:SWI124 1 "register_operand") ;; oldval output
kono
parents: 63
diff changeset
506 (match_operand:SWI124 2 "memory_operand") ;; memory
kono
parents: 63
diff changeset
507 (match_operand:SWI124 3 "register_operand") ;; expected input
kono
parents: 63
diff changeset
508 (match_operand:SWI124 4 "register_operand") ;; newval input
kono
parents: 63
diff changeset
509 (match_operand:SI 5 "const_int_operand") ;; is_weak
kono
parents: 63
diff changeset
510 (match_operand:SI 6 "const_int_operand") ;; success model
kono
parents: 63
diff changeset
511 (match_operand:SI 7 "const_int_operand")] ;; failure model
kono
parents: 63
diff changeset
512 "TARGET_CMPXCHG"
kono
parents: 63
diff changeset
513 {
kono
parents: 63
diff changeset
514 emit_insn
kono
parents: 63
diff changeset
515 (gen_atomic_compare_and_swap<mode>_1
kono
parents: 63
diff changeset
516 (operands[1], operands[2], operands[3], operands[4], operands[6]));
kono
parents: 63
diff changeset
517 ix86_expand_setcc (operands[0], EQ, gen_rtx_REG (CCZmode, FLAGS_REG),
kono
parents: 63
diff changeset
518 const0_rtx);
kono
parents: 63
diff changeset
519 DONE;
kono
parents: 63
diff changeset
520 })
kono
parents: 63
diff changeset
521
kono
parents: 63
diff changeset
522 (define_mode_iterator CASMODE
kono
parents: 63
diff changeset
523 [(DI "TARGET_64BIT || TARGET_CMPXCHG8B")
kono
parents: 63
diff changeset
524 (TI "TARGET_64BIT && TARGET_CMPXCHG16B")])
kono
parents: 63
diff changeset
525 (define_mode_attr CASHMODE [(DI "SI") (TI "DI")])
kono
parents: 63
diff changeset
526
kono
parents: 63
diff changeset
527 (define_expand "atomic_compare_and_swap<mode>"
kono
parents: 63
diff changeset
528 [(match_operand:QI 0 "register_operand") ;; bool success output
kono
parents: 63
diff changeset
529 (match_operand:CASMODE 1 "register_operand") ;; oldval output
kono
parents: 63
diff changeset
530 (match_operand:CASMODE 2 "memory_operand") ;; memory
kono
parents: 63
diff changeset
531 (match_operand:CASMODE 3 "register_operand") ;; expected input
kono
parents: 63
diff changeset
532 (match_operand:CASMODE 4 "register_operand") ;; newval input
kono
parents: 63
diff changeset
533 (match_operand:SI 5 "const_int_operand") ;; is_weak
kono
parents: 63
diff changeset
534 (match_operand:SI 6 "const_int_operand") ;; success model
kono
parents: 63
diff changeset
535 (match_operand:SI 7 "const_int_operand")] ;; failure model
kono
parents: 63
diff changeset
536 "TARGET_CMPXCHG"
kono
parents: 63
diff changeset
537 {
kono
parents: 63
diff changeset
538 if (<MODE>mode == DImode && TARGET_64BIT)
kono
parents: 63
diff changeset
539 {
kono
parents: 63
diff changeset
540 emit_insn
kono
parents: 63
diff changeset
541 (gen_atomic_compare_and_swapdi_1
kono
parents: 63
diff changeset
542 (operands[1], operands[2], operands[3], operands[4], operands[6]));
kono
parents: 63
diff changeset
543 }
kono
parents: 63
diff changeset
544 else
kono
parents: 63
diff changeset
545 {
kono
parents: 63
diff changeset
546 machine_mode hmode = <CASHMODE>mode;
kono
parents: 63
diff changeset
547
kono
parents: 63
diff changeset
548 emit_insn
kono
parents: 63
diff changeset
549 (gen_atomic_compare_and_swap<mode>_doubleword
kono
parents: 63
diff changeset
550 (operands[1], operands[2], operands[3],
kono
parents: 63
diff changeset
551 gen_lowpart (hmode, operands[4]), gen_highpart (hmode, operands[4]),
kono
parents: 63
diff changeset
552 operands[6]));
kono
parents: 63
diff changeset
553 }
kono
parents: 63
diff changeset
554
kono
parents: 63
diff changeset
555 ix86_expand_setcc (operands[0], EQ, gen_rtx_REG (CCZmode, FLAGS_REG),
kono
parents: 63
diff changeset
556 const0_rtx);
kono
parents: 63
diff changeset
557 DONE;
kono
parents: 63
diff changeset
558 })
kono
parents: 63
diff changeset
559
kono
parents: 63
diff changeset
560 ;; For double-word compare and swap, we are obliged to play tricks with
kono
parents: 63
diff changeset
561 ;; the input newval (op3:op4) because the Intel register numbering does
kono
parents: 63
diff changeset
562 ;; not match the gcc register numbering, so the pair must be CX:BX.
kono
parents: 63
diff changeset
563
kono
parents: 63
diff changeset
564 (define_mode_attr doublemodesuffix [(SI "8") (DI "16")])
kono
parents: 63
diff changeset
565
kono
parents: 63
diff changeset
566 (define_insn "atomic_compare_and_swap<dwi>_doubleword"
kono
parents: 63
diff changeset
567 [(set (match_operand:<DWI> 0 "register_operand" "=A")
kono
parents: 63
diff changeset
568 (unspec_volatile:<DWI>
kono
parents: 63
diff changeset
569 [(match_operand:<DWI> 1 "memory_operand" "+m")
kono
parents: 63
diff changeset
570 (match_operand:<DWI> 2 "register_operand" "0")
kono
parents: 63
diff changeset
571 (match_operand:DWIH 3 "register_operand" "b")
kono
parents: 63
diff changeset
572 (match_operand:DWIH 4 "register_operand" "c")
kono
parents: 63
diff changeset
573 (match_operand:SI 5 "const_int_operand")]
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
574 UNSPECV_CMPXCHG))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
575 (set (match_dup 1)
111
kono
parents: 63
diff changeset
576 (unspec_volatile:<DWI> [(const_int 0)] UNSPECV_CMPXCHG))
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
577 (set (reg:CCZ FLAGS_REG)
111
kono
parents: 63
diff changeset
578 (unspec_volatile:CCZ [(const_int 0)] UNSPECV_CMPXCHG))]
kono
parents: 63
diff changeset
579 "TARGET_CMPXCHG<doublemodesuffix>B"
kono
parents: 63
diff changeset
580 "lock{%;} %K5cmpxchg<doublemodesuffix>b\t%1")
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
581
111
kono
parents: 63
diff changeset
582 (define_insn "atomic_compare_and_swap<mode>_1"
kono
parents: 63
diff changeset
583 [(set (match_operand:SWI 0 "register_operand" "=a")
kono
parents: 63
diff changeset
584 (unspec_volatile:SWI
kono
parents: 63
diff changeset
585 [(match_operand:SWI 1 "memory_operand" "+m")
kono
parents: 63
diff changeset
586 (match_operand:SWI 2 "register_operand" "0")
kono
parents: 63
diff changeset
587 (match_operand:SWI 3 "register_operand" "<r>")
kono
parents: 63
diff changeset
588 (match_operand:SI 4 "const_int_operand")]
kono
parents: 63
diff changeset
589 UNSPECV_CMPXCHG))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
590 (set (match_dup 1)
111
kono
parents: 63
diff changeset
591 (unspec_volatile:SWI [(const_int 0)] UNSPECV_CMPXCHG))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
592 (set (reg:CCZ FLAGS_REG)
111
kono
parents: 63
diff changeset
593 (unspec_volatile:CCZ [(const_int 0)] UNSPECV_CMPXCHG))]
kono
parents: 63
diff changeset
594 "TARGET_CMPXCHG"
kono
parents: 63
diff changeset
595 "lock{%;} %K4cmpxchg{<imodesuffix>}\t{%3, %1|%1, %3}")
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
596
111
kono
parents: 63
diff changeset
597 ;; For operand 2 nonmemory_operand predicate is used instead of
kono
parents: 63
diff changeset
598 ;; register_operand to allow combiner to better optimize atomic
kono
parents: 63
diff changeset
599 ;; additions of constants.
kono
parents: 63
diff changeset
600 (define_insn "atomic_fetch_add<mode>"
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
601 [(set (match_operand:SWI 0 "register_operand" "=<r>")
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
602 (unspec_volatile:SWI
111
kono
parents: 63
diff changeset
603 [(match_operand:SWI 1 "memory_operand" "+m")
kono
parents: 63
diff changeset
604 (match_operand:SI 3 "const_int_operand")] ;; model
kono
parents: 63
diff changeset
605 UNSPECV_XCHG))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
606 (set (match_dup 1)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
607 (plus:SWI (match_dup 1)
111
kono
parents: 63
diff changeset
608 (match_operand:SWI 2 "nonmemory_operand" "0")))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
609 (clobber (reg:CC FLAGS_REG))]
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
610 "TARGET_XADD"
111
kono
parents: 63
diff changeset
611 "lock{%;} %K3xadd{<imodesuffix>}\t{%0, %1|%1, %0}")
kono
parents: 63
diff changeset
612
kono
parents: 63
diff changeset
613 ;; This peephole2 and following insn optimize
kono
parents: 63
diff changeset
614 ;; __sync_fetch_and_add (x, -N) == N into just lock {add,sub,inc,dec}
kono
parents: 63
diff changeset
615 ;; followed by testing of flags instead of lock xadd and comparisons.
kono
parents: 63
diff changeset
616 (define_peephole2
kono
parents: 63
diff changeset
617 [(set (match_operand:SWI 0 "register_operand")
kono
parents: 63
diff changeset
618 (match_operand:SWI 2 "const_int_operand"))
kono
parents: 63
diff changeset
619 (parallel [(set (match_dup 0)
kono
parents: 63
diff changeset
620 (unspec_volatile:SWI
kono
parents: 63
diff changeset
621 [(match_operand:SWI 1 "memory_operand")
kono
parents: 63
diff changeset
622 (match_operand:SI 4 "const_int_operand")]
kono
parents: 63
diff changeset
623 UNSPECV_XCHG))
kono
parents: 63
diff changeset
624 (set (match_dup 1)
kono
parents: 63
diff changeset
625 (plus:SWI (match_dup 1)
kono
parents: 63
diff changeset
626 (match_dup 0)))
kono
parents: 63
diff changeset
627 (clobber (reg:CC FLAGS_REG))])
kono
parents: 63
diff changeset
628 (set (reg:CCZ FLAGS_REG)
kono
parents: 63
diff changeset
629 (compare:CCZ (match_dup 0)
kono
parents: 63
diff changeset
630 (match_operand:SWI 3 "const_int_operand")))]
kono
parents: 63
diff changeset
631 "peep2_reg_dead_p (3, operands[0])
kono
parents: 63
diff changeset
632 && (unsigned HOST_WIDE_INT) INTVAL (operands[2])
kono
parents: 63
diff changeset
633 == -(unsigned HOST_WIDE_INT) INTVAL (operands[3])
kono
parents: 63
diff changeset
634 && !reg_overlap_mentioned_p (operands[0], operands[1])"
kono
parents: 63
diff changeset
635 [(parallel [(set (reg:CCZ FLAGS_REG)
kono
parents: 63
diff changeset
636 (compare:CCZ
kono
parents: 63
diff changeset
637 (unspec_volatile:SWI [(match_dup 1) (match_dup 4)]
kono
parents: 63
diff changeset
638 UNSPECV_XCHG)
kono
parents: 63
diff changeset
639 (match_dup 3)))
kono
parents: 63
diff changeset
640 (set (match_dup 1)
kono
parents: 63
diff changeset
641 (plus:SWI (match_dup 1)
kono
parents: 63
diff changeset
642 (match_dup 2)))])])
kono
parents: 63
diff changeset
643
kono
parents: 63
diff changeset
644 ;; Likewise, but for the -Os special case of *mov<mode>_or.
kono
parents: 63
diff changeset
645 (define_peephole2
kono
parents: 63
diff changeset
646 [(parallel [(set (match_operand:SWI 0 "register_operand")
kono
parents: 63
diff changeset
647 (match_operand:SWI 2 "constm1_operand"))
kono
parents: 63
diff changeset
648 (clobber (reg:CC FLAGS_REG))])
kono
parents: 63
diff changeset
649 (parallel [(set (match_dup 0)
kono
parents: 63
diff changeset
650 (unspec_volatile:SWI
kono
parents: 63
diff changeset
651 [(match_operand:SWI 1 "memory_operand")
kono
parents: 63
diff changeset
652 (match_operand:SI 4 "const_int_operand")]
kono
parents: 63
diff changeset
653 UNSPECV_XCHG))
kono
parents: 63
diff changeset
654 (set (match_dup 1)
kono
parents: 63
diff changeset
655 (plus:SWI (match_dup 1)
kono
parents: 63
diff changeset
656 (match_dup 0)))
kono
parents: 63
diff changeset
657 (clobber (reg:CC FLAGS_REG))])
kono
parents: 63
diff changeset
658 (set (reg:CCZ FLAGS_REG)
kono
parents: 63
diff changeset
659 (compare:CCZ (match_dup 0)
kono
parents: 63
diff changeset
660 (match_operand:SWI 3 "const_int_operand")))]
kono
parents: 63
diff changeset
661 "peep2_reg_dead_p (3, operands[0])
kono
parents: 63
diff changeset
662 && (unsigned HOST_WIDE_INT) INTVAL (operands[2])
kono
parents: 63
diff changeset
663 == -(unsigned HOST_WIDE_INT) INTVAL (operands[3])
kono
parents: 63
diff changeset
664 && !reg_overlap_mentioned_p (operands[0], operands[1])"
kono
parents: 63
diff changeset
665 [(parallel [(set (reg:CCZ FLAGS_REG)
kono
parents: 63
diff changeset
666 (compare:CCZ
kono
parents: 63
diff changeset
667 (unspec_volatile:SWI [(match_dup 1) (match_dup 4)]
kono
parents: 63
diff changeset
668 UNSPECV_XCHG)
kono
parents: 63
diff changeset
669 (match_dup 3)))
kono
parents: 63
diff changeset
670 (set (match_dup 1)
kono
parents: 63
diff changeset
671 (plus:SWI (match_dup 1)
kono
parents: 63
diff changeset
672 (match_dup 2)))])])
kono
parents: 63
diff changeset
673
kono
parents: 63
diff changeset
674 (define_insn "*atomic_fetch_add_cmp<mode>"
kono
parents: 63
diff changeset
675 [(set (reg:CCZ FLAGS_REG)
kono
parents: 63
diff changeset
676 (compare:CCZ
kono
parents: 63
diff changeset
677 (unspec_volatile:SWI
kono
parents: 63
diff changeset
678 [(match_operand:SWI 0 "memory_operand" "+m")
kono
parents: 63
diff changeset
679 (match_operand:SI 3 "const_int_operand")] ;; model
kono
parents: 63
diff changeset
680 UNSPECV_XCHG)
kono
parents: 63
diff changeset
681 (match_operand:SWI 2 "const_int_operand" "i")))
kono
parents: 63
diff changeset
682 (set (match_dup 0)
kono
parents: 63
diff changeset
683 (plus:SWI (match_dup 0)
kono
parents: 63
diff changeset
684 (match_operand:SWI 1 "const_int_operand" "i")))]
kono
parents: 63
diff changeset
685 "(unsigned HOST_WIDE_INT) INTVAL (operands[1])
kono
parents: 63
diff changeset
686 == -(unsigned HOST_WIDE_INT) INTVAL (operands[2])"
kono
parents: 63
diff changeset
687 {
kono
parents: 63
diff changeset
688 if (incdec_operand (operands[1], <MODE>mode))
kono
parents: 63
diff changeset
689 {
kono
parents: 63
diff changeset
690 if (operands[1] == const1_rtx)
kono
parents: 63
diff changeset
691 return "lock{%;} %K3inc{<imodesuffix>}\t%0";
kono
parents: 63
diff changeset
692 else
kono
parents: 63
diff changeset
693 {
kono
parents: 63
diff changeset
694 gcc_assert (operands[1] == constm1_rtx);
kono
parents: 63
diff changeset
695 return "lock{%;} %K3dec{<imodesuffix>}\t%0";
kono
parents: 63
diff changeset
696 }
kono
parents: 63
diff changeset
697 }
kono
parents: 63
diff changeset
698
kono
parents: 63
diff changeset
699 if (x86_maybe_negate_const_int (&operands[1], <MODE>mode))
kono
parents: 63
diff changeset
700 return "lock{%;} %K3sub{<imodesuffix>}\t{%1, %0|%0, %1}";
kono
parents: 63
diff changeset
701
kono
parents: 63
diff changeset
702 return "lock{%;} %K3add{<imodesuffix>}\t{%1, %0|%0, %1}";
kono
parents: 63
diff changeset
703 })
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
704
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
705 ;; Recall that xchg implicitly sets LOCK#, so adding it again wastes space.
111
kono
parents: 63
diff changeset
706 ;; In addition, it is always a full barrier, so we can ignore the memory model.
kono
parents: 63
diff changeset
707 (define_insn "atomic_exchange<mode>"
kono
parents: 63
diff changeset
708 [(set (match_operand:SWI 0 "register_operand" "=<r>") ;; output
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
709 (unspec_volatile:SWI
111
kono
parents: 63
diff changeset
710 [(match_operand:SWI 1 "memory_operand" "+m") ;; memory
kono
parents: 63
diff changeset
711 (match_operand:SI 3 "const_int_operand")] ;; model
kono
parents: 63
diff changeset
712 UNSPECV_XCHG))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
713 (set (match_dup 1)
111
kono
parents: 63
diff changeset
714 (match_operand:SWI 2 "register_operand" "0"))] ;; input
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
715 ""
111
kono
parents: 63
diff changeset
716 "%K3xchg{<imodesuffix>}\t{%1, %0|%0, %1}")
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
717
111
kono
parents: 63
diff changeset
718 (define_insn "atomic_add<mode>"
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
719 [(set (match_operand:SWI 0 "memory_operand" "+m")
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
720 (unspec_volatile:SWI
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
721 [(plus:SWI (match_dup 0)
111
kono
parents: 63
diff changeset
722 (match_operand:SWI 1 "nonmemory_operand" "<r><i>"))
kono
parents: 63
diff changeset
723 (match_operand:SI 2 "const_int_operand")] ;; model
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
724 UNSPECV_LOCK))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
725 (clobber (reg:CC FLAGS_REG))]
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
726 ""
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
727 {
111
kono
parents: 63
diff changeset
728 if (incdec_operand (operands[1], <MODE>mode))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
729 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
730 if (operands[1] == const1_rtx)
111
kono
parents: 63
diff changeset
731 return "lock{%;} %K2inc{<imodesuffix>}\t%0";
kono
parents: 63
diff changeset
732 else
kono
parents: 63
diff changeset
733 {
kono
parents: 63
diff changeset
734 gcc_assert (operands[1] == constm1_rtx);
kono
parents: 63
diff changeset
735 return "lock{%;} %K2dec{<imodesuffix>}\t%0";
kono
parents: 63
diff changeset
736 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
737 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
738
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
739 if (x86_maybe_negate_const_int (&operands[1], <MODE>mode))
111
kono
parents: 63
diff changeset
740 return "lock{%;} %K2sub{<imodesuffix>}\t{%1, %0|%0, %1}";
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
741
111
kono
parents: 63
diff changeset
742 return "lock{%;} %K2add{<imodesuffix>}\t{%1, %0|%0, %1}";
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
743 })
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
744
111
kono
parents: 63
diff changeset
745 (define_insn "atomic_sub<mode>"
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
746 [(set (match_operand:SWI 0 "memory_operand" "+m")
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
747 (unspec_volatile:SWI
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
748 [(minus:SWI (match_dup 0)
111
kono
parents: 63
diff changeset
749 (match_operand:SWI 1 "nonmemory_operand" "<r><i>"))
kono
parents: 63
diff changeset
750 (match_operand:SI 2 "const_int_operand")] ;; model
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
751 UNSPECV_LOCK))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
752 (clobber (reg:CC FLAGS_REG))]
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
753 ""
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
754 {
111
kono
parents: 63
diff changeset
755 if (incdec_operand (operands[1], <MODE>mode))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
756 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
757 if (operands[1] == const1_rtx)
111
kono
parents: 63
diff changeset
758 return "lock{%;} %K2dec{<imodesuffix>}\t%0";
kono
parents: 63
diff changeset
759 else
kono
parents: 63
diff changeset
760 {
kono
parents: 63
diff changeset
761 gcc_assert (operands[1] == constm1_rtx);
kono
parents: 63
diff changeset
762 return "lock{%;} %K2inc{<imodesuffix>}\t%0";
kono
parents: 63
diff changeset
763 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
764 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
765
111
kono
parents: 63
diff changeset
766 if (x86_maybe_negate_const_int (&operands[1], <MODE>mode))
kono
parents: 63
diff changeset
767 return "lock{%;} %K2add{<imodesuffix>}\t{%1, %0|%0, %1}";
kono
parents: 63
diff changeset
768
kono
parents: 63
diff changeset
769 return "lock{%;} %K2sub{<imodesuffix>}\t{%1, %0|%0, %1}";
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
770 })
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
771
111
kono
parents: 63
diff changeset
772 (define_insn "atomic_<logic><mode>"
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
773 [(set (match_operand:SWI 0 "memory_operand" "+m")
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
774 (unspec_volatile:SWI
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
775 [(any_logic:SWI (match_dup 0)
111
kono
parents: 63
diff changeset
776 (match_operand:SWI 1 "nonmemory_operand" "<r><i>"))
kono
parents: 63
diff changeset
777 (match_operand:SI 2 "const_int_operand")] ;; model
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
778 UNSPECV_LOCK))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
779 (clobber (reg:CC FLAGS_REG))]
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
780 ""
111
kono
parents: 63
diff changeset
781 "lock{%;} %K2<logic>{<imodesuffix>}\t{%1, %0|%0, %1}")
kono
parents: 63
diff changeset
782
kono
parents: 63
diff changeset
783 (define_expand "atomic_bit_test_and_set<mode>"
kono
parents: 63
diff changeset
784 [(match_operand:SWI248 0 "register_operand")
kono
parents: 63
diff changeset
785 (match_operand:SWI248 1 "memory_operand")
kono
parents: 63
diff changeset
786 (match_operand:SWI248 2 "nonmemory_operand")
kono
parents: 63
diff changeset
787 (match_operand:SI 3 "const_int_operand") ;; model
kono
parents: 63
diff changeset
788 (match_operand:SI 4 "const_int_operand")]
kono
parents: 63
diff changeset
789 ""
kono
parents: 63
diff changeset
790 {
kono
parents: 63
diff changeset
791 emit_insn (gen_atomic_bit_test_and_set<mode>_1 (operands[1], operands[2],
kono
parents: 63
diff changeset
792 operands[3]));
kono
parents: 63
diff changeset
793 rtx tem = gen_reg_rtx (QImode);
kono
parents: 63
diff changeset
794 ix86_expand_setcc (tem, EQ, gen_rtx_REG (CCCmode, FLAGS_REG), const0_rtx);
kono
parents: 63
diff changeset
795 rtx result = convert_modes (<MODE>mode, QImode, tem, 1);
kono
parents: 63
diff changeset
796 if (operands[4] == const0_rtx)
kono
parents: 63
diff changeset
797 result = expand_simple_binop (<MODE>mode, ASHIFT, result,
kono
parents: 63
diff changeset
798 operands[2], operands[0], 0, OPTAB_DIRECT);
kono
parents: 63
diff changeset
799 if (result != operands[0])
kono
parents: 63
diff changeset
800 emit_move_insn (operands[0], result);
kono
parents: 63
diff changeset
801 DONE;
kono
parents: 63
diff changeset
802 })
kono
parents: 63
diff changeset
803
kono
parents: 63
diff changeset
804 (define_insn "atomic_bit_test_and_set<mode>_1"
kono
parents: 63
diff changeset
805 [(set (reg:CCC FLAGS_REG)
kono
parents: 63
diff changeset
806 (compare:CCC
kono
parents: 63
diff changeset
807 (unspec_volatile:SWI248
kono
parents: 63
diff changeset
808 [(match_operand:SWI248 0 "memory_operand" "+m")
kono
parents: 63
diff changeset
809 (match_operand:SI 2 "const_int_operand")] ;; model
kono
parents: 63
diff changeset
810 UNSPECV_XCHG)
kono
parents: 63
diff changeset
811 (const_int 0)))
kono
parents: 63
diff changeset
812 (set (zero_extract:SWI248 (match_dup 0)
kono
parents: 63
diff changeset
813 (const_int 1)
kono
parents: 63
diff changeset
814 (match_operand:SWI248 1 "nonmemory_operand" "rN"))
kono
parents: 63
diff changeset
815 (const_int 1))]
kono
parents: 63
diff changeset
816 ""
kono
parents: 63
diff changeset
817 "lock{%;} %K2bts{<imodesuffix>}\t{%1, %0|%0, %1}")
kono
parents: 63
diff changeset
818
kono
parents: 63
diff changeset
819 (define_expand "atomic_bit_test_and_complement<mode>"
kono
parents: 63
diff changeset
820 [(match_operand:SWI248 0 "register_operand")
kono
parents: 63
diff changeset
821 (match_operand:SWI248 1 "memory_operand")
kono
parents: 63
diff changeset
822 (match_operand:SWI248 2 "nonmemory_operand")
kono
parents: 63
diff changeset
823 (match_operand:SI 3 "const_int_operand") ;; model
kono
parents: 63
diff changeset
824 (match_operand:SI 4 "const_int_operand")]
kono
parents: 63
diff changeset
825 ""
kono
parents: 63
diff changeset
826 {
kono
parents: 63
diff changeset
827 emit_insn (gen_atomic_bit_test_and_complement<mode>_1 (operands[1],
kono
parents: 63
diff changeset
828 operands[2],
kono
parents: 63
diff changeset
829 operands[3]));
kono
parents: 63
diff changeset
830 rtx tem = gen_reg_rtx (QImode);
kono
parents: 63
diff changeset
831 ix86_expand_setcc (tem, EQ, gen_rtx_REG (CCCmode, FLAGS_REG), const0_rtx);
kono
parents: 63
diff changeset
832 rtx result = convert_modes (<MODE>mode, QImode, tem, 1);
kono
parents: 63
diff changeset
833 if (operands[4] == const0_rtx)
kono
parents: 63
diff changeset
834 result = expand_simple_binop (<MODE>mode, ASHIFT, result,
kono
parents: 63
diff changeset
835 operands[2], operands[0], 0, OPTAB_DIRECT);
kono
parents: 63
diff changeset
836 if (result != operands[0])
kono
parents: 63
diff changeset
837 emit_move_insn (operands[0], result);
kono
parents: 63
diff changeset
838 DONE;
kono
parents: 63
diff changeset
839 })
kono
parents: 63
diff changeset
840
kono
parents: 63
diff changeset
841 (define_insn "atomic_bit_test_and_complement<mode>_1"
kono
parents: 63
diff changeset
842 [(set (reg:CCC FLAGS_REG)
kono
parents: 63
diff changeset
843 (compare:CCC
kono
parents: 63
diff changeset
844 (unspec_volatile:SWI248
kono
parents: 63
diff changeset
845 [(match_operand:SWI248 0 "memory_operand" "+m")
kono
parents: 63
diff changeset
846 (match_operand:SI 2 "const_int_operand")] ;; model
kono
parents: 63
diff changeset
847 UNSPECV_XCHG)
kono
parents: 63
diff changeset
848 (const_int 0)))
kono
parents: 63
diff changeset
849 (set (zero_extract:SWI248 (match_dup 0)
kono
parents: 63
diff changeset
850 (const_int 1)
kono
parents: 63
diff changeset
851 (match_operand:SWI248 1 "nonmemory_operand" "rN"))
kono
parents: 63
diff changeset
852 (not:SWI248 (zero_extract:SWI248 (match_dup 0)
kono
parents: 63
diff changeset
853 (const_int 1)
kono
parents: 63
diff changeset
854 (match_dup 1))))]
kono
parents: 63
diff changeset
855 ""
kono
parents: 63
diff changeset
856 "lock{%;} %K2btc{<imodesuffix>}\t{%1, %0|%0, %1}")
kono
parents: 63
diff changeset
857
kono
parents: 63
diff changeset
858 (define_expand "atomic_bit_test_and_reset<mode>"
kono
parents: 63
diff changeset
859 [(match_operand:SWI248 0 "register_operand")
kono
parents: 63
diff changeset
860 (match_operand:SWI248 1 "memory_operand")
kono
parents: 63
diff changeset
861 (match_operand:SWI248 2 "nonmemory_operand")
kono
parents: 63
diff changeset
862 (match_operand:SI 3 "const_int_operand") ;; model
kono
parents: 63
diff changeset
863 (match_operand:SI 4 "const_int_operand")]
kono
parents: 63
diff changeset
864 ""
kono
parents: 63
diff changeset
865 {
kono
parents: 63
diff changeset
866 emit_insn (gen_atomic_bit_test_and_reset<mode>_1 (operands[1], operands[2],
kono
parents: 63
diff changeset
867 operands[3]));
kono
parents: 63
diff changeset
868 rtx tem = gen_reg_rtx (QImode);
kono
parents: 63
diff changeset
869 ix86_expand_setcc (tem, EQ, gen_rtx_REG (CCCmode, FLAGS_REG), const0_rtx);
kono
parents: 63
diff changeset
870 rtx result = convert_modes (<MODE>mode, QImode, tem, 1);
kono
parents: 63
diff changeset
871 if (operands[4] == const0_rtx)
kono
parents: 63
diff changeset
872 result = expand_simple_binop (<MODE>mode, ASHIFT, result,
kono
parents: 63
diff changeset
873 operands[2], operands[0], 0, OPTAB_DIRECT);
kono
parents: 63
diff changeset
874 if (result != operands[0])
kono
parents: 63
diff changeset
875 emit_move_insn (operands[0], result);
kono
parents: 63
diff changeset
876 DONE;
kono
parents: 63
diff changeset
877 })
kono
parents: 63
diff changeset
878
kono
parents: 63
diff changeset
879 (define_insn "atomic_bit_test_and_reset<mode>_1"
kono
parents: 63
diff changeset
880 [(set (reg:CCC FLAGS_REG)
kono
parents: 63
diff changeset
881 (compare:CCC
kono
parents: 63
diff changeset
882 (unspec_volatile:SWI248
kono
parents: 63
diff changeset
883 [(match_operand:SWI248 0 "memory_operand" "+m")
kono
parents: 63
diff changeset
884 (match_operand:SI 2 "const_int_operand")] ;; model
kono
parents: 63
diff changeset
885 UNSPECV_XCHG)
kono
parents: 63
diff changeset
886 (const_int 0)))
kono
parents: 63
diff changeset
887 (set (zero_extract:SWI248 (match_dup 0)
kono
parents: 63
diff changeset
888 (const_int 1)
kono
parents: 63
diff changeset
889 (match_operand:SWI248 1 "nonmemory_operand" "rN"))
kono
parents: 63
diff changeset
890 (const_int 0))]
kono
parents: 63
diff changeset
891 ""
kono
parents: 63
diff changeset
892 "lock{%;} %K2btr{<imodesuffix>}\t{%1, %0|%0, %1}")