aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/config/rs6000/htm.md
blob: ca7f7fdf4fb720f8dd8a7e92afb7e4eb765d6c57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
;; Hardware Transactional Memory (HTM) patterns.
;; Copyright (C) 2013-2014 Free Software Foundation, Inc.
;; Contributed by Peter Bergner <bergner@vnet.ibm.com>.

;; This file is part of GCC.

;; GCC is free software; you can redistribute it and/or modify it
;; under the terms of the GNU General Public License as published
;; by the Free Software Foundation; either version 3, or (at your
;; option) any later version.

;; GCC is distributed in the hope that it will be useful, but WITHOUT
;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
;; or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
;; License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GCC; see the file COPYING3.  If not see
;; <http://www.gnu.org/licenses/>.

(define_constants
  [(TFHAR_SPR		128)
   (TFIAR_SPR		129)
   (TEXASR_SPR		130)
   (TEXASRU_SPR		131)
   (MAX_HTM_OPERANDS	4)
  ])

;;
;; UNSPEC_VOLATILE usage
;;

(define_c_enum "unspecv"
  [UNSPECV_HTM_TABORT
   UNSPECV_HTM_TABORTDC
   UNSPECV_HTM_TABORTDCI
   UNSPECV_HTM_TABORTWC
   UNSPECV_HTM_TABORTWCI
   UNSPECV_HTM_TBEGIN
   UNSPECV_HTM_TCHECK
   UNSPECV_HTM_TEND
   UNSPECV_HTM_TRECHKPT
   UNSPECV_HTM_TRECLAIM
   UNSPECV_HTM_TSR
   UNSPECV_HTM_MFSPR
   UNSPECV_HTM_MTSPR
  ])


(define_expand "tabort"
  [(set (match_dup 2)
	(unspec_volatile:CC [(match_operand:SI 1 "int_reg_operand" "")]
			    UNSPECV_HTM_TABORT))
   (set (match_dup 3)
	(eq:SI (match_dup 2)
	       (const_int 0)))
   (set (match_operand:SI 0 "int_reg_operand" "")
	(minus:SI (const_int 1) (match_dup 3)))]
  "TARGET_HTM"
{
  operands[2] = gen_rtx_REG (CCmode, CR0_REGNO);
  operands[3] = gen_reg_rtx (SImode);
})

(define_insn "*tabort_internal"
  [(set (match_operand:CC 1 "cc_reg_operand" "=x")
	(unspec_volatile:CC [(match_operand:SI 0 "int_reg_operand" "r")]
			    UNSPECV_HTM_TABORT))]
  "TARGET_HTM"
  "tabort. %0"
  [(set_attr "type" "htm")
   (set_attr "length" "4")])

(define_expand "tabortdc"
  [(set (match_dup 4)
	(unspec_volatile:CC [(match_operand 1 "u5bit_cint_operand" "n")
			     (match_operand:SI 2 "gpc_reg_operand" "r")
			     (match_operand:SI 3 "gpc_reg_operand" "r")]
			    UNSPECV_HTM_TABORTDC))
   (set (match_dup 5)
	(eq:SI (match_dup 4)
	       (const_int 0)))
   (set (match_operand:SI 0 "int_reg_operand" "")
	(minus:SI (const_int 1) (match_dup 5)))]
  "TARGET_HTM"
{
  operands[4] = gen_rtx_REG (CCmode, CR0_REGNO);
  operands[5] = gen_reg_rtx (SImode);
})

(define_insn "*tabortdc_internal"
  [(set (match_operand:CC 3 "cc_reg_operand" "=x")
	(unspec_volatile:CC [(match_operand 0 "u5bit_cint_operand" "n")
			     (match_operand:SI 1 "gpc_reg_operand" "r")
			     (match_operand:SI 2 "gpc_reg_operand" "r")]
			    UNSPECV_HTM_TABORTDC))]
  "TARGET_HTM"
  "tabortdc. %0,%1,%2"
  [(set_attr "type" "htm")
   (set_attr "length" "4")])

