1;;- Machine description for GNU compiler -- S/390 / zSeries version.
2;;  Subst patterns.
3;;  Copyright (C) 2016-2022 Free Software Foundation, Inc.
4;;  Contributed by Andreas Krebbel (Andreas.Krebbel@de.ibm.com)
5
6;; This file is part of GCC.
7
8;; GCC is free software; you can redistribute it and/or modify it under
9;; the terms of the GNU General Public License as published by the Free
10;; Software Foundation; either version 3, or (at your option) any later
11;; version.
12
13;; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14;; WARRANTY; without even the implied warranty of MERCHANTABILITY or
15;; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16;; for more details.
17
18;; You should have received a copy of the GNU General Public License
19;; along with GCC; see the file COPYING3.  If not see
20;; <http://www.gnu.org/licenses/>.
21
22(define_code_iterator SUBST [rotate ashift lshiftrt ashiftrt])
23(define_mode_iterator DSI_VI [SI DI V2QI V4QI V8QI V16QI V2HI V4HI V8HI V2SI V4SI V2DI])
24
25; This adds an explicit CC reg set to an operation while keeping the
26; set for the operation result as well.
27(define_subst "setcc_subst"
28  [(set (match_operand:DSI 0 ""           "")
29        (match_operand:DSI 1 "" ""))
30   (clobber (reg:CC CC_REGNUM))]
31  "s390_match_ccmode(insn, CCSmode)"
32  [(set (reg CC_REGNUM)
33	(compare (match_dup 1) (const_int 0)))
34   (set (match_dup 0) (match_dup 1))])
35
36; Use this in the insn name.
37(define_subst_attr "setcc" "setcc_subst" "" "_cc")
38
39; This adds an explicit CC reg set to an operation while dropping the
40; result of the operation.
41(define_subst "cconly_subst"
42  [(set (match_operand:DSI 0 ""           "")
43        (match_operand:DSI 1 "" ""))
44   (clobber (reg:CC CC_REGNUM))]
45  "s390_match_ccmode(insn, CCSmode)"
46  [(set (reg CC_REGNUM)
47	(compare (match_dup 1) (const_int 0)))
48   (clobber (match_scratch:DSI 0 "=d"))])
49
50(define_subst_attr "cconly" "cconly_subst" "" "_cconly")
51
52
53; Does transformations to switch between patterns unsing risbg +
54; clobber CC (z10) and risbgn without clobber (zEC12).
55(define_subst "clobbercc_or_nocc_subst"
56  [(set (match_operand 0 "" "") (match_operand 1 "" ""))]
57  ""
58  [(set (match_dup 0) (match_dup 1))
59   (clobber (reg:CC CC_REGNUM))])
60
61; Use this in the insn name to add the target suffix.
62(define_subst_attr "clobbercc_or_nocc" "clobbercc_or_nocc_subst"
63  "_nocc" "_clobbercc")
64
65; Use this in the condition.
66(define_subst_attr "z10_or_zEC12_cond" "clobbercc_or_nocc_subst"
67  "TARGET_ZEC12" "TARGET_Z10 && ! TARGET_ZEC12")
68
69; Use this instead of the risbg instruction.
70(define_subst_attr "risbg_n" "clobbercc_or_nocc_subst"
71  "risbgn" "risbg")
72