1 ;; Hardware Transactional Memory (HTM) patterns.
2 ;; Copyright (C) 2013-2018 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")])
77 (define_expand "tabort<wd>c"
79 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
80 (unspec_volatile:CC [(match_operand 0 "u5bit_cint_operand" "n")
81 (match_operand:GPR 1 "gpc_reg_operand" "r")
82 (match_operand:GPR 2 "gpc_reg_operand" "r")]
83 UNSPECV_HTM_TABORTXC))
84 (set (match_dup 4) (unspec:BLK [(match_dup 4)] UNSPEC_HTM_FENCE))])]
87 operands[4] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
88 MEM_VOLATILE_P (operands[4]) = 1;
91 (define_insn "*tabort<wd>c"
92 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
93 (unspec_volatile:CC [(match_operand 0 "u5bit_cint_operand" "n")
94 (match_operand:GPR 1 "gpc_reg_operand" "r")
95 (match_operand:GPR 2 "gpc_reg_operand" "r")]
96 UNSPECV_HTM_TABORTXC))
97 (set (match_operand:BLK 4) (unspec:BLK [(match_dup 4)] UNSPEC_HTM_FENCE))]
99 "tabort<wd>c. %0,%1,%2"
100 [(set_attr "type" "htmsimple")])
102 (define_expand "tabort<wd>ci"
104 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
105 (unspec_volatile:CC [(match_operand 0 "u5bit_cint_operand" "n")
106 (match_operand:GPR 1 "gpc_reg_operand" "r")
107 (match_operand 2 "s5bit_cint_operand" "n")]
108 UNSPECV_HTM_TABORTXCI))
109 (set (match_dup 4) (unspec:BLK [(match_dup 4)] UNSPEC_HTM_FENCE))])]
112 operands[4] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
113 MEM_VOLATILE_P (operands[4]) = 1;
116 (define_insn "*tabort<wd>ci"
117 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
118 (unspec_volatile:CC [(match_operand 0 "u5bit_cint_operand" "n")
119 (match_operand:GPR 1 "gpc_reg_operand" "r")
120 (match_operand 2 "s5bit_cint_operand" "n")]
121 UNSPECV_HTM_TABORTXCI))
122 (set (match_operand:BLK 4) (unspec:BLK [(match_dup 4)] UNSPEC_HTM_FENCE))]
124 "tabort<wd>ci. %0,%1,%2"
125 [(set_attr "type" "htmsimple")])
127 (define_expand "tbegin"
129 [(set (match_operand:CC 1 "cc_reg_operand" "=x")
130 (unspec_volatile:CC [(match_operand 0 "const_0_to_1_operand" "n")]
132 (set (match_dup 2) (unspec:BLK [(match_dup 2)] UNSPEC_HTM_FENCE))])]
135 operands[2] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
136 MEM_VOLATILE_P (operands[2]) = 1;
139 (define_insn "*tbegin"
140 [(set (match_operand:CC 1 "cc_reg_operand" "=x")
141 (unspec_volatile:CC [(match_operand 0 "const_0_to_1_operand" "n")]
143 (set (match_operand:BLK 2) (unspec:BLK [(match_dup 2)] UNSPEC_HTM_FENCE))]
146 [(set_attr "type" "htm")])
148 (define_expand "tcheck"
150 [(set (match_operand:CC 0 "cc_reg_operand" "=y")
151 (unspec_volatile:CC [(const_int 0)] UNSPECV_HTM_TCHECK))
152 (set (match_dup 1) (unspec:BLK [(match_dup 1)] UNSPEC_HTM_FENCE))])]
155 operands[1] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
156 MEM_VOLATILE_P (operands[1]) = 1;
159 (define_insn "*tcheck"
160 [(set (match_operand:CC 0 "cc_reg_operand" "=y")
161 (unspec_volatile:CC [(const_int 0)] UNSPECV_HTM_TCHECK))
162 (set (match_operand:BLK 1) (unspec:BLK [(match_dup 1)] UNSPEC_HTM_FENCE))]
165 [(set_attr "type" "htm")])
167 (define_expand "tend"
169 [(set (match_operand:CC 1 "cc_reg_operand" "=x")
170 (unspec_volatile:CC [(match_operand 0 "const_0_to_1_operand" "n")]
172 (set (match_dup 2) (unspec:BLK [(match_dup 2)] UNSPEC_HTM_FENCE))])]
175 operands[2] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
176 MEM_VOLATILE_P (operands[2]) = 1;
180 [(set (match_operand:CC 1 "cc_reg_operand" "=x")
181 (unspec_volatile:CC [(match_operand 0 "const_0_to_1_operand" "n")]
183 (set (match_operand:BLK 2) (unspec:BLK [(match_dup 2)] UNSPEC_HTM_FENCE))]
186 [(set_attr "type" "htm")])
188 (define_expand "trechkpt"
190 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
191 (unspec_volatile:CC [(const_int 0)] UNSPECV_HTM_TRECHKPT))
192 (set (match_dup 1) (unspec:BLK [(match_dup 1)] UNSPEC_HTM_FENCE))])]
195 operands[1] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
196 MEM_VOLATILE_P (operands[1]) = 1;
199 (define_insn "*trechkpt"
200 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
201 (unspec_volatile:CC [(const_int 0)] UNSPECV_HTM_TRECHKPT))
202 (set (match_operand:BLK 1) (unspec:BLK [(match_dup 1)] UNSPEC_HTM_FENCE))]
205 [(set_attr "type" "htmsimple")])
207 (define_expand "treclaim"
209 [(set (match_operand:CC 1 "cc_reg_operand" "=x")
210 (unspec_volatile:CC [(match_operand:SI 0 "gpc_reg_operand" "r")]
211 UNSPECV_HTM_TRECLAIM))
212 (set (match_dup 2) (unspec:BLK [(match_dup 2)] UNSPEC_HTM_FENCE))])]
215 operands[2] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
216 MEM_VOLATILE_P (operands[2]) = 1;
219 (define_insn "*treclaim"
220 [(set (match_operand:CC 1 "cc_reg_operand" "=x")
221 (unspec_volatile:CC [(match_operand:SI 0 "gpc_reg_operand" "r")]
222 UNSPECV_HTM_TRECLAIM))
223 (set (match_operand:BLK 2) (unspec:BLK [(match_dup 2)] UNSPEC_HTM_FENCE))]
226 [(set_attr "type" "htmsimple")])
230 [(set (match_operand:CC 1 "cc_reg_operand" "=x")
231 (unspec_volatile:CC [(match_operand 0 "const_0_to_1_operand" "n")]
233 (set (match_dup 2) (unspec:BLK [(match_dup 2)] UNSPEC_HTM_FENCE))])]
236 operands[2] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
237 MEM_VOLATILE_P (operands[2]) = 1;
241 [(set (match_operand:CC 1 "cc_reg_operand" "=x")
242 (unspec_volatile:CC [(match_operand 0 "const_0_to_1_operand" "n")]
244 (set (match_operand:BLK 2) (unspec:BLK [(match_dup 2)] UNSPEC_HTM_FENCE))]
247 [(set_attr "type" "htmsimple")])
249 (define_expand "ttest"
251 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
252 (unspec_volatile:CC [(const_int 0)] UNSPECV_HTM_TTEST))
253 (set (match_dup 1) (unspec:BLK [(match_dup 1)] UNSPEC_HTM_FENCE))])]
256 operands[1] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
257 MEM_VOLATILE_P (operands[1]) = 1;
260 (define_insn "*ttest"
261 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
262 (unspec_volatile:CC [(const_int 0)] UNSPECV_HTM_TTEST))
263 (set (match_operand:BLK 1) (unspec:BLK [(match_dup 1)] UNSPEC_HTM_FENCE))]
266 [(set_attr "type" "htmsimple")])
268 (define_insn "htm_mfspr_<mode>"
269 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
270 (unspec_volatile:GPR [(match_operand 1 "u10bit_cint_operand" "n")
271 (match_operand:GPR 2 "htm_spr_reg_operand" "")]
275 [(set_attr "type" "htm")])
277 (define_insn "htm_mtspr_<mode>"
278 [(set (match_operand:GPR 2 "htm_spr_reg_operand" "")
279 (unspec_volatile:GPR [(match_operand:GPR 0 "gpc_reg_operand" "r")
280 (match_operand 1 "u10bit_cint_operand" "n")]
284 [(set_attr "type" "htm")])