(define_expand "tabortdci"
  [(set (match_dup 4)
	(unspec_volatile:CC [(match_operand 1 "u5bit_cint_operand" "n")
			     (match_operand:SI 2 "gpc_reg_operand" "r")
			     (match_operand 3 "s5bit_cint_operand" "n")]
			    UNSPECV_HTM_TABORTDCI))
   (set (match_dup 5)
	(eq:SI (match_dup 4)
	       (const_int 0)))
   (set (match_operand:SI 0 "int_reg_operand" "")
	(minus:SI (const_int 1) (match_dup 5)))]
  "TARGET_HTM"
{
  operands[4] = gen_rtx_REG (CCmode, CR0_REGNO);
  operands[5] = gen_reg_rtx (SImode);
})

(define_insn "*tabortdci_internal"
  [(set (match_operand:CC 3 "cc_reg_operand" "=x")
	(unspec_volatile:CC [(match_operand 0 "u5bit_cint_operand" "n")
			     (match_operand:SI 1 "gpc_reg_operand" "r")
			     (match_operand 2 "s5bit_cint_operand" "n")]
			    UNSPECV_HTM_TABORTDCI))]
  "TARGET_HTM"
  "tabortdci. %0,%1,%2"
  [(set_attr "type" "htm")
   (set_attr "length" "4")])

(define_expand "tabortwc"
  [(set (match_dup 4)
	(unspec_volatile:CC [(match_operand 1 "u5bit_cint_operand" "n")
			     (match_operand:SI 2 "gpc_reg_operand" "r")
			     (match_operand:SI 3 "gpc_reg_operand" "r")]
			    UNSPECV_HTM_TABORTWC))
   (set (match_dup 5)
	(eq:SI (match_dup 4)
	       (const_int 0)))
   (set (match_operand:SI 0 "int_reg_operand" "")
	(minus:SI (const_int 1) (match_dup 5)))]
  "TARGET_HTM"
{
  operands[4] = gen_rtx_REG (CCmode, CR0_REGNO);
  operands[5] = gen_reg_rtx (SImode);
})

(define_insn "*tabortwc_internal"
  [(set (match_operand:CC 3 "cc_reg_operand" "=x")
	(unspec_volatile:CC [(match_operand 0 "u5bit_cint_operand" "n")
			     (match_operand:SI 1 "gpc_reg_operand" "r")
			     (match_operand:SI 2 "gpc_reg_operand" "r")]
			    UNSPECV_HTM_TABORTWC))]
  "TARGET_HTM"
  "tabortwc. %0,%1,%2"
  [(set_attr "type" "htm")
   (set_attr "length" "4")])

(define_expand "tabortwci"
  [(set (match_dup 4)
	(unspec_volatile:CC [(match_operand 1 "u5bit_cint_operand" "n")
			     (match_operand:SI 2 "gpc_reg_operand" "r")
			     (match_operand 3 "s5bit_cint_operand" "n")]
			    UNSPECV_HTM_TABORTWCI))
   (set (match_dup 5)
	(eq:SI (match_dup 4)
	       (const_int 0)))
   (set (match_operand:SI 0 "int_reg_operand" "")
	(minus:SI (const_int 1) (match_dup 5)))]
  "TARGET_HTM"
{
  operands[4] = gen_rtx_REG (CCmode, CR0_REGNO);
  operands[5] = gen_reg_rtx (SImode);
})

(define_expand "ttest"
  [(set (match_dup 1)
	(unspec_volatile:CC [(const_int 0)
			     (reg:SI 0)
			     (const_int 0)]
			    UNSPECV_HTM_TABORTWCI))
   (set (subreg:CC (match_dup 2) 0) (match_dup 1))
   (set (match_dup 3) (lshiftrt:SI (match_dup 2) (const_int 28)))
   (parallel [(set (match_operand:SI 0 "int_reg_operand" "")
		   (and:SI (match_dup 3) (const_int 15)))
              (clobber (scratch:CC))])]
  "TARGET_HTM"
{
  operands[1] = gen_rtx_REG (CCmode, CR0_REGNO);
  operands[2] = gen_reg_rtx (SImode);
  operands[3] = gen_reg_rtx (SImode);
})

