1 ;; Hardware Transactional Memory (HTM) patterns.
2 ;; Copyright (C) 2013-2017 Free Software Foundation, Inc.
3 ;; Contributed by Peter Bergner <bergner@vnet.ibm.com>.
5 ;; This file is part of GCC.
7 ;; GCC is free software; you can redistribute it and/or modify it
8 ;; under the terms of the GNU General Public License as published
9 ;; by the Free Software Foundation; either version 3, or (at your
10 ;; option) any later version.
12 ;; GCC is distributed in the hope that it will be useful, but WITHOUT
13 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 ;; License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GCC; see the file COPYING3. If not see
19 ;; <http://www.gnu.org/licenses/>.
33 (define_c_enum "unspec"
38 ;; UNSPEC_VOLATILE usage
41 (define_c_enum "unspecv"
56 (define_expand "tabort"
58 [(set (match_operand:CC 1 "cc_reg_operand" "=x")
59 (unspec_volatile:CC [(match_operand:SI 0 "base_reg_operand" "b")]
61 (set (match_dup 2) (unspec:BLK [(match_dup 2)] UNSPEC_HTM_FENCE))])]
64 operands[2] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
65 MEM_VOLATILE_P (operands[2]) = 1;
68 (define_insn "*tabort"
69 [(set (match_operand:CC 1 "cc_reg_operand" "=x")
70 (unspec_volatile:CC [(match_operand:SI 0 "base_reg_operand" "b")]
72 (set (match_operand:BLK 2) (unspec:BLK [(match_dup 2)] UNSPEC_HTM_FENCE))]
75 [(set_attr "type" "htmsimple")
76 (set_attr "length" "4")])
78 (define_expand "tabort<wd>c"
80 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
81 (unspec_volatile:CC [(match_operand 0 "u5bit_cint_operand" "n")
82 (match_operand:GPR 1 "gpc_reg_operand" "r")
83 (match_operand:GPR 2 "gpc_reg_operand" "r")]
84 UNSPECV_HTM_TABORTXC))
85 (set (match_dup 4) (unspec:BLK [(match_dup 4)] UNSPEC_HTM_FENCE))])]
88 operands[4] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
89 MEM_VOLATILE_P (operands[4]) = 1;
92 (define_insn "*tabort<wd>c"
93 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
94 (unspec_volatile:CC [(match_operand 0 "u5bit_cint_operand" "n")
95 (match_operand:GPR 1 "gpc_reg_operand" "r")
96 (match_operand:GPR 2 "gpc_reg_operand" "r")]
97 UNSPECV_HTM_TABORTXC))
98 (set (match_operand:BLK 4) (unspec:BLK [(match_dup 4)] UNSPEC_HTM_FENCE))]
100 "tabort<wd>c. %0,%1,%2"
101 [(set_attr "type" "htmsimple")
102 (set_attr "length" "4")])
104 (define_expand "tabort<wd>ci"
106 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
107 (unspec_volatile:CC [(match_operand 0 "u5bit_cint_operand" "n")
108 (match_operand:GPR 1 "gpc_reg_operand" "r")
109 (match_operand 2 "s5bit_cint_operand" "n")]
110 UNSPECV_HTM_TABORTXCI))
111 (set (match_dup 4) (unspec:BLK [(match_dup 4)] UNSPEC_HTM_FENCE))])]
114 operands[4] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
115 MEM_VOLATILE_P (operands[4]) = 1;
118 (define_insn "*tabort<wd>ci"
119 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
120 (unspec_volatile:CC [(match_operand 0 "u5bit_cint_operand" "n")
121 (match_operand:GPR 1 "gpc_reg_operand" "r")
122 (match_operand 2 "s5bit_cint_operand" "n")]
123 UNSPECV_HTM_TABORTXCI))
124 (set (match_operand:BLK 4) (unspec:BLK [(match_dup 4)] UNSPEC_HTM_FENCE))]
126 "tabort<wd>ci. %0,%1,%2"
127 [(set_attr "type" "htmsimple")
128 (set_attr "length" "4")])
130 (define_expand "tbegin"
132 [(set (match_operand:CC 1 "cc_reg_operand" "=x")
133 (unspec_volatile:CC [(match_operand 0 "const_0_to_1_operand" "n")]
135 (set (match_dup 2) (unspec:BLK [(match_dup 2)] UNSPEC_HTM_FENCE))])]
138 operands[2] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
139 MEM_VOLATILE_P (operands[2]) = 1;
142 (define_insn "*tbegin"
143 [(set (match_operand:CC 1 "cc_reg_operand" "=x")
144 (unspec_volatile:CC [(match_operand 0 "const_0_to_1_operand" "n")]
146 (set (match_operand:BLK 2) (unspec:BLK [(match_dup 2)] UNSPEC_HTM_FENCE))]
149 [(set_attr "type" "htm")
150 (set_attr "length" "4")])
152 (define_expand "tcheck"
154 [(set (match_operand:CC 0 "cc_reg_operand" "=y")
155 (unspec_volatile:CC [(const_int 0)] UNSPECV_HTM_TCHECK))
156 (set (match_dup 1) (unspec:BLK [(match_dup 1)] UNSPEC_HTM_FENCE))])]
159 operands[1] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
160 MEM_VOLATILE_P (operands[1]) = 1;
163 (define_insn "*tcheck"
164 [(set (match_operand:CC 0 "cc_reg_operand" "=y")
165 (unspec_volatile:CC [(const_int 0)] UNSPECV_HTM_TCHECK))
166 (set (match_operand:BLK 1) (unspec:BLK [(match_dup 1)] UNSPEC_HTM_FENCE))]
169 [(set_attr "type" "htm")
170 (set_attr "length" "4")])
172 (define_expand "tend"
174 [(set (match_operand:CC 1 "cc_reg_operand" "=x")
175 (unspec_volatile:CC [(match_operand 0 "const_0_to_1_operand" "n")]
177 (set (match_dup 2) (unspec:BLK [(match_dup 2)] UNSPEC_HTM_FENCE))])]
180 operands[2] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
181 MEM_VOLATILE_P (operands[2]) = 1;
185 [(set (match_operand:CC 1 "cc_reg_operand" "=x")
186 (unspec_volatile:CC [(match_operand 0 "const_0_to_1_operand" "n")]
188 (set (match_operand:BLK 2) (unspec:BLK [(match_dup 2)] UNSPEC_HTM_FENCE))]
191 [(set_attr "type" "htm")
192 (set_attr "length" "4")])
194 (define_expand "trechkpt"
196 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
197 (unspec_volatile:CC [(const_int 0)] UNSPECV_HTM_TRECHKPT))
198 (set (match_dup 1) (unspec:BLK [(match_dup 1)] UNSPEC_HTM_FENCE))])]
201 operands[1] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
202 MEM_VOLATILE_P (operands[1]) = 1;
205 (define_insn "*trechkpt"
206 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
207 (unspec_volatile:CC [(const_int 0)] UNSPECV_HTM_TRECHKPT))
208 (set (match_operand:BLK 1) (unspec:BLK [(match_dup 1)] UNSPEC_HTM_FENCE))]
211 [(set_attr "type" "htmsimple")
212 (set_attr "length" "4")])
214 (define_expand "treclaim"
216 [(set (match_operand:CC 1 "cc_reg_operand" "=x")
217 (unspec_volatile:CC [(match_operand:SI 0 "gpc_reg_operand" "r")]
218 UNSPECV_HTM_TRECLAIM))
219 (set (match_dup 2) (unspec:BLK [(match_dup 2)] UNSPEC_HTM_FENCE))])]
222 operands[2] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
223 MEM_VOLATILE_P (operands[2]) = 1;
226 (define_insn "*treclaim"
227 [(set (match_operand:CC 1 "cc_reg_operand" "=x")
228 (unspec_volatile:CC [(match_operand:SI 0 "gpc_reg_operand" "r")]
229 UNSPECV_HTM_TRECLAIM))
230 (set (match_operand:BLK 2) (unspec:BLK [(match_dup 2)] UNSPEC_HTM_FENCE))]
233 [(set_attr "type" "htmsimple")
234 (set_attr "length" "4")])
238 [(set (match_operand:CC 1 "cc_reg_operand" "=x")
239 (unspec_volatile:CC [(match_operand 0 "const_0_to_1_operand" "n")]
241 (set (match_dup 2) (unspec:BLK [(match_dup 2)] UNSPEC_HTM_FENCE))])]
244 operands[2] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
245 MEM_VOLATILE_P (operands[2]) = 1;
249 [(set (match_operand:CC 1 "cc_reg_operand" "=x")
250 (unspec_volatile:CC [(match_operand 0 "const_0_to_1_operand" "n")]
252 (set (match_operand:BLK 2) (unspec:BLK [(match_dup 2)] UNSPEC_HTM_FENCE))]
255 [(set_attr "type" "htmsimple")
256 (set_attr "length" "4")])
258 (define_expand "ttest"
260 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
261 (unspec_volatile:CC [(const_int 0)] UNSPECV_HTM_TTEST))
262 (set (match_dup 1) (unspec:BLK [(match_dup 1)] UNSPEC_HTM_FENCE))])]
265 operands[1] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
266 MEM_VOLATILE_P (operands[1]) = 1;
269 (define_insn "*ttest"
270 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
271 (unspec_volatile:CC [(const_int 0)] UNSPECV_HTM_TTEST))
272 (set (match_operand:BLK 1) (unspec:BLK [(match_dup 1)] UNSPEC_HTM_FENCE))]
275 [(set_attr "type" "htmsimple")
276 (set_attr "length" "4")])
278 (define_insn "htm_mfspr_<mode>"
279 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
280 (unspec_volatile:GPR [(match_operand 1 "u10bit_cint_operand" "n")
281 (match_operand:GPR 2 "htm_spr_reg_operand" "")]
285 [(set_attr "type" "htm")
286 (set_attr "length" "4")])
288 (define_insn "htm_mtspr_<mode>"
289 [(set (match_operand:GPR 2 "htm_spr_reg_operand" "")
290 (unspec_volatile:GPR [(match_operand:GPR 0 "gpc_reg_operand" "r")
291 (match_operand 1 "u10bit_cint_operand" "n")]
295 [(set_attr "type" "htm")
296 (set_attr "length" "4")])