(define_insn "*tabortwci_internal"
  [(set (match_operand:CC 3 "cc_reg_operand" "=x")
	(unspec_volatile:CC [(match_operand 0 "u5bit_cint_operand" "n")
			     (match_operand:SI 1 "gpc_reg_operand" "r")
			     (match_operand 2 "s5bit_cint_operand" "n")]
			    UNSPECV_HTM_TABORTWCI))]
  "TARGET_HTM"
  "tabortwci. %0,%1,%2"
  [(set_attr "type" "htm")
   (set_attr "length" "4")])

(define_expand "tbegin"
  [(set (match_dup 2)
	(unspec_volatile:CC [(match_operand 1 "const_0_to_1_operand" "n")]
			    UNSPECV_HTM_TBEGIN))
   (set (match_dup 3)
	(eq:SI (match_dup 2)
	       (const_int 0)))
   (set (match_operand:SI 0 "int_reg_operand" "")
	(minus:SI (const_int 1) (match_dup 3)))]
  "TARGET_HTM"
{
  operands[2] = gen_rtx_REG (CCmode, CR0_REGNO);
  operands[3] = gen_reg_rtx (SImode);
})

(define_insn "*tbegin_internal"
  [(set (match_operand:CC 1 "cc_reg_operand" "=x")
	(unspec_volatile:CC [(match_operand 0 "const_0_to_1_operand" "n")]
			    UNSPECV_HTM_TBEGIN))]
  "TARGET_HTM"
  "tbegin. %0"
  [(set_attr "type" "htm")
   (set_attr "length" "4")])

(define_expand "tcheck"
  [(set (match_dup 2)
	(unspec_volatile:CC [(match_operand 1 "u3bit_cint_operand" "n")]
			    UNSPECV_HTM_TCHECK))
   (set (match_dup 3)
	(eq:SI (match_dup 2)
	       (const_int 0)))
   (set (match_operand:SI 0 "int_reg_operand" "")
	(minus:SI (const_int 1) (match_dup 3)))]
  "TARGET_HTM"
{
  operands[2] = gen_rtx_REG (CCmode, CR0_REGNO);
  operands[3] = gen_reg_rtx (SImode);
})

(define_insn "*tcheck_internal"
  [(set (match_operand:CC 1 "cc_reg_operand" "=x")
	(unspec_volatile:CC [(match_operand 0 "u3bit_cint_operand" "n")]
			    UNSPECV_HTM_TCHECK))]
  "TARGET_HTM"
  "tcheck. %0"
  [(set_attr "type" "htm")
   (set_attr "length" "4")])

(define_expand "tend"
  [(set (match_dup 2)
	(unspec_volatile:CC [(match_operand 1 "const_0_to_1_operand" "n")]
			    UNSPECV_HTM_TEND))
   (set (match_dup 3)
	(eq:SI (match_dup 2)
	       (const_int 0)))
   (set (match_operand:SI 0 "int_reg_operand" "")
	(minus:SI (const_int 1) (match_dup 3)))]
  "TARGET_HTM"
{
  operands[2] = gen_rtx_REG (CCmode, CR0_REGNO);
  operands[3] = gen_reg_rtx (SImode);
})

(define_insn "*tend_internal"
  [(set (match_operand:CC 1 "cc_reg_operand" "=x")
	(unspec_volatile:CC [(match_operand 0 "const_0_to_1_operand" "n")]
			    UNSPECV_HTM_TEND))]
  "TARGET_HTM"
  "tend. %0"
  [(set_attr "type" "htm")
   (set_attr "length" "4")])

(define_expand "trechkpt"
  [(set (match_dup 1)
	(unspec_volatile:CC [(const_int 0)]
			    UNSPECV_HTM_TRECHKPT))
   (set (match_dup 2)
	(eq:SI (match_dup 1)
	       (const_int 0)))
   (set (match_operand:SI 0 "int_reg_operand" "")
	(minus:SI (const_int 1) (match_dup 2)))]
  "TARGET_HTM"
{
  operands[1] = gen_rtx_REG (CCmode, CR0_REGNO);
  operands[2] = gen_reg_rtx (SImode);
})

(define_insn "*trechkpt_internal"
  [(set (match_operand:CC 0 "cc_reg_operand" "=x")
	(unspec_volatile:CC [(const_int 0)]
			    UNSPECV_HTM_TRECHKPT))]
  "TARGET_HTM"
  "trechkpt."
  [(set_attr "type" "htm")
   (set_attr "length" "4")])

(define_expand "treclaim"
  [(set (match_dup 2)
	(unspec_volatile:CC [(match_operand:SI 1 "gpc_reg_operand" "r")]
			    UNSPECV_HTM_TRECLAIM))
   (set (match_dup 3)
	(eq:SI (match_dup 2)
	       (const_int 0)))
   (set (match_operand:SI 0 "int_reg_operand" "")
	(minus:SI (const_int 1) (match_dup 3)))]
  "TARGET_HTM"
{
  operands[2] = gen_rtx_REG (CCmode, CR0_REGNO);
  operands[3] = gen_reg_rtx (SImode);
})

(define_insn "*treclaim_internal"
  [(set (match_operand:CC 1 "cc_reg_operand" "=x")
	(unspec_volatile:CC [(match_operand:SI 0 "gpc_reg_operand" "r")]
			    UNSPECV_HTM_TRECLAIM))]
  "TARGET_HTM"
  "treclaim. %0"
  [(set_attr "type" "htm")
   (set_attr "length" "4")])

(define_expand "tsr"
  [(set (match_dup 2)
	(unspec_volatile:CC [(match_operand 1 "const_0_to_1_operand" "n")]
			    UNSPECV_HTM_TSR))
   (set (match_dup 3)
	(eq:SI (match_dup 2)
	       (const_int 0)))
   (set (match_operand:SI 0 "int_reg_operand" "")
	(minus:SI (const_int 1) (match_dup 3)))]
  "TARGET_HTM"
{
  operands[2] = gen_rtx_REG (CCmode, CR0_REGNO);
  operands[3] = gen_reg_rtx (SImode);
})

(define_insn "*tsr_internal"
  [(set (match_operand:CC 1 "cc_reg_operand" "=x")
	(unspec_volatile:CC [(match_operand 0 "const_0_to_1_operand" "n")]
			    UNSPECV_HTM_TSR))]
  "TARGET_HTM"
  "tsr. %0"
  [(set_attr "type" "htm")
   (set_attr "length" "4")])

(define_insn "htm_mfspr_<mode>"
  [(set (match_operand:P 0 "gpc_reg_operand" "=r")
        (unspec_volatile:P [(match_operand 1 "u10bit_cint_operand" "n")
			    (match_operand:P 2 "htm_spr_reg_operand" "")]
			   UNSPECV_HTM_MFSPR))]
  "TARGET_HTM"
  "mfspr %0,%1";
  [(set_attr "type" "htm")
   (set_attr "length" "4")])

(define_insn "htm_mtspr_<mode>"
  [(set (match_operand:P 2 "htm_spr_reg_operand" "")
        (unspec_volatile:P [(match_operand:P 0 "gpc_reg_operand" "r")
			    (match_operand 1 "u10bit_cint_operand" "n")]
                           UNSPECV_HTM_MTSPR))]
  "TARGET_HTM"
  "mtspr %1,%0";
  [(set_attr "type" "htm")
   (set_attr "length" "4